Kaydet (Commit) 3ba914c2 authored tarafından Henry Castro's avatar Henry Castro

sw lok: enable Page Header/Footer

Change-Id: I5e0d080c53079069a086f06c2a314b6372bf6391
Reviewed-on: https://gerrit.libreoffice.org/39782Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarHenry Castro <hcastro@collabora.com>
üst a31267be
...@@ -1748,7 +1748,9 @@ static void doc_iniUnoCommands () ...@@ -1748,7 +1748,9 @@ static void doc_iniUnoCommands ()
OUString(".uno:ParagraphDialog"), OUString(".uno:ParagraphDialog"),
OUString(".uno:OutlineBullet"), OUString(".uno:OutlineBullet"),
OUString(".uno:InsertIndexesEntry"), OUString(".uno:InsertIndexesEntry"),
OUString(".uno:DocumentRepair") OUString(".uno:DocumentRepair"),
OUString(".uno:InsertPageHeader"),
OUString(".uno:InsertPageFooter")
}; };
util::URL aCommandURL; util::URL aCommandURL;
......
...@@ -1019,7 +1019,9 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c ...@@ -1019,7 +1019,9 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
aEvent.FeatureURL.Path == "AlignLeft" || aEvent.FeatureURL.Path == "AlignLeft" ||
aEvent.FeatureURL.Path == "AlignHorizontalCenter" || aEvent.FeatureURL.Path == "AlignHorizontalCenter" ||
aEvent.FeatureURL.Path == "AlignRight" || aEvent.FeatureURL.Path == "AlignRight" ||
aEvent.FeatureURL.Path == "DocumentRepair") aEvent.FeatureURL.Path == "DocumentRepair" ||
aEvent.FeatureURL.Path == "InsertPageHeader" ||
aEvent.FeatureURL.Path == "InsertPageFooter")
{ {
bool bTemp = false; bool bTemp = false;
aEvent.State >>= bTemp; aEvent.State >>= bTemp;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx> #include <sfx2/viewfrm.hxx>
#include <sfx2/lokhelper.hxx> #include <sfx2/lokhelper.hxx>
#include <sfx2/dispatch.hxx>
#include <redline.hxx> #include <redline.hxx>
#include <IDocumentRedlineAccess.hxx> #include <IDocumentRedlineAccess.hxx>
#include <vcl/scheduler.hxx> #include <vcl/scheduler.hxx>
...@@ -96,6 +97,8 @@ public: ...@@ -96,6 +97,8 @@ public:
void testDisableUndoRepair(); void testDisableUndoRepair();
void testAllTrackedChanges(); void testAllTrackedChanges();
void testDocumentRepair(); void testDocumentRepair();
void testPageHeader();
void testPageFooter();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback); CPPUNIT_TEST(testRegisterCallback);
...@@ -143,7 +146,8 @@ public: ...@@ -143,7 +146,8 @@ public:
CPPUNIT_TEST(testDisableUndoRepair); CPPUNIT_TEST(testDisableUndoRepair);
CPPUNIT_TEST(testAllTrackedChanges); CPPUNIT_TEST(testAllTrackedChanges);
CPPUNIT_TEST(testDocumentRepair); CPPUNIT_TEST(testDocumentRepair);
CPPUNIT_TEST(testPageHeader);
CPPUNIT_TEST(testPageFooter);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -1933,6 +1937,75 @@ void SwTiledRenderingTest::testDocumentRepair() ...@@ -1933,6 +1937,75 @@ void SwTiledRenderingTest::testDocumentRepair()
comphelper::LibreOfficeKit::setActive(false); 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); CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <hintids.hxx> #include <hintids.hxx>
#include <cmdid.h> #include <cmdid.h>
#include <helpids.h> #include <helpids.h>
#include <comphelper/lok.hxx>
#include <i18nutil/unicode.hxx> #include <i18nutil/unicode.hxx>
#include <i18nlangtag/languagetag.hxx> #include <i18nlangtag/languagetag.hxx>
...@@ -94,6 +95,10 @@ ...@@ -94,6 +95,10 @@
#include <IDocumentStatistics.hxx> #include <IDocumentStatistics.hxx>
#include <sfx2/sfxdlg.hxx> #include <sfx2/sfxdlg.hxx>
#include <unotools/lingucfg.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 <com/sun/star/uno/Any.hxx>
#include <editeng/unolingu.hxx> #include <editeng/unolingu.hxx>
#include <unotools/syslocaleoptions.hxx> #include <unotools/syslocaleoptions.hxx>
...@@ -115,6 +120,9 @@ ...@@ -115,6 +120,9 @@
#include <memory> #include <memory>
using namespace ::com::sun::star; 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; using namespace svx::sidebar;
void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq ) void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq )
...@@ -1268,7 +1276,7 @@ void SwTextShell::Execute(SfxRequest &rReq) ...@@ -1268,7 +1276,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
bool bOn = true; bool bOn = true;
if( SfxItemState::SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem)) if( SfxItemState::SET == pArgs->GetItemState(FN_PARAM_1, false, &pItem))
bOn = static_cast<const SfxBoolItem*>(pItem)->GetValue(); 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(); rReq.Done();
} }
break; break;
...@@ -1612,6 +1620,32 @@ void SwTextShell::GetState( SfxItemSet &rSet ) ...@@ -1612,6 +1620,32 @@ void SwTextShell::GetState( SfxItemSet &rSet )
case FN_INSERT_PAGEHEADER: case FN_INSERT_PAGEHEADER:
case FN_INSERT_PAGEFOOTER: 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() )); rSet.Put( SfxObjectShellItem( nWhich, GetView().GetDocShell() ));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment