core.git: Branch 'distro/collabora/co-24.04' - framework/inc framework/source

2024-05-25 Thread Michael Meeks (via logerrit)
 framework/inc/helper/statusindicatorfactory.hxx|2 
 framework/inc/helper/wakeupthread.hxx  |   17 --
 framework/source/helper/statusindicatorfactory.cxx |   13 -
 framework/source/helper/wakeupthread.cxx   |  152 ++---
 4 files changed, 144 insertions(+), 40 deletions(-)

New commits:
commit 6e322952a57484c1d823acd5c19797c7d3dea579
Author: Michael Meeks 
AuthorDate: Fri May 24 21:32:27 2024 +0100
Commit: Noel Grandin 
CommitDate: Sat May 25 19:20:58 2024 +0200

WakeupThread - re-factor to have a single shared wakeup thread.

The WakeupThread is an attempt to avoid needing to call gettimeofday
and/or update a visual status bar very regularly, and to have a thread
marking the passing of time to emit progress updates infrequently.

Re-factor this to have a single time-keeping thread, so it will be
easier to shutdown and re-start for LOK; and also to simplify some
of the complexity lurking here.

Change-Id: Ia95890e5d6041a029484aa3f7df13b59a0397086
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168032
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Noel Grandin 

diff --git a/framework/inc/helper/statusindicatorfactory.hxx 
b/framework/inc/helper/statusindicatorfactory.hxx
index c492a645f5bc..08f31aa87ada 100644
--- a/framework/inc/helper/statusindicatorfactory.hxx
+++ b/framework/inc/helper/statusindicatorfactory.hxx
@@ -150,7 +150,7 @@ class StatusIndicatorFactory final : public  
::cppu::WeakImplHelper<
 
 /** Notify us if a fix time is over. We use it to implement an
 intelligent "Reschedule" ... */
-rtl::Reference m_pWakeUp;
+std::unique_ptr m_pWakeUp;
 
 /** Our WakeUpThread calls us in our interface method 
"XUpdatable::update().
 There we set this member m_bAllowReschedule to sal_True. Next time 
if our impl_reschedule()
diff --git a/framework/inc/helper/wakeupthread.hxx 
b/framework/inc/helper/wakeupthread.hxx
index cdc8700a5266..b25a933dc8c8 100644
--- a/framework/inc/helper/wakeupthread.hxx
+++ b/framework/inc/helper/wakeupthread.hxx
@@ -23,9 +23,6 @@
 
 #include 
 #include 
-#include 
-#include 
-#include 
 
 namespace com::sun::star::util
 {
@@ -34,19 +31,17 @@ class XUpdatable;
 
 namespace framework
 {
-class WakeUpThread final : public salhelper::Thread
+/// Provides a regular callback to @updatable roughly every 25ms while running
+class WakeUpThread final
 {
-css::uno::WeakReference updatable_;
-std::condition_variable condition_;
-std::mutex mutex_;
-bool terminate_;
-
-void execute() override;
+css::uno::Reference _updatable;
 
 public:
 WakeUpThread(css::uno::Reference const& updatable);
-
 void stop();
+
+static void joinThread();
+static void startThread();
 };
 }
 
diff --git a/framework/source/helper/statusindicatorfactory.cxx 
b/framework/source/helper/statusindicatorfactory.cxx
index 64cf3543c22a..879bd8597b33 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -544,24 +544,19 @@ void StatusIndicatorFactory::impl_startWakeUpThread()
 if (m_bDisableReschedule)
 return;
 
-if (!m_pWakeUp.is())
-{
-m_pWakeUp = new WakeUpThread(this);
-m_pWakeUp->launch();
-}
+if (!m_pWakeUp)
+m_pWakeUp.reset(new WakeUpThread(this));
 }
 
 void StatusIndicatorFactory::impl_stopWakeUpThread()
 {
-rtl::Reference wakeUp;
+std::unique_ptr wakeUp;
 {
 std::scoped_lock g(m_mutex);
 std::swap(wakeUp, m_pWakeUp);
 }
-if (wakeUp.is())
-{
+if (wakeUp)
 wakeUp->stop();
-}
 }
 
 } // namespace framework
diff --git a/framework/source/helper/wakeupthread.cxx 
b/framework/source/helper/wakeupthread.cxx
index 40487c83b88f..63d52a82da76 100644
--- a/framework/source/helper/wakeupthread.cxx
+++ b/framework/source/helper/wakeupthread.cxx
@@ -21,40 +21,154 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
-#include 
 
 using namespace std::chrono_literals;
 
-void framework::WakeUpThread::execute() {
-for (;;) {
+/// We only need one thread to wake everyone up.
+
+namespace
+{
+class SharedWakeUpThread final : public salhelper::Thread
+{
+static std::vector> 
updatables;
+std::condition_variable condition;
+bool terminate;
+
+public:
+static rtl::Reference wakeupThread;
+
+static std::mutex& getMutex()
+{
+static std::mutex mutex;
+return mutex;
+}
+
+SharedWakeUpThread()
+: Thread("WakeUpThread")
+, terminate(false)
+{
+assert(!wakeupThread);
+launch();
+}
+
+void execute() override
+{
+while (true)
 {
-std::unique_lock g(mutex_);
-condition_.wait_for(g, 25ms, [this] { return terminate_; });
-if (terminate_) {
+

core.git: framework/inc framework/source

2024-05-25 Thread Michael Meeks (via logerrit)
 framework/inc/helper/statusindicatorfactory.hxx|2 
 framework/inc/helper/wakeupthread.hxx  |   17 --
 framework/source/helper/statusindicatorfactory.cxx |   13 -
 framework/source/helper/wakeupthread.cxx   |  152 ++---
 4 files changed, 144 insertions(+), 40 deletions(-)

New commits:
commit c28bcfd7a0c40e8c839a14868e211b7ff003cde5
Author: Michael Meeks 
AuthorDate: Fri May 24 21:32:27 2024 +0100
Commit: Michael Meeks 
CommitDate: Sat May 25 14:57:23 2024 +0200

WakeupThread - re-factor to have a single shared wakeup thread.

The WakeupThread is an attempt to avoid needing to call gettimeofday
and/or update a visual status bar very regularly, and to have a thread
marking the passing of time to emit progress updates infrequently.

Re-factor this to have a single time-keeping thread, so it will be
easier to shutdown and re-start for LOK; and also to simplify some
of the complexity lurking here.

Change-Id: Ia95890e5d6041a029484aa3f7df13b59a0397086
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167949
Reviewed-by: Michael Meeks 
Tested-by: Jenkins

diff --git a/framework/inc/helper/statusindicatorfactory.hxx 
b/framework/inc/helper/statusindicatorfactory.hxx
index 007607e1d543..1bb07f1a0c08 100644
--- a/framework/inc/helper/statusindicatorfactory.hxx
+++ b/framework/inc/helper/statusindicatorfactory.hxx
@@ -150,7 +150,7 @@ class StatusIndicatorFactory final : public  
::cppu::WeakImplHelper<
 
 /** Notify us if a fix time is over. We use it to implement an
 intelligent "Reschedule" ... */
-rtl::Reference m_pWakeUp;
+std::unique_ptr m_pWakeUp;
 
 /** Our WakeUpThread calls us in our interface method 
"XUpdatable::update().
 There we set this member m_bAllowReschedule to sal_True. Next time 
if our impl_reschedule()
diff --git a/framework/inc/helper/wakeupthread.hxx 
b/framework/inc/helper/wakeupthread.hxx
index cdc8700a5266..b25a933dc8c8 100644
--- a/framework/inc/helper/wakeupthread.hxx
+++ b/framework/inc/helper/wakeupthread.hxx
@@ -23,9 +23,6 @@
 
 #include 
 #include 
-#include 
-#include 
-#include 
 
 namespace com::sun::star::util
 {
@@ -34,19 +31,17 @@ class XUpdatable;
 
 namespace framework
 {
-class WakeUpThread final : public salhelper::Thread
+/// Provides a regular callback to @updatable roughly every 25ms while running
+class WakeUpThread final
 {
-css::uno::WeakReference updatable_;
-std::condition_variable condition_;
-std::mutex mutex_;
-bool terminate_;
-
-void execute() override;
+css::uno::Reference _updatable;
 
 public:
 WakeUpThread(css::uno::Reference const& updatable);
-
 void stop();
+
+static void joinThread();
+static void startThread();
 };
 }
 
diff --git a/framework/source/helper/statusindicatorfactory.cxx 
b/framework/source/helper/statusindicatorfactory.cxx
index 9ac4022f60dd..6bf526e340b4 100644
--- a/framework/source/helper/statusindicatorfactory.cxx
+++ b/framework/source/helper/statusindicatorfactory.cxx
@@ -544,24 +544,19 @@ void StatusIndicatorFactory::impl_startWakeUpThread()
 if (m_bDisableReschedule)
 return;
 
-if (!m_pWakeUp.is())
-{
-m_pWakeUp = new WakeUpThread(this);
-m_pWakeUp->launch();
-}
+if (!m_pWakeUp)
+m_pWakeUp.reset(new WakeUpThread(this));
 }
 
 void StatusIndicatorFactory::impl_stopWakeUpThread()
 {
-rtl::Reference wakeUp;
+std::unique_ptr wakeUp;
 {
 std::scoped_lock g(m_mutex);
 std::swap(wakeUp, m_pWakeUp);
 }
-if (wakeUp.is())
-{
+if (wakeUp)
 wakeUp->stop();
-}
 }
 
 } // namespace framework
diff --git a/framework/source/helper/wakeupthread.cxx 
b/framework/source/helper/wakeupthread.cxx
index 40487c83b88f..63d52a82da76 100644
--- a/framework/source/helper/wakeupthread.cxx
+++ b/framework/source/helper/wakeupthread.cxx
@@ -21,40 +21,154 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
-#include 
 
 using namespace std::chrono_literals;
 
-void framework::WakeUpThread::execute() {
-for (;;) {
+/// We only need one thread to wake everyone up.
+
+namespace
+{
+class SharedWakeUpThread final : public salhelper::Thread
+{
+static std::vector> 
updatables;
+std::condition_variable condition;
+bool terminate;
+
+public:
+static rtl::Reference wakeupThread;
+
+static std::mutex& getMutex()
+{
+static std::mutex mutex;
+return mutex;
+}
+
+SharedWakeUpThread()
+: Thread("WakeUpThread")
+, terminate(false)
+{
+assert(!wakeupThread);
+launch();
+}
+
+void execute() override
+{
+while (true)
 {
-std::unique_lock g(mutex_);
-condition_.wait_for(g, 25ms, [this] { return terminate_; });
-if (terminate_) {
+

core.git: desktop/source

2024-05-23 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   79 +---
 1 file changed, 53 insertions(+), 26 deletions(-)

New commits:
commit aaf4613a0aeb9cf7c27c731f2391de14bdcff880
Author: Michael Meeks 
AuthorDate: Fri May 17 21:25:29 2024 +0100
Commit: Michael Meeks 
CommitDate: Thu May 23 12:31:46 2024 +0200

lok: stop amazing waste of repeated font sizes in each font element.

These days all sensible fonts are scalable, so anything else is madness.

With the compact_fonts option we go from:

INCOMING: commandvalues: 
{"commandName":".uno:CharFontName","commandValues":
{"Albany 
AMT":["6","7","8","9","10","10.5","11","12","13","14","15","16",
"18","20","21","22","24","26","28","32","36","40","42","44","48","54",
"60","66","72","80","88","96"],"Amiri":["6","7"



INCOMING: commandvalues: { "commandName": ".uno:CharFontName", 
"FontNames":
[ "Albany AMT", "Amiri", "Amiri Quran", "Amiri Quran Colored", "Andale 
Mono",
"Andale Sans", "Andy MT", "AR PL UMing CN", "AR PL UMing HK", "AR PL 
UMing TW",
"AR PL UMing TW MBE", "Arial",

   

An 8x size win.

Change-Id: I3dc9f5de876def6e4afc09a43105b1740f7c621f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167799
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Noel Grandin 
(cherry picked from commit 628f56a1802ad76cbe84a9a5590b04ed81a57a9e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167962
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7730614d6a49..4e484cf71a34 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -252,11 +252,12 @@ extern "C" {
 
 #endif
 
-
 using LanguageToolCfg = 
officecfg::Office::Linguistic::GrammarChecking::LanguageTool;
 
+
 static LibLibreOffice_Impl *gImpl = nullptr;
 static bool lok_preinit_2_called = false;
+static bool gUseCompactFonts = false;
 static std::weak_ptr< LibreOfficeKitClass > gOfficeClass;
 static std::weak_ptr< LibreOfficeKitDocumentClass > gDocumentClass;
 
@@ -6036,7 +6037,7 @@ static char* getLanguages(const char* pCommand)
 return pJson;
 }
 
-static char* getFonts (const char* pCommand)
+static char* getFonts (const char* pCommand, const bool 
bBloatWithRepeatedSizes)
 {
 SfxObjectShell* pDocSh = SfxObjectShell::Current();
 if (!pDocSh)
@@ -6045,36 +6046,60 @@ static char* getFonts (const char* pCommand)
 pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
 const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr;
 
-boost::property_tree::ptree aTree;
-aTree.put("commandName", pCommand);
-boost::property_tree::ptree aValues;
-if ( pList )
+if (!bBloatWithRepeatedSizes)
 {
-sal_uInt16 nFontCount = pList->GetFontNameCount();
-for (sal_uInt16 i = 0; i < nFontCount; ++i)
+tools::JsonWriter aJson;
+aJson.put("commandName", pCommand);
+if (pList)
+{
+auto aFontNames = aJson.startArray("FontNames");
+
+sal_uInt16 nFontCount = pList->GetFontNameCount();
+for (sal_uInt16 i = 0; i < nFontCount; ++i)
+aJson.putSimpleValue(pList->GetFontName(i).GetFamilyName());
+}
 {
-boost::property_tree::ptree aChildren;
-const FontMetric& rFontMetric = pList->GetFontName(i);
+auto aFontSizes = aJson.startArray("FontSizes");
 const int* pAry = FontList::GetStdSizeAry();
-sal_uInt16 nSizeCount = 0;
-while (pAry[nSizeCount])
+for (sal_uInt16 i = 0; pAry[i]; ++i)
+
aJson.putSimpleValue(OUString::number(static_cast(pAry[i]) / 10));
+}
+
+return convertOString(aJson.finishAndGetAsOString());
+}
+else // FIXME: remove nonsensical legacy version
+{
+boost::property_tree::ptree aTree;
+aTree.put("commandName", pCommand);
+boost::property_tree::ptree aValues;
+if ( pList )
+{
+sal_uInt16 nFontCount = pList->GetFontNameCount();
+for (sal_uInt16 i = 0; i < nFontCount; ++i)
 {
-boost::property_tree::ptree aChild;
-aChild.put("", static_cast(pAry[nSizeCount]) / 10);
-aChildren.push_back(std::make_pair("", aChild));
-nSizeCount++;
+boost::property_tree::ptree aChildren;
+const FontMetric& rFontMetric = pList->GetFontName(i);
+const int* pAry = FontList::GetStdSizeAry();
+sal_uInt16 nSizeCount = 0;
+while (pAry[nSizeCount])
+{
+boost::property_tree::ptree aChild;
+aChild.put("", static_cast(pAry[nSizeCount]) / 10);
+aChildren.push_back(std::make_pair("", aChild));
+   

core.git: desktop/source

2024-05-23 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 9d1956031ed326e3d377800530993dcd2571f99a
Author: Michael Meeks 
AuthorDate: Fri May 17 17:49:32 2024 +0100
Commit: Michael Meeks 
CommitDate: Thu May 23 10:29:28 2024 +0200

lok: stop amazing waste of pretty-printed JSON sent over the API.

before:

INCOMING: commandvalues: {
"commandName": ".uno:CharFontName",
"commandValues": {
"Albany AMT": [
"6",
"7",
"8",
"9",
"10",
"10.5",
"11",
"12",



after:

INCOMING: commandvalues: {"commandName":".uno:CharFontName","commandValues":
{"Albany AMT":["6","7","8","9","10","10.5","11","12","13","14","15","16",
"18","20","21","22","24","26","28","32","36","40","42","44","48","54",
"60","66","72","80","88","96"],"Amiri":["6","7"



A 3x size saving.

Change-Id: I574b8bdf790078c61b7605137a47a531dee16f1e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167685
Reviewed-by: Michael Meeks 
Tested-by: Jenkins

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3b4b9f11a4d4..7730614d6a49 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -5969,7 +5969,7 @@ static char* getDocReadOnly(LibreOfficeKitDocument* pThis)
 aTree.put("success", pObjectShell->IsLoadReadonly());
 
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 if (!pJson)
 return nullptr;
@@ -6028,7 +6028,7 @@ static char* getLanguages(const char* pCommand)
 addLocale(aValues, rLocale);
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6069,7 +6069,7 @@ static char* getFonts (const char* pCommand)
 }
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6104,7 +6104,7 @@ static char* getFontSubset (std::string_view aFontName)
 
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6227,7 +6227,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, 
const char* pCommand)
 
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());


core.git: Branch 'distro/collabora/co-24.04' - desktop/qa desktop/source include/comphelper include/LibreOfficeKit ucb/source

2024-05-20 Thread Michael Meeks (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx  |5 +--
 desktop/source/lib/init.cxx  |   18 +++
 include/LibreOfficeKit/LibreOfficeKit.h  |3 +
 include/LibreOfficeKit/LibreOfficeKit.hxx|9 +
 include/comphelper/lok.hxx   |2 +
 ucb/source/ucp/webdav-curl/CurlSession.cxx   |   43 +++
 ucb/source/ucp/webdav-curl/SerfLockStore.cxx |   35 +++--
 ucb/source/ucp/webdav-curl/SerfLockStore.hxx |   12 ++-
 ucb/source/ucp/webdav-curl/ucpdav1.component |4 ++
 9 files changed, 117 insertions(+), 14 deletions(-)

New commits:
commit 66de5312607e93b985ca5934e851718453a24693
Author: Michael Meeks 
AuthorDate: Sat May 18 22:08:22 2024 +0100
Commit: Michael Meeks 
CommitDate: Mon May 20 16:43:00 2024 +0200

lok: join Webdav Ticker thread.

Add 'startThreads' lok method for the few thread scenarios where
we need to have a background thread running that cannot be started
opportunistically.

Also add that to the ThreadJoinable interface so we can get into
UNO components' implementations to handle their worker threads
easily.

Implement joining and re-starting in WebDAV ucp too.

Change-Id: I329ef9decb32b263197e4c03a0d54952985fdd0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167858
Reviewed-by: Michael Meeks 
Reviewed-by: Caolán McNamara 
Tested-by: Jenkins CollaboraOffice 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 298e5a5d7a9b..4a09b10931f6 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3594,11 +3594,12 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(18), offsetof(struct 
_LibreOfficeKitClass, startURP));
 CPPUNIT_ASSERT_EQUAL(classOffset(19), offsetof(struct 
_LibreOfficeKitClass, stopURP));
 CPPUNIT_ASSERT_EQUAL(classOffset(20), offsetof(struct 
_LibreOfficeKitClass, joinThreads));
-CPPUNIT_ASSERT_EQUAL(classOffset(21), offsetof(struct 
_LibreOfficeKitClass, setForkedChild));
+CPPUNIT_ASSERT_EQUAL(classOffset(21), offsetof(struct 
_LibreOfficeKitClass, startThreads));
+CPPUNIT_ASSERT_EQUAL(classOffset(22), offsetof(struct 
_LibreOfficeKitClass, setForkedChild));
 
 // When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
 // new function pointer and bump this assert for the size of the class.
-CPPUNIT_ASSERT_EQUAL(classOffset(22), sizeof(struct _LibreOfficeKitClass));
+CPPUNIT_ASSERT_EQUAL(classOffset(23), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f00edb9ec9c9..86f0efda8857 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2602,6 +2602,8 @@ static void lo_stopURP(LibreOfficeKit* pThis, void* 
pSendURPToLOContext);
 
 static int lo_joinThreads(LibreOfficeKit* pThis);
 
+static void lo_startThreads(LibreOfficeKit* pThis);
+
 static void lo_setForkedChild(LibreOfficeKit* pThis, bool bIsChild);
 
 static void lo_runLoop(LibreOfficeKit* pThis,
@@ -2649,6 +2651,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->startURP = lo_startURP;
 m_pOfficeClass->stopURP = lo_stopURP;
 m_pOfficeClass->joinThreads = lo_joinThreads;
+m_pOfficeClass->startThreads = lo_startThreads;
 m_pOfficeClass->setForkedChild = lo_setForkedChild;
 
 gOfficeClass = m_pOfficeClass;
@@ -3399,6 +3402,12 @@ static int lo_joinThreads(LibreOfficeKit* /* pThis */)
 if (joinable && !joinable->joinThreads())
 return 0;
 
+auto ucpWebdav = xContext->getServiceManager()->createInstanceWithContext(
+"com.sun.star.ucb.WebDAVManager", xContext);
+joinable = dynamic_cast(ucpWebdav.get());
+if (joinable && !joinable->joinThreads())
+return 0;
+
 // Ensure configmgr's write thread is down
 css::uno::Reference< css::util::XFlushable >(
 css::configuration::theDefaultProvider::get(
@@ -3408,6 +3417,15 @@ static int lo_joinThreads(LibreOfficeKit* /* pThis */)
 return 1;
 }
 
+static void lo_startThreads(LibreOfficeKit* /* pThis */)
+{
+auto ucpWebdav = xContext->getServiceManager()->createInstanceWithContext(
+"com.sun.star.ucb.WebDAVManager", xContext);
+auto joinable = dynamic_cast(ucpWebdav.get());
+if (joinable)
+joinable->startThreads();
+}
+
 static void lo_setForkedChild(LibreOfficeKit* /* pThis */, bool bIsChild)
 {
 comphelper::LibreOfficeKit::setForkedChild(bIsChild);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 

core.git: Branch 'distro/collabora/co-24.04' - desktop/source

2024-05-20 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit 84ede4db0482a5bdcdb3398483ec1a63f7167012
Author: Michael Meeks 
AuthorDate: Mon May 20 14:03:51 2024 +0100
Commit: Michael Meeks 
CommitDate: Mon May 20 15:39:12 2024 +0200

lok: joinThreads - take down configmgr's write-thread.

Change-Id: I1f9b6b88ef7e97da02fecf2035f953584cd28c16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167868
Reviewed-by: Caolán McNamara 
Reviewed-by: Michael Meeks 
Tested-by: Jenkins CollaboraOffice 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cb487d641ac8..f00edb9ec9c9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -112,6 +112,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -3397,6 +3399,12 @@ static int lo_joinThreads(LibreOfficeKit* /* pThis */)
 if (joinable && !joinable->joinThreads())
 return 0;
 
+// Ensure configmgr's write thread is down
+css::uno::Reference< css::util::XFlushable >(
+css::configuration::theDefaultProvider::get(
+comphelper::getProcessComponentContext()),
+css::uno::UNO_QUERY_THROW)->flush();
+
 return 1;
 }
 


core.git: Branch 'distro/collabora/co-24.04' - desktop/source

2024-05-18 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   78 +---
 1 file changed, 52 insertions(+), 26 deletions(-)

New commits:
commit 628f56a1802ad76cbe84a9a5590b04ed81a57a9e
Author: Michael Meeks 
AuthorDate: Fri May 17 21:25:29 2024 +0100
Commit: Noel Grandin 
CommitDate: Sat May 18 22:06:18 2024 +0200

lok: stop amazing waste of repeated font sizes in each font element.

These days all sensible fonts are scalable, so anything else is madness.

With the compact_fonts option we go from:

INCOMING: commandvalues: 
{"commandName":".uno:CharFontName","commandValues":
{"Albany 
AMT":["6","7","8","9","10","10.5","11","12","13","14","15","16",
"18","20","21","22","24","26","28","32","36","40","42","44","48","54",
"60","66","72","80","88","96"],"Amiri":["6","7"



INCOMING: commandvalues: { "commandName": ".uno:CharFontName", 
"FontNames":
[ "Albany AMT", "Amiri", "Amiri Quran", "Amiri Quran Colored", "Andale 
Mono",
"Andale Sans", "Andy MT", "AR PL UMing CN", "AR PL UMing HK", "AR PL 
UMing TW",
"AR PL UMing TW MBE", "Arial",

   

An 8x size win.

Change-Id: I3dc9f5de876def6e4afc09a43105b1740f7c621f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167799
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Noel Grandin 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9608c5374da7..cb487d641ac8 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -267,11 +267,12 @@ extern "C" {
 
 #endif
 
-
 using LanguageToolCfg = 
officecfg::Office::Linguistic::GrammarChecking::LanguageTool;
 
+
 static LibLibreOffice_Impl *gImpl = nullptr;
 static bool lok_preinit_2_called = false;
+static bool gUseCompactFonts = false;
 static std::weak_ptr< LibreOfficeKitClass > gOfficeClass;
 static std::weak_ptr< LibreOfficeKitDocumentClass > gDocumentClass;
 
@@ -6080,7 +6081,7 @@ static char* getLanguages(const char* pCommand)
 return pJson;
 }
 
-static char* getFonts (const char* pCommand)
+static char* getFonts (const char* pCommand, const bool 
bBloatWithRepeatedSizes)
 {
 SfxObjectShell* pDocSh = SfxObjectShell::Current();
 if (!pDocSh)
@@ -6089,36 +6090,59 @@ static char* getFonts (const char* pCommand)
 pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
 const FontList* pList = pFonts ? pFonts->GetFontList() : nullptr;
 
-boost::property_tree::ptree aTree;
-aTree.put("commandName", pCommand);
-boost::property_tree::ptree aValues;
-if ( pList )
+if (!bBloatWithRepeatedSizes)
 {
-sal_uInt16 nFontCount = pList->GetFontNameCount();
-for (sal_uInt16 i = 0; i < nFontCount; ++i)
+tools::JsonWriter aJson;
+aJson.put("commandName", pCommand);
+{
+auto aFontNames = aJson.startArray("FontNames");
+
+sal_uInt16 nFontCount = pList->GetFontNameCount();
+for (sal_uInt16 i = 0; i < nFontCount; ++i)
+aJson.putSimpleValue(pList->GetFontName(i).GetFamilyName());
+}
 {
-boost::property_tree::ptree aChildren;
-const FontMetric& rFontMetric = pList->GetFontName(i);
+auto aFontSizes = aJson.startArray("FontSizes");
 const int* pAry = FontList::GetStdSizeAry();
-sal_uInt16 nSizeCount = 0;
-while (pAry[nSizeCount])
+for (sal_uInt16 i = 0; pAry[i]; ++i)
+
aJson.putSimpleValue(OUString::number(static_cast(pAry[i]) / 10));
+}
+
+return convertOString(aJson.finishAndGetAsOString());
+}
+else // FIXME: remove nonsensical legacy version
+{
+boost::property_tree::ptree aTree;
+aTree.put("commandName", pCommand);
+boost::property_tree::ptree aValues;
+if ( pList )
+{
+sal_uInt16 nFontCount = pList->GetFontNameCount();
+for (sal_uInt16 i = 0; i < nFontCount; ++i)
 {
-boost::property_tree::ptree aChild;
-aChild.put("", static_cast(pAry[nSizeCount]) / 10);
-aChildren.push_back(std::make_pair("", aChild));
-nSizeCount++;
+boost::property_tree::ptree aChildren;
+const FontMetric& rFontMetric = pList->GetFontName(i);
+const int* pAry = FontList::GetStdSizeAry();
+sal_uInt16 nSizeCount = 0;
+while (pAry[nSizeCount])
+{
+boost::property_tree::ptree aChild;
+aChild.put("", static_cast(pAry[nSizeCount]) / 10);
+aChildren.push_back(std::make_pair("", aChild));
+nSizeCount++;
+}
+
aValues.add_child(rFontMetric.GetFamilyName().toUtf8().getStr(), aChildren);
 }
-

core.git: desktop/source include/sfx2 include/vcl sfx2/source vcl/source

2024-05-18 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx   |2 +-
 include/sfx2/viewsh.hxx   |1 +
 include/vcl/IDialogRenderable.hxx |3 +++
 include/vcl/svapp.hxx |2 +-
 sfx2/source/view/lokhelper.cxx|3 ++-
 sfx2/source/view/viewsh.cxx   |   23 +++
 vcl/source/app/svapp.cxx  |   16 
 7 files changed, 47 insertions(+), 3 deletions(-)

New commits:
commit e2aab0d02e7be66881f2ac0f08b6ac5007f65648
Author: Michael Meeks 
AuthorDate: Thu May 16 19:35:51 2024 +0100
Commit: Michael Meeks 
CommitDate: Sat May 18 12:34:59 2024 +0200

lok: dump more SfxViewShell state, and LOK notifier state on Windows.

This should help to associate the right view-ids, with the right
windows, and help to catch any stray / lingering windows from closed
sessions - hopefully.

Change-Id: I197a3280d5d2aeddd356ee037c51e4887f43278b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167765
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins CollaboraOffice 
(cherry picked from commit 8d979fae0c435b820302c76fcfdc2642b4820360)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167684
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2ab701cae3d2..3b4b9f11a4d4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1637,7 +1637,7 @@ void 
CallbackFlushHandler::libreOfficeKitViewUpdatedCallbackPerViewId(int nType,
 void CallbackFlushHandler::dumpState(rtl::OStringBuffer )
 {
 // NB. no locking
-rState.append("
View:   ");
+rState.append("
View:   ");
 rState.append(static_cast(m_viewId));
 rState.append("
DisableCallbacks:   ");
 rState.append(static_cast(m_nDisableCallbacks));
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index b7461b160af1..71380213b9c9 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -274,6 +274,7 @@ public:
 
 // ILibreOfficeKitNotifier
 virtual voidnotifyWindow(vcl::LOKWindowId nLOKWindowId, 
const OUString& rAction, const std::vector& rPayload = 
std::vector()) const override;
+virtual OString dumpNotifyState() const override;
 
 // Focus, KeyInput, Cursor
 virtual voidShowCursor( bool bOn = true );
diff --git a/include/vcl/IDialogRenderable.hxx 
b/include/vcl/IDialogRenderable.hxx
index 386ed1e865c8..d92eb88ed25c 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -41,6 +41,9 @@ public:
 
 /// Emits a LOK_CALLBACK_INVALIDATE_TILES.
 virtual void notifyInvalidation(tools::Rectangle const *) const = 0;
+
+/// Debugging
+virtual OString dumpNotifyState() const = 0;
 };
 
 } // namespace vcl
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index d5f1739be1ae..2725642763c0 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1326,7 +1326,7 @@ public:
   const std::vector& rPayload 
= std::vector()) const override;
 virtual void libreOfficeKitViewCallback(int nType, const OString& 
pPayload) const override;
 virtual void notifyInvalidation(tools::Rectangle const *) const override;
-
+virtual OString dumpNotifyState() const override;
 
 private:
 DECL_DLLPRIVATE_STATIC_LINK( Application, PostEventHandler, void*, void );
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 756fda428273..549f43906908 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -735,7 +735,8 @@ void 
SfxLokHelper::notifyPartSizeChangedAllViews(vcl::ITiledRenderable* pDoc, in
 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
 while (pViewShell)
 {
-if (pViewShell->getPart() == nPart)
+if (// FIXME should really filter on pViewShell->GetDocId() too
+pViewShell->getPart() == nPart)
 SfxLokHelper::notifyDocumentSizeChanged(pViewShell, ""_ostr, pDoc, 
false);
 pViewShell = SfxViewShell::GetNext(*pViewShell);
 }
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index df122f41054f..b5f010e9b0be 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -3173,6 +3173,20 @@ SfxLokCallbackInterface* 
SfxViewShell::getLibreOfficeKitViewCallback() const
 
 void SfxViewShell::dumpLibreOfficeKitViewState(rtl::OStringBuffer )
 {
+rState.append("
SfxViewShell: ");
+rState.append(OString::number(reinterpret_cast(this), 16));
+rState.append("
DocId:  ");
+auto nDocId = static_cast(GetDocId());
+rState.append(static_cast(nDocId));
+rState.append("
ViewId: ");
+rState.append(static_cast(GetViewShellId()));
+rState.append("
Part:   ");
+rState.append(static_cast(getPart()));
+rState.append("
Lang:   ");
+

core.git: Branch 'distro/collabora/co-23.05' - desktop/source

2024-05-17 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit eb08961598c52ad236980023149a0907f23525d7
Author: Michael Meeks 
AuthorDate: Fri May 17 17:49:32 2024 +0100
Commit: Noel Grandin 
CommitDate: Fri May 17 20:42:58 2024 +0200

lok: stop amazing waste of pretty-printed JSON sent over the API.

before:

INCOMING: commandvalues: {
"commandName": ".uno:CharFontName",
"commandValues": {
"Albany AMT": [
"6",
"7",
"8",
"9",
"10",
"10.5",
"11",
"12",



after:

INCOMING: commandvalues: {"commandName":".uno:CharFontName","commandValues":
{"Albany AMT":["6","7","8","9","10","10.5","11","12","13","14","15","16",
"18","20","21","22","24","26","28","32","36","40","42","44","48","54",
"60","66","72","80","88","96"],"Amiri":["6","7"



A 3x size saving.

Change-Id: I574b8bdf790078c61b7605137a47a531dee16f1e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167686
Reviewed-by: Noel Grandin 
Tested-by: Jenkins CollaboraOffice 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 81366621ec15..dec02b7c3103 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -5959,7 +5959,7 @@ static char* getDocReadOnly(LibreOfficeKitDocument* pThis)
 aTree.put("success", pObjectShell->IsLoadReadonly());
 
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 if (!pJson)
 return nullptr;
@@ -6006,7 +6006,7 @@ static char* getLanguages(const char* pCommand)
 addLocale(aValues, rLocale);
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6047,7 +6047,7 @@ static char* getFonts (const char* pCommand)
 }
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6082,7 +6082,7 @@ static char* getFontSubset (std::string_view aFontName)
 
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6205,7 +6205,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, 
const char* pCommand)
 
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());


core.git: Branch 'distro/collabora/co-24.04' - desktop/source

2024-05-17 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 457f24c004590a28d200fdda79bf468d363fff69
Author: Michael Meeks 
AuthorDate: Fri May 17 17:49:32 2024 +0100
Commit: Noel Grandin 
CommitDate: Fri May 17 20:42:26 2024 +0200

lok: stop amazing waste of pretty-printed JSON sent over the API.

before:

INCOMING: commandvalues: {
"commandName": ".uno:CharFontName",
"commandValues": {
"Albany AMT": [
"6",
"7",
"8",
"9",
"10",
"10.5",
"11",
"12",



after:

INCOMING: commandvalues: {"commandName":".uno:CharFontName","commandValues":
{"Albany AMT":["6","7","8","9","10","10.5","11","12","13","14","15","16",
"18","20","21","22","24","26","28","32","36","40","42","44","48","54",
"60","66","72","80","88","96"],"Amiri":["6","7"



A 3x size saving.

Change-Id: I574b8bdf790078c61b7605137a47a531dee16f1e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167789
Reviewed-by: Noel Grandin 
Tested-by: Jenkins CollaboraOffice 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 298d15b4ddf6..9608c5374da7 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -6013,7 +6013,7 @@ static char* getDocReadOnly(LibreOfficeKitDocument* pThis)
 aTree.put("success", pObjectShell->IsLoadReadonly());
 
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 if (!pJson)
 return nullptr;
@@ -6072,7 +6072,7 @@ static char* getLanguages(const char* pCommand)
 addLocale(aValues, rLocale);
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6113,7 +6113,7 @@ static char* getFonts (const char* pCommand)
 }
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6148,7 +6148,7 @@ static char* getFontSubset (std::string_view aFontName)
 
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());
@@ -6271,7 +6271,7 @@ static char* getStyles(LibreOfficeKitDocument* pThis, 
const char* pCommand)
 
 aTree.add_child("commandValues", aValues);
 std::stringstream aStream;
-boost::property_tree::write_json(aStream, aTree);
+boost::property_tree::write_json(aStream, aTree, false /* pretty */);
 char* pJson = static_cast(malloc(aStream.str().size() + 1));
 assert(pJson); // Don't handle OOM conditions
 strcpy(pJson, aStream.str().c_str());


core.git: Branch 'distro/collabora/co-24.04' - desktop/source include/sfx2 include/vcl sfx2/source vcl/source

2024-05-17 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx   |2 +-
 include/sfx2/viewsh.hxx   |1 +
 include/vcl/IDialogRenderable.hxx |3 +++
 include/vcl/svapp.hxx |2 +-
 sfx2/source/view/lokhelper.cxx|3 ++-
 sfx2/source/view/viewsh.cxx   |   23 +++
 vcl/source/app/svapp.cxx  |   16 
 7 files changed, 47 insertions(+), 3 deletions(-)

New commits:
commit 8d979fae0c435b820302c76fcfdc2642b4820360
Author: Michael Meeks 
AuthorDate: Thu May 16 19:35:51 2024 +0100
Commit: Michael Meeks 
CommitDate: Fri May 17 17:41:40 2024 +0200

lok: dump more SfxViewShell state, and LOK notifier state on Windows.

This should help to associate the right view-ids, with the right
windows, and help to catch any stray / lingering windows from closed
sessions - hopefully.

Change-Id: I197a3280d5d2aeddd356ee037c51e4887f43278b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167765
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins CollaboraOffice 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a61eb3ff0879..298d15b4ddf6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1660,7 +1660,7 @@ void 
CallbackFlushHandler::libreOfficeKitViewUpdatedCallbackPerViewId(int nType,
 void CallbackFlushHandler::dumpState(rtl::OStringBuffer )
 {
 // NB. no locking
-rState.append("
View:   ");
+rState.append("
View:   ");
 rState.append(static_cast(m_viewId));
 rState.append("
DisableCallbacks:   ");
 rState.append(static_cast(m_nDisableCallbacks));
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index e68f556c1072..d098d76d0031 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -274,6 +274,7 @@ public:
 
 // ILibreOfficeKitNotifier
 virtual voidnotifyWindow(vcl::LOKWindowId nLOKWindowId, 
const OUString& rAction, const std::vector& rPayload = 
std::vector()) const override;
+virtual OString dumpNotifyState() const override;
 
 // Focus, KeyInput, Cursor
 virtual voidShowCursor( bool bOn = true );
diff --git a/include/vcl/IDialogRenderable.hxx 
b/include/vcl/IDialogRenderable.hxx
index 49e22c3c5357..11a7adfb0f27 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -42,6 +42,9 @@ public:
 
 /// Emits a LOK_CALLBACK_INVALIDATE_TILES.
 virtual void notifyInvalidation(tools::Rectangle const *) const = 0;
+
+/// Debugging
+virtual OString dumpNotifyState() const = 0;
 };
 
 } // namespace vcl
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index 36d7eeb1fc06..be1e80090576 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1326,7 +1326,7 @@ public:
   const std::vector& rPayload 
= std::vector()) const override;
 virtual void libreOfficeKitViewCallback(int nType, const OString& 
pPayload) const override;
 virtual void notifyInvalidation(tools::Rectangle const *) const override;
-
+virtual OString dumpNotifyState() const override;
 
 private:
 DECL_DLLPRIVATE_STATIC_LINK( Application, PostEventHandler, void*, void );
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 8df19c359442..99f39fbf4e8b 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -733,7 +733,8 @@ void 
SfxLokHelper::notifyPartSizeChangedAllViews(vcl::ITiledRenderable* pDoc, in
 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
 while (pViewShell)
 {
-if (pViewShell->getPart() == nPart)
+if (// FIXME should really filter on pViewShell->GetDocId() too
+pViewShell->getPart() == nPart)
 SfxLokHelper::notifyDocumentSizeChanged(pViewShell, ""_ostr, pDoc, 
false);
 pViewShell = SfxViewShell::GetNext(*pViewShell);
 }
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 75731ecf1ccd..0b6c07c68d5c 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -3181,6 +3181,20 @@ SfxLokCallbackInterface* 
SfxViewShell::getLibreOfficeKitViewCallback() const
 
 void SfxViewShell::dumpLibreOfficeKitViewState(rtl::OStringBuffer )
 {
+rState.append("
SfxViewShell: ");
+rState.append(OString::number(reinterpret_cast(this), 16));
+rState.append("
DocId:  ");
+auto nDocId = static_cast(GetDocId());
+rState.append(static_cast(nDocId));
+rState.append("
ViewId: ");
+rState.append(static_cast(GetViewShellId()));
+rState.append("
Part:   ");
+rState.append(static_cast(getPart()));
+rState.append("
Lang:   ");
+rState.append(OUStringToOString(GetLOKLanguageTag().getBcp47(), 
RTL_TEXTENCODING_UTF8));
+rState.append("
A11y:   ");
+rState.append(GetLOKAccessibilityState() ? "enabled" : "disabled");
+
 if 

core.git: desktop/source sfx2/source

2024-05-15 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |5 +
 sfx2/source/doc/objmisc.cxx |   11 ++-
 2 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 113dabb58dcab72ad17d5c2ab21a86e6825d90dc
Author: Michael Meeks 
AuthorDate: Tue May 14 16:13:43 2024 +0100
Commit: Michael Meeks 
CommitDate: Wed May 15 18:16:00 2024 +0200

lok: get faster ModifiedStatus from the core.

Gives a more responsive UI, closes a number of races, and helps us
to make better decisions, more quickly on whether to save.

Change-Id: I6e2548f06f715ba56ba75fd746273bdd57dc20dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167635
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 44e79f02241fbc213462df03a37b621cb72f9d05)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167469
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 635bca3b5de9..549319a7946c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -5112,6 +5112,11 @@ void LibLibreOffice_Impl::dumpState(rtl::OStringBuffer 
)
 rState.append(static_cast(mOptionalFeatures), 16);
 rState.append("
CallbackData:   0x");
 rState.append(reinterpret_cast(mpCallback), 16);
+rState.append("
IsModified: ");
+if (SfxObjectShell::Current())
+rState.append(SfxObjectShell::Current()->IsModified() ? "modified" : 
"unmodified");
+else
+rState.append("noshell");
 // TODO: dump mInteractionMap
 SfxLokHelper::dumpState(rState);
 vcl::lok::dumpState(rState);
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index c1d19b268adb..6d60e683770a 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -51,6 +51,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -102,6 +103,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "objstor.hxx"
@@ -324,7 +326,6 @@ void SfxObjectShell::ModifyChanged()
 // SetModified dispose of the models!
 return;
 
-
 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
 if ( pViewFrame )
 pViewFrame->GetBindings().Invalidate( SID_SAVEDOCS );
@@ -334,6 +335,14 @@ void SfxObjectShell::ModifyChanged()
 Broadcast( SfxHint( SfxHintId::TitleChanged ) );// xmlsec05, signed 
state might change in title...
 
 SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::ModifyChanged, 
GlobalEventConfig::GetEventName(GlobalEventId::MODIFYCHANGED), this ) );
+
+// Don't wait to get this important state via binding notification timeout.
+if ( comphelper::LibreOfficeKit::isActive() )
+{
+OString aStatus = ".uno:ModifiedStatus="_ostr;
+aStatus += IsModified() ? "true" : "false";
+SfxLokHelper::notifyAllViews(LOK_CALLBACK_STATE_CHANGED, aStatus);
+}
 }
 
 


core.git: external/nss

2024-05-15 Thread Michael Meeks (via logerrit)
 external/nss/UnpackedTarball_nss.mk |2 
 external/nss/nss.getrandom.patch|   97 
 2 files changed, 99 insertions(+)

New commits:
commit 06f1787d50fd6dd510917e53f4842d88725b32d1
Author: Michael Meeks 
AuthorDate: Fri Apr 5 15:23:22 2024 +0100
Commit: Michael Meeks 
CommitDate: Wed May 15 14:37:19 2024 +0200

lok: use of lok random hook in NSS.

This allows us to avoid opening /dev/urandom which may not be there.

Change-Id: I51727fe4a2a28be802afdf6d9ccca5a198167b7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165851
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 708663da401e1cc5c4531c8cbb3370c4cf2843d6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167670
Reviewed-by: Michael Meeks 
Tested-by: Jenkins

diff --git a/external/nss/UnpackedTarball_nss.mk 
b/external/nss/UnpackedTarball_nss.mk
index bf2a93233e60..6b69dd9b1631 100644
--- a/external/nss/UnpackedTarball_nss.mk
+++ b/external/nss/UnpackedTarball_nss.mk
@@ -26,6 +26,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,nss,\
 external/nss/macos-dlopen.patch.0 \
 external/nss/nss-restore-manual-pre-dependencies.patch.1 \
 external/nss/Wincompatible-function-pointer-types.patch.0 \
+$(if $(filter LINUX,$(OS)), \
+external/nss/nss.getrandom.patch) \
 $(if $(filter iOS,$(OS)), \
 external/nss/nss-ios.patch) \
 $(if $(filter ANDROID,$(OS)), \
diff --git a/external/nss/nss.getrandom.patch b/external/nss/nss.getrandom.patch
new file mode 100644
index ..b7f883b64d5a
--- /dev/null
+++ b/external/nss/nss.getrandom.patch
@@ -0,0 +1,97 @@
+--- a/nss/nspr/pr/src/md/unix/uxrng.c
 b/nss/nspr/pr/src/md/unix/uxrng.c
+@@ -68,13 +68,18 @@
+ #include 
+ #include 
+ #include 
++#include 
+ 
+ static int  fdDevURandom;
+ static PRCallOnceType coOpenDevURandom;
+ 
+ static PRStatus OpenDevURandom( void )
+ {
+-fdDevURandom = open( "/dev/urandom", O_RDONLY );
++static int (*lok_open_urandom)();
++if (!lok_open_urandom)
++  lok_open_urandom = dlsym(RTLD_DEFAULT, "lok_open_urandom");
++if (!lok_open_urandom || (fdDevURandom = lok_open_urandom()) < 0)
++  fdDevURandom = open( "/dev/urandom", O_RDONLY );
+ return((-1 == fdDevURandom)? PR_FAILURE : PR_SUCCESS );
+ } /* end OpenDevURandom() */
+ 
+--- a/nss/nss/lib/freebl/unix_rand.c
 b/nss/nss/lib/freebl/unix_rand.c
+@@ -13,6 +13,7 @@
+ #include 
+ #include 
+ #include 
++#include 
+ #include 
+ #include "secrng.h"
+ #include "secerr.h"
+@@ -650,11 +651,21 @@
+ RNG_RandomUpdate(buf, strlen(buf));
+ }
+ 
++{
++unsigned char buffer[SYSTEM_RNG_SEED_COUNT];
++bytes = RNG_SystemRNG(buffer, sizeof (buffer));
++if (bytes == SYSTEM_RNG_SEED_COUNT) /* success */
++ RNG_RandomUpdate(buffer, bytes);
++}
++
++if (bytes != SYSTEM_RNG_SEED_COUNT) /* fail */
++{
+ /* grab some data from system's PRNG before any other files. */
+ bytes = RNG_FileUpdate("/dev/urandom", SYSTEM_RNG_SEED_COUNT);
+ if (!bytes) {
+ PORT_SetError(SEC_ERROR_NEED_RANDOM);
+ }
++}
+ 
+ /* If the user points us to a random file, pass it through the rng */
+ randfile = PR_GetEnvSecure("NSRANDFILE");
+@@ -781,11 +794,19 @@
+ size_t fileBytes = 0;
+ unsigned char *buffer = dest;
+ 
++static int (*lok_open_urandom)();
++if (!lok_open_urandom)
++  lok_open_urandom = dlsym(NULL, "lok_open_urandom");
++if (!lok_open_urandom || (fd = lok_open_urandom()) < 0)
++{
+ file = fopen("/dev/urandom", "r");
+ if (file == NULL) {
+ PORT_SetError(SEC_ERROR_NEED_RANDOM);
+ return 0;
+ }
++}
++else
++  file = fdopen(fd, "r");
+ /* Read from the underlying file descriptor directly to bypass stdio
+  * buffering and avoid reading more bytes than we need from /dev/urandom.
+  * NOTE: we can't use fread with unbuffered I/O because fread may return
+--- a/nss/nss/lib/freebl/unix_urandom.c
 b/nss/nss/lib/freebl/unix_urandom.c
+@@ -5,6 +5,7 @@
+ #include 
+ #include 
+ #include 
++#include 
+ #include "secerr.h"
+ #include "secrng.h"
+ #include "prprf.h"
+@@ -62,7 +63,11 @@
+  * Reset the number of bytes to get and fall back to /dev/urandom. */
+ fileBytes = 0;
+ #endif
+-fd = open("/dev/urandom", O_RDONLY);
++static int (*lok_open_urandom)();
++if (!lok_open_urandom)
++  lok_open_urandom = dlsym(NULL, "lok_open_urandom");
++if (!lok_open_urandom || (fd = lok_open_urandom()) < 0)
++fd = open("/dev/urandom", O_RDONLY);
+ if (fd < 0) {
+ PORT_SetError(SEC_ERROR_NEED_RANDOM);
+ return 0;


core.git: Branch 'distro/collabora/co-24.04' - desktop/source sfx2/source

2024-05-14 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |5 +
 sfx2/source/doc/objmisc.cxx |   11 ++-
 2 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 44e79f02241fbc213462df03a37b621cb72f9d05
Author: Michael Meeks 
AuthorDate: Tue May 14 16:13:43 2024 +0100
Commit: Caolán McNamara 
CommitDate: Tue May 14 21:01:06 2024 +0200

lok: get faster ModifiedStatus from the core.

Gives a more responsive UI, closes a number of races, and helps us
to make better decisions, more quickly on whether to save.

Change-Id: I6e2548f06f715ba56ba75fd746273bdd57dc20dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167635
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 3ae89cf84ba1..8edd138cc907 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -5160,6 +5160,11 @@ void LibLibreOffice_Impl::dumpState(rtl::OStringBuffer 
)
 rState.append(static_cast(mOptionalFeatures), 16);
 rState.append("
CallbackData:   0x");
 rState.append(reinterpret_cast(mpCallback), 16);
+rState.append("
IsModified: ");
+if (SfxObjectShell::Current())
+rState.append(SfxObjectShell::Current()->IsModified() ? "modified" : 
"unmodified");
+else
+rState.append("noshell");
 // TODO: dump mInteractionMap
 SfxLokHelper::dumpState(rState);
 vcl::lok::dumpState(rState);
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index e5a69d717657..ef7eed6b90fc 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -51,6 +51,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -102,6 +103,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "objstor.hxx"
@@ -325,7 +327,6 @@ void SfxObjectShell::ModifyChanged()
 // SetModified dispose of the models!
 return;
 
-
 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
 if ( pViewFrame )
 pViewFrame->GetBindings().Invalidate( SID_SAVEDOCS );
@@ -335,6 +336,14 @@ void SfxObjectShell::ModifyChanged()
 Broadcast( SfxHint( SfxHintId::TitleChanged ) );// xmlsec05, signed 
state might change in title...
 
 SfxGetpApp()->NotifyEvent( SfxEventHint( SfxEventHintId::ModifyChanged, 
GlobalEventConfig::GetEventName(GlobalEventId::MODIFYCHANGED), this ) );
+
+// Don't wait to get this important state via binding notification timeout.
+if ( comphelper::LibreOfficeKit::isActive() )
+{
+OString aStatus = ".uno:ModifiedStatus="_ostr;
+aStatus += IsModified() ? "true" : "false";
+SfxLokHelper::notifyAllViews(LOK_CALLBACK_STATE_CHANGED, aStatus);
+}
 }
 
 


core.git: Branch 'distro/collabora/co-24.04' - external/nss sal/osl

2024-05-11 Thread Michael Meeks (via logerrit)
 external/nss/UnpackedTarball_nss.mk |1 +
 external/nss/nss.disablefsync.patch |   18 ++
 sal/osl/unx/file.cxx|6 +-
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 90bd45d7a96c8c7084db13e4b6f86753db67655a
Author: Michael Meeks 
AuthorDate: Fri May 10 17:47:19 2024 +0100
Commit: Caolán McNamara 
CommitDate: Sat May 11 20:07:19 2024 +0200

lok: add SAL_DISABLE_FSYNC environment to disable fsync.

For state-less containers there is no benefit in fsync'ing,
file data is safe when it is up-loaded back to storage - but
profiling shows latency from stray fsyncs.

Change-Id: I9f03d5866dec05e5507deb56b0dca93b6876225e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167490
Tested-by: Michael Meeks 
Reviewed-by: Caolán McNamara 

diff --git a/external/nss/UnpackedTarball_nss.mk 
b/external/nss/UnpackedTarball_nss.mk
index 6b69dd9b1631..7a9010bdf743 100644
--- a/external/nss/UnpackedTarball_nss.mk
+++ b/external/nss/UnpackedTarball_nss.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,nss,\
 external/nss/nss-restore-manual-pre-dependencies.patch.1 \
 external/nss/Wincompatible-function-pointer-types.patch.0 \
 $(if $(filter LINUX,$(OS)), \
+external/nss/nss.disablefsync.patch \
 external/nss/nss.getrandom.patch) \
 $(if $(filter iOS,$(OS)), \
 external/nss/nss-ios.patch) \
diff --git a/external/nss/nss.disablefsync.patch 
b/external/nss/nss.disablefsync.patch
new file mode 100644
index ..8c5d84b553ce
--- /dev/null
+++ b/external/nss/nss.disablefsync.patch
@@ -0,0 +1,18 @@
+--- a/nss/nss/lib/sqlite/sqlite3.c
 b/nss/nss/lib/sqlite/sqlite3.c
+@@ -36136,6 +36136,15 @@
+ static int full_fsync(int fd, int fullSync, int dataOnly){
+   int rc;
+ 
++  static int disabledKnown = 0, disabled = 0;
++  if (!disabledKnown)
++  {
++disabled = getenv("SAL_DISABLE_FSYNC") != NULL;
++disabledKnown = 1;
++  }
++  if (disabled)
++return 0;
++
+   /* The following "ifdef/elif/else/" block has the same structure as
+   ** the one below. It is replicated here solely to avoid cluttering 
+   ** up the real code with the UNUSED_PARAMETER() macros.
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 912d61a50614..a82a0bcf7f71 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -1387,7 +1387,11 @@ oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle)
 if (result != osl_File_E_None)
 return result;
 
-if (fsync(pImpl->m_fd) == -1)
+static bool disabled = getenv("SAL_DISABLE_FSYNC") != nullptr;
+
+if (disabled)
+SAL_INFO("sal.file", "fsync(" << pImpl->m_fd << "): Disabled");
+else if (fsync(pImpl->m_fd) == -1)
 {
 int e = errno;
 SAL_INFO("sal.file", "fsync(" << pImpl->m_fd << "): " << 
UnixErrnoString(e));


core.git: Branch 'distro/collabora/co-24.04' - vcl/source

2024-05-11 Thread Michael Meeks (via logerrit)
 vcl/source/app/svapp.cxx |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 7b61926fd6704dd244682a965c17e7141ffc1fc5
Author: Michael Meeks 
AuthorDate: Fri May 10 17:13:55 2024 +0100
Commit: Noel Grandin 
CommitDate: Sat May 11 14:51:38 2024 +0200

lok: dumpState should truncate very long JSON messages.

Otherwise we get huge dumps which can overwhelm our logging and hide
more useful information, and/or the journal can drop them on the ground.

Change-Id: Ie942c70a90a6df60ccd8986444362d622c213e15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167488
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Noel Grandin 

diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 79b8f5873df8..34b2774995f1 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1758,11 +1758,17 @@ void dumpState(rtl::OStringBuffer )
 vcl::Window *pWin = Application::GetFirstTopLevelWindow();
 while (pWin)
 {
-tools::JsonWriter props;
-pWin->DumpAsPropertyTree(props);
+tools::JsonWriter aProps;
+pWin->DumpAsPropertyTree(aProps);
 
 rState.append("
Window: ");
-rState.append(props.finishAndGetAsOString());
+OString aPropStr = aProps.finishAndGetAsOString();
+if (aPropStr.getLength() > 256)
+{
+rState.append(aPropStr.subView(0, 256));
+rState.append("...");
+} else
+rState.append(aPropStr);
 
 pWin = Application::GetNextTopLevelWindow( pWin );
 }


core.git: vcl/source

2024-05-11 Thread Michael Meeks (via logerrit)
 vcl/source/window/window.cxx |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit fbfeb33b38cc0a644c0315448f6a2d8637a0007e
Author: Michael Meeks 
AuthorDate: Fri May 10 20:29:32 2024 +0100
Commit: Caolán McNamara 
CommitDate: Sat May 11 14:27:33 2024 +0200

lok: Don't dump empty aria properties in every JSON element.

They simply bloat the json to no benefit if the properties are
empty, avoid serializing empty values.

Change-Id: I83c780d01820ec39acc85899d45ad9e929ad7e76
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167496
Reviewed-by: Marco Cecchetti 
Tested-by: Michael Meeks 
(cherry picked from commit 24876e5611abbaec9b2fe5fcbcf4be71a10ee366)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167457
Reviewed-by: Caolán McNamara 
Tested-by: Jenkins

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index b7f0ea58181b..3cb43a8a4a05 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3410,13 +3410,17 @@ void Window::DumpAsPropertyTree(tools::JsonWriter& 
rJsonWriter)
 
 if(!pAccLabelFor && !pAccLabelledBy)
 {
-auto aAria = rJsonWriter.startNode("aria");
+OUString sAccName = GetAccessibleName();
+OUString sAccDesc = GetAccessibleDescription();
 
-OUString sAccString = GetAccessibleName();
-rJsonWriter.put("label", sAccString);
-
-sAccString = GetAccessibleDescription();
-rJsonWriter.put("description", sAccString);
+if (!sAccName.isEmpty() || !sAccDesc.isEmpty())
+{
+auto aAria = rJsonWriter.startNode("aria");
+if (!sAccName.isEmpty())
+rJsonWriter.put("label", sAccName);
+if (!sAccDesc.isEmpty())
+rJsonWriter.put("description", sAccDesc);
+}
 }
 
 mpWindowImpl->maDumpAsPropertyTreeHdl.Call(rJsonWriter);


core.git: Branch 'distro/collabora/co-24.04' - vcl/source

2024-05-11 Thread Michael Meeks (via logerrit)
 vcl/source/window/window.cxx |   16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit 24876e5611abbaec9b2fe5fcbcf4be71a10ee366
Author: Michael Meeks 
AuthorDate: Fri May 10 20:29:32 2024 +0100
Commit: Michael Meeks 
CommitDate: Sat May 11 11:30:41 2024 +0200

lok: Don't dump empty aria properties in every JSON element.

They simply bloat the json to no benefit if the properties are
empty, avoid serializing empty values.

Change-Id: I83c780d01820ec39acc85899d45ad9e929ad7e76
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167496
Reviewed-by: Marco Cecchetti 
Tested-by: Michael Meeks 

diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index b3585c8d80bf..11386eaa74c9 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3404,13 +3404,17 @@ void Window::DumpAsPropertyTree(tools::JsonWriter& 
rJsonWriter)
 
 if(!pAccLabelFor && !pAccLabelledBy)
 {
-auto aAria = rJsonWriter.startNode("aria");
+OUString sAccName = GetAccessibleName();
+OUString sAccDesc = GetAccessibleDescription();
 
-OUString sAccString = GetAccessibleName();
-rJsonWriter.put("label", sAccString);
-
-sAccString = GetAccessibleDescription();
-rJsonWriter.put("description", sAccString);
+if (!sAccName.isEmpty() || !sAccDesc.isEmpty())
+{
+auto aAria = rJsonWriter.startNode("aria");
+if (!sAccName.isEmpty())
+rJsonWriter.put("label", sAccName);
+if (!sAccDesc.isEmpty())
+rJsonWriter.put("description", sAccDesc);
+}
 }
 
 mpWindowImpl->maDumpAsPropertyTreeHdl.Call(rJsonWriter);


core.git: vcl/source

2024-05-10 Thread Michael Meeks (via logerrit)
 vcl/source/app/svapp.cxx |   12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit b1c77f927aced5eeaebd5c17c30efdc1df74c4f9
Author: Michael Meeks 
AuthorDate: Fri May 10 17:13:55 2024 +0100
Commit: Michael Meeks 
CommitDate: Fri May 10 21:25:15 2024 +0200

lok: dumpState should truncate very long JSON messages.

Otherwise we get huge dumps which can overwhelm our logging and hide
more useful information, and/or the journal can drop them on the ground.

Change-Id: Ie942c70a90a6df60ccd8986444362d622c213e15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167456
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 8bfcb5e03d66..b3a63cd05a46 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1750,11 +1750,17 @@ void dumpState(rtl::OStringBuffer )
 vcl::Window *pWin = Application::GetFirstTopLevelWindow();
 while (pWin)
 {
-tools::JsonWriter props;
-pWin->DumpAsPropertyTree(props);
+tools::JsonWriter aProps;
+pWin->DumpAsPropertyTree(aProps);
 
 rState.append("
Window: ");
-rState.append(props.finishAndGetAsOString());
+OString aPropStr = aProps.finishAndGetAsOString();
+if (aPropStr.getLength() > 256)
+{
+rState.append(aPropStr.subView(0, 256));
+rState.append("...");
+} else
+rState.append(aPropStr);
 
 pWin = Application::GetNextTopLevelWindow( pWin );
 }


core.git: comphelper/source desktop/source include/comphelper

2024-05-07 Thread Michael Meeks (via logerrit)
 comphelper/source/misc/random.cxx |   34 ++
 desktop/source/lib/init.cxx   |4 
 include/comphelper/random.hxx |2 ++
 3 files changed, 24 insertions(+), 16 deletions(-)

New commits:
commit a2605a66fdb8ab18018f3a0f8e49043e73854986
Author: Michael Meeks 
AuthorDate: Fri May 3 14:17:27 2024 +0100
Commit: Michael Meeks 
CommitDate: Tue May 7 09:51:13 2024 +0200

lok: reseed comphelper's random number generator on fork.

Also avoid std::random_device it doesn't work in a COOL
kit process.

Change-Id: Ie2d063611a73e734afd92d6fd779f34a2f316230
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167070
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/comphelper/source/misc/random.cxx 
b/comphelper/source/misc/random.cxx
index 96d466641dfb..058eb99813eb 100644
--- a/comphelper/source/misc/random.cxx
+++ b/comphelper/source/misc/random.cxx
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #if defined HAVE_VALGRIND_HEADERS
 #include 
@@ -40,7 +41,9 @@ struct RandomNumberGenerator
 {
 std::mutex mutex;
 STD_RNG_ALGO global_rng;
-RandomNumberGenerator()
+RandomNumberGenerator() { reseed(); }
+
+void reseed()
 {
 // make RR easier to use, breaks easily without the RNG being 
repeatable
 bool bRepeatable = (getenv("SAL_RAND_REPEATABLE") != nullptr) || 
(getenv("RR") != nullptr);
@@ -56,21 +59,18 @@ struct RandomNumberGenerator
 return;
 }
 
-try
-{
-std::random_device rd;
-// initialises the state of the global random number generator
-// should only be called once.
-// (note, a few std::variate_generator<> (like normal) have their
-// own state which would need a reset as well to guarantee 
identical
-// sequence of numbers, e.g. via myrand.distribution().reset())
-global_rng.seed(rd() ^ time(nullptr));
-}
-catch (std::runtime_error& e)
-{
-SAL_WARN("comphelper", "Using std::random_device failed: " << 
e.what());
-global_rng.seed(time(nullptr));
-}
+size_t seed = 0;
+rtlRandomPool aRandomPool = rtl_random_createPool();
+if (rtl_random_getBytes(aRandomPool, , sizeof(seed)) != 
rtl_Random_E_None)
+seed = 0;
+rtl_random_destroyPool(aRandomPool);
+
+// initialises the state of the global random number generator
+// should only be called once.
+// (note, a few std::variate_generator<> (like normal) have their
+// own state which would need a reset as well to guarantee identical
+// sequence of numbers, e.g. via myrand.distribution().reset())
+global_rng.seed(seed ^ time(nullptr));
 }
 };
 
@@ -81,6 +81,8 @@ RandomNumberGenerator& GetTheRandomNumberGenerator()
 }
 }
 
+void reseed() { GetTheRandomNumberGenerator().reseed(); }
+
 // uniform ints [a,b] distribution
 int uniform_int_distribution(int a, int b)
 {
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ce1ba38334f6..28ba524ad0eb 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -76,6 +76,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -7969,7 +7970,10 @@ static int lo_initialize(LibreOfficeKit* pThis, const 
char* pAppPath, const char
 }
 rtl::Bootstrap::set(u"UserInstallation"_ustr, url);
 if (eStage == SECOND_INIT)
+{
+comphelper::rng::reseed();
 utl::Bootstrap::reloadData();
+}
 }
 
 OUString aAppPath;
diff --git a/include/comphelper/random.hxx b/include/comphelper/random.hxx
index 345d57c7158d..1fe4dc5fdf58 100644
--- a/include/comphelper/random.hxx
+++ b/include/comphelper/random.hxx
@@ -17,6 +17,8 @@ namespace comphelper::rng
 // These functions obey the SAL_RAND_REPEATABLE environment
 // variable: If it is set, use a fixed seed.
 
+COMPHELPER_DLLPUBLIC void reseed();
+
 // note that uniform_int_distribution is inclusive of b, i.e. [a,b] while
 // uniform_real_distribution is exclusive of b, i.e. [a,b), std::nextafter may 
be your friend there
 


core.git: Branch 'distro/collabora/co-24.04' - comphelper/source desktop/source include/comphelper

2024-05-03 Thread Michael Meeks (via logerrit)
 comphelper/source/misc/random.cxx |   34 ++
 desktop/source/lib/init.cxx   |4 
 include/comphelper/random.hxx |2 ++
 3 files changed, 24 insertions(+), 16 deletions(-)

New commits:
commit 6d9228d6b14d968fa92df3ca018a555f8652e579
Author: Michael Meeks 
AuthorDate: Fri May 3 14:17:27 2024 +0100
Commit: Michael Meeks 
CommitDate: Fri May 3 19:54:47 2024 +0200

lok: reseed comphelper's random number generator on fork.

Also avoid std::random_device it doesn't work in a COOL
kit process.

Change-Id: Ie2d063611a73e734afd92d6fd779f34a2f316230
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167058
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
Reviewed-by: Caolán McNamara 

diff --git a/comphelper/source/misc/random.cxx 
b/comphelper/source/misc/random.cxx
index 96d466641dfb..b8358344e5b0 100644
--- a/comphelper/source/misc/random.cxx
+++ b/comphelper/source/misc/random.cxx
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #if defined HAVE_VALGRIND_HEADERS
 #include 
@@ -40,7 +41,9 @@ struct RandomNumberGenerator
 {
 std::mutex mutex;
 STD_RNG_ALGO global_rng;
-RandomNumberGenerator()
+RandomNumberGenerator() { reseed(); }
+
+void reseed()
 {
 // make RR easier to use, breaks easily without the RNG being 
repeatable
 bool bRepeatable = (getenv("SAL_RAND_REPEATABLE") != nullptr) || 
(getenv("RR") != nullptr);
@@ -56,21 +59,18 @@ struct RandomNumberGenerator
 return;
 }
 
-try
-{
-std::random_device rd;
-// initialises the state of the global random number generator
-// should only be called once.
-// (note, a few std::variate_generator<> (like normal) have their
-// own state which would need a reset as well to guarantee 
identical
-// sequence of numbers, e.g. via myrand.distribution().reset())
-global_rng.seed(rd() ^ time(nullptr));
-}
-catch (std::runtime_error& e)
-{
-SAL_WARN("comphelper", "Using std::random_device failed: " << 
e.what());
-global_rng.seed(time(nullptr));
-}
+size_t seed = -1;
+rtlRandomPool aRandomPool = rtl_random_createPool();
+if (rtl_random_getBytes(aRandomPool, , sizeof(seed)) != 
rtl_Random_E_None)
+seed = -1;
+rtl_random_destroyPool(aRandomPool);
+
+// initialises the state of the global random number generator
+// should only be called once.
+// (note, a few std::variate_generator<> (like normal) have their
+// own state which would need a reset as well to guarantee identical
+// sequence of numbers, e.g. via myrand.distribution().reset())
+global_rng.seed(seed ^ time(nullptr));
 }
 };
 
@@ -81,6 +81,8 @@ RandomNumberGenerator& GetTheRandomNumberGenerator()
 }
 }
 
+void reseed() { GetTheRandomNumberGenerator().reseed(); }
+
 // uniform ints [a,b] distribution
 int uniform_int_distribution(int a, int b)
 {
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 79e5af2fdedd..081166baeb0b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -80,6 +80,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -8024,7 +8025,10 @@ static int lo_initialize(LibreOfficeKit* pThis, const 
char* pAppPath, const char
 }
 rtl::Bootstrap::set(u"UserInstallation"_ustr, url);
 if (eStage == SECOND_INIT)
+{
+comphelper::rng::reseed();
 utl::Bootstrap::reloadData();
+}
 }
 
 OUString aAppPath;
diff --git a/include/comphelper/random.hxx b/include/comphelper/random.hxx
index 345d57c7158d..1fe4dc5fdf58 100644
--- a/include/comphelper/random.hxx
+++ b/include/comphelper/random.hxx
@@ -17,6 +17,8 @@ namespace comphelper::rng
 // These functions obey the SAL_RAND_REPEATABLE environment
 // variable: If it is set, use a fixed seed.
 
+COMPHELPER_DLLPUBLIC void reseed();
+
 // note that uniform_int_distribution is inclusive of b, i.e. [a,b] while
 // uniform_real_distribution is exclusive of b, i.e. [a,b), std::nextafter may 
be your friend there
 


core.git: Branch 'distro/collabora/co-24.04' - desktop/source

2024-04-20 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit ddeec9754cb2871a709d22efb460e141ab4c6f33
Author: Michael Meeks 
AuthorDate: Fri Apr 19 21:13:18 2024 +0100
Commit: Caolán McNamara 
CommitDate: Sat Apr 20 11:56:09 2024 +0200

lok: ensure our 'main thread' concept is updated post-fork.

Otherwise we fall foul of assertions and behavioral differences
around the main thread as the new forked main-thread has a
different thread-id.

Change-Id: I0bd97e5173767ac6c697326aaf0d0822037e480f
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166319
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index fdf25b4cfeac..cc909fa57c16 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3405,6 +3405,8 @@ static int lo_joinThreads(LibreOfficeKit* /* pThis */)
 static void lo_setForkedChild(LibreOfficeKit* /* pThis */, bool bIsChild)
 {
 comphelper::LibreOfficeKit::setForkedChild(bIsChild);
+if (bIsChild)
+Application::UpdateMainThread();
 }
 
 static void lo_registerCallback (LibreOfficeKit* pThis,


core.git: Branch 'distro/collabora/co-24.04' - desktop/source

2024-04-16 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   23 +++
 1 file changed, 23 insertions(+)

New commits:
commit 95f1f2143ae53469417fcebc9b2020c34b53ff30
Author: Michael Meeks 
AuthorDate: Tue Apr 16 18:24:26 2024 +0100
Commit: Caolán McNamara 
CommitDate: Tue Apr 16 20:51:53 2024 +0200

lok: elide various unhelpful events during background save.

In particular TEXT_SELECTION and TABLE_SELECTED seem to be favorites,
but nothing good would come of getting these others either.

Change-Id: I1f014824452bffaeddb1dfaf6565542c3c7c9e91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166158
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1c047116a22d..04c46306f12e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1697,6 +1697,29 @@ void CallbackFlushHandler::queue(const int type, 
CallbackData& aCallbackData)
 
 SAL_INFO("lok", "Queue: [" << type << "]: [" << aCallbackData.getPayload() 
<< "] on " << m_queue1.size() << " entries.");
 
+if (comphelper::LibreOfficeKit::isForkedChild())
+{
+// In background mode - avoid any extraneous or confusing messages
+switch (type)
+{
+case LOK_CALLBACK_INVALIDATE_TILES:
+case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
+case LOK_CALLBACK_TEXT_SELECTION:
+case LOK_CALLBACK_CURSOR_VISIBLE:
+case LOK_CALLBACK_GRAPHIC_SELECTION:
+case LOK_CALLBACK_TABLE_SELECTED:
+case LOK_CALLBACK_SET_PART:
+case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
+case LOK_CALLBACK_MOUSE_POINTER:
+case LOK_CALLBACK_INVALIDATE_HEADER:
+case LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY:
+SAL_INFO("lok", "Elide event in background save mode");
+return;
+default:
+break;
+}
+}
+
 bool bIsChartActive = false;
 bool bIsComment = false;
 if (type == LOK_CALLBACK_GRAPHIC_SELECTION)


core.git: Branch 'distro/collabora/co-24.04' - sfx2/source

2024-04-16 Thread Michael Meeks (via logerrit)
 sfx2/source/doc/sfxbasemodel.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit e005690e9c648ce516c1ed60da6341c7215bf2c9
Author: Michael Meeks 
AuthorDate: Tue Apr 16 18:11:36 2024 +0100
Commit: Caolán McNamara 
CommitDate: Tue Apr 16 20:49:26 2024 +0200

lok: avoid sending jsdialog messages during background save.

This creates lots of enable/disable traffic that is no longer
needed, and may trigger a fallback to non-background-save.

Change-Id: I3dd789d13b6c28540422d99128014c9c17e00d70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166157
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 062c594f2c4f..a42f9e6703b8 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -394,6 +394,9 @@ SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell 
const * pObjectShell )
 if ( !pObjectShell )
 return;
 
+if ( comphelper::LibreOfficeKit::isForkedChild() )
+return; // no need to tweak UI when in the background
+
 for (   SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pObjectShell );
 pFrame;
 pFrame = SfxViewFrame::GetNext( *pFrame, pObjectShell )


core.git: bin/find-can-be-private-symbols.functions.results desktop/source sal/osl

2024-04-15 Thread Michael Meeks (via logerrit)
 bin/find-can-be-private-symbols.functions.results |1 +
 desktop/source/lib/init.cxx   |   22 +-
 sal/osl/unx/random.cxx|8 +++-
 3 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit b99082e4f3d4e4d13433ca062ba98da7cd14aa9a
Author: Michael Meeks 
AuthorDate: Fri Apr 5 14:56:13 2024 +0100
Commit: Miklos Vajna 
CommitDate: Mon Apr 15 15:28:41 2024 +0200

lok: provide global random symbol to find random device.

This is vital for lok when used in a jail with no random device,
but with an inherited file-handle to /dev/urandom.

Use 'dup' to avoid changing code that wants to 'close' the handle
after use.

Change-Id: I15f40fb251f180a2394af030f56e47f2bf9651d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166113
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/bin/find-can-be-private-symbols.functions.results 
b/bin/find-can-be-private-symbols.functions.results
index bc776435eb0e..4080a49fb984 100644
--- a/bin/find-can-be-private-symbols.functions.results
+++ b/bin/find-can-be-private-symbols.functions.results
@@ -13449,6 +13449,7 @@ linguistic::SpellAlternatives::SetFailureType(short)
 linguistic::SpellAlternatives::SetWordLanguage(rtl::OUString const&, 
o3tl::strong_int)
 linguistic::SpellAlternatives::SpellAlternatives()
 load_BLAS
+lok_open_urandom
 longdual_testset
 lower_utf(w_char, int)
 lp_solve_version
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9b49a9c934a6..f1ca1291aed0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -31,8 +31,10 @@
 
 #undef HAVE_MALLOC_TRIM
 
+#ifdef UNX
+#  include 
+#endif
 #ifdef LINUX
-#include 
 #if defined __GLIBC__
 #  include 
 #  define HAVE_MALLOC_TRIM
@@ -234,6 +236,20 @@ using namespace bridge;
 using namespace uno;
 using namespace lang;
 
+#ifdef UNX
+
+static int urandom = -1;
+
+extern "C" {
+int SAL_JNI_EXPORT lok_open_urandom()
+{
+return dup(urandom);
+}
+};
+
+#endif
+
+
 using LanguageToolCfg = 
officecfg::Office::Linguistic::GrammarChecking::LanguageTool;
 
 static LibLibreOffice_Impl *gImpl = nullptr;
@@ -7903,6 +7919,10 @@ static int lo_initialize(LibreOfficeKit* pThis, const 
char* pAppPath, const char
 const char* tz = ::getenv("TZ");
 SfxLokHelper::setDefaultTimezone(!!tz, tz ? OStringToOUString(tz, 
RTL_TEXTENCODING_UTF8)
   : OUString());
+#ifdef UNX
+if (urandom < 0)
+urandom = open("/dev/urandom", O_RDONLY);
+#endif
 }
 
 if (eStage != SECOND_INIT)
diff --git a/sal/osl/unx/random.cxx b/sal/osl/unx/random.cxx
index fbb2d7dedb90..743379818b57 100644
--- a/sal/osl/unx/random.cxx
+++ b/sal/osl/unx/random.cxx
@@ -13,13 +13,19 @@
 #include 
 #include 
 #include 
+#include 
 
 bool osl_get_system_random_data(char* buffer, size_t desired_len)
 {
 int fd;
 
 assert(buffer);
-fd = open("/dev/urandom", O_RDONLY);
+
+static int (*lok_open_urandom)()
+= reinterpret_cast(dlsym(RTLD_DEFAULT, "lok_open_urandom"));
+if (!lok_open_urandom || (fd = lok_open_urandom()) < 0)
+fd = open("/dev/urandom", O_RDONLY);
+
 if (fd != -1)
 {
 while (desired_len)


core.git: Branch 'distro/collabora/co-24.04' - external/nss

2024-04-06 Thread Michael Meeks (via logerrit)
 external/nss/UnpackedTarball_nss.mk |2 
 external/nss/nss.getrandom.patch|   97 
 2 files changed, 99 insertions(+)

New commits:
commit 708663da401e1cc5c4531c8cbb3370c4cf2843d6
Author: Michael Meeks 
AuthorDate: Fri Apr 5 15:23:22 2024 +0100
Commit: Caolán McNamara 
CommitDate: Sat Apr 6 22:10:37 2024 +0200

lok: use of lok random hook in NSS.

This allows us to avoid opening /dev/urandom which may not be there.

Change-Id: I51727fe4a2a28be802afdf6d9ccca5a198167b7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165851
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/external/nss/UnpackedTarball_nss.mk 
b/external/nss/UnpackedTarball_nss.mk
index bf2a93233e60..6b69dd9b1631 100644
--- a/external/nss/UnpackedTarball_nss.mk
+++ b/external/nss/UnpackedTarball_nss.mk
@@ -26,6 +26,8 @@ $(eval $(call gb_UnpackedTarball_add_patches,nss,\
 external/nss/macos-dlopen.patch.0 \
 external/nss/nss-restore-manual-pre-dependencies.patch.1 \
 external/nss/Wincompatible-function-pointer-types.patch.0 \
+$(if $(filter LINUX,$(OS)), \
+external/nss/nss.getrandom.patch) \
 $(if $(filter iOS,$(OS)), \
 external/nss/nss-ios.patch) \
 $(if $(filter ANDROID,$(OS)), \
diff --git a/external/nss/nss.getrandom.patch b/external/nss/nss.getrandom.patch
new file mode 100644
index ..b7f883b64d5a
--- /dev/null
+++ b/external/nss/nss.getrandom.patch
@@ -0,0 +1,97 @@
+--- a/nss/nspr/pr/src/md/unix/uxrng.c
 b/nss/nspr/pr/src/md/unix/uxrng.c
+@@ -68,13 +68,18 @@
+ #include 
+ #include 
+ #include 
++#include 
+ 
+ static int  fdDevURandom;
+ static PRCallOnceType coOpenDevURandom;
+ 
+ static PRStatus OpenDevURandom( void )
+ {
+-fdDevURandom = open( "/dev/urandom", O_RDONLY );
++static int (*lok_open_urandom)();
++if (!lok_open_urandom)
++  lok_open_urandom = dlsym(RTLD_DEFAULT, "lok_open_urandom");
++if (!lok_open_urandom || (fdDevURandom = lok_open_urandom()) < 0)
++  fdDevURandom = open( "/dev/urandom", O_RDONLY );
+ return((-1 == fdDevURandom)? PR_FAILURE : PR_SUCCESS );
+ } /* end OpenDevURandom() */
+ 
+--- a/nss/nss/lib/freebl/unix_rand.c
 b/nss/nss/lib/freebl/unix_rand.c
+@@ -13,6 +13,7 @@
+ #include 
+ #include 
+ #include 
++#include 
+ #include 
+ #include "secrng.h"
+ #include "secerr.h"
+@@ -650,11 +651,21 @@
+ RNG_RandomUpdate(buf, strlen(buf));
+ }
+ 
++{
++unsigned char buffer[SYSTEM_RNG_SEED_COUNT];
++bytes = RNG_SystemRNG(buffer, sizeof (buffer));
++if (bytes == SYSTEM_RNG_SEED_COUNT) /* success */
++ RNG_RandomUpdate(buffer, bytes);
++}
++
++if (bytes != SYSTEM_RNG_SEED_COUNT) /* fail */
++{
+ /* grab some data from system's PRNG before any other files. */
+ bytes = RNG_FileUpdate("/dev/urandom", SYSTEM_RNG_SEED_COUNT);
+ if (!bytes) {
+ PORT_SetError(SEC_ERROR_NEED_RANDOM);
+ }
++}
+ 
+ /* If the user points us to a random file, pass it through the rng */
+ randfile = PR_GetEnvSecure("NSRANDFILE");
+@@ -781,11 +794,19 @@
+ size_t fileBytes = 0;
+ unsigned char *buffer = dest;
+ 
++static int (*lok_open_urandom)();
++if (!lok_open_urandom)
++  lok_open_urandom = dlsym(NULL, "lok_open_urandom");
++if (!lok_open_urandom || (fd = lok_open_urandom()) < 0)
++{
+ file = fopen("/dev/urandom", "r");
+ if (file == NULL) {
+ PORT_SetError(SEC_ERROR_NEED_RANDOM);
+ return 0;
+ }
++}
++else
++  file = fdopen(fd, "r");
+ /* Read from the underlying file descriptor directly to bypass stdio
+  * buffering and avoid reading more bytes than we need from /dev/urandom.
+  * NOTE: we can't use fread with unbuffered I/O because fread may return
+--- a/nss/nss/lib/freebl/unix_urandom.c
 b/nss/nss/lib/freebl/unix_urandom.c
+@@ -5,6 +5,7 @@
+ #include 
+ #include 
+ #include 
++#include 
+ #include "secerr.h"
+ #include "secrng.h"
+ #include "prprf.h"
+@@ -62,7 +63,11 @@
+  * Reset the number of bytes to get and fall back to /dev/urandom. */
+ fileBytes = 0;
+ #endif
+-fd = open("/dev/urandom", O_RDONLY);
++static int (*lok_open_urandom)();
++if (!lok_open_urandom)
++  lok_open_urandom = dlsym(NULL, "lok_open_urandom");
++if (!lok_open_urandom || (fd = lok_open_urandom()) < 0)
++fd = open("/dev/urandom", O_RDONLY);
+ if (fd < 0) {
+ PORT_SetError(SEC_ERROR_NEED_RANDOM);
+ return 0;


core.git: Branch 'distro/collabora/co-24.04' - bin/find-can-be-private-symbols.functions.results desktop/source sal/osl

2024-04-06 Thread Michael Meeks (via logerrit)
 bin/find-can-be-private-symbols.functions.results |1 +
 desktop/source/lib/init.cxx   |   22 +-
 sal/osl/unx/random.cxx|8 +++-
 3 files changed, 29 insertions(+), 2 deletions(-)

New commits:
commit 75973267b0cf8661a815574eeb80e43eb3b9c8fc
Author: Michael Meeks 
AuthorDate: Fri Apr 5 14:56:13 2024 +0100
Commit: Caolán McNamara 
CommitDate: Sat Apr 6 22:07:49 2024 +0200

lok: provide global random symbol to find random device.

This is vital for lok when used in a jail with no random device,
but with an inherited file-handle to /dev/urandom.

Use 'dup' to avoid changing code that wants to 'close' the handle
after use.

Change-Id: I15f40fb251f180a2394af030f56e47f2bf9651d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165850
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/bin/find-can-be-private-symbols.functions.results 
b/bin/find-can-be-private-symbols.functions.results
index 02cd245cbb54..075c73e10125 100644
--- a/bin/find-can-be-private-symbols.functions.results
+++ b/bin/find-can-be-private-symbols.functions.results
@@ -20152,6 +20152,7 @@ linguistic::SpellAlternatives::SetFailureType(short)
 linguistic::SpellAlternatives::SetWordLanguage(rtl::OUString const&, 
o3tl::strong_int)
 linguistic::SpellAlternatives::SpellAlternatives()
 load_BLAS
+lok_open_urandom
 longdual_testset
 lower_utf(w_char, int)
 lp_solve_version
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2c4fba114092..1c047116a22d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -33,8 +33,10 @@
 
 #undef HAVE_MALLOC_TRIM
 
+#ifdef UNX
+#  include 
+#endif
 #ifdef LINUX
-#include 
 #if defined __GLIBC__
 #  include 
 #  define HAVE_MALLOC_TRIM
@@ -249,6 +251,20 @@ using namespace bridge;
 using namespace uno;
 using namespace lang;
 
+#ifdef UNX
+
+static int urandom = -1;
+
+extern "C" {
+int SAL_JNI_EXPORT lok_open_urandom()
+{
+return dup(urandom);
+}
+};
+
+#endif
+
+
 using LanguageToolCfg = 
officecfg::Office::Linguistic::GrammarChecking::LanguageTool;
 
 static LibLibreOffice_Impl *gImpl = nullptr;
@@ -7944,6 +7960,10 @@ static int lo_initialize(LibreOfficeKit* pThis, const 
char* pAppPath, const char
 const char* tz = ::getenv("TZ");
 SfxLokHelper::setDefaultTimezone(!!tz, tz ? OStringToOUString(tz, 
RTL_TEXTENCODING_UTF8)
   : OUString());
+#ifdef UNX
+if (urandom < 0)
+urandom = open("/dev/urandom", O_RDONLY);
+#endif
 }
 
 if (eStage != SECOND_INIT)
diff --git a/sal/osl/unx/random.cxx b/sal/osl/unx/random.cxx
index e8379f8f0bf7..62a552ce4ea3 100644
--- a/sal/osl/unx/random.cxx
+++ b/sal/osl/unx/random.cxx
@@ -13,13 +13,19 @@
 #include 
 #include 
 #include 
+#include 
 
 int osl_get_system_random_data(char* buffer, size_t desired_len)
 {
 int fd;
 
 assert(buffer);
-fd = open("/dev/urandom", O_RDONLY);
+
+static int (*lok_open_urandom)()
+= reinterpret_cast(dlsym(RTLD_DEFAULT, "lok_open_urandom"));
+if (!lok_open_urandom || (fd = lok_open_urandom()) < 0)
+fd = open("/dev/urandom", O_RDONLY);
+
 if (fd != -1)
 {
 while (desired_len)


core.git: desktop/inc desktop/source

2024-04-01 Thread Michael Meeks (via logerrit)
 desktop/inc/app.hxx |2 +-
 desktop/source/lib/init.cxx |3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit c0dcd388b83d73f704cb42ab121fb31a7cb867da
Author: Michael Meeks 
AuthorDate: Mon Apr 1 15:39:00 2024 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 1 22:04:41 2024 +0200

lok preinit: don't re-synchronize extensions on each child start.

We should sort out our extensions, if at all, at pre-init time.
This should save ~4% of CPU in a week-long profile of a COOL server.
From Desktop::Main's SynchronizeExtensionRepositories.

Change-Id: I2760de26635723492dfa5a52005ee90623337bee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165622
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 9d6ac9864a52..0c96240f1b0d 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -69,7 +69,7 @@ class Desktop final : public Application
 
 Desktop();
 virtual ~Desktop() override;
-virtual int Main( ) override;
+virtual int Main() override;
 virtual voidInit() override;
 virtual voidInitFinished() override;
 virtual voidDeInit() override;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cac261e9bcac..52057cd2645d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7509,6 +7509,9 @@ static void preloadData()
 if(bAbort)
 std::cerr << "CheckExtensionDependencies failed" << std::endl;
 
+// inhibit forced 2nd synchronization from Main
+::rtl::Bootstrap::set( "DISABLE_EXTENSION_SYNCHRONIZATION", "true");
+
 std::cerr << "Preload textencodings"; // sal_textenc
 // Use RTL_TEXTENCODING_MS_1250 to trigger Impl_getTextEncodingData
 // to dlopen sal_textenclo


core.git: Branch 'distro/collabora/co-24.04' - desktop/inc desktop/source

2024-04-01 Thread Michael Meeks (via logerrit)
 desktop/inc/app.hxx |2 +-
 desktop/source/lib/init.cxx |3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 4b224658980087558706968c19a8170ecef5620b
Author: Michael Meeks 
AuthorDate: Mon Apr 1 15:39:00 2024 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 1 22:04:33 2024 +0200

lok preinit: don't re-synchronize extensions on each child start.

We should sort out our extensions, if at all, at pre-init time.
This should save ~4% of CPU in a week-long profile of a COOL server.
From Desktop::Main's SynchronizeExtensionRepositories.

Change-Id: I2760de26635723492dfa5a52005ee90623337bee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165639
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 9d6ac9864a52..0c96240f1b0d 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -69,7 +69,7 @@ class Desktop final : public Application
 
 Desktop();
 virtual ~Desktop() override;
-virtual int Main( ) override;
+virtual int Main() override;
 virtual voidInit() override;
 virtual voidInitFinished() override;
 virtual voidDeInit() override;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 68191600f0f8..bfe4ff5fd699 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7527,6 +7527,9 @@ static void preloadData()
 if(bAbort)
 std::cerr << "CheckExtensionDependencies failed" << std::endl;
 
+// inhibit forced 2nd synchronization from Main
+::rtl::Bootstrap::set( "DISABLE_EXTENSION_SYNCHRONIZATION", "true");
+
 std::cerr << "Preload textencodings"; // sal_textenc
 // Use RTL_TEXTENCODING_MS_1250 to trigger Impl_getTextEncodingData
 // to dlopen sal_textenclo


core.git: Branch 'distro/collabora/co-24.04' - desktop/source include/sfx2 sfx2/source

2024-03-28 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   13 +
 include/sfx2/objsh.hxx  |4 
 sfx2/source/doc/objxtor.cxx |5 +
 3 files changed, 22 insertions(+)

New commits:
commit 7d784910689172014b8cf6144e654402696d8801
Author: Michael Meeks 
AuthorDate: Thu Mar 28 09:38:15 2024 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 28 17:15:58 2024 +0100

lok: add method to allow explicit cleanup of temporary files.o

Special case fast destruction of background saving children.

Change-Id: I8fba4d0818d23a8b0e1bb4d074e1afae7dacde33
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165448
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 52882a4a9f88..68191600f0f8 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1471,6 +1471,19 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference 
 xC
 
 LibLODocument_Impl::~LibLODocument_Impl()
 {
+if (comphelper::LibreOfficeKit::isForkedChild())
+{
+// Touch the least memory possible, while trying to avoid leaking 
files.
+SfxBaseModel* pBaseModel = 
dynamic_cast(mxComponent.get());
+if (pBaseModel)
+{
+SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
+if (pObjectShell)
+pObjectShell->InternalCloseAndRemoveFiles();
+}
+return;
+}
+
 try
 {
 mxComponent->dispose();
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 3175cb283642..32d9afd6ed6f 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -239,6 +239,7 @@ private:
 
 public:
 static const css::uno::Sequence& getUnoTunnelId();
+
 /* Stampit disable/enable cancel button for print jobs
default = true = enable! */
 voidStamp_SetPrintCancelState(bool bState);
@@ -699,6 +700,9 @@ public:
 bool bShowCloseButton = true);
 std::vector& getPendingInfobars();
 
+// Destruction of storages and streams
+void InternalCloseAndRemoveFiles();
+
 SAL_DLLPRIVATE bool CreatePreview_Impl(bool bFullContent, VirtualDevice* 
pDevice, GDIMetaFile* pFile) const;
 
 SAL_DLLPRIVATE static bool IsPackageStorageFormat_Impl(const SfxMedium &);
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 11b38ced10a0..434c0f17992d 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -306,6 +306,11 @@ SfxObjectShell::~SfxObjectShell()
 
 pImpl->pBaseModel.clear();
 
+InternalCloseAndRemoveFiles();
+}
+
+void SfxObjectShell::InternalCloseAndRemoveFiles()
+{
 // don't call GetStorage() here, in case of Load Failure it's possible 
that a storage was never assigned!
 if ( pMedium && pMedium->HasStorage_Impl() && pMedium->GetStorage( false ) 
== pImpl->m_xDocStorage )
 pMedium->CanDisposeStorage_Impl( false );


core.git: comphelper/source desktop/qa desktop/source include/comphelper include/LibreOfficeKit

2024-03-28 Thread Michael Meeks (via logerrit)
 comphelper/source/misc/lok.cxx  |   12 
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |8 
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |9 +
 include/comphelper/lok.hxx  |6 ++
 6 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit ccc2e526d107a353469b5aad99e94544c07a10ee
Author: Michael Meeks 
AuthorDate: Wed Mar 27 17:25:24 2024 +
Commit: Michael Meeks 
CommitDate: Thu Mar 28 17:07:15 2024 +0100

lok: add isForkedChild method.

This can be used to tag short-lived transient 'save' processes
to encourage them not to mutate eg. filesystem state that is
shared with the parent process.

Change-Id: I027d18cbe4ce519b31c4fc1d3ac46b916d1efc87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165407
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 9dab5edb90d14ad6f71cc2ac96cc504c1e8c290b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165427
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index b5cbcc74cb54..c042b0c626e5 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -19,6 +19,8 @@ namespace comphelper::LibreOfficeKit
 
 static bool g_bActive(false);
 
+static bool g_bForkedChild(false);
+
 static bool g_bPartInInvalidation(false);
 
 static bool g_bTiledPainting(false);
@@ -98,6 +100,16 @@ bool isActive()
 return g_bActive;
 }
 
+void setForkedChild(bool bIsChild)
+{
+g_bForkedChild = bIsChild;
+}
+
+bool isForkedChild()
+{
+return g_bForkedChild;
+}
+
 void setPartInInvalidation(bool bPartInInvalidation)
 {
 g_bPartInInvalidation = bPartInInvalidation;
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 1a0c2fed27b1..298e5a5d7a9b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3594,10 +3594,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(18), offsetof(struct 
_LibreOfficeKitClass, startURP));
 CPPUNIT_ASSERT_EQUAL(classOffset(19), offsetof(struct 
_LibreOfficeKitClass, stopURP));
 CPPUNIT_ASSERT_EQUAL(classOffset(20), offsetof(struct 
_LibreOfficeKitClass, joinThreads));
+CPPUNIT_ASSERT_EQUAL(classOffset(21), offsetof(struct 
_LibreOfficeKitClass, setForkedChild));
 
 // When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
 // new function pointer and bump this assert for the size of the class.
-CPPUNIT_ASSERT_EQUAL(classOffset(21), sizeof(struct _LibreOfficeKitClass));
+CPPUNIT_ASSERT_EQUAL(classOffset(22), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 99c533c20598..cac261e9bcac 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2543,6 +2543,8 @@ static void lo_stopURP(LibreOfficeKit* pThis, void* 
pSendURPToLOContext);
 
 static int lo_joinThreads(LibreOfficeKit* pThis);
 
+static void lo_setForkedChild(LibreOfficeKit* pThis, bool bIsChild);
+
 static void lo_runLoop(LibreOfficeKit* pThis,
LibreOfficeKitPollCallback pPollCallback,
LibreOfficeKitWakeCallback pWakeCallback,
@@ -2588,6 +2590,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->startURP = lo_startURP;
 m_pOfficeClass->stopURP = lo_stopURP;
 m_pOfficeClass->joinThreads = lo_joinThreads;
+m_pOfficeClass->setForkedChild = lo_setForkedChild;
 
 gOfficeClass = m_pOfficeClass;
 }
@@ -3340,6 +3343,11 @@ static int lo_joinThreads(LibreOfficeKit* /* pThis */)
 return 1;
 }
 
+static void lo_setForkedChild(LibreOfficeKit* /* pThis */, bool bIsChild)
+{
+comphelper::LibreOfficeKit::setForkedChild(bIsChild);
+}
+
 static void lo_registerCallback (LibreOfficeKit* pThis,
  LibreOfficeKitCallback pCallback,
  void* pData)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index de7be575e445..8db2848ef7c8 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -143,6 +143,9 @@ struct _LibreOfficeKitClass
 
 /// @see lok::Office::joinThreads
 int (*joinThreads)(LibreOfficeKit* pThis);
+
+/// @see lok::Office::setForkedChild
+void (*setForkedChild)(LibreOfficeKit* pThis, bool bIsChild);
 };
 

core.git: Branch 'distro/collabora/co-24.04' - sfx2/source

2024-03-28 Thread Michael Meeks (via logerrit)
 sfx2/source/doc/docfile.cxx |   35 +++
 sfx2/source/doc/objstor.cxx |4 +++-
 2 files changed, 34 insertions(+), 5 deletions(-)

New commits:
commit 53316a6b8228885a17bf53c4fae6fe9d8ef80d2d
Author: Michael Meeks 
AuthorDate: Wed Mar 27 18:01:49 2024 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 28 15:37:46 2024 +0100

lok: avoid perturbing parent background save process' temp file.

The temporary file that typically contains the content of thes
currently open document is re-written, and deleted on save. Avoid
deleting the original when we are background save worker.

Change-Id: Ibbb3a963cb3420088623994c067115ff77b96f54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165408
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index c961733d85ac..ba45c8eb9250 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -76,6 +76,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -344,6 +345,32 @@ 
CheckReadOnlyTaskTerminateListener::notifyTermination(const css::lang::EventObje
 lock.unlock();
 mCond.notify_one();
 }
+
+/// Temporary file wrapper to handle tmp file lifecyle
+/// for lok fork a background saving worker issues.
+class MediumTempFile : public ::utl::TempFileNamed
+{
+bool m_bWasChild;
+public:
+MediumTempFile(const OUString *pParent )
+: ::utl::TempFileNamed(pParent)
+, m_bWasChild(comphelper::LibreOfficeKit::isForkedChild())
+{
+}
+
+MediumTempFile(const MediumTempFile  ) = delete;
+
+~MediumTempFile()
+{
+bool isForked = comphelper::LibreOfficeKit::isForkedChild();
+
+// avoid deletion of files created by the parent
+if (isForked && ! m_bWasChild)
+{
+EnableKillingFile(false);
+}
+}
+};
 }
 
 class SfxMedium_Impl
@@ -406,7 +433,7 @@ public:
 
 uno::Sequence < util::RevisionTag > aVersions;
 
-std::unique_ptr<::utl::TempFileNamed> pTempFile;
+std::unique_ptr pTempFile;
 
 uno::Reference xStorage;
 uno::Reference m_xZipStorage;
@@ -3524,7 +3551,7 @@ void SfxMedium::CompleteReOpen()
 bool bUseInteractionHandler = pImpl->bUseInteractionHandler;
 pImpl->bUseInteractionHandler = false;
 
-std::unique_ptr<::utl::TempFileNamed> pTmpFile;
+std::unique_ptr pTmpFile;
 if ( pImpl->pTempFile )
 {
 pTmpFile = std::move(pImpl->pTempFile);
@@ -4035,7 +4062,7 @@ void SfxMedium::CreateTempFile( bool bReplace )
 }
 
 OUString aLogicBase = GetLogicBase(GetURLObject(), pImpl);
-pImpl->pTempFile.reset(new ::utl::TempFileNamed());
+pImpl->pTempFile.reset(new MediumTempFile());
 pImpl->pTempFile->EnableKillingFile();
 pImpl->m_aName = pImpl->pTempFile->GetFileName();
 OUString aTmpURL = pImpl->pTempFile->GetURL();
@@ -4131,7 +4158,7 @@ void SfxMedium::CreateTempFileNoCopy()
 pImpl->pTempFile.reset();
 
 OUString aLogicBase = GetLogicBase(GetURLObject(), pImpl);
-pImpl->pTempFile.reset(new ::utl::TempFileNamed());
+pImpl->pTempFile.reset(new MediumTempFile());
 pImpl->pTempFile->EnableKillingFile();
 pImpl->m_aName = pImpl->pTempFile->GetFileName();
 if ( pImpl->m_aName.isEmpty() )
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 17ee6bf6217d..4d7822613ac9 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1425,7 +1425,9 @@ bool SfxObjectShell::SaveTo_Impl
 // TODO/LATER: error handling
 if( rMedium.GetErrorCode() || pMedium->GetErrorCode() || GetErrorCode() )
 {
-SAL_WARN("sfx.doc", "SfxObjectShell::SaveTo_Impl: very early error 
return");
+SAL_WARN("sfx.doc", "SfxObjectShell::SaveTo_Impl: "
+ " very early error return " << rMedium.GetErrorCode() << " "
+ << pMedium->GetErrorCode() << " " << GetErrorCode());
 return false;
 }
 


core.git: Branch 'distro/collabora/co-24.04' - comphelper/source desktop/qa desktop/source include/comphelper include/LibreOfficeKit

2024-03-28 Thread Michael Meeks (via logerrit)
 comphelper/source/misc/lok.cxx  |   12 
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |8 
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |9 +
 include/comphelper/lok.hxx  |6 ++
 6 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 9dab5edb90d14ad6f71cc2ac96cc504c1e8c290b
Author: Michael Meeks 
AuthorDate: Wed Mar 27 17:25:24 2024 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 28 12:29:41 2024 +0100

lok: add isForkedChild method.

This can be used to tag short-lived transient 'save' processes
to encourage them not to mutate eg. filesystem state that is
shared with the parent process.

Change-Id: I027d18cbe4ce519b31c4fc1d3ac46b916d1efc87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165407
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index b5cbcc74cb54..c042b0c626e5 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -19,6 +19,8 @@ namespace comphelper::LibreOfficeKit
 
 static bool g_bActive(false);
 
+static bool g_bForkedChild(false);
+
 static bool g_bPartInInvalidation(false);
 
 static bool g_bTiledPainting(false);
@@ -98,6 +100,16 @@ bool isActive()
 return g_bActive;
 }
 
+void setForkedChild(bool bIsChild)
+{
+g_bForkedChild = bIsChild;
+}
+
+bool isForkedChild()
+{
+return g_bForkedChild;
+}
+
 void setPartInInvalidation(bool bPartInInvalidation)
 {
 g_bPartInInvalidation = bPartInInvalidation;
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 1a0c2fed27b1..298e5a5d7a9b 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3594,10 +3594,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(18), offsetof(struct 
_LibreOfficeKitClass, startURP));
 CPPUNIT_ASSERT_EQUAL(classOffset(19), offsetof(struct 
_LibreOfficeKitClass, stopURP));
 CPPUNIT_ASSERT_EQUAL(classOffset(20), offsetof(struct 
_LibreOfficeKitClass, joinThreads));
+CPPUNIT_ASSERT_EQUAL(classOffset(21), offsetof(struct 
_LibreOfficeKitClass, setForkedChild));
 
 // When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
 // new function pointer and bump this assert for the size of the class.
-CPPUNIT_ASSERT_EQUAL(classOffset(21), sizeof(struct _LibreOfficeKitClass));
+CPPUNIT_ASSERT_EQUAL(classOffset(22), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 437c904e0db2..52882a4a9f88 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2548,6 +2548,8 @@ static void lo_stopURP(LibreOfficeKit* pThis, void* 
pSendURPToLOContext);
 
 static int lo_joinThreads(LibreOfficeKit* pThis);
 
+static void lo_setForkedChild(LibreOfficeKit* pThis, bool bIsChild);
+
 static void lo_runLoop(LibreOfficeKit* pThis,
LibreOfficeKitPollCallback pPollCallback,
LibreOfficeKitWakeCallback pWakeCallback,
@@ -2593,6 +2595,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->startURP = lo_startURP;
 m_pOfficeClass->stopURP = lo_stopURP;
 m_pOfficeClass->joinThreads = lo_joinThreads;
+m_pOfficeClass->setForkedChild = lo_setForkedChild;
 
 gOfficeClass = m_pOfficeClass;
 }
@@ -3345,6 +3348,11 @@ static int lo_joinThreads(LibreOfficeKit* /* pThis */)
 return 1;
 }
 
+static void lo_setForkedChild(LibreOfficeKit* /* pThis */, bool bIsChild)
+{
+comphelper::LibreOfficeKit::setForkedChild(bIsChild);
+}
+
 static void lo_registerCallback (LibreOfficeKit* pThis,
  LibreOfficeKitCallback pCallback,
  void* pData)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 450366ccb70c..f57c7ad32843 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -143,6 +143,9 @@ struct _LibreOfficeKitClass
 
 /// @see lok::Office::joinThreads
 int (*joinThreads)(LibreOfficeKit* pThis);
+
+/// @see lok::Office::setForkedChild
+void (*setForkedChild)(LibreOfficeKit* pThis, bool bIsChild);
 };
 
 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) 
LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
diff --git 

core.git: Changes to 'refs/tags/cp-24.04.0-1'

2024-02-14 Thread Michael Meeks (via logerrit)
Tag 'cp-24.04.0-1' created by Andras Timar  at 
2024-02-14 17:29 +

cp-24.04.0-1

Changes since co-24.04-branch-point-367:
---
 0 files changed
---


core.git: Branch 'distro/collabora/co-24.04' - desktop/qa desktop/source include/comphelper include/LibreOfficeKit linguistic/source

2024-02-14 Thread Michael Meeks (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |   23 +++
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   12 +++-
 include/comphelper/lok.hxx  |8 
 linguistic/source/gciterator.cxx|8 
 linguistic/source/gciterator.hxx|7 ++-
 linguistic/source/lngsvcmgr.cxx |8 
 linguistic/source/lngsvcmgr.hxx |7 ++-
 9 files changed, 75 insertions(+), 4 deletions(-)

New commits:
commit 269a307da6bc4f8f4c759662703e20d4b6860f9a
Author: Michael Meeks 
AuthorDate: Tue Feb 6 18:05:09 2024 +
Commit: Michael Meeks 
CommitDate: Wed Feb 14 18:27:16 2024 +0100

lok: implement a joinThreads function - to wind down thread pools.

Necessary to do this before forking on Unix systems; use a
dynamic_cast interface since this is all for internal use.

Change-Id: I8a911322acd4ec5654eb0d14804c09d513a0bd4b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163210
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d9809cf56ce3..c9f276a67eeb 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3593,10 +3593,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(17), offsetof(struct 
_LibreOfficeKitClass, trimMemory));
 CPPUNIT_ASSERT_EQUAL(classOffset(18), offsetof(struct 
_LibreOfficeKitClass, startURP));
 CPPUNIT_ASSERT_EQUAL(classOffset(19), offsetof(struct 
_LibreOfficeKitClass, stopURP));
+CPPUNIT_ASSERT_EQUAL(classOffset(20), offsetof(struct 
_LibreOfficeKitClass, joinThreads));
 
 // When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
 // new function pointer and bump this assert for the size of the class.
-CPPUNIT_ASSERT_EQUAL(classOffset(20), sizeof(struct _LibreOfficeKitClass));
+CPPUNIT_ASSERT_EQUAL(classOffset(21), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0fd3e62a571c..3b97df3faa1c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2581,6 +2581,8 @@ lo_startURP(LibreOfficeKit* pThis, void* 
pReceiveURPFromLOContext, void* pSendUR
 
 static void lo_stopURP(LibreOfficeKit* pThis, void* pSendURPToLOContext);
 
+static int lo_joinThreads(LibreOfficeKit* pThis);
+
 static void lo_runLoop(LibreOfficeKit* pThis,
LibreOfficeKitPollCallback pPollCallback,
LibreOfficeKitWakeCallback pWakeCallback,
@@ -2625,6 +2627,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->trimMemory = lo_trimMemory;
 m_pOfficeClass->startURP = lo_startURP;
 m_pOfficeClass->stopURP = lo_stopURP;
+m_pOfficeClass->joinThreads = lo_joinThreads;
 
 gOfficeClass = m_pOfficeClass;
 }
@@ -3357,6 +3360,26 @@ static void lo_stopURP(LibreOfficeKit* /* pThis */,
 
static_cast(pFunctionBasedURPConnection)->close();
 }
 
+
+static int lo_joinThreads(LibreOfficeKit* /* pThis */)
+{
+comphelper::ThreadPool  = 
comphelper::ThreadPool::getSharedOptimalPool();
+pool.joinThreadsIfIdle();
+
+//if (comphelper::getWorkerCount() > 0)
+//return 0;
+
+// Grammar checker thread
+css::uno::Reference xLangSrv =
+css::linguistic2::LinguServiceManager::create(xContext);
+
+auto joinable = dynamic_cast(xLangSrv.get());
+if (joinable && !joinable->joinThreads())
+return 0;
+
+return 1;
+}
+
 static void lo_registerCallback (LibreOfficeKit* pThis,
  LibreOfficeKitCallback pCallback,
  void* pData)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index ed7f4e7f2d28..d924c416eb0b 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -140,6 +140,9 @@ struct _LibreOfficeKitClass
 
 /// @see lok::Office::stopURP
 void (*stopURP)(LibreOfficeKit* pThis, void* pSendURPToLOContext);
+
+/// @see lok::Office::joinThreads
+int (*joinThreads)(LibreOfficeKit* pThis);
 };
 
 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) 
LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 6f75eb6be5cb..797dd6bca73b 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ 

core.git: desktop/qa desktop/source include/comphelper include/LibreOfficeKit linguistic/source

2024-02-14 Thread Michael Meeks (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 ++-
 desktop/source/lib/init.cxx |   23 +++
 include/LibreOfficeKit/LibreOfficeKit.h |3 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   12 +++-
 include/comphelper/lok.hxx  |8 
 linguistic/source/gciterator.cxx|8 
 linguistic/source/gciterator.hxx|7 ++-
 linguistic/source/lngsvcmgr.cxx |8 
 linguistic/source/lngsvcmgr.hxx |7 ++-
 9 files changed, 75 insertions(+), 4 deletions(-)

New commits:
commit 52f2720af102c9a4800db085bbe09e60e5d6a3c7
Author: Michael Meeks 
AuthorDate: Tue Feb 6 18:05:09 2024 +
Commit: Michael Meeks 
CommitDate: Wed Feb 14 17:29:02 2024 +0100

lok: implement a joinThreads function - to wind down thread pools.

Necessary to do this before forking on Unix systems; use a
dynamic_cast interface since this is all for internal use.

Change-Id: I8a911322acd4ec5654eb0d14804c09d513a0bd4b
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163335
Tested-by: Jenkins

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d9809cf56ce3..c9f276a67eeb 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3593,10 +3593,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(17), offsetof(struct 
_LibreOfficeKitClass, trimMemory));
 CPPUNIT_ASSERT_EQUAL(classOffset(18), offsetof(struct 
_LibreOfficeKitClass, startURP));
 CPPUNIT_ASSERT_EQUAL(classOffset(19), offsetof(struct 
_LibreOfficeKitClass, stopURP));
+CPPUNIT_ASSERT_EQUAL(classOffset(20), offsetof(struct 
_LibreOfficeKitClass, joinThreads));
 
 // When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
 // new function pointer and bump this assert for the size of the class.
-CPPUNIT_ASSERT_EQUAL(classOffset(20), sizeof(struct _LibreOfficeKitClass));
+CPPUNIT_ASSERT_EQUAL(classOffset(21), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1742488a7cf9..7d5bbc66d492 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2577,6 +2577,8 @@ lo_startURP(LibreOfficeKit* pThis, void* 
pReceiveURPFromLOContext, void* pSendUR
 
 static void lo_stopURP(LibreOfficeKit* pThis, void* pSendURPToLOContext);
 
+static int lo_joinThreads(LibreOfficeKit* pThis);
+
 static void lo_runLoop(LibreOfficeKit* pThis,
LibreOfficeKitPollCallback pPollCallback,
LibreOfficeKitWakeCallback pWakeCallback,
@@ -2621,6 +2623,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->trimMemory = lo_trimMemory;
 m_pOfficeClass->startURP = lo_startURP;
 m_pOfficeClass->stopURP = lo_stopURP;
+m_pOfficeClass->joinThreads = lo_joinThreads;
 
 gOfficeClass = m_pOfficeClass;
 }
@@ -3353,6 +3356,26 @@ static void lo_stopURP(LibreOfficeKit* /* pThis */,
 
static_cast(pFunctionBasedURPConnection)->close();
 }
 
+
+static int lo_joinThreads(LibreOfficeKit* /* pThis */)
+{
+comphelper::ThreadPool  = 
comphelper::ThreadPool::getSharedOptimalPool();
+pool.joinThreadsIfIdle();
+
+//if (comphelper::getWorkerCount() > 0)
+//return 0;
+
+// Grammar checker thread
+css::uno::Reference xLangSrv =
+css::linguistic2::LinguServiceManager::create(xContext);
+
+auto joinable = dynamic_cast(xLangSrv.get());
+if (joinable && !joinable->joinThreads())
+return 0;
+
+return 1;
+}
+
 static void lo_registerCallback (LibreOfficeKit* pThis,
  LibreOfficeKitCallback pCallback,
  void* pData)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 963d7962a6c2..78651128d3ac 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -140,6 +140,9 @@ struct _LibreOfficeKitClass
 
 /// @see lok::Office::stopURP
 void (*stopURP)(LibreOfficeKit* pThis, void* pSendURPToLOContext);
+
+/// @see lok::Office::joinThreads
+int (*joinThreads)(LibreOfficeKit* pThis);
 };
 
 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) 
LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 29e644900caf..e94053378355 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ 

core.git: desktop/source

2024-02-09 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   17 +
 1 file changed, 17 insertions(+)

New commits:
commit ba0773e50b7058f12981c4d29fb05c34d7486290
Author: Michael Meeks 
AuthorDate: Fri Feb 2 18:16:40 2024 +
Commit: Caolán McNamara 
CommitDate: Fri Feb 9 12:54:46 2024 +0100

preload: open and close empty documents of main types in preinit.

Some quick testing suggest this saves ~800k for writer, ~3Mb for
impress each loading an ~empty hello-world document.

Change-Id: I9a7bc25d38d82b5556dfb04a99d5c145dd71ffec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162939
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
(cherry picked from commit d85cb3832286ae1fdcf4a8494abb8212f21e4e9a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163148
Tested-by: Jenkins

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0db7e1010156..1742488a7cf9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7543,6 +7543,23 @@ static void preloadData()
 #pragma GCC diagnostic pop
 #endif
 
+static constexpr OUString preloadComponents[] = {
+u"private:factory/swriter"_ustr,
+u"private:factory/scalc"_ustr,
+u"private:factory/simpress"_ustr,
+u"private:factory/sdraw"_ustr
+};
+// getting the remote LibreOffice service manager
+uno::Reference 
xCompLoader(frame::Desktop::create(xContext));
+
+// Preload and close each of the main components once to initialize global 
state
+uno::Sequence szEmptyArgs(0);
+for (const auto& component : preloadComponents)
+{
+auto xComp = xCompLoader->loadComponentFromURL(component, "_blank", 0, 
szEmptyArgs);
+xComp->dispose();
+}
+
 // Set user profile's path back to the original one
 rtl::Bootstrap::set(u"UserInstallation"_ustr, sUserPath);
 }


core.git: Branch 'distro/collabora/co-24.04' - desktop/source

2024-02-02 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   17 +
 1 file changed, 17 insertions(+)

New commits:
commit d85cb3832286ae1fdcf4a8494abb8212f21e4e9a
Author: Michael Meeks 
AuthorDate: Fri Feb 2 18:16:40 2024 +
Commit: Caolán McNamara 
CommitDate: Fri Feb 2 22:47:28 2024 +0100

preload: open and close empty documents of main types in preinit.

Some quick testing suggest this saves ~800k for writer, ~3Mb for
impress each loading an ~empty hello-world document.

Change-Id: I9a7bc25d38d82b5556dfb04a99d5c145dd71ffec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162939
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 80442dc5ffa2..c76e7a014725 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7553,6 +7553,23 @@ static void preloadData()
 #pragma GCC diagnostic pop
 #endif
 
+static const OUString preloadComponents[] = {
+"private:factory/swriter",
+"private:factory/scalc",
+"private:factory/simpress",
+"private:factory/sdraw"
+};
+// getting the remote LibreOffice service manager
+uno::Reference 
xCompLoader(frame::Desktop::create(xContext), uno::UNO_QUERY);
+
+// Preload and close each of the main components once to initialize global 
state
+uno::Sequence szEmptyArgs(0);
+for (auto component : preloadComponents)
+{
+auto xComp = xCompLoader->loadComponentFromURL(component, "_blank", 0, 
szEmptyArgs);
+xComp->dispose();
+}
+
 // Set user profile's path back to the original one
 rtl::Bootstrap::set(u"UserInstallation"_ustr, sUserPath);
 }


core.git: Branch 'libreoffice-7-6' - comphelper/source

2024-01-04 Thread Michael Meeks (via logerrit)
 comphelper/source/misc/traceevent.cxx |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 6e1ff96f9c422da509223777f5b72ed3606cd50a
Author: Michael Meeks 
AuthorDate: Thu Dec 28 21:57:57 2023 +
Commit: Xisco Fauli 
CommitDate: Thu Jan 4 15:51:40 2024 +0100

trace events: fix deadlock from non-recursive mutex.

Release lock over s_pBufferFullCallback:
 #4  std::lock_guard::lock_guard(std::mutex&)
 #5  comphelper::TraceEvent::getEventVectorAndClear()
 #6  0x7f2367c61836 in comphelper::TraceEvent::getRecordingAndClear()
 #7  0x7f236877263e in (anonymous 
namespace)::TraceEventDumper::flushRecordings()
 #8  0x7f2367c60cb7 in 
comphelper::TraceEvent::addRecording(rtl::OUString const&)

regression from:
  commit c2424341ed444647d979a69ae55268e96fad3d56
  Date:   Sun Jan 30 10:30:27 2022 +0100
comphelper : use std::mutex in traceevent

Change-Id: Ic89d63d14f06d710937a4da759976ae308c9df45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161329
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit d7bbd8363e3a6856fb7039050b45a5ea0a626f29)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161553
Reviewed-by: Xisco Fauli 

diff --git a/comphelper/source/misc/traceevent.cxx 
b/comphelper/source/misc/traceevent.cxx
index fb07e1caa771..1296404ebd32 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -40,15 +40,16 @@ std::mutex g_aMutex;
 
 void TraceEvent::addRecording(const OUString& sObject)
 {
-std::lock_guard aGuard(g_aMutex);
+bool bEmitCallback;
+{
+std::lock_guard aGuard(g_aMutex);
 
-g_aRecording.emplace_back(sObject);
+g_aRecording.emplace_back(sObject);
 
-if (s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize)
-{
-if (s_pBufferFullCallback != nullptr)
-(*s_pBufferFullCallback)();
+bEmitCallback = s_nBufferSize > 0 && g_aRecording.size() >= 
s_nBufferSize;
 }
+if (bEmitCallback && s_pBufferFullCallback != nullptr)
+(*s_pBufferFullCallback)();
 }
 
 void TraceEvent::addInstantEvent(const char* sName, const std::map& args)


core.git: Branch 'libreoffice-24-2' - comphelper/source

2024-01-02 Thread Michael Meeks (via logerrit)
 comphelper/source/misc/traceevent.cxx |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit c10756b90dd8ed32fa4f370700870e00d93efdb4
Author: Michael Meeks 
AuthorDate: Thu Dec 28 21:57:57 2023 +
Commit: Noel Grandin 
CommitDate: Tue Jan 2 14:12:45 2024 +0100

trace events: fix deadlock from non-recursive mutex.

Release lock over s_pBufferFullCallback:
 #4  std::lock_guard::lock_guard(std::mutex&)
 #5  comphelper::TraceEvent::getEventVectorAndClear()
 #6  0x7f2367c61836 in comphelper::TraceEvent::getRecordingAndClear()
 #7  0x7f236877263e in (anonymous 
namespace)::TraceEventDumper::flushRecordings()
 #8  0x7f2367c60cb7 in 
comphelper::TraceEvent::addRecording(rtl::OUString const&)

regression from:
  commit c2424341ed444647d979a69ae55268e96fad3d56
  Date:   Sun Jan 30 10:30:27 2022 +0100
comphelper : use std::mutex in traceevent

Change-Id: Ic89d63d14f06d710937a4da759976ae308c9df45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161329
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
(cherry picked from commit d7bbd8363e3a6856fb7039050b45a5ea0a626f29)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161551
Reviewed-by: Michael Meeks 

diff --git a/comphelper/source/misc/traceevent.cxx 
b/comphelper/source/misc/traceevent.cxx
index fb07e1caa771..1296404ebd32 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -40,15 +40,16 @@ std::mutex g_aMutex;
 
 void TraceEvent::addRecording(const OUString& sObject)
 {
-std::lock_guard aGuard(g_aMutex);
+bool bEmitCallback;
+{
+std::lock_guard aGuard(g_aMutex);
 
-g_aRecording.emplace_back(sObject);
+g_aRecording.emplace_back(sObject);
 
-if (s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize)
-{
-if (s_pBufferFullCallback != nullptr)
-(*s_pBufferFullCallback)();
+bEmitCallback = s_nBufferSize > 0 && g_aRecording.size() >= 
s_nBufferSize;
 }
+if (bEmitCallback && s_pBufferFullCallback != nullptr)
+(*s_pBufferFullCallback)();
 }
 
 void TraceEvent::addInstantEvent(const char* sName, const std::map& args)


core.git: comphelper/source

2023-12-29 Thread Michael Meeks (via logerrit)
 comphelper/source/misc/traceevent.cxx |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit d7bbd8363e3a6856fb7039050b45a5ea0a626f29
Author: Michael Meeks 
AuthorDate: Thu Dec 28 21:57:57 2023 +
Commit: Noel Grandin 
CommitDate: Fri Dec 29 12:51:31 2023 +0100

trace events: fix deadlock from non-recursive mutex.

Release lock over s_pBufferFullCallback:
 #4  std::lock_guard::lock_guard(std::mutex&)
 #5  comphelper::TraceEvent::getEventVectorAndClear()
 #6  0x7f2367c61836 in comphelper::TraceEvent::getRecordingAndClear()
 #7  0x7f236877263e in (anonymous 
namespace)::TraceEventDumper::flushRecordings()
 #8  0x7f2367c60cb7 in 
comphelper::TraceEvent::addRecording(rtl::OUString const&)

regression from:
  commit c2424341ed444647d979a69ae55268e96fad3d56
  Date:   Sun Jan 30 10:30:27 2022 +0100
comphelper : use std::mutex in traceevent

Change-Id: Ic89d63d14f06d710937a4da759976ae308c9df45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161329
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/comphelper/source/misc/traceevent.cxx 
b/comphelper/source/misc/traceevent.cxx
index fb07e1caa771..1296404ebd32 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -40,15 +40,16 @@ std::mutex g_aMutex;
 
 void TraceEvent::addRecording(const OUString& sObject)
 {
-std::lock_guard aGuard(g_aMutex);
+bool bEmitCallback;
+{
+std::lock_guard aGuard(g_aMutex);
 
-g_aRecording.emplace_back(sObject);
+g_aRecording.emplace_back(sObject);
 
-if (s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize)
-{
-if (s_pBufferFullCallback != nullptr)
-(*s_pBufferFullCallback)();
+bEmitCallback = s_nBufferSize > 0 && g_aRecording.size() >= 
s_nBufferSize;
 }
+if (bEmitCallback && s_pBufferFullCallback != nullptr)
+(*s_pBufferFullCallback)();
 }
 
 void TraceEvent::addInstantEvent(const char* sName, const std::map& args)


core.git: Branch 'distro/collabora/co-23.05' - comphelper/source

2023-12-29 Thread Michael Meeks (via logerrit)
 comphelper/source/misc/traceevent.cxx |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 265328f81946f25d17e7dea90d88af184d35e80c
Author: Michael Meeks 
AuthorDate: Thu Dec 28 21:57:57 2023 +
Commit: Noel Grandin 
CommitDate: Fri Dec 29 12:50:44 2023 +0100

trace events: fix deadlock from non-recursive mutex.

Release lock over s_pBufferFullCallback:
 #4  std::lock_guard::lock_guard(std::mutex&)
 #5  comphelper::TraceEvent::getEventVectorAndClear()
 #6  0x7f2367c61836 in comphelper::TraceEvent::getRecordingAndClear()
 #7  0x7f236877263e in (anonymous 
namespace)::TraceEventDumper::flushRecordings()
 #8  0x7f2367c60cb7 in 
comphelper::TraceEvent::addRecording(rtl::OUString const&)

regression from:
  commit c2424341ed444647d979a69ae55268e96fad3d56
  Date:   Sun Jan 30 10:30:27 2022 +0100
comphelper : use std::mutex in traceevent

Change-Id: Ic89d63d14f06d710937a4da759976ae308c9df45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161394
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Noel Grandin 

diff --git a/comphelper/source/misc/traceevent.cxx 
b/comphelper/source/misc/traceevent.cxx
index fb07e1caa771..1296404ebd32 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -40,15 +40,16 @@ std::mutex g_aMutex;
 
 void TraceEvent::addRecording(const OUString& sObject)
 {
-std::lock_guard aGuard(g_aMutex);
+bool bEmitCallback;
+{
+std::lock_guard aGuard(g_aMutex);
 
-g_aRecording.emplace_back(sObject);
+g_aRecording.emplace_back(sObject);
 
-if (s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize)
-{
-if (s_pBufferFullCallback != nullptr)
-(*s_pBufferFullCallback)();
+bEmitCallback = s_nBufferSize > 0 && g_aRecording.size() >= 
s_nBufferSize;
 }
+if (bEmitCallback && s_pBufferFullCallback != nullptr)
+(*s_pBufferFullCallback)();
 }
 
 void TraceEvent::addInstantEvent(const char* sName, const std::map& args)


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/source

2023-11-30 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 282cf792f23830e98b0ee5a5bd9923714604c8ba
Author: Michael Meeks 
AuthorDate: Sat Nov 25 21:24:49 2023 +
Commit: Szymon Kłos 
CommitDate: Thu Nov 30 15:49:49 2023 +0100

lok: import allowed paths from the SAL_ALLOWED_PATHS.

Do this on second init, in order to be able to reset this for
each child kit process.

Change-Id: I6939ea3677ea2b84c8944b63a9a9120e880a6bfa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159961
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2e6960e9ee52..3c658388306a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -7766,6 +7766,15 @@ static int lo_initialize(LibreOfficeKit* pThis, const 
char* pAppPath, const char
 }
 }
 
+#ifdef LINUX
+{
+const char *pAllowedPaths = getenv("SAL_ALLOWED_PATHS");
+if (pAllowedPaths)
+osl_setAllowedPaths(
+OUString(pAllowedPaths, strlen(pAllowedPaths), 
RTL_TEXTENCODING_UTF8).pData);
+}
+#endif
+
 // What stage are we at ?
 if (pThis == nullptr)
 {


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - include/osl sal/osl sal/qa sal/util

2023-11-29 Thread Michael Meeks (via logerrit)
 include/osl/file.h   |   48 
 include/osl/file.hxx |   52 ++
 sal/osl/unx/file.cxx |  124 +++
 sal/osl/unx/file_impl.hxx|2 
 sal/osl/unx/file_misc.cxx|   34 +++
 sal/osl/unx/file_stat.cxx|6 ++
 sal/osl/unx/file_volume.cxx  |4 +
 sal/osl/unx/pipe.cxx |4 +
 sal/osl/unx/process.cxx  |5 +
 sal/osl/unx/profile.cxx  |5 +
 sal/qa/osl/file/osl_File.cxx |  118 
 sal/util/sal.map |6 ++
 12 files changed, 407 insertions(+), 1 deletion(-)

New commits:
commit de81e7d933fbab6fe1546b513900e1c50a9aab38
Author: Michael Meeks 
AuthorDate: Wed Nov 22 19:37:38 2023 +
Commit: Michael Meeks 
CommitDate: Wed Nov 29 20:21:33 2023 +0100

sal: initial osl::File sand-boxing commit for Unix.

Change-Id: If2c106fef9640499b82b5cf350cb5169beb219fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159838
Reviewed-by: Szymon Kłos 
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/include/osl/file.h b/include/osl/file.h
index 07d2beb2ae1f..98ad568550b9 100644
--- a/include/osl/file.h
+++ b/include/osl/file.h
@@ -960,6 +960,54 @@ SAL_DLLPUBLIC oslFileError SAL_CALL osl_readFile(
 SAL_DLLPUBLIC oslFileError SAL_CALL osl_isEndOfFile(
 oslFileHandle Handle, sal_Bool *pIsEOF );
 
+/** Resets the list of paths and associated permissions for osl
+
+@param[in] pustrFileURLs
+Contains a ':' delimited list of control strings and paths.
+Control segments are a short path that refers to the following
+segments and contain either:
+
+r: read-only paths follow (the default)
+w: read & write paths follow
+x: executable paths follow
+
+Any real paths (ie. having resolved all symlinks)
+accessed outside of these paths will cause an
+osl_File_E_ACCESS error in the relevant method calls.
+
+This method is Unix specific.
+
+@see osl_isForbiddenPath
+
+@since LibreOffice 7.7
+*/
+SAL_DLLPUBLIC void SAL_CALL osl_setAllowedPaths(
+rtl_uString *pustrFileURLs
+);
+
+/**
+   Determine if the passed in path is not contained inside
+   the allowed paths, or if no allowed paths are set it
+   will not forbid any access.
+
+   @param[in] pustrFileURL
+   A URL (or path) that we want to check if it is forbidden
+   to access.
+
+   @param[in] nFlags
+   Flags to determine what type of access is requested,
+   osl_File_OpenFlag_Read | Write, or 0x80 for 'execute'.
+
+   This method is Unix specific.
+
+   @see osl_setAllowedPaths
+
+   @since LibreOffice 7.7
+ */
+SAL_DLLPUBLIC sal_Bool SAL_CALL osl_isForbiddenPath(
+rtl_uString *pustrFileURL, int nFlags
+);
+
 /** Write a number of bytes to a file.
 
 Writes a number of bytes to a file.
diff --git a/include/osl/file.hxx b/include/osl/file.hxx
index fcbabe96d674..6330247ba818 100644
--- a/include/osl/file.hxx
+++ b/include/osl/file.hxx
@@ -313,6 +313,58 @@ public:
 
 return static_cast< RC >( osl_createTempFile(pustr_dir_url, pHandle, 
ppustr_tmp_file_url) );
 }
+
+
+/** Resets the list of paths and associated permissions for osl
+
+@param[in] rPaths
+Contains a ':' delimited list of control strings and paths.
+Control segments are a short path that refers to the following
+segments and contain either:
+
+r: read-only paths follow (the default)
+w: read & write paths follow
+x: executable paths follow
+
+Any real paths (ie. having resolved all symlinks)
+accessed outside of these paths will cause an
+osl_File_E_ACCESS error in the relevant method calls.
+
+This method is Unix specific.
+
+@see osl_isForbiddenPath
+
+@since LibreOffice 7.7
+*/
+
+static void setAllowedPaths(const OUString )
+{
+osl_setAllowedPaths(rPaths.pData);
+}
+
+/**
+   Determine if the passed in path is not contained inside
+   the allowed paths, or if no allowed paths are set it
+   will not forbid any access.
+
+   @param[in] pustrFileURL
+   A URL (or path) that we want to check if it is forbidden
+   to access.
+
+   @param[in] nFlags
+   Flags to determine what type of access is requested,
+   osl_File_OpenFlag_Read | Write, or 0x80 for 'execute'.
+
+   This method is Unix specific.
+
+   @see osl_setAllowedPaths
+
+   @since LibreOffice 7.7
+*/
+static bool isForbidden(const OUString , int nFlags)
+{
+return osl_isForbiddenPath(rPath.pData, nFlags);
+}
 };
 
 
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index a39365b9b115..0556be7fc97a 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -783,6 +783,125 @@ static bool osl_file_queryLocking(sal_uInt32 uFlags)
 return false;
 }
 
+static bool abortOnForbidden = false;
+static std::vector 

[Libreoffice-commits] core.git: sc/source

2023-11-20 Thread Michael Meeks (via logerrit)
 sc/source/ui/inc/viewfunc.hxx  |3 -
 sc/source/ui/undo/undoblk3.cxx |3 -
 sc/source/ui/view/cellsh3.cxx  |8 ---
 sc/source/ui/view/viewfun2.cxx |   96 +++--
 4 files changed, 60 insertions(+), 50 deletions(-)

New commits:
commit 13eb599d8b0f81e4024f4aa2a6dd8b074f80a9df
Author: Michael Meeks 
AuthorDate: Thu Nov 16 19:28:21 2023 +
Commit: Michael Meeks 
CommitDate: Mon Nov 20 14:37:01 2023 +0100

lok: async calc merge-cells popup dialog.

Change-Id: I6f7d1e8de4ac36f546706f7702157cc7e49c80b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159581
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 45b053f3d33d..52e2aedd9d22 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -236,7 +236,8 @@ public:
 boolTestMergeCells();
 boolTestRemoveMerge();
 
-boolMergeCells( bool bApi, bool& rDoContents, bool bCenter );
+voidMergeCells( bool bApi, bool bDoContents, bool bCenter,
+const sal_uInt16 nSlot );
 boolRemoveMerge();
 
 SC_DLLPUBLIC void
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index b7b615d6608f..bc967d96d47f 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -755,8 +755,7 @@ void ScUndoMerge::Repeat(SfxRepeatTarget& rTarget)
 if (auto pViewTarget = dynamic_cast( ))
 {
 ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
-bool bCont = false;
-rViewShell.MergeCells( false, bCont, false );
+rViewShell.MergeCells( false, false, false, 0 );
 }
 }
 
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index e052952ff664..e6c89b6a2b9c 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -943,13 +943,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
 bMoveContents = static_cast(pItem)->GetValue();
 }
 
-if (pTabViewShell->MergeCells( bApi, bMoveContents, 
bCenter ))
-{
-if (!bApi && bMoveContents) // "yes" 
clicked in dialog
-rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents 
) );
-rBindings.Invalidate( nSlot );
-rReq.Done();
-}
+pTabViewShell->MergeCells( bApi, bMoveContents, bCenter, 
nSlot );
 }
 else
 {
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index c2a7bfac2797..42c3ba2a62cd 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -20,6 +20,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1179,7 +1180,8 @@ bool ScViewFunc::TestMergeCells()   // pre-test 
(for menu)
 return false;
 }
 
-bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
+void ScViewFunc::MergeCells( bool bApi, bool bDoContents, bool bCenter,
+ const sal_uInt16 nSlot )
 {
 //  Editable- and Being-Nested- test must be at the beginning (in DocFunc 
too),
 //  so that the Contents-QueryBox won't appear
@@ -1187,7 +1189,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& 
rDoContents, bool bCenter )
 if (!aTester.IsEditable())
 {
 ErrorMessage(aTester.GetMessageId());
-return false;
+return;
 }
 
 ScMarkData& rMark = GetViewData().GetMarkData();
@@ -1195,7 +1197,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& 
rDoContents, bool bCenter )
 if (!rMark.IsMarked())
 {
 ErrorMessage(STR_NOMULTISELECT);
-return false;
+return;
 }
 
 ScDocShell* pDocSh = GetViewData().GetDocShell();
@@ -1211,14 +1213,14 @@ bool ScViewFunc::MergeCells( bool bApi, bool& 
rDoContents, bool bCenter )
 if ( nStartCol == nEndCol && nStartRow == nEndRow )
 {
 // nothing to do
-return true;
+return;
 }
 
 if ( rDoc.HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, 
nEndTab,
 HasAttrFlags::Merged | HasAttrFlags::Overlapped ) )
 {   // "Don't nest merging  !"
 ErrorMessage(STR_MSSG_MERGECELLS_0);
-return false;
+return;
 }
 
 // Check for the contents of all selected tables.
@@ -1241,7 +1243,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& 
rDoContents, bool bCenter )
 {
 // this range contains only one data cell.
 if (nStartCol != aState.mnCol1 || nStartRow != aState.mnRow1)
-rDoContents = true; // move the value to the top-left.
+bDoContents = true; // move the value to the 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/source

2023-11-18 Thread Michael Meeks (via logerrit)
 sc/source/ui/inc/viewfunc.hxx  |3 -
 sc/source/ui/undo/undoblk3.cxx |3 -
 sc/source/ui/view/cellsh3.cxx  |8 ---
 sc/source/ui/view/viewfun2.cxx |   96 +++--
 4 files changed, 60 insertions(+), 50 deletions(-)

New commits:
commit 5c77b34a2004a2f6e7cab7a81b111ba22c2b96ba
Author: Michael Meeks 
AuthorDate: Thu Nov 16 19:28:21 2023 +
Commit: Tomaž Vajngerl 
CommitDate: Sun Nov 19 02:18:27 2023 +0100

lok: async calc merge-cells popup dialog.

Change-Id: I6f7d1e8de4ac36f546706f7702157cc7e49c80b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159520
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 0d8d7515441a..a62406020de5 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -236,7 +236,8 @@ public:
 boolTestMergeCells();
 boolTestRemoveMerge();
 
-boolMergeCells( bool bApi, bool& rDoContents, bool bCenter );
+voidMergeCells( bool bApi, bool bDoContents, bool bCenter,
+const sal_uInt16 nSlot );
 boolRemoveMerge();
 
 SC_DLLPUBLIC void
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index f614e0ff0b4a..43363fd6722c 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -755,8 +755,7 @@ void ScUndoMerge::Repeat(SfxRepeatTarget& rTarget)
 if (auto pViewTarget = dynamic_cast( ))
 {
 ScTabViewShell& rViewShell = *pViewTarget->GetViewShell();
-bool bCont = false;
-rViewShell.MergeCells( false, bCont, false );
+rViewShell.MergeCells( false, false, false, 0 );
 }
 }
 
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
index 72c7d94ff625..dab2ee7b6a3f 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -944,13 +944,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
 bMoveContents = static_cast(pItem)->GetValue();
 }
 
-if (pTabViewShell->MergeCells( bApi, bMoveContents, 
bCenter ))
-{
-if (!bApi && bMoveContents) // "yes" 
clicked in dialog
-rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents 
) );
-rBindings.Invalidate( nSlot );
-rReq.Done();
-}
+pTabViewShell->MergeCells( bApi, bMoveContents, bCenter, 
nSlot );
 }
 else
 {
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 884722204f0a..45aeb2a3cdce 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -20,6 +20,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1178,7 +1179,8 @@ bool ScViewFunc::TestMergeCells()   // pre-test 
(for menu)
 return false;
 }
 
-bool ScViewFunc::MergeCells( bool bApi, bool& rDoContents, bool bCenter )
+void ScViewFunc::MergeCells( bool bApi, bool bDoContents, bool bCenter,
+ const sal_uInt16 nSlot )
 {
 //  Editable- and Being-Nested- test must be at the beginning (in DocFunc 
too),
 //  so that the Contents-QueryBox won't appear
@@ -1186,7 +1188,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& 
rDoContents, bool bCenter )
 if (!aTester.IsEditable())
 {
 ErrorMessage(aTester.GetMessageId());
-return false;
+return;
 }
 
 ScMarkData& rMark = GetViewData().GetMarkData();
@@ -1194,7 +1196,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& 
rDoContents, bool bCenter )
 if (!rMark.IsMarked())
 {
 ErrorMessage(STR_NOMULTISELECT);
-return false;
+return;
 }
 
 ScDocShell* pDocSh = GetViewData().GetDocShell();
@@ -1210,14 +1212,14 @@ bool ScViewFunc::MergeCells( bool bApi, bool& 
rDoContents, bool bCenter )
 if ( nStartCol == nEndCol && nStartRow == nEndRow )
 {
 // nothing to do
-return true;
+return;
 }
 
 if ( rDoc.HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, 
nEndTab,
 HasAttrFlags::Merged | HasAttrFlags::Overlapped ) )
 {   // "Don't nest merging  !"
 ErrorMessage(STR_MSSG_MERGECELLS_0);
-return false;
+return;
 }
 
 // Check for the contents of all selected tables.
@@ -1240,7 +1242,7 @@ bool ScViewFunc::MergeCells( bool bApi, bool& 
rDoContents, bool bCenter )
 {
 // this range contains only one data cell.
 if (nStartCol != aState.mnCol1 || nStartRow != aState.mnRow1)
-rDoContents = true; // move the value to the top-left.
+bDoContents = true; // move the 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - static/CustomTarget_emscripten_fs_image.mk

2023-10-27 Thread Michael Meeks (via logerrit)
 static/CustomTarget_emscripten_fs_image.mk |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d4d97669b6c5a661148ae280d76f7ad1c13a83cb
Author: Michael Meeks 
AuthorDate: Thu Oct 26 21:54:05 2023 +0100
Commit: Andras Timar 
CommitDate: Fri Oct 27 20:59:37 2023 +0200

cowasm: fix easy conditional format ui file name.

Change-Id: I4302b3dd924f6d3cafcf91cfd858a03797f40a4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158515
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/static/CustomTarget_emscripten_fs_image.mk 
b/static/CustomTarget_emscripten_fs_image.mk
index 5441b3d1dae1..35b4e0ff7142 100644
--- a/static/CustomTarget_emscripten_fs_image.mk
+++ b/static/CustomTarget_emscripten_fs_image.mk
@@ -931,7 +931,7 @@ gb_emscripten_fs_image_files += \
 
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/colwidthdialog.ui
 \
 
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/condformatmanager.ui
 \
 
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/conditionalentry.ui
 \
-
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/conditionalformateasy.ui
 \
+
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/conditionaleasydialog.ui
 \
 
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/conditionalformatdialog.ui
 \
 
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/conditionaliconset.ui
 \
 
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/modules/scalc/ui/conflictsdialog.ui
 \


[Libreoffice-commits] core.git: sc/source

2023-10-20 Thread Michael Meeks (via logerrit)
 sc/source/core/data/column4.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 2cbf54efab073d9147e2d6c627c8ff3726de8578
Author: Michael Meeks 
AuthorDate: Thu Oct 19 15:15:33 2023 +0100
Commit: Caolán McNamara 
CommitDate: Fri Oct 20 17:17:54 2023 +0200

sc: perf: avoid construction of collector for empty note columns.

It is extremely common to have empty note columns; so shorten this
path profile in: cool#7334

Change-Id: Ibfd550be1a5e8e98df8b4ede0d018c4f85300648
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158158
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index a1423b2e1c67..be0fc4f201c3 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -856,7 +856,9 @@ public:
 
 void ScColumn::GetAllNoteEntries( std::vector& rNotes ) const
 {
-std::for_each(maCellNotes.begin(), maCellNotes.end(), 
NoteEntryCollector(rNotes, nTab, nCol, 0, GetDoc().MaxRow()));
+if (HasCellNotes())
+std::for_each(maCellNotes.begin(), maCellNotes.end(),
+  NoteEntryCollector(rNotes, nTab, nCol, 0, 
GetDoc().MaxRow()));
 }
 
 void ScColumn::GetNotesInRange(SCROW nStartRow, SCROW nEndRow,


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/source

2023-10-20 Thread Michael Meeks (via logerrit)
 sc/source/core/data/column4.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 00563949554ca52f7316e9c8769b4567d8875c88
Author: Michael Meeks 
AuthorDate: Thu Oct 19 15:15:33 2023 +0100
Commit: Caolán McNamara 
CommitDate: Fri Oct 20 11:26:58 2023 +0200

sc: perf: avoid construction of collector for empty note columns.

It is extremely common to have empty note columns; so shorten this
path profile in: cool#7334

Change-Id: Ibfd550be1a5e8e98df8b4ede0d018c4f85300648
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158182
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 49420642bf5f..aeb38e00150a 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -860,7 +860,9 @@ public:
 
 void ScColumn::GetAllNoteEntries( std::vector& rNotes ) const
 {
-std::for_each(maCellNotes.begin(), maCellNotes.end(), 
NoteEntryCollector(rNotes, nTab, nCol, 0, GetDoc().MaxRow()));
+if (HasCellNotes())
+std::for_each(maCellNotes.begin(), maCellNotes.end(),
+  NoteEntryCollector(rNotes, nTab, nCol, 0, 
GetDoc().MaxRow()));
 }
 
 void ScColumn::GetNotesInRange(SCROW nStartRow, SCROW nEndRow,


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sc/source

2023-08-30 Thread Michael Meeks (via logerrit)
 sc/source/ui/app/inputwin.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit 2721148fe36aaab9c2eed6c52a4afde7a868e29d
Author: Michael Meeks 
AuthorDate: Tue Aug 29 22:08:42 2023 +0100
Commit: Caolán McNamara 
CommitDate: Wed Aug 30 10:29:52 2023 +0200

lok: avoid forcing expensive re-layout of the calc input bar.

This occured on doc_setView and was unreasonably expensive - loading and
de-compressing new PNGs as multiple users typed, re-sizing and
re-rendering a toolbar that is not visible -> do nothing here.

cf. cool#6893.

Change-Id: I1980a3a4516fb2aa629da85de9d4628f29de5af7
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156219
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 07a4cd93a836..1afa94c23822 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1104,6 +1104,10 @@ void ScInputBarGroup::NumLinesChanged()
 
 void ScInputBarGroup::TriggerToolboxLayout()
 {
+// layout changes are expensive and un-necessary.
+if (comphelper::LibreOfficeKit::isActive())
+return;
+
 vcl::Window *w=GetParent();
 ScInputWindow  = dynamic_cast(*w);
 SfxViewFrame* pViewFrm = SfxViewFrame::Current();


[Libreoffice-commits] core.git: sc/source

2023-08-30 Thread Michael Meeks (via logerrit)
 sc/source/ui/app/inputwin.cxx |4 
 1 file changed, 4 insertions(+)

New commits:
commit 1fbf566ad06cb41ae181b3848dfd2535e2dd87a2
Author: Michael Meeks 
AuthorDate: Tue Aug 29 22:08:42 2023 +0100
Commit: Michael Meeks 
CommitDate: Wed Aug 30 10:00:00 2023 +0200

lok: avoid forcing expensive re-layout of the calc input bar.

This occured on doc_setView and was unreasonably expensive - loading and
de-compressing new PNGs as multiple users typed, re-sizing and
re-rendering a toolbar that is not visible -> do nothing here.

cf. cool#6893.

Change-Id: I1980a3a4516fb2aa629da85de9d4628f29de5af7
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156270

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 70dee0e453fd..802d2d7087e5 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1141,6 +1141,10 @@ void ScInputBarGroup::NumLinesChanged()
 
 void ScInputBarGroup::TriggerToolboxLayout()
 {
+// layout changes are expensive and un-necessary.
+if (comphelper::LibreOfficeKit::isActive())
+return;
+
 vcl::Window *w=GetParent();
 ScInputWindow  = dynamic_cast(*w);
 SfxViewFrame* pViewFrm = SfxViewFrame::Current();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-6' - vcl/source

2023-06-12 Thread Michael Meeks (via logerrit)
 vcl/source/app/svdata.cxx |8 ++--
 vcl/source/app/svmain.cxx |8 +---
 2 files changed, 7 insertions(+), 9 deletions(-)

New commits:
commit 2642ae3c7ddc188496e19d8e4a024b3403fdd86e
Author: Michael Meeks 
AuthorDate: Fri Jun 9 12:17:36 2023 +0100
Commit: Michael Meeks 
CommitDate: Mon Jun 12 18:39:52 2023 +0200

trimMemory - fix crash modifying structure during clear.

Re-use existing code from shutdown, to avoid ~Bitmap mutating
maScaleCache while we're iterating it inside clear.

Change-Id: I021d9075cf5c449702af091c2c8a4de64887f2ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152769
Tested-by: Jenkins
Reviewed-by: Michael Meeks 
(cherry picked from commit 6fc48879f8347a53a5ef1bf801fab831be3310f2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152884

diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index ac1fd6b2c623..9840eec37fc6 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -420,9 +420,13 @@ ImplSVData::ImplSVData()
 
 void ImplSVData::dropCaches()
 {
-maGDIData.maScaleCache.clear();
-maGDIData.maThemeImageCache.clear();
+// we are iterating over a map and doing erase while inside a loop which 
is doing erase
+// hence we can't use clear() here
+maGDIData.maScaleCache.remove_if([](const 
lru_scale_cache::key_value_pair_t&)
+{ return true; });
+
 maGDIData.maThemeDrawCommandsCache.clear();
+maGDIData.maThemeImageCache.clear();
 }
 
 void ImplSVData::dumpState(rtl::OStringBuffer )
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 5bccf3e3a0c4..b574873744ee 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -589,13 +589,7 @@ void DeInitVCL()
 
 pSVData->maGDIData.mxScreenFontList.reset();
 pSVData->maGDIData.mxScreenFontCache.reset();
-// we are iterating over a map and doing erase while inside a loop which 
is doing erase
-// hence we can't use clear() here
-pSVData->maGDIData.maScaleCache.remove_if([](const 
lru_scale_cache::key_value_pair_t&)
-{ return true; });
-
-pSVData->maGDIData.maThemeDrawCommandsCache.clear();
-pSVData->maGDIData.maThemeImageCache.clear();
+pSVData->dropCaches();
 
 comphelper::AccessibleEventNotifier::shutdown();
 


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - vcl/source

2023-06-09 Thread Michael Meeks (via logerrit)
 vcl/source/app/svdata.cxx |8 ++--
 vcl/source/app/svmain.cxx |8 +---
 2 files changed, 7 insertions(+), 9 deletions(-)

New commits:
commit 6fb7330f35424f3b9f04a6dfb99b1754e2dcfa0f
Author: Michael Meeks 
AuthorDate: Fri Jun 9 12:17:36 2023 +0100
Commit: Caolán McNamara 
CommitDate: Fri Jun 9 16:54:04 2023 +0200

trimMemory - fix crash modifying structure during clear.

Re-use existing code from shutdown, to avoid ~Bitmap mutating
maScaleCache while we're iterating it inside clear.

Change-Id: I021d9075cf5c449702af091c2c8a4de64887f2ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152785
Reviewed-by: Miklos Vajna 
Tested-by: Michael Meeks 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index febed41cb98c..cb7778fcfd40 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -419,9 +419,13 @@ ImplSVData::ImplSVData()
 
 void ImplSVData::dropCaches()
 {
-maGDIData.maScaleCache.clear();
-maGDIData.maThemeImageCache.clear();
+// we are iterating over a map and doing erase while inside a loop which 
is doing erase
+// hence we can't use clear() here
+maGDIData.maScaleCache.remove_if([](const 
lru_scale_cache::key_value_pair_t&)
+{ return true; });
+
 maGDIData.maThemeDrawCommandsCache.clear();
+maGDIData.maThemeImageCache.clear();
 }
 
 void ImplSVData::dumpState(rtl::OStringBuffer )
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 7c5505f364cb..2838cfc3a63c 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -588,13 +588,7 @@ void DeInitVCL()
 
 pSVData->maGDIData.mxScreenFontList.reset();
 pSVData->maGDIData.mxScreenFontCache.reset();
-// we are iterating over a map and doing erase while inside a loop which 
is doing erase
-// hence we can't use clear() here
-pSVData->maGDIData.maScaleCache.remove_if([](const 
lru_scale_cache::key_value_pair_t&)
-{ return true; });
-
-pSVData->maGDIData.maThemeDrawCommandsCache.clear();
-pSVData->maGDIData.maThemeImageCache.clear();
+pSVData->dropCaches();
 
 // Deinit Sal
 if (pSVData->mpDefInst)


[Libreoffice-commits] core.git: vcl/source

2023-06-09 Thread Michael Meeks (via logerrit)
 vcl/source/app/svdata.cxx |8 ++--
 vcl/source/app/svmain.cxx |8 +---
 2 files changed, 7 insertions(+), 9 deletions(-)

New commits:
commit 6fc48879f8347a53a5ef1bf801fab831be3310f2
Author: Michael Meeks 
AuthorDate: Fri Jun 9 12:17:36 2023 +0100
Commit: Michael Meeks 
CommitDate: Fri Jun 9 16:33:40 2023 +0200

trimMemory - fix crash modifying structure during clear.

Re-use existing code from shutdown, to avoid ~Bitmap mutating
maScaleCache while we're iterating it inside clear.

Change-Id: I021d9075cf5c449702af091c2c8a4de64887f2ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152769
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index ac1fd6b2c623..9840eec37fc6 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -420,9 +420,13 @@ ImplSVData::ImplSVData()
 
 void ImplSVData::dropCaches()
 {
-maGDIData.maScaleCache.clear();
-maGDIData.maThemeImageCache.clear();
+// we are iterating over a map and doing erase while inside a loop which 
is doing erase
+// hence we can't use clear() here
+maGDIData.maScaleCache.remove_if([](const 
lru_scale_cache::key_value_pair_t&)
+{ return true; });
+
 maGDIData.maThemeDrawCommandsCache.clear();
+maGDIData.maThemeImageCache.clear();
 }
 
 void ImplSVData::dumpState(rtl::OStringBuffer )
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 5bccf3e3a0c4..b574873744ee 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -589,13 +589,7 @@ void DeInitVCL()
 
 pSVData->maGDIData.mxScreenFontList.reset();
 pSVData->maGDIData.mxScreenFontCache.reset();
-// we are iterating over a map and doing erase while inside a loop which 
is doing erase
-// hence we can't use clear() here
-pSVData->maGDIData.maScaleCache.remove_if([](const 
lru_scale_cache::key_value_pair_t&)
-{ return true; });
-
-pSVData->maGDIData.maThemeDrawCommandsCache.clear();
-pSVData->maGDIData.maThemeImageCache.clear();
+pSVData->dropCaches();
 
 comphelper::AccessibleEventNotifier::shutdown();
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - 2 commits - vcl/inc vcl/source vcl/unx

2023-05-25 Thread Michael Meeks (via logerrit)
 vcl/inc/unx/cairotextrender.hxx |5 --
 vcl/source/gdi/salgdilayout.cxx |2 
 vcl/unx/generic/gdi/cairotextrender.cxx |   66 +---
 3 files changed, 45 insertions(+), 28 deletions(-)

New commits:
commit 3b1e2ec969c7ff55b241dd791e13dffb8afe40cd
Author: Michael Meeks 
AuthorDate: Tue May 23 18:19:18 2023 +0100
Commit: Caolán McNamara 
CommitDate: Thu May 25 09:45:34 2023 +0200

perf: surprising to see getenv on a profile.

Change-Id: Id97c77d4c836e4f3c5a9eff6da07eb52d29248c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152167
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 127a7b263c4a45c1570f21080022f79099c5c3e6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152212
Tested-by: Jenkins

diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 91419779d871..a219ce89e5c6 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -62,7 +62,7 @@ SalGraphics::SalGraphics()
 
 bool SalGraphics::initWidgetDrawBackends(bool bForce)
 {
-bool bFileDefinitionsWidgetDraw = !!getenv("VCL_DRAW_WIDGETS_FROM_FILE");
+static bool bFileDefinitionsWidgetDraw = 
!!getenv("VCL_DRAW_WIDGETS_FROM_FILE");
 
 if (bFileDefinitionsWidgetDraw || bForce)
 {
commit 9c03d4ebd1e9ddd9657a2ff48dffc51f5c0f11f2
Author: Michael Meeks 
AuthorDate: Tue May 23 18:19:45 2023 +0100
Commit: Caolán McNamara 
CommitDate: Thu May 25 09:45:26 2023 +0200

perf: surprising to see PDF being vsprintf'd during JSDialog rendering.

Avoid some hundreds of these:

_cairo_pdf_surface_show_page
...
cairo_surface_destroy
CairoTextRender::CairoTextRender

via.

SvpCairoTextRender: :SvpCairoTextRender(SvpSalGraphics&)
SvpSalGraphics: :SvpSalGraphics()
Change-Id: Ieefb65138f7e685f09dbf4c36a2fccd39b4b05cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152168
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 28615c7c048151820b44beddf444690403ee55e6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152213
Tested-by: Jenkins

diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index e9a85739827b..70ae0dceccc4 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -29,11 +29,6 @@ typedef struct _cairo_font_options cairo_font_options_t;
 
 class VCL_DLLPUBLIC CairoTextRender : public FreeTypeTextRenderImpl
 {
-private:
-// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
-// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo
-// surfaces font_options, but that's private, so tricky to achieve
-cairo_font_options_t*   mpRoundGlyphPosOffOptions;
 protected:
 virtual cairo_t*getCairoContext() = 0;
 virtual voidgetSurfaceOffset(double& nDX, double& nDY) = 0;
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index 612bf49ff6d0..0a10f6708faf 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -131,34 +131,56 @@ extern "C"
 }
 #endif
 
-CairoTextRender::CairoTextRender()
-{
-// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
-// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo surfaces
-// font_options when trying subpixel rendering, but that's a private
-// feature of cairo_font_options_t, so tricky to achieve. Hack this by
-// getting the font options of a backend known to set this private feature
-// to CAIRO_ROUND_GLYPH_POS_OFF and then set to defaults the public
-// features and the result can be merged with new font options to set
-// CAIRO_ROUND_GLYPH_POS_OFF in those
-mpRoundGlyphPosOffOptions = cairo_font_options_create();
+namespace {
+struct CairoFontOptions
+{
+// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
+// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo
+// surfaces font_options, but that's private, so tricky to achieve
+cairo_font_options_t* mpRoundGlyphPosOffOptions;
+
+CairoFontOptions()
+{
+// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
+// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo 
surfaces
+// font_options when trying subpixel rendering, but that's a 
private
+// feature of cairo_font_options_t, so tricky to achieve. Hack 
this by
+// getting the font options of a backend known to set this private 
feature
+// to CAIRO_ROUND_GLYPH_POS_OFF and then set to defaults the public
+// features and the result can be merged with new 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - vcl/source

2023-05-24 Thread Michael Meeks (via logerrit)
 vcl/source/gdi/salgdilayout.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 127a7b263c4a45c1570f21080022f79099c5c3e6
Author: Michael Meeks 
AuthorDate: Tue May 23 18:19:18 2023 +0100
Commit: Caolán McNamara 
CommitDate: Wed May 24 20:38:54 2023 +0200

perf: surprising to see getenv on a profile.

Change-Id: Id97c77d4c836e4f3c5a9eff6da07eb52d29248c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152167
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 91419779d871..a219ce89e5c6 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -62,7 +62,7 @@ SalGraphics::SalGraphics()
 
 bool SalGraphics::initWidgetDrawBackends(bool bForce)
 {
-bool bFileDefinitionsWidgetDraw = !!getenv("VCL_DRAW_WIDGETS_FROM_FILE");
+static bool bFileDefinitionsWidgetDraw = 
!!getenv("VCL_DRAW_WIDGETS_FROM_FILE");
 
 if (bFileDefinitionsWidgetDraw || bForce)
 {


[Libreoffice-commits] core.git: vcl/source

2023-05-23 Thread Michael Meeks (via logerrit)
 vcl/source/gdi/salgdilayout.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit b3768c69c20018febfe5161670fc44b19307bd0e
Author: Michael Meeks 
AuthorDate: Tue May 23 18:19:18 2023 +0100
Commit: Michael Meeks 
CommitDate: Tue May 23 23:15:27 2023 +0200

perf: surprising to see getenv on a profile.

Change-Id: Id97c77d4c836e4f3c5a9eff6da07eb52d29248c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152105
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 7b5c11022e03..5f7baf18d71d 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -62,7 +62,7 @@ SalGraphics::SalGraphics()
 
 bool SalGraphics::initWidgetDrawBackends(bool bForce)
 {
-bool bFileDefinitionsWidgetDraw = !!getenv("VCL_DRAW_WIDGETS_FROM_FILE");
+static bool bFileDefinitionsWidgetDraw = 
!!getenv("VCL_DRAW_WIDGETS_FROM_FILE");
 
 if (bFileDefinitionsWidgetDraw || bForce)
 {


[Libreoffice-commits] core.git: vcl/inc vcl/unx

2023-05-23 Thread Michael Meeks (via logerrit)
 vcl/inc/unx/cairotextrender.hxx |4 -
 vcl/unx/generic/gdi/cairotextrender.cxx |   68 +---
 2 files changed, 45 insertions(+), 27 deletions(-)

New commits:
commit 2a1e7671795ee6c6350b7d799b9c4742ffb67e78
Author: Michael Meeks 
AuthorDate: Tue May 23 20:13:14 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue May 23 22:13:34 2023 +0200

perf: surprising to see PDF being vsprintf'd during JSDialog rendering.

Avoid some hundreds of these:

_cairo_pdf_surface_show_page
...
cairo_surface_destroy
CairoTextRender::CairoTextRender

via.

SvpCairoTextRender: :SvpCairoTextRender(SvpSalGraphics&)
SvpSalGraphics: :SvpSalGraphics()
Change-Id: Ieefb65138f7e685f09dbf4c36a2fccd39b4b05cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152173
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index 05f15d14ee27..ff0a2117811a 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -32,10 +32,6 @@ class VCL_DLLPUBLIC CairoTextRender : public 
FreeTypeTextRenderImpl
 {
 private:
 CairoCommon& mrCairoCommon;
-// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
-// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo
-// surfaces font_options, but that's private, so tricky to achieve
-cairo_font_options_t* mpRoundGlyphPosOffOptions;
 protected:
 cairo_t*getCairoContext();
 voidreleaseCairoContext(cairo_t* cr);
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index e7689c1028e1..f962c21d39ed 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -131,35 +131,57 @@ extern "C"
 }
 #endif
 
-CairoTextRender::CairoTextRender(CairoCommon& rCairoCommon)
-: mrCairoCommon(rCairoCommon)
-{
-// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
-// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo surfaces
-// font_options when trying subpixel rendering, but that's a private
-// feature of cairo_font_options_t, so tricky to achieve. Hack this by
-// getting the font options of a backend known to set this private feature
-// to CAIRO_ROUND_GLYPH_POS_OFF and then set to defaults the public
-// features and the result can be merged with new font options to set
-// CAIRO_ROUND_GLYPH_POS_OFF in those
-mpRoundGlyphPosOffOptions = cairo_font_options_create();
+namespace {
+struct CairoFontOptions
+{
+// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
+// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo
+// surfaces font_options, but that's private, so tricky to achieve
+cairo_font_options_t* mpRoundGlyphPosOffOptions;
+
+CairoFontOptions()
+{
+// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
+// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo 
surfaces
+// font_options when trying subpixel rendering, but that's a 
private
+// feature of cairo_font_options_t, so tricky to achieve. Hack 
this by
+// getting the font options of a backend known to set this private 
feature
+// to CAIRO_ROUND_GLYPH_POS_OFF and then set to defaults the public
+// features and the result can be merged with new font options to 
set
+// CAIRO_ROUND_GLYPH_POS_OFF in those
+mpRoundGlyphPosOffOptions = cairo_font_options_create();
 #if defined(CAIRO_HAS_SVG_SURFACE)
-// svg, pdf and ps backends have CAIRO_ROUND_GLYPH_POS_OFF by default
-cairo_surface_t* hack = cairo_svg_surface_create(nullptr, 1, 1);
+// svg, pdf and ps backends have CAIRO_ROUND_GLYPH_POS_OFF by 
default
+cairo_surface_t* hack = cairo_svg_surface_create(nullptr, 1, 1);
 #elif defined(CAIRO_HAS_PDF_SURFACE)
-cairo_surface_t* hack = cairo_pdf_surface_create(nullptr, 1, 1);
+cairo_surface_t* hack = cairo_pdf_surface_create(nullptr, 1, 1);
 #endif
-cairo_surface_get_font_options(hack, mpRoundGlyphPosOffOptions);
-cairo_surface_destroy(hack);
-cairo_font_options_set_antialias(mpRoundGlyphPosOffOptions, 
CAIRO_ANTIALIAS_DEFAULT);
-cairo_font_options_set_subpixel_order(mpRoundGlyphPosOffOptions, 
CAIRO_SUBPIXEL_ORDER_DEFAULT);
-cairo_font_options_set_hint_style(mpRoundGlyphPosOffOptions, 
CAIRO_HINT_STYLE_DEFAULT);
-cairo_font_options_set_hint_metrics(mpRoundGlyphPosOffOptions, 
CAIRO_HINT_METRICS_DEFAULT);
+cairo_surface_get_font_options(hack, mpRoundGlyphPosOffOptions);
+cairo_surface_destroy(hack);
+cairo_font_options_set_antialias(mpRoundGlyphPosOffOptions, 
CAIRO_ANTIALIAS_DEFAULT);
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - vcl/inc vcl/unx

2023-05-23 Thread Michael Meeks (via logerrit)
 vcl/inc/unx/cairotextrender.hxx |5 --
 vcl/unx/generic/gdi/cairotextrender.cxx |   66 +---
 2 files changed, 44 insertions(+), 27 deletions(-)

New commits:
commit 28615c7c048151820b44beddf444690403ee55e6
Author: Michael Meeks 
AuthorDate: Tue May 23 18:19:45 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue May 23 21:15:29 2023 +0200

perf: surprising to see PDF being vsprintf'd during JSDialog rendering.

Avoid some hundreds of these:

_cairo_pdf_surface_show_page
...
cairo_surface_destroy
CairoTextRender::CairoTextRender

via.

SvpCairoTextRender: :SvpCairoTextRender(SvpSalGraphics&)
SvpSalGraphics: :SvpSalGraphics()
Change-Id: Ieefb65138f7e685f09dbf4c36a2fccd39b4b05cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152168
Tested-by: Jenkins CollaboraOffice 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx
index e9a85739827b..70ae0dceccc4 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -29,11 +29,6 @@ typedef struct _cairo_font_options cairo_font_options_t;
 
 class VCL_DLLPUBLIC CairoTextRender : public FreeTypeTextRenderImpl
 {
-private:
-// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
-// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo
-// surfaces font_options, but that's private, so tricky to achieve
-cairo_font_options_t*   mpRoundGlyphPosOffOptions;
 protected:
 virtual cairo_t*getCairoContext() = 0;
 virtual voidgetSurfaceOffset(double& nDX, double& nDY) = 0;
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index 612bf49ff6d0..0a10f6708faf 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -131,34 +131,56 @@ extern "C"
 }
 #endif
 
-CairoTextRender::CairoTextRender()
-{
-// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
-// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo surfaces
-// font_options when trying subpixel rendering, but that's a private
-// feature of cairo_font_options_t, so tricky to achieve. Hack this by
-// getting the font options of a backend known to set this private feature
-// to CAIRO_ROUND_GLYPH_POS_OFF and then set to defaults the public
-// features and the result can be merged with new font options to set
-// CAIRO_ROUND_GLYPH_POS_OFF in those
-mpRoundGlyphPosOffOptions = cairo_font_options_create();
+namespace {
+struct CairoFontOptions
+{
+// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
+// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo
+// surfaces font_options, but that's private, so tricky to achieve
+cairo_font_options_t* mpRoundGlyphPosOffOptions;
+
+CairoFontOptions()
+{
+// https://gitlab.freedesktop.org/cairo/cairo/-/merge_requests/235
+// I don't want to have CAIRO_ROUND_GLYPH_POS_ON set in the cairo 
surfaces
+// font_options when trying subpixel rendering, but that's a 
private
+// feature of cairo_font_options_t, so tricky to achieve. Hack 
this by
+// getting the font options of a backend known to set this private 
feature
+// to CAIRO_ROUND_GLYPH_POS_OFF and then set to defaults the public
+// features and the result can be merged with new font options to 
set
+// CAIRO_ROUND_GLYPH_POS_OFF in those
+mpRoundGlyphPosOffOptions = cairo_font_options_create();
 #if defined(CAIRO_HAS_SVG_SURFACE)
-// svg, pdf and ps backends have CAIRO_ROUND_GLYPH_POS_OFF by default
-cairo_surface_t* hack = cairo_svg_surface_create(nullptr, 1, 1);
+// svg, pdf and ps backends have CAIRO_ROUND_GLYPH_POS_OFF by 
default
+cairo_surface_t* hack = cairo_svg_surface_create(nullptr, 1, 1);
 #elif defined(CAIRO_HAS_PDF_SURFACE)
-cairo_surface_t* hack = cairo_pdf_surface_create(nullptr, 1, 1);
+cairo_surface_t* hack = cairo_pdf_surface_create(nullptr, 1, 1);
 #endif
-cairo_surface_get_font_options(hack, mpRoundGlyphPosOffOptions);
-cairo_surface_destroy(hack);
-cairo_font_options_set_antialias(mpRoundGlyphPosOffOptions, 
CAIRO_ANTIALIAS_DEFAULT);
-cairo_font_options_set_subpixel_order(mpRoundGlyphPosOffOptions, 
CAIRO_SUBPIXEL_ORDER_DEFAULT);
-cairo_font_options_set_hint_style(mpRoundGlyphPosOffOptions, 
CAIRO_HINT_STYLE_DEFAULT);
-cairo_font_options_set_hint_metrics(mpRoundGlyphPosOffOptions, 
CAIRO_HINT_METRICS_DEFAULT);
+cairo_surface_get_font_options(hack, mpRoundGlyphPosOffOptions);
+cairo_surface_destroy(hack);
+cairo_font_options_set_antialias(mpRoundGlyphPosOffOptions, 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/source

2023-05-17 Thread Michael Meeks (via logerrit)
 sw/source/core/layout/layact.cxx |1 +
 sw/source/core/view/viewsh.cxx   |4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit ab2e73d33addd6a4cf489597cb2a7b6a401d15c6
Author: Michael Meeks 
AuthorDate: Fri Mar 24 17:42:40 2023 +
Commit: Caolán McNamara 
CommitDate: Wed May 17 18:01:24 2023 +0200

lok: avoid painting writer windows to a giant virtual-device.

When layout changes, we don't want to immediately redraw lots of
windows; we should be able to wait for tiles to be rendered
instead. Certainly we don't want to allocate a giant virtual
device.

Unfortunately we also believe that full document invalidations
are cheap - so warn about that.

Change-Id: Ib56320d4860c4b6f4e100b30cc6d3e490a1c7a90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150117
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 81c3a588c363..4277b6e6c3a3 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -2338,6 +2338,7 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
 bool bUnlock = false;
 if ( pViewImp->HasPaintRegion() )
 {
+SAL_INFO("sw.idle", "Disappointing full document 
invalidation");
 pViewImp->DeletePaintRegion();
 
 // Cause a repaint with virtual device.
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 7c4b55729ca7..30218dceead1 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -468,7 +468,7 @@ void SwViewShell::ImplStartAction()
 
 void SwViewShell::ImplLockPaint()
 {
-if ( GetWin() && GetWin()->IsVisible() )
+if ( GetWin() && GetWin()->IsVisible() && 
!comphelper::LibreOfficeKit::isActive())
 GetWin()->EnablePaint( false ); //Also cut off the controls.
 Imp()->LockPaint();
 }
@@ -478,7 +478,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
 CurrShell aCurr( this );
 if ( GetWin() && GetWin()->IsVisible() )
 {
-if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
+if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() && 
!comphelper::LibreOfficeKit::isActive())
 {
 //Refresh with virtual device to avoid flickering.
 VclPtrInstance pVout( *mpOut );


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sw/source

2023-05-16 Thread Michael Meeks (via logerrit)
 sw/source/core/layout/layact.cxx |1 +
 sw/source/core/view/viewsh.cxx   |4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 765cc200fd7e809d4aeca9bc83fa125ee248fce9
Author: Michael Meeks 
AuthorDate: Fri Mar 24 17:42:40 2023 +
Commit: Caolán McNamara 
CommitDate: Wed May 17 00:37:45 2023 +0200

lok: avoid painting writer windows to a giant virtual-device.

When layout changes, we don't want to immediately redraw lots of
windows; we should be able to wait for tiles to be rendered
instead. Certainly we don't want to allocate a giant virtual
device.

Unfortunately we also believe that full document invalidations
are cheap - so warn about that.

Change-Id: Ib56320d4860c4b6f4e100b30cc6d3e490a1c7a90
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149601
Tested-by: Jenkins
(cherry picked from commit 1ed50bb714b8ed657cd422df850a6852cd863f43)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149622
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 583ca4a3b4db..be803a3b00c1 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -2352,6 +2352,7 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
 bool bUnlock = false;
 if ( pViewImp->HasPaintRegion() )
 {
+SAL_INFO("sw.idle", "Disappointing full document 
invalidation");
 pViewImp->DeletePaintRegion();
 
 // Cause a repaint with virtual device.
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 8a99aa5de310..53457942749f 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -475,7 +475,7 @@ void SwViewShell::ImplStartAction()
 
 void SwViewShell::ImplLockPaint()
 {
-if ( GetWin() && GetWin()->IsVisible() )
+if ( GetWin() && GetWin()->IsVisible() && 
!comphelper::LibreOfficeKit::isActive())
 GetWin()->EnablePaint( false ); //Also cut off the controls.
 Imp()->LockPaint();
 }
@@ -485,7 +485,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
 CurrShell aCurr( this );
 if ( GetWin() && GetWin()->IsVisible() )
 {
-if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
+if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() && 
!comphelper::LibreOfficeKit::isActive())
 {
 //Refresh with virtual device to avoid flickering.
 VclPtrInstance pVout( *mpOut );


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - include/vcl vcl/source

2023-05-08 Thread Michael Meeks (via logerrit)
 include/vcl/BinaryDataContainer.hxx|   15 ++-
 include/vcl/gfxlink.hxx|3 
 vcl/source/gdi/impgraph.cxx|5 +
 vcl/source/graphic/BinaryDataContainer.cxx |  121 +
 4 files changed, 127 insertions(+), 17 deletions(-)

New commits:
commit 3200e73aee4b954ddf4fa1b017efc871a9c08f28
Author: Michael Meeks 
AuthorDate: Mon Apr 3 09:34:54 2023 +0100
Commit: Tomaž Vajngerl 
CommitDate: Mon May 8 08:32:36 2023 +0200

BinaryDataContainer swap out implementation.

We can easily accumulate a large number of in-memory graphic
objects, and swapping these as well as the un-compressed
images can become important.

For now we swap out the container when the image is swapped
out, however it seems unlikely it will ever need to be swapped
in again.

Despite the shared pImpl, we retained the reference counting
on the underling vector to keep this immutable while we hand
out a MemoryStream reference to it.

Change-Id: Ib7ca45afb8499460b1852461f7c11afca3f3cdfa
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151436
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index 3e5b4395a61a..4011c8685487 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -13,6 +13,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -26,9 +27,11 @@
  */
 class VCL_DLLPUBLIC BinaryDataContainer final
 {
-private:
-// the binary data
-std::shared_ptr> mpData;
+struct Impl;
+
+std::shared_ptr mpImpl;
+
+void ensureSwappedIn() const;
 
 public:
 BinaryDataContainer() = default;
@@ -53,6 +56,12 @@ public:
 /// writes the contents to the given stream
 std::size_t writeToStream(SvStream& rStream) const;
 
+/// return the in-memory size in bytes as of now.
+std::size_t getSizeBytes() const;
+
+/// swap out to disk for now
+void swapOut() const;
+
 size_t calculateHash() const;
 };
 
diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx
index 8c0f5fd32b05..531633b3f738 100644
--- a/include/vcl/gfxlink.hxx
+++ b/include/vcl/gfxlink.hxx
@@ -85,6 +85,9 @@ public:
 sal_uInt32  GetDataSize() const { return 
maDataContainer.getSize(); }
 const sal_uInt8*GetData() const;
 
+/// return the in-memory size as of now.
+size_t  getSizeBytes() const { return 
maDataContainer.getSizeBytes(); }
+
 const BinaryDataContainer& getDataContainer() const
 {
 return maDataContainer;
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index a4569f95e200..3b06fbe94787 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1250,6 +1250,9 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream)
 break;
 }
 
+if (mpGfxLink)
+mpGfxLink->getDataContainer().swapOut();
+
 return true;
 }
 
@@ -1434,6 +1437,8 @@ void ImpGraphic::dumpState(rtl::OStringBuffer )
 rState.append(static_cast(meType));
 rState.append("\tsize:\t");
 rState.append(static_cast(mnSizeBytes));
+rState.append("\tgfxl:\t");
+rState.append(static_cast(mpGfxLink ? mpGfxLink->getSizeBytes() 
: -1));
 rState.append("\t");
 rState.append(static_cast(maSwapInfo.maSizePixel.Width()));
 rState.append("x");
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index 0eaaa75e380c..cfbd4560a8d5 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -10,20 +10,78 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+struct BinaryDataContainer::Impl
+{
+// temp file to store the data out of RAM if necessary
+std::unique_ptr mpFile;
+// the binary data
+std::shared_ptr> mpData;
+
+Impl(SvStream& stream, size_t size) { readData(stream, size); }
+
+/// Populate mpData from the stream
+void readData(SvStream& stream, size_t size)
+{
+auto pData = std::make_shared>(size);
+if (stream.ReadBytes(pData->data(), pData->size()) == size)
+mpData = std::move(pData);
+}
+
+/// ensure the data is in-RAM
+void ensureSwappedIn()
+{
+if (mpData || !mpFile)
+return;
+
+auto pStream = mpFile->GetStream(StreamMode::READ);
+pStream->Seek(0);
+readData(*pStream, pStream->remainingSize());
+
+// Horrifying data loss ...
+SAL_WARN_IF(pStream->GetError(), "vcl",
+"Inconsistent system - failed to swap image back in");
+SAL_DEBUG("Swap in: " << pStream->GetError());
+}
+
+void swapOut()
+{
+if (mpFile)
+{
+// we already have it swapped out.
+mpData.reset();
+return;

[Libreoffice-commits] core.git: include/vcl vcl/source

2023-05-05 Thread Michael Meeks (via logerrit)
 include/vcl/BinaryDataContainer.hxx|   15 ++-
 include/vcl/gfxlink.hxx|3 
 vcl/source/gdi/impgraph.cxx|5 +
 vcl/source/graphic/BinaryDataContainer.cxx |  117 +
 4 files changed, 123 insertions(+), 17 deletions(-)

New commits:
commit 0f2581204a70038ed7ca78089a9bd96d158e02c0
Author: Michael Meeks 
AuthorDate: Mon Apr 3 09:34:54 2023 +0100
Commit: Michael Meeks 
CommitDate: Fri May 5 18:47:03 2023 +0200

BinaryDataContainer swap out implementation.

We can easily accumulate a large number of in-memory graphic
objects, and swapping these as well as the un-compressed
images can become important.

For now we swap out the container when the image is swapped
out, however it seems unlikely it will ever need to be swapped
in again.

Despite the shared pImpl, we retained the reference counting
on the underling vector to keep this immutable while we hand
out a MemoryStream reference to it.

Change-Id: Ib7ca45afb8499460b1852461f7c11afca3f3cdfa
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151359
Tested-by: Jenkins

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index e9e46a04e667..f6f07f0c5ef6 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -13,6 +13,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -26,9 +27,11 @@
  */
 class VCL_DLLPUBLIC BinaryDataContainer final
 {
-private:
-// the binary data
-std::shared_ptr> mpData;
+struct Impl;
+
+std::shared_ptr mpImpl;
+
+void ensureSwappedIn() const;
 
 public:
 BinaryDataContainer() = default;
@@ -53,6 +56,12 @@ public:
 /// writes the contents to the given stream
 std::size_t writeToStream(SvStream& rStream) const;
 
+/// return the in-memory size in bytes as of now.
+std::size_t getSizeBytes() const;
+
+/// swap out to disk for now
+void swapOut() const;
+
 size_t calculateHash() const;
 };
 
diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx
index 8c0f5fd32b05..531633b3f738 100644
--- a/include/vcl/gfxlink.hxx
+++ b/include/vcl/gfxlink.hxx
@@ -85,6 +85,9 @@ public:
 sal_uInt32  GetDataSize() const { return 
maDataContainer.getSize(); }
 const sal_uInt8*GetData() const;
 
+/// return the in-memory size as of now.
+size_t  getSizeBytes() const { return 
maDataContainer.getSizeBytes(); }
+
 const BinaryDataContainer& getDataContainer() const
 {
 return maDataContainer;
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 84df1765569c..41f921228d34 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1250,6 +1250,9 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream)
 break;
 }
 
+if (mpGfxLink)
+mpGfxLink->getDataContainer().swapOut();
+
 return true;
 }
 
@@ -1431,6 +1434,8 @@ void ImpGraphic::dumpState(rtl::OStringBuffer )
 rState.append(static_cast(meType));
 rState.append("\tsize:\t");
 rState.append(static_cast(mnSizeBytes));
+rState.append("\tgfxl:\t");
+rState.append(static_cast(mpGfxLink ? mpGfxLink->getSizeBytes() 
: -1));
 rState.append("\t");
 rState.append(static_cast(maSwapInfo.maSizePixel.Width()));
 rState.append("x");
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index b35195b7d27e..f395497f9449 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -10,21 +10,76 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+struct BinaryDataContainer::Impl
+{
+// temp file to store the data out of RAM if necessary
+std::unique_ptr mpFile;
+// the binary data
+std::shared_ptr> mpData;
+
+Impl(SvStream& stream, size_t size) { readData(stream, size); }
+
+/// Populate mpData from the stream
+void readData(SvStream& stream, size_t size)
+{
+auto pData = std::make_shared>(size);
+if (stream.ReadBytes(pData->data(), pData->size()) == size)
+mpData = std::move(pData);
+}
+
+/// ensure the data is in-RAM
+void ensureSwappedIn()
+{
+if (mpData || !mpFile)
+return;
+
+auto pStream = mpFile->GetStream(StreamMode::READ);
+pStream->Seek(0);
+readData(*pStream, pStream->remainingSize());
+
+// Horrifying data loss ...
+SAL_WARN_IF(pStream->GetError(), "vcl",
+"Inconsistent system - failed to swap image back in");
+SAL_DEBUG("Swap in: " << pStream->GetError());
+}
+
+void swapOut()
+{
+if (mpFile)
+{
+// we already have it swapped out.
+mpData.reset();
+return;
+}
+
+if (!mpData || 

[Libreoffice-commits] core.git: Branch 'private/mmeeks/binarydatacache' - 4211 commits - accessibility/inc accessibility/source android/Bootstrap android/source animations/source autogen.sh avmedia/in

2023-05-02 Thread Michael Meeks (via logerrit)
Rebased ref, commits from common ancestor:
commit fec9070133e89d7d02e20cb7f1dd8b07d3ba62a9
Author: Michael Meeks 
AuthorDate: Mon Apr 3 09:39:53 2023 +0100
Commit: Michael Meeks 
CommitDate: Mon May 1 19:22:30 2023 +0100

BinaryDataContainer swap out implementation.

We can easily accumulate a large number of in-memory graphic
objects, and swapping these as well as the un-compressed
images can become important.

Despite the shared pImpl, we retained the reference counting
on the underling vector to keep this immutable while we hand
out a MemoryStream reference to it.

Change-Id: Ib7ca45afb8499460b1852461f7c11afca3f3cdfa
Signed-off-by: Michael Meeks 

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index e178ad6c4d62..f6f07f0c5ef6 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -13,6 +13,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -26,9 +27,11 @@
  */
 class VCL_DLLPUBLIC BinaryDataContainer final
 {
-private:
-// the binary data
-std::shared_ptr> mpData;
+struct Impl;
+
+std::shared_ptr mpImpl;
+
+void ensureSwappedIn() const;
 
 public:
 BinaryDataContainer() = default;
@@ -56,6 +59,9 @@ public:
 /// return the in-memory size in bytes as of now.
 std::size_t getSizeBytes() const;
 
+/// swap out to disk for now
+void swapOut() const;
+
 size_t calculateHash() const;
 };
 
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 76598c9945e1..ce49a8e42706 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1253,6 +1253,9 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream)
 break;
 }
 
+if (mpGfxLink)
+mpGfxLink->getDataContainer().swapOut();
+
 return true;
 }
 
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index 31561d9e16e3..a99cae99e023 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -10,21 +10,75 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+struct BinaryDataContainer::Impl
+{
+// temp file to store the data out of RAM if necessary
+std::unique_ptr mpFile;
+// the binary data
+std::shared_ptr> mpData;
+
+/// Populate mpData from the stream
+void readData(SvStream& stream, size_t size)
+{
+auto pData = std::make_shared>(size);
+if (stream.ReadBytes(pData->data(), pData->size()) == size)
+mpData = std::move(pData);
+}
+
+/// ensure the data is in-RAM
+void ensureSwappedIn()
+{
+if (mpData || !mpFile)
+return;
+
+auto pStream = mpFile->GetStream(StreamMode::READ);
+pStream->Seek(0);
+readData(*pStream, pStream->remainingSize());
+
+// Horrifying data loss ...
+SAL_WARN_IF(pStream->GetError(), "vcl",
+"Inconsistent system - failed to swap image back in");
+SAL_DEBUG("Swap in: " << pStream->GetError());
+}
+
+void swapOut()
+{
+if (mpFile)
+{
+// we already have it swapped out.
+mpData.reset();
+return;
+}
+
+if (!mpData || mpData->empty())
+return;
+
+mpFile.reset(new utl::TempFileNamed());
+auto pStream = mpFile->GetStream(StreamMode::READWRITE);
+
+pStream->WriteBytes(mpData->data(), mpData->size());
+
+mpData.reset();
+}
+};
 
 BinaryDataContainer::BinaryDataContainer(SvStream& stream, size_t size)
 {
-auto pBuffer = std::make_shared>(size);
-if (stream.ReadBytes(pBuffer->data(), pBuffer->size()) == size)
-mpData = std::move(pBuffer);
+mpImpl.reset(new Impl());
+mpImpl->readData(stream, size);
 }
 
 size_t BinaryDataContainer::calculateHash() const
 {
 size_t nSeed = 0;
-if (mpData)
+if (mpImpl && mpImpl->mpData && !mpImpl->mpData->empty())
 {
 o3tl::hash_combine(nSeed, getSize());
-for (sal_uInt8 const& rByte : *mpData)
+for (sal_uInt8 const& rByte : *mpImpl->mpData)
 o3tl::hash_combine(nSeed, rByte);
 }
 return nSeed;
@@ -34,10 +88,11 @@ css::uno::Sequence 
BinaryDataContainer::getCopyAsByteSequence() const
 {
 if (isEmpty())
 return css::uno::Sequence();
+assert(mpImpl);
 
 css::uno::Sequence aData(getSize());
 
-std::copy(mpData->cbegin(), mpData->cend(), aData.getArray());
+std::copy(mpImpl->mpData->cbegin(), mpImpl->mpData->cend(), 
aData.getArray());
 
 return aData;
 }
@@ -53,10 +108,9 @@ class ReferencedMemoryStream : public SvMemoryStream
 std::shared_ptr> mpData;
 
 public:
-ReferencedMemoryStream(const std::shared_ptr>& 
rData)
-: SvMemoryStream(rData ? rData->data() : nullptr, rData ? 
rData->size() : 0,
- StreamMode::READ)
-, 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/source

2023-04-14 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   12 
 1 file changed, 12 insertions(+)

New commits:
commit d65f88621351aaa7bc753edec611619fceac110b
Author: Michael Meeks 
AuthorDate: Wed Apr 12 16:01:46 2023 +0100
Commit: Michael Meeks 
CommitDate: Fri Apr 14 10:40:56 2023 +0200

lok: trim glibc allocator's pending heap when called.

Change-Id: I8d1bda01a0e6ccff0fa868013c67c0fbbf78a836
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150299
Tested-by: Jenkins
(cherry picked from commit faa5ee1e497d6cf7bd4dbce4bf75b6231eb2387a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150315

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4caa1b034d86..20cc63231cbd 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -26,8 +26,14 @@
 #include 
 #endif
 
+#undef HAVE_MALLOC_TRIM
+
 #ifdef LINUX
 #include 
+#if defined __GLIBC__
+#  include 
+#  define HAVE_MALLOC_TRIM
+#endif
 #endif
 
 #ifdef ANDROID
@@ -3153,6 +3159,12 @@ static char* lo_extractRequest(LibreOfficeKit* 
/*pThis*/, const char* pFilePath)
 static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget)
 {
 vcl::lok::trimMemory(nTarget);
+if (nTarget > 1000)
+{
+#ifdef HAVE_MALLOC_TRIM
+malloc_trim(0);
+#endif
+}
 }
 
 static void lo_registerCallback (LibreOfficeKit* pThis,


[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source

2023-04-13 Thread Michael Meeks (via logerrit)
 include/vcl/BinaryDataContainer.hxx|6 --
 vcl/inc/pdf/ExternalPDFStreams.hxx |4 ++--
 vcl/source/filter/graphicfilter.cxx|8 
 vcl/source/graphic/BinaryDataContainer.cxx |   23 +--
 4 files changed, 31 insertions(+), 10 deletions(-)

New commits:
commit c55d5586304f23f9d8acbaffefba68a3a11c6175
Author: Michael Meeks 
AuthorDate: Sat Apr 1 16:10:33 2023 +0100
Commit: Michael Meeks 
CommitDate: Thu Apr 13 22:24:18 2023 +0200

BinaryDataContainer: hand out shared_ptr's to SvStreams.

Hide the SvMemoryStream implementation detail better - this
could be served from a file in future. Also couple lifecycle
of the SvMemoryStream to the vector backing it.

Change-Id: Ia9b28b57b8df4ce57286effd4d1753bf345fc10e
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149917
Tested-by: Jenkins

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index 2e2e5d4b6264..e9e46a04e667 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -47,8 +47,10 @@ public:
 const sal_uInt8* getData() const;
 css::uno::Sequence getCopyAsByteSequence() const;
 
-// Returns the data as a stream open for reading
-SvMemoryStream getMemoryStream();
+// Returns the data as a readonly stream open for reading
+std::shared_ptr getAsStream();
+
+/// writes the contents to the given stream
 std::size_t writeToStream(SvStream& rStream) const;
 
 size_t calculateHash() const;
diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx 
b/vcl/inc/pdf/ExternalPDFStreams.hxx
index e2ddd58b91a5..b2936f01a898 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -38,9 +38,9 @@ struct VCL_DLLPUBLIC ExternalPDFStream
 {
 if (!mpPDFDocument)
 {
-SvMemoryStream aPDFStream = maDataContainer.getMemoryStream();
+std::shared_ptr aPDFStream = 
maDataContainer.getAsStream();
 auto pPDFDocument = std::make_shared();
-if (!pPDFDocument->ReadWithPossibleFixup(aPDFStream))
+if (!pPDFDocument->ReadWithPossibleFixup(*aPDFStream))
 {
 SAL_WARN("vcl.pdfwriter",
  "PDFWriterImpl::writeReferenceXObject: reading the 
PDF document failed");
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index 53071f6dea76..e51b027be701 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -914,8 +914,8 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& 
rIStream, sal_uInt64 size
 Size aLogicSize;
 if (eLinkType == GfxLinkType::NativeGif)
 {
-SvMemoryStream 
aMemoryStream(aGraphicContent.getMemoryStream());
-bAnimated = IsGIFAnimated(aMemoryStream, aLogicSize);
+std::shared_ptr pMemoryStream = 
aGraphicContent.getAsStream();
+bAnimated = IsGIFAnimated(*pMemoryStream, aLogicSize);
 if (!pSizeHint && aLogicSize.getWidth() && 
aLogicSize.getHeight())
 {
 pSizeHint = 
@@ -954,8 +954,8 @@ ErrCode GraphicFilter::readPNG(SvStream & rStream, Graphic 
& rGraphic, GfxLinkTy
 if (auto aMSGifChunk = vcl::PngImageReader::getMicrosoftGifChunk(rStream);
 !aMSGifChunk.isEmpty())
 {
-SvMemoryStream aIStrm(aMSGifChunk.getMemoryStream());
-ImportGIF(aIStrm, rGraphic);
+std::shared_ptr pIStrm(aMSGifChunk.getAsStream());
+ImportGIF(*pIStrm, rGraphic);
 rLinkType = GfxLinkType::NativeGif;
 rpGraphicContent = aMSGifChunk;
 return aReturnCode;
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index deb676a553f9..72d9bac27940 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -42,9 +42,28 @@ css::uno::Sequence 
BinaryDataContainer::getCopyAsByteSequence() const
 return aData;
 }
 
-SvMemoryStream BinaryDataContainer::getMemoryStream()
+namespace
 {
-return SvMemoryStream(mpData ? mpData->data() : nullptr, getSize(), 
StreamMode::READ);
+/*
+ * Hold a reference on the internal state in case we swap out
+ * and free the vector while someone holds an SvStream pointer.
+ */
+class ReferencedMemoryStream : public SvMemoryStream
+{
+std::shared_ptr> mpData;
+
+public:
+ReferencedMemoryStream(const std::shared_ptr>& 
rData)
+: SvMemoryStream(rData ? rData->data() : nullptr, rData->size(), 
StreamMode::READ)
+, mpData(rData)
+{
+}
+};
+}
+
+std::shared_ptr BinaryDataContainer::getAsStream()
+{
+return std::make_shared(mpData);
 }
 
 std::size_t BinaryDataContainer::writeToStream(SvStream& rStream) const


[Libreoffice-commits] core.git: include/vcl vcl/source

2023-04-13 Thread Michael Meeks (via logerrit)
 include/vcl/BinaryDataContainer.hxx   |5 ++---
 vcl/source/gdi/vectorgraphicdata.cxx  |7 ++-
 vcl/source/graphic/BinaryDataContainer.cxx|   12 
 vcl/source/graphic/UnoBinaryDataContainer.cxx |   11 +--
 4 files changed, 17 insertions(+), 18 deletions(-)

New commits:
commit 689f0da67b063284991d758a4f0c66a305dcad37
Author: Michael Meeks 
AuthorDate: Sat Apr 1 15:06:30 2023 +0100
Commit: Michael Meeks 
CommitDate: Thu Apr 13 22:22:47 2023 +0200

BinaryDataContainer: pure re-factor - encapsulate cbegin/cend

Change-Id: Ic8dbf0afdb96a0f1be210eedfbd12ef6467dd29f
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149916
Tested-by: Jenkins

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index 0d5be69f512c..2e2e5d4b6264 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -12,6 +12,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -44,15 +45,13 @@ public:
 size_t getSize() const;
 bool isEmpty() const;
 const sal_uInt8* getData() const;
+css::uno::Sequence getCopyAsByteSequence() const;
 
 // Returns the data as a stream open for reading
 SvMemoryStream getMemoryStream();
 std::size_t writeToStream(SvStream& rStream) const;
 
 size_t calculateHash() const;
-
-auto cbegin() const { return mpData->cbegin(); }
-auto cend() const { return mpData->cend(); }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/vectorgraphicdata.cxx 
b/vcl/source/gdi/vectorgraphicdata.cxx
index d2a0aa06a682..979fd4f18ad0 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -196,11 +196,9 @@ void VectorGraphicData::ensureSequenceAndRange()
 {
 case VectorGraphicDataType::Svg:
 {
-css::uno::Sequence 
aDataSequence(maDataContainer.getSize());
-std::copy(maDataContainer.cbegin(), maDataContainer.cend(), 
aDataSequence.getArray());
+css::uno::Sequence aDataSequence = 
maDataContainer.getCopyAsByteSequence();
 const uno::Reference xInputStream(new 
comphelper::SequenceInputStream(aDataSequence));
 
-
 const uno::Reference< graphic::XSvgParser > xSvgParser = 
graphic::SvgTools::create(xContext);
 
 if (xInputStream.is())
@@ -213,8 +211,7 @@ void VectorGraphicData::ensureSequenceAndRange()
 {
 const uno::Reference< graphic::XEmfParser > xEmfParser = 
graphic::EmfTools::create(xContext);
 
-css::uno::Sequence 
aDataSequence(maDataContainer.getSize());
-std::copy(maDataContainer.cbegin(), maDataContainer.cend(), 
aDataSequence.getArray());
+css::uno::Sequence aDataSequence = 
maDataContainer.getCopyAsByteSequence();
 const uno::Reference xInputStream(new 
comphelper::SequenceInputStream(aDataSequence));
 
 if (xInputStream.is())
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index 0264fec09983..deb676a553f9 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -30,6 +30,18 @@ size_t BinaryDataContainer::calculateHash() const
 return nSeed;
 }
 
+css::uno::Sequence BinaryDataContainer::getCopyAsByteSequence() const
+{
+if (isEmpty())
+return css::uno::Sequence();
+
+css::uno::Sequence aData(getSize());
+
+std::copy(mpData->cbegin(), mpData->cend(), aData.getArray());
+
+return aData;
+}
+
 SvMemoryStream BinaryDataContainer::getMemoryStream()
 {
 return SvMemoryStream(mpData ? mpData->data() : nullptr, getSize(), 
StreamMode::READ);
diff --git a/vcl/source/graphic/UnoBinaryDataContainer.cxx 
b/vcl/source/graphic/UnoBinaryDataContainer.cxx
index 4d6a0de9f796..3fe277024a6e 100644
--- a/vcl/source/graphic/UnoBinaryDataContainer.cxx
+++ b/vcl/source/graphic/UnoBinaryDataContainer.cxx
@@ -16,16 +16,7 @@ using namespace css;
 
 css::uno::Sequence SAL_CALL 
UnoBinaryDataContainer::getCopyAsByteSequence()
 {
-if (maBinaryDataContainer.isEmpty())
-return css::uno::Sequence();
-
-size_t nSize = maBinaryDataContainer.getSize();
-
-css::uno::Sequence aData(nSize);
-
-std::copy(maBinaryDataContainer.cbegin(), maBinaryDataContainer.cend(), 
aData.getArray());
-
-return aData;
+return maBinaryDataContainer.getCopyAsByteSequence();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2023-04-13 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |   12 
 1 file changed, 12 insertions(+)

New commits:
commit 15f0fd06346618c772466993598df5fd25181202
Author: Michael Meeks 
AuthorDate: Wed Apr 12 16:01:46 2023 +0100
Commit: Michael Meeks 
CommitDate: Thu Apr 13 10:45:38 2023 +0200

lok: trim glibc allocator's pending heap when called.

Change-Id: I8d1bda01a0e6ccff0fa868013c67c0fbbf78a836
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150299
Tested-by: Jenkins

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 49d4298c7a66..a4f34cc349e8 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -26,8 +26,14 @@
 #include 
 #endif
 
+#undef HAVE_MALLOC_TRIM
+
 #ifdef LINUX
 #include 
+#if defined __GLIBC__
+#  include 
+#  define HAVE_MALLOC_TRIM
+#endif
 #endif
 
 #ifdef ANDROID
@@ -3146,6 +3152,12 @@ static char* lo_extractRequest(LibreOfficeKit* 
/*pThis*/, const char* pFilePath)
 static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget)
 {
 vcl::lok::trimMemory(nTarget);
+if (nTarget > 1000)
+{
+#ifdef HAVE_MALLOC_TRIM
+malloc_trim(0);
+#endif
+}
 }
 
 static void lo_registerCallback (LibreOfficeKit* pThis,


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - include/vcl vcl/source

2023-04-08 Thread Michael Meeks (via logerrit)
 include/vcl/BinaryDataContainer.hxx|2 +-
 vcl/source/graphic/BinaryDataContainer.cxx |   25 -
 2 files changed, 9 insertions(+), 18 deletions(-)

New commits:
commit e435da0b59789f2396ab7eac4d93aa255b02a730
Author: Michael Meeks 
AuthorDate: Sat Apr 1 21:17:15 2023 +0100
Commit: Michael Meeks 
CommitDate: Sat Apr 8 11:13:59 2023 +0200

clang-format noise to make porting to/from master easier.

Change-Id: Id2721719ff4e7713892b0b6c549b455382eca8ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150118
Tested-by: Michael Meeks 
Reviewed-by: Michael Meeks 

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index 78cb52d05f8a..3e5b4395a61a 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -51,7 +51,7 @@ public:
 std::shared_ptr getAsStream();
 
 /// writes the contents to the given stream
-std::size_t writeToStream(SvStream ) const;
+std::size_t writeToStream(SvStream& rStream) const;
 
 size_t calculateHash() const;
 };
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index c0992421223f..0eaaa75e380c 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -46,10 +46,11 @@ css::uno::Sequence 
BinaryDataContainer::getAsSequence() const
 class ReferencedMemoryStream : public SvMemoryStream
 {
 std::shared_ptr> mpData;
+
 public:
-ReferencedMemoryStream(const std::shared_ptr> 
)
-: SvMemoryStream(rData ? rData->data() : nullptr, rData->size(), 
StreamMode::READ),
-  mpData(rData)
+ReferencedMemoryStream(const std::shared_ptr>& 
rData)
+: SvMemoryStream(rData ? rData->data() : nullptr, rData->size(), 
StreamMode::READ)
+, mpData(rData)
 {
 }
 };
@@ -59,25 +60,15 @@ std::shared_ptr BinaryDataContainer::getAsStream()
 return std::make_shared(mpData);
 }
 
-std::size_t BinaryDataContainer::writeToStream(SvStream ) const
+std::size_t BinaryDataContainer::writeToStream(SvStream& rStream) const
 {
 return rStream.WriteBytes(getData(), getSize());
 }
 
-size_t BinaryDataContainer::getSize() const
-{
-return mpData ? mpData->size() : 0;
-}
-
-bool BinaryDataContainer::isEmpty() const
-{
-return !mpData || mpData->empty();
-}
+size_t BinaryDataContainer::getSize() const { return mpData ? mpData->size() : 
0; }
 
-const sal_uInt8* BinaryDataContainer::getData() const
-{
-return mpData ? mpData->data() : nullptr;
-}
+bool BinaryDataContainer::isEmpty() const { return !mpData || mpData->empty(); 
}
 
+const sal_uInt8* BinaryDataContainer::getData() const { return mpData ? 
mpData->data() : nullptr; }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2023-04-07 Thread Michael Meeks (via logerrit)
 sw/source/core/layout/layact.cxx |1 +
 sw/source/core/view/viewsh.cxx   |4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 1ed50bb714b8ed657cd422df850a6852cd863f43
Author: Michael Meeks 
AuthorDate: Fri Mar 24 17:42:40 2023 +
Commit: Michael Meeks 
CommitDate: Fri Apr 7 18:43:19 2023 +0200

lok: avoid painting writer windows to a giant virtual-device.

When layout changes, we don't want to immediately redraw lots of
windows; we should be able to wait for tiles to be rendered
instead. Certainly we don't want to allocate a giant virtual
device.

Unfortunately we also believe that full document invalidations
are cheap - so warn about that.

Change-Id: Ib56320d4860c4b6f4e100b30cc6d3e490a1c7a90
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149601
Tested-by: Jenkins

diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx
index 583ca4a3b4db..be803a3b00c1 100644
--- a/sw/source/core/layout/layact.cxx
+++ b/sw/source/core/layout/layact.cxx
@@ -2352,6 +2352,7 @@ SwLayIdle::SwLayIdle( SwRootFrame *pRt, SwViewShellImp 
*pI ) :
 bool bUnlock = false;
 if ( pViewImp->HasPaintRegion() )
 {
+SAL_INFO("sw.idle", "Disappointing full document 
invalidation");
 pViewImp->DeletePaintRegion();
 
 // Cause a repaint with virtual device.
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 73fa17fd3c55..bc0102aef06a 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -475,7 +475,7 @@ void SwViewShell::ImplStartAction()
 
 void SwViewShell::ImplLockPaint()
 {
-if ( GetWin() && GetWin()->IsVisible() )
+if ( GetWin() && GetWin()->IsVisible() && 
!comphelper::LibreOfficeKit::isActive())
 GetWin()->EnablePaint( false ); //Also cut off the controls.
 Imp()->LockPaint();
 }
@@ -485,7 +485,7 @@ void SwViewShell::ImplUnlockPaint( bool bVirDev )
 CurrShell aCurr( this );
 if ( GetWin() && GetWin()->IsVisible() )
 {
-if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() )
+if ( (bInSizeNotify || bVirDev ) && VisArea().HasArea() && 
!comphelper::LibreOfficeKit::isActive())
 {
 //Refresh with virtual device to avoid flickering.
 VclPtrInstance pVout( *mpOut );


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - libreofficekit/qa

2023-04-05 Thread Michael Meeks (via logerrit)
 libreofficekit/qa/tilebench/tilebench.cxx |   25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

New commits:
commit ab150f968a8626ec35354643079c6a11742b
Author: Michael Meeks 
AuthorDate: Fri Mar 10 22:18:39 2023 +
Commit: Michael Meeks 
CommitDate: Wed Apr 5 16:28:58 2023 +0200

tilebench: allow save after rendering, and better load fail diagnostic.

Change-Id: I24df1a42b1d3e991a430cf0ca25e9dc53b4bbff2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150048
Tested-by: Michael Meeks 
Reviewed-by: Michael Meeks 

diff --git a/libreofficekit/qa/tilebench/tilebench.cxx 
b/libreofficekit/qa/tilebench/tilebench.cxx
index 6b6dcf4056a4..382003e9ec5a 100644
--- a/libreofficekit/qa/tilebench/tilebench.cxx
+++ b/libreofficekit/qa/tilebench/tilebench.cxx
@@ -32,7 +32,7 @@ static int help( const char *error = nullptr )
 {
 if (error)
 fprintf (stderr, "Error: %s\n\n", error);
-fprintf( stderr, "Usage: tilebench  
[path to document] [--preinit] \n");
+fprintf( stderr, "Usage: tilebench  
[path to document] [--preinit] [--save ] \n");
 fprintf( stderr, "\trenders a selection of small tiles from the document, 
checksums them and times the process based on options:\n" );
 fprintf( stderr, "\t--tile\t[max parts|-1] [max tiles|-1]\n" );
 fprintf( stderr, "\t--dialog\t<.uno:Command>\n" );
@@ -579,6 +579,14 @@ int main( int argc, char* argv[] )
 mode = argv[arg++];
 }
 
+const char *saveToPath = nullptr;
+if (!strcmp (mode, "--save"))
+{
+pre_init = true;
+saveToPath = argv[arg++];
+mode = argv[arg++];
+}
+
 std::string user_url("file:///");
 user_url.append(argv[1]);
 user_url.append("../user");
@@ -598,6 +606,7 @@ int main( int argc, char* argv[] )
 const char *user_profile = nullptr;
 const char *doc_url = strdup([NSBundle mainBundle] bundleURL] 
absoluteString] stringByAppendingString:@"/test.odt"] UTF8String]);
 const char *mode = "--tile";
+const char *saveToPath = nullptr;
 #endif
 
 aTimes.emplace_back("initialization");
@@ -655,9 +664,19 @@ int main( int argc, char* argv[] )
 }
 }
 testDialog (pDocument.get(), uno_cmd);
-} else
+}
+else
 return help ("unknown parameter");
-}
+
+if (saveToPath != nullptr)
+{
+aTimes.emplace_back("save");
+pDocument->saveAs(saveToPath);
+aTimes.emplace_back();
+}
+} else
+fprintf(stderr, "Failed to load document '%s'\n",
+(doc_url ? doc_url : ""));
 
 #ifdef IOS
 Application::Quit();


[Libreoffice-commits] core.git: Branch 'private/mmeeks/swapdatacontainer' - 90 commits - avmedia/source chart2/qa chart2/source cppuhelper/source cui/source cui/uiconfig dbaccess/source desktop/qa des

2023-04-03 Thread Michael Meeks (via logerrit)
Rebased ref, commits from common ancestor:
commit 6e266e0aa3821382cb3eca38eabab53930745ed9
Author: Michael Meeks 
AuthorDate: Mon Apr 3 09:39:53 2023 +0100
Commit: Michael Meeks 
CommitDate: Mon Apr 3 15:20:32 2023 +0100

Sketch of BinaryDataContainer swap out ...

Change-Id: Ib7ca45afb8499460b1852461f7c11afca3f3cdfa

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index eb4ed13f4750..fb9150bceda3 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -56,6 +56,9 @@ public:
 /// return the in-memory size in bytes as of now.
 std::size_t getSizeBytes() const;
 
+/// swap out to disk for now
+void swapOut() const;
+
 size_t calculateHash() const;
 };
 
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 2749bd13119b..e87b639c0bcd 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1253,6 +1253,9 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream)
 break;
 }
 
+if (mpGfxLink)
+mpGfxLink->getDataContainer().swapOut();
+
 return true;
 }
 
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index 7c05144e4897..079eb2a090d0 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -73,4 +73,9 @@ bool BinaryDataContainer::isEmpty() const { return !mpData || 
mpData->empty(); }
 
 const sal_uInt8* BinaryDataContainer::getData() const { return mpData ? 
mpData->data() : nullptr; }
 
+void BinaryDataContainer::swapOut() const
+{
+// FIXME: swap out the data to disk - and force it in again in above 
methods.
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit cff31b7f57d177397642aa429a8ab4c3c579deaf
Author: Michael Meeks 
AuthorDate: Mon Apr 3 09:34:54 2023 +0100
Commit: Michael Meeks 
CommitDate: Mon Apr 3 15:04:34 2023 +0100

BinaryDataContainer: account for in-memory size of un-compressed image.

Change-Id: Ia86d4dda706959bb58e941e65f2b2f7fffa8dc3d

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index 3e5b4395a61a..eb4ed13f4750 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -53,6 +53,9 @@ public:
 /// writes the contents to the given stream
 std::size_t writeToStream(SvStream& rStream) const;
 
+/// return the in-memory size in bytes as of now.
+std::size_t getSizeBytes() const;
+
 size_t calculateHash() const;
 };
 
diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx
index 8c0f5fd32b05..531633b3f738 100644
--- a/include/vcl/gfxlink.hxx
+++ b/include/vcl/gfxlink.hxx
@@ -85,6 +85,9 @@ public:
 sal_uInt32  GetDataSize() const { return 
maDataContainer.getSize(); }
 const sal_uInt8*GetData() const;
 
+/// return the in-memory size as of now.
+size_t  getSizeBytes() const { return 
maDataContainer.getSizeBytes(); }
+
 const BinaryDataContainer& getDataContainer() const
 {
 return maDataContainer;
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index a4569f95e200..2749bd13119b 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -999,6 +999,9 @@ sal_uLong ImpGraphic::getSizeBytes() const
 break;
 }
 
+if (mpGfxLink)
+mnSizeBytes += mpGfxLink->getSizeBytes();
+
 return mnSizeBytes;
 }
 
@@ -1434,6 +1437,8 @@ void ImpGraphic::dumpState(rtl::OStringBuffer )
 rState.append(static_cast(meType));
 rState.append("\tsize:\t");
 rState.append(static_cast(mnSizeBytes));
+rState.append("\tgfxl:\t");
+rState.append(static_cast(mpGfxLink ? mpGfxLink->getSizeBytes() 
: -1));
 rState.append("\t");
 rState.append(static_cast(maSwapInfo.maSizePixel.Width()));
 rState.append("x");
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index 0eaaa75e380c..7c05144e4897 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -67,6 +67,8 @@ std::size_t BinaryDataContainer::writeToStream(SvStream& 
rStream) const
 
 size_t BinaryDataContainer::getSize() const { return mpData ? mpData->size() : 
0; }
 
+size_t BinaryDataContainer::getSizeBytes() const { return getSize(); }
+
 bool BinaryDataContainer::isEmpty() const { return !mpData || mpData->empty(); 
}
 
 const sal_uInt8* BinaryDataContainer::getData() const { return mpData ? 
mpData->data() : nullptr; }
commit bd1b5a3a6e9ab4201aa5dde4f6433e0bfcefbbac
Author: Michael Meeks 
AuthorDate: Sat Apr 1 21:17:15 2023 +0100
Commit: Michael Meeks 
CommitDate: Mon Apr 3 15:04:33 2023 +0100

clang-format noise to make porting to/from master easier.

Change-Id: I0df08baa9504c09d8f850ce54670dfa9671220bb

diff --git a/include/vcl/BinaryDataContainer.hxx 

[Libreoffice-commits] core.git: Changes to 'private/mmeeks/swapdatacontainer'

2023-04-03 Thread Michael Meeks (via logerrit)
New branch 'private/mmeeks/swapdatacontainer' available with the following 
commits:
commit 6674d6fb4d0035a2d4c05965a0b8f95bbd33e3fb
Author: Michael Meeks 
Date:   Mon Apr 3 09:39:53 2023 +0100

Sketch of BinaryDataContainer swap out ...

Change-Id: Ib7ca45afb8499460b1852461f7c11afca3f3cdfa

commit 9a56ece8a182b3a9c3c3660ac7855ec4372a9a88
Author: Michael Meeks 
Date:   Mon Apr 3 09:34:54 2023 +0100

BinaryDataContainer: account for in-memory size of un-compressed image.

Change-Id: Ia86d4dda706959bb58e941e65f2b2f7fffa8dc3d

commit 267a6a4c29c077ff407994f873eb9fb154509504
Author: Michael Meeks 
Date:   Sat Apr 1 21:17:15 2023 +0100

clang-format noise to make porting to/from master easier.

Change-Id: I0df08baa9504c09d8f850ce54670dfa9671220bb



[Libreoffice-commits] core.git: include/vcl svx/source vcl/inc vcl/source

2023-04-03 Thread Michael Meeks (via logerrit)
 include/vcl/BinaryDataContainer.hxx|9 +
 svx/source/xoutdev/_xoutbmp.cxx|3 +--
 vcl/inc/pdf/ExternalPDFStreams.hxx |4 +---
 vcl/source/filter/graphicfilter.cxx|   12 +++-
 vcl/source/gdi/TypeSerializer.cxx  |4 ++--
 vcl/source/gdi/impgraph.cxx|5 +
 vcl/source/graphic/BinaryDataContainer.cxx |   11 +++
 7 files changed, 24 insertions(+), 24 deletions(-)

New commits:
commit 0bd949f4412249e5ecd63716efcc55d92d120da9
Author: Michael Meeks 
AuthorDate: Sat Apr 1 12:40:58 2023 +0100
Commit: Michael Meeks 
CommitDate: Mon Apr 3 10:30:10 2023 +0200

BinaryDataContainer: pure re-factor to encapsulate stream copying.

Change-Id: Iab24e8d18bf7badbca672fbdbf455f78d08f41a0
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149905
Tested-by: Jenkins

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index e6e13cd340d8..0d5be69f512c 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -41,16 +41,17 @@ public:
 
 BinaryDataContainer& operator=(BinaryDataContainer&& rBinaryDataContainer) 
noexcept = default;
 
-size_t getSize() const { return mpData ? mpData->size() : 0; }
-bool isEmpty() const { return !mpData || mpData->empty(); }
-const sal_uInt8* getData() const { return mpData ? mpData->data() : 
nullptr; }
+size_t getSize() const;
+bool isEmpty() const;
+const sal_uInt8* getData() const;
+
 // Returns the data as a stream open for reading
 SvMemoryStream getMemoryStream();
+std::size_t writeToStream(SvStream& rStream) const;
 
 size_t calculateHash() const;
 
 auto cbegin() const { return mpData->cbegin(); }
-
 auto cend() const { return mpData->cend(); }
 };
 
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index 0f40946f429f..e095f8e200f1 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -207,8 +207,7 @@ ErrCode XOutBitmap::WriteGraphic( const Graphic& rGraphic, 
OUString& rFileName,
 
 if (pOStm)
 {
-auto& rDataContainer = 
rGraphic.getVectorGraphicData()->getBinaryDataContainer();
-pOStm->WriteBytes(rDataContainer.getData(), 
rDataContainer.getSize());
+
rGraphic.getVectorGraphicData()->getBinaryDataContainer().writeToStream(*pOStm);
 aMedium.Commit();
 
 if (!aMedium.GetError())
diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx 
b/vcl/inc/pdf/ExternalPDFStreams.hxx
index 45b15f7a74bc..e2ddd58b91a5 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -38,9 +38,7 @@ struct VCL_DLLPUBLIC ExternalPDFStream
 {
 if (!mpPDFDocument)
 {
-SvMemoryStream aPDFStream;
-aPDFStream.WriteBytes(maDataContainer.getData(), 
maDataContainer.getSize());
-aPDFStream.Seek(0);
+SvMemoryStream aPDFStream = maDataContainer.getMemoryStream();
 auto pPDFDocument = std::make_shared();
 if (!pPDFDocument->ReadWithPossibleFixup(aPDFStream))
 {
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index dc7b47598d71..53071f6dea76 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1632,9 +1632,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& 
rGraphic, std::u16string_vi
 && 
!rVectorGraphicDataPtr->getBinaryDataContainer().isEmpty()
 && !bIsEMF)
 {
-auto & aDataContainer = 
rVectorGraphicDataPtr->getBinaryDataContainer();
-rTempStm->WriteBytes(aDataContainer.getData(), 
aDataContainer.getSize());
-
+
rVectorGraphicDataPtr->getBinaryDataContainer().writeToStream(*rTempStm);
 if (rTempStm->GetError())
 {
 nStatus = ERRCODE_GRFILTER_IOERROR;
@@ -1673,9 +1671,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& 
rGraphic, std::u16string_vi
 && rVectorGraphicDataPtr->getType() == 
VectorGraphicDataType::Emf
 && 
!rVectorGraphicDataPtr->getBinaryDataContainer().isEmpty())
 {
-auto & aDataContainer = 
rVectorGraphicDataPtr->getBinaryDataContainer();
-rTempStm->WriteBytes(aDataContainer.getData(), 
aDataContainer.getSize());
-
+
rVectorGraphicDataPtr->getBinaryDataContainer().writeToStream(*rTempStm);
 if (rTempStm->GetError())
 {
 nStatus = ERRCODE_GRFILTER_IOERROR;
@@ -1743,9 +1739,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& 
rGraphic, std::u16string_vi
 && rVectorGraphicDataPtr->getType()  ==  

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - 5 commits - include/vcl sd/source svx/source vcl/inc vcl/qa vcl/source

2023-04-01 Thread Michael Meeks (via logerrit)
 include/vcl/BinaryDataContainer.hxx   |   47 +++--
 include/vcl/filter/PngImageReader.hxx |5 
 include/vcl/gfxlink.hxx   |2 
 include/vcl/graphicfilter.hxx |5 
 include/vcl/vectorgraphicdata.hxx |2 
 sd/source/ui/view/sdview3.cxx |7 -
 svx/source/xoutdev/_xoutbmp.cxx   |3 
 vcl/inc/pdf/ExternalPDFStreams.hxx|6 -
 vcl/qa/cppunit/BinaryDataContainerTest.cxx|   33 ++
 vcl/qa/cppunit/svm/svmtest.cxx|   10 -
 vcl/source/filter/graphicfilter.cxx   |  132 --
 vcl/source/filter/ieps/ieps.cxx   |   58 ---
 vcl/source/filter/ipdf/pdfcompat.cxx  |6 -
 vcl/source/filter/png/PngImageReader.cxx  |   31 ++
 vcl/source/filter/wmf/wmf.cxx |4 
 vcl/source/gdi/TypeSerializer.cxx |   13 --
 vcl/source/gdi/gfxlink.cxx|   10 -
 vcl/source/gdi/impgraph.cxx   |9 -
 vcl/source/gdi/vectorgraphicdata.cxx  |   13 --
 vcl/source/graphic/BinaryDataContainer.cxx|   67 +++--
 vcl/source/graphic/UnoBinaryDataContainer.cxx |   11 --
 21 files changed, 197 insertions(+), 277 deletions(-)

New commits:
commit 4b0bdda5be8a8c910190dd448a8e9c77f60b7359
Author: Michael Meeks 
AuthorDate: Sat Apr 1 16:10:33 2023 +0100
Commit: Michael Meeks 
CommitDate: Sat Apr 1 21:10:04 2023 +0100

BinaryDataContainer: hand out shared_ptr's to SvStreams.

Hide the SvMemoryStream implementation detail better - this
could be served from a file in future. Also couple lifecycle
of the SvMemoryStream to the vector backing it.

Change-Id: Ia9b28b57b8df4ce57286effd4d1753bf345fc10e

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
index e91ca82c7728..78cb52d05f8a 100644
--- a/include/vcl/BinaryDataContainer.hxx
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -47,8 +47,10 @@ public:
 const sal_uInt8* getData() const;
 css::uno::Sequence getAsSequence() const;
 
-// Returns the data as a stream open for reading
-SvMemoryStream getMemoryStream();
+// Returns the data as a readonly stream open for reading
+std::shared_ptr getAsStream();
+
+/// writes the contents to the given stream
 std::size_t writeToStream(SvStream ) const;
 
 size_t calculateHash() const;
diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx 
b/vcl/inc/pdf/ExternalPDFStreams.hxx
index e2ddd58b91a5..b2936f01a898 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -38,9 +38,9 @@ struct VCL_DLLPUBLIC ExternalPDFStream
 {
 if (!mpPDFDocument)
 {
-SvMemoryStream aPDFStream = maDataContainer.getMemoryStream();
+std::shared_ptr aPDFStream = 
maDataContainer.getAsStream();
 auto pPDFDocument = std::make_shared();
-if (!pPDFDocument->ReadWithPossibleFixup(aPDFStream))
+if (!pPDFDocument->ReadWithPossibleFixup(*aPDFStream))
 {
 SAL_WARN("vcl.pdfwriter",
  "PDFWriterImpl::writeReferenceXObject: reading the 
PDF document failed");
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index 80b9491da6d4..6160493c3ec0 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -914,8 +914,8 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& 
rIStream, sal_uInt64 size
 Size aLogicSize;
 if (eLinkType == GfxLinkType::NativeGif)
 {
-SvMemoryStream 
aMemoryStream(aGraphicContent.getMemoryStream());
-bAnimated = IsGIFAnimated(aMemoryStream, aLogicSize);
+std::shared_ptr pMemoryStream = 
aGraphicContent.getAsStream();
+bAnimated = IsGIFAnimated(*pMemoryStream, aLogicSize);
 if (!pSizeHint && aLogicSize.getWidth() && 
aLogicSize.getHeight())
 {
 pSizeHint = 
@@ -954,8 +954,8 @@ ErrCode GraphicFilter::readPNG(SvStream & rStream, Graphic 
& rGraphic, GfxLinkTy
 if (auto aMSGifChunk = vcl::PngImageReader::getMicrosoftGifChunk(rStream);
 !aMSGifChunk.isEmpty())
 {
-SvMemoryStream aIStrm(aMSGifChunk.getMemoryStream());
-ImportGIF(aIStrm, rGraphic);
+std::shared_ptr pIStrm(aMSGifChunk.getAsStream());
+ImportGIF(*pIStrm, rGraphic);
 rLinkType = GfxLinkType::NativeGif;
 rpGraphicContent = aMSGifChunk;
 return aReturnCode;
diff --git a/vcl/source/graphic/BinaryDataContainer.cxx 
b/vcl/source/graphic/BinaryDataContainer.cxx
index aa5a10b445a3..c0992421223f 100644
--- a/vcl/source/graphic/BinaryDataContainer.cxx
+++ b/vcl/source/graphic/BinaryDataContainer.cxx
@@ -39,9 +39,24 @@ css::uno::Sequence 
BinaryDataContainer::getAsSequence() const
 return 

[Libreoffice-commits] core.git: Changes to 'private/mmeeks/binarydatacache'

2023-04-01 Thread Michael Meeks (via logerrit)
New branch 'private/mmeeks/binarydatacache' available with the following 
commits:
commit b5aab0806e396e59471404c8f93726017fa6201c
Author: Michael Meeks 
Date:   Sat Apr 1 12:40:58 2023 +0100

BinaryDataCache: re-factor to encapsulate stream copying.

Change-Id: Iab24e8d18bf7badbca672fbdbf455f78d08f41a0

commit 70506a6b5a10c52dffdaa99dd551962822b68f48
Author: Mike Kaganski 
Date:   Wed Mar 8 02:14:11 2023 +0300

Simplify usage of BinaryDataContainer

It is always used to store data read from streams

Change-Id: I613bc446eaadf98d2b1c012002d38f23d79a40ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148450
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

commit f5c7a7ca775bec1ec855d613ecb0d502b6410621
Author: Mike Kaganski 
Date:   Tue Mar 7 09:50:11 2023 +0300

Drop VectorGraphicDataArray

Change-Id: If444317edf35d0627c6bc3a8c36ba973a8a0af8d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148371
Reviewed-by: Noel Grandin 
Tested-by: Jenkins



[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/source include/LibreOfficeKit vcl/source

2023-03-11 Thread Michael Meeks (via logerrit)
 desktop/source/lib/init.cxx |1 +
 include/LibreOfficeKit/LibreOfficeKit.h |2 +-
 vcl/source/app/svapp.cxx|4 ++--
 vcl/source/gdi/impgraph.cxx |   11 +--
 vcl/source/graphic/Manager.cxx  |3 +--
 5 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 8fd1dacbc4fdb586ea9c7bc0f405641eb3058e04
Author: Michael Meeks 
AuthorDate: Sat Mar 11 15:56:04 2023 +
Commit: Michael Meeks 
CommitDate: Sat Mar 11 21:06:00 2023 +

lok: cleanup trimMemory capability, and expand dumpState to caches.

Being able to trigger some more aggressive memory saving is
useful in for both online and mobile.

Signed-off-by: Michael Meeks 
Change-Id: If740469a59e7e1896e5952dbcd28742446c7559d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148684

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 28849bb4161e..07bb6be18fa0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2567,6 +2567,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->setOption = lo_setOption;
 m_pOfficeClass->dumpState = lo_dumpState;
 m_pOfficeClass->extractRequest = lo_extractRequest;
+m_pOfficeClass->trimMemory = lo_trimMemory;
 
 gOfficeClass = m_pOfficeClass;
 }
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 219013f6fb9f..e98ea6f47f42 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -119,7 +119,7 @@ struct _LibreOfficeKitClass
 /// @see lok::Office::setOption
 void (*setOption) (LibreOfficeKit* pThis, const char* pOption, const char* 
pValue);
 
-/// @see lok::Document::dumpState
+/// @see lok::Office::dumpState
 /// @since LibreOffice 7.5
 void (*dumpState) (LibreOfficeKit* pThis, const char* pOptions, char** 
pState);
 
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index adc98af951ef..5359ac139532 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1887,8 +1887,8 @@ void trimMemory(int nTarget)
 return;
 pSVData->dropCaches();
 vcl::graphic::Manager::get().dropCache();
-// free up any deeper dirtied thread stacks.
-comphelper::ThreadPool::getSharedOptimalPool().shutdown();
+// TODO: ideally - free up any deeper dirtied thread stacks.
+// comphelper::ThreadPool::getSharedOptimalPool().shutdown();
 }
 // else for now caches re-fill themselves as/when used.
 }
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 6011e17feb75..3b8029b362de 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1424,6 +1424,9 @@ void ImpGraphic::updateFromLoadedGraphic(const 
ImpGraphic* pGraphic)
 
 void ImpGraphic::dumpState(rtl::OStringBuffer )
 {
+if (meType == GraphicType::NONE && mnSizeBytes == 0)
+return; // uninteresting.
+
 rState.append("\n\t");
 
 if (mbSwapOut)
@@ -1433,8 +1436,12 @@ void ImpGraphic::dumpState(rtl::OStringBuffer )
 
 rState.append(static_cast(meType));
 rState.append("\tsize:\t");
-rState.append(static_cast(mnSizeBytes/1024));
-rState.append("\tkb\t");
+rState.append(static_cast(mnSizeBytes));
+rState.append("\t");
+rState.append(static_cast(maSwapInfo.maSizePixel.Width()));
+rState.append("x");
+rState.append(static_cast(maSwapInfo.maSizePixel.Height()));
+rState.append("\t");
 rState.append(static_cast(maExPrefSize.Width()));
 rState.append("x");
 rState.append(static_cast(maExPrefSize.Height()));
diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx
index 80aac3948cc6..d43a617a7272 100644
--- a/vcl/source/graphic/Manager.cxx
+++ b/vcl/source/graphic/Manager.cxx
@@ -92,7 +92,7 @@ void 
Manager::loopGraphicsAndSwapOut(std::unique_lock& rGuard, bool
 continue;
 
 sal_Int64 nCurrentGraphicSize = getGraphicSizeBytes(pEachImpGraphic);
-if (nCurrentGraphicSize > 10)
+if (nCurrentGraphicSize > 10 || bDropAll)
 {
 if (!pEachImpGraphic->mpContext)
 {
@@ -166,7 +166,6 @@ void Manager::dumpState(rtl::OStringBuffer )
 rState.append(static_cast(mnUsedSize/1024));
 rState.append("\tkb");
 
-sal_Int32 i = 0;
 for (ImpGraphic* pEachImpGraphic : m_pImpGraphicList)
 {
 pEachImpGraphic->dumpState(rState);


[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/vcl vcl/inc vcl/source

2023-03-11 Thread Michael Meeks (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 +-
 desktop/source/lib/init.cxx |8 ++
 include/LibreOfficeKit/LibreOfficeKit.h |4 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   17 +
 include/vcl/lok.hxx |4 +++
 vcl/inc/graphic/Manager.hxx |8 --
 vcl/inc/impgraph.hxx|2 +
 vcl/inc/svdata.hxx  |7 +
 vcl/source/app/svapp.cxx|   21 
 vcl/source/app/svdata.cxx   |   23 +
 vcl/source/gdi/impgraph.cxx |   25 +++
 vcl/source/graphic/Manager.cxx  |   36 +++-
 12 files changed, 149 insertions(+), 9 deletions(-)

New commits:
commit 4a4602ad7513262a6c0423f17b42791a852b7e23
Author: Michael Meeks 
AuthorDate: Fri Mar 10 10:36:22 2023 +
Commit: Michael Meeks 
CommitDate: Sat Mar 11 21:03:05 2023 +

lok: add trimMemory capability, and expand dumpState to caches.

Being able to trigger some more aggressive memory saving is
useful in for both online and mobile.

Change-Id: I9b91c9fe9eecec06c75112595deac0bfeb94c144
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148624
Tested-by: Jenkins

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 217b537fa214..a919dbcf4267 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3554,10 +3554,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(14), offsetof(struct 
_LibreOfficeKitClass, setOption));
 CPPUNIT_ASSERT_EQUAL(classOffset(15), offsetof(struct 
_LibreOfficeKitClass, dumpState));
 CPPUNIT_ASSERT_EQUAL(classOffset(16), offsetof(struct 
_LibreOfficeKitClass, extractRequest));
+CPPUNIT_ASSERT_EQUAL(classOffset(17), offsetof(struct 
_LibreOfficeKitClass, trimMemory));
 
 // When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
 // new function pointer and bump this assert for the size of the class.
-CPPUNIT_ASSERT_EQUAL(classOffset(17), sizeof(struct _LibreOfficeKitClass));
+CPPUNIT_ASSERT_EQUAL(classOffset(18), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cf23f09f1413..9722be530db2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2523,6 +2523,8 @@ static bool lo_signDocument(LibreOfficeKit* pThis,
 static char* lo_extractRequest(LibreOfficeKit* pThis,
const char* pFilePath);
 
+static void lo_trimMemory(LibreOfficeKit* pThis, int nTarget);
+
 static void lo_runLoop(LibreOfficeKit* pThis,
LibreOfficeKitPollCallback pPollCallback,
LibreOfficeKitWakeCallback pWakeCallback,
@@ -2564,6 +2566,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->setOption = lo_setOption;
 m_pOfficeClass->dumpState = lo_dumpState;
 m_pOfficeClass->extractRequest = lo_extractRequest;
+m_pOfficeClass->trimMemory = lo_trimMemory;
 
 gOfficeClass = m_pOfficeClass;
 }
@@ -3142,6 +3145,11 @@ static char* lo_extractRequest(LibreOfficeKit* 
/*pThis*/, const char* pFilePath)
 return convertOUString(result);
 }
 
+static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget)
+{
+vcl::lok::trimMemory(nTarget);
+}
+
 static void lo_registerCallback (LibreOfficeKit* pThis,
  LibreOfficeKitCallback pCallback,
  void* pData)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 3887d3d3c412..e98ea6f47f42 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -127,6 +127,10 @@ struct _LibreOfficeKitClass
  */
 char* (*extractRequest) (LibreOfficeKit* pThis,
const char* pFilePath);
+
+/// @see lok::Office::trimMemory
+/// @since LibreOffice 7.6
+void (*trimMemory) (LibreOfficeKit* pThis, int nTarget);
 };
 
 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) 
LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index d3c2e5de78aa..bc3bbb98cc10 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -1146,6 +1146,23 @@ public:
 {
 return mpThis->pClass->extractRequest(mpThis, 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/qa desktop/source include/LibreOfficeKit include/vcl vcl/inc vcl/source

2023-03-11 Thread Michael Meeks (via logerrit)
 desktop/qa/desktop_lib/test_desktop_lib.cxx |3 +-
 desktop/source/lib/init.cxx |7 +
 include/LibreOfficeKit/LibreOfficeKit.h |4 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   17 +
 include/vcl/lok.hxx |4 +++
 vcl/inc/graphic/Manager.hxx |8 --
 vcl/inc/impgraph.hxx|2 +
 vcl/inc/svdata.hxx  |7 +
 vcl/source/app/svapp.cxx|   21 
 vcl/source/app/svdata.cxx   |   23 ++
 vcl/source/gdi/impgraph.cxx |   18 ++
 vcl/source/graphic/Manager.cxx  |   35 
 12 files changed, 141 insertions(+), 8 deletions(-)

New commits:
commit e283ec533c78a231ce25cbebc2ad30fe46605497
Author: Michael Meeks 
AuthorDate: Fri Mar 10 10:36:22 2023 +
Commit: Michael Meeks 
CommitDate: Sat Mar 11 14:44:29 2023 +

lok: add trimMemory capability, and expand dumpState to caches.

Being able to trigger some more aggressive memory saving is
useful in for both online and mobile.

Change-Id: I9b91c9fe9eecec06c75112595deac0bfeb94c144
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148653

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx 
b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index e8971919475c..f74b5b5304d3 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -3559,10 +3559,11 @@ void DesktopLOKTest::testABI()
 CPPUNIT_ASSERT_EQUAL(classOffset(14), offsetof(struct 
_LibreOfficeKitClass, setOption));
 CPPUNIT_ASSERT_EQUAL(classOffset(15), offsetof(struct 
_LibreOfficeKitClass, dumpState));
 CPPUNIT_ASSERT_EQUAL(classOffset(16), offsetof(struct 
_LibreOfficeKitClass, extractRequest));
+CPPUNIT_ASSERT_EQUAL(classOffset(17), offsetof(struct 
_LibreOfficeKitClass, trimMemory));
 
 // When extending LibreOfficeKit with a new function pointer,  add new 
assert for the offsetof the
 // new function pointer and bump this assert for the size of the class.
-CPPUNIT_ASSERT_EQUAL(classOffset(17), sizeof(struct _LibreOfficeKitClass));
+CPPUNIT_ASSERT_EQUAL(classOffset(18), sizeof(struct _LibreOfficeKitClass));
 
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(0), offsetof(struct 
_LibreOfficeKitDocumentClass, destroy));
 CPPUNIT_ASSERT_EQUAL(documentClassOffset(1), offsetof(struct 
_LibreOfficeKitDocumentClass, saveAs));
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6d0a32b5a25e..28849bb4161e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2524,6 +2524,8 @@ static bool lo_signDocument(LibreOfficeKit* pThis,
 static char* lo_extractRequest(LibreOfficeKit* pThis,
const char* pFilePath);
 
+static void lo_trimMemory(LibreOfficeKit* pThis, int nTarget);
+
 static void lo_runLoop(LibreOfficeKit* pThis,
LibreOfficeKitPollCallback pPollCallback,
LibreOfficeKitWakeCallback pWakeCallback,
@@ -3143,6 +3145,11 @@ static char* lo_extractRequest(LibreOfficeKit* 
/*pThis*/, const char* pFilePath)
 return convertOUString(result);
 }
 
+static void lo_trimMemory(LibreOfficeKit* /* pThis */, int nTarget)
+{
+vcl::lok::trimMemory(nTarget);
+}
+
 static void lo_registerCallback (LibreOfficeKit* pThis,
  LibreOfficeKitCallback pCallback,
  void* pData)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 899fdc7a2cf7..219013f6fb9f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -127,6 +127,10 @@ struct _LibreOfficeKitClass
  */
 char* (*extractRequest) (LibreOfficeKit* pThis,
const char* pFilePath);
+
+/// @see lok::Office::trimMemory
+/// @since LibreOffice 7.6
+void (*trimMemory) (LibreOfficeKit* pThis, int nTarget);
 };
 
 #define LIBREOFFICEKIT_DOCUMENT_HAS(pDoc,member) 
LIBREOFFICEKIT_HAS_MEMBER(LibreOfficeKitDocumentClass,member,(pDoc)->pClass->nSize)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index d3c2e5de78aa..bc3bbb98cc10 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -1146,6 +1146,23 @@ public:
 {
 return mpThis->pClass->extractRequest(mpThis, pFilePath);
 }
+
+/**
+ * Trim memory usage.
+ *
+ * LibreOfficeKit caches lots of information from large pixmaps
+ * to view and calculation results. When a view has not been
+ * used for some time, depending on the load on memory it can
+ * be useful to free up memory.
+ *
+ * @param nTarget - a negative number means 

[Libreoffice-commits] core.git: libreofficekit/qa

2023-03-11 Thread Michael Meeks (via logerrit)
 libreofficekit/qa/tilebench/tilebench.cxx |   25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

New commits:
commit 950ad392c8e57a78a92450330a91b2f8233f038c
Author: Michael Meeks 
AuthorDate: Fri Mar 10 22:18:39 2023 +
Commit: Michael Meeks 
CommitDate: Sat Mar 11 14:40:03 2023 +

tilebench: allow save after rendering, and better load fail diagnostic.

Change-Id: I24df1a42b1d3e991a430cf0ca25e9dc53b4bbff2
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148674

diff --git a/libreofficekit/qa/tilebench/tilebench.cxx 
b/libreofficekit/qa/tilebench/tilebench.cxx
index 6b6dcf4056a4..382003e9ec5a 100644
--- a/libreofficekit/qa/tilebench/tilebench.cxx
+++ b/libreofficekit/qa/tilebench/tilebench.cxx
@@ -32,7 +32,7 @@ static int help( const char *error = nullptr )
 {
 if (error)
 fprintf (stderr, "Error: %s\n\n", error);
-fprintf( stderr, "Usage: tilebench  
[path to document] [--preinit] \n");
+fprintf( stderr, "Usage: tilebench  
[path to document] [--preinit] [--save ] \n");
 fprintf( stderr, "\trenders a selection of small tiles from the document, 
checksums them and times the process based on options:\n" );
 fprintf( stderr, "\t--tile\t[max parts|-1] [max tiles|-1]\n" );
 fprintf( stderr, "\t--dialog\t<.uno:Command>\n" );
@@ -579,6 +579,14 @@ int main( int argc, char* argv[] )
 mode = argv[arg++];
 }
 
+const char *saveToPath = nullptr;
+if (!strcmp (mode, "--save"))
+{
+pre_init = true;
+saveToPath = argv[arg++];
+mode = argv[arg++];
+}
+
 std::string user_url("file:///");
 user_url.append(argv[1]);
 user_url.append("../user");
@@ -598,6 +606,7 @@ int main( int argc, char* argv[] )
 const char *user_profile = nullptr;
 const char *doc_url = strdup([NSBundle mainBundle] bundleURL] 
absoluteString] stringByAppendingString:@"/test.odt"] UTF8String]);
 const char *mode = "--tile";
+const char *saveToPath = nullptr;
 #endif
 
 aTimes.emplace_back("initialization");
@@ -655,9 +664,19 @@ int main( int argc, char* argv[] )
 }
 }
 testDialog (pDocument.get(), uno_cmd);
-} else
+}
+else
 return help ("unknown parameter");
-}
+
+if (saveToPath != nullptr)
+{
+aTimes.emplace_back("save");
+pDocument->saveAs(saveToPath);
+aTimes.emplace_back();
+}
+} else
+fprintf(stderr, "Failed to load document '%s'\n",
+(doc_url ? doc_url : ""));
 
 #ifdef IOS
 Application::Quit();


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - desktop/source

2023-03-07 Thread Michael Meeks (via logerrit)
 desktop/source/app/app.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 5f340bbcf5916a5dc66e65a8f98aac397a26c494
Author: Michael Meeks 
AuthorDate: Sat Mar 4 21:19:08 2023 +
Commit: Andras Timar 
CommitDate: Tue Mar 7 22:45:17 2023 +

Avoid running graphics tests when in lok mode.

Best to avoid allocating and freeing 64Mb of RAM, and
burning lots of CPU doing CPU rendering on an invisible
for each document loaded through lok API.

Change-Id: I656b400159b9d6a7a9f2c79d188e3aec9b3dd0e2
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148259
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 4683f76e3295..1caad5299ff5 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -82,6 +82,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -341,6 +342,8 @@ namespace {
 
 void runGraphicsRenderTests()
 {
+if (comphelper::LibreOfficeKit::isActive())
+return;
 if (!utl::isProductVersionUpgraded(false))
 {
 return;


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - desktop/source

2023-03-07 Thread Michael Meeks (via logerrit)
 desktop/source/app/app.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 35275a42610e35f6a4250529ce01450c88b4583d
Author: Michael Meeks 
AuthorDate: Sat Mar 4 21:19:08 2023 +
Commit: Michael Meeks 
CommitDate: Tue Mar 7 08:35:36 2023 +

Avoid running graphics tests when in lok mode.

Best to avoid allocating and freeing 64Mb of RAM, and
burning lots of CPU doing CPU rendering on an invisible
for each document loaded through lok API.

Change-Id: I656b400159b9d6a7a9f2c79d188e3aec9b3dd0e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148222
Tested-by: Michael Meeks 
Reviewed-by: Michael Meeks 

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 135a5b5fdb1f..d2eb5f3e2a9b 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -81,6 +81,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -340,6 +341,8 @@ namespace {
 
 void runGraphicsRenderTests()
 {
+if (comphelper::LibreOfficeKit::isActive())
+return;
 #if !ENABLE_WASM_STRIP_PINGUSER
 if (!utl::isProductVersionUpgraded(false))
 {


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

2023-03-07 Thread Michael Meeks (via logerrit)
 desktop/source/app/app.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 5a41b0a42acac80d7c601f0899c82b9f390bff3d
Author: Michael Meeks 
AuthorDate: Sat Mar 4 21:19:08 2023 +
Commit: Michael Meeks 
CommitDate: Tue Mar 7 08:34:25 2023 +

Avoid running graphics tests when in lok mode.

Best to avoid allocating and freeing 64Mb of RAM, and
burning lots of CPU doing CPU rendering on an invisible
for each document loaded through lok API.

Change-Id: I656b400159b9d6a7a9f2c79d188e3aec9b3dd0e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148258
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 135a5b5fdb1f..d2eb5f3e2a9b 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -81,6 +81,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -340,6 +341,8 @@ namespace {
 
 void runGraphicsRenderTests()
 {
+if (comphelper::LibreOfficeKit::isActive())
+return;
 #if !ENABLE_WASM_STRIP_PINGUSER
 if (!utl::isProductVersionUpgraded(false))
 {


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sc/source

2022-12-20 Thread Michael Meeks (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 3d3f15040c7ed4f8d8e3fedf93b5042ae15b70c7
Author: Michael Meeks 
AuthorDate: Thu Dec 15 18:32:59 2022 +
Commit: Andras Timar 
CommitDate: Tue Dec 20 20:47:14 2022 +

lok: protect sc from null ScViewData.

Working hypothesis is this happens after a failed spreadsheet
load, or from a race during load.


ScModelObj::getPartInfo(int) sc/source/ui/unoobj/docuno.cxx:602
doc_getPartInfo desktop/source/lib/init.cxx:3531
...
KitSocketPoll::kitPoll(int)   coolforkit
SvpSalInstance::DoYield(bool, bool) vcl/headless/svpinst.cxx:492

Change-Id: I06870336d4e64ebfc69bce64e280821c25e1b1e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144251
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 4b6d5ff3a2a9..1b3c53213d3e 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -572,7 +572,10 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 void ScModelObj::setPart( int nPart, bool /*bAllowChangeFocus*/ )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
-ScTabView* pTabView = pViewData->GetView();
+ScTabView* pTabView = nullptr;
+
+if (pViewData)
+pTabView = pViewData->GetView();
 
 if (pTabView)
 {
@@ -599,6 +602,8 @@ int ScModelObj::getPart()
 OUString ScModelObj::getPartInfo( int nPart )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 const bool bIsVisible = pViewData->GetDocument().IsVisible(nPart);
 //FIXME: Implement IsSelected().
 const bool bIsSelected = false; 
//pViewData->GetDocument()->IsSelected(nPart);
@@ -618,6 +623,8 @@ OUString ScModelObj::getPartName( int nPart )
 {
 OUString sTabName;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 pViewData->GetDocument().GetName(nPart, sTabName);
 return sTabName;
 }
@@ -626,6 +633,8 @@ OUString ScModelObj::getPartHash( int nPart )
 {
 sal_Int64 nHashCode;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 return (pViewData->GetDocument().GetHashCode(nPart, nHashCode) ? 
OUString::number(nHashCode) : OUString());
 }
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4-4' - sc/source

2022-12-20 Thread Michael Meeks (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 0765b7cee2d60076f744fcbd9da0396ae323c0b5
Author: Michael Meeks 
AuthorDate: Thu Dec 15 18:32:59 2022 +
Commit: Caolán McNamara 
CommitDate: Tue Dec 20 09:54:20 2022 +

lok: protect sc from null ScViewData.

Working hypothesis is this happens after a failed spreadsheet
load, or from a race during load.


ScModelObj::getPartInfo(int) sc/source/ui/unoobj/docuno.cxx:602
doc_getPartInfo desktop/source/lib/init.cxx:3531
...
KitSocketPoll::kitPoll(int)   coolforkit
SvpSalInstance::DoYield(bool, bool) vcl/headless/svpinst.cxx:492

Change-Id: I06870336d4e64ebfc69bce64e280821c25e1b1e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144308
Tested-by: Jenkins
Reviewed-by: Michael Meeks 
(cherry picked from commit 39ffd246450cbf5feb68d7f5ab058b92a951066a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144433
Reviewed-by: Xisco Fauli 
(cherry picked from commit 97ad52082df46e665293c21621eab2f147db41d6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144487
Reviewed-by: Eike Rathke 
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 46933719e135..f030ff8b484f 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -571,7 +571,10 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 void ScModelObj::setPart( int nPart, bool /*bAllowChangeFocus*/ )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
-ScTabView* pTabView = pViewData->GetView();
+ScTabView* pTabView = nullptr;
+
+if (pViewData)
+pTabView = pViewData->GetView();
 
 if (pTabView)
 {
@@ -598,6 +601,8 @@ int ScModelObj::getPart()
 OUString ScModelObj::getPartInfo( int nPart )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 const bool bIsVisible = pViewData->GetDocument().IsVisible(nPart);
 //FIXME: Implement IsSelected().
 const bool bIsSelected = false; 
//pViewData->GetDocument()->IsSelected(nPart);
@@ -617,6 +622,8 @@ OUString ScModelObj::getPartName( int nPart )
 {
 OUString sTabName;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 pViewData->GetDocument().GetName(nPart, sTabName);
 return sTabName;
 }
@@ -625,6 +632,8 @@ OUString ScModelObj::getPartHash( int nPart )
 {
 sal_Int64 nHashCode;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 return (pViewData->GetDocument().GetHashCode(nPart, nHashCode) ? 
OUString::number(nHashCode) : OUString());
 }
 


[Libreoffice-commits] core.git: vcl/source

2022-12-20 Thread Michael Meeks (via logerrit)
 vcl/source/app/scheduler.cxx |   41 +++--
 1 file changed, 19 insertions(+), 22 deletions(-)

New commits:
commit 50a08d1eb47f8faeb511cec43d1f8ba12b8f27f7
Author: Michael Meeks 
AuthorDate: Mon Nov 21 17:41:58 2022 +
Commit: Noel Grandin 
CommitDate: Tue Dec 20 09:21:51 2022 +

tdf#148434 - avoid strange OS/X deadlock around AnyInput.

Apparently calling AnyInput on Mac and filtering for just input, gives
you window creation / re-sizing events which then trigger idle paint
events which then deadlock if called with the scheduler lock.

Try having a little more inefficiency and a different race for
this case to handle the Mac world.

Change-Id: I9985eaf18f8d0ba4d44e83c03746510a6ba6d664
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143046
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 251b972fe5ac..1f8f3034bc58 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -419,24 +419,6 @@ void Scheduler::CallbackTaskScheduling()
 break;
 }
 
-// tdf#148435 Apparently calling AnyInput on Mac and filtering for just input, 
gives
-// you window creation / re-sizing events which then trigger idle paint
-// events which then deadlock if called with the scheduler lock.
-// So since this is an optimisation, just don't do this on mac.
-#ifndef MACOSX
-// Delay invoking tasks with idle priorities as long as there are user 
input or repaint events
-// in the OS event queue. This will often effectively compress such events 
and repaint only
-// once at the end, improving performance in cases such as repeated 
zooming with a complex document.
-if ( pMostUrgent && pMostUrgent->mePriority >= TaskPriority::HIGH_IDLE
-&& Application::AnyInput( VclInputFlags::MOUSE | 
VclInputFlags::KEYBOARD | VclInputFlags::PAINT ))
-{
-SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks()
-<< " idle priority task " << pMostUrgent << " delayed, system 
events pending" );
-pMostUrgent = nullptr;
-nMinPeriod = 0;
-}
-#endif
-
 if (InfiniteTimeoutMs != nMinPeriod)
 SAL_INFO("vcl.schedule",
  "Calculated minimum timeout as " << nMinPeriod << " of " << 
nTasks << " tasks");
@@ -452,9 +434,6 @@ void Scheduler::CallbackTaskScheduling()
 
 comphelper::ProfileZone aZone( pTask->GetDebugName() );
 
-// prepare Scheduler object for deletion after handling
-pTask->SetDeletionFlags();
-
 assert(!pMostUrgent->mbInScheduler);
 pMostUrgent->mbInScheduler = true;
 
@@ -464,8 +443,17 @@ void Scheduler::CallbackTaskScheduling()
 rSchedCtx.mpSchedulerStack = pMostUrgent;
 rSchedCtx.mpSchedulerStackTop = pMostUrgent;
 
+bool bIsHighPriorityIdle = pMostUrgent->mePriority >= 
TaskPriority::HIGH_IDLE;
+
 // invoke the task
 Unlock();
+
+// Delay invoking tasks with idle priorities as long as there are user 
input or repaint events
+// in the OS event queue. This will often effectively compress such events 
and repaint only
+// once at the end, improving performance in cases such as repeated 
zooming with a complex document.
+bool bDelayInvoking = bIsHighPriorityIdle &&
+Application::AnyInput( VclInputFlags::MOUSE | VclInputFlags::KEYBOARD 
| VclInputFlags::PAINT );
+
 /*
 * Current policy is that scheduler tasks aren't allowed to throw an 
exception.
 * Because otherwise the exception is caught somewhere totally unrelated.
@@ -475,7 +463,16 @@ void Scheduler::CallbackTaskScheduling()
 */
 try
 {
-pTask->Invoke();
+if (bDelayInvoking)
+SAL_INFO( "vcl.schedule", tools::Time::GetSystemTicks()
+  << " idle priority task " << pTask->GetDebugName()
+  << " delayed, system events pending" );
+else
+{
+// prepare Scheduler object for deletion after handling
+pTask->SetDeletionFlags();
+pTask->Invoke();
+}
 }
 catch (css::uno::Exception&)
 {


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sc/source

2022-12-19 Thread Michael Meeks (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 97ad52082df46e665293c21621eab2f147db41d6
Author: Michael Meeks 
AuthorDate: Thu Dec 15 18:32:59 2022 +
Commit: Xisco Fauli 
CommitDate: Mon Dec 19 11:55:17 2022 +

lok: protect sc from null ScViewData.

Working hypothesis is this happens after a failed spreadsheet
load, or from a race during load.


ScModelObj::getPartInfo(int) sc/source/ui/unoobj/docuno.cxx:602
doc_getPartInfo desktop/source/lib/init.cxx:3531
...
KitSocketPoll::kitPoll(int)   coolforkit
SvpSalInstance::DoYield(bool, bool) vcl/headless/svpinst.cxx:492

Change-Id: I06870336d4e64ebfc69bce64e280821c25e1b1e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144308
Tested-by: Jenkins
Reviewed-by: Michael Meeks 
(cherry picked from commit 39ffd246450cbf5feb68d7f5ab058b92a951066a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144433
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 46933719e135..f030ff8b484f 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -571,7 +571,10 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 void ScModelObj::setPart( int nPart, bool /*bAllowChangeFocus*/ )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
-ScTabView* pTabView = pViewData->GetView();
+ScTabView* pTabView = nullptr;
+
+if (pViewData)
+pTabView = pViewData->GetView();
 
 if (pTabView)
 {
@@ -598,6 +601,8 @@ int ScModelObj::getPart()
 OUString ScModelObj::getPartInfo( int nPart )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 const bool bIsVisible = pViewData->GetDocument().IsVisible(nPart);
 //FIXME: Implement IsSelected().
 const bool bIsSelected = false; 
//pViewData->GetDocument()->IsSelected(nPart);
@@ -617,6 +622,8 @@ OUString ScModelObj::getPartName( int nPart )
 {
 OUString sTabName;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 pViewData->GetDocument().GetName(nPart, sTabName);
 return sTabName;
 }
@@ -625,6 +632,8 @@ OUString ScModelObj::getPartHash( int nPart )
 {
 sal_Int64 nHashCode;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 return (pViewData->GetDocument().GetHashCode(nPart, nHashCode) ? 
OUString::number(nHashCode) : OUString());
 }
 


[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source

2022-12-19 Thread Michael Meeks (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 4908ac8ca1145a258ca8a972f86c4baa8aaf8b1f
Author: Michael Meeks 
AuthorDate: Thu Dec 15 18:32:59 2022 +
Commit: Xisco Fauli 
CommitDate: Mon Dec 19 08:44:11 2022 +

lok: protect sc from null ScViewData.

Working hypothesis is this happens after a failed spreadsheet
load, or from a race during load.


ScModelObj::getPartInfo(int) sc/source/ui/unoobj/docuno.cxx:602
doc_getPartInfo desktop/source/lib/init.cxx:3531
...
KitSocketPoll::kitPoll(int)   coolforkit
SvpSalInstance::DoYield(bool, bool) vcl/headless/svpinst.cxx:492

Change-Id: I06870336d4e64ebfc69bce64e280821c25e1b1e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144308
Tested-by: Jenkins
Reviewed-by: Michael Meeks 
(cherry picked from commit 39ffd246450cbf5feb68d7f5ab058b92a951066a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144359
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index d3cbd98af592..9072d2824ce4 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -568,7 +568,10 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 void ScModelObj::setPart( int nPart, bool /*bAllowChangeFocus*/ )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
-ScTabView* pTabView = pViewData->GetView();
+ScTabView* pTabView = nullptr;
+
+if (pViewData)
+pTabView = pViewData->GetView();
 
 if (pTabView)
 {
@@ -595,6 +598,8 @@ int ScModelObj::getPart()
 OUString ScModelObj::getPartInfo( int nPart )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 const bool bIsVisible = pViewData->GetDocument().IsVisible(nPart);
 //FIXME: Implement IsSelected().
 const bool bIsSelected = false; 
//pViewData->GetDocument()->IsSelected(nPart);
@@ -614,6 +619,8 @@ OUString ScModelObj::getPartName( int nPart )
 {
 OUString sTabName;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 pViewData->GetDocument().GetName(nPart, sTabName);
 return sTabName;
 }
@@ -622,6 +629,8 @@ OUString ScModelObj::getPartHash( int nPart )
 {
 sal_Int64 nHashCode;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 return (pViewData->GetDocument().GetHashCode(nPart, nHashCode) ? 
OUString::number(nHashCode) : OUString());
 }
 


[Libreoffice-commits] core.git: sc/source

2022-12-16 Thread Michael Meeks (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 39ffd246450cbf5feb68d7f5ab058b92a951066a
Author: Michael Meeks 
AuthorDate: Thu Dec 15 18:32:59 2022 +
Commit: Michael Meeks 
CommitDate: Fri Dec 16 16:55:21 2022 +

lok: protect sc from null ScViewData.

Working hypothesis is this happens after a failed spreadsheet
load, or from a race during load.


ScModelObj::getPartInfo(int) sc/source/ui/unoobj/docuno.cxx:602
doc_getPartInfo desktop/source/lib/init.cxx:3531
...
KitSocketPoll::kitPoll(int)   coolforkit
SvpSalInstance::DoYield(bool, bool) vcl/headless/svpinst.cxx:492

Change-Id: I06870336d4e64ebfc69bce64e280821c25e1b1e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144308
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index d3cbd98af592..9072d2824ce4 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -568,7 +568,10 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 void ScModelObj::setPart( int nPart, bool /*bAllowChangeFocus*/ )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
-ScTabView* pTabView = pViewData->GetView();
+ScTabView* pTabView = nullptr;
+
+if (pViewData)
+pTabView = pViewData->GetView();
 
 if (pTabView)
 {
@@ -595,6 +598,8 @@ int ScModelObj::getPart()
 OUString ScModelObj::getPartInfo( int nPart )
 {
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 const bool bIsVisible = pViewData->GetDocument().IsVisible(nPart);
 //FIXME: Implement IsSelected().
 const bool bIsSelected = false; 
//pViewData->GetDocument()->IsSelected(nPart);
@@ -614,6 +619,8 @@ OUString ScModelObj::getPartName( int nPart )
 {
 OUString sTabName;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 pViewData->GetDocument().GetName(nPart, sTabName);
 return sTabName;
 }
@@ -622,6 +629,8 @@ OUString ScModelObj::getPartHash( int nPart )
 {
 sal_Int64 nHashCode;
 ScViewData* pViewData = ScDocShell::GetViewData();
+if (!pViewData)
+return OUString();
 return (pViewData->GetDocument().GetHashCode(nPart, nHashCode) ? 
OUString::number(nHashCode) : OUString());
 }
 


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - vcl/jsdialog

2022-11-28 Thread Michael Meeks (via logerrit)
 vcl/jsdialog/enabled.cxx |7 +++
 1 file changed, 7 insertions(+)

New commits:
commit d7e39e3eb50198f64d837d6b62f25a9942e9298c
Author: Michael Meeks 
AuthorDate: Fri Nov 25 19:08:38 2022 +
Commit: Michael Meeks 
CommitDate: Mon Nov 28 14:50:38 2022 +0100

jsdialog: white-list calc group/un-group & row/col metric dialogs.

They're simple dialogs, and are testd.

Change-Id: I5a34314f57e058bc66a718c1e85ed52b265752e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143308
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index dc339e469a95..d665557385a1 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -52,6 +52,13 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool 
bMobile)
 || rUIFile == u"modules/scalc/ui/datafieldoptionsdialog.ui"
 || rUIFile == u"modules/scalc/ui/insertcells.ui"
 || rUIFile == u"modules/scalc/ui/deletecells.ui"
+|| rUIFile == u"modules/scalc/ui/deletecontents.ui"
+|| rUIFile == u"modules/scalc/ui/ungroupdialog.ui"
+|| rUIFile == u"modules/scalc/ui/groupdialog.ui"
+|| rUIFile == u"modules/scalc/ui/rowheightdialog.ui"
+|| rUIFile == u"modules/scalc/ui/optimalrowheightdialog.ui"
+|| rUIFile == u"modules/scalc/ui/colwidthdialog.ui"
+|| rUIFile == u"modules/scalc/ui/optimalcolwidthdialog.ui"
 || rUIFile == u"svx/ui/fontworkgallerydialog.ui"
 || rUIFile == u"svx/ui/findreplacedialog.ui" || rUIFile == 
u"cui/ui/macroselectordialog.ui"
 || rUIFile == u"uui/ui/macrowarnmedium.ui"


[Libreoffice-commits] core.git: vcl/jsdialog

2022-11-25 Thread Michael Meeks (via logerrit)
 vcl/jsdialog/enabled.cxx |7 +++
 1 file changed, 7 insertions(+)

New commits:
commit 254e56c0c05015db1cbfd20c1e5a48703d3bd136
Author: Michael Meeks 
AuthorDate: Fri Nov 25 19:08:38 2022 +
Commit: Michael Meeks 
CommitDate: Fri Nov 25 22:15:13 2022 +0100

jsdialog: white-list calc group/un-group & row/col metric dialogs.

They're simple dialogs, and are testd.

Change-Id: I5a34314f57e058bc66a718c1e85ed52b265752e2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143262
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index 47d8e0e08df5..79960d687f14 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -52,6 +52,13 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool 
bMobile)
 || rUIFile == u"modules/scalc/ui/datafieldoptionsdialog.ui"
 || rUIFile == u"modules/scalc/ui/insertcells.ui"
 || rUIFile == u"modules/scalc/ui/deletecells.ui"
+|| rUIFile == u"modules/scalc/ui/deletecontents.ui"
+|| rUIFile == u"modules/scalc/ui/ungroupdialog.ui"
+|| rUIFile == u"modules/scalc/ui/groupdialog.ui"
+|| rUIFile == u"modules/scalc/ui/rowheightdialog.ui"
+|| rUIFile == u"modules/scalc/ui/optimalrowheightdialog.ui"
+|| rUIFile == u"modules/scalc/ui/colwidthdialog.ui"
+|| rUIFile == u"modules/scalc/ui/optimalcolwidthdialog.ui"
 || rUIFile == u"svx/ui/fontworkgallerydialog.ui"
 || rUIFile == u"svx/ui/findreplacedialog.ui" || rUIFile == 
u"svx/ui/findreplacedialog.ui"
 || rUIFile == u"cui/ui/macroselectordialog.ui" || rUIFile == 
u"uui/ui/macrowarnmedium.ui"


[Libreoffice-commits] core.git: Changes to 'private/mmeeks/macinput'

2022-11-21 Thread Michael Meeks (via logerrit)
New branch 'private/mmeeks/macinput' available with the following commits:
commit 91c43c58f0d46debbe3054c5e33f3a102a4b5a12
Author: Michael Meeks 
Date:   Mon Nov 21 17:41:58 2022 +

tdf#148435 - avoid strange OS/X deadlock around AnyInput.

Apparently calling AnyInput on Mac and filtering for just input, gives
you window creation / re-sizing events which then trigger idle paint
events which then deadlock if called with the scheduler lock.

Try having a little more inefficiency and a different race for
this case to handle the Mac world.

Change-Id: I9985eaf18f8d0ba4d44e83c03746510a6ba6d664



[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sc/source vcl/jsdialog

2022-11-02 Thread Michael Meeks (via logerrit)
 sc/source/ui/attrdlg/scdlgfact.cxx |   10 +++
 sc/source/ui/attrdlg/scdlgfact.hxx |   10 +--
 sc/source/ui/view/cellsh1.cxx  |  122 +
 vcl/jsdialog/enabled.cxx   |2 
 4 files changed, 89 insertions(+), 55 deletions(-)

New commits:
commit 66a95dec001c5db891f20ddd5005fcc496bef4f8
Author: Michael Meeks 
AuthorDate: Tue Nov 1 21:43:08 2022 +
Commit: Michael Meeks 
CommitDate: Wed Nov 2 16:48:14 2022 +0100

sc: make InsertCell and DeleteCell async.

Also enable for use with jsdialogs.

Change-Id: I378f228e86959edb98ad691089af919330dcdcec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142163
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 

diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx 
b/sc/source/ui/attrdlg/scdlgfact.cxx
index ab8741a9e8d8..7cea4669e784 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -137,6 +137,11 @@ short AbstractScDeleteCellDlg_Impl::Execute()
 return m_xDlg->run();
 }
 
+bool AbstractScDeleteCellDlg_Impl::StartExecuteAsync(AsyncContext& rCtx)
+{
+return ScDeleteCellDlg::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 //for dataform
 short AbstractScDataFormDlg_Impl::Execute()
 {
@@ -174,6 +179,11 @@ short AbstractScInsertCellDlg_Impl::Execute()
 return m_xDlg->run();
 }
 
+bool AbstractScInsertCellDlg_Impl::StartExecuteAsync(AsyncContext& rCtx)
+{
+return ScInsertCellDlg::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 short AbstractScInsertContentsDlg_Impl::Execute()
 {
 return m_xDlg->run();
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx 
b/sc/source/ui/attrdlg/scdlgfact.hxx
index b3756bb075af..e13efe7b5c93 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -218,13 +218,14 @@ public:
 
 class AbstractScDeleteCellDlg_Impl : public AbstractScDeleteCellDlg
 {
-std::unique_ptr m_xDlg;
+std::shared_ptr m_xDlg;
 public:
 explicit AbstractScDeleteCellDlg_Impl(std::unique_ptr p)
 : m_xDlg(std::move(p))
 {
 }
-virtual short   Execute() override;
+virtual short Execute() override;
+virtual bool  StartExecuteAsync(AsyncContext& rCtx) override;
 virtual DelCellCmd GetDelCellCmd() const override;
 
 // screenshotting
@@ -299,13 +300,14 @@ public:
 
 class AbstractScInsertCellDlg_Impl : public AbstractScInsertCellDlg
 {
-std::unique_ptr m_xDlg;
+std::shared_ptr m_xDlg;
 public:
 explicit AbstractScInsertCellDlg_Impl(std::unique_ptr p)
 : m_xDlg(std::move(p))
 {
 }
-virtual short   Execute() override;
+virtual short Execute() override;
+virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext ) 
override;
 virtual InsCellCmd GetInsCellCmd() const override ;
 };
 
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index edd2dac01280..dd9726bc1ee0 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -168,6 +168,60 @@ void SetTabNoAndCursor( const ScViewData& rViewData, const 
OUString& rCellId )
 pTabViewShell->SetCursor(aFoundPos.Col(), aFoundPos.Row());
 }
 }
+
+void InsertCells(ScTabViewShell* pTabViewShell, SfxRequest , InsCellCmd 
eCmd)
+{
+if (eCmd!=INS_NONE)
+{
+pTabViewShell->InsertCells( eCmd );
+
+if( ! rReq.IsAPI() )
+{
+OUString aParam;
+
+switch( eCmd )
+{
+case INS_CELLSDOWN: aParam = "V"; break;
+case INS_CELLSRIGHT: aParam = ">"; break;
+case INS_INSROWS_BEFORE: aParam = "R"; break;
+case INS_INSCOLS_BEFORE: aParam = "C"; break;
+default:
+{
+// added to avoid warnings
+}
+}
+rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
+rReq.Done();
+}
+}
+}
+
+void DeleteCells(ScTabViewShell* pTabViewShell, SfxRequest , DelCellCmd 
eCmd)
+{
+if (eCmd != DelCellCmd::NONE )
+{
+pTabViewShell->DeleteCells( eCmd );
+
+if( ! rReq.IsAPI() )
+{
+OUString aParam;
+
+switch( eCmd )
+{
+case DelCellCmd::CellsUp: aParam = "U"; break;
+case DelCellCmd::CellsLeft: aParam = "L"; break;
+case DelCellCmd::Rows: aParam = "R"; break;
+case DelCellCmd::Cols: aParam = "C"; break;
+default:
+{
+// added to avoid warnings
+}
+}
+rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
+rReq.Done();
+}
+}
+}
 }
 
 void ScCellShell::ExecuteEdit( SfxRequest& rReq )
@@ -286,35 +340,19 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
 ScAbstractDialogFactory* pFact = 
ScAbstractDialogFactory::Create();
 
-ScopedVclPtr 

[Libreoffice-commits] core.git: sc/source vcl/jsdialog

2022-11-02 Thread Michael Meeks (via logerrit)
 sc/source/ui/attrdlg/scdlgfact.cxx |   10 +++
 sc/source/ui/attrdlg/scdlgfact.hxx |   10 +--
 sc/source/ui/view/cellsh1.cxx  |  122 +
 vcl/jsdialog/enabled.cxx   |2 
 4 files changed, 89 insertions(+), 55 deletions(-)

New commits:
commit d4b5689c18f9bc10e6b552ba7f20b0af2b36d170
Author: Michael Meeks 
AuthorDate: Tue Nov 1 21:43:08 2022 +
Commit: Michael Meeks 
CommitDate: Wed Nov 2 15:19:00 2022 +0100

sc: make InsertCell and DeleteCell async.

Also enable them for use with jsdialogs.

Change-Id: I378f228e86959edb98ad691089af919330dcdcec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142144
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx 
b/sc/source/ui/attrdlg/scdlgfact.cxx
index 8b59e672ca12..722c3b8c29e4 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -137,6 +137,11 @@ short AbstractScDeleteCellDlg_Impl::Execute()
 return m_xDlg->run();
 }
 
+bool AbstractScDeleteCellDlg_Impl::StartExecuteAsync(AsyncContext& rCtx)
+{
+return ScDeleteCellDlg::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 //for dataform
 short AbstractScDataFormDlg_Impl::Execute()
 {
@@ -174,6 +179,11 @@ short AbstractScInsertCellDlg_Impl::Execute()
 return m_xDlg->run();
 }
 
+bool AbstractScInsertCellDlg_Impl::StartExecuteAsync(AsyncContext& rCtx)
+{
+return ScInsertCellDlg::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 short AbstractScInsertContentsDlg_Impl::Execute()
 {
 return m_xDlg->run();
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx 
b/sc/source/ui/attrdlg/scdlgfact.hxx
index b1703930c584..35782000b979 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -174,13 +174,14 @@ public:
 
 class AbstractScDeleteCellDlg_Impl : public AbstractScDeleteCellDlg
 {
-std::unique_ptr m_xDlg;
+std::shared_ptr m_xDlg;
 public:
 explicit AbstractScDeleteCellDlg_Impl(std::unique_ptr p)
 : m_xDlg(std::move(p))
 {
 }
-virtual short   Execute() override;
+virtual short Execute() override;
+virtual bool  StartExecuteAsync(AsyncContext& rCtx) override;
 virtual DelCellCmd GetDelCellCmd() const override;
 
 // screenshotting
@@ -255,13 +256,14 @@ public:
 
 class AbstractScInsertCellDlg_Impl : public AbstractScInsertCellDlg
 {
-std::unique_ptr m_xDlg;
+std::shared_ptr m_xDlg;
 public:
 explicit AbstractScInsertCellDlg_Impl(std::unique_ptr p)
 : m_xDlg(std::move(p))
 {
 }
-virtual short   Execute() override;
+virtual short Execute() override;
+virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext ) 
override;
 virtual InsCellCmd GetInsCellCmd() const override ;
 };
 
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index b3e03a488a6a..88c1470bc8db 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -169,6 +169,60 @@ void SetTabNoAndCursor( const ScViewData& rViewData, 
std::u16string_view rCellId
 pTabViewShell->SetCursor(aFoundPos.Col(), aFoundPos.Row());
 }
 }
+
+void InsertCells(ScTabViewShell* pTabViewShell, SfxRequest , InsCellCmd 
eCmd)
+{
+if (eCmd!=INS_NONE)
+{
+pTabViewShell->InsertCells( eCmd );
+
+if( ! rReq.IsAPI() )
+{
+OUString aParam;
+
+switch( eCmd )
+{
+case INS_CELLSDOWN: aParam = "V"; break;
+case INS_CELLSRIGHT: aParam = ">"; break;
+case INS_INSROWS_BEFORE: aParam = "R"; break;
+case INS_INSCOLS_BEFORE: aParam = "C"; break;
+default:
+{
+// added to avoid warnings
+}
+}
+rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
+rReq.Done();
+}
+}
+}
+
+void DeleteCells(ScTabViewShell* pTabViewShell, SfxRequest , DelCellCmd 
eCmd)
+{
+if (eCmd != DelCellCmd::NONE )
+{
+pTabViewShell->DeleteCells( eCmd );
+
+if( ! rReq.IsAPI() )
+{
+OUString aParam;
+
+switch( eCmd )
+{
+case DelCellCmd::CellsUp: aParam = "U"; break;
+case DelCellCmd::CellsLeft: aParam = "L"; break;
+case DelCellCmd::Rows: aParam = "R"; break;
+case DelCellCmd::Cols: aParam = "C"; break;
+default:
+{
+// added to avoid warnings
+}
+}
+rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
+rReq.Done();
+}
+}
+}
 }
 
 void ScCellShell::ExecuteEdit( SfxRequest& rReq )
@@ -287,35 +341,19 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
 ScAbstractDialogFactory* pFact = 
ScAbstractDialogFactory::Create();
 
-ScopedVclPtr 

[Libreoffice-commits] core.git: basic/source

2022-10-17 Thread Michael Meeks (via logerrit)
 basic/source/classes/sbxmod.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit da6a1a05b2b718a60d31858f19f3af8629d602a9
Author: Michael Meeks 
AuthorDate: Mon Oct 17 23:01:34 2022 +0100
Commit: Michael Meeks 
CommitDate: Tue Oct 18 01:05:59 2022 +0200

basic: s/helt/held/ and some cleanup.

Change-Id: Idebd2eef29230056caa605c79028e46d34891c44
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141485
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 8f3a56c17d7b..2766d9be6ab2 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -916,8 +916,8 @@ static void SendHint( SbxObject* pObj, SfxHintId nId, 
SbMethod* p )
 SendHint_( pObj, nId, p );
 }
 
-// #57841 Clear Uno-Objects, which were helt in RTL functions,
-// at the end of the program, so that nothing were helt.
+// #57841 Clear Uno-Objects, which were held in RTL functions,
+// at the end of the program, so that nothing is held
 static void ClearUnoObjectsInRTL_Impl_Rek( StarBASIC* pBasic )
 {
 // delete the return value of CreateUnoService
@@ -1179,8 +1179,8 @@ void SbModule::Run( SbMethod* pMeth )
 
 if( bDelInst )
 {
-// #57841 Clear Uno-Objects, which were helt in RTL functions,
-// at the end of the program, so that nothing were helt.
+// #57841 Clear Uno-Objects, which were held in RTL functions,
+// at the end of the program, so that nothing is held.
 ClearUnoObjectsInRTL_Impl( xBasic.get() );
 
 clearNativeObjectWrapperVector();
@@ -1224,8 +1224,8 @@ void SbModule::Run( SbMethod* pMeth )
 StarBASIC* pBasic = dynamic_cast( GetParent() );
 if( bDelInst )
 {
-   // #57841 Clear Uno-Objects, which were helt in RTL functions,
-   // the end of the program, so that nothing were helt.
+// #57841 Clear Uno-Objects, which were held in RTL functions,
+// the end of the program, so that nothing is held.
 ClearUnoObjectsInRTL_Impl( xBasic.get() );
 
 delete pSbData->pInst;


[Libreoffice-commits] core.git: basic/source

2022-10-17 Thread Michael Meeks (via logerrit)
 basic/source/runtime/runtime.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c0ce606701080bb93a8dff1d7e5df6006f19683a
Author: Michael Meeks 
AuthorDate: Mon Oct 17 22:44:35 2022 +0100
Commit: Michael Meeks 
CommitDate: Tue Oct 18 00:55:50 2022 +0200

basic: correct reference to method that doesn't exist.

Apparently not there in basic from prior to its open-sourcing.

Change-Id: I9b2da35abfc9971ee380c68f33e239fe63b381c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141483
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 4f77fecb56e2..6a15cb1606e6 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -4422,7 +4422,7 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 
nOp2 )
 }
 
 // 16.10.96: #31460 new concept for StepInto/Over/Out
-// see explanation at _ImplGetBreakCallLevel
+// see explanation at SbiInstance::CalcBreakCallLevel
 if( pInst->nCallLvl <= pInst->nBreakCallLvl )
 {
 StarBASIC* pStepBasic = GetCurrentBasic(  );


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - desktop/inc desktop/source include/LibreOfficeKit include/sfx2 include/test include/vcl sfx2/source vcl/source

2022-07-28 Thread Michael Meeks (via logerrit)
 desktop/inc/lib/init.hxx  |4 ++
 desktop/source/lib/init.cxx   |   55 ++
 include/LibreOfficeKit/LibreOfficeKit.h   |4 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx |   15 
 include/sfx2/lokcallback.hxx  |5 ++
 include/sfx2/lokhelper.hxx|4 ++
 include/sfx2/viewsh.hxx   |3 +
 include/test/lokcallback.hxx  |2 +
 include/vcl/lok.hxx   |3 +
 sfx2/source/view/lokhelper.cxx|   25 +
 sfx2/source/view/viewsh.cxx   |7 +++
 vcl/source/app/svapp.cxx  |   23 
 12 files changed, 149 insertions(+), 1 deletion(-)

New commits:
commit 7902e1bc3599e10830d18127a51f46b0d4e5151c
Author: Michael Meeks 
AuthorDate: Wed Jul 27 14:02:48 2022 +0100
Commit: Michael Meeks 
CommitDate: Thu Jul 28 16:22:34 2022 +0200

lok: add dumpState feature for better in-field diagnostics.

Always suspicious that some un-expected dialog / state can cause
strange behavior in a client. An initial cut at an API to make it
easier to unwind such problems by exposing the toolkit state.

Change-Id: If8f17943fa4837df4f9ca659a111dcdce5c23244
Signed-off-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137564

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index b7f3722dff1c..3ef6433ebea2 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -117,6 +118,7 @@ namespace desktop {
 virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) override;
 virtual void libreOfficeKitViewUpdatedCallback(int nType) override;
 virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId, int nSourceViewId) override;
+virtual void dumpState(rtl::OStringBuffer ) override;
 
 private:
 struct CallbackData
@@ -261,6 +263,8 @@ namespace desktop {
 {
 return (mOptionalFeatures & feature) != 0;
 }
+
+void dumpState(rtl::OStringBuffer );
 };
 
 /// Helper function to extract the value from parameters delimited by
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4ea081efefd1..04672fb1ba34 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1476,6 +1476,23 @@ void 
CallbackFlushHandler::libreOfficeKitViewUpdatedCallbackPerViewId(int nType,
 setUpdatedTypePerViewId(nType, nViewId, nSourceViewId, true);
 }
 
+void CallbackFlushHandler::dumpState(rtl::OStringBuffer )
+{
+// NB. no locking
+rState.append("\nView:\t");
+rState.append(static_cast(m_viewId));
+rState.append("\n\tDisableCallbacks:\t");
+rState.append(static_cast(m_nDisableCallbacks));
+rState.append("\n\tStates:\n");
+for (const auto  : m_states)
+{
+rState.append("\n\t\t");
+rState.append(static_cast(i.first));
+rState.append("\t");
+rState.append(i.second);
+}
+}
+
 void CallbackFlushHandler::queue(const int type, const char* data)
 {
 CallbackData callbackData(data);
@@ -2344,6 +2361,8 @@ static void lo_sendDialogEvent(LibreOfficeKit* pThis,
 
 static void lo_setOption(LibreOfficeKit* pThis, const char* pOption, const 
char* pValue);
 
+static void lo_dumpState(LibreOfficeKit* pThis, const char* pOptions, char** 
pState);
+
 LibLibreOffice_Impl::LibLibreOffice_Impl()
 : m_pOfficeClass( gOfficeClass.lock() )
 , maThread(nullptr)
@@ -2370,6 +2389,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->runLoop = lo_runLoop;
 m_pOfficeClass->sendDialogEvent = lo_sendDialogEvent;
 m_pOfficeClass->setOption = lo_setOption;
+m_pOfficeClass->dumpState = lo_dumpState;
 
 gOfficeClass = m_pOfficeClass;
 }
@@ -4184,6 +4204,41 @@ static void lo_setOption(LibreOfficeKit* /*pThis*/, 
const char *pOption, const c
 #endif
 }
 
+static void lo_dumpState (LibreOfficeKit* pThis, const char* /* pOptions */, 
char** pState)
+{
+if (!pState)
+return;
+
+// NB. no SolarMutexGuard since this may be caused in some extremis / 
deadlock
+SetLastExceptionMsg();
+
+*pState = nullptr;
+OStringBuffer aState(4096*256);
+
+LibLibreOffice_Impl* pLib = static_cast(pThis);
+
+pLib->dumpState(aState);
+
+OString aStr = aState.makeStringAndClear();
+*pState = strdup(aStr.getStr());
+}
+
+void LibLibreOffice_Impl::dumpState(rtl::OStringBuffer )
+{
+rState.append("LibreOfficeKit state:");
+rState.append("\n\tLastExceptionMsg:\t");
+rState.append(rtl::OUStringToOString(maLastExceptionMsg, 
RTL_TEXTENCODING_UTF8));
+rState.append("\n\tUnipoll:\t");
+rState.append(vcl::lok::isUnipoll() ? "yes" : "no: events on thread");
+

[Libreoffice-commits] core.git: desktop/inc desktop/source include/LibreOfficeKit include/sfx2 include/test include/vcl sfx2/source vcl/source

2022-07-28 Thread Michael Meeks (via logerrit)
 desktop/inc/lib/init.hxx  |4 ++
 desktop/source/lib/init.cxx   |   55 ++
 include/LibreOfficeKit/LibreOfficeKit.h   |4 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx |   15 
 include/sfx2/lokcallback.hxx  |5 ++
 include/sfx2/lokhelper.hxx|4 ++
 include/sfx2/viewsh.hxx   |3 +
 include/test/lokcallback.hxx  |2 +
 include/vcl/lok.hxx   |3 +
 sfx2/source/view/lokhelper.cxx|   25 +
 sfx2/source/view/viewsh.cxx   |7 +++
 vcl/source/app/svapp.cxx  |   23 
 12 files changed, 149 insertions(+), 1 deletion(-)

New commits:
commit a71a5cdb972174cb7c33e67927cd519152fd3cf6
Author: Michael Meeks 
AuthorDate: Wed Jul 27 14:02:48 2022 +0100
Commit: Michael Meeks 
CommitDate: Thu Jul 28 14:49:19 2022 +0200

lok: add dumpState feature for better in-field diagnostics.

Always suspicious that some un-expected dialog / state can cause
strange behavior in a client. An initial cut at an API to make it
easier to unwind such problems by exposing the toolkit state.

Change-Id: If8f17943fa4837df4f9ca659a111dcdce5c23244
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137504
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index c5dcea03d9fe..78c74c753063 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -117,6 +118,7 @@ namespace desktop {
 virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) override;
 virtual void libreOfficeKitViewUpdatedCallback(int nType) override;
 virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId, int nSourceViewId) override;
+virtual void dumpState(rtl::OStringBuffer ) override;
 
 private:
 struct CallbackData
@@ -261,6 +263,8 @@ namespace desktop {
 {
 return (mOptionalFeatures & feature) != 0;
 }
+
+void dumpState(rtl::OStringBuffer );
 };
 
 /// Helper function to extract the value from parameters delimited by
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c0f129fef72f..74349ace09a4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1469,6 +1469,23 @@ void 
CallbackFlushHandler::libreOfficeKitViewUpdatedCallbackPerViewId(int nType,
 setUpdatedTypePerViewId(nType, nViewId, nSourceViewId, true);
 }
 
+void CallbackFlushHandler::dumpState(rtl::OStringBuffer )
+{
+// NB. no locking
+rState.append("\nView:\t");
+rState.append(static_cast(m_viewId));
+rState.append("\n\tDisableCallbacks:\t");
+rState.append(static_cast(m_nDisableCallbacks));
+rState.append("\n\tStates:\n");
+for (const auto  : m_states)
+{
+rState.append("\n\t\t");
+rState.append(static_cast(i.first));
+rState.append("\t");
+rState.append(i.second);
+}
+}
+
 void CallbackFlushHandler::queue(const int type, const char* data)
 {
 CallbackData callbackData(data);
@@ -2337,6 +2354,8 @@ static void lo_sendDialogEvent(LibreOfficeKit* pThis,
 
 static void lo_setOption(LibreOfficeKit* pThis, const char* pOption, const 
char* pValue);
 
+static void lo_dumpState(LibreOfficeKit* pThis, const char* pOptions, char** 
pState);
+
 LibLibreOffice_Impl::LibLibreOffice_Impl()
 : m_pOfficeClass( gOfficeClass.lock() )
 , maThread(nullptr)
@@ -2363,6 +2382,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl()
 m_pOfficeClass->runLoop = lo_runLoop;
 m_pOfficeClass->sendDialogEvent = lo_sendDialogEvent;
 m_pOfficeClass->setOption = lo_setOption;
+m_pOfficeClass->dumpState = lo_dumpState;
 
 gOfficeClass = m_pOfficeClass;
 }
@@ -4159,6 +4179,41 @@ static void lo_setOption(LibreOfficeKit* /*pThis*/, 
const char *pOption, const c
 }
 }
 
+static void lo_dumpState (LibreOfficeKit* pThis, const char* /* pOptions */, 
char** pState)
+{
+if (!pState)
+return;
+
+// NB. no SolarMutexGuard since this may be caused in some extremis / 
deadlock
+SetLastExceptionMsg();
+
+*pState = nullptr;
+OStringBuffer aState(4096*256);
+
+LibLibreOffice_Impl* pLib = static_cast(pThis);
+
+pLib->dumpState(aState);
+
+OString aStr = aState.makeStringAndClear();
+*pState = strdup(aStr.getStr());
+}
+
+void LibLibreOffice_Impl::dumpState(rtl::OStringBuffer )
+{
+rState.append("LibreOfficeKit state:");
+rState.append("\n\tLastExceptionMsg:\t");
+rState.append(rtl::OUStringToOString(maLastExceptionMsg, 
RTL_TEXTENCODING_UTF8));
+rState.append("\n\tUnipoll:\t");
+rState.append(vcl::lok::isUnipoll() ? "yes" : "no: events on thread");
+

[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sc/source

2022-07-16 Thread Michael Meeks (via logerrit)
 sc/source/ui/view/gridwin4.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 679102b057377c23c3582b0a6d26e218cfd6e773
Author: Michael Meeks 
AuthorDate: Thu Jul 7 15:28:59 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat Jul 16 13:45:31 2022 +0200

lok: skip app background rendering for lok case.

this is/was mis-placed and tends to make a mess of large sheets'
tiles close to the bottom at ~2^20 rows.

Change-Id: Iac0977d58428707ff56c0ac30a7740c0ed0b27c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136866
Tested-by: Jenkins
Reviewed-by: Michael Meeks 
(cherry picked from commit a4acae686c2c55b18b5c27e832827d3c2d8e0f63)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136870
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index af87b086ca7c..42cc0781d26b 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -817,8 +817,8 @@ void ScGridWindow::DrawContent(OutputDevice , const 
ScTableInfo& rTableI
 }
 }
 
-// edge (area) (Pixel)
-if ( nX2==rDoc.MaxCol() || nY2==rDoc.MaxRow() )
+// app-background / document edge (area) (Pixel)
+if ( !bIsTiledRendering && ( nX2 == rDoc.MaxCol() || nY2 == rDoc.MaxRow() 
) )
 {
 // save MapMode and set to pixel
 MapMode aCurrentMapMode(pContentDev->GetMapMode());


[Libreoffice-commits] core.git: sc/source

2022-07-08 Thread Michael Meeks (via logerrit)
 sc/source/ui/view/gridwin4.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit a4acae686c2c55b18b5c27e832827d3c2d8e0f63
Author: Michael Meeks 
AuthorDate: Thu Jul 7 15:28:59 2022 +0100
Commit: Michael Meeks 
CommitDate: Fri Jul 8 12:25:51 2022 +0200

lok: skip app background rendering for lok case.

this is/was mis-placed and tends to make a mess of large sheets'
tiles close to the bottom at ~2^20 rows.

Change-Id: Iac0977d58428707ff56c0ac30a7740c0ed0b27c9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136866
Tested-by: Jenkins
Reviewed-by: Michael Meeks 

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index af87b086ca7c..42cc0781d26b 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -817,8 +817,8 @@ void ScGridWindow::DrawContent(OutputDevice , const 
ScTableInfo& rTableI
 }
 }
 
-// edge (area) (Pixel)
-if ( nX2==rDoc.MaxCol() || nY2==rDoc.MaxRow() )
+// app-background / document edge (area) (Pixel)
+if ( !bIsTiledRendering && ( nX2 == rDoc.MaxCol() || nY2 == rDoc.MaxRow() 
) )
 {
 // save MapMode and set to pixel
 MapMode aCurrentMapMode(pContentDev->GetMapMode());


  1   2   3   4   5   6   7   8   9   >