if (!pWin)
nStateSet |= AccessibleStateType::DEFUNC; else
{
nStateSet |= AccessibleStateType::ENABLED;
nStateSet |= AccessibleStateType::FOCUSABLE; if (pWin->HasFocus())
nStateSet |= AccessibleStateType::FOCUSED; if (pWin->IsActive())
nStateSet |= AccessibleStateType::ACTIVE; if (pWin->IsVisible())
nStateSet |= AccessibleStateType::SHOWING; if (pWin->IsReallyVisible())
nStateSet |= AccessibleStateType::VISIBLE;
weld::DrawingArea* pDrawingArea = pWin->GetDrawingArea();
OutputDevice& rDevice = pDrawingArea->get_ref_device(); if (COL_TRANSPARENT != rDevice.GetBackground().GetColor())
nStateSet |= AccessibleStateType::OPAQUE;
}
return nStateSet;
}
Locale SAL_CALL SmGraphicAccessible::getLocale()
{
SolarMutexGuard aGuard; // should be the document language... // We use the language of the localized symbol names here. return Application::GetSettings().GetUILanguageTag().getLocale();
}
// get accessible text
SmDocShell* pDoc = pWin->GetView().GetDoc(); if (!pDoc) throw RuntimeException();
OUString aTxt( GetAccessibleText_Impl() ); if (0 > nIndex || nIndex > aTxt.getLength()) // aTxt.getLength() is valid throw IndexOutOfBoundsException();
// find a reasonable rectangle for position aTxt.getLength(). bool bWasBehindText = (nIndex == aTxt.getLength()); if (bWasBehindText && nIndex)
--nIndex;
const SmNode *pTree = pDoc->GetFormulaTree(); const SmNode *pNode = pTree->FindNodeWithAccessibleIndex( nIndex ); //! pNode may be 0 if the index belongs to a char that was inserted //! only for the accessible text! if (pNode)
{
sal_Int32 nAccIndex = pNode->GetAccessibleIndex();
OSL_ENSURE( nAccIndex >= 0, "invalid accessible index" );
OSL_ENSURE( nIndex >= nAccIndex, "index out of range" );
OUStringBuffer aBuf;
pNode->GetAccessibleText(aBuf);
OUString aNodeText = aBuf.makeStringAndClear();
sal_Int32 nNodeIndex = nIndex - nAccIndex; if (0 <= nNodeIndex && nNodeIndex < aNodeText.getLength())
{ // get appropriate rectangle
Point aOffset(pNode->GetTopLeft() - pTree->GetTopLeft());
Point aTLPos (pWin->GetFormulaDrawPos() + aOffset);
Size aSize (pNode->GetSize());
sal_Int32 nRes = -1; if (pWin)
{ const SmNode *pTree = pWin->GetView().GetDoc()->GetFormulaTree(); // can be NULL! e.g. if one clicks within the window already during loading of the // document (before the parser even started) if (!pTree) return nRes;
// get position relative to formula draw position
Point aPos( aPoint.X, aPoint.Y );
aPos = rDevice.PixelToLogic( aPos );
aPos -= pWin->GetFormulaDrawPos();
// if it was inside the formula then get the appropriate node const SmNode *pNode = nullptr; if (pTree->OrientedDist(aPos) <= 0)
pNode = pTree->FindRectClosestTo(aPos);
if (pNode)
{ // get appropriate rectangle
Point aOffset( pNode->GetTopLeft() - pTree->GetTopLeft() );
Point aTLPos ( aOffset );
Size aSize( pNode->GetSize() );
tools::Rectangle aRect( aTLPos, aSize ); if (aRect.Contains( aPos ))
{
OSL_ENSURE( pNode->IsVisible(), "node is not a leaf" );
OUStringBuffer aBuf;
pNode->GetAccessibleText(aBuf);
OUString aTxt = aBuf.makeStringAndClear();
OSL_ENSURE( !aTxt.isEmpty(), "no accessible text available" );
tools::Long nNodeX = pNode->GetLeft();
KernArray aXAry;
rDevice.SetFont( pNode->GetFont() );
rDevice.GetTextArray( aTxt, &aXAry, 0, aTxt.getLength() ); for (sal_Int32 i = 0; i < aTxt.getLength() && nRes == -1; ++i)
{ if (aXAry[i] + nNodeX > aPos.X())
nRes = i;
}
OSL_ENSURE( nRes >= 0 && nRes < aTxt.getLength(), "index out of range" );
OSL_ENSURE( pNode->GetAccessibleIndex() >= 0, "invalid accessible index" );
OUString SAL_CALL SmGraphicAccessible::getTextRange(
sal_Int32 nStartIndex,
sal_Int32 nEndIndex )
{ //!! nEndIndex may be the string length per definition of the interface !! //!! text should be copied exclusive that end index though. And arguments //!! may be switched.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.