use "Rubik" from more_fonts instead of "System" for consistent layout
[LibreOffice.git] / starmath / source / accessibility.cxx
blob63de6e0d6ea30dfae285e9cf857f5131677128d0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/accessibility/AccessibleRole.hpp>
21 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
22 #include <com/sun/star/accessibility/AccessibleTextType.hpp>
23 #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
24 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25 #include <unotools/accessiblerelationsethelper.hxx>
27 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
28 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
29 #include <comphelper/accessibleeventnotifier.hxx>
30 #include <cppuhelper/supportsservice.hxx>
31 #include <osl/diagnose.h>
32 #include <comphelper/diagnose_ex.hxx>
33 #include <vcl/svapp.hxx>
34 #include <vcl/unohelp2.hxx>
35 #include <vcl/settings.hxx>
37 #include <tools/gen.hxx>
39 #include <editeng/editobj.hxx>
42 #include "accessibility.hxx"
43 #include <document.hxx>
44 #include <view.hxx>
45 #include <strings.hrc>
46 #include <smmod.hxx>
48 using namespace com::sun::star;
49 using namespace com::sun::star::lang;
50 using namespace com::sun::star::uno;
51 using namespace com::sun::star::accessibility;
53 SmGraphicAccessible::SmGraphicAccessible(SmGraphicWidget *pGraphicWin) :
54 aAccName (SmResId(RID_DOCUMENTSTR)),
55 nClientId (0),
56 pWin (pGraphicWin)
58 OSL_ENSURE( pWin, "SmGraphicAccessible: window missing" );
61 SmGraphicAccessible::~SmGraphicAccessible()
65 SmDocShell * SmGraphicAccessible::GetDoc_Impl()
67 SmViewShell *pView = pWin ? &pWin->GetView() : nullptr;
68 return pView ? pView->GetDoc() : nullptr;
71 OUString SmGraphicAccessible::GetAccessibleText_Impl()
73 OUString aTxt;
74 SmDocShell *pDoc = GetDoc_Impl();
75 if (pDoc)
76 aTxt = pDoc->GetAccessibleText();
77 return aTxt;
80 void SmGraphicAccessible::ClearWin()
82 pWin = nullptr; // implicitly results in AccessibleStateType::DEFUNC set
84 if ( nClientId )
86 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( std::exchange(nClientId, 0), *this );
90 void SmGraphicAccessible::LaunchEvent(
91 const sal_Int16 nAccessibleEventId,
92 const uno::Any &rOldVal,
93 const uno::Any &rNewVal)
95 AccessibleEventObject aEvt;
96 aEvt.Source = static_cast<XAccessible *>(this);
97 aEvt.EventId = nAccessibleEventId;
98 aEvt.OldValue = rOldVal;
99 aEvt.NewValue = rNewVal ;
101 // pass event on to event-listener's
102 if (nClientId)
103 comphelper::AccessibleEventNotifier::addEvent( nClientId, aEvt );
106 uno::Reference< XAccessibleContext > SAL_CALL SmGraphicAccessible::getAccessibleContext()
108 return this;
111 sal_Bool SAL_CALL SmGraphicAccessible::containsPoint( const awt::Point& aPoint )
113 //! the arguments coordinates are relative to the current window !
114 //! Thus the top-left point is (0, 0)
116 SolarMutexGuard aGuard;
117 if (!pWin)
118 throw RuntimeException();
120 Size aSz( pWin->GetOutputSizePixel() );
121 return aPoint.X >= 0 && aPoint.Y >= 0 &&
122 aPoint.X < aSz.Width() && aPoint.Y < aSz.Height();
125 uno::Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleAtPoint(
126 const awt::Point& aPoint )
128 SolarMutexGuard aGuard;
129 XAccessible *pRes = nullptr;
130 if (containsPoint( aPoint ))
131 pRes = this;
132 return pRes;
135 awt::Rectangle SAL_CALL SmGraphicAccessible::getBounds()
137 SolarMutexGuard aGuard;
138 if (!pWin)
139 throw RuntimeException();
141 const Point aOutPos;
142 const Size aOutSize(pWin->GetOutputSizePixel());
143 css::awt::Rectangle aRet;
145 aRet.X = aOutPos.X();
146 aRet.Y = aOutPos.Y();
147 aRet.Width = aOutSize.Width();
148 aRet.Height = aOutSize.Height();
150 return aRet;
153 awt::Point SAL_CALL SmGraphicAccessible::getLocation()
155 SolarMutexGuard aGuard;
156 if (!pWin)
157 throw RuntimeException();
159 const css::awt::Rectangle aRect(getBounds());
160 css::awt::Point aRet;
162 aRet.X = aRect.X;
163 aRet.Y = aRect.Y;
165 return aRet;
168 awt::Point SAL_CALL SmGraphicAccessible::getLocationOnScreen()
170 SolarMutexGuard aGuard;
171 if (!pWin)
172 throw RuntimeException();
174 css::awt::Point aScreenLoc(0, 0);
176 css::uno::Reference<css::accessibility::XAccessible> xParent(getAccessibleParent());
177 if (xParent)
179 css::uno::Reference<css::accessibility::XAccessibleContext> xParentContext(
180 xParent->getAccessibleContext());
181 css::uno::Reference<css::accessibility::XAccessibleComponent> xParentComponent(
182 xParentContext, css::uno::UNO_QUERY);
183 OSL_ENSURE(xParentComponent.is(),
184 "WeldEditAccessible::getLocationOnScreen: no parent component!");
185 if (xParentComponent.is())
187 css::awt::Point aParentScreenLoc(xParentComponent->getLocationOnScreen());
188 css::awt::Point aOwnRelativeLoc(getLocation());
189 aScreenLoc.X = aParentScreenLoc.X + aOwnRelativeLoc.X;
190 aScreenLoc.Y = aParentScreenLoc.Y + aOwnRelativeLoc.Y;
194 return aScreenLoc;
197 awt::Size SAL_CALL SmGraphicAccessible::getSize()
199 SolarMutexGuard aGuard;
200 if (!pWin)
201 throw RuntimeException();
202 Size aSz(pWin->GetOutputSizePixel());
203 return css::awt::Size(aSz.Width(), aSz.Height());
206 void SAL_CALL SmGraphicAccessible::grabFocus()
208 SolarMutexGuard aGuard;
209 if (!pWin)
210 throw RuntimeException();
212 pWin->GrabFocus();
215 sal_Int32 SAL_CALL SmGraphicAccessible::getForeground()
217 SolarMutexGuard aGuard;
218 if (!pWin)
219 throw RuntimeException();
221 weld::DrawingArea* pDrawingArea = pWin->GetDrawingArea();
222 OutputDevice& rDevice = pDrawingArea->get_ref_device();
224 return static_cast<sal_Int32>(rDevice.GetTextColor());
227 sal_Int32 SAL_CALL SmGraphicAccessible::getBackground()
229 SolarMutexGuard aGuard;
230 if (!pWin)
231 throw RuntimeException();
233 weld::DrawingArea* pDrawingArea = pWin->GetDrawingArea();
234 OutputDevice& rDevice = pDrawingArea->get_ref_device();
236 Wallpaper aWall(rDevice.GetBackground());
237 Color nCol;
238 if (aWall.IsBitmap() || aWall.IsGradient())
239 nCol = Application::GetSettings().GetStyleSettings().GetWindowColor();
240 else
241 nCol = aWall.GetColor();
242 return static_cast<sal_Int32>(nCol);
245 sal_Int32 SAL_CALL SmGraphicAccessible::getAccessibleChildCount()
247 return 0;
250 Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleChild(
251 sal_Int32 /*i*/ )
253 throw IndexOutOfBoundsException(); // there is no child...
256 Reference< XAccessible > SAL_CALL SmGraphicAccessible::getAccessibleParent()
258 SolarMutexGuard aGuard;
259 if (!pWin)
260 throw RuntimeException();
262 return pWin->GetDrawingArea()->get_accessible_parent();
265 sal_Int32 SAL_CALL SmGraphicAccessible::getAccessibleIndexInParent()
267 SolarMutexGuard aGuard;
269 // -1 for child not found/no parent (according to specification)
270 sal_Int32 nRet = -1;
272 css::uno::Reference<css::accessibility::XAccessible> xParent(getAccessibleParent());
273 if (!xParent)
274 return nRet;
278 css::uno::Reference<css::accessibility::XAccessibleContext> xParentContext(
279 xParent->getAccessibleContext());
281 // iterate over parent's children and search for this object
282 if (xParentContext.is())
284 sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
285 for (sal_Int32 nChild = 0; (nChild < nChildCount) && (-1 == nRet); ++nChild)
287 css::uno::Reference<css::accessibility::XAccessible> xChild(
288 xParentContext->getAccessibleChild(nChild));
289 if (xChild.get() == this)
290 nRet = nChild;
294 catch (const css::uno::Exception&)
296 TOOLS_WARN_EXCEPTION("svx", "WeldEditAccessible::getAccessibleIndexInParent");
299 return nRet;
302 sal_Int16 SAL_CALL SmGraphicAccessible::getAccessibleRole()
304 return AccessibleRole::DOCUMENT;
307 OUString SAL_CALL SmGraphicAccessible::getAccessibleDescription()
309 SolarMutexGuard aGuard;
310 SmDocShell *pDoc = GetDoc_Impl();
311 return pDoc ? pDoc->GetText() : OUString();
314 OUString SAL_CALL SmGraphicAccessible::getAccessibleName()
316 SolarMutexGuard aGuard;
317 return aAccName;
320 Reference< XAccessibleRelationSet > SAL_CALL SmGraphicAccessible::getAccessibleRelationSet()
322 return new utl::AccessibleRelationSetHelper(); // empty relation set
325 sal_Int64 SAL_CALL SmGraphicAccessible::getAccessibleStateSet()
327 SolarMutexGuard aGuard;
328 sal_Int64 nStateSet = 0;
330 if (!pWin)
331 nStateSet |= AccessibleStateType::DEFUNC;
332 else
334 nStateSet |= AccessibleStateType::ENABLED;
335 nStateSet |= AccessibleStateType::FOCUSABLE;
336 if (pWin->HasFocus())
337 nStateSet |= AccessibleStateType::FOCUSED;
338 if (pWin->IsActive())
339 nStateSet |= AccessibleStateType::ACTIVE;
340 if (pWin->IsVisible())
341 nStateSet |= AccessibleStateType::SHOWING;
342 if (pWin->IsReallyVisible())
343 nStateSet |= AccessibleStateType::VISIBLE;
344 weld::DrawingArea* pDrawingArea = pWin->GetDrawingArea();
345 OutputDevice& rDevice = pDrawingArea->get_ref_device();
346 if (COL_TRANSPARENT != rDevice.GetBackground().GetColor())
347 nStateSet |= AccessibleStateType::OPAQUE;
350 return nStateSet;
353 Locale SAL_CALL SmGraphicAccessible::getLocale()
355 SolarMutexGuard aGuard;
356 // should be the document language...
357 // We use the language of the localized symbol names here.
358 return Application::GetSettings().GetUILanguageTag().getLocale();
362 void SAL_CALL SmGraphicAccessible::addAccessibleEventListener(
363 const Reference< XAccessibleEventListener >& xListener )
365 if (xListener.is())
367 SolarMutexGuard aGuard;
368 if (pWin)
370 if (!nClientId)
371 nClientId = comphelper::AccessibleEventNotifier::registerClient( );
372 comphelper::AccessibleEventNotifier::addEventListener( nClientId, xListener );
377 void SAL_CALL SmGraphicAccessible::removeAccessibleEventListener(
378 const Reference< XAccessibleEventListener >& xListener )
380 if (!(xListener.is() && nClientId))
381 return;
383 SolarMutexGuard aGuard;
384 sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( nClientId, xListener );
385 if ( !nListenerCount )
387 // no listeners anymore
388 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
389 // and at least to us not firing any events anymore, in case somebody calls
390 // NotifyAccessibleEvent, again
391 comphelper::AccessibleEventNotifier::revokeClient( std::exchange(nClientId, 0) );
395 sal_Int32 SAL_CALL SmGraphicAccessible::getCaretPosition()
397 return 0;
400 sal_Bool SAL_CALL SmGraphicAccessible::setCaretPosition( sal_Int32 nIndex )
402 SolarMutexGuard aGuard;
403 OUString aTxt( GetAccessibleText_Impl() );
404 if (nIndex >= aTxt.getLength())
405 throw IndexOutOfBoundsException();
406 return false;
409 sal_Unicode SAL_CALL SmGraphicAccessible::getCharacter( sal_Int32 nIndex )
411 SolarMutexGuard aGuard;
412 OUString aTxt( GetAccessibleText_Impl() );
413 if (nIndex >= aTxt.getLength())
414 throw IndexOutOfBoundsException();
415 return aTxt[nIndex];
418 Sequence< beans::PropertyValue > SAL_CALL SmGraphicAccessible::getCharacterAttributes(
419 sal_Int32 nIndex,
420 const uno::Sequence< OUString > & /*rRequestedAttributes*/ )
422 SolarMutexGuard aGuard;
423 sal_Int32 nLen = GetAccessibleText_Impl().getLength();
424 if (0 > nIndex || nIndex >= nLen)
425 throw IndexOutOfBoundsException();
426 return Sequence< beans::PropertyValue >();
429 awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nIndex )
431 SolarMutexGuard aGuard;
433 awt::Rectangle aRes;
435 if (!pWin)
436 throw RuntimeException();
438 // get accessible text
439 SmDocShell* pDoc = pWin->GetView().GetDoc();
440 if (!pDoc)
441 throw RuntimeException();
442 OUString aTxt( GetAccessibleText_Impl() );
443 if (0 > nIndex || nIndex > aTxt.getLength()) // aTxt.getLength() is valid
444 throw IndexOutOfBoundsException();
446 // find a reasonable rectangle for position aTxt.getLength().
447 bool bWasBehindText = (nIndex == aTxt.getLength());
448 if (bWasBehindText && nIndex)
449 --nIndex;
451 const SmNode *pTree = pDoc->GetFormulaTree();
452 const SmNode *pNode = pTree->FindNodeWithAccessibleIndex( nIndex );
453 //! pNode may be 0 if the index belongs to a char that was inserted
454 //! only for the accessible text!
455 if (pNode)
457 sal_Int32 nAccIndex = pNode->GetAccessibleIndex();
458 OSL_ENSURE( nAccIndex >= 0, "invalid accessible index" );
459 OSL_ENSURE( nIndex >= nAccIndex, "index out of range" );
461 OUStringBuffer aBuf;
462 pNode->GetAccessibleText(aBuf);
463 OUString aNodeText = aBuf.makeStringAndClear();
464 sal_Int32 nNodeIndex = nIndex - nAccIndex;
465 if (0 <= nNodeIndex && nNodeIndex < aNodeText.getLength())
467 // get appropriate rectangle
468 Point aOffset(pNode->GetTopLeft() - pTree->GetTopLeft());
469 Point aTLPos (pWin->GetFormulaDrawPos() + aOffset);
470 Size aSize (pNode->GetSize());
472 weld::DrawingArea* pDrawingArea = pWin->GetDrawingArea();
473 OutputDevice& rDevice = pDrawingArea->get_ref_device();
475 std::vector<sal_Int32> aXAry;
476 rDevice.SetFont( pNode->GetFont() );
477 rDevice.GetTextArray( aNodeText, &aXAry, 0, aNodeText.getLength() );
478 aTLPos.AdjustX(nNodeIndex > 0 ? aXAry[nNodeIndex - 1] : 0 );
479 aSize.setWidth( nNodeIndex > 0 ? aXAry[nNodeIndex] - aXAry[nNodeIndex - 1] : aXAry[nNodeIndex] );
481 aTLPos = rDevice.LogicToPixel( aTLPos );
482 aSize = rDevice.LogicToPixel( aSize );
483 aRes.X = aTLPos.X();
484 aRes.Y = aTLPos.Y();
485 aRes.Width = aSize.Width();
486 aRes.Height = aSize.Height();
490 // take rectangle from last character and move it to the right
491 if (bWasBehindText)
492 aRes.X += aRes.Width;
494 return aRes;
497 sal_Int32 SAL_CALL SmGraphicAccessible::getCharacterCount()
499 SolarMutexGuard aGuard;
500 return GetAccessibleText_Impl().getLength();
503 sal_Int32 SAL_CALL SmGraphicAccessible::getIndexAtPoint( const awt::Point& aPoint )
505 SolarMutexGuard aGuard;
507 sal_Int32 nRes = -1;
508 if (pWin)
510 const SmNode *pTree = pWin->GetView().GetDoc()->GetFormulaTree();
511 // can be NULL! e.g. if one clicks within the window already during loading of the
512 // document (before the parser even started)
513 if (!pTree)
514 return nRes;
516 weld::DrawingArea* pDrawingArea = pWin->GetDrawingArea();
517 OutputDevice& rDevice = pDrawingArea->get_ref_device();
519 // get position relative to formula draw position
520 Point aPos( aPoint.X, aPoint.Y );
521 aPos = rDevice.PixelToLogic( aPos );
522 aPos -= pWin->GetFormulaDrawPos();
524 // if it was inside the formula then get the appropriate node
525 const SmNode *pNode = nullptr;
526 if (pTree->OrientedDist(aPos) <= 0)
527 pNode = pTree->FindRectClosestTo(aPos);
529 if (pNode)
531 // get appropriate rectangle
532 Point aOffset( pNode->GetTopLeft() - pTree->GetTopLeft() );
533 Point aTLPos ( aOffset );
534 Size aSize( pNode->GetSize() );
536 tools::Rectangle aRect( aTLPos, aSize );
537 if (aRect.Contains( aPos ))
539 OSL_ENSURE( pNode->IsVisible(), "node is not a leaf" );
540 OUStringBuffer aBuf;
541 pNode->GetAccessibleText(aBuf);
542 OUString aTxt = aBuf.makeStringAndClear();
543 OSL_ENSURE( !aTxt.isEmpty(), "no accessible text available" );
545 tools::Long nNodeX = pNode->GetLeft();
547 std::vector<sal_Int32> aXAry;
548 rDevice.SetFont( pNode->GetFont() );
549 rDevice.GetTextArray( aTxt, &aXAry, 0, aTxt.getLength() );
550 for (sal_Int32 i = 0; i < aTxt.getLength() && nRes == -1; ++i)
552 if (aXAry[i] + nNodeX > aPos.X())
553 nRes = i;
555 OSL_ENSURE( nRes >= 0 && nRes < aTxt.getLength(), "index out of range" );
556 OSL_ENSURE( pNode->GetAccessibleIndex() >= 0,
557 "invalid accessible index" );
559 nRes = pNode->GetAccessibleIndex() + nRes;
563 return nRes;
566 OUString SAL_CALL SmGraphicAccessible::getSelectedText()
568 return OUString();
571 sal_Int32 SAL_CALL SmGraphicAccessible::getSelectionStart()
573 return -1;
576 sal_Int32 SAL_CALL SmGraphicAccessible::getSelectionEnd()
578 return -1;
581 sal_Bool SAL_CALL SmGraphicAccessible::setSelection(
582 sal_Int32 nStartIndex,
583 sal_Int32 nEndIndex )
585 SolarMutexGuard aGuard;
586 sal_Int32 nLen = GetAccessibleText_Impl().getLength();
587 if (0 > nStartIndex || nStartIndex >= nLen ||
588 0 > nEndIndex || nEndIndex >= nLen)
589 throw IndexOutOfBoundsException();
590 return false;
593 OUString SAL_CALL SmGraphicAccessible::getText()
595 SolarMutexGuard aGuard;
596 return GetAccessibleText_Impl();
599 OUString SAL_CALL SmGraphicAccessible::getTextRange(
600 sal_Int32 nStartIndex,
601 sal_Int32 nEndIndex )
603 //!! nEndIndex may be the string length per definition of the interface !!
604 //!! text should be copied exclusive that end index though. And arguments
605 //!! may be switched.
607 SolarMutexGuard aGuard;
608 OUString aTxt( GetAccessibleText_Impl() );
609 sal_Int32 nStart = std::min(nStartIndex, nEndIndex);
610 sal_Int32 nEnd = std::max(nStartIndex, nEndIndex);
611 if ((nStart > aTxt.getLength()) ||
612 (nEnd > aTxt.getLength()))
613 throw IndexOutOfBoundsException();
614 return aTxt.copy( nStart, nEnd - nStart );
617 css::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType )
619 SolarMutexGuard aGuard;
620 OUString aTxt( GetAccessibleText_Impl() );
621 //!! nIndex is allowed to be the string length
622 if (nIndex > aTxt.getLength())
623 throw IndexOutOfBoundsException();
625 css::accessibility::TextSegment aResult;
626 aResult.SegmentStart = -1;
627 aResult.SegmentEnd = -1;
628 if ( (AccessibleTextType::CHARACTER == aTextType) && (nIndex < aTxt.getLength()) )
630 aResult.SegmentText = aTxt.copy(nIndex, 1);
631 aResult.SegmentStart = nIndex;
632 aResult.SegmentEnd = nIndex+1;
634 return aResult;
637 css::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType )
639 SolarMutexGuard aGuard;
640 OUString aTxt( GetAccessibleText_Impl() );
641 //!! nIndex is allowed to be the string length
642 if (nIndex > aTxt.getLength())
643 throw IndexOutOfBoundsException();
645 css::accessibility::TextSegment aResult;
646 aResult.SegmentStart = -1;
647 aResult.SegmentEnd = -1;
649 if ( (AccessibleTextType::CHARACTER == aTextType) && nIndex )
651 aResult.SegmentText = aTxt.copy(nIndex-1, 1);
652 aResult.SegmentStart = nIndex-1;
653 aResult.SegmentEnd = nIndex;
655 return aResult;
658 css::accessibility::TextSegment SAL_CALL SmGraphicAccessible::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType )
660 SolarMutexGuard aGuard;
661 OUString aTxt( GetAccessibleText_Impl() );
662 //!! nIndex is allowed to be the string length
663 if (nIndex > aTxt.getLength())
664 throw IndexOutOfBoundsException();
666 css::accessibility::TextSegment aResult;
667 aResult.SegmentStart = -1;
668 aResult.SegmentEnd = -1;
670 nIndex++; // text *behind*
671 if ( (AccessibleTextType::CHARACTER == aTextType) && (nIndex < aTxt.getLength()) )
673 aResult.SegmentText = aTxt.copy(nIndex, 1);
674 aResult.SegmentStart = nIndex;
675 aResult.SegmentEnd = nIndex+1;
677 return aResult;
680 sal_Bool SAL_CALL SmGraphicAccessible::copyText(
681 sal_Int32 nStartIndex,
682 sal_Int32 nEndIndex )
684 SolarMutexGuard aGuard;
685 bool bReturn = false;
687 if (!pWin)
688 throw RuntimeException();
690 Reference< datatransfer::clipboard::XClipboard > xClipboard = pWin->GetClipboard();
691 if ( xClipboard.is() )
693 OUString sText( getTextRange(nStartIndex, nEndIndex) );
695 rtl::Reference<vcl::unohelper::TextDataObject> pDataObj = new vcl::unohelper::TextDataObject( sText );
696 SolarMutexReleaser aReleaser;
697 xClipboard->setContents( pDataObj, nullptr );
699 Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
700 if( xFlushableClipboard.is() )
701 xFlushableClipboard->flushClipboard();
703 bReturn = true;
707 return bReturn;
710 sal_Bool SAL_CALL SmGraphicAccessible::scrollSubstringTo( sal_Int32, sal_Int32, AccessibleScrollType )
712 return false;
715 OUString SAL_CALL SmGraphicAccessible::getImplementationName()
717 return "SmGraphicAccessible";
720 sal_Bool SAL_CALL SmGraphicAccessible::supportsService(
721 const OUString& rServiceName )
723 return cppu::supportsService(this, rServiceName);
726 Sequence< OUString > SAL_CALL SmGraphicAccessible::getSupportedServiceNames()
728 return {
729 "css::accessibility::Accessible",
730 "css::accessibility::AccessibleComponent",
731 "css::accessibility::AccessibleContext",
732 "css::accessibility::AccessibleText"
736 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */