summaryrefslogtreecommitdiff
path: root/accessibility/source/extended/textwindowaccessibility.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility/source/extended/textwindowaccessibility.cxx')
-rw-r--r--accessibility/source/extended/textwindowaccessibility.cxx119
1 files changed, 52 insertions, 67 deletions
diff --git a/accessibility/source/extended/textwindowaccessibility.cxx b/accessibility/source/extended/textwindowaccessibility.cxx
index 4b37b1c78dd7..f1ccc69c413d 100644
--- a/accessibility/source/extended/textwindowaccessibility.cxx
+++ b/accessibility/source/extended/textwindowaccessibility.cxx
@@ -30,13 +30,14 @@
#include <com/sun/star/i18n/Boundary.hpp>
#include <cppuhelper/exc_hlp.hxx>
#include <extended/textwindowaccessibility.hxx>
+#include <comphelper/accessiblecontexthelper.hxx>
#include <comphelper/accessibleeventnotifier.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
-#include <unotools/accessiblestatesethelper.hxx>
+#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/txtattr.hxx>
#include <vcl/window.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <toolkit/helper/convert.hxx>
#include <comphelper/sequence.hxx>
@@ -79,10 +80,10 @@ void WindowListenerGuard::endListening()
}
}
-Paragraph::Paragraph(::rtl::Reference< Document > const & rDocument,
+Paragraph::Paragraph(::rtl::Reference< Document > xDocument,
Paragraphs::size_type nNumber):
ParagraphBase(m_aMutex),
- m_xDocument(rDocument),
+ m_xDocument(std::move(xDocument)),
m_nNumber(nNumber),
m_nClientId(0)
{
@@ -117,8 +118,8 @@ void Paragraph::notifyEvent(::sal_Int16 nEventId,
{
if (m_nClientId)
comphelper::AccessibleEventNotifier::addEvent( m_nClientId, css::accessibility::AccessibleEventObject(
- static_cast< ::cppu::OWeakObject * >(this),
- nEventId, rNewValue, rOldValue) );
+ getXWeak(),
+ nEventId, rNewValue, rOldValue, -1) );
}
// virtual
@@ -130,7 +131,7 @@ Paragraph::getAccessibleContext()
}
// virtual
-::sal_Int32 SAL_CALL Paragraph::getAccessibleChildCount()
+sal_Int64 SAL_CALL Paragraph::getAccessibleChildCount()
{
checkDisposed();
return 0;
@@ -138,13 +139,13 @@ Paragraph::getAccessibleContext()
// virtual
css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
-Paragraph::getAccessibleChild(::sal_Int32)
+Paragraph::getAccessibleChild(sal_Int64)
{
checkDisposed();
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Paragraph::getAccessibleChild",
- static_cast< css::uno::XWeak * >(this));
+ getXWeak());
}
// virtual
@@ -156,7 +157,7 @@ Paragraph::getAccessibleParent()
}
// virtual
-::sal_Int32 SAL_CALL Paragraph::getAccessibleIndexInParent()
+sal_Int64 SAL_CALL Paragraph::getAccessibleIndexInParent()
{
checkDisposed();
return m_xDocument->retrieveParagraphIndex(this);
@@ -192,15 +193,13 @@ SAL_CALL Paragraph::getAccessibleRelationSet()
}
// virtual
-css::uno::Reference< css::accessibility::XAccessibleStateSet >
-SAL_CALL Paragraph::getAccessibleStateSet()
+sal_Int64 SAL_CALL Paragraph::getAccessibleStateSet()
{
checkDisposed();
// FIXME Notification of changes (STATE_CHANGED) missing when
// m_rView.IsReadOnly() changes:
- return new ::utl::AccessibleStateSetHelper(
- m_xDocument->retrieveParagraphState(this));
+ return m_xDocument->retrieveParagraphState(this);
}
// virtual
@@ -559,7 +558,7 @@ css::accessibility::TextSegment SAL_CALL Paragraph::getTextAtLineWithCaret( )
throw css::lang::WrappedTargetRuntimeException(
"textwindowaccessibility.cxx:"
" Paragraph::getTextAtLineWithCaret",
- static_cast< css::uno::XWeak * >( this ), anyEx );
+ getXWeak(), anyEx );
}
}
@@ -584,7 +583,7 @@ void SAL_CALL Paragraph::addAccessibleEventListener(
{
aGuard.clear();
rListener->disposing(css::lang::EventObject(
- static_cast< ::cppu::OWeakObject * >(this)));
+ getXWeak()));
}
else
{
@@ -698,7 +697,7 @@ void Paragraph::checkDisposed()
if (!(rBHelper.bDisposed || rBHelper.bInDispose))
return;
throw css::lang::DisposedException(
- OUString(), static_cast< css::uno::XWeak * >(this));
+ OUString(), getXWeak());
}
Document::Document(::VCLXWindow * pVclXWindow, ::TextEngine & rEngine,
@@ -747,29 +746,21 @@ css::lang::Locale Document::retrieveLocale()
// happen that this Paragraph lies outside the range from m_aVisibleBegin
// to m_aVisibleEnd. In that case, it is neither VISIBLE nor SHOWING:
::sal_Int64 nState
- = (static_cast< ::sal_Int64 >(1)
- << css::accessibility::AccessibleStateType::ENABLED)
- | (static_cast< ::sal_Int64 >(1)
- << css::accessibility::AccessibleStateType::SENSITIVE)
- | (static_cast< ::sal_Int64 >(1)
- << css::accessibility::AccessibleStateType::FOCUSABLE)
- | (static_cast< ::sal_Int64 >(1)
- << css::accessibility::AccessibleStateType::MULTI_LINE);
+ = css::accessibility::AccessibleStateType::ENABLED
+ | css::accessibility::AccessibleStateType::SENSITIVE
+ | css::accessibility::AccessibleStateType::FOCUSABLE
+ | css::accessibility::AccessibleStateType::MULTI_LINE;
if (!m_rView.IsReadOnly())
- nState |= (static_cast< ::sal_Int64 >(1)
- << css::accessibility::AccessibleStateType::EDITABLE);
+ nState |= css::accessibility::AccessibleStateType::EDITABLE;
Paragraphs::iterator aPara(m_xParagraphs->begin()
+ pParagraph->getNumber());
if (aPara >= m_aVisibleBegin && aPara < m_aVisibleEnd)
{
nState
- |= (static_cast< ::sal_Int64 >(1)
- << css::accessibility::AccessibleStateType::VISIBLE)
- | (static_cast< ::sal_Int64 >(1)
- << css::accessibility::AccessibleStateType::SHOWING);
+ |= css::accessibility::AccessibleStateType::VISIBLE
+ | css::accessibility::AccessibleStateType::SHOWING;
if (aPara == m_aFocused)
- nState |= (static_cast< ::sal_Int64 >(1)
- << css::accessibility::AccessibleStateType::FOCUSED);
+ nState |= css::accessibility::AccessibleStateType::FOCUSED;
}
return nState;
};
@@ -798,7 +789,7 @@ Document::retrieveParagraphBounds(Paragraph const * pParagraph,
Point aOrig(0, 0);
if (bAbsolute)
- aOrig = m_rView.GetWindow()->OutputToAbsoluteScreenPixel(aOrig);
+ aOrig = Point(m_rView.GetWindow()->OutputToAbsoluteScreenPixel(aOrig));
return css::awt::Rectangle(
static_cast< ::sal_Int32 >(aOrig.X()),
@@ -872,7 +863,7 @@ Document::retrieveCharacterBounds(Paragraph const * pParagraph,
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::retrieveCharacterAttributes",
- static_cast< css::uno::XWeak * >(this));
+ getXWeak());
css::awt::Rectangle aBounds( 0, 0, 0, 0 );
if ( nIndex == nLength )
{
@@ -997,7 +988,7 @@ Document::retrieveCharacterAttributes(
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::retrieveCharacterAttributes",
- static_cast< css::uno::XWeak * >(this));
+ getXWeak());
// retrieve run attributes
@@ -1090,7 +1081,7 @@ Document::retrieveRunAttributes(
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::retrieveRunAttributes",
- static_cast< css::uno::XWeak * >( this ) );
+ getXWeak() );
tPropValMap aRunAttrSeq;
retrieveRunAttributesImpl( pParagraph, Index, RequestedAttributes, aRunAttrSeq );
@@ -1125,7 +1116,7 @@ void Document::changeParagraphText(Paragraph const * pParagraph,
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::changeParagraphText",
- static_cast< css::uno::XWeak * >(this));
+ getXWeak());
changeParagraphText(nNumber, static_cast< ::sal_uInt16 >(nBegin),
static_cast< ::sal_uInt16 >(nEnd), bCut, bPaste, rText);
// XXX numeric overflow (2x)
@@ -1145,7 +1136,7 @@ void Document::copyParagraphText(Paragraph const * pParagraph,
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::copyParagraphText",
- static_cast< css::uno::XWeak * >(this));
+ getXWeak());
m_rView.SetSelection(
::TextSelection(::TextPaM(nNumber, nBegin),
::TextPaM(nNumber, nEnd)));
@@ -1168,7 +1159,7 @@ void Document::changeParagraphAttributes(
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::changeParagraphAttributes",
- static_cast< css::uno::XWeak * >(this));
+ getXWeak());
// FIXME The new attributes are added to any attributes already set,
// they do not replace the old attributes as required by
@@ -1200,7 +1191,7 @@ void Document::changeParagraphSelection(Paragraph const * pParagraph,
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::changeParagraphSelection",
- static_cast< css::uno::XWeak * >(this));
+ getXWeak());
m_rView.SetSelection(
::TextSelection(::TextPaM(nNumber, nBegin),
::TextPaM(nNumber, nEnd)));
@@ -1224,7 +1215,7 @@ Document::retrieveParagraphLineBoundary( Paragraph const * pParagraph,
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::retrieveParagraphLineBoundary",
- static_cast< css::uno::XWeak * >( this ) );
+ getXWeak() );
::sal_Int32 nLineStart = 0;
::sal_Int32 nLineEnd = 0;
::sal_uInt16 nLineCount = m_rEngine.GetLineCount( nNumber );
@@ -1262,7 +1253,7 @@ Document::retrieveParagraphBoundaryOfLine( Paragraph const * pParagraph,
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::retrieveParagraphBoundaryOfLine",
- static_cast< css::uno::XWeak * >( this ) );
+ getXWeak() );
::sal_Int32 nLineStart = 0;
::sal_Int32 nLineEnd = 0;
for ( ::sal_Int32 nLine = 0; nLine <= nLineNo; ++nLine )
@@ -1318,7 +1309,7 @@ Document::retrieveParagraphRelationSet( Paragraph const * pParagraph )
}
// virtual
-::sal_Int32 SAL_CALL Document::getAccessibleChildCount()
+sal_Int64 SAL_CALL Document::getAccessibleChildCount()
{
::comphelper::OExternalLockGuard aGuard(this);
init();
@@ -1327,7 +1318,7 @@ Document::retrieveParagraphRelationSet( Paragraph const * pParagraph )
// virtual
css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
-Document::getAccessibleChild(::sal_Int32 i)
+Document::getAccessibleChild(sal_Int64 i)
{
::comphelper::OExternalLockGuard aGuard(this);
init();
@@ -1335,7 +1326,7 @@ Document::getAccessibleChild(::sal_Int32 i)
throw css::lang::IndexOutOfBoundsException(
"textwindowaccessibility.cxx:"
" Document::getAccessibleChild",
- static_cast< css::uno::XWeak * >(this));
+ getXWeak());
return getAccessibleChild(m_aVisibleBegin
+ static_cast< Paragraphs::size_type >(i));
}
@@ -1368,11 +1359,11 @@ Document::getAccessibleAtPoint(css::awt::Point const & rPoint)
}
return nullptr;
}
-void Document::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
+void Document::FillAccessibleStateSet( sal_Int64& rStateSet )
{
VCLXAccessibleComponent::FillAccessibleStateSet( rStateSet );
if (!m_rView.IsReadOnly())
- rStateSet.AddState( css::accessibility::AccessibleStateType::EDITABLE );
+ rStateSet |= css::accessibility::AccessibleStateType::EDITABLE;
}
void Document::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet )
@@ -1532,7 +1523,7 @@ IMPL_LINK(Document, WindowEventHandler, ::VclWindowEvent&, rEvent, void)
if (!isAlive())
break;
//to enable the PARAGRAPH to get focus for multiline edit
- ::sal_Int32 count = getAccessibleChildCount();
+ sal_Int64 count = getAccessibleChildCount();
bool bEmpty = m_aFocused == m_aVisibleEnd && count == 1;
if ((m_aFocused >= m_aVisibleBegin && m_aFocused < m_aVisibleEnd) || bEmpty)
{
@@ -1557,7 +1548,7 @@ IMPL_LINK(Document, WindowEventHandler, ::VclWindowEvent&, rEvent, void)
if (!isAlive())
break;
//to enable the PARAGRAPH to get focus for multiline edit
- ::sal_Int32 count = getAccessibleChildCount();
+ sal_Int64 count = getAccessibleChildCount();
bool bEmpty = m_aFocused == m_aVisibleEnd && count == 1;
if ((m_aFocused >= m_aVisibleBegin && m_aFocused < m_aVisibleEnd) || bEmpty)
{
@@ -1588,8 +1579,7 @@ void Document::init()
m_xParagraphs->reserve(static_cast< Paragraphs::size_type >(nCount));
// numeric overflow is harmless here
for (::sal_uInt32 i = 0; i < nCount; ++i)
- m_xParagraphs->push_back(ParagraphInfo(static_cast< ::sal_Int32 >(
- m_rEngine.GetTextHeight(i))));
+ m_xParagraphs->emplace_back(m_rEngine.GetTextHeight(i));
// XXX numeric overflow
m_nViewOffset = static_cast< ::sal_Int32 >(
m_rView.GetStartDocPos().Y()); // XXX numeric overflow
@@ -1610,16 +1600,13 @@ void Document::init()
::rtl::Reference< Paragraph >
Document::getParagraph(Paragraphs::iterator const & rIt)
{
- return static_cast< Paragraph * >(
- css::uno::Reference< css::accessibility::XAccessible >(
- rIt->getParagraph()).get());
+ return rIt->getParagraph().get();
}
css::uno::Reference< css::accessibility::XAccessible >
Document::getAccessibleChild(Paragraphs::iterator const & rIt)
{
- css::uno::Reference< css::accessibility::XAccessible > xParagraph(
- rIt->getParagraph());
+ rtl::Reference< Paragraph > xParagraph(rIt->getParagraph());
if (!xParagraph.is())
{
xParagraph = new Paragraph(this, rIt - m_xParagraphs->begin());
@@ -1850,8 +1837,7 @@ void Document::handleParagraphNotifications()
xStrong;
if (bWasVisible)
xStrong = getAccessibleChild(aIt);
- css::uno::WeakReference<
- css::accessibility::XAccessible > xWeak(
+ unotools::WeakReference<Paragraph> xWeak(
aIt->getParagraph());
aIt = m_xParagraphs->erase(aIt);
@@ -1874,8 +1860,7 @@ void Document::handleParagraphNotifications()
css::uno::Any(xStrong),
css::uno::Any());
- css::uno::Reference< css::lang::XComponent > xComponent(
- xWeak.get(), css::uno::UNO_QUERY);
+ rtl::Reference< Paragraph > xComponent( xWeak.get() );
if (xComponent.is())
xComponent->dispose();
@@ -2082,7 +2067,7 @@ void Document::handleSelectionChangeNotification()
if (xParagraph.is())
{
//disable the first event when user types in empty field.
- ::sal_Int32 count = getAccessibleChildCount();
+ sal_Int64 count = getAccessibleChildCount();
bool bEmpty = count > 1;
//if (aIt != m_aFocused)
if (aIt != m_aFocused && bEmpty)
@@ -2097,9 +2082,9 @@ void Document::handleSelectionChangeNotification()
xParagraph->notifyEvent(
css::accessibility::AccessibleEventId::
CARET_CHANGED,
- css::uno::makeAny< ::sal_Int32 >(
+ css::uno::Any( ::sal_Int32 (
nNewLastPara == m_nSelectionLastPara
- ? m_nSelectionLastPos : 0),
+ ? m_nSelectionLastPos : 0)),
css::uno::Any(nNewLastPos));
}
}
@@ -2206,8 +2191,8 @@ void Document::disposeParagraphs()
{
for (auto const& paragraph : *m_xParagraphs)
{
- css::uno::Reference< css::lang::XComponent > xComponent(
- paragraph.getParagraph().get(), css::uno::UNO_QUERY);
+ rtl::Reference< Paragraph > xComponent(
+ paragraph.getParagraph().get() );
if (xComponent.is())
xComponent->dispose();
}
@@ -2216,7 +2201,7 @@ void Document::disposeParagraphs()
// static
css::uno::Any Document::mapFontColor(::Color const & rColor)
{
- return css::uno::makeAny(rColor.GetRGBColor());
+ return css::uno::Any(rColor.GetRGBColor());
// FIXME keep transparency?
}