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