desktop/source/lib/init.cxx | 4 + sfx2/source/control/unoctitm.cxx | 4 + sw/qa/extras/tiledrendering/tiledrendering.cxx | 75 ++++++++++++++++++++++++- sw/source/uibase/shells/textsh1.cxx | 36 +++++++++++- 4 files changed, 115 insertions(+), 4 deletions(-)
New commits: commit d8be925640a142315bcf73c25f85fb8eefeba79a Author: Henry Castro <hcas...@collabora.com> Date: Mon Jul 10 17:33:38 2017 -0400 sw lok: enable Page Header/Footer Reviewed-on: https://gerrit.libreoffice.org/39782 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Henry Castro <hcas...@collabora.com> (cherry picked from commit 3ba914c229adfed5c917d1ee23d35b9184b092c4) Change-Id: I5e0d080c53079069a086f06c2a314b6372bf6391 Reviewed-on: https://gerrit.libreoffice.org/47830 Reviewed-by: pranavk <pran...@collabora.co.uk> Tested-by: pranavk <pran...@collabora.co.uk> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9cd6337fc395..a6e40937de00 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1771,7 +1771,9 @@ static void doc_iniUnoCommands () OUString(".uno:ParagraphDialog"), OUString(".uno:OutlineBullet"), OUString(".uno:InsertIndexesEntry"), - OUString(".uno:DocumentRepair") + OUString(".uno:DocumentRepair"), + OUString(".uno:InsertPageHeader"), + OUString(".uno:InsertPageFooter") }; util::URL aCommandURL; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 60c55bdeb3d6..bb90866246e9 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1006,7 +1006,9 @@ 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 == "DocumentRepair" || + aEvent.FeatureURL.Path == "InsertPageHeader" || + aEvent.FeatureURL.Path == "InsertPageFooter") { bool bTemp = false; aEvent.State >>= bTemp; diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 91cc2140716b..804f77073803 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -34,6 +34,7 @@ #include <sfx2/dispatch.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/lokhelper.hxx> +#include <sfx2/dispatch.hxx> #include <redline.hxx> #include <IDocumentRedlineAccess.hxx> @@ -89,6 +90,8 @@ public: void testDisableUndoRepair(); void testAllTrackedChanges(); void testDocumentRepair(); + void testPageHeader(); + void testPageFooter(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -136,7 +139,8 @@ public: CPPUNIT_TEST(testDisableUndoRepair); CPPUNIT_TEST(testAllTrackedChanges); CPPUNIT_TEST(testDocumentRepair); - + CPPUNIT_TEST(testPageHeader); + CPPUNIT_TEST(testPageFooter); CPPUNIT_TEST_SUITE_END(); private: @@ -1921,6 +1925,75 @@ void SwTiledRenderingTest::testDocumentRepair() comphelper::LibreOfficeKit::setActive(false); } +namespace { +void checkPageHeaderOrFooter(const SfxViewShell* pViewShell, sal_uInt16 nWhich, bool bValue) +{ + 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()); +}; + +} + +void SwTiledRenderingTest::testPageHeader() +{ + comphelper::LibreOfficeKit::setActive(); + + createDoc("dummy.fodt"); + SfxViewShell* pViewShell = SfxViewShell::Current(); + // Check Page Header State + checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, false); + // Insert Page Header + { + SfxBoolItem aItem(FN_PARAM_1, true); + pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEHEADER, SfxCallMode::SYNCHRON, {&aItem}); + } + // Check Page Header State + checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, true); + + // Remove Page Header + { + SfxBoolItem aItem(FN_PARAM_1, false); + pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEHEADER, SfxCallMode::SYNCHRON, {&aItem}); + } + // Check Page Header State + checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, false); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + +void SwTiledRenderingTest::testPageFooter() +{ + comphelper::LibreOfficeKit::setActive(); + + createDoc("dummy.fodt"); + SfxViewShell* pViewShell = SfxViewShell::Current(); + // Check Page Footer State + checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, false); + // Insert Page Footer + { + SfxBoolItem aItem(FN_PARAM_1, true); + pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEFOOTER, SfxCallMode::SYNCHRON, {&aItem}); + } + // Check Page Footer State + checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, true); + + // Remove Page Footer + { + SfxBoolItem aItem(FN_PARAM_1, false); + pViewShell->GetDispatcher()->ExecuteList(FN_INSERT_PAGEFOOTER, SfxCallMode::SYNCHRON, {&aItem}); + } + // Check Footer State + checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, false); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 824e6dc1d650..08da7496a15c 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -22,6 +22,7 @@ #include <hintids.hxx> #include <cmdid.h> #include <helpid.h> +#include <comphelper/lok.hxx> #include <i18nutil/unicode.hxx> #include <i18nlangtag/languagetag.hxx> @@ -97,6 +98,10 @@ #include <IDocumentStatistics.hxx> #include <sfx2/sfxdlg.hxx> #include <unotools/lingucfg.hxx> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/uno/Any.hxx> #include <editeng/unolingu.hxx> #include <unotools/syslocaleoptions.hxx> @@ -119,6 +124,9 @@ #include <memory> using namespace ::com::sun::star; +using namespace com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace com::sun::star::style; using namespace svx::sidebar; static void sw_CharDialogResult(const SfxItemSet* pSet, SwWrtShell &rWrtSh, std::shared_ptr<SfxItemSet> pCoreSet, bool bSel, bool bSelectionPut, SfxRequest *pReq); @@ -1356,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, !rReq.IsAPI()); + rWrtSh.ChangeHeaderOrFooter(sStyleName, FN_INSERT_PAGEHEADER == nSlot, bOn, !comphelper::LibreOfficeKit::isActive() && !rReq.IsAPI()); rReq.Done(); } break; @@ -1694,6 +1702,32 @@ void SwTextShell::GetState( SfxItemSet &rSet ) case FN_INSERT_PAGEHEADER: case FN_INSERT_PAGEFOOTER: + if (comphelper::LibreOfficeKit::isActive()) + { + bool bState = false; + bool bIsPhysical = false; + uno::Reference< XStyleFamiliesSupplier > xSupplier(GetView().GetDocShell()->GetBaseModel(), uno::UNO_QUERY); + if (xSupplier.is()) + { + uno::Reference< XNameContainer > xContainer; + uno::Reference< XNameAccess > xFamilies = xSupplier->getStyleFamilies(); + if (xFamilies->getByName("PageStyles") >>= xContainer) + { + uno::Sequence< OUString > aSeqNames = xContainer->getElementNames(); + for (sal_Int32 itNames = 0; itNames < aSeqNames.getLength(); itNames++) + { + uno::Reference< XPropertySet > xPropSet(xContainer->getByName(aSeqNames[itNames]), uno::UNO_QUERY); + if (xPropSet.is() && (xPropSet->getPropertyValue("IsPhysical") >>= bIsPhysical) && bIsPhysical) + { + if ((xPropSet->getPropertyValue(nWhich == FN_INSERT_PAGEHEADER ? OUString("HeaderIsOn") : OUString("FooterIsOn")) >>= bState) && bState) + break; + } + } + } + } + rSet.Put(SfxBoolItem(nWhich, bState)); + } + else { rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() )); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits