diff options
-rw-r--r-- | sw/qa/uitest/data/chained-frames.odt | bin | 0 -> 10241 bytes | |||
-rw-r--r-- | sw/qa/uitest/ui/frmdlg/frmdlg.py | 17 | ||||
-rw-r--r-- | sw/source/ui/frmdlg/frmpage.cxx | 23 |
3 files changed, 29 insertions, 11 deletions
diff --git a/sw/qa/uitest/data/chained-frames.odt b/sw/qa/uitest/data/chained-frames.odt Binary files differnew file mode 100644 index 000000000000..281e06520e27 --- /dev/null +++ b/sw/qa/uitest/data/chained-frames.odt diff --git a/sw/qa/uitest/ui/frmdlg/frmdlg.py b/sw/qa/uitest/ui/frmdlg/frmdlg.py index cfa2dd8ba954..e3aeb67c569c 100644 --- a/sw/qa/uitest/ui/frmdlg/frmdlg.py +++ b/sw/qa/uitest/ui/frmdlg/frmdlg.py @@ -13,6 +13,7 @@ import time from libreoffice.uno.propertyvalue import mkPropertyValues from uitest.framework import UITestCase from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import get_url_for_data_file class Test(UITestCase): @@ -44,5 +45,21 @@ class Test(UITestCase): # Then make sure the doc model is updated correctly: self.assertEqual(xComponent.TextFrames.Frame1.IsSplitAllowed, True) + def test_chained_fly_split(self): + # Given a document with 2 chained fly frames: + with self.ui_test.load_file(get_url_for_data_file("chained-frames.odt")): + # When selecting the first and opening the fly frame properties dialog: + self.xUITest.executeCommand(".uno:JumpToNextFrame") + # Wait until SwTextShell is replaced with SwDrawShell after 120 ms, as set in the SwView + # ctor. + time.sleep(0.2) + with self.ui_test.execute_dialog_through_command(".uno:FrameDialog") as xDialog: + # Then make sure that the 'split' checkbox is hidden: + xFlysplit = xDialog.getChild("flysplit") + # Without the accompanying fix in place, this test would have failed with: + # AssertionError: 'true' != 'false' + # i.e. the UI didn't hide this option, leading to some weird mix of chained shapes + # and floating tables. + self.assertEqual(get_state_as_dict(xFlysplit)['Visible'], "false") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx index 74ccc1a51809..82bb86e7a095 100644 --- a/sw/source/ui/frmdlg/frmpage.cxx +++ b/sw/source/ui/frmdlg/frmpage.cxx @@ -798,15 +798,9 @@ namespace }; /// Checks if the current fly frame contains exactly one table. -bool ContainsSingleTable(SwWrtShell* pWrtShell) +bool ContainsSingleTable(const SwFrameFormat& rFlyFormat) { - const SwFrameFormat* pFlyFormat = pWrtShell->GetFlyFrameFormat(); - if (!pFlyFormat) - { - return false; - } - - const SwNodeIndex* pStartNode = pFlyFormat->GetContent().GetContentIdx(); + const SwNodeIndex* pStartNode = rFlyFormat.GetContent().GetContentIdx(); if (!pStartNode) { return false; @@ -830,6 +824,12 @@ bool ContainsSingleTable(SwWrtShell* pWrtShell) return true; } + +bool ContainsChain(const SwFrameFormat& rFlyFormat) +{ + const SwFormatChain& rChain = rFlyFormat.GetChain(); + return rChain.GetPrev() || rChain.GetNext(); +} } void SwFramePage::setOptimalRelWidth() @@ -1047,10 +1047,11 @@ void SwFramePage::Reset( const SfxItemSet *rSet ) m_xFlySplitCB->set_sensitive(m_xAnchorAtParaRB->get_active()); } - if (!ContainsSingleTable(pSh)) + const SwFrameFormat* pFlyFormat = pSh->GetFlyFrameFormat(); + if (!pFlyFormat || !ContainsSingleTable(*pFlyFormat) || ContainsChain(*pFlyFormat)) { - // Only allow fly split if the frame contains a single table, otherwise it would be hard the - // resulting model to Word formats. + // Only allow fly split if the frame contains a single table, otherwise it would be hard to + // save the resulting model to Word formats. m_xFlySplitCB->hide(); } |