desktop/qa/desktop_lib/test_desktop_lib.cxx | 1 desktop/source/lib/init.cxx | 29 +++++++++++++++++++ sfx2/source/control/unoctitm.cxx | 25 ++++++++++++++-- sw/qa/extras/tiledrendering/tiledrendering.cxx | 26 +++++++++++++---- sw/source/uibase/shells/textsh1.cxx | 37 +++++++++++++++++++------ 5 files changed, 101 insertions(+), 17 deletions(-)
New commits: commit 83202ea1341c98a216871f14702548ce5aabd94a Author: Henry Castro <hcas...@collabora.com> Date: Tue Jan 9 22:17:23 2018 -0400 sw lokit: add page syles to header & footer Change-Id: I3c0b0603d1e03f1cc19af4324dd2b909320d9d4a Reviewed-on: https://gerrit.libreoffice.org/47687 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Henry Castro <hcas...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/48236 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index d35faff93900..163db824c32d 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -306,6 +306,7 @@ void DesktopLOKTest::testGetStyles() rPair.first != "CellStyles" && rPair.first != "ShapeStyles" && rPair.first != "TableStyles" && + rPair.first != "HeaderFooter" && rPair.first != "Commands") { CPPUNIT_FAIL("Unknown style family: " + rPair.first); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 1de022c3fa68..0c20f6936a28 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2795,6 +2795,35 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) aValues.add_child(sStyleFam.toUtf8().getStr(), aChildren); } + // Header & Footer Styles + { + OUString sName; + bool bIsPhysical; + boost::property_tree::ptree aChild; + uno::Reference<beans::XPropertySet> xProperty; + boost::property_tree::ptree aChildren; + uno::Reference<container::XNameContainer> xContainer; + + if (xStyleFamilies->getByName("PageStyles") >>= xContainer) + { + uno::Sequence<OUString> aSeqNames = xContainer->getElementNames(); + for (sal_Int32 itName = 0; itName < aSeqNames.getLength(); itName++) + { + sName = aSeqNames[itName]; + xProperty.set(xContainer->getByName(sName), uno::UNO_QUERY); + if (xProperty.is() && (xProperty->getPropertyValue("IsPhysical") >>= bIsPhysical) && bIsPhysical) + { + xProperty->getPropertyValue("DisplayName") >>= sName; + aChild.put("", sName.toUtf8()); + aChildren.push_back(std::make_pair("", aChild)); + } + else + bIsPhysical = false; + } + aValues.add_child("HeaderFooter", aChildren); + } + } + { boost::property_tree::ptree aCommandList; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index b74f971d6a07..39561e09489e 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1006,9 +1006,7 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c aEvent.FeatureURL.Path == "AlignLeft" || aEvent.FeatureURL.Path == "AlignHorizontalCenter" || aEvent.FeatureURL.Path == "AlignRight" || - aEvent.FeatureURL.Path == "DocumentRepair" || - aEvent.FeatureURL.Path == "InsertPageHeader" || - aEvent.FeatureURL.Path == "InsertPageFooter") + aEvent.FeatureURL.Path == "DocumentRepair") { bool bTemp = false; aEvent.State >>= bTemp; @@ -1185,6 +1183,27 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c } } } + else if (aEvent.FeatureURL.Path == "InsertPageHeader" || + aEvent.FeatureURL.Path == "InsertPageFooter") + { + if (aEvent.IsEnabled) + { + css::uno::Sequence< OUString > aSeq; + if (aEvent.State >>= aSeq) + { + aBuffer.append(u'{'); + for (sal_Int32 itSeq = 0; itSeq < aSeq.getLength(); itSeq++) + { + aBuffer.append("\"" + aSeq[itSeq]); + if (itSeq != aSeq.getLength() - 1) + aBuffer.append("\":true,"); + else + aBuffer.append("\":true"); + } + aBuffer.append(u'}'); + } + } + } else { return; diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 804f77073803..226874291be6 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -23,6 +23,7 @@ #include <editeng/editview.hxx> #include <editeng/outliner.hxx> #include <svl/srchitem.hxx> +#include <svl/slstitm.hxx> #include <drawdoc.hxx> #include <ndtxt.hxx> #include <wrtsh.hxx> @@ -1928,10 +1929,19 @@ void SwTiledRenderingTest::testDocumentRepair() namespace { void checkPageHeaderOrFooter(const SfxViewShell* pViewShell, sal_uInt16 nWhich, bool bValue) { + uno::Sequence<OUString> aSeq; const SfxPoolItem* pState = nullptr; pViewShell->GetDispatcher()->QueryState(nWhich, pState); - CPPUNIT_ASSERT(dynamic_cast< const SfxBoolItem * >(pState)); - CPPUNIT_ASSERT_EQUAL(bValue, dynamic_cast< const SfxBoolItem * >(pState)->GetValue()); + const SfxStringListItem* pListItem = dynamic_cast<const SfxStringListItem*>(pState); + CPPUNIT_ASSERT(pListItem); + pListItem->GetStringList(aSeq); + if (bValue) + { + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aSeq.getLength()); + CPPUNIT_ASSERT_EQUAL(OUString("Default Style"), aSeq[0]); + } + else + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aSeq.getLength()); }; } @@ -1946,16 +1956,18 @@ void SwTiledRenderingTest::testPageHeader() checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, false); // Insert Page Header { + SfxStringItem aStyle(FN_INSERT_PAGEHEADER, "Default Style"); SfxBoolItem aItem(FN_PARAM_1, true); - pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEHEADER, SfxCallMode::SYNCHRON, {&aItem}); + pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEHEADER, SfxCallMode::API | SfxCallMode::SYNCHRON, {&aStyle, &aItem}); } // Check Page Header State checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, true); // Remove Page Header { + SfxStringItem aStyle(FN_INSERT_PAGEHEADER, "Default Style"); SfxBoolItem aItem(FN_PARAM_1, false); - pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEHEADER, SfxCallMode::SYNCHRON, {&aItem}); + pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEHEADER, SfxCallMode::API | SfxCallMode::SYNCHRON, {&aStyle, &aItem}); } // Check Page Header State checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, false); @@ -1975,16 +1987,18 @@ void SwTiledRenderingTest::testPageFooter() checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, false); // Insert Page Footer { + SfxStringItem aPageStyle(FN_INSERT_PAGEFOOTER, "Default Style"); SfxBoolItem aItem(FN_PARAM_1, true); - pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEFOOTER, SfxCallMode::SYNCHRON, {&aItem}); + pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEFOOTER, SfxCallMode::API | SfxCallMode::SYNCHRON, {&aPageStyle, &aItem}); } // Check Page Footer State checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, true); // Remove Page Footer { + SfxStringItem aPageStyle(FN_INSERT_PAGEFOOTER, "Default Style"); SfxBoolItem aItem(FN_PARAM_1, false); - pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEFOOTER, SfxCallMode::SYNCHRON, {&aItem}); + pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEFOOTER, SfxCallMode::API | SfxCallMode::SYNCHRON, {&aPageStyle, &aItem}); } // Check Footer State checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, false); diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 51909fa43504..f45f89462d05 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1364,7 +1364,7 @@ void SwTextShell::Execute(SfxRequest &rReq) bool bOn = true; if( SfxItemState::SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem)) bOn = static_cast<const SfxBoolItem*>(pItem)->GetValue(); - rWrtSh.ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !comphelper::LibreOfficeKit::isActive() && !rReq.IsAPI()); + rWrtSh.ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !rReq.IsAPI()); rReq.Done(); } break; @@ -1705,7 +1705,15 @@ void SwTextShell::GetState( SfxItemSet &rSet ) if (comphelper::LibreOfficeKit::isActive()) { bool bState = false; + bool bAllState = true; bool bIsPhysical = false; + + OUString aStyleName; + std::vector<OUString> aList; + const OUString sPhysical("IsPhysical"); + const OUString sDisplay("DisplayName"); + const OUString sHeaderOn(nWhich == FN_INSERT_PAGEHEADER ? OUString("HeaderIsOn") : OUString("FooterIsOn")); + uno::Reference< XStyleFamiliesSupplier > xSupplier(GetView().GetDocShell()->GetBaseModel(), uno::UNO_QUERY); if (xSupplier.is()) { @@ -1714,18 +1722,31 @@ void SwTextShell::GetState( SfxItemSet &rSet ) if (xFamilies->getByName("PageStyles") >>= xContainer) { uno::Sequence< OUString > aSeqNames = xContainer->getElementNames(); - for (sal_Int32 itNames = 0; itNames < aSeqNames.getLength(); itNames++) + for (sal_Int32 itName = 0; itName < aSeqNames.getLength(); itName++) { - uno::Reference< XPropertySet > xPropSet(xContainer->getByName(aSeqNames[itNames]), uno::UNO_QUERY); - if (xPropSet.is() && (xPropSet->getPropertyValue("IsPhysical") >>= bIsPhysical) && bIsPhysical) + aStyleName = aSeqNames[itName]; + uno::Reference<XPropertySet> xPropSet(xContainer->getByName(aStyleName), uno::UNO_QUERY); + if (xPropSet.is() && (xPropSet->getPropertyValue(sPhysical) >>= bIsPhysical) && bIsPhysical) { - if ((xPropSet->getPropertyValue(nWhich == FN_INSERT_PAGEHEADER ? OUString("HeaderIsOn") : OUString("FooterIsOn")) >>= bState) && bState) - break; + xPropSet->getPropertyValue(sDisplay) >>= aStyleName; + if ((xPropSet->getPropertyValue(sHeaderOn)>>= bState) && bState) + aList.push_back(aStyleName); + else + bState = false; + + // Check if all entries have the same state + bAllState &= bState; } - } + else + bIsPhysical = false; + } } } - rSet.Put(SfxBoolItem(nWhich, bState)); + + if (bAllState && aList.size() > 1) + aList.push_back("_ALL_"); + + rSet.Put(SfxStringListItem(nWhich, &aList)); } else { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits