[Libreoffice-commits] core.git: sc/qa sc/source sfx2/source
sc/qa/unit/bugfix-test.cxx | 21 sc/qa/unit/data/ods/tdf108188_pagestyle.ods |binary sc/source/core/data/stlsheet.cxx| 35 +++- sfx2/source/dialog/StyleList.cxx| 15 4 files changed, 45 insertions(+), 26 deletions(-) New commits: commit ad79900cd62c487bda9d2515892d62b3b08a5dfa Author: Andreas Heinisch AuthorDate: Sun May 8 14:31:00 2022 +0200 Commit: Andreas Heinisch CommitDate: Tue May 10 20:30:56 2022 +0200 tdf#108188, tdf#131190 - Verify that the page style is actually used Change-Id: I007d26c6fcaf60d2a2378cc00e630da447f95a8a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134022 Tested-by: Andreas Heinisch Reviewed-by: Andreas Heinisch diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index 3b3cc27439df..2975b0b0a834 100644 --- a/sc/qa/unit/bugfix-test.cxx +++ b/sc/qa/unit/bugfix-test.cxx @@ -29,6 +29,7 @@ #include #include #include +#include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -63,6 +64,7 @@ public: void testTdf129789(); void testTdf130725(); void testTdf104502_hiddenColsCountedInPageCount(); +void testTdf108188_pagestyle(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testTdf137576_Measureline); @@ -87,6 +89,7 @@ public: CPPUNIT_TEST(testTdf129789); CPPUNIT_TEST(testTdf130725); CPPUNIT_TEST(testTdf104502_hiddenColsCountedInPageCount); +CPPUNIT_TEST(testTdf108188_pagestyle); CPPUNIT_TEST_SUITE_END(); private: @@ -726,6 +729,24 @@ void ScFiltersTest::testTdf104502_hiddenColsCountedInPageCount() xShell->DoClose(); } +void ScFiltersTest::testTdf108188_pagestyle() +{ +ScDocShellRef xDocSh = loadDoc(u"tdf108188_pagestyle.", FORMAT_ODS); +CPPUNIT_ASSERT(xDocSh); + +// Check if the user defined page style is present +const OUString aTestPageStyle = "TestPageStyle"; +ScDocument& rDoc = xDocSh->GetDocument(); +CPPUNIT_ASSERT_EQUAL(aTestPageStyle, rDoc.GetPageStyle(0)); + +// Without the accompanying fix in place, the page styles are always used +ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool(); +CPPUNIT_ASSERT(pStylePool->Find(aTestPageStyle, SfxStyleFamily::Page)->IsUsed()); +CPPUNIT_ASSERT(!pStylePool->Find("Default", SfxStyleFamily::Page)->IsUsed()); + +xDocSh->DoClose(); +} + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "sc/qa/unit/data" ) diff --git a/sc/qa/unit/data/ods/tdf108188_pagestyle.ods b/sc/qa/unit/data/ods/tdf108188_pagestyle.ods new file mode 100644 index ..d0ecf9f88453 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf108188_pagestyle.ods differ diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index e485b5f7fc99..fdf09e7cde3e 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -250,19 +250,32 @@ SfxItemSet& ScStyleSheet::GetItemSet() bool ScStyleSheet::IsUsed() const { -if ( GetFamily() == SfxStyleFamily::Para ) +switch (GetFamily()) { -// Always query the document to let it decide if a rescan is necessary, -// and store the state. -ScDocument* pDoc = static_cast(m_pPool)->GetDocument(); -if ( pDoc && pDoc->IsStyleSheetUsed( *this ) ) -eUsage = Usage::USED; -else -eUsage = Usage::NOTUSED; -return eUsage == Usage::USED; +case SfxStyleFamily::Para: +{ +// Always query the document to let it decide if a rescan is necessary, +// and store the state. +ScDocument* pDoc = static_cast(m_pPool)->GetDocument(); +if ( pDoc && pDoc->IsStyleSheetUsed( *this ) ) +eUsage = Usage::USED; +else +eUsage = Usage::NOTUSED; +return eUsage == Usage::USED; +} +case SfxStyleFamily::Page: +{ +// tdf#108188 - verify that the page style is actually used +ScDocument* pDoc = static_cast(m_pPool)->GetDocument(); +if (pDoc && pDoc->IsPageStyleInUse(GetName(), nullptr)) +eUsage = Usage::USED; +else +eUsage = Usage::NOTUSED; +return eUsage == Usage::USED; +} +default: +return true; } -else -return true; } void ScStyleSheet::Notify( SfxBroadcaster&, const SfxHint& rHint ) diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx index 6f8e3543aac8..a25050ead918 100644 --- a/sfx2/source/dialog/StyleList.cxx +++ b/sfx2/source/dialog/StyleList.cxx @@ -1321,21 +1321,6 @@ IMPL_LINK_NOARG(StyleList, EnableDelete, void*, void) { bEnableDelete = true; } -else if (pStyle->GetFamily() == SfxStyleFamily::Page) -{ -// Hack to
[Libreoffice-commits] core.git: sc/qa sc/source sfx2/source
sc/qa/unit/tiledrendering/tiledrendering.cxx | 67 +++ sc/source/ui/view/tabvwshb.cxx |3 + sfx2/source/view/viewfrm.cxx | 26 +- 3 files changed, 94 insertions(+), 2 deletions(-) New commits: commit 0ac92837d31c4065be4a41e2a2541811c9f6be00 Author: Henry CastroDate: Wed Jun 28 10:26:21 2017 -0400 sc lok: disable Undo/Redo state if conflict with other views Change-Id: I5bc5be2b17925ec3a203f9704f62a8c80ac5fc9d Reviewed-on: https://gerrit.libreoffice.org/39363 Tested-by: Jenkins Reviewed-by: Henry Castro diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 3778f4be1093..c90032a8c0ca 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -83,6 +83,7 @@ public: void testUndoRepairDispatch(); void testInsertGraphicInvalidations(); void testDocumentSizeWithTwoViews(); +void testDisableUndoRepair(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnSelections); @@ -109,6 +110,7 @@ public: CPPUNIT_TEST(testUndoRepairDispatch); CPPUNIT_TEST(testInsertGraphicInvalidations); CPPUNIT_TEST(testDocumentSizeWithTwoViews); +CPPUNIT_TEST(testDisableUndoRepair); CPPUNIT_TEST_SUITE_END(); private: @@ -1347,6 +1349,71 @@ void ScTiledRenderingTest::testDocumentSizeWithTwoViews() comphelper::LibreOfficeKit::setActive(false); } +void ScTiledRenderingTest::testDisableUndoRepair() +{ +comphelper::LibreOfficeKit::setActive(); +ScModelObj* pModelObj = createDoc("cursor-away.ods"); +CPPUNIT_ASSERT(pModelObj); + +// view #1 +int nView1 = SfxLokHelper::getView(); +SfxViewShell* pView1 = SfxViewShell::Current(); + +// view #2 +SfxLokHelper::createView(); +int nView2 = SfxLokHelper::getView(); +SfxViewShell* pView2 = SfxViewShell::Current(); +CPPUNIT_ASSERT(pView1 != pView2); +{ +SfxItemSet aSet1(pView1->GetPool(), svl::Items {}); +SfxItemSet aSet2(pView2->GetPool(), svl::Items {}); +pView1->GetSlotState(SID_UNDO, nullptr, ); +pView2->GetSlotState(SID_UNDO, nullptr, ); +CPPUNIT_ASSERT_EQUAL(SfxItemState::DISABLED, aSet1.GetItemState(SID_UNDO)); +CPPUNIT_ASSERT_EQUAL(SfxItemState::DISABLED, aSet2.GetItemState(SID_UNDO)); +} + +// text edit a cell in view #1 +SfxLokHelper::setView(nView1); +pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'h', 0); +pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'h', 0); +pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN); +pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN); +Scheduler::ProcessEventsToIdle(); +{ +SfxItemSet aSet1(pView1->GetPool(), svl::Items {}); +SfxItemSet aSet2(pView2->GetPool(), svl::Items {}); +pView1->GetSlotState(SID_UNDO, nullptr, ); +pView2->GetSlotState(SID_UNDO, nullptr, ); +CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aSet1.GetItemState(SID_UNDO)); +CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(aSet1.GetItem(SID_UNDO))); +CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aSet2.GetItemState(SID_UNDO)); +CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(aSet2.GetItem(SID_UNDO))); +CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item* >(aSet2.GetItem(SID_UNDO))->GetValue()); +} + +// text edit a cell in view #2 +SfxLokHelper::setView(nView2); +pModelObj->setPart(1); +pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0); +pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0); +pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN); +pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN); +Scheduler::ProcessEventsToIdle(); +Scheduler::ProcessEventsToIdle(); +{ +SfxItemSet aSet1(pView1->GetPool(), svl::Items {}); +SfxItemSet aSet2(pView2->GetPool(), svl::Items {}); +pView1->GetSlotState(SID_UNDO, nullptr, ); +pView2->GetSlotState(SID_UNDO, nullptr, ); +CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aSet1.GetItemState(SID_UNDO)); +CPPUNIT_ASSERT(dynamic_cast< const SfxUInt32Item* >(aSet1.GetItem(SID_UNDO))); +CPPUNIT_ASSERT_EQUAL(static_cast< sal_uInt32 >(SID_REPAIRPACKAGE), dynamic_cast< const SfxUInt32Item* >(aSet1.GetItem(SID_UNDO))->GetValue()); +CPPUNIT_ASSERT_EQUAL(SfxItemState::SET, aSet2.GetItemState(SID_UNDO)); +CPPUNIT_ASSERT(dynamic_cast< const SfxStringItem* >(aSet2.GetItem(SID_UNDO))); +} +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); diff --git