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