winaccessibility/source/UAccCOM/AccTextBase.cxx | 59 +++++++++++------------- winaccessibility/source/UAccCOM/AccTextBase.h | 2 2 files changed, 28 insertions(+), 33 deletions(-)
New commits: commit 3b6366773389c55c127f097d5d82d27d5efaa69a Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Oct 10 12:52:49 2023 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Oct 11 07:20:21 2023 +0200 wina11y: Drop CAccTextBase::GetXInterface Just use the private `pRXText` member directly. The separate getter doesn't really help regarding readability, in particular since the typical usage pattern involved first checking the member directly, then using the getter, making it less obvious that this was about the same object/reference e.g. if(!pRXText.is()) { return E_FAIL; } if( offset < 0 || offset > GetXInterface()->getCharacterCount() ) return E_FAIL; Change-Id: Iaf786220b94a37e79a46985f58e0586252846f56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157766 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/winaccessibility/source/UAccCOM/AccTextBase.cxx b/winaccessibility/source/UAccCOM/AccTextBase.cxx index 131d001b27df..37eb1d6fcf70 100644 --- a/winaccessibility/source/UAccCOM/AccTextBase.cxx +++ b/winaccessibility/source/UAccCOM/AccTextBase.cxx @@ -108,7 +108,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_addSelection(long startOffse } else { - GetXInterface()->setSelection(startOffset, endOffset); + pRXText->setSelection(startOffset, endOffset); return S_OK; } @@ -137,12 +137,12 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_attributes(long offset, long return E_FAIL; } - if( offset < 0 || offset > GetXInterface()->getCharacterCount() ) + if (offset < 0 || offset > pRXText->getCharacterCount() ) return E_FAIL; OUStringBuffer strAttrs("Version:1;"); - Sequence< css::beans::PropertyValue > pValues = GetXInterface()->getCharacterAttributes(offset, Sequence< OUString >()); + Sequence <css::beans::PropertyValue> pValues = pRXText->getCharacterAttributes(offset, Sequence<OUString>()); int nCount = pValues.getLength(); sal_Int16 numberingLevel = 0; @@ -220,9 +220,9 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_attributes(long offset, long SysFreeString(*textAttributes); *textAttributes = SysAllocString(o3tl::toW(strAttrs.makeStringAndClear().getStr())); - if( offset < GetXInterface()->getCharacterCount() ) + if (offset < pRXText->getCharacterCount()) { - TextSegment textSeg = GetXInterface()->getTextAtIndex(offset, AccessibleTextType::ATTRIBUTE_RUN); + TextSegment textSeg = pRXText->getTextAtIndex(offset, AccessibleTextType::ATTRIBUTE_RUN); *startOffset = textSeg.SegmentStart; *endOffset = textSeg.SegmentEnd; } @@ -257,7 +257,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_caretOffset(long * offset) return S_OK; } - *offset = GetXInterface()->getCaretPosition(); + *offset = pRXText->getCaretPosition(); return S_OK; } catch(...) { return E_FAIL; } @@ -283,7 +283,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_characterCount(long * nChara return S_OK; } - *nCharacters = GetXInterface()->getCharacterCount(); + *nCharacters = pRXText->getCharacterCount(); return S_OK; } catch(...) { return E_FAIL; } @@ -310,11 +310,11 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_characterExtents(long offset if(!pRXText.is()) return E_FAIL; - if(offset < 0 || offset > GetXInterface()->getCharacterCount() ) + if (offset < 0 || offset > pRXText->getCharacterCount()) return E_FAIL; css::awt::Rectangle rectangle; - rectangle = GetXInterface()->getCharacterBounds(offset); + rectangle = pRXText->getCharacterBounds(offset); //IA2Point aPoint; css::awt::Point aPoint; @@ -346,10 +346,10 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_characterExtents(long offset *x = rectangle.X; *y = rectangle.Y; - // GetXInterface()->getCharacterBounds() have different implement in different acc component + // pRXText->getCharacterBounds() have different implement in different acc component // But we need return the width/height == 1 for every component when offset == text length. - // So we ignore the return result of GetXInterface()->getCharacterBounds() when offset == text length. - if( offset == GetXInterface()->getCharacterCount() ) + // So we ignore the return result of pRXText->getCharacterBounds() when offset == text length. + if (offset == pRXText->getCharacterCount()) { *width = 1; *height = 1; @@ -395,7 +395,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_nSelections(long * nSelectio return S_OK; } - long iLength = GetXInterface()->getSelectedText().getLength(); + long iLength = pRXText->getSelectedText().getLength(); if( iLength> 0) { *nSelections = 1; @@ -445,7 +445,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_offsetAtPoint(long x, long y point.Y -= aObjectPos.Y; } - *offset = GetXInterface()->getIndexAtPoint(point); + *offset = pRXText->getIndexAtPoint(point); return S_OK; } catch(...) { return E_FAIL; } @@ -487,10 +487,10 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_selection(long selectionInde *endOffset = pRExtension->getSeletedPositionEnd(selectionIndex); return S_OK; } - else if(GetXInterface()->getSelectionEnd() > -1) + else if (pRXText->getSelectionEnd() > -1) { - *startOffset = GetXInterface()->getSelectionStart(); - *endOffset = GetXInterface()->getSelectionEnd(); + *startOffset = pRXText->getSelectionStart(); + *endOffset = pRXText->getSelectionEnd(); return S_OK; } @@ -531,12 +531,12 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_text(long startOffset, long long nLen=0; if(SUCCEEDED(get_characterCount(&nLen))) { - ouStr = GetXInterface()->getTextRange( 0, nLen ); + ouStr = pRXText->getTextRange(0, nLen); } } else { - ouStr = GetXInterface()->getTextRange( startOffset, endOffset ); + ouStr = pRXText->getTextRange(startOffset, endOffset); } SysFreeString(*text); @@ -580,7 +580,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_textBeforeOffset(long offset if (nUnoBoundaryType < 0) return E_FAIL; - TextSegment segment = GetXInterface()->getTextBeforeIndex(offset, nUnoBoundaryType); + TextSegment segment = pRXText->getTextBeforeIndex(offset, nUnoBoundaryType); OUString ouStr = segment.SegmentText; SysFreeString(*text); *text = SysAllocString(o3tl::toW(ouStr.getStr())); @@ -626,7 +626,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_textAfterOffset(long offset, if (nUnoBoundaryType < 0) return E_FAIL; - TextSegment segment = GetXInterface()->getTextBehindIndex(offset, nUnoBoundaryType); + TextSegment segment = pRXText->getTextBehindIndex(offset, nUnoBoundaryType); OUString ouStr = segment.SegmentText; SysFreeString(*text); *text = SysAllocString(o3tl::toW(ouStr.getStr())); @@ -672,7 +672,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_textAtOffset(long offset, IA if (nUnoBoundaryType < 0) return E_FAIL; - TextSegment segment = GetXInterface()->getTextAtIndex(offset, nUnoBoundaryType); + TextSegment segment = pRXText->getTextAtIndex(offset, nUnoBoundaryType); OUString ouStr = segment.SegmentText; SysFreeString(*text); *text = SysAllocString(o3tl::toW(ouStr.getStr())); @@ -712,7 +712,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::removeSelection(long selectionIn } else { - GetXInterface()->setSelection(0, 0); + pRXText->setSelection(0, 0); return S_OK; } @@ -734,7 +734,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::setCaretOffset(long offset) if(!pRXText.is()) return E_FAIL; - GetXInterface()->setCaretPosition( offset); + pRXText->setCaretPosition(offset); return S_OK; @@ -760,7 +760,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::setSelection(long, long startOff return E_FAIL; } - GetXInterface()->setSelection( startOffset, endOffset ); + pRXText->setSelection(startOffset, endOffset); return S_OK; @@ -787,7 +787,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::get_nCharacters(long * nCharacte return S_OK; } - *nCharacters = GetXInterface()->getCharacterCount(); + *nCharacters = pRXText->getCharacterCount(); return S_OK; @@ -854,7 +854,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::scrollSubstringTo(long startInde return E_NOTIMPL; } - if( GetXInterface()->scrollSubstringTo(startIndex, endIndex, lUnoType) ) + if (pRXText->scrollSubstringTo(startIndex, endIndex, lUnoType)) return S_OK; return E_NOTIMPL; diff --git a/winaccessibility/source/UAccCOM/AccTextBase.h b/winaccessibility/source/UAccCOM/AccTextBase.h index 66f0087563ad..50d50cb077f5 100644 --- a/winaccessibility/source/UAccCOM/AccTextBase.h +++ b/winaccessibility/source/UAccCOM/AccTextBase.h @@ -106,8 +106,6 @@ public: private: css::uno::Reference<css::accessibility::XAccessibleText> pRXText; - - css::accessibility::XAccessibleText* GetXInterface() { return pRXText.get(); } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 7b2ed8ef83220cad2982e53948fe227770006a61 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Oct 10 12:41:53 2023 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Oct 11 07:20:11 2023 +0200 wina11y: Drop unnecessary check for empty Reference Using operator= with either an empty Reference or nullptr has the same effect. Change-Id: Ifa33127f3718ba4bbf3d364484b412b4108719a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157765 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/winaccessibility/source/UAccCOM/AccTextBase.cxx b/winaccessibility/source/UAccCOM/AccTextBase.cxx index 27c8f74c341c..131d001b27df 100644 --- a/winaccessibility/source/UAccCOM/AccTextBase.cxx +++ b/winaccessibility/source/UAccCOM/AccTextBase.cxx @@ -883,10 +883,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTextBase::put_XInterface(hyper pXInterface return E_FAIL; } Reference<XAccessibleText> pRXI(pRContext,UNO_QUERY); - if( !pRXI.is() ) - pRXText = nullptr; - else - pRXText = pRXI; + pRXText = pRXI; return S_OK; } catch(...) { return E_FAIL; }