include/svx/searchcharmap.hxx | 2 -- svx/source/dialog/charmap.cxx | 1 + svx/source/dialog/searchcharmap.cxx | 18 +++++++----------- sw/qa/extras/accessibility/dialogs.cxx | 11 ++++++----- 4 files changed, 14 insertions(+), 18 deletions(-)
New commits: commit 65f672b27f84682764f924a3da3cecbafc88b278 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Mar 7 12:59:14 2023 +0000 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Mar 8 06:04:09 2023 +0000 tdf#153918 svx a11y: Drop old items when switching FontCharMap Calling `rRenderContext.GetFontCharMap(mxFontCharMap)` in `SvxShowCharSet::RecalculateFont` means that a new `FontCharMapRef` gets assigned to `mxFontCharMap`. Therefore, clear the old items based on the previous one from the map, so that new ones will be created based on the new font char map in `SvxShowCharSet::ImplGetItem` as needed instead of still returning the old ones. Adapt the a11y UI test to check again that the "!" character now has the proper accessible name. The incorrect accessible name in the special characters dialog had actually been uncovered by the initial version of the test that failed on Windows due to this, and the test was adapted to workaround that, s. tdf#153918 and the discussion in the Gerrit change adding the test [1] for more details. [1] https://gerrit.libreoffice.org/c/core/+/142260/24..26/sw/qa/extras/accessibility/dialogs.cxx#b85 Change-Id: I0ac578750b1fa0a7e63e62a6937a125c7ceab510 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148423 Reviewed-by: Colomban Wendling <cwendl...@hypra.fr> Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx index 4c17ce11c98a..5f08ba3e96c8 100644 --- a/svx/source/dialog/charmap.cxx +++ b/svx/source/dialog/charmap.cxx @@ -695,6 +695,7 @@ void SvxShowCharSet::RecalculateFont(vcl::RenderContext& rRenderContext) aFont.SetTransparent(true); rRenderContext.SetFont(aFont); rRenderContext.GetFontCharMap(mxFontCharMap); + m_aItems.clear(); getFavCharacterList(); nX = aSize.Width() / COLUMN_COUNT; diff --git a/svx/source/dialog/searchcharmap.cxx b/svx/source/dialog/searchcharmap.cxx index 02fb19be20b0..e15ec15da2c7 100644 --- a/svx/source/dialog/searchcharmap.cxx +++ b/svx/source/dialog/searchcharmap.cxx @@ -323,6 +323,7 @@ void SvxSearchCharSet::RecalculateFont(vcl::RenderContext& rRenderContext) aFont.SetTransparent(true); rRenderContext.SetFont(aFont); rRenderContext.GetFontCharMap(mxFontCharMap); + m_aItems.clear(); getFavCharacterList(); nX = aSize.Width() / COLUMN_COUNT; diff --git a/sw/qa/extras/accessibility/dialogs.cxx b/sw/qa/extras/accessibility/dialogs.cxx index 7997f7743b1e..6faab49128cd 100644 --- a/sw/qa/extras/accessibility/dialogs.cxx +++ b/sw/qa/extras/accessibility/dialogs.cxx @@ -74,13 +74,14 @@ CPPUNIT_TEST_FIXTURE(test::SwAccessibleTestBase, TestSpecialCharactersDialogFocu /* as there is a bug that focusing the character table doesn't enable the Insert button * (https://bugs.documentfoundation.org/show_bug.cgi?id=153806), we move to another cell - * so it works -- and we actually don't care which one it is */ - dialog.postKeyEventAsync(0, awt::Key::DOWN); - Scheduler::ProcessEventsToIdle(); + * so it works. */ + // tdf#153918: Check that '!' char has correct accessible name and insert it + dialog.postKeyEventAsync(0, awt::Key::RIGHT); + Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL( AccessibilityTools::getAccessibleObjectForName( - dialog.getAccessible(), accessibility::AccessibleRole::TABLE_CELL, u"0"), + dialog.getAccessible(), accessibility::AccessibleRole::TABLE_CELL, u"!"), getFocusedObject(dialog.getAccessible())); CPPUNIT_ASSERT(dialog.tabTo(accessibility::AccessibleRole::PUSH_BUTTON, u"Insert")); @@ -92,7 +93,7 @@ CPPUNIT_TEST_FIXTURE(test::SwAccessibleTestBase, TestSpecialCharactersDialogFocu CPPUNIT_ASSERT(activateMenuItem(u"Insert", u"Special Character...")); CPPUNIT_ASSERT(dialogWaiter->waitEndDialog()); - CPPUNIT_ASSERT_EQUAL(rtl::OUString(u"<PARAGRAPH>0</PARAGRAPH>"), collectText()); + CPPUNIT_ASSERT_EQUAL(rtl::OUString(u"<PARAGRAPH>!</PARAGRAPH>"), collectText()); } CPPUNIT_TEST_FIXTURE(test::SwAccessibleTestBase, BasicTestHyperlinkDialog) commit 224286b32587fe9a5db4a7f18b93956a0865d42d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Mar 7 11:19:19 2023 +0000 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Mar 8 06:03:58 2023 +0000 svx: Stop manually counting map entries The `nCount` member counts the number of elements in `m_aItemList`, but `std::unordered_map::size()` also returns that, so just use that instead. Use `SvxSearchCharSet::getMaxCharCount` in most places and simplify to use `std::min` in `SvxSearchCharSet::LastInView`. Change-Id: I8b66b1d83c0327026b13147f201995c7d1df1238 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148422 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/include/svx/searchcharmap.hxx b/include/svx/searchcharmap.hxx index 33d7432096d8..7ebc8ce5ab2c 100644 --- a/include/svx/searchcharmap.hxx +++ b/include/svx/searchcharmap.hxx @@ -54,8 +54,6 @@ public: virtual sal_Int32 getMaxCharCount() const override; private: - sal_Int32 nCount; - //index to char code mapping for the search //to uniquely identify each appended element std::unordered_map<sal_Int32, sal_UCS4> m_aItemList; diff --git a/svx/source/dialog/searchcharmap.cxx b/svx/source/dialog/searchcharmap.cxx index ea2ae309735a..02fb19be20b0 100644 --- a/svx/source/dialog/searchcharmap.cxx +++ b/svx/source/dialog/searchcharmap.cxx @@ -40,7 +40,6 @@ using namespace ::com::sun::star; SvxSearchCharSet::SvxSearchCharSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow, const VclPtr<VirtualDevice>& rVirDev) : SvxShowCharSet(std::move(pScrolledWindow), rVirDev) - , nCount(0) { } @@ -48,10 +47,7 @@ int SvxSearchCharSet::LastInView() const { int nIndex = FirstInView(); nIndex += ROW_COUNT * COLUMN_COUNT - 1; - int nCompare = nCount - 1; - if (nIndex > nCompare) - nIndex = nCompare; - return nIndex; + return std::min<int>(nIndex, getMaxCharCount() -1); } bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt) @@ -92,7 +88,7 @@ bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt) tmpSelected = 0; break; case KEY_END: - tmpSelected = nCount - 1; + tmpSelected = getMaxCharCount() - 1; break; case KEY_TAB: // some fonts have a character at these unicode control codes case KEY_ESCAPE: @@ -333,7 +329,7 @@ void SvxSearchCharSet::RecalculateFont(vcl::RenderContext& rRenderContext) nY = aSize.Height() / ROW_COUNT; //scrollbar settings -- error - int nLastRow = (nCount - 1 + COLUMN_COUNT) / COLUMN_COUNT; + int nLastRow = (getMaxCharCount() - 1 + COLUMN_COUNT) / COLUMN_COUNT; mxScrollArea->vadjustment_configure(mxScrollArea->vadjustment_get_value(), 0, nLastRow, 1, ROW_COUNT - 1, ROW_COUNT); // rearrange CharSet element in sync with nX- and nY-multiples @@ -371,7 +367,7 @@ void SvxSearchCharSet::SelectIndex(int nNewIndex, bool bFocus) int nDelta = (nNewIndex - LastInView() + COLUMN_COUNT) / COLUMN_COUNT; mxScrollArea->vadjustment_set_value(nOldPos + nDelta); - if( nNewIndex < nCount ) + if (nNewIndex < getMaxCharCount()) { nSelectedIndex = nNewIndex; Invalidate(); @@ -443,19 +439,18 @@ svx::SvxShowCharSetItem* SvxSearchCharSet::ImplGetItem( int _nPos ) sal_Int32 SvxSearchCharSet::getMaxCharCount() const { - return nCount; + return m_aItemList.size(); } void SvxSearchCharSet::ClearPreviousData() { m_aItemList.clear(); - nCount = 0; Invalidate(); } void SvxSearchCharSet::AppendCharToList(sal_UCS4 sChar) { - m_aItemList.insert(std::make_pair(nCount++, sChar)); + m_aItemList.insert(std::make_pair(m_aItemList.size(), sChar)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */