Branch data Line data Source code
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/AccessibleRole.hpp>
21 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
22 : : #include <com/sun/star/accessibility/AccessibleTextType.hpp>
23 : : #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
24 : : #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
25 : : #include <com/sun/star/awt/FocusEvent.hpp>
26 : : #include <com/sun/star/awt/XFocusListener.hpp>
27 : : #include <unotools/accessiblerelationsethelper.hxx>
28 : :
29 : :
30 : : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
31 : : #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
32 : : #include <com/sun/star/i18n/WordType.hpp>
33 : : #include <unotools/accessiblestatesethelper.hxx>
34 : : #include <comphelper/accessibleeventnotifier.hxx>
35 : : #include <osl/diagnose.h>
36 : : #include <vcl/svapp.hxx>
37 : : #include <vcl/window.hxx>
38 : : #include <vcl/unohelp2.hxx>
39 : : #include <tools/gen.hxx>
40 : : #include <osl/mutex.hxx>
41 : : #include <svl/itemset.hxx>
42 : :
43 : : #include <editeng/editobj.hxx>
44 : : #include <editeng/editdata.hxx>
45 : : #include <editeng/editview.hxx>
46 : : #include <editeng/eeitem.hxx>
47 : : #include <editeng/outliner.hxx>
48 : : #include <editeng/unoedhlp.hxx>
49 : :
50 : :
51 : : #include "accessibility.hxx"
52 : : #include <unomodel.hxx>
53 : : #include <document.hxx>
54 : : #include <view.hxx>
55 : :
56 : : using rtl::OUString;
57 : : using namespace com::sun::star;
58 : : using namespace com::sun::star::lang;
59 : : using namespace com::sun::star::uno;
60 : : using namespace com::sun::star::accessibility;
61 : :
62 : : //////////////////////////////////////////////////////////////////////
63 : :
64 : 8 : static awt::Rectangle lcl_GetBounds( Window *pWin )
65 : : {
66 : : // !! see VCLXAccessibleComponent::implGetBounds()
67 : :
68 : : //! the coordinates returned are relativ to the parent window !
69 : : //! Thus the top-left point may be different from (0, 0) !
70 : :
71 : 8 : awt::Rectangle aBounds;
72 [ + - ]: 8 : if (pWin)
73 : : {
74 [ + - ]: 8 : Rectangle aRect = pWin->GetWindowExtentsRelative( NULL );
75 : 8 : aBounds.X = aRect.Left();
76 : 8 : aBounds.Y = aRect.Top();
77 [ + - ]: 8 : aBounds.Width = aRect.GetWidth();
78 [ + - ]: 8 : aBounds.Height = aRect.GetHeight();
79 [ + - ]: 8 : Window* pParent = pWin->GetAccessibleParentWindow();
80 [ + - ]: 8 : if (pParent)
81 : : {
82 [ + - ]: 8 : Rectangle aParentRect = pParent->GetWindowExtentsRelative( NULL );
83 : 8 : awt::Point aParentScreenLoc( aParentRect.Left(), aParentRect.Top() );
84 : 8 : aBounds.X -= aParentScreenLoc.X;
85 : 8 : aBounds.Y -= aParentScreenLoc.Y;
86 : : }
87 : : }
88 : 8 : return aBounds;
89 : : }
90 : :
91 : 4 : static awt::Point lcl_GetLocationOnScreen( Window *pWin )
92 : : {
93 : : // !! see VCLXAccessibleComponent::getLocationOnScreen()
94 : :
95 : 4 : awt::Point aPos;
96 [ + - ]: 4 : if (pWin)
97 : : {
98 [ + - ]: 4 : Rectangle aRect = pWin->GetWindowExtentsRelative( NULL );
99 : 4 : aPos.X = aRect.Left();
100 : 4 : aPos.Y = aRect.Top();
101 : : }
102 : 4 : return aPos;
103 : : }
104 : :
105 : : //////////////////////////////////////////////////////////////////////
106 : :
107 : 6 : SmGraphicAccessible::SmGraphicAccessible( SmGraphicWindow *pGraphicWin ) :
108 : : aAccName ( String(SmResId(RID_DOCUMENTSTR)) ),
109 : : nClientId (0),
110 [ + - ][ + - ]: 6 : pWin (pGraphicWin)
[ + - ]
111 : : {
112 : : OSL_ENSURE( pWin, "SmGraphicAccessible: window missing" );
113 : 6 : }
114 : :
115 : :
116 : 0 : SmGraphicAccessible::SmGraphicAccessible( const SmGraphicAccessible &rSmAcc ) :
117 : : SmGraphicAccessibleBaseClass(),
118 : : aAccName ( String(SmResId(RID_DOCUMENTSTR)) ),
119 [ # # ][ # # ]: 0 : nClientId (0)
[ # # ]
120 : : {
121 : 0 : pWin = rSmAcc.pWin;
122 : : OSL_ENSURE( pWin, "SmGraphicAccessible: window missing" );
123 : 0 : }
124 : :
125 : :
126 [ + - ][ + - ]: 6 : SmGraphicAccessible::~SmGraphicAccessible()
127 : : {
128 [ - + ]: 12 : }
129 : :
130 : :
131 : 6 : SmDocShell * SmGraphicAccessible::GetDoc_Impl()
132 : : {
133 [ + - ]: 6 : SmViewShell *pView = pWin ? pWin->GetView() : 0;
134 [ + - ]: 6 : return pView ? pView->GetDoc() : 0;
135 : : }
136 : :
137 : 0 : String SmGraphicAccessible::GetAccessibleText_Impl()
138 : : {
139 : 0 : String aTxt;
140 [ # # ]: 0 : SmDocShell *pDoc = GetDoc_Impl();
141 [ # # ]: 0 : if (pDoc)
142 [ # # ][ # # ]: 0 : aTxt = pDoc->GetAccessibleText();
[ # # ]
143 : 0 : return aTxt;
144 : : }
145 : :
146 : 6 : void SmGraphicAccessible::ClearWin()
147 : : {
148 : 6 : pWin = 0; // implicitly results in AccessibleStateType::DEFUNC set
149 : :
150 [ - + ]: 6 : if ( nClientId )
151 : : {
152 [ # # ]: 0 : comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, *this );
153 : 0 : nClientId = 0;
154 : : }
155 : 6 : }
156 : :
157 : 2 : void SmGraphicAccessible::LaunchEvent(
158 : : const sal_Int16 nAccesibleEventId,
159 : : const uno::Any &rOldVal,
160 : : const uno::Any &rNewVal)
161 : : {
162 [ + - ]: 2 : AccessibleEventObject aEvt;
163 [ + - ]: 2 : aEvt.Source = (XAccessible *) this;
164 : 2 : aEvt.EventId = nAccesibleEventId;
165 : 2 : aEvt.OldValue = rOldVal;
166 : 2 : aEvt.NewValue = rNewVal ;
167 : :
168 : : // pass event on to event-listener's
169 [ - + ]: 2 : if (nClientId)
170 [ # # ][ + - ]: 2 : comphelper::AccessibleEventNotifier::addEvent( nClientId, aEvt );
171 : 2 : }
172 : :
173 : 14 : uno::Reference< XAccessibleContext > SAL_CALL SmGraphicAccessible::getAccessibleContext()
174 : : throw (RuntimeException)
175 : : {
176 [ + - ]: 14 : SolarMutexGuard aGuard;
177 [ + - ][ + - ]: 14 : return this;
178 : : }
179 : :
180 : 4708 : sal_Bool SAL_CALL SmGraphicAccessible::containsPoint( const awt::Point& aPoint )
181 : : throw (RuntimeException)
182 : : {
183 : : //! the arguments coordinates are relativ to the current window !
184 : : //! Thus the top-left point is (0, 0)
185 : :
186 [ + - ]: 4708 : SolarMutexGuard aGuard;
187 [ - + ]: 4708 : if (!pWin)
188 [ # # ]: 0 : throw RuntimeException();
189 : :
190 [ + - ]: 4708 : Size aSz( pWin->GetSizePixel() );
191 : : return aPoint.X >= 0 && aPoint.Y >= 0 &&
192 [ + + ][ + + ]: 4708 : aPoint.X < aSz.Width() && aPoint.Y < aSz.Height();
[ + + ][ + + ]
[ + - ]
193 : : }
194 : :
195 : 0 : uno::Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleAtPoint(
196 : : const awt::Point& aPoint )
197 : : throw (RuntimeException)
198 : : {
199 [ # # ]: 0 : SolarMutexGuard aGuard;
200 : 0 : XAccessible *pRes = 0;
201 [ # # ][ # # ]: 0 : if (containsPoint( aPoint ))
202 : 0 : pRes = this;
203 [ # # ][ # # ]: 0 : return pRes;
204 : : }
205 : :
206 : 2 : awt::Rectangle SAL_CALL SmGraphicAccessible::getBounds()
207 : : throw (RuntimeException)
208 : : {
209 [ + - ]: 2 : SolarMutexGuard aGuard;
210 [ - + ]: 2 : if (!pWin)
211 [ # # ]: 0 : throw RuntimeException();
212 : : OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
213 : : "mismatch of window parent and accessible parent" );
214 [ + - ][ + - ]: 2 : return lcl_GetBounds( pWin );
215 : : }
216 : :
217 : 2 : awt::Point SAL_CALL SmGraphicAccessible::getLocation()
218 : : throw (RuntimeException)
219 : : {
220 [ + - ]: 2 : SolarMutexGuard aGuard;
221 [ - + ]: 2 : if (!pWin)
222 [ # # ]: 0 : throw RuntimeException();
223 : : OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
224 : : "mismatch of window parent and accessible parent" );
225 [ + - ]: 2 : awt::Rectangle aRect( lcl_GetBounds( pWin ) );
226 [ + - ]: 2 : return awt::Point( aRect.X, aRect.Y );
227 : : }
228 : :
229 : 2 : awt::Point SAL_CALL SmGraphicAccessible::getLocationOnScreen()
230 : : throw (RuntimeException)
231 : : {
232 [ + - ]: 2 : SolarMutexGuard aGuard;
233 [ - + ]: 2 : if (!pWin)
234 [ # # ]: 0 : throw RuntimeException();
235 : : OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
236 : : "mismatch of window parent and accessible parent" );
237 [ + - ][ + - ]: 2 : return lcl_GetLocationOnScreen( pWin );
238 : : }
239 : :
240 : 2 : awt::Size SAL_CALL SmGraphicAccessible::getSize()
241 : : throw (RuntimeException)
242 : : {
243 [ + - ]: 2 : SolarMutexGuard aGuard;
244 [ - + ]: 2 : if (!pWin)
245 [ # # ]: 0 : throw RuntimeException();
246 : : OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
247 : : "mismatch of window parent and accessible parent" );
248 : :
249 [ + - ]: 2 : Size aSz( pWin->GetSizePixel() );
250 : : #if OSL_DEBUG_LEVEL > 1
251 : : awt::Rectangle aRect( lcl_GetBounds( pWin ) );
252 : : Size aSz2( aRect.Width, aRect.Height );
253 : : OSL_ENSURE( aSz == aSz2, "mismatch in width" );
254 : : #endif
255 [ + - ]: 2 : return awt::Size( aSz.Width(), aSz.Height() );
256 : : }
257 : :
258 : 2 : void SAL_CALL SmGraphicAccessible::grabFocus()
259 : : throw (RuntimeException)
260 : : {
261 [ + - ]: 2 : SolarMutexGuard aGuard;
262 [ - + ]: 2 : if (!pWin)
263 [ # # ]: 0 : throw RuntimeException();
264 : :
265 [ + - ][ + - ]: 2 : pWin->GrabFocus();
266 : 2 : }
267 : :
268 : 2 : sal_Int32 SAL_CALL SmGraphicAccessible::getForeground()
269 : : throw (RuntimeException)
270 : : {
271 [ + - ]: 2 : SolarMutexGuard aGuard;
272 : :
273 [ - + ]: 2 : if (!pWin)
274 [ # # ]: 0 : throw RuntimeException();
275 [ + - ]: 2 : return (sal_Int32) pWin->GetTextColor().GetColor();
276 : : }
277 : :
278 : 2 : sal_Int32 SAL_CALL SmGraphicAccessible::getBackground()
279 : : throw (RuntimeException)
280 : : {
281 [ + - ]: 2 : SolarMutexGuard aGuard;
282 : :
283 [ - + ]: 2 : if (!pWin)
284 [ # # ]: 0 : throw RuntimeException();
285 [ + - ][ + - ]: 2 : Wallpaper aWall( pWin->GetDisplayBackground() );
286 : : ColorData nCol;
287 [ + - ][ + - ]: 2 : if (aWall.IsBitmap() || aWall.IsGradient())
[ + - ][ - + ]
[ - + ]
288 : 0 : nCol = pWin->GetSettings().GetStyleSettings().GetWindowColor().GetColor();
289 : : else
290 [ + - ]: 2 : nCol = aWall.GetColor().GetColor();
291 [ + - ][ + - ]: 2 : return (sal_Int32) nCol;
292 : : }
293 : :
294 : 16 : sal_Int32 SAL_CALL SmGraphicAccessible::getAccessibleChildCount()
295 : : throw (RuntimeException)
296 : : {
297 [ + - ]: 16 : SolarMutexGuard aGuard;
298 [ + - ]: 16 : return 0;
299 : : }
300 : :
301 : 0 : Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleChild(
302 : : sal_Int32 /*i*/ )
303 : : throw (IndexOutOfBoundsException, RuntimeException)
304 : : {
305 [ # # ]: 0 : SolarMutexGuard aGuard;
306 [ # # ]: 0 : throw IndexOutOfBoundsException(); // there is no child...
307 : : }
308 : :
309 : 8 : Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleParent()
310 : : throw (RuntimeException)
311 : : {
312 [ + - ]: 8 : SolarMutexGuard aGuard;
313 [ - + ]: 8 : if (!pWin)
314 [ # # ]: 0 : throw RuntimeException();
315 : :
316 [ + - ]: 8 : Window *pAccParent = pWin->GetAccessibleParentWindow();
317 : : OSL_ENSURE( pAccParent, "accessible parent missing" );
318 [ + - ][ + - ]: 8 : return pAccParent ? pAccParent->GetAccessible() : Reference< XAccessible >();
[ + - ]
319 : : }
320 : :
321 : 2 : sal_Int32 SAL_CALL SmGraphicAccessible::getAccessibleIndexInParent()
322 : : throw (RuntimeException)
323 : : {
324 [ + - ]: 2 : SolarMutexGuard aGuard;
325 : 2 : sal_Int32 nIdx = -1;
326 [ + - ][ + - ]: 2 : Window *pAccParent = pWin ? pWin->GetAccessibleParentWindow() : 0;
327 [ + - ]: 2 : if (pAccParent)
328 : : {
329 [ + - ]: 2 : sal_uInt16 nCnt = pAccParent->GetAccessibleChildWindowCount();
330 [ + + ][ + - ]: 4 : for (sal_uInt16 i = 0; i < nCnt && nIdx == -1; ++i)
[ + + ]
331 [ + - ][ + - ]: 2 : if (pAccParent->GetAccessibleChildWindow( i ) == pWin)
332 : 2 : nIdx = i;
333 : : }
334 [ + - ]: 2 : return nIdx;
335 : : }
336 : :
337 : 12 : sal_Int16 SAL_CALL SmGraphicAccessible::getAccessibleRole()
338 : : throw (RuntimeException)
339 : : {
340 [ + - ]: 12 : SolarMutexGuard aGuard;
341 [ + - ]: 12 : return AccessibleRole::DOCUMENT;
342 : : }
343 : :
344 : 6 : OUString SAL_CALL SmGraphicAccessible::getAccessibleDescription()
345 : : throw (RuntimeException)
346 : : {
347 [ + - ]: 6 : SolarMutexGuard aGuard;
348 [ + - ]: 6 : SmDocShell *pDoc = GetDoc_Impl();
349 [ + - ][ + - ]: 6 : return pDoc ? OUString(pDoc->GetText()) : OUString();
[ + - ]
350 : : }
351 : :
352 : 8 : OUString SAL_CALL SmGraphicAccessible::getAccessibleName()
353 : : throw (RuntimeException)
354 : : {
355 [ + - ]: 8 : SolarMutexGuard aGuard;
356 [ + - ][ + - ]: 8 : return aAccName;
357 : : }
358 : :
359 : 2 : Reference< XAccessibleRelationSet > SAL_CALL SmGraphicAccessible::getAccessibleRelationSet()
360 : : throw (RuntimeException)
361 : : {
362 [ + - ]: 2 : SolarMutexGuard aGuard;
363 [ + - ][ + - ]: 2 : Reference< XAccessibleRelationSet > xRelSet = new utl::AccessibleRelationSetHelper();
[ + - ]
364 [ + - ]: 2 : return xRelSet; // empty relation set
365 : : }
366 : :
367 : 8 : Reference< XAccessibleStateSet > SAL_CALL SmGraphicAccessible::getAccessibleStateSet()
368 : : throw (RuntimeException)
369 : : {
370 [ + - ]: 8 : SolarMutexGuard aGuard;
371 : : ::utl::AccessibleStateSetHelper *pStateSet =
372 [ + - ]: 8 : new ::utl::AccessibleStateSetHelper;
373 : :
374 [ + - ][ + - ]: 8 : Reference<XAccessibleStateSet> xStateSet( pStateSet );
375 : :
376 [ - + ]: 8 : if (!pWin)
377 [ # # ]: 0 : pStateSet->AddState( AccessibleStateType::DEFUNC );
378 : : else
379 : : {
380 [ + - ]: 8 : pStateSet->AddState( AccessibleStateType::ENABLED );
381 [ + - ]: 8 : pStateSet->AddState( AccessibleStateType::FOCUSABLE );
382 [ + - ][ + + ]: 8 : if (pWin->HasFocus())
383 [ + - ]: 2 : pStateSet->AddState( AccessibleStateType::FOCUSED );
384 [ + - ][ - + ]: 8 : if (pWin->IsActive())
385 [ # # ]: 0 : pStateSet->AddState( AccessibleStateType::ACTIVE );
386 [ + - ][ + - ]: 8 : if (pWin->IsVisible())
387 [ + - ]: 8 : pStateSet->AddState( AccessibleStateType::SHOWING );
388 [ + - ][ + - ]: 8 : if (pWin->IsReallyVisible())
389 [ + - ]: 8 : pStateSet->AddState( AccessibleStateType::VISIBLE );
390 [ + - ][ + - ]: 8 : if (COL_TRANSPARENT != pWin->GetBackground().GetColor().GetColor())
391 [ + - ]: 8 : pStateSet->AddState( AccessibleStateType::OPAQUE );
392 : : }
393 : :
394 [ + - ]: 8 : return xStateSet;
395 : : }
396 : :
397 : 2 : Locale SAL_CALL SmGraphicAccessible::getLocale()
398 : : throw (IllegalAccessibleComponentStateException, RuntimeException)
399 : : {
400 [ + - ]: 2 : SolarMutexGuard aGuard;
401 : : // should be the document language...
402 : : // We use the language of the localized symbol names here.
403 [ + - ][ + - ]: 2 : return Application::GetSettings().GetUILocale();
[ + - ]
404 : : }
405 : :
406 : :
407 : 0 : void SAL_CALL SmGraphicAccessible::addEventListener(
408 : : const Reference< XAccessibleEventListener >& xListener )
409 : : throw (RuntimeException)
410 : : {
411 [ # # ]: 0 : if (xListener.is())
412 : : {
413 [ # # ]: 0 : SolarMutexGuard aGuard;
414 [ # # ]: 0 : if (pWin)
415 : : {
416 [ # # ]: 0 : if (!nClientId)
417 [ # # ]: 0 : nClientId = comphelper::AccessibleEventNotifier::registerClient( );
418 [ # # ]: 0 : comphelper::AccessibleEventNotifier::addEventListener( nClientId, xListener );
419 [ # # ]: 0 : }
420 : : }
421 : 0 : }
422 : :
423 : 0 : void SAL_CALL SmGraphicAccessible::removeEventListener(
424 : : const Reference< XAccessibleEventListener >& xListener )
425 : : throw (RuntimeException)
426 : : {
427 [ # # ]: 0 : if (xListener.is())
428 : : {
429 [ # # ]: 0 : SolarMutexGuard aGuard;
430 [ # # ]: 0 : sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( nClientId, xListener );
431 [ # # ]: 0 : if ( !nListenerCount )
432 : : {
433 : : // no listeners anymore
434 : : // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
435 : : // and at least to us not firing any events anymore, in case somebody calls
436 : : // NotifyAccessibleEvent, again
437 [ # # ]: 0 : comphelper::AccessibleEventNotifier::revokeClient( nClientId );
438 : 0 : nClientId = 0;
439 [ # # ]: 0 : }
440 : : }
441 : 0 : }
442 : :
443 : 0 : sal_Int32 SAL_CALL SmGraphicAccessible::getCaretPosition()
444 : : throw (RuntimeException)
445 : : {
446 [ # # ]: 0 : SolarMutexGuard aGuard;
447 [ # # ]: 0 : return 0;
448 : : }
449 : :
450 : 0 : sal_Bool SAL_CALL SmGraphicAccessible::setCaretPosition( sal_Int32 nIndex )
451 : : throw (IndexOutOfBoundsException, RuntimeException)
452 : : {
453 [ # # ]: 0 : SolarMutexGuard aGuard;
454 : 0 : xub_StrLen nIdx = (xub_StrLen) nIndex;
455 [ # # ]: 0 : String aTxt( GetAccessibleText_Impl() );
456 [ # # ]: 0 : if (!(nIdx < aTxt.Len()))
457 [ # # ]: 0 : throw IndexOutOfBoundsException();
458 [ # # ][ # # ]: 0 : return sal_False;
459 : : }
460 : :
461 : 0 : sal_Unicode SAL_CALL SmGraphicAccessible::getCharacter( sal_Int32 nIndex )
462 : : throw (IndexOutOfBoundsException, RuntimeException)
463 : : {
464 [ # # ]: 0 : SolarMutexGuard aGuard;
465 : :
466 : 0 : xub_StrLen nIdx = (xub_StrLen) nIndex;
467 [ # # ]: 0 : String aTxt( GetAccessibleText_Impl() );
468 [ # # ]: 0 : if (!(nIdx < aTxt.Len()))
469 [ # # ]: 0 : throw IndexOutOfBoundsException();
470 [ # # ][ # # ]: 0 : return aTxt.GetChar( nIdx );
471 : : }
472 : :
473 : 0 : Sequence< beans::PropertyValue > SAL_CALL SmGraphicAccessible::getCharacterAttributes(
474 : : sal_Int32 nIndex,
475 : : const uno::Sequence< ::rtl::OUString > & /*rRequestedAttributes*/ )
476 : : throw (IndexOutOfBoundsException, RuntimeException)
477 : : {
478 [ # # ]: 0 : SolarMutexGuard aGuard;
479 [ # # ][ # # ]: 0 : sal_Int32 nLen = GetAccessibleText_Impl().Len();
480 [ # # ][ # # ]: 0 : if (!(0 <= nIndex && nIndex < nLen))
481 [ # # ]: 0 : throw IndexOutOfBoundsException();
482 [ # # ][ # # ]: 0 : return Sequence< beans::PropertyValue >();
483 : : }
484 : :
485 : 0 : awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nIndex )
486 : : throw (IndexOutOfBoundsException, RuntimeException)
487 : : {
488 [ # # ]: 0 : SolarMutexGuard aGuard;
489 : :
490 : 0 : awt::Rectangle aRes;
491 : :
492 [ # # ]: 0 : if (!pWin)
493 [ # # ]: 0 : throw RuntimeException();
494 : : else
495 : : {
496 : : // get accessible text
497 : 0 : SmViewShell *pView = pWin->GetView();
498 [ # # ][ # # ]: 0 : SmDocShell *pDoc = pView ? pView->GetDoc() : 0;
499 [ # # ]: 0 : if (!pDoc)
500 [ # # ]: 0 : throw RuntimeException();
501 [ # # ]: 0 : String aTxt( GetAccessibleText_Impl() );
502 [ # # ][ # # ]: 0 : if (!(0 <= nIndex && nIndex <= aTxt.Len())) // aTxt.Len() is valid
[ # # ]
503 [ # # ]: 0 : throw IndexOutOfBoundsException();
504 : :
505 : : // find a reasonable rectangle for position aTxt.Len().
506 : 0 : bool bWasBehindText = (nIndex == aTxt.Len());
507 [ # # ][ # # ]: 0 : if (bWasBehindText && nIndex)
508 : 0 : --nIndex;
509 : :
510 : 0 : const SmNode *pTree = pDoc->GetFormulaTree();
511 [ # # ]: 0 : const SmNode *pNode = pTree->FindNodeWithAccessibleIndex( (xub_StrLen) nIndex );
512 : : //! pNode may be 0 if the index belongs to a char that was inserted
513 : : //! only for the accessible text!
514 [ # # ]: 0 : if (pNode)
515 : : {
516 : 0 : sal_Int32 nAccIndex = pNode->GetAccessibleIndex();
517 : : OSL_ENSURE( nAccIndex >= 0, "invalid accessible index" );
518 : : OSL_ENSURE( nIndex >= nAccIndex, "index out of range" );
519 : :
520 [ # # ]: 0 : String aNodeText;
521 [ # # ]: 0 : pNode->GetAccessibleText( aNodeText );
522 : 0 : sal_Int32 nNodeIndex = nIndex - nAccIndex;
523 [ # # ][ # # ]: 0 : if (0 <= nNodeIndex && nNodeIndex < aNodeText.Len())
[ # # ]
524 : : {
525 : : // get appropriate rectangle
526 : 0 : Point aOffset(pNode->GetTopLeft() - pTree->GetTopLeft());
527 : 0 : Point aTLPos (pWin->GetFormulaDrawPos() + aOffset);
528 : 0 : aTLPos.X() -= 0;
529 : 0 : Size aSize (pNode->GetSize());
530 : :
531 [ # # ]: 0 : sal_Int32 *pXAry = new sal_Int32[ aNodeText.Len() ];
532 [ # # ]: 0 : pWin->SetFont( pNode->GetFont() );
533 [ # # ]: 0 : pWin->GetTextArray( aNodeText, pXAry, 0, aNodeText.Len() );
534 [ # # ]: 0 : aTLPos.X() += nNodeIndex > 0 ? pXAry[nNodeIndex - 1] : 0;
535 [ # # ]: 0 : aSize.Width() = nNodeIndex > 0 ? pXAry[nNodeIndex] - pXAry[nNodeIndex - 1] : pXAry[nNodeIndex];
536 [ # # ]: 0 : delete[] pXAry;
537 : :
538 : : #if OSL_DEBUG_LEVEL > 1
539 : : Point aLP00( pWin->LogicToPixel( Point(0,0)) );
540 : : Point aPL00( pWin->PixelToLogic( Point(0,0)) );
541 : : #endif
542 [ # # ]: 0 : aTLPos = pWin->LogicToPixel( aTLPos );
543 [ # # ]: 0 : aSize = pWin->LogicToPixel( aSize );
544 : 0 : aRes.X = aTLPos.X();
545 : 0 : aRes.Y = aTLPos.Y();
546 : 0 : aRes.Width = aSize.Width();
547 : 0 : aRes.Height = aSize.Height();
548 [ # # ]: 0 : }
549 : : }
550 : :
551 : : // take rectangle from last character and move it to the right
552 [ # # ]: 0 : if (bWasBehindText)
553 [ # # ]: 0 : aRes.X += aRes.Width;
554 : : }
555 : :
556 [ # # ]: 0 : return aRes;
557 : : }
558 : :
559 : 0 : sal_Int32 SAL_CALL SmGraphicAccessible::getCharacterCount()
560 : : throw (RuntimeException)
561 : : {
562 [ # # ]: 0 : SolarMutexGuard aGuard;
563 [ # # ][ # # ]: 0 : return GetAccessibleText_Impl().Len();
[ # # ]
564 : : }
565 : :
566 : 0 : sal_Int32 SAL_CALL SmGraphicAccessible::getIndexAtPoint( const awt::Point& aPoint )
567 : : throw (RuntimeException)
568 : : {
569 [ # # ]: 0 : SolarMutexGuard aGuard;
570 : :
571 : 0 : sal_Int32 nRes = -1;
572 [ # # ]: 0 : if (pWin)
573 : : {
574 [ # # ]: 0 : const SmNode *pTree = pWin->GetView()->GetDoc()->GetFormulaTree();
575 : : // can be NULL! e.g. if one clicks within the window already during loading of the
576 : : // document (before the parser even started)
577 [ # # ]: 0 : if (!pTree)
578 : 0 : return nRes;
579 : :
580 : : // get position relative to formula draw position
581 : 0 : Point aPos( aPoint.X, aPoint.Y );
582 [ # # ]: 0 : aPos = pWin->PixelToLogic( aPos );
583 : 0 : aPos -= pWin->GetFormulaDrawPos();
584 : :
585 : : // if it was inside the formula then get the appropriate node
586 : 0 : const SmNode *pNode = 0;
587 [ # # ][ # # ]: 0 : if (pTree->OrientedDist(aPos) <= 0)
588 [ # # ]: 0 : pNode = pTree->FindRectClosestTo(aPos);
589 : :
590 [ # # ]: 0 : if (pNode)
591 : : {
592 : : // get appropriate rectangle
593 : 0 : Point aOffset( pNode->GetTopLeft() - pTree->GetTopLeft() );
594 : 0 : Point aTLPos ( aOffset );
595 : 0 : aTLPos.X() -= 0;
596 : 0 : Size aSize( pNode->GetSize() );
597 : : #if OSL_DEBUG_LEVEL > 1
598 : : Point aLP00( pWin->LogicToPixel( Point(0,0)) );
599 : : Point aPL00( pWin->PixelToLogic( Point(0,0)) );
600 : : #endif
601 : :
602 [ # # ]: 0 : Rectangle aRect( aTLPos, aSize );
603 [ # # ][ # # ]: 0 : if (aRect.IsInside( aPos ))
604 : : {
605 : : OSL_ENSURE( pNode->IsVisible(), "node is not a leaf" );
606 [ # # ]: 0 : String aTxt;
607 [ # # ]: 0 : pNode->GetAccessibleText( aTxt );
608 : : OSL_ENSURE( aTxt.Len(), "no accessible text available" );
609 : :
610 : 0 : long nNodeX = pNode->GetLeft();
611 : :
612 [ # # ]: 0 : sal_Int32 *pXAry = new sal_Int32[ aTxt.Len() ];
613 [ # # ]: 0 : pWin->SetFont( pNode->GetFont() );
614 [ # # ]: 0 : pWin->GetTextArray( aTxt, pXAry, 0, aTxt.Len() );
615 [ # # ][ # # ]: 0 : for (sal_Int32 i = 0; i < aTxt.Len() && nRes == -1; ++i)
[ # # ]
616 : : {
617 [ # # ]: 0 : if (pXAry[i] + nNodeX > aPos.X())
618 : 0 : nRes = i;
619 : : }
620 [ # # ]: 0 : delete[] pXAry;
621 : : OSL_ENSURE( nRes >= 0 && nRes < aTxt.Len(), "index out of range" );
622 : : OSL_ENSURE( pNode->GetAccessibleIndex() >= 0,
623 : : "invalid accessible index" );
624 : :
625 [ # # ]: 0 : nRes = pNode->GetAccessibleIndex() + nRes;
626 : : }
627 : : }
628 : : }
629 [ # # ]: 0 : return nRes;
630 : : }
631 : :
632 : 0 : OUString SAL_CALL SmGraphicAccessible::getSelectedText()
633 : : throw (RuntimeException)
634 : : {
635 [ # # ]: 0 : SolarMutexGuard aGuard;
636 [ # # ]: 0 : return OUString();
637 : : }
638 : :
639 : 0 : sal_Int32 SAL_CALL SmGraphicAccessible::getSelectionStart()
640 : : throw (RuntimeException)
641 : : {
642 [ # # ]: 0 : SolarMutexGuard aGuard;
643 [ # # ]: 0 : return -1;
644 : : }
645 : :
646 : 0 : sal_Int32 SAL_CALL SmGraphicAccessible::getSelectionEnd()
647 : : throw (RuntimeException)
648 : : {
649 [ # # ]: 0 : SolarMutexGuard aGuard;
650 [ # # ]: 0 : return -1;
651 : : }
652 : :
653 : 0 : sal_Bool SAL_CALL SmGraphicAccessible::setSelection(
654 : : sal_Int32 nStartIndex,
655 : : sal_Int32 nEndIndex )
656 : : throw (IndexOutOfBoundsException, RuntimeException)
657 : : {
658 [ # # ]: 0 : SolarMutexGuard aGuard;
659 [ # # ][ # # ]: 0 : sal_Int32 nLen = GetAccessibleText_Impl().Len();
660 [ # # ][ # # ]: 0 : if (!(0 <= nStartIndex && nStartIndex < nLen) ||
[ # # ]
661 [ # # ]: 0 : !(0 <= nEndIndex && nEndIndex < nLen))
662 [ # # ]: 0 : throw IndexOutOfBoundsException();
663 [ # # ]: 0 : return sal_False;
664 : : }
665 : :
666 : 0 : OUString SAL_CALL SmGraphicAccessible::getText()
667 : : throw (RuntimeException)
668 : : {
669 [ # # ]: 0 : SolarMutexGuard aGuard;
670 [ # # ][ # # ]: 0 : return GetAccessibleText_Impl();
[ # # ][ # # ]
671 : : }
672 : :
673 : 0 : OUString SAL_CALL SmGraphicAccessible::getTextRange(
674 : : sal_Int32 nStartIndex,
675 : : sal_Int32 nEndIndex )
676 : : throw (IndexOutOfBoundsException, RuntimeException)
677 : : {
678 : : //!! nEndIndex may be the string length per definition of the interface !!
679 : : //!! text should be copied exclusive that end index though. And arguments
680 : : //!! may be switched.
681 : :
682 [ # # ]: 0 : SolarMutexGuard aGuard;
683 [ # # ]: 0 : String aTxt( GetAccessibleText_Impl() );
684 : 0 : xub_StrLen nStart = (xub_StrLen) Min(nStartIndex, nEndIndex);
685 : 0 : xub_StrLen nEnd = (xub_StrLen) Max(nStartIndex, nEndIndex);
686 [ # # ]: 0 : if (!(nStart <= aTxt.Len()) ||
[ # # # # ]
687 : 0 : !(nEnd <= aTxt.Len()))
688 [ # # ]: 0 : throw IndexOutOfBoundsException();
689 [ # # ][ # # ]: 0 : return aTxt.Copy( nStart, nEnd - nStart );
[ # # ][ # # ]
[ # # ]
690 : : }
691 : :
692 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
693 : : {
694 [ # # ]: 0 : SolarMutexGuard aGuard;
695 [ # # ]: 0 : String aTxt( GetAccessibleText_Impl() );
696 : 0 : xub_StrLen nIdx = (xub_StrLen) nIndex;
697 : : //!! nIndex is allowed to be the string length
698 [ # # ]: 0 : if (!(nIdx <= aTxt.Len()))
699 [ # # ]: 0 : throw IndexOutOfBoundsException();
700 : :
701 : 0 : ::com::sun::star::accessibility::TextSegment aResult;
702 : 0 : aResult.SegmentStart = -1;
703 : 0 : aResult.SegmentEnd = -1;
704 [ # # ][ # # ]: 0 : if ( (AccessibleTextType::CHARACTER == aTextType) && (nIdx < aTxt.Len()) )
[ # # ]
705 : : {
706 [ # # ][ # # ]: 0 : aResult.SegmentText = aTxt.Copy(nIdx, 1);
[ # # ]
707 : 0 : aResult.SegmentStart = nIdx;
708 : 0 : aResult.SegmentEnd = nIdx+1;
709 : : }
710 [ # # ][ # # ]: 0 : return aResult;
711 : : }
712 : :
713 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
714 : : {
715 [ # # ]: 0 : SolarMutexGuard aGuard;
716 [ # # ]: 0 : String aTxt( GetAccessibleText_Impl() );
717 : 0 : xub_StrLen nIdx = (xub_StrLen) nIndex;
718 : : //!! nIndex is allowed to be the string length
719 [ # # ]: 0 : if (!(nIdx <= aTxt.Len()))
720 [ # # ]: 0 : throw IndexOutOfBoundsException();
721 : :
722 : 0 : ::com::sun::star::accessibility::TextSegment aResult;
723 : 0 : aResult.SegmentStart = -1;
724 : 0 : aResult.SegmentEnd = -1;
725 : :
726 [ # # ][ # # ]: 0 : if ( (AccessibleTextType::CHARACTER == aTextType) && nIdx )
727 : : {
728 [ # # ][ # # ]: 0 : aResult.SegmentText = aTxt.Copy(nIdx-1, 1);
[ # # ]
729 : 0 : aResult.SegmentStart = nIdx-1;
730 : 0 : aResult.SegmentEnd = nIdx;
731 : : }
732 [ # # ][ # # ]: 0 : return aResult;
733 : : }
734 : :
735 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
736 : : {
737 [ # # ]: 0 : SolarMutexGuard aGuard;
738 [ # # ]: 0 : String aTxt( GetAccessibleText_Impl() );
739 : 0 : xub_StrLen nIdx = (xub_StrLen) nIndex;
740 : : //!! nIndex is allowed to be the string length
741 [ # # ]: 0 : if (!(nIdx <= aTxt.Len()))
742 [ # # ]: 0 : throw IndexOutOfBoundsException();
743 : :
744 : 0 : ::com::sun::star::accessibility::TextSegment aResult;
745 : 0 : aResult.SegmentStart = -1;
746 : 0 : aResult.SegmentEnd = -1;
747 : :
748 : 0 : nIdx++; // text *behind*
749 [ # # ][ # # ]: 0 : if ( (AccessibleTextType::CHARACTER == aTextType) && (nIdx < aTxt.Len()) )
[ # # ]
750 : : {
751 [ # # ][ # # ]: 0 : aResult.SegmentText = aTxt.Copy(nIdx, 1);
[ # # ]
752 : 0 : aResult.SegmentStart = nIdx;
753 : 0 : aResult.SegmentEnd = nIdx+1;
754 : : }
755 [ # # ][ # # ]: 0 : return aResult;
756 : : }
757 : :
758 : 0 : sal_Bool SAL_CALL SmGraphicAccessible::copyText(
759 : : sal_Int32 nStartIndex,
760 : : sal_Int32 nEndIndex )
761 : : throw (IndexOutOfBoundsException, RuntimeException)
762 : : {
763 [ # # ]: 0 : SolarMutexGuard aGuard;
764 : 0 : sal_Bool bReturn = sal_False;
765 : :
766 [ # # ]: 0 : if (!pWin)
767 [ # # ]: 0 : throw RuntimeException();
768 : : else
769 : : {
770 [ # # ]: 0 : Reference< datatransfer::clipboard::XClipboard > xClipboard = pWin->GetClipboard();
771 [ # # ]: 0 : if ( xClipboard.is() )
772 : : {
773 [ # # ]: 0 : ::rtl::OUString sText( getTextRange(nStartIndex, nEndIndex) );
774 : :
775 [ # # ][ # # ]: 0 : ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
[ # # ]
776 [ # # ]: 0 : const sal_uInt32 nRef = Application::ReleaseSolarMutex();
777 [ # # ][ # # ]: 0 : xClipboard->setContents( pDataObj, NULL );
[ # # ][ # # ]
778 : :
779 [ # # ]: 0 : Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
780 [ # # ]: 0 : if( xFlushableClipboard.is() )
781 [ # # ][ # # ]: 0 : xFlushableClipboard->flushClipboard();
782 : :
783 [ # # ]: 0 : Application::AcquireSolarMutex( nRef );
784 : :
785 : 0 : bReturn = sal_True;
786 : 0 : }
787 : : }
788 : :
789 [ # # ]: 0 : return bReturn;
790 : : }
791 : :
792 : 4 : OUString SAL_CALL SmGraphicAccessible::getImplementationName()
793 : : throw (RuntimeException)
794 : : {
795 : 4 : return OUString("SmGraphicAccessible");
796 : : }
797 : :
798 : 0 : sal_Bool SAL_CALL SmGraphicAccessible::supportsService(
799 : : const OUString& rServiceName )
800 : : throw (RuntimeException)
801 : : {
802 : 0 : return rServiceName == "com::sun::star::accessibility::Accessible" ||
803 : 0 : rServiceName == "com::sun::star::accessibility::AccessibleComponent" ||
804 : 0 : rServiceName == "com::sun::star::accessibility::AccessibleContext" ||
805 [ # # ][ # # : 0 : rServiceName == "com::sun::star::accessibility::AccessibleText";
# # # # ]
806 : : }
807 : :
808 : 0 : Sequence< OUString > SAL_CALL SmGraphicAccessible::getSupportedServiceNames()
809 : : throw (RuntimeException)
810 : : {
811 : 0 : Sequence< OUString > aNames(4);
812 [ # # ]: 0 : OUString *pNames = aNames.getArray();
813 : 0 : pNames[0] = "com::sun::star::accessibility::Accessible";
814 : 0 : pNames[1] = "com::sun::star::accessibility::AccessibleComponent";
815 : 0 : pNames[2] = "com::sun::star::accessibility::AccessibleContext";
816 : 0 : pNames[3] = "com::sun::star::accessibility::AccessibleText";
817 : 0 : return aNames;
818 : : }
819 : :
820 : : //////////////////////////////////////////////////////////////////////
821 : :
822 : : //------------------------------------------------------------------------
823 : :
824 : 4 : SmEditSource::SmEditSource( SmEditWindow * /*pWin*/, SmEditAccessible &rAcc ) :
825 : : aViewFwd (rAcc),
826 : : aTextFwd (rAcc, *this),
827 : : aEditViewFwd(rAcc),
828 [ + - ][ + - ]: 4 : rEditAcc (rAcc)
[ + - ][ + - ]
829 : : {
830 : 4 : }
831 : :
832 : 0 : SmEditSource::SmEditSource( const SmEditSource &rSrc ) :
833 : : SvxEditSource(),
834 : : aViewFwd (rSrc.rEditAcc),
835 : : aTextFwd (rSrc.rEditAcc, *this),
836 : : aEditViewFwd(rSrc.rEditAcc),
837 [ # # ][ # # ]: 0 : rEditAcc (rSrc.rEditAcc)
[ # # ][ # # ]
838 : : {
839 : 0 : }
840 : :
841 [ + - ][ + - ]: 4 : SmEditSource::~SmEditSource()
[ + - ][ + - ]
842 : : {
843 [ - + ]: 8 : }
844 : :
845 : 0 : SvxEditSource* SmEditSource::Clone() const
846 : : {
847 [ # # ]: 0 : return new SmEditSource( *this );
848 : : }
849 : :
850 : 46 : SvxTextForwarder* SmEditSource::GetTextForwarder()
851 : : {
852 : 46 : return &aTextFwd;
853 : : }
854 : :
855 : 16 : SvxViewForwarder* SmEditSource::GetViewForwarder()
856 : : {
857 : 16 : return &aViewFwd;
858 : : }
859 : :
860 : 8 : SvxEditViewForwarder* SmEditSource::GetEditViewForwarder( sal_Bool /*bCreate*/ )
861 : : {
862 : 8 : return &aEditViewFwd;
863 : : }
864 : :
865 : 0 : void SmEditSource::UpdateData()
866 : : {
867 : : // would possibly only by needed if the XText inteface is implemented
868 : : // and its text needs to be updated.
869 : 0 : }
870 : :
871 : 8 : SfxBroadcaster & SmEditSource::GetBroadcaster() const
872 : : {
873 : 8 : return ((SmEditSource *) this)->aBroadCaster;
874 : : }
875 : :
876 : : //------------------------------------------------------------------------
877 : :
878 : 4 : SmViewForwarder::SmViewForwarder( SmEditAccessible &rAcc ) :
879 : 4 : rEditAcc(rAcc)
880 : : {
881 : 4 : }
882 : :
883 : 4 : SmViewForwarder::~SmViewForwarder()
884 : : {
885 [ - + ]: 4 : }
886 : :
887 : 16 : sal_Bool SmViewForwarder::IsValid() const
888 : : {
889 : 16 : return rEditAcc.GetEditView() != 0;
890 : : }
891 : :
892 : 4 : Rectangle SmViewForwarder::GetVisArea() const
893 : : {
894 : 4 : EditView *pEditView = rEditAcc.GetEditView();
895 [ + - ]: 4 : OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
896 : :
897 [ + - ][ + - ]: 4 : if( pOutDev && pEditView)
898 : : {
899 [ + - ]: 4 : Rectangle aVisArea = pEditView->GetVisArea();
900 : :
901 : : // figure out map mode from edit engine
902 [ + - ]: 4 : EditEngine* pEditEngine = pEditView->GetEditEngine();
903 : :
904 [ + - ]: 4 : if( pEditEngine )
905 : : {
906 [ + - ]: 4 : MapMode aMapMode(pOutDev->GetMapMode());
907 : : aVisArea = OutputDevice::LogicToLogic( aVisArea,
908 : : pEditEngine->GetRefMapMode(),
909 [ + - ][ + - ]: 4 : aMapMode.GetMapUnit() );
[ + - ][ + - ]
[ + - ]
910 [ + - ]: 4 : aMapMode.SetOrigin(Point());
911 [ + - ][ + - ]: 4 : return pOutDev->LogicToPixel( aVisArea, aMapMode );
912 : : }
913 : : }
914 : :
915 : 4 : return Rectangle();
916 : : }
917 : :
918 : 24 : Point SmViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
919 : : {
920 : 24 : EditView *pEditView = rEditAcc.GetEditView();
921 [ + - ]: 24 : OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
922 : :
923 [ + - ]: 24 : if( pOutDev )
924 : : {
925 [ + - ]: 24 : MapMode aMapMode(pOutDev->GetMapMode());
926 : : Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode,
927 [ + - ][ + - ]: 24 : aMapMode.GetMapUnit() ) );
[ + - ]
928 [ + - ]: 24 : aMapMode.SetOrigin(Point());
929 [ + - ][ + - ]: 24 : return pOutDev->LogicToPixel( aPoint, aMapMode );
930 : : }
931 : :
932 : 24 : return Point();
933 : : }
934 : :
935 : 4 : Point SmViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
936 : : {
937 : 4 : EditView *pEditView = rEditAcc.GetEditView();
938 [ + - ]: 4 : OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
939 : :
940 [ + - ]: 4 : if( pOutDev )
941 : : {
942 [ + - ]: 4 : MapMode aMapMode(pOutDev->GetMapMode());
943 [ + - ]: 4 : aMapMode.SetOrigin(Point());
944 [ + - ]: 4 : Point aPoint( pOutDev->PixelToLogic( rPoint, aMapMode ) );
945 : : return OutputDevice::LogicToLogic( aPoint,
946 : : aMapMode.GetMapUnit(),
947 [ + - ][ + - ]: 4 : rMapMode );
[ + - ][ + - ]
948 : : }
949 : :
950 : 4 : return Point();
951 : : }
952 : :
953 : :
954 : : //------------------------------------------------------------------------
955 : :
956 : 4 : SmTextForwarder::SmTextForwarder( SmEditAccessible& rAcc, SmEditSource & rSource) :
957 : : rEditAcc ( rAcc ),
958 : 4 : rEditSource (rSource)
959 : : {
960 [ + - ]: 4 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
961 [ + - ]: 4 : if (pEditEngine)
962 [ + - ][ + - ]: 4 : pEditEngine->SetNotifyHdl( LINK(this, SmTextForwarder, NotifyHdl) );
963 : 4 : }
964 : :
965 : 4 : SmTextForwarder::~SmTextForwarder()
966 : : {
967 [ + - ]: 4 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
968 [ - + ]: 4 : if (pEditEngine)
969 [ # # ][ # # ]: 0 : pEditEngine->SetNotifyHdl( Link() );
970 [ - + ]: 4 : }
971 : :
972 : 0 : IMPL_LINK(SmTextForwarder, NotifyHdl, EENotify*, aNotify)
973 : : {
974 [ # # ]: 0 : if (aNotify)
975 : : {
976 [ # # ][ # # ]: 0 : ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
977 [ # # ]: 0 : if (aHint.get())
978 [ # # ][ # # ]: 0 : rEditSource.GetBroadcaster().Broadcast( *aHint.get() );
[ # # ]
979 : : }
980 : :
981 : 0 : return 0;
982 : : }
983 : :
984 : 14 : sal_uInt16 SmTextForwarder::GetParagraphCount() const
985 : : {
986 : 14 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
987 [ + - ]: 14 : return pEditEngine ? pEditEngine->GetParagraphCount() : 0;
988 : : }
989 : :
990 : 4 : sal_uInt16 SmTextForwarder::GetTextLen( sal_uInt16 nParagraph ) const
991 : : {
992 : 4 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
993 [ + - ]: 4 : return pEditEngine ? pEditEngine->GetTextLen( nParagraph ) : 0;
994 : : }
995 : :
996 : 4 : String SmTextForwarder::GetText( const ESelection& rSel ) const
997 : : {
998 [ + - ]: 4 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
999 [ + - ]: 4 : String aRet;
1000 [ + - ]: 4 : if (pEditEngine)
1001 [ + - ][ + - ]: 4 : aRet = pEditEngine->GetText( rSel, LINEEND_LF );
[ + - ]
1002 [ + - ][ + - ]: 4 : return convertLineEnd(aRet, GetSystemLineEnd());
[ + - ][ + - ]
1003 : : }
1004 : :
1005 : 0 : SfxItemSet SmTextForwarder::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib ) const
1006 : : {
1007 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1008 : : OSL_ENSURE( pEditEngine, "EditEngine missing" );
1009 [ # # ]: 0 : if( rSel.nStartPara == rSel.nEndPara )
1010 : : {
1011 : 0 : sal_uInt8 nFlags = 0;
1012 [ # # # # ]: 0 : switch( bOnlyHardAttrib )
1013 : : {
1014 : : case EditEngineAttribs_All:
1015 : 0 : nFlags = GETATTRIBS_ALL;
1016 : 0 : break;
1017 : : case EditEngineAttribs_HardAndPara:
1018 : 0 : nFlags = GETATTRIBS_PARAATTRIBS|GETATTRIBS_CHARATTRIBS;
1019 : 0 : break;
1020 : : case EditEngineAttribs_OnlyHard:
1021 : 0 : nFlags = GETATTRIBS_CHARATTRIBS;
1022 : 0 : break;
1023 : : default:
1024 : : OSL_FAIL("unknown flags for SmTextForwarder::GetAttribs");
1025 : : }
1026 : :
1027 : 0 : return pEditEngine->GetAttribs( rSel.nStartPara, rSel.nStartPos, rSel.nEndPos, nFlags );
1028 : : }
1029 : : else
1030 : : {
1031 : 0 : return pEditEngine->GetAttribs( rSel, bOnlyHardAttrib );
1032 : : }
1033 : : }
1034 : :
1035 : 0 : SfxItemSet SmTextForwarder::GetParaAttribs( sal_uInt16 nPara ) const
1036 : : {
1037 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1038 : : OSL_ENSURE( pEditEngine, "EditEngine missing" );
1039 : :
1040 : 0 : SfxItemSet aSet( pEditEngine->GetParaAttribs( nPara ) );
1041 : :
1042 : 0 : sal_uInt16 nWhich = EE_PARA_START;
1043 [ # # ]: 0 : while( nWhich <= EE_PARA_END )
1044 : : {
1045 [ # # ][ # # ]: 0 : if( aSet.GetItemState( nWhich, sal_True ) != SFX_ITEM_ON )
1046 : : {
1047 [ # # ][ # # ]: 0 : if( pEditEngine->HasParaAttrib( nPara, nWhich ) )
1048 [ # # ][ # # ]: 0 : aSet.Put( pEditEngine->GetParaAttrib( nPara, nWhich ) );
1049 : : }
1050 : 0 : nWhich++;
1051 : : }
1052 : :
1053 : 0 : return aSet;
1054 : : }
1055 : :
1056 : 0 : void SmTextForwarder::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
1057 : : {
1058 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1059 [ # # ]: 0 : if (pEditEngine)
1060 : 0 : pEditEngine->SetParaAttribs( nPara, rSet );
1061 : 0 : }
1062 : :
1063 : 0 : SfxItemPool* SmTextForwarder::GetPool() const
1064 : : {
1065 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1066 [ # # ]: 0 : return pEditEngine ? pEditEngine->GetEmptyItemSet().GetPool() : 0;
1067 : : }
1068 : :
1069 : 0 : void SmTextForwarder::RemoveAttribs( const ESelection& rSelection, sal_Bool bRemoveParaAttribs, sal_uInt16 nWhich )
1070 : : {
1071 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1072 [ # # ]: 0 : if (pEditEngine)
1073 : 0 : pEditEngine->RemoveAttribs( rSelection, bRemoveParaAttribs, nWhich );
1074 : 0 : }
1075 : :
1076 : 0 : void SmTextForwarder::GetPortions( sal_uInt16 nPara, std::vector<sal_uInt16>& rList ) const
1077 : : {
1078 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1079 [ # # ]: 0 : if (pEditEngine)
1080 : 0 : pEditEngine->GetPortions( nPara, rList );
1081 : 0 : }
1082 : :
1083 : 0 : void SmTextForwarder::QuickInsertText( const String& rText, const ESelection& rSel )
1084 : : {
1085 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1086 [ # # ]: 0 : if (pEditEngine)
1087 : 0 : pEditEngine->QuickInsertText( rText, rSel );
1088 : 0 : }
1089 : :
1090 : 0 : void SmTextForwarder::QuickInsertLineBreak( const ESelection& rSel )
1091 : : {
1092 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1093 [ # # ]: 0 : if (pEditEngine)
1094 : 0 : pEditEngine->QuickInsertLineBreak( rSel );
1095 : 0 : }
1096 : :
1097 : 0 : void SmTextForwarder::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
1098 : : {
1099 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1100 [ # # ]: 0 : if (pEditEngine)
1101 : 0 : pEditEngine->QuickInsertField( rFld, rSel );
1102 : 0 : }
1103 : :
1104 : 0 : void SmTextForwarder::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
1105 : : {
1106 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1107 [ # # ]: 0 : if (pEditEngine)
1108 : 0 : pEditEngine->QuickSetAttribs( rSet, rSel );
1109 : 0 : }
1110 : :
1111 : 38 : sal_Bool SmTextForwarder::IsValid() const
1112 : : {
1113 : 38 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1114 : : // cannot reliably query EditEngine state
1115 : : // while in the middle of an update
1116 [ + - ]: 38 : return pEditEngine ? pEditEngine->GetUpdateMode() : sal_False;
1117 : : }
1118 : :
1119 : 0 : XubString SmTextForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
1120 : : {
1121 : 0 : XubString aTxt;
1122 [ # # ]: 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1123 [ # # ]: 0 : if (pEditEngine)
1124 [ # # ][ # # ]: 0 : aTxt = pEditEngine->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
[ # # ]
1125 : 0 : return aTxt;
1126 : : }
1127 : :
1128 : 0 : void SmTextForwarder::FieldClicked(const SvxFieldItem&, sal_uInt16, sal_uInt16)
1129 : : {
1130 : 0 : }
1131 : :
1132 : 0 : sal_uInt16 GetSvxEditEngineItemState( EditEngine& rEditEngine, const ESelection& rSel, sal_uInt16 nWhich )
1133 : : {
1134 [ # # ]: 0 : std::vector<EECharAttrib> aAttribs;
1135 : :
1136 : 0 : const SfxPoolItem* pLastItem = NULL;
1137 : :
1138 : 0 : SfxItemState eState = SFX_ITEM_DEFAULT;
1139 : :
1140 : : // check all paragraphs inside the selection
1141 [ # # ]: 0 : for( sal_uInt16 nPara = rSel.nStartPara; nPara <= rSel.nEndPara; nPara++ )
1142 : : {
1143 : 0 : SfxItemState eParaState = SFX_ITEM_DEFAULT;
1144 : :
1145 : : // calculate start and endpos for this paragraph
1146 : 0 : sal_uInt16 nPos = 0;
1147 [ # # ]: 0 : if( rSel.nStartPara == nPara )
1148 : 0 : nPos = rSel.nStartPos;
1149 : :
1150 : 0 : sal_uInt16 nEndPos = rSel.nEndPos;
1151 [ # # ]: 0 : if( rSel.nEndPara != nPara )
1152 [ # # ]: 0 : nEndPos = rEditEngine.GetTextLen( nPara );
1153 : :
1154 : :
1155 : : // get list of char attribs
1156 [ # # ]: 0 : rEditEngine.GetCharAttribs( nPara, aAttribs );
1157 : :
1158 : 0 : bool bEmpty = true; // we found no item inside the selektion of this paragraph
1159 : 0 : bool bGaps = false; // we found items but theire gaps between them
1160 : 0 : sal_uInt16 nLastEnd = nPos;
1161 : :
1162 : 0 : const SfxPoolItem* pParaItem = NULL;
1163 : :
1164 [ # # ][ # # ]: 0 : for(std::vector<EECharAttrib>::const_iterator i = aAttribs.begin(); i < aAttribs.end(); ++i)
[ # # ]
1165 : : {
1166 : : OSL_ENSURE( i->pAttr, "GetCharAttribs gives corrupt data" );
1167 : :
1168 : 0 : const sal_Bool bEmptyPortion = (i->nStart == i->nEnd);
1169 [ # # ][ # # ]: 0 : if( (!bEmptyPortion && (i->nStart >= nEndPos)) || (bEmptyPortion && (i->nStart > nEndPos)) )
[ # # ][ # # ]
[ # # ]
1170 : 0 : break; // break if we are already behind our selektion
1171 : :
1172 [ # # ][ # # ]: 0 : if( (!bEmptyPortion && (i->nEnd <= nPos)) || (bEmptyPortion && (i->nEnd < nPos)) )
[ # # ][ # # ]
[ # # ]
1173 : 0 : continue; // or if the attribute ends before our selektion
1174 : :
1175 [ # # ]: 0 : if( i->pAttr->Which() != nWhich )
1176 : 0 : continue; // skip if is not the searched item
1177 : :
1178 : : // if we already found an item
1179 [ # # ]: 0 : if( pParaItem )
1180 : : {
1181 : : // ... and its different to this one than the state is dont care
1182 [ # # ][ # # ]: 0 : if( *pParaItem != *(i->pAttr) )
1183 : 0 : return SFX_ITEM_DONTCARE;
1184 : : }
1185 : : else
1186 : : {
1187 : 0 : pParaItem = i->pAttr;
1188 : : }
1189 : :
1190 [ # # ]: 0 : if( bEmpty )
1191 : 0 : bEmpty = false;
1192 : :
1193 [ # # ][ # # ]: 0 : if( !bGaps && i->nStart > nLastEnd )
[ # # ]
1194 : 0 : bGaps = true;
1195 : :
1196 : 0 : nLastEnd = i->nEnd;
1197 : : }
1198 : :
1199 [ # # ][ # # ]: 0 : if( !bEmpty && !bGaps && nLastEnd < ( nEndPos - 1 ) )
[ # # ]
1200 : 0 : bGaps = true;
1201 [ # # ]: 0 : if( bEmpty )
1202 : 0 : eParaState = SFX_ITEM_DEFAULT;
1203 [ # # ]: 0 : else if( bGaps )
1204 : 0 : eParaState = SFX_ITEM_DONTCARE;
1205 : : else
1206 : 0 : eParaState = SFX_ITEM_SET;
1207 : :
1208 : : // if we already found an item check if we found the same
1209 [ # # ]: 0 : if( pLastItem )
1210 : : {
1211 [ # # ][ # # ]: 0 : if( (pParaItem == NULL) || (*pLastItem != *pParaItem) )
[ # # ][ # # ]
1212 : 0 : return SFX_ITEM_DONTCARE;
1213 : : }
1214 : : else
1215 : : {
1216 : 0 : pLastItem = pParaItem;
1217 : 0 : eState = eParaState;
1218 : : }
1219 : : }
1220 : :
1221 : 0 : return eState;
1222 : : }
1223 : :
1224 : 0 : sal_uInt16 SmTextForwarder::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const
1225 : : {
1226 : 0 : sal_uInt16 nState = SFX_ITEM_DISABLED;
1227 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1228 [ # # ]: 0 : if (pEditEngine)
1229 : 0 : nState = GetSvxEditEngineItemState( *pEditEngine, rSel, nWhich );
1230 : 0 : return nState;
1231 : : }
1232 : :
1233 : 0 : sal_uInt16 SmTextForwarder::GetItemState( sal_uInt16 nPara, sal_uInt16 nWhich ) const
1234 : : {
1235 : 0 : sal_uInt16 nState = SFX_ITEM_DISABLED;
1236 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1237 [ # # ]: 0 : if (pEditEngine)
1238 : : {
1239 : 0 : const SfxItemSet& rSet = pEditEngine->GetParaAttribs( nPara );
1240 : 0 : nState = rSet.GetItemState( nWhich );
1241 : : }
1242 : 0 : return nState;
1243 : : }
1244 : :
1245 : 0 : LanguageType SmTextForwarder::GetLanguage( sal_uInt16 nPara, sal_uInt16 nIndex ) const
1246 : : {
1247 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1248 [ # # ]: 0 : return pEditEngine ? pEditEngine->GetLanguage(nPara, nIndex) : LANGUAGE_NONE;
1249 : : }
1250 : :
1251 : 12 : sal_uInt16 SmTextForwarder::GetFieldCount( sal_uInt16 nPara ) const
1252 : : {
1253 : 12 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1254 [ + - ]: 12 : return pEditEngine ? pEditEngine->GetFieldCount(nPara) : 0;
1255 : : }
1256 : :
1257 : 0 : EFieldInfo SmTextForwarder::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const
1258 : : {
1259 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1260 [ # # ]: 0 : return pEditEngine ? pEditEngine->GetFieldInfo( nPara, nField ) : EFieldInfo();
1261 : : }
1262 : :
1263 : 40 : EBulletInfo SmTextForwarder::GetBulletInfo( sal_uInt16 /*nPara*/ ) const
1264 : : {
1265 : 40 : return EBulletInfo();
1266 : : }
1267 : :
1268 : 0 : Rectangle SmTextForwarder::GetCharBounds( sal_uInt16 nPara, sal_uInt16 nIndex ) const
1269 : : {
1270 : 0 : Rectangle aRect(0,0,0,0);
1271 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1272 : :
1273 [ # # ]: 0 : if (pEditEngine)
1274 : : {
1275 : : // Handle virtual position one-past-the end of the string
1276 [ # # ]: 0 : if( nIndex >= pEditEngine->GetTextLen(nPara) )
1277 : : {
1278 [ # # ]: 0 : if( nIndex )
1279 [ # # ]: 0 : aRect = pEditEngine->GetCharacterBounds( EPosition(nPara, nIndex-1) );
1280 : :
1281 : 0 : aRect.Move( aRect.Right() - aRect.Left(), 0 );
1282 [ # # ]: 0 : aRect.SetSize( Size(1, pEditEngine->GetTextHeight()) );
1283 : : }
1284 : : else
1285 : : {
1286 [ # # ]: 0 : aRect = pEditEngine->GetCharacterBounds( EPosition(nPara, nIndex) );
1287 : : }
1288 : : }
1289 : 0 : return aRect;
1290 : : }
1291 : :
1292 : 16 : Rectangle SmTextForwarder::GetParaBounds( sal_uInt16 nPara ) const
1293 : : {
1294 : 16 : Rectangle aRect(0,0,0,0);
1295 : 16 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1296 : :
1297 [ + - ]: 16 : if (pEditEngine)
1298 : : {
1299 [ + - ]: 16 : const Point aPnt = pEditEngine->GetDocPosTopLeft( nPara );
1300 [ + - ]: 16 : const sal_uLong nWidth = pEditEngine->CalcTextWidth();
1301 [ + - ]: 16 : const sal_uLong nHeight = pEditEngine->GetTextHeight( nPara );
1302 [ + - ]: 16 : aRect = Rectangle( aPnt.X(), aPnt.Y(), aPnt.X() + nWidth, aPnt.Y() + nHeight );
1303 : : }
1304 : :
1305 : 16 : return aRect;
1306 : : }
1307 : :
1308 : 16 : MapMode SmTextForwarder::GetMapMode() const
1309 : : {
1310 : 16 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1311 [ + - ]: 16 : return pEditEngine ? pEditEngine->GetRefMapMode() : MapMode( MAP_100TH_MM );
1312 : : }
1313 : :
1314 : 0 : OutputDevice* SmTextForwarder::GetRefDevice() const
1315 : : {
1316 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1317 [ # # ]: 0 : return pEditEngine ? pEditEngine->GetRefDevice() : 0;
1318 : : }
1319 : :
1320 : 0 : sal_Bool SmTextForwarder::GetIndexAtPoint( const Point& rPos, sal_uInt16& nPara, sal_uInt16& nIndex ) const
1321 : : {
1322 : 0 : sal_Bool bRes = sal_False;
1323 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1324 [ # # ]: 0 : if (pEditEngine)
1325 : : {
1326 [ # # ]: 0 : EPosition aDocPos = pEditEngine->FindDocPosition( rPos );
1327 : 0 : nPara = aDocPos.nPara;
1328 : 0 : nIndex = aDocPos.nIndex;
1329 : 0 : bRes = sal_True;
1330 : : }
1331 : 0 : return bRes;
1332 : : }
1333 : :
1334 : 0 : sal_Bool SmTextForwarder::GetWordIndices( sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
1335 : : {
1336 : 0 : sal_Bool bRes = sal_False;
1337 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1338 [ # # ]: 0 : if (pEditEngine)
1339 : : {
1340 [ # # ]: 0 : ESelection aRes = pEditEngine->GetWord( ESelection(nPara, nIndex, nPara, nIndex), com::sun::star::i18n::WordType::DICTIONARY_WORD );
1341 : :
1342 [ # # ][ # # ]: 0 : if( aRes.nStartPara == nPara &&
1343 : : aRes.nStartPara == aRes.nEndPara )
1344 : : {
1345 : 0 : nStart = aRes.nStartPos;
1346 : 0 : nEnd = aRes.nEndPos;
1347 : :
1348 : 0 : bRes = sal_True;
1349 : : }
1350 : : }
1351 : :
1352 : 0 : return bRes;
1353 : : }
1354 : :
1355 : 0 : sal_Bool SmTextForwarder::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_uInt16 nPara, sal_uInt16 nIndex ) const
1356 : : {
1357 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1358 : : return pEditEngine ?
1359 : 0 : SvxEditSourceHelper::GetAttributeRun( nStartIndex, nEndIndex, *pEditEngine, nPara, nIndex )
1360 [ # # ]: 0 : : sal_False;
1361 : : }
1362 : :
1363 : 0 : sal_uInt16 SmTextForwarder::GetLineCount( sal_uInt16 nPara ) const
1364 : : {
1365 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1366 [ # # ]: 0 : return pEditEngine ? pEditEngine->GetLineCount(nPara) : 0;
1367 : : }
1368 : :
1369 : 0 : sal_uInt16 SmTextForwarder::GetLineLen( sal_uInt16 nPara, sal_uInt16 nLine ) const
1370 : : {
1371 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1372 [ # # ]: 0 : return pEditEngine ? pEditEngine->GetLineLen(nPara, nLine) : 0;
1373 : : }
1374 : :
1375 : 0 : void SmTextForwarder::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nPara, sal_uInt16 nLine ) const
1376 : : {
1377 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1378 : 0 : pEditEngine->GetLineBoundaries(rStart, rEnd, nPara, nLine);
1379 : 0 : }
1380 : :
1381 : 0 : sal_uInt16 SmTextForwarder::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const
1382 : : {
1383 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1384 [ # # ]: 0 : return pEditEngine ? pEditEngine->GetLineNumberAtIndex(nPara, nIndex) : 0;
1385 : : }
1386 : :
1387 : 0 : sal_Bool SmTextForwarder::QuickFormatDoc( sal_Bool /*bFull*/ )
1388 : : {
1389 : 0 : sal_Bool bRes = sal_False;
1390 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1391 [ # # ]: 0 : if (pEditEngine)
1392 : : {
1393 : 0 : pEditEngine->QuickFormatDoc();
1394 : 0 : bRes = sal_True;
1395 : : }
1396 : 0 : return bRes;
1397 : : }
1398 : :
1399 : 0 : sal_Int16 SmTextForwarder::GetDepth( sal_uInt16 /*nPara*/ ) const
1400 : : {
1401 : : // math has no outliner...
1402 : 0 : return -1;
1403 : : }
1404 : :
1405 : 0 : sal_Bool SmTextForwarder::SetDepth( sal_uInt16 /*nPara*/, sal_Int16 nNewDepth )
1406 : : {
1407 : : // math has no outliner...
1408 : 0 : return -1 == nNewDepth; // is it the value from 'GetDepth' ?
1409 : : }
1410 : :
1411 : 0 : sal_Bool SmTextForwarder::Delete( const ESelection& rSelection )
1412 : : {
1413 : 0 : sal_Bool bRes = sal_False;
1414 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1415 [ # # ]: 0 : if (pEditEngine)
1416 : : {
1417 : 0 : pEditEngine->QuickDelete( rSelection );
1418 : 0 : pEditEngine->QuickFormatDoc();
1419 : 0 : bRes = sal_True;
1420 : : }
1421 : 0 : return bRes;
1422 : : }
1423 : :
1424 : 0 : sal_Bool SmTextForwarder::InsertText( const String& rStr, const ESelection& rSelection )
1425 : : {
1426 : 0 : sal_Bool bRes = sal_False;
1427 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1428 [ # # ]: 0 : if (pEditEngine)
1429 : : {
1430 : 0 : pEditEngine->QuickInsertText( rStr, rSelection );
1431 : 0 : pEditEngine->QuickFormatDoc();
1432 : 0 : bRes = sal_True;
1433 : : }
1434 : 0 : return bRes;
1435 : : }
1436 : :
1437 : 0 : const SfxItemSet* SmTextForwarder::GetEmptyItemSetPtr()
1438 : : {
1439 : 0 : const SfxItemSet *pItemSet = 0;
1440 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1441 [ # # ]: 0 : if (pEditEngine)
1442 : : {
1443 : 0 : pItemSet = &pEditEngine->GetEmptyItemSet();
1444 : : }
1445 : 0 : return pItemSet;
1446 : : }
1447 : :
1448 : 0 : void SmTextForwarder::AppendParagraph()
1449 : : {
1450 : : // append an empty paragraph
1451 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1452 [ # # ]: 0 : if (pEditEngine)
1453 : : {
1454 : 0 : sal_uInt16 nParaCount = pEditEngine->GetParagraphCount();
1455 [ # # ]: 0 : pEditEngine->InsertParagraph( nParaCount, String() );
1456 : : }
1457 : 0 : }
1458 : :
1459 : 0 : xub_StrLen SmTextForwarder::AppendTextPortion( sal_uInt16 nPara, const String &rText, const SfxItemSet &rSet )
1460 : : {
1461 : 0 : xub_StrLen nRes = 0;
1462 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1463 [ # # ][ # # ]: 0 : if (pEditEngine && nPara < pEditEngine->GetParagraphCount())
[ # # ]
1464 : : {
1465 : : // append text
1466 [ # # ]: 0 : ESelection aSel( nPara, pEditEngine->GetTextLen( nPara ) );
1467 [ # # ]: 0 : pEditEngine->QuickInsertText( rText, aSel );
1468 : :
1469 : : // set attributes for new appended text
1470 [ # # ]: 0 : nRes = aSel.nEndPos = pEditEngine->GetTextLen( nPara );
1471 [ # # ]: 0 : pEditEngine->QuickSetAttribs( rSet, aSel );
1472 : : }
1473 : 0 : return nRes;
1474 : : }
1475 : :
1476 : 0 : void SmTextForwarder::CopyText(const SvxTextForwarder& rSource)
1477 : : {
1478 : :
1479 [ # # ]: 0 : const SmTextForwarder* pSourceForwarder = dynamic_cast< const SmTextForwarder* >( &rSource );
1480 [ # # ]: 0 : if( !pSourceForwarder )
1481 : 0 : return;
1482 : 0 : EditEngine* pSourceEditEngine = pSourceForwarder->rEditAcc.GetEditEngine();
1483 : 0 : EditEngine *pEditEngine = rEditAcc.GetEditEngine();
1484 [ # # ][ # # ]: 0 : if (pEditEngine && pSourceEditEngine )
1485 : : {
1486 : 0 : EditTextObject* pNewTextObject = pSourceEditEngine->CreateTextObject();
1487 : 0 : pEditEngine->SetText( *pNewTextObject );
1488 [ # # ]: 0 : delete pNewTextObject;
1489 : : }
1490 : : }
1491 : :
1492 : : //------------------------------------------------------------------------
1493 : :
1494 : 4 : SmEditViewForwarder::SmEditViewForwarder( SmEditAccessible& rAcc ) :
1495 : 4 : rEditAcc( rAcc )
1496 : : {
1497 : 4 : }
1498 : :
1499 : 4 : SmEditViewForwarder::~SmEditViewForwarder()
1500 : : {
1501 [ - + ]: 4 : }
1502 : :
1503 : 8 : sal_Bool SmEditViewForwarder::IsValid() const
1504 : : {
1505 : 8 : return rEditAcc.GetEditView() != 0;
1506 : : }
1507 : :
1508 : 4 : Rectangle SmEditViewForwarder::GetVisArea() const
1509 : : {
1510 : 4 : Rectangle aRect(0,0,0,0);
1511 : :
1512 : 4 : EditView *pEditView = rEditAcc.GetEditView();
1513 [ + - ]: 4 : OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
1514 : :
1515 [ + - ][ + - ]: 4 : if( pOutDev && pEditView)
1516 : : {
1517 [ + - ]: 4 : Rectangle aVisArea = pEditView->GetVisArea();
1518 : :
1519 : : // figure out map mode from edit engine
1520 [ + - ]: 4 : EditEngine* pEditEngine = pEditView->GetEditEngine();
1521 : :
1522 [ + - ]: 4 : if( pEditEngine )
1523 : : {
1524 [ + - ]: 4 : MapMode aMapMode(pOutDev->GetMapMode());
1525 : : aVisArea = OutputDevice::LogicToLogic( aVisArea,
1526 : : pEditEngine->GetRefMapMode(),
1527 [ + - ][ + - ]: 4 : aMapMode.GetMapUnit() );
[ + - ][ + - ]
[ + - ]
1528 [ + - ]: 4 : aMapMode.SetOrigin(Point());
1529 [ + - ][ + - ]: 4 : aRect = pOutDev->LogicToPixel( aVisArea, aMapMode );
1530 : : }
1531 : : }
1532 : :
1533 : 4 : return aRect;
1534 : : }
1535 : :
1536 : 0 : Point SmEditViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
1537 : : {
1538 : 0 : EditView *pEditView = rEditAcc.GetEditView();
1539 [ # # ]: 0 : OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
1540 : :
1541 [ # # ]: 0 : if( pOutDev )
1542 : : {
1543 [ # # ]: 0 : MapMode aMapMode(pOutDev->GetMapMode());
1544 : : Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode,
1545 [ # # ][ # # ]: 0 : aMapMode.GetMapUnit() ) );
[ # # ]
1546 [ # # ]: 0 : aMapMode.SetOrigin(Point());
1547 [ # # ][ # # ]: 0 : return pOutDev->LogicToPixel( aPoint, aMapMode );
1548 : : }
1549 : :
1550 : 0 : return Point();
1551 : : }
1552 : :
1553 : 0 : Point SmEditViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
1554 : : {
1555 : 0 : EditView *pEditView = rEditAcc.GetEditView();
1556 [ # # ]: 0 : OutputDevice* pOutDev = pEditView ? pEditView->GetWindow() : 0;
1557 : :
1558 [ # # ]: 0 : if( pOutDev )
1559 : : {
1560 [ # # ]: 0 : MapMode aMapMode(pOutDev->GetMapMode());
1561 [ # # ]: 0 : aMapMode.SetOrigin(Point());
1562 [ # # ]: 0 : Point aPoint( pOutDev->PixelToLogic( rPoint, aMapMode ) );
1563 : : return OutputDevice::LogicToLogic( aPoint,
1564 : : aMapMode.GetMapUnit(),
1565 [ # # ][ # # ]: 0 : rMapMode );
[ # # ][ # # ]
1566 : : }
1567 : :
1568 : 0 : return Point();
1569 : : }
1570 : :
1571 : 0 : sal_Bool SmEditViewForwarder::GetSelection( ESelection& rSelection ) const
1572 : : {
1573 : 0 : sal_Bool bRes = sal_False;
1574 : 0 : EditView *pEditView = rEditAcc.GetEditView();
1575 [ # # ]: 0 : if (pEditView)
1576 : : {
1577 : 0 : rSelection = pEditView->GetSelection();
1578 : 0 : bRes = sal_True;
1579 : : }
1580 : 0 : return bRes;
1581 : : }
1582 : :
1583 : 0 : sal_Bool SmEditViewForwarder::SetSelection( const ESelection& rSelection )
1584 : : {
1585 : 0 : sal_Bool bRes = sal_False;
1586 : 0 : EditView *pEditView = rEditAcc.GetEditView();
1587 [ # # ]: 0 : if (pEditView)
1588 : : {
1589 : 0 : pEditView->SetSelection( rSelection );
1590 : 0 : bRes = sal_True;
1591 : : }
1592 : 0 : return bRes;
1593 : : }
1594 : :
1595 : 0 : sal_Bool SmEditViewForwarder::Copy()
1596 : : {
1597 : 0 : sal_Bool bRes = sal_False;
1598 : 0 : EditView *pEditView = rEditAcc.GetEditView();
1599 [ # # ]: 0 : if (pEditView)
1600 : : {
1601 : 0 : pEditView->Copy();
1602 : 0 : bRes = sal_True;
1603 : : }
1604 : 0 : return bRes;
1605 : : }
1606 : :
1607 : 0 : sal_Bool SmEditViewForwarder::Cut()
1608 : : {
1609 : 0 : sal_Bool bRes = sal_False;
1610 : 0 : EditView *pEditView = rEditAcc.GetEditView();
1611 [ # # ]: 0 : if (pEditView)
1612 : : {
1613 : 0 : pEditView->Cut();
1614 : 0 : bRes = sal_True;
1615 : : }
1616 : 0 : return bRes;
1617 : : }
1618 : :
1619 : 0 : sal_Bool SmEditViewForwarder::Paste()
1620 : : {
1621 : 0 : sal_Bool bRes = sal_False;
1622 : 0 : EditView *pEditView = rEditAcc.GetEditView();
1623 [ # # ]: 0 : if (pEditView)
1624 : : {
1625 : 0 : pEditView->Paste();
1626 : 0 : bRes = sal_True;
1627 : : }
1628 : 0 : return bRes;
1629 : : }
1630 : :
1631 : : //------------------------------------------------------------------------
1632 : :
1633 : 4 : SmEditAccessible::SmEditAccessible( SmEditWindow *pEditWin ) :
1634 : : aAccName ( String(SmResId(STR_CMDBOXWINDOW)) ),
1635 : : pTextHelper (0),
1636 [ + - ][ + - ]: 4 : pWin (pEditWin)
[ + - ]
1637 : : {
1638 : : OSL_ENSURE( pWin, "SmEditAccessible: window missing" );
1639 : 4 : }
1640 : :
1641 : :
1642 : 0 : SmEditAccessible::SmEditAccessible( const SmEditAccessible &rSmAcc ) :
1643 : : SmEditAccessibleBaseClass(),
1644 [ # # ][ # # ]: 0 : aAccName ( String(SmResId(STR_CMDBOXWINDOW)) )
[ # # ]
1645 : : {
1646 : 0 : pWin = rSmAcc.pWin;
1647 : : OSL_ENSURE( pWin, "SmEditAccessible: window missing" );
1648 : 0 : }
1649 : :
1650 [ + - ][ + - ]: 4 : SmEditAccessible::~SmEditAccessible()
1651 : : {
1652 [ - + ][ # # ]: 4 : delete pTextHelper;
1653 [ - + ]: 8 : }
1654 : :
1655 : 4 : void SmEditAccessible::Init()
1656 : : {
1657 : : OSL_ENSURE( pWin, "SmEditAccessible: window missing" );
1658 [ + - ]: 4 : if (pWin)
1659 : : {
1660 : 4 : EditEngine *pEditEngine = pWin->GetEditEngine();
1661 : 4 : EditView *pEditView = pWin->GetEditView();
1662 [ + - ][ + - ]: 4 : if (pEditEngine && pEditView)
1663 : : {
1664 : : ::std::auto_ptr< SvxEditSource > pEditSource(
1665 [ + - ][ + - ]: 4 : new SmEditSource( pWin, *this ) );
1666 [ + - ][ + - ]: 4 : pTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource );
[ + - ]
1667 [ + - ][ + - ]: 4 : pTextHelper->SetEventSource( this );
[ + - ]
1668 : : }
1669 : : }
1670 : 4 : }
1671 : :
1672 : 4 : void SmEditAccessible::ClearWin()
1673 : : {
1674 : : // remove handler before current object gets destroyed
1675 : : // (avoid handler being called for already dead object)
1676 : 4 : EditEngine *pEditEngine = GetEditEngine();
1677 [ + - ]: 4 : if (pEditEngine)
1678 [ + - ]: 4 : pEditEngine->SetNotifyHdl( Link() );
1679 : :
1680 : 4 : pWin = 0; // implicitly results in AccessibleStateType::DEFUNC set
1681 : :
1682 : : //! make TextHelper implicitly release C++ references to some core objects
1683 [ + - ][ + - ]: 4 : pTextHelper->SetEditSource( ::std::auto_ptr<SvxEditSource>(NULL) );
1684 : : //! make TextHelper release references
1685 : : //! (e.g. the one set by the 'SetEventSource' call)
1686 : 4 : pTextHelper->Dispose();
1687 [ + - ]: 4 : delete pTextHelper; pTextHelper = 0;
1688 : 4 : }
1689 : :
1690 : : // XAccessible
1691 : 26 : uno::Reference< XAccessibleContext > SAL_CALL SmEditAccessible::getAccessibleContext( )
1692 : : throw (RuntimeException)
1693 : : {
1694 [ + - ]: 26 : SolarMutexGuard aGuard;
1695 [ + - ][ + - ]: 26 : return this;
1696 : : }
1697 : :
1698 : : // XAccessibleComponent
1699 : 3740 : sal_Bool SAL_CALL SmEditAccessible::containsPoint( const awt::Point& aPoint )
1700 : : throw (RuntimeException)
1701 : : {
1702 : : //! the arguments coordinates are relativ to the current window !
1703 : : //! Thus the top left-point is (0, 0)
1704 : :
1705 [ + - ]: 3740 : SolarMutexGuard aGuard;
1706 [ - + ]: 3740 : if (!pWin)
1707 [ # # ]: 0 : throw RuntimeException();
1708 : :
1709 [ + - ]: 3740 : Size aSz( pWin->GetSizePixel() );
1710 : : return aPoint.X >= 0 && aPoint.Y >= 0 &&
1711 [ + + ][ + + ]: 3740 : aPoint.X < aSz.Width() && aPoint.Y < aSz.Height();
[ + + ][ + + ]
[ + - ]
1712 : : }
1713 : :
1714 : 4 : uno::Reference< XAccessible > SAL_CALL SmEditAccessible::getAccessibleAtPoint( const awt::Point& aPoint )
1715 : : throw (RuntimeException)
1716 : : {
1717 [ + - ]: 4 : SolarMutexGuard aGuard;
1718 [ - + ]: 4 : if (!pTextHelper)
1719 [ # # ]: 0 : throw RuntimeException();
1720 [ + - ][ + - ]: 4 : return pTextHelper->GetAt( aPoint );
1721 : : }
1722 : :
1723 : 2 : awt::Rectangle SAL_CALL SmEditAccessible::getBounds( )
1724 : : throw (RuntimeException)
1725 : : {
1726 [ + - ]: 2 : SolarMutexGuard aGuard;
1727 [ - + ]: 2 : if (!pWin)
1728 [ # # ]: 0 : throw RuntimeException();
1729 : : OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
1730 : : "mismatch of window parent and accessible parent" );
1731 [ + - ][ + - ]: 2 : return lcl_GetBounds( pWin );
1732 : : }
1733 : :
1734 : 2 : awt::Point SAL_CALL SmEditAccessible::getLocation( )
1735 : : throw (RuntimeException)
1736 : : {
1737 [ + - ]: 2 : SolarMutexGuard aGuard;
1738 [ - + ]: 2 : if (!pWin)
1739 [ # # ]: 0 : throw RuntimeException();
1740 : : OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
1741 : : "mismatch of window parent and accessible parent" );
1742 [ + - ]: 2 : awt::Rectangle aRect( lcl_GetBounds( pWin ) );
1743 [ + - ]: 2 : return awt::Point( aRect.X, aRect.Y );
1744 : : }
1745 : :
1746 : 2 : awt::Point SAL_CALL SmEditAccessible::getLocationOnScreen( )
1747 : : throw (RuntimeException)
1748 : : {
1749 [ + - ]: 2 : SolarMutexGuard aGuard;
1750 [ - + ]: 2 : if (!pWin)
1751 [ # # ]: 0 : throw RuntimeException();
1752 : : OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
1753 : : "mismatch of window parent and accessible parent" );
1754 [ + - ][ + - ]: 2 : return lcl_GetLocationOnScreen( pWin );
1755 : : }
1756 : :
1757 : 2 : awt::Size SAL_CALL SmEditAccessible::getSize( )
1758 : : throw (RuntimeException)
1759 : : {
1760 [ + - ]: 2 : SolarMutexGuard aGuard;
1761 [ - + ]: 2 : if (!pWin)
1762 [ # # ]: 0 : throw RuntimeException();
1763 : : OSL_ENSURE(pWin->GetParent()->GetAccessible() == getAccessibleParent(),
1764 : : "mismatch of window parent and accessible parent" );
1765 : :
1766 [ + - ]: 2 : Size aSz( pWin->GetSizePixel() );
1767 : : #if OSL_DEBUG_LEVEL > 1
1768 : : awt::Rectangle aRect( lcl_GetBounds( pWin ) );
1769 : : Size aSz2( aRect.Width, aRect.Height );
1770 : : OSL_ENSURE( aSz == aSz2, "mismatch in width" );
1771 : : #endif
1772 [ + - ]: 2 : return awt::Size( aSz.Width(), aSz.Height() );
1773 : : }
1774 : :
1775 : 2 : void SAL_CALL SmEditAccessible::grabFocus( )
1776 : : throw (RuntimeException)
1777 : : {
1778 [ + - ]: 2 : SolarMutexGuard aGuard;
1779 [ - + ]: 2 : if (!pWin)
1780 [ # # ]: 0 : throw RuntimeException();
1781 : :
1782 [ + - ][ + - ]: 2 : pWin->GrabFocus();
1783 : 2 : }
1784 : :
1785 : 2 : sal_Int32 SAL_CALL SmEditAccessible::getForeground()
1786 : : throw (RuntimeException)
1787 : : {
1788 [ + - ]: 2 : SolarMutexGuard aGuard;
1789 : :
1790 [ - + ]: 2 : if (!pWin)
1791 [ # # ]: 0 : throw RuntimeException();
1792 [ + - ]: 2 : return (sal_Int32) pWin->GetTextColor().GetColor();
1793 : : }
1794 : :
1795 : 2 : sal_Int32 SAL_CALL SmEditAccessible::getBackground()
1796 : : throw (RuntimeException)
1797 : : {
1798 [ + - ]: 2 : SolarMutexGuard aGuard;
1799 : :
1800 [ - + ]: 2 : if (!pWin)
1801 [ # # ]: 0 : throw RuntimeException();
1802 [ + - ][ + - ]: 2 : Wallpaper aWall( pWin->GetDisplayBackground() );
1803 : : ColorData nCol;
1804 [ + - ][ + - ]: 2 : if (aWall.IsBitmap() || aWall.IsGradient())
[ + - ][ - + ]
[ - + ]
1805 : 0 : nCol = pWin->GetSettings().GetStyleSettings().GetWindowColor().GetColor();
1806 : : else
1807 [ + - ]: 2 : nCol = aWall.GetColor().GetColor();
1808 [ + - ][ + - ]: 2 : return (sal_Int32) nCol;
1809 : : }
1810 : :
1811 : : // XAccessibleContext
1812 : 16 : sal_Int32 SAL_CALL SmEditAccessible::getAccessibleChildCount( )
1813 : : throw (RuntimeException)
1814 : : {
1815 [ + - ]: 16 : SolarMutexGuard aGuard;
1816 [ - + ]: 16 : if (!pTextHelper)
1817 [ # # ]: 0 : throw RuntimeException();
1818 [ + - ][ + - ]: 16 : return pTextHelper->GetChildCount();
1819 : : }
1820 : :
1821 : 4 : uno::Reference< XAccessible > SAL_CALL SmEditAccessible::getAccessibleChild( sal_Int32 i )
1822 : : throw (IndexOutOfBoundsException, RuntimeException)
1823 : : {
1824 [ + - ]: 4 : SolarMutexGuard aGuard;
1825 [ - + ]: 4 : if (!pTextHelper)
1826 [ # # ]: 0 : throw RuntimeException();
1827 [ + - ][ + - ]: 4 : return pTextHelper->GetChild( i );
1828 : : }
1829 : :
1830 : 16 : uno::Reference< XAccessible > SAL_CALL SmEditAccessible::getAccessibleParent( )
1831 : : throw (RuntimeException)
1832 : : {
1833 [ + - ]: 16 : SolarMutexGuard aGuard;
1834 [ - + ]: 16 : if (!pWin)
1835 [ # # ]: 0 : throw RuntimeException();
1836 : :
1837 [ + - ]: 16 : Window *pAccParent = pWin->GetAccessibleParentWindow();
1838 : : OSL_ENSURE( pAccParent, "accessible parent missing" );
1839 [ + - ][ + - ]: 16 : return pAccParent ? pAccParent->GetAccessible() : Reference< XAccessible >();
[ + - ]
1840 : : }
1841 : :
1842 : 2 : sal_Int32 SAL_CALL SmEditAccessible::getAccessibleIndexInParent( )
1843 : : throw (RuntimeException)
1844 : : {
1845 [ + - ]: 2 : SolarMutexGuard aGuard;
1846 : 2 : sal_Int32 nIdx = -1;
1847 [ + - ][ + - ]: 2 : Window *pAccParent = pWin ? pWin->GetAccessibleParentWindow() : 0;
1848 [ + - ]: 2 : if (pAccParent)
1849 : : {
1850 [ + - ]: 2 : sal_uInt16 nCnt = pAccParent->GetAccessibleChildWindowCount();
1851 [ + + ][ + - ]: 4 : for (sal_uInt16 i = 0; i < nCnt && nIdx == -1; ++i)
[ + + ]
1852 [ + - ][ + - ]: 2 : if (pAccParent->GetAccessibleChildWindow( i ) == pWin)
1853 : 2 : nIdx = i;
1854 : : }
1855 [ + - ]: 2 : return nIdx;
1856 : : }
1857 : :
1858 : 18 : sal_Int16 SAL_CALL SmEditAccessible::getAccessibleRole( )
1859 : : throw (RuntimeException)
1860 : : {
1861 [ + - ]: 18 : SolarMutexGuard aGuard;
1862 [ + - ]: 18 : return AccessibleRole::PANEL /*TEXT ?*/;
1863 : : }
1864 : :
1865 : 14 : rtl::OUString SAL_CALL SmEditAccessible::getAccessibleDescription( )
1866 : : throw (RuntimeException)
1867 : : {
1868 [ + - ]: 14 : SolarMutexGuard aGuard;
1869 [ + - ]: 14 : return OUString(); // empty as agreed with product-management
1870 : : }
1871 : :
1872 : 18 : rtl::OUString SAL_CALL SmEditAccessible::getAccessibleName( )
1873 : : throw (RuntimeException)
1874 : : {
1875 [ + - ]: 18 : SolarMutexGuard aGuard;
1876 : : // same name as displayed by the window when not docked
1877 [ + - ][ + - ]: 18 : return aAccName;
1878 : : }
1879 : :
1880 : 2 : uno::Reference< XAccessibleRelationSet > SAL_CALL SmEditAccessible::getAccessibleRelationSet( )
1881 : : throw (RuntimeException)
1882 : : {
1883 [ + - ]: 2 : SolarMutexGuard aGuard;
1884 [ + - ][ + - ]: 2 : Reference< XAccessibleRelationSet > xRelSet = new utl::AccessibleRelationSetHelper();
[ + - ]
1885 [ + - ]: 2 : return xRelSet; // empty relation set
1886 : : }
1887 : :
1888 : 6 : uno::Reference< XAccessibleStateSet > SAL_CALL SmEditAccessible::getAccessibleStateSet( )
1889 : : throw (RuntimeException)
1890 : : {
1891 [ + - ]: 6 : SolarMutexGuard aGuard;
1892 : : ::utl::AccessibleStateSetHelper *pStateSet =
1893 [ + - ]: 6 : new ::utl::AccessibleStateSetHelper;
1894 : :
1895 [ + - ][ + - ]: 6 : Reference<XAccessibleStateSet> xStateSet( pStateSet );
1896 : :
1897 [ + - ][ - + ]: 6 : if (!pWin || !pTextHelper)
1898 [ # # ]: 0 : pStateSet->AddState( AccessibleStateType::DEFUNC );
1899 : : else
1900 : : {
1901 [ + - ]: 6 : pStateSet->AddState( AccessibleStateType::MULTI_LINE );
1902 [ + - ]: 6 : pStateSet->AddState( AccessibleStateType::ENABLED );
1903 [ + - ]: 6 : pStateSet->AddState( AccessibleStateType::FOCUSABLE );
1904 [ + - ][ + - ]: 6 : if (pWin->HasFocus())
1905 [ + - ]: 6 : pStateSet->AddState( AccessibleStateType::FOCUSED );
1906 [ + - ][ - + ]: 6 : if (pWin->IsActive())
1907 [ # # ]: 0 : pStateSet->AddState( AccessibleStateType::ACTIVE );
1908 [ + - ][ + - ]: 6 : if (pWin->IsVisible())
1909 [ + - ]: 6 : pStateSet->AddState( AccessibleStateType::SHOWING );
1910 [ + - ][ + - ]: 6 : if (pWin->IsReallyVisible())
1911 [ + - ]: 6 : pStateSet->AddState( AccessibleStateType::VISIBLE );
1912 [ + - ][ + - ]: 6 : if (COL_TRANSPARENT != pWin->GetBackground().GetColor().GetColor())
1913 [ + - ]: 6 : pStateSet->AddState( AccessibleStateType::OPAQUE );
1914 : : }
1915 : :
1916 [ + - ]: 6 : return xStateSet;
1917 : : }
1918 : :
1919 : 2 : Locale SAL_CALL SmEditAccessible::getLocale( )
1920 : : throw (IllegalAccessibleComponentStateException, RuntimeException)
1921 : : {
1922 [ + - ]: 2 : SolarMutexGuard aGuard;
1923 : : // should be the document language...
1924 : : // We use the language of the localized symbol names here.
1925 [ + - ][ + - ]: 2 : return Application::GetSettings().GetUILocale();
[ + - ]
1926 : : }
1927 : :
1928 : :
1929 : : // XAccessibleEventBroadcaster
1930 : 0 : void SAL_CALL SmEditAccessible::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
1931 : : throw (RuntimeException)
1932 : : {
1933 [ # # ]: 0 : if (pTextHelper) // not disposing (about to destroy view shell)
1934 : 0 : pTextHelper->AddEventListener( xListener );
1935 : 0 : }
1936 : :
1937 : 0 : void SAL_CALL SmEditAccessible::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
1938 : : throw (RuntimeException)
1939 : : {
1940 [ # # ]: 0 : if (pTextHelper) // not disposing (about to destroy view shell)
1941 : 0 : pTextHelper->RemoveEventListener( xListener );
1942 : 0 : }
1943 : :
1944 : 8 : OUString SAL_CALL SmEditAccessible::getImplementationName()
1945 : : throw (RuntimeException)
1946 : : {
1947 : 8 : return OUString("SmEditAccessible");
1948 : : }
1949 : :
1950 : 0 : sal_Bool SAL_CALL SmEditAccessible::supportsService(
1951 : : const OUString& rServiceName )
1952 : : throw (RuntimeException)
1953 : : {
1954 : 0 : return rServiceName == "com::sun::star::accessibility::Accessible" ||
1955 : 0 : rServiceName == "com::sun::star::accessibility::AccessibleComponent" ||
1956 [ # # ]: 0 : rServiceName == "com::sun::star::accessibility::AccessibleContext";
[ # # # # ]
1957 : : }
1958 : :
1959 : 0 : Sequence< OUString > SAL_CALL SmEditAccessible::getSupportedServiceNames()
1960 : : throw (RuntimeException)
1961 : : {
1962 : 0 : Sequence< OUString > aNames(3);
1963 [ # # ]: 0 : OUString *pNames = aNames.getArray();
1964 : 0 : pNames[0] = "com::sun::star::accessibility::Accessible";
1965 : 0 : pNames[1] = "com::sun::star::accessibility::AccessibleComponent";
1966 : 0 : pNames[2] = "com::sun::star::accessibility::AccessibleContext";
1967 : 0 : return aNames;
1968 [ + - ][ + - ]: 30 : }
1969 : :
1970 : : //////////////////////////////////////////////////////////////////////
1971 : :
1972 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|