sw/qa/uitest/writer_tests/data/tdf107975.odt |binary sw/qa/uitest/writer_tests6/tdf107975.py | 42 +++++++++++++++++++++++++++ sw/source/core/access/accframebase.cxx | 8 +++++ sw/source/core/access/accmap.cxx | 17 ++++++++++ sw/source/core/layout/trvlfrm.cxx | 16 ++++++++-- 5 files changed, 79 insertions(+), 4 deletions(-)
New commits: commit 1145f62936c4979a50b26ddf3d6b9127dd749ab9 Author: Zdeněk Crhonek <zcrho...@gmail.com> AuthorDate: Wed Jun 12 19:13:17 2019 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Jul 22 14:02:44 2019 +0200 uitest for bug tdf#107975 Change-Id: I90300092b9f8aa4190acd05f41f3c7093a2229a3 Reviewed-on: https://gerrit.libreoffice.org/73907 Tested-by: Jenkins Reviewed-by: Zdenek Crhonek <zcrho...@gmail.com> (cherry picked from commit cd4ec0c236483d4c478157b08e310e1585412c7c) Reviewed-on: https://gerrit.libreoffice.org/76085 Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/sw/qa/uitest/writer_tests/data/tdf107975.odt b/sw/qa/uitest/writer_tests/data/tdf107975.odt new file mode 100644 index 000000000000..afcab1814b58 Binary files /dev/null and b/sw/qa/uitest/writer_tests/data/tdf107975.odt differ diff --git a/sw/qa/uitest/writer_tests6/tdf107975.py b/sw/qa/uitest/writer_tests6/tdf107975.py new file mode 100644 index 000000000000..202e7426bbaa --- /dev/null +++ b/sw/qa/uitest/writer_tests6/tdf107975.py @@ -0,0 +1,42 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, type_text +from uitest.debug import sleep +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 107975 - CRASH: Crash after undo operation (BigPtrArray::Index2Block(unsigned long) + +class tdf107975(UITestCase): + def test_tdf107975_crash_after_undo(self): + writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf107975.odt")) + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + #Press CTRL+A and + CTRL+C + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + #Position the mouse cursor (caret) after "ABC" below the blue image + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + #Paste CTRL+V + self.xUITest.executeCommand(".uno:Paste") + #Undo paste CTRL+Z -> Crash + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Text.String[0:3], "ABC") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: commit 74912b98a81efd41da7565bb508f364e58ac9a9f Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Thu Jul 18 18:27:18 2019 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jul 22 14:02:37 2019 +0200 (related: tdf#110442) sw: fix a11y/UI selection of at-char flys SwAccessibleFrameBase::GetSelectedState() and SwAccessibleMap ignored FLY_AT_CHAR flys for no apparent reason. SwRootFrame::CalcFrameRects() is the function that determines the selection overlay painted in the view. Change-Id: I60aae2e401d2e811ed1aa8eb95cfd093c65c1de4 Reviewed-on: https://gerrit.libreoffice.org/75961 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@cib.de> (cherry picked from commit be55b1915fd0374f8f25c2c1be2b39744666d052) Reviewed-on: https://gerrit.libreoffice.org/76087 Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/source/core/access/accframebase.cxx b/sw/source/core/access/accframebase.cxx index 609ca2e5b4d5..9b344b5a2b35 100644 --- a/sw/source/core/access/accframebase.cxx +++ b/sw/source/core/access/accframebase.cxx @@ -38,6 +38,7 @@ #include <txtfrm.hxx> #include <notxtfrm.hxx> #include <ndtxt.hxx> +#include <undobj.hxx> #include <dcontact.hxx> #include <fmtanchr.hxx> @@ -342,6 +343,13 @@ bool SwAccessibleFrameBase::GetSelectedState( ) && (nHere < nEndIndex ) ) return true; } + else if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR) + { + if (IsDestroyFrameAnchoredAtChar(*pPos, *pStart, *pEnd)) + { + return true; + } + } break; } // else: this PaM doesn't point to this paragraph diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx index fedd41e68fae..5d60c0020804 100644 --- a/sw/source/core/access/accmap.cxx +++ b/sw/source/core/access/accmap.cxx @@ -76,6 +76,7 @@ #include <dflyobj.hxx> #include <prevwpage.hxx> #include <calbck.hxx> +#include <undobj.hxx> #include <tools/diagnose_ex.h> #include <tools/debug.hxx> @@ -1203,7 +1204,6 @@ void SwAccessibleMap::InvalidateShapeInParaSelection() sal_uLong nEndIndex = pEnd->nNode.GetIndex(); if ((nStartIndex <= nLastNode) && (nFirstNode <= nEndIndex)) { - // FIXME: what about missing FLY_AT_CHAR? if( rAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR ) { if( ( ((nHere == nStartIndex) && (nIndex >= pStart->nContent.GetIndex())) || (nHere > nStartIndex) ) @@ -1237,6 +1237,21 @@ void SwAccessibleMap::InvalidateShapeInParaSelection() static_cast < ::accessibility::AccessibleShape* >(xAcc.get())->ResetState( AccessibleStateType::SELECTED ); } } + else if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR) + { + uno::Reference<XAccessible> const xAcc((*aIter).second); + if (xAcc.is()) + { + if (IsDestroyFrameAnchoredAtChar(*pPos, *pStart, *pEnd)) + { + static_cast<::accessibility::AccessibleShape*>(xAcc.get())->SetState( AccessibleStateType::SELECTED ); + } + else + { + static_cast<::accessibility::AccessibleShape*>(xAcc.get())->ResetState( AccessibleStateType::SELECTED ); + } + } + } } } } diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 24b9f6b588f3..ceb5f26a4564 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -48,6 +48,7 @@ #include <frmatr.hxx> #include <frmtool.hxx> #include <ndtxt.hxx> +#include <undobj.hxx> #include <cfloat> #include <swselectionlist.hxx> @@ -2573,9 +2574,18 @@ void SwRootFrame::CalcFrameRects(SwShellCursor &rCursor) const SwFlyFrame* pFly = static_cast<const SwFlyFrame*>(pAnchoredObj); const SwVirtFlyDrawObj* pObj = pFly->GetVirtDrawObj(); const SwFormatSurround &rSur = pFly->GetFormat()->GetSurround(); - const SwPosition* anchoredAt = pAnchoredObj->GetFrameFormat().GetAnchor().GetContentAnchor(); - bool inSelection = ( anchoredAt != nullptr && *pStartPos <= *anchoredAt && *anchoredAt < *pEndPos ); - if( anchoredAt != nullptr && *anchoredAt == *pEndPos ) + SwFormatAnchor const& rAnchor(pAnchoredObj->GetFrameFormat().GetAnchor()); + const SwPosition* anchoredAt = rAnchor.GetContentAnchor(); + bool inSelection = ( + anchoredAt != nullptr + && ( (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR + && IsDestroyFrameAnchoredAtChar(*anchoredAt, *pStartPos, *pEndPos)) + || (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA + && *pStartPos <= *anchoredAt + && *anchoredAt < *pEndPos))); + if (anchoredAt != nullptr + && rAnchor.GetAnchorId() != RndStdIds::FLY_AT_CHAR + && *anchoredAt == *pEndPos) { const SwNodes& nodes = anchoredAt->GetDoc()->GetNodes(); if( *pEndPos == SwPosition( nodes.GetEndOfContent())) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits