[Libreoffice-commits] core.git: desktop/source sfx2/source sw/qa sw/source

Henry Castro hcastro at collabora.com
Fri Dec 8 17:12:36 UTC 2017


 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 3ba914c229adfed5c917d1ee23d35b9184b092c4
Author: Henry Castro <hcastro at collabora.com>
Date:   Mon Jul 10 17:33:38 2017 -0400

    sw lok: enable Page Header/Footer
    
    Change-Id: I5e0d080c53079069a086f06c2a314b6372bf6391
    Reviewed-on: https://gerrit.libreoffice.org/39782
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 51bcd2e34afb..f5361bdb834a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1748,7 +1748,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 d5adabbaa598..5f4c2edf5241 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1019,7 +1019,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 d6f95df456e7..9c8f35dcc6d2 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>
 #include <vcl/scheduler.hxx>
@@ -96,6 +97,8 @@ public:
     void testDisableUndoRepair();
     void testAllTrackedChanges();
     void testDocumentRepair();
+    void testPageHeader();
+    void testPageFooter();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -143,7 +146,8 @@ public:
     CPPUNIT_TEST(testDisableUndoRepair);
     CPPUNIT_TEST(testAllTrackedChanges);
     CPPUNIT_TEST(testDocumentRepair);
-
+    CPPUNIT_TEST(testPageHeader);
+    CPPUNIT_TEST(testPageFooter);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1933,6 +1937,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 7a83cc9408c6..191dc8683f05 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 <helpids.h>
+#include <comphelper/lok.hxx>
 
 #include <i18nutil/unicode.hxx>
 #include <i18nlangtag/languagetag.hxx>
@@ -94,6 +95,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>
@@ -115,6 +120,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;
 
 void sw_CharDialog( SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq )
@@ -1268,7 +1276,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;
@@ -1612,6 +1620,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() ));
             }


More information about the Libreoffice-commits mailing list