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

Miklos Vajna vmiklos at collabora.co.uk
Tue Jan 19 07:46:47 PST 2016


 desktop/qa/desktop_lib/test_desktop_lib.cxx |   43 +++++++++++++++++++++++++++-
 desktop/source/lib/init.cxx                 |    3 +
 sfx2/source/control/bindings.cxx            |    4 +-
 sfx2/source/control/unoctitm.cxx            |    3 +
 4 files changed, 49 insertions(+), 4 deletions(-)

New commits:
commit cdf08b3aa74bb32ea18b583a9c0c41b91d7819ac
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 19 16:30:59 2016 +0100

    CppunitTest_desktop_lib: add ModifiedStatus callback testcase
    
    Change-Id: Ieb7e808ebc7619c3a4a013cad776eeefd6163e22

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d55ae37..75b4f64 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -15,6 +15,7 @@
 #include <com/sun/star/awt/XReschedule.hpp>
 #include <com/sun/star/awt/Toolkit.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
 #include <boost/property_tree/json_parser.hpp>
 #include <comphelper/processfactory.hxx>
 #include <sfx2/objsh.hxx>
@@ -39,7 +40,8 @@ class DesktopLOKTest : public UnoApiTest
 public:
     DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
     m_nSelectionBeforeSearchResult(0),
-    m_nSelectionAfterSearchResult(0)
+    m_nSelectionAfterSearchResult(0),
+    m_bModified(false)
     {
     }
 
@@ -80,6 +82,7 @@ public:
     void testCellCursor();
     void testCommandResult();
     void testWriterComments();
+    void testModifiedStatus();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
     CPPUNIT_TEST(testGetStyles);
@@ -98,6 +101,7 @@ public:
     CPPUNIT_TEST(testCellCursor);
     CPPUNIT_TEST(testCommandResult);
     CPPUNIT_TEST(testWriterComments);
+    CPPUNIT_TEST(testModifiedStatus);
     CPPUNIT_TEST_SUITE_END();
 
     uno::Reference<lang::XComponent> mxComponent;
@@ -110,6 +114,10 @@ public:
     // for testCommandResult
     osl::Condition m_aCommandResultCondition;
     OString m_aCommandResult;
+
+    // for testModifiedStatus
+    osl::Condition m_aStateChangedCondition;
+    bool m_bModified;
 };
 
 LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType)
@@ -183,6 +191,17 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
         m_aCommandResultCondition.set();
     }
     break;
+    case LOK_CALLBACK_STATE_CHANGED:
+    {
+        OString aPayload(pPayload);
+        OString aPrefix(".uno:ModifiedStatus=");
+        if (aPayload.startsWith(aPrefix))
+        {
+            m_bModified = aPayload.copy(aPrefix.getLength()).toBoolean();
+            m_aStateChangedCondition.set();
+        }
+    }
+    break;
     }
 }
 
@@ -600,6 +619,28 @@ void DesktopLOKTest::testWriterComments()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void DesktopLOKTest::testModifiedStatus()
+{
+    LibLibreOffice_Impl aOffice;
+    comphelper::LibreOfficeKit::setActive();
+    LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+    pDocument->pClass->initializeForRendering(pDocument, nullptr);
+    pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+    // Set the document as modified.
+    m_aStateChangedCondition.reset();
+    uno::Reference<util::XModifiable> xModifiable(mxComponent, uno::UNO_QUERY);
+    xModifiable->setModified(true);
+    TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max
+    m_aStateChangedCondition.wait(aTimeValue);
+    Scheduler::ProcessEventsToIdle();
+
+    // This was false, there was no callback about the modified status change.
+    CPPUNIT_ASSERT(m_bModified);
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index aa62415..9e679b7 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -1587,7 +1587,9 @@ bool SfxBindings::NextJob_Impl(Timer * pTimer)
     }
 
     // if possible Update all server / happens in its own time slice
-    if ( pImp->bMsgDirty )
+    // but process all events at once when unit testing, for reliability reasons
+    static bool bTest = getenv("LO_TESTNAME");
+    if ( pImp->bMsgDirty && !bTest )
     {
         UpdateSlotServer_Impl();
         return false;
commit abbfbb4d35d6fa9edbb8f331a9d9503183eb0356
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 19 15:18:52 2016 +0100

    LOK: include ModifiedStatus in CALLBACK_STATE_CHANGED
    
    Change-Id: Ic44a9266a67bfad8b0490a8acb4a419af99ea42c

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f8d6a6c..d2b4f60 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -684,7 +684,8 @@ static void doc_iniUnoCommands ()
         OUString(".uno:SuperScript"),
         OUString(".uno:Strikeout"),
         OUString(".uno:StyleApply"),
-        OUString(".uno:Underline")
+        OUString(".uno:Underline"),
+        OUString(".uno:ModifiedStatus")
     };
 
     util::URL aCommandURL;
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 5b4b8af..7a2616c 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -1097,7 +1097,8 @@ void SfxDispatchController_Impl::InterceptLOKStateChangeEvent(const SfxObjectShe
         aEvent.FeatureURL.Path == "SubScript" ||
         aEvent.FeatureURL.Path == "SuperScript" ||
         aEvent.FeatureURL.Path == "Strikeout" ||
-        aEvent.FeatureURL.Path == "Underline")
+        aEvent.FeatureURL.Path == "Underline" ||
+        aEvent.FeatureURL.Path == "ModifiedStatus")
     {
         bool bTemp = false;
         aEvent.State >>= bTemp;


More information about the Libreoffice-commits mailing list