core.git: Branch 'distro/collabora/co-23.05' - sc/CppunitTest_sc_tiledrendering.mk sc/qa sc/source

2024-01-23 Thread Dennis Francis (via logerrit)
 sc/CppunitTest_sc_tiledrendering.mk  |1 
 sc/qa/unit/tiledrendering/data/rowheight.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   31 +++
 sc/source/ui/docshell/sizedev.cxx|4 +--
 sc/source/ui/inc/sizedev.hxx |2 -
 sc/source/ui/inc/viewfunc.hxx|2 -
 sc/source/ui/view/viewfunc.cxx   |2 -
 7 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit aabca62553513f41c4991998fbdf67de4b7d97a9
Author: Dennis Francis 
AuthorDate: Mon Jan 22 19:11:25 2024 +0530
Commit: Caolán McNamara 
CommitDate: Tue Jan 23 10:26:19 2024 +0100

lok: sc: .uno:SetOptimalRowHeight does not work correctly

because it uses ScSizeDeviceProvider uses a printer "device" with its
own PPTX, PPTY for computing the optimal height which does not match
with the tile rendering parameters.

Conflicts:
sc/qa/unit/tiledrendering/tiledrendering.cxx

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

diff --git a/sc/CppunitTest_sc_tiledrendering.mk 
b/sc/CppunitTest_sc_tiledrendering.mk
index 960e5fa67205..604c2da9f802 100644
--- a/sc/CppunitTest_sc_tiledrendering.mk
+++ b/sc/CppunitTest_sc_tiledrendering.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_tiledrendering, 
\
 $(eval $(call gb_CppunitTest_use_externals,sc_tiledrendering,\
 boost_headers \
 libxml2 \
+mdds_headers \
 ))
 
 $(eval $(call gb_CppunitTest_set_include,sc_tiledrendering,\
diff --git a/sc/qa/unit/tiledrendering/data/rowheight.ods 
b/sc/qa/unit/tiledrendering/data/rowheight.ods
new file mode 100644
index ..5f8a5278c724
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/rowheight.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 250caa5d5392..8b092c49c0d2 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using namespace css;
 
@@ -175,6 +176,7 @@ public:
 void testNoInvalidateOnSave();
 void testCellMinimalInvalidations();
 void testCellInvalidationDocWithExistingZoom();
+void testOptimalRowHeight();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -252,6 +254,7 @@ public:
 CPPUNIT_TEST(testNoInvalidateOnSave);
 CPPUNIT_TEST(testCellMinimalInvalidations);
 CPPUNIT_TEST(testCellInvalidationDocWithExistingZoom);
+CPPUNIT_TEST(testOptimalRowHeight);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3886,6 +3889,34 @@ void 
ScTiledRenderingTest::testCellInvalidationDocWithExistingZoom()
   50);
 }
 
+void ScTiledRenderingTest::testOptimalRowHeight()
+{
+ScModelObj* pModelObj = createDoc("rowheight.ods");
+CPPUNIT_ASSERT(pModelObj);
+ScDocument* pDoc = pModelObj->GetDocument();
+CPPUNIT_ASSERT(pDoc);
+
+ScTabViewShell* pView = 
dynamic_cast(SfxViewShell::Current());
+CPPUNIT_ASSERT(pView);
+
+pModelObj->setClientVisibleArea(tools::Rectangle(0, 82545, 22290, 7380));
+pModelObj->setClientZoom(256, 256, 3072, 3072);
+Scheduler::ProcessEventsToIdle();
+
+constexpr SCROW nRow = 305;
+pView->SetCursor(0, nRow);
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Before setOptimalHeight: Row#306 height is 
invalid!", sal_uInt16(300), pDoc->GetRowHeight(nRow, 0));
+
+std::vector aRowArr(1, sc::ColRowSpan(nRow, nRow));
+pView->SetWidthOrHeight(false, aRowArr, SC_SIZE_OPTIMAL, 0);
+
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_EQUAL_MESSAGE("After setOptimalHeight: Row#306 height is 
invalid!", sal_uInt16(504), pDoc->GetRowHeight(nRow, 0));
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/ui/docshell/sizedev.cxx 
b/sc/source/ui/docshell/sizedev.cxx
index c5b7e416c83c..43c9e15036de 100644
--- a/sc/source/ui/docshell/sizedev.cxx
+++ b/sc/source/ui/docshell/sizedev.cxx
@@ -25,10 +25,10 @@
 #include 
 #include 
 
-ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh )
+ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh, bool 
bForceOwnDevice )
 {
 bool bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
-if ( bTextWysiwyg )
+if ( bTextWysiwyg && !bForceOwnDevice)
 {
 pDevice = pDocSh->GetPrinter();
 bOwner = false;
diff --git a/sc/source/ui/inc/sizedev.hxx b/sc/source/ui/inc/sizedev.hxx
index 8bf98be8ef0e..52f2a9c319ad 100644
--- a/sc/source/ui/inc/sizedev.hxx
+++ b/sc/source/ui/inc/sizedev.hxx
@@ -34,7 +34,7 @@ 

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

2024-01-16 Thread Dennis Francis (via logerrit)
 sc/inc/colorscale.hxx  |   13 ++-
 sc/inc/conditio.hxx|   20 +++
 sc/source/core/data/colorscale.cxx |   37 +++--
 sc/source/core/data/conditio.cxx   |   63 +
 4 files changed, 113 insertions(+), 20 deletions(-)

New commits:
commit 516be3d680e9a18eeb7e785dc34ea5f10b3428cd
Author: Dennis Francis 
AuthorDate: Tue Oct 3 12:40:25 2023 +0530
Commit: Andras Timar 
CommitDate: Tue Jan 16 23:39:34 2024 +0100

sc: condfmt-perf: use a shared cache that...

is reset only when the data changes. Resetting is done only on
invalidation of associated ranges of data via a listener.

Earlier there were three separate caches that resets on every draw.

Change-Id: I1c185ece4b781bf6db7c82697cd5225d98c82651
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157508
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 1aa1a5340f63b31524117a3cfd6e05bee2aa1aa0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161998
Tested-by: Jenkins

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 6652e224fe67..f43f533e8f60 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -224,7 +224,7 @@ public:
 virtual ~ScColorFormat() override;
 
 const ScRangeList& GetRange() const;
-void SetCache(const std::vector& aValues);
+void SetCache(const std::vector& aValues) const;
 std::vector GetCache() const;
 
 virtual void SetParent(ScConditionalFormat* pParent) override;
@@ -240,14 +240,6 @@ protected:
 double getMaxValue() const;
 
 ScConditionalFormat* mpParent;
-
-private:
-
-struct ScColorFormatCache
-{
-std::vector maValues;
-};
-mutable std::unique_ptr mpCache;
 };
 
 typedef std::vector>> ScColorScaleEntries;
@@ -265,7 +257,10 @@ private:
 public:
 ScColorScaleFormat(ScDocument* pDoc);
 ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleFormat& rFormat);
+ScColorScaleFormat(const ScColorScaleFormat&) = delete;
 virtual ~ScColorScaleFormat() override;
+const ScColorScaleFormat& operator=(const ScColorScaleFormat&) = delete;
+
 virtual ScColorFormat* Clone(ScDocument* pDoc) const override;
 
 virtual void SetParent(ScConditionalFormat* pParent) override;
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index c3ef00e5cf93..ba5e0289bab8 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -538,6 +538,20 @@ private:
 OUString maStyleName;
 };
 
+class ScColorFormatCache final : public SvtListener
+{
+private:
+ScDocument& mrDoc;
+
+public:
+explicit ScColorFormatCache(ScDocument& rDoc, const ScRangeList& rRanges);
+virtual ~ScColorFormatCache() override;
+
+void Notify( const SfxHint& rHint ) override;
+
+std::vector maValues;
+};
+
 //  complete conditional formatting
 class SC_DLLPUBLIC ScConditionalFormat
 {
@@ -547,6 +561,8 @@ class SC_DLLPUBLIC ScConditionalFormat
 std::vector> maEntries;
 ScRangeList maRanges;// Ranges for conditional format
 
+mutable std::unique_ptr mpCache;
+
 public:
 ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument);
 ~ScConditionalFormat();
@@ -606,6 +622,10 @@ public:
 
 // Forced recalculation for formulas
 void CalcAll();
+
+void ResetCache() const;
+void SetCache(const std::vector& aValues) const;
+std::vector* GetCache() const;
 };
 
 class RepaintInIdle final : public Idle
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index eff6d050b13b..415dde5872e5 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -462,22 +462,39 @@ const ScRangeList& ScColorFormat::GetRange() const
 
 std::vector ScColorFormat::GetCache() const
 {
-std::vector empty;
-return mpCache ? mpCache->maValues : empty;
+if (!mpParent)
+return {};
+
+std::vector* pRes = mpParent->GetCache();
+if (pRes)
+return *pRes;
+
+return {};
 }
 
-void ScColorFormat::SetCache(const std::vector& aValues)
+void ScColorFormat::SetCache(const std::vector& aValues) const
 {
-mpCache.reset(new ScColorFormatCache);
-mpCache->maValues = aValues;
+if (!mpParent)
+return;
+
+mpParent->SetCache(aValues);
 }
 
 std::vector& ScColorFormat::getValues() const
 {
-if(!mpCache)
+assert(mpParent);
+
+std::vector* pCache = mpParent->GetCache();
+if (!pCache || pCache->empty())
 {
-mpCache.reset(new ScColorFormatCache);
-std::vector& rValues = mpCache->maValues;
+if (!pCache)
+{
+SetCache({});
+pCache = mpParent->GetCache();
+assert(pCache);
+}
+
+std::vector& rValues = *pCache;
 
 size_t n = GetRange().size();
  

core.git: sc/inc sc/source

2024-01-15 Thread Dennis Francis (via logerrit)
 sc/inc/colorscale.hxx  |   13 ++-
 sc/inc/conditio.hxx|   20 +++
 sc/source/core/data/colorscale.cxx |   37 +++--
 sc/source/core/data/conditio.cxx   |   63 +
 4 files changed, 113 insertions(+), 20 deletions(-)

New commits:
commit c84a1928ea76cf175711942db9ca7bb2f0ec6f0b
Author: Dennis Francis 
AuthorDate: Tue Oct 3 12:40:25 2023 +0530
Commit: Caolán McNamara 
CommitDate: Mon Jan 15 17:19:38 2024 +0100

sc: condfmt-perf: use a shared cache that...

is reset only when the data changes. Resetting is done only on
invalidation of associated ranges of data via a listener.

Earlier there were three separate caches that resets on every draw.

Change-Id: I1c185ece4b781bf6db7c82697cd5225d98c82651
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157508
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 1aa1a5340f63b31524117a3cfd6e05bee2aa1aa0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161998
Tested-by: Jenkins

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 6652e224fe67..f43f533e8f60 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -224,7 +224,7 @@ public:
 virtual ~ScColorFormat() override;
 
 const ScRangeList& GetRange() const;
-void SetCache(const std::vector& aValues);
+void SetCache(const std::vector& aValues) const;
 std::vector GetCache() const;
 
 virtual void SetParent(ScConditionalFormat* pParent) override;
@@ -240,14 +240,6 @@ protected:
 double getMaxValue() const;
 
 ScConditionalFormat* mpParent;
-
-private:
-
-struct ScColorFormatCache
-{
-std::vector maValues;
-};
-mutable std::unique_ptr mpCache;
 };
 
 typedef std::vector>> ScColorScaleEntries;
@@ -265,7 +257,10 @@ private:
 public:
 ScColorScaleFormat(ScDocument* pDoc);
 ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleFormat& rFormat);
+ScColorScaleFormat(const ScColorScaleFormat&) = delete;
 virtual ~ScColorScaleFormat() override;
+const ScColorScaleFormat& operator=(const ScColorScaleFormat&) = delete;
+
 virtual ScColorFormat* Clone(ScDocument* pDoc) const override;
 
 virtual void SetParent(ScConditionalFormat* pParent) override;
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index c3ef00e5cf93..ba5e0289bab8 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -538,6 +538,20 @@ private:
 OUString maStyleName;
 };
 
+class ScColorFormatCache final : public SvtListener
+{
+private:
+ScDocument& mrDoc;
+
+public:
+explicit ScColorFormatCache(ScDocument& rDoc, const ScRangeList& rRanges);
+virtual ~ScColorFormatCache() override;
+
+void Notify( const SfxHint& rHint ) override;
+
+std::vector maValues;
+};
+
 //  complete conditional formatting
 class SC_DLLPUBLIC ScConditionalFormat
 {
@@ -547,6 +561,8 @@ class SC_DLLPUBLIC ScConditionalFormat
 std::vector> maEntries;
 ScRangeList maRanges;// Ranges for conditional format
 
+mutable std::unique_ptr mpCache;
+
 public:
 ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument);
 ~ScConditionalFormat();
@@ -606,6 +622,10 @@ public:
 
 // Forced recalculation for formulas
 void CalcAll();
+
+void ResetCache() const;
+void SetCache(const std::vector& aValues) const;
+std::vector* GetCache() const;
 };
 
 class RepaintInIdle final : public Idle
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index eff6d050b13b..415dde5872e5 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -462,22 +462,39 @@ const ScRangeList& ScColorFormat::GetRange() const
 
 std::vector ScColorFormat::GetCache() const
 {
-std::vector empty;
-return mpCache ? mpCache->maValues : empty;
+if (!mpParent)
+return {};
+
+std::vector* pRes = mpParent->GetCache();
+if (pRes)
+return *pRes;
+
+return {};
 }
 
-void ScColorFormat::SetCache(const std::vector& aValues)
+void ScColorFormat::SetCache(const std::vector& aValues) const
 {
-mpCache.reset(new ScColorFormatCache);
-mpCache->maValues = aValues;
+if (!mpParent)
+return;
+
+mpParent->SetCache(aValues);
 }
 
 std::vector& ScColorFormat::getValues() const
 {
-if(!mpCache)
+assert(mpParent);
+
+std::vector* pCache = mpParent->GetCache();
+if (!pCache || pCache->empty())
 {
-mpCache.reset(new ScColorFormatCache);
-std::vector& rValues = mpCache->maValues;
+if (!pCache)
+{
+SetCache({});
+pCache = mpParent->GetCache();
+assert(pCache);
+}
+
+std::vector& rValues = *pCache;
 
 size_t n = GetRange()

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

2024-01-12 Thread Dennis Francis (via logerrit)
 sc/inc/colorscale.hxx  |   13 ++-
 sc/inc/conditio.hxx|   20 +++
 sc/source/core/data/colorscale.cxx |   37 +++--
 sc/source/core/data/conditio.cxx   |   63 +
 4 files changed, 113 insertions(+), 20 deletions(-)

New commits:
commit 1aa1a5340f63b31524117a3cfd6e05bee2aa1aa0
Author: Dennis Francis 
AuthorDate: Tue Oct 3 12:40:25 2023 +0530
Commit: Caolán McNamara 
CommitDate: Fri Jan 12 17:09:44 2024 +0100

sc: condfmt-perf: use a shared cache that...

is reset only when the data changes. Resetting is done only on
invalidation of associated ranges of data via a listener.

Earlier there were three separate caches that resets on every draw.

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

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 6652e224fe67..f43f533e8f60 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -224,7 +224,7 @@ public:
 virtual ~ScColorFormat() override;
 
 const ScRangeList& GetRange() const;
-void SetCache(const std::vector& aValues);
+void SetCache(const std::vector& aValues) const;
 std::vector GetCache() const;
 
 virtual void SetParent(ScConditionalFormat* pParent) override;
@@ -240,14 +240,6 @@ protected:
 double getMaxValue() const;
 
 ScConditionalFormat* mpParent;
-
-private:
-
-struct ScColorFormatCache
-{
-std::vector maValues;
-};
-mutable std::unique_ptr mpCache;
 };
 
 typedef std::vector>> ScColorScaleEntries;
@@ -265,7 +257,10 @@ private:
 public:
 ScColorScaleFormat(ScDocument* pDoc);
 ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleFormat& rFormat);
+ScColorScaleFormat(const ScColorScaleFormat&) = delete;
 virtual ~ScColorScaleFormat() override;
+const ScColorScaleFormat& operator=(const ScColorScaleFormat&) = delete;
+
 virtual ScColorFormat* Clone(ScDocument* pDoc) const override;
 
 virtual void SetParent(ScConditionalFormat* pParent) override;
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 8e5af1dd3c3c..e1cf5dc2f581 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -538,6 +538,20 @@ private:
 OUString maStyleName;
 };
 
+class ScColorFormatCache final : public SvtListener
+{
+private:
+ScDocument& mrDoc;
+
+public:
+explicit ScColorFormatCache(ScDocument& rDoc, const ScRangeList& rRanges);
+virtual ~ScColorFormatCache() override;
+
+void Notify( const SfxHint& rHint ) override;
+
+std::vector maValues;
+};
+
 //  complete conditional formatting
 class SC_DLLPUBLIC ScConditionalFormat
 {
@@ -547,6 +561,8 @@ class SC_DLLPUBLIC ScConditionalFormat
 std::vector> maEntries;
 ScRangeList maRanges;// Ranges for conditional format
 
+mutable std::unique_ptr mpCache;
+
 public:
 ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument);
 ~ScConditionalFormat();
@@ -606,6 +622,10 @@ public:
 
 // Forced recalculation for formulas
 void CalcAll();
+
+void ResetCache() const;
+void SetCache(const std::vector& aValues) const;
+std::vector* GetCache() const;
 };
 
 class RepaintInIdle final : public Idle
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 97cc50f73829..d5d40ec2c94d 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -462,22 +462,39 @@ const ScRangeList& ScColorFormat::GetRange() const
 
 std::vector ScColorFormat::GetCache() const
 {
-std::vector empty;
-return mpCache ? mpCache->maValues : empty;
+if (!mpParent)
+return {};
+
+std::vector* pRes = mpParent->GetCache();
+if (pRes)
+return *pRes;
+
+return {};
 }
 
-void ScColorFormat::SetCache(const std::vector& aValues)
+void ScColorFormat::SetCache(const std::vector& aValues) const
 {
-mpCache.reset(new ScColorFormatCache);
-mpCache->maValues = aValues;
+if (!mpParent)
+return;
+
+mpParent->SetCache(aValues);
 }
 
 std::vector& ScColorFormat::getValues() const
 {
-if(!mpCache)
+assert(mpParent);
+
+std::vector* pCache = mpParent->GetCache();
+if (!pCache || pCache->empty())
 {
-mpCache.reset(new ScColorFormatCache);
-std::vector& rValues = mpCache->maValues;
+if (!pCache)
+{
+SetCache({});
+pCache = mpParent->GetCache();
+assert(pCache);
+}
+
+std::vector& rValues = *pCache;
 
 size_t n = GetRange().size();
 const ScRangeList& aRanges = GetRange();
@@ -515,7 +532,7 @@ std::vector& ScColorFormat::getValues() const
 std::sort(rValues

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

2023-09-13 Thread Dennis Francis (via logerrit)
 sc/source/ui/dbgui/pvfundlg.cxx |   18 +++---
 sc/source/ui/inc/pvfundlg.hxx   |1 -
 2 files changed, 3 insertions(+), 16 deletions(-)

New commits:
commit 0b645cf5696be172104b546e4225cb90b27693ce
Author: Dennis Francis 
AuthorDate: Mon Sep 11 17:49:32 2023 +0530
Commit: Xisco Fauli 
CommitDate: Wed Sep 13 10:03:21 2023 +0200

tdf#157192: sc:pivot allow sort by selection in non-manual mode

Otherwise it is currently impossible to sort a field by its data
summarization values.

The RadioClickHdl is now doing nothing hence is removed with this
change.

Change-Id: I76064ce05e5b996ad96f596524be351708ef35e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156747
Tested-by: Jenkins
Reviewed-by: Dennis Francis 
(cherry picked from commit b8f6f91f476f1c3f93bb44265381305f6f02b161)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156870
Reviewed-by: Xisco Fauli 

diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index f74bb4b7391d..7f97e2576795 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -703,9 +703,11 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& 
rLabelData ) const
 {
 rLabelData.maSortInfo.Field =
 ScDPUtil::createDuplicateDimensionName(aFieldName.maName, 
aFieldName.mnDupCount);
-rLabelData.maSortInfo.IsAscending = m_xRbSortAsc->get_active();
 }
 
+if (rLabelData.maSortInfo.Mode != DataPilotFieldSortMode::MANUAL)
+rLabelData.maSortInfo.IsAscending = m_xRbSortAsc->get_active();
+
 // *** LAYOUT MODE ***
 
 rLabelData.maLayoutInfo.LayoutMode = 
ToDataPilotFieldLayoutMode(m_xLbLayout->get_active());
@@ -769,11 +771,6 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& 
rDataFields, bool bEnableLayou
 }
 m_xLbSortBy->set_active(nSortPos);
 
-// sorting mode
-m_xRbSortAsc->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-m_xRbSortDesc->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-m_xRbSortMan->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-
 weld::RadioButton* pRBtn = nullptr;
 switch( nSortMode )
 {
@@ -785,7 +782,6 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& 
rDataFields, bool bEnableLayou
 pRBtn = maLabelData.maSortInfo.IsAscending ? m_xRbSortAsc.get() : 
m_xRbSortDesc.get();
 }
 pRBtn->set_active(true);
-RadioClickHdl(*pRBtn);
 
 // *** LAYOUT MODE ***
 
@@ -879,14 +875,6 @@ IMPL_LINK(ScDPSubtotalOptDlg, ButtonClicked, 
weld::Button&, rButton, void)
 response(RET_CANCEL);
 }
 
-IMPL_LINK(ScDPSubtotalOptDlg, RadioClickHdl, weld::Toggleable&, rBtn, void)
-{
-if (!rBtn.get_active())
-return;
-
-m_xLbSortBy->set_sensitive(m_xRbSortMan->get_active());
-}
-
 IMPL_LINK(ScDPSubtotalOptDlg, CheckHdl, weld::Toggleable&, rCBox, void)
 {
 if ( == m_xCbShow.get())
diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx
index f5f140c54cdf..146048cfedbf 100644
--- a/sc/source/ui/inc/pvfundlg.hxx
+++ b/sc/source/ui/inc/pvfundlg.hxx
@@ -150,7 +150,6 @@ private:
 /** Searches for a listbox entry, starts search at specified position. */
 sal_Int32 FindListBoxEntry( const weld::ComboBox& rLBox, 
std::u16string_view rEntry, sal_Int32 nStartPos ) const;
 
-DECL_LINK( RadioClickHdl, weld::Toggleable&, void );
 DECL_LINK( CheckHdl, weld::Toggleable&, void );
 DECL_LINK( SelectHdl, weld::ComboBox&, void );
 DECL_LINK( ButtonClicked, weld::Button&, void );


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

2023-09-12 Thread Dennis Francis (via logerrit)
 sc/source/ui/dbgui/pvfundlg.cxx |   18 +++---
 sc/source/ui/inc/pvfundlg.hxx   |1 -
 2 files changed, 3 insertions(+), 16 deletions(-)

New commits:
commit b8f6f91f476f1c3f93bb44265381305f6f02b161
Author: Dennis Francis 
AuthorDate: Mon Sep 11 17:49:32 2023 +0530
Commit: Dennis Francis 
CommitDate: Tue Sep 12 16:12:18 2023 +0200

sc:pivot allow sort by selection in non-manual mode

Otherwise it is currently impossible to sort a field by its data
summarization values.

The RadioClickHdl is now doing nothing hence is removed with this
change.

Change-Id: I76064ce05e5b996ad96f596524be351708ef35e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156747
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index f74bb4b7391d..7f97e2576795 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -703,9 +703,11 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& 
rLabelData ) const
 {
 rLabelData.maSortInfo.Field =
 ScDPUtil::createDuplicateDimensionName(aFieldName.maName, 
aFieldName.mnDupCount);
-rLabelData.maSortInfo.IsAscending = m_xRbSortAsc->get_active();
 }
 
+if (rLabelData.maSortInfo.Mode != DataPilotFieldSortMode::MANUAL)
+rLabelData.maSortInfo.IsAscending = m_xRbSortAsc->get_active();
+
 // *** LAYOUT MODE ***
 
 rLabelData.maLayoutInfo.LayoutMode = 
ToDataPilotFieldLayoutMode(m_xLbLayout->get_active());
@@ -769,11 +771,6 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& 
rDataFields, bool bEnableLayou
 }
 m_xLbSortBy->set_active(nSortPos);
 
-// sorting mode
-m_xRbSortAsc->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-m_xRbSortDesc->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-m_xRbSortMan->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-
 weld::RadioButton* pRBtn = nullptr;
 switch( nSortMode )
 {
@@ -785,7 +782,6 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& 
rDataFields, bool bEnableLayou
 pRBtn = maLabelData.maSortInfo.IsAscending ? m_xRbSortAsc.get() : 
m_xRbSortDesc.get();
 }
 pRBtn->set_active(true);
-RadioClickHdl(*pRBtn);
 
 // *** LAYOUT MODE ***
 
@@ -879,14 +875,6 @@ IMPL_LINK(ScDPSubtotalOptDlg, ButtonClicked, 
weld::Button&, rButton, void)
 response(RET_CANCEL);
 }
 
-IMPL_LINK(ScDPSubtotalOptDlg, RadioClickHdl, weld::Toggleable&, rBtn, void)
-{
-if (!rBtn.get_active())
-return;
-
-m_xLbSortBy->set_sensitive(m_xRbSortMan->get_active());
-}
-
 IMPL_LINK(ScDPSubtotalOptDlg, CheckHdl, weld::Toggleable&, rCBox, void)
 {
 if ( == m_xCbShow.get())
diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx
index f5f140c54cdf..146048cfedbf 100644
--- a/sc/source/ui/inc/pvfundlg.hxx
+++ b/sc/source/ui/inc/pvfundlg.hxx
@@ -150,7 +150,6 @@ private:
 /** Searches for a listbox entry, starts search at specified position. */
 sal_Int32 FindListBoxEntry( const weld::ComboBox& rLBox, 
std::u16string_view rEntry, sal_Int32 nStartPos ) const;
 
-DECL_LINK( RadioClickHdl, weld::Toggleable&, void );
 DECL_LINK( CheckHdl, weld::Toggleable&, void );
 DECL_LINK( SelectHdl, weld::ComboBox&, void );
 DECL_LINK( ButtonClicked, weld::Button&, void );


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

2023-09-12 Thread Dennis Francis (via logerrit)
 sc/source/ui/dbgui/pvfundlg.cxx |   18 +++---
 sc/source/ui/inc/pvfundlg.hxx   |1 -
 2 files changed, 3 insertions(+), 16 deletions(-)

New commits:
commit 88afeef7cf58863707ea9fe404fdc3942e74e55b
Author: Dennis Francis 
AuthorDate: Mon Sep 11 17:49:32 2023 +0530
Commit: Dennis Francis 
CommitDate: Tue Sep 12 16:09:00 2023 +0200

sc:pivot allow sort by selection in non-manual mode

Otherwise it is currently impossible to sort a field by its data
summarization values.

The RadioClickHdl is now doing nothing hence is removed with this
change.

Change-Id: I76064ce05e5b996ad96f596524be351708ef35e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156823
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index f74bb4b7391d..7f97e2576795 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -703,9 +703,11 @@ void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& 
rLabelData ) const
 {
 rLabelData.maSortInfo.Field =
 ScDPUtil::createDuplicateDimensionName(aFieldName.maName, 
aFieldName.mnDupCount);
-rLabelData.maSortInfo.IsAscending = m_xRbSortAsc->get_active();
 }
 
+if (rLabelData.maSortInfo.Mode != DataPilotFieldSortMode::MANUAL)
+rLabelData.maSortInfo.IsAscending = m_xRbSortAsc->get_active();
+
 // *** LAYOUT MODE ***
 
 rLabelData.maLayoutInfo.LayoutMode = 
ToDataPilotFieldLayoutMode(m_xLbLayout->get_active());
@@ -769,11 +771,6 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& 
rDataFields, bool bEnableLayou
 }
 m_xLbSortBy->set_active(nSortPos);
 
-// sorting mode
-m_xRbSortAsc->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-m_xRbSortDesc->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-m_xRbSortMan->connect_toggled( LINK( this, ScDPSubtotalOptDlg, 
RadioClickHdl ) );
-
 weld::RadioButton* pRBtn = nullptr;
 switch( nSortMode )
 {
@@ -785,7 +782,6 @@ void ScDPSubtotalOptDlg::Init( const ScDPNameVec& 
rDataFields, bool bEnableLayou
 pRBtn = maLabelData.maSortInfo.IsAscending ? m_xRbSortAsc.get() : 
m_xRbSortDesc.get();
 }
 pRBtn->set_active(true);
-RadioClickHdl(*pRBtn);
 
 // *** LAYOUT MODE ***
 
@@ -879,14 +875,6 @@ IMPL_LINK(ScDPSubtotalOptDlg, ButtonClicked, 
weld::Button&, rButton, void)
 response(RET_CANCEL);
 }
 
-IMPL_LINK(ScDPSubtotalOptDlg, RadioClickHdl, weld::Toggleable&, rBtn, void)
-{
-if (!rBtn.get_active())
-return;
-
-m_xLbSortBy->set_sensitive(m_xRbSortMan->get_active());
-}
-
 IMPL_LINK(ScDPSubtotalOptDlg, CheckHdl, weld::Toggleable&, rCBox, void)
 {
 if ( == m_xCbShow.get())
diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx
index f5f140c54cdf..146048cfedbf 100644
--- a/sc/source/ui/inc/pvfundlg.hxx
+++ b/sc/source/ui/inc/pvfundlg.hxx
@@ -150,7 +150,6 @@ private:
 /** Searches for a listbox entry, starts search at specified position. */
 sal_Int32 FindListBoxEntry( const weld::ComboBox& rLBox, 
std::u16string_view rEntry, sal_Int32 nStartPos ) const;
 
-DECL_LINK( RadioClickHdl, weld::Toggleable&, void );
 DECL_LINK( CheckHdl, weld::Toggleable&, void );
 DECL_LINK( SelectHdl, weld::ComboBox&, void );
 DECL_LINK( ButtonClicked, weld::Button&, void );


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

2023-06-28 Thread Dennis Francis (via logerrit)
 sc/Library_scfilt.mk |1 
 sc/source/filter/inc/patterncache.hxx|   46 +++
 sc/source/filter/inc/stylesbuffer.hxx|5 ++
 sc/source/filter/oox/patterncache.cxx|   52 +++
 sc/source/filter/oox/sheetdatabuffer.cxx |6 ++-
 sc/source/filter/oox/stylesbuffer.cxx|   23 +
 6 files changed, 124 insertions(+), 9 deletions(-)

New commits:
commit 64dbb50e028e56c224a55affbc17277da40b659e
Author: Dennis Francis 
AuthorDate: Wed Jun 7 11:34:56 2023 +0530
Commit: Caolán McNamara 
CommitDate: Wed Jun 28 13:05:11 2023 +0200

sc: perf: speedup sheets with lots of repetitive...

row styles using a small cache of already allocated patterns that are
tied to extended format id and number format id.

Change-Id: I3136aef9a034635924f7b7b6d2432f9ae5c2bd15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152692
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153588
Reviewed-by: Caolán McNamara 

diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index eff7cca485e4..4614e8889ba1 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -188,6 +188,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\
sc/source/filter/oox/numberformatsbuffer \
sc/source/filter/oox/ooxformulaparser \
sc/source/filter/oox/pagesettings \
+   sc/source/filter/oox/patterncache \
sc/source/filter/oox/pivotcachebuffer \
sc/source/filter/oox/pivotcachefragment \
sc/source/filter/oox/pivottablebuffer \
diff --git a/sc/source/filter/inc/patterncache.hxx 
b/sc/source/filter/inc/patterncache.hxx
new file mode 100644
index ..3962dccc37da
--- /dev/null
+++ b/sc/source/filter/inc/patterncache.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include 
+
+class ScPatternAttr;
+
+static constexpr sal_Int32 nPatternCacheSize = 16;
+class ScPatternCache
+{
+struct Entry
+{
+sal_Int32 nXfId;
+sal_Int32 nNumFmtId;
+ScPatternAttr* pPattern;
+
+Entry();
+};
+
+Entry maEntries[nPatternCacheSize];
+sal_Int32 nNextPos;
+
+public:
+ScPatternCache();
+
+ScPatternAttr* query(sal_Int32 nXfId, sal_Int32 nNumFmtId) const;
+void add(sal_Int32 nXfId, sal_Int32 nNumFmtId, ScPatternAttr* pPattern);
+};
diff --git a/sc/source/filter/inc/stylesbuffer.hxx 
b/sc/source/filter/inc/stylesbuffer.hxx
index 4d9e7aeed33d..2cc7590dbcde 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+class ScPatternCache;
+
 namespace oox { class SequenceInputStream; }
 
 namespace oox { class PropertySet;
@@ -623,7 +625,8 @@ public:
 const Alignment& getAlignment() const { return maAlignment; }
 
 void applyPatternToAttrList(
-AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal_Int32 nForceScNumFmt );
+AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal_Int32 nXfId,
+sal_Int32 nForceScNumFmt, ScPatternCache& rCache );
 
 void writeToDoc( ScDocumentImport& rDoc, const ScRange& rRange );
 
diff --git a/sc/source/filter/oox/patterncache.cxx 
b/sc/source/filter/oox/patterncache.cxx
new file mode 100644
index ..2431a36fed20
--- /dev/null
+++ b/sc/source/filter/oox/patterncache.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for addition

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

2023-06-17 Thread Dennis Francis (via logerrit)
 sc/Library_scfilt.mk |1 
 sc/source/filter/inc/patterncache.hxx|   46 +++
 sc/source/filter/inc/stylesbuffer.hxx|5 ++
 sc/source/filter/oox/patterncache.cxx|   52 +++
 sc/source/filter/oox/sheetdatabuffer.cxx |6 ++-
 sc/source/filter/oox/stylesbuffer.cxx|   23 +
 6 files changed, 124 insertions(+), 9 deletions(-)

New commits:
commit 447a4bcac071840e5dd19cdaaefc6897d5d19cbe
Author: Dennis Francis 
AuthorDate: Wed Jun 7 11:34:56 2023 +0530
Commit: Noel Grandin 
CommitDate: Sat Jun 17 09:08:03 2023 +0200

sc: perf: speedup sheets with lots of repetitive...

row styles using a small cache of already allocated patterns that are
tied to extended format id and number format id.

Change-Id: I3136aef9a034635924f7b7b6d2432f9ae5c2bd15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152692
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 
(cherry picked from commit 92b13ad1f1a87393cf66a35694f3e542db57f150)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152874
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index 5590a4ab7605..aa4e1fae787c 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -189,6 +189,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\
sc/source/filter/oox/numberformatsbuffer \
sc/source/filter/oox/ooxformulaparser \
sc/source/filter/oox/pagesettings \
+   sc/source/filter/oox/patterncache \
sc/source/filter/oox/pivotcachebuffer \
sc/source/filter/oox/pivotcachefragment \
sc/source/filter/oox/pivottablebuffer \
diff --git a/sc/source/filter/inc/patterncache.hxx 
b/sc/source/filter/inc/patterncache.hxx
new file mode 100644
index ..25013a930143
--- /dev/null
+++ b/sc/source/filter/inc/patterncache.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include 
+
+class ScPatternAttr;
+
+constexpr sal_Int32 nPatternCacheSize = 16;
+class ScPatternCache
+{
+struct Entry
+{
+sal_Int32 nXfId;
+sal_Int32 nNumFmtId;
+ScPatternAttr* pPattern;
+
+Entry();
+};
+
+Entry maEntries[nPatternCacheSize];
+sal_Int32 nNextPos;
+
+public:
+ScPatternCache();
+
+ScPatternAttr* query(sal_Int32 nXfId, sal_Int32 nNumFmtId) const;
+void add(sal_Int32 nXfId, sal_Int32 nNumFmtId, ScPatternAttr* pPattern);
+};
diff --git a/sc/source/filter/inc/stylesbuffer.hxx 
b/sc/source/filter/inc/stylesbuffer.hxx
index a687a14d3b31..c80eab77241d 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+class ScPatternCache;
+
 namespace oox { class SequenceInputStream; }
 
 namespace oox { class PropertySet;
@@ -623,7 +625,8 @@ public:
 const Alignment& getAlignment() const { return maAlignment; }
 
 void applyPatternToAttrList(
-AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal_Int32 nForceScNumFmt );
+AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal_Int32 nXfId,
+sal_Int32 nForceScNumFmt, ScPatternCache& rCache );
 
 void writeToDoc( ScDocumentImport& rDoc, const ScRange& rRange );
 
diff --git a/sc/source/filter/oox/patterncache.cxx 
b/sc/source/filter/oox/patterncache.cxx
new file mode 100644
index ..2431a36fed20
--- /dev/null
+++ b/sc/source/filter/oox/patterncache.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor licen

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

2023-06-08 Thread Dennis Francis (via logerrit)
 sc/Library_scfilt.mk |1 
 sc/source/filter/inc/patterncache.hxx|   46 +++
 sc/source/filter/inc/stylesbuffer.hxx|5 ++
 sc/source/filter/oox/patterncache.cxx|   52 +++
 sc/source/filter/oox/sheetdatabuffer.cxx |6 ++-
 sc/source/filter/oox/stylesbuffer.cxx|   23 +
 6 files changed, 124 insertions(+), 9 deletions(-)

New commits:
commit 92b13ad1f1a87393cf66a35694f3e542db57f150
Author: Dennis Francis 
AuthorDate: Wed Jun 7 11:34:56 2023 +0530
Commit: Andras Timar 
CommitDate: Thu Jun 8 21:58:04 2023 +0200

sc: perf: speedup sheets with lots of repetitive...

row styles using a small cache of already allocated patterns that are
tied to extended format id and number format id.

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

diff --git a/sc/Library_scfilt.mk b/sc/Library_scfilt.mk
index 5590a4ab7605..aa4e1fae787c 100644
--- a/sc/Library_scfilt.mk
+++ b/sc/Library_scfilt.mk
@@ -189,6 +189,7 @@ $(eval $(call gb_Library_add_exception_objects,scfilt,\
sc/source/filter/oox/numberformatsbuffer \
sc/source/filter/oox/ooxformulaparser \
sc/source/filter/oox/pagesettings \
+   sc/source/filter/oox/patterncache \
sc/source/filter/oox/pivotcachebuffer \
sc/source/filter/oox/pivotcachefragment \
sc/source/filter/oox/pivottablebuffer \
diff --git a/sc/source/filter/inc/patterncache.hxx 
b/sc/source/filter/inc/patterncache.hxx
new file mode 100644
index ..3962dccc37da
--- /dev/null
+++ b/sc/source/filter/inc/patterncache.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include 
+
+class ScPatternAttr;
+
+static constexpr sal_Int32 nPatternCacheSize = 16;
+class ScPatternCache
+{
+struct Entry
+{
+sal_Int32 nXfId;
+sal_Int32 nNumFmtId;
+ScPatternAttr* pPattern;
+
+Entry();
+};
+
+Entry maEntries[nPatternCacheSize];
+sal_Int32 nNextPos;
+
+public:
+ScPatternCache();
+
+ScPatternAttr* query(sal_Int32 nXfId, sal_Int32 nNumFmtId) const;
+void add(sal_Int32 nXfId, sal_Int32 nNumFmtId, ScPatternAttr* pPattern);
+};
diff --git a/sc/source/filter/inc/stylesbuffer.hxx 
b/sc/source/filter/inc/stylesbuffer.hxx
index a687a14d3b31..c80eab77241d 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -35,6 +35,8 @@
 #include 
 #include 
 
+class ScPatternCache;
+
 namespace oox { class SequenceInputStream; }
 
 namespace oox { class PropertySet;
@@ -623,7 +625,8 @@ public:
 const Alignment& getAlignment() const { return maAlignment; }
 
 void applyPatternToAttrList(
-AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal_Int32 nForceScNumFmt );
+AttrList& rAttrs, SCROW nRow1, SCROW nRow2, sal_Int32 nXfId,
+sal_Int32 nForceScNumFmt, ScPatternCache& rCache );
 
 void writeToDoc( ScDocumentImport& rDoc, const ScRange& rRange );
 
diff --git a/sc/source/filter/oox/patterncache.cxx 
b/sc/source/filter/oox/patterncache.cxx
new file mode 100644
index ..2431a36fed20
--- /dev/null
+++ b/sc/source/filter/oox/patterncache.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   

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

2023-05-25 Thread Dennis Francis (via logerrit)
 sc/qa/unit/data/xlsx/tablerefsnamed.xlsx |binary
 sc/qa/unit/subsequent_filters_test2.cxx  |   17 
 sc/source/core/tool/interpr1.cxx |   43 +++
 3 files changed, 50 insertions(+), 10 deletions(-)

New commits:
commit 52e7edf4a5980b4451551a33a5f4e5432d27a9e0
Author: Dennis Francis 
AuthorDate: Sat May 13 13:37:39 2023 +0530
Commit: Xisco Fauli 
CommitDate: Thu May 25 10:37:05 2023 +0200

tdf#155369 ScIndirect: handle names that resolve to...

table structured references.

Conflicts:
sc/qa/unit/subsequent_filters_test2.cxx

Change-Id: I897feeeb49e63c1758cf64450799acb192e2d593
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151888
Tested-by: Jenkins
Reviewed-by: Dennis Francis 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152083

diff --git a/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx 
b/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx
new file mode 100644
index ..825103d54993
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index da79b48af6b5..177fcc773ed7 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -190,6 +190,7 @@ public:
 void testTdf83671_SmartArt_import();
 void testTdf83671_SmartArt_import2();
 void testTdf151818_SmartArtFontColor();
+void testNamedTableRef();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest2);
 
@@ -310,6 +311,7 @@ public:
 CPPUNIT_TEST(testTdf83671_SmartArt_import);
 CPPUNIT_TEST(testTdf83671_SmartArt_import2);
 CPPUNIT_TEST(testTdf151818_SmartArtFontColor);
+CPPUNIT_TEST(testNamedTableRef);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -3035,6 +3037,21 @@ void ScFiltersTest2::testTdf151818_SmartArtFontColor()
 }
 }
 
+void ScFiltersTest2::testNamedTableRef()
+{
+createScDoc("xlsx/tablerefsnamed.xlsx");
+ScDocument* pDoc = getScDoc();
+for (sal_Int32 nRow = 1; nRow < 7; ++nRow)
+{
+ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(5, nRow, 0));
+CPPUNIT_ASSERT(pFC);
+// Without the fix there will be #REF in F2:F7.
+CPPUNIT_ASSERT_EQUAL(FormulaError::NONE, pFC->GetErrCode());
+// Without the fix value will be 0 (FALSE).
+CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(6, nRow, 0)));
+}
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index b833e3f48f24..32ec7338c35e 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8181,6 +8181,12 @@ void ScInterpreter::ScDBVarP()
 PushDouble(fVal/fCount);
 }
 
+static bool lcl_IsTableStructuredRef(const OUString& sRefStr, sal_Int32& 
nIndex)
+{
+nIndex = ScGlobal::FindUnquoted(sRefStr, '[');
+return (nIndex > 0 && ScGlobal::FindUnquoted(sRefStr, ']', nIndex + 1) > 
nIndex);
+}
+
 void ScInterpreter::ScIndirect()
 {
 sal_uInt8 nParamCount = GetByte();
@@ -8217,6 +8223,10 @@ void ScInterpreter::ScIndirect()
 const ScAddress::Details aDetailsXlA1( FormulaGrammar::CONV_XL_A1, aPos );
 SCTAB nTab = aPos.Tab();
 
+bool bTableRefNamed = false;
+sal_Int32 nTableRefNamedIndex = -1;
+OUString sTabRefStr;
+
 // Named expressions and DB range names need to be tried first, as older 1K
 // columns allowed names that would now match a 16k columns cell address.
 do
@@ -8232,8 +8242,14 @@ void ScInterpreter::ScIndirect()
 
 // This is the usual way to treat named ranges containing
 // relative references.
-if (!pData->IsReference( aRange, aPos))
+if (!pData->IsReference(aRange, aPos))
+{
+sTabRefStr = pData->GetSymbol();
+bTableRefNamed = lcl_IsTableStructuredRef(sTabRefStr, 
nTableRefNamedIndex);
+// if bTableRefNamed is true, we have a name that maps to a table 
structured reference.
+// Such a case is handled below.
 break;
+}
 
 if (aRange.aStart == aRange.aEnd)
 PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(),
@@ -8250,6 +8266,9 @@ void ScInterpreter::ScIndirect()
 
 do
 {
+if (bTableRefNamed)
+break;
+
 const OUString & aName( sSharedRefStr.getIgnoreCaseString() );
 ScDBCollection::NamedDBs& rDBs = 
mrDoc.GetDBCollection()->getNamedDBs();
 const ScDBData* pData = rDBs.findByUpperName( aName);
@@ -8285,9 +8304,10 @@ void ScInterpreter::ScIndirect()
 
 ScRefAddress aRefAd, aRefAd2;
 ScAddress::ExternalInfo aExtInfo;
-if ( ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd, aRefAd2, aDetails, 
) ||
- ( bTryXlA1 && ConvertDoubleRef(mrDoc, sRefStr, nTab

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

2023-05-20 Thread Dennis Francis (via logerrit)
 sc/qa/unit/data/xlsx/tablerefsnamed.xlsx |binary
 sc/qa/unit/subsequent_filters_test2.cxx  |   15 ++
 sc/source/core/tool/interpr1.cxx |   43 +++
 3 files changed, 48 insertions(+), 10 deletions(-)

New commits:
commit 4536694edb7e564ea1f4ae871e9107f52ed0972f
Author: Dennis Francis 
AuthorDate: Sat May 13 13:37:39 2023 +0530
Commit: Dennis Francis 
CommitDate: Sat May 20 17:07:21 2023 +0200

tdf#155369 ScIndirect: handle names that resolve to...

table structured references.

Conflicts:
sc/qa/unit/subsequent_filters_test2.cxx

Change-Id: I897feeeb49e63c1758cf64450799acb192e2d593
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151888
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx 
b/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx
new file mode 100644
index ..825103d54993
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index cd5f073f46c4..a00558730d0b 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -1565,6 +1565,21 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest2, 
testBorderDirectionsXLSXML)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest2, testNamedTableRef)
+{
+createScDoc("xlsx/tablerefsnamed.xlsx");
+ScDocument* pDoc = getScDoc();
+for (sal_Int32 nRow = 1; nRow < 7; ++nRow)
+{
+ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(5, nRow, 0));
+CPPUNIT_ASSERT(pFC);
+// Without the fix there will be #REF in F2:F7.
+CPPUNIT_ASSERT_EQUAL(FormulaError::NONE, pFC->GetErrCode());
+// Without the fix value will be 0 (FALSE).
+CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(6, nRow, 0)));
+}
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 9e2277f60392..2f48398827ed 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8187,6 +8187,12 @@ void ScInterpreter::ScDBVarP()
 PushDouble(fVal/fCount);
 }
 
+static bool lcl_IsTableStructuredRef(const OUString& sRefStr, sal_Int32& 
nIndex)
+{
+nIndex = ScGlobal::FindUnquoted(sRefStr, '[');
+return (nIndex > 0 && ScGlobal::FindUnquoted(sRefStr, ']', nIndex + 1) > 
nIndex);
+}
+
 void ScInterpreter::ScIndirect()
 {
 sal_uInt8 nParamCount = GetByte();
@@ -8223,6 +8229,10 @@ void ScInterpreter::ScIndirect()
 const ScAddress::Details aDetailsXlA1( FormulaGrammar::CONV_XL_A1, aPos );
 SCTAB nTab = aPos.Tab();
 
+bool bTableRefNamed = false;
+sal_Int32 nTableRefNamedIndex = -1;
+OUString sTabRefStr;
+
 // Named expressions and DB range names need to be tried first, as older 1K
 // columns allowed names that would now match a 16k columns cell address.
 do
@@ -8238,8 +8248,14 @@ void ScInterpreter::ScIndirect()
 
 // This is the usual way to treat named ranges containing
 // relative references.
-if (!pData->IsReference( aRange, aPos))
+if (!pData->IsReference(aRange, aPos))
+{
+sTabRefStr = pData->GetSymbol();
+bTableRefNamed = lcl_IsTableStructuredRef(sTabRefStr, 
nTableRefNamedIndex);
+// if bTableRefNamed is true, we have a name that maps to a table 
structured reference.
+// Such a case is handled below.
 break;
+}
 
 if (aRange.aStart == aRange.aEnd)
 PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(),
@@ -8256,6 +8272,9 @@ void ScInterpreter::ScIndirect()
 
 do
 {
+if (bTableRefNamed)
+break;
+
 const OUString & aName( sSharedRefStr.getIgnoreCaseString() );
 ScDBCollection::NamedDBs& rDBs = 
mrDoc.GetDBCollection()->getNamedDBs();
 const ScDBData* pData = rDBs.findByUpperName( aName);
@@ -8291,9 +8310,10 @@ void ScInterpreter::ScIndirect()
 
 ScRefAddress aRefAd, aRefAd2;
 ScAddress::ExternalInfo aExtInfo;
-if ( ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd, aRefAd2, aDetails, 
) ||
- ( bTryXlA1 && ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd,
-aRefAd2, aDetailsXlA1, ) ) )
+if ( !bTableRefNamed &&
+ (ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd, aRefAd2, aDetails, 
) ||
+( bTryXlA1 && ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd,
+   aRefAd2, aDetailsXlA1, ) ) 
) )
 {
 if (aExtInfo.mbExternal)
 {
@@ -8305,9 +8325,10 @@ void ScInterpreter::ScIndirect()
 else
 PushDoubleRef( aRefAd, aRefAd2);
 }
-else if ( ConvertSingleRef(mrD

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

2023-05-20 Thread Dennis Francis (via logerrit)
 sc/qa/unit/data/xlsx/tablerefsnamed.xlsx |binary
 sc/qa/unit/subsequent_filters_test2.cxx  |   17 
 sc/source/core/tool/interpr1.cxx |   43 +++
 3 files changed, 50 insertions(+), 10 deletions(-)

New commits:
commit 49d6567a196f4bfafb45b07b1b88e7c00c134bfd
Author: Dennis Francis 
AuthorDate: Sat May 13 13:37:39 2023 +0530
Commit: Dennis Francis 
CommitDate: Sat May 20 17:06:40 2023 +0200

tdf#155369 ScIndirect: handle names that resolve to...

table structured references.

Change-Id: I897feeeb49e63c1758cf64450799acb192e2d593
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151720
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Dennis Francis 

diff --git a/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx 
b/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx
new file mode 100644
index ..825103d54993
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tablerefsnamed.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index 850026d3bc46..f2fd4196dfa1 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -192,6 +192,7 @@ public:
 void testTdf151818_SmartArtFontColor();
 void testTdf82984_zip64XLSXImport();
 void testSingleLine();
+void testNamedTableRef();
 
 CPPUNIT_TEST_SUITE(ScFiltersTest2);
 
@@ -314,6 +315,7 @@ public:
 CPPUNIT_TEST(testTdf151818_SmartArtFontColor);
 CPPUNIT_TEST(testTdf82984_zip64XLSXImport);
 CPPUNIT_TEST(testSingleLine);
+CPPUNIT_TEST(testNamedTableRef);
 
 CPPUNIT_TEST_SUITE_END();
 };
@@ -3078,6 +3080,21 @@ void ScFiltersTest2::testSingleLine()
 testCells(pDoc);
 }
 
+void ScFiltersTest2::testNamedTableRef()
+{
+createScDoc("xlsx/tablerefsnamed.xlsx");
+ScDocument* pDoc = getScDoc();
+for (sal_Int32 nRow = 1; nRow < 7; ++nRow)
+{
+ScFormulaCell* pFC = pDoc->GetFormulaCell(ScAddress(5, nRow, 0));
+CPPUNIT_ASSERT(pFC);
+// Without the fix there will be #REF in F2:F7.
+CPPUNIT_ASSERT_EQUAL(FormulaError::NONE, pFC->GetErrCode());
+// Without the fix value will be 0 (FALSE).
+CPPUNIT_ASSERT_EQUAL(1.0, pDoc->GetValue(ScAddress(6, nRow, 0)));
+}
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index b833e3f48f24..7283002f328d 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -8181,6 +8181,12 @@ void ScInterpreter::ScDBVarP()
 PushDouble(fVal/fCount);
 }
 
+bool lcl_IsTableStructuredRef(const OUString& sRefStr, sal_Int32& nIndex)
+{
+nIndex = ScGlobal::FindUnquoted(sRefStr, '[');
+return (nIndex > 0 && ScGlobal::FindUnquoted(sRefStr, ']', nIndex + 1) > 
nIndex);
+}
+
 void ScInterpreter::ScIndirect()
 {
 sal_uInt8 nParamCount = GetByte();
@@ -8217,6 +8223,10 @@ void ScInterpreter::ScIndirect()
 const ScAddress::Details aDetailsXlA1( FormulaGrammar::CONV_XL_A1, aPos );
 SCTAB nTab = aPos.Tab();
 
+bool bTableRefNamed = false;
+sal_Int32 nTableRefNamedIndex = -1;
+OUString sTabRefStr;
+
 // Named expressions and DB range names need to be tried first, as older 1K
 // columns allowed names that would now match a 16k columns cell address.
 do
@@ -8232,8 +8242,14 @@ void ScInterpreter::ScIndirect()
 
 // This is the usual way to treat named ranges containing
 // relative references.
-if (!pData->IsReference( aRange, aPos))
+if (!pData->IsReference(aRange, aPos))
+{
+sTabRefStr = pData->GetSymbol();
+bTableRefNamed = lcl_IsTableStructuredRef(sTabRefStr, 
nTableRefNamedIndex);
+// if bTableRefNamed is true, we have a name that maps to a table 
structured reference.
+// Such a case is handled below.
 break;
+}
 
 if (aRange.aStart == aRange.aEnd)
 PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(),
@@ -8250,6 +8266,9 @@ void ScInterpreter::ScIndirect()
 
 do
 {
+if (bTableRefNamed)
+break;
+
 const OUString & aName( sSharedRefStr.getIgnoreCaseString() );
 ScDBCollection::NamedDBs& rDBs = 
mrDoc.GetDBCollection()->getNamedDBs();
 const ScDBData* pData = rDBs.findByUpperName( aName);
@@ -8285,9 +8304,10 @@ void ScInterpreter::ScIndirect()
 
 ScRefAddress aRefAd, aRefAd2;
 ScAddress::ExternalInfo aExtInfo;
-if ( ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd, aRefAd2, aDetails, 
) ||
- ( bTryXlA1 && ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd,
-aRefAd2, aDetailsXlA1, ) ) )
+if ( !bTableRefNamed &&
+ (ConvertDoubleRef(mrDoc, sRefStr, nTab, aRefAd, aRefAd2, aDetails

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

2023-05-13 Thread Dennis Francis (via logerrit)
 sc/source/core/data/validat.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit e848d91a1d060558e89029b6beecfa796105d962
Author: Dennis Francis 
AuthorDate: Wed May 3 13:00:09 2023 +0530
Commit: Andras Timar 
CommitDate: Sat May 13 13:55:55 2023 +0200

sc: use the current cell's numfmt to format...

to format the values in the validation list when the items are numbers.
This is better than applying no formatting since we lost track of the
source formatting when values are passed through a matrix.

Change-Id: I06432bd93ef8d01181dd16d2f5ee99eb0477c094
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151313
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Henry Castro 
(cherry picked from commit 2f6d1cefc184fda3ba292f1718b034202989d7b3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151521
Reviewed-by: Andras Timar 

diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 43ebb8faea58..01c864934821 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -764,6 +764,7 @@ bool ScValidationData::GetSelectionFromFormula(
 rMatch = -1;
 
 SvNumberFormatter* pFormatter = GetDocument()->GetFormatTable();
+sal_uInt32 nDestFormat = pDocument->GetNumberFormat(rPos.Col(), 
rPos.Row(), rPos.Tab());
 
 SCSIZE  nCol, nRow, nCols, nRows, n = 0;
 pValues->GetDimensions( nCols, nRows );
@@ -865,7 +866,7 @@ bool ScValidationData::GetSelectionFromFormula(
 }
 else
 {
-pFormatter->GetInputLineString( nMatVal.fVal, 0, 
aValStr );
+pFormatter->GetInputLineString( nMatVal.fVal, 
nDestFormat, aValStr );
 }
 }
 


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

2023-05-09 Thread Dennis Francis (via logerrit)
 sc/source/core/data/validat.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 4adf6852cc3fd0eddf53c2ab4f66efed0668b699
Author: Dennis Francis 
AuthorDate: Wed May 3 13:00:09 2023 +0530
Commit: Dennis Francis 
CommitDate: Tue May 9 17:41:47 2023 +0200

sc: use the current cell's numfmt to format...

to format the values in the validation list when the items are numbers.
This is better than applying no formatting since we lost track of the
source formatting when values are passed through a matrix.

Change-Id: I06432bd93ef8d01181dd16d2f5ee99eb0477c094
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151313
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Henry Castro 
(cherry picked from commit 2f6d1cefc184fda3ba292f1718b034202989d7b3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151386
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 8fb0f9f7924a..009bc0eaebe7 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -856,6 +856,7 @@ bool ScValidationData::GetSelectionFromFormula(
 rMatch = -1;
 
 SvNumberFormatter* pFormatter = GetDocument()->GetFormatTable();
+sal_uInt32 nDestFormat = pDocument->GetNumberFormat(rPos.Col(), 
rPos.Row(), rPos.Tab());
 
 SCSIZE  nCol, nRow, nCols, nRows, n = 0;
 pValues->GetDimensions( nCols, nRows );
@@ -957,7 +958,7 @@ bool ScValidationData::GetSelectionFromFormula(
 }
 else
 {
-pFormatter->GetInputLineString( nMatVal.fVal, 0, 
aValStr );
+pFormatter->GetInputLineString( nMatVal.fVal, 
nDestFormat, aValStr );
 }
 }
 


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

2023-05-03 Thread Dennis Francis (via logerrit)
 sc/source/core/data/validat.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 2f6d1cefc184fda3ba292f1718b034202989d7b3
Author: Dennis Francis 
AuthorDate: Wed May 3 13:00:09 2023 +0530
Commit: Henry Castro 
CommitDate: Wed May 3 15:10:40 2023 +0200

sc: use the current cell's numfmt to format...

to format the values in the validation list when the items are numbers.
This is better than applying no formatting since we lost track of the
source formatting when values are passed through a matrix.

Change-Id: I06432bd93ef8d01181dd16d2f5ee99eb0477c094
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151313
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Henry Castro 

diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 8fb0f9f7924a..009bc0eaebe7 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -856,6 +856,7 @@ bool ScValidationData::GetSelectionFromFormula(
 rMatch = -1;
 
 SvNumberFormatter* pFormatter = GetDocument()->GetFormatTable();
+sal_uInt32 nDestFormat = pDocument->GetNumberFormat(rPos.Col(), 
rPos.Row(), rPos.Tab());
 
 SCSIZE  nCol, nRow, nCols, nRows, n = 0;
 pValues->GetDimensions( nCols, nRows );
@@ -957,7 +958,7 @@ bool ScValidationData::GetSelectionFromFormula(
 }
 else
 {
-pFormatter->GetInputLineString( nMatVal.fVal, 0, 
aValStr );
+pFormatter->GetInputLineString( nMatVal.fVal, 
nDestFormat, aValStr );
 }
 }
 


[Libreoffice-commits] core.git: offapi/com

2023-04-27 Thread Dennis Francis (via logerrit)
 offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 53279b8bc210485471f9550ebbc5ad09adefa4c0
Author: Dennis Francis 
AuthorDate: Thu Apr 27 12:36:49 2023 +0530
Commit: Dennis Francis 
CommitDate: Thu Apr 27 10:10:55 2023 +0200

add @since for COMPACT_LAYOUT

Change-Id: I4b7f918e846ea1d220b9df2be5bc0b39d1f22f7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151086
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl 
b/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
index 4bbc233c674e..ae8cee9ee75c 100644
--- a/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
+++ b/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
@@ -68,6 +68,8 @@ constants DataPilotFieldLayoutMode
 the subtotals take up more than one row (manually selected, or because 
there
 are several data fields), they are always shown below the item's data,
 regardless of the setting.
+
+@since LibreOffice 7.6
  */
 
 const long COMPACT_LAYOUT = 3;


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - include/xmloff offapi/com schema/libreoffice sc/inc sc/qa sc/source sc/uiconfig xmloff/source

2023-04-27 Thread Dennis Francis (via logerrit)
 include/xmloff/xmltoken.hxx |2 
 offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl  |   12 
 sc/inc/attrib.hxx   |9 
 sc/inc/dpobject.hxx |3 
 sc/inc/dpoutput.hxx |   13 
 sc/inc/dpsave.hxx   |5 
 sc/inc/dptabsrc.hxx |4 
 sc/inc/fillinfo.hxx |7 
 sc/inc/globstr.hrc  |2 
 sc/qa/unit/data/xlsx/pivot-table/pivotcompact.xlsx  |binary
 sc/qa/unit/pivottable_filters_test.cxx  |   75 +++
 sc/source/core/data/attrib.cxx  |   11 
 sc/source/core/data/dpobject.cxx|   30 +
 sc/source/core/data/dpoutput.cxx|  205 
 sc/source/core/data/dpsave.cxx  |7 
 sc/source/core/data/fillinfo.cxx|   11 
 sc/source/filter/excel/xepivotxml.cxx   |   47 +-
 sc/source/filter/inc/pivottablebuffer.hxx   |1 
 sc/source/filter/oox/pivottablebuffer.cxx   |   24 -
 sc/source/filter/xml/XMLExportDataPilot.cxx |   10 
 sc/source/filter/xml/xmldpimp.cxx   |   42 +
 sc/source/filter/xml/xmldpimp.hxx   |5 
 sc/source/ui/cctrl/checklistmenu.cxx|   58 ++
 sc/source/ui/cctrl/dpcontrol.cxx|   74 +++
 sc/source/ui/dbgui/PivotLayoutDialog.cxx|4 
 sc/source/ui/dbgui/pvfundlg.cxx |4 
 sc/source/ui/inc/PivotLayoutDialog.hxx  |1 
 sc/source/ui/inc/checklistmenu.hxx  |   14 
 sc/source/ui/inc/dpcontrol.hxx  |8 
 sc/source/ui/inc/gridwin.hxx|   12 
 sc/source/ui/view/gridwin.cxx   |   11 
 sc/source/ui/view/gridwin2.cxx  |  275 ++--
 sc/source/ui/view/gridwin4.cxx  |   16 
 sc/uiconfig/scalc/ui/datafieldoptionsdialog.ui  |1 
 sc/uiconfig/scalc/ui/filterdropdown.ui  |   30 +
 sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui  |   19 
 schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng |   23 +
 xmloff/source/core/xmltoken.cxx |2 
 xmloff/source/token/tokens.txt  |2 
 39 files changed, 988 insertions(+), 91 deletions(-)

New commits:
commit 29014b2d883d4b94039bfba697606b9b87b905aa
Author: Dennis Francis 
AuthorDate: Wed Jan 25 13:51:17 2023 +0530
Commit: Dennis Francis 
CommitDate: Thu Apr 27 08:41:09 2023 +0200

sc: pivot table compact layout

This implements compact layout for pivot tables. In ooxml each row field
can have a compact layout setting. Support for any such "mixed" layout
of tabular/outline/compact per field is also implemented. This also
implements expand/collpse toggle buttons to field labels to make pivot
tables with compact layout more usable. Such buttons are also available
if other layouts are used.

Change-Id: Ieaa1f3bd282ebdec804d0b45a0af7b3d95a2027f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150344
Tested-by: Dennis Francis 
Reviewed-by: Dennis Francis 

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 96ffea048732..af0939a8568a 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -2570,6 +2570,7 @@ namespace xmloff::token {
 XML_TABULAR_LAYOUT,
 XML_OUTLINE_SUBTOTALS_TOP,
 XML_OUTLINE_SUBTOTALS_BOTTOM,
+XML_COMPACT_LAYOUT,
 XML_LAYOUT_MODE,
 XML_DATA_PILOT_LAYOUT_INFO,
 
@@ -2755,6 +2756,7 @@ namespace xmloff::token {
 
 XML_SHOW_FILTER_BUTTON,
 XML_DRILL_DOWN_ON_DOUBLE_CLICK,
+XML_SHOW_DRILL_DOWN_BUTTONS,
 XML_HEADER_GRID_LAYOUT,
 XML_GROUPED_BY,
 XML_DAYS,
diff --git a/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl 
b/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
index 470b671a3028..4bbc233c674e 100644
--- a/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
+++ b/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
@@ -60,6 +60,18 @@ constants DataPilotFieldLayoutMode
 
 const long OUTLINE_SUBTOTALS_BOTTOM = 2;
 
+/** In compact layout mode, the items from the following field start in 
the row
+below an item's name with an indentation but in the same column as 
this field's
+items are.
+
+Subtotals are shown at the top (on the same row as the item's 
name). When
+the subtotals ta

[Libreoffice-commits] core.git: include/xmloff offapi/com schema/libreoffice sc/inc sc/qa sc/source sc/uiconfig xmloff/source

2023-04-27 Thread Dennis Francis (via logerrit)
 include/xmloff/xmltoken.hxx |2 
 offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl  |   12 
 sc/inc/attrib.hxx   |9 
 sc/inc/dpobject.hxx |3 
 sc/inc/dpoutput.hxx |   13 
 sc/inc/dpsave.hxx   |5 
 sc/inc/dptabsrc.hxx |4 
 sc/inc/fillinfo.hxx |7 
 sc/inc/globstr.hrc  |2 
 sc/qa/unit/data/xlsx/pivot-table/pivotcompact.xlsx  |binary
 sc/qa/unit/pivottable_filters_test.cxx  |   78 +++
 sc/source/core/data/attrib.cxx  |   11 
 sc/source/core/data/dpobject.cxx|   30 +
 sc/source/core/data/dpoutput.cxx|  205 
 sc/source/core/data/dpsave.cxx  |7 
 sc/source/core/data/fillinfo.cxx|   11 
 sc/source/filter/excel/xepivotxml.cxx   |   47 +-
 sc/source/filter/inc/pivottablebuffer.hxx   |1 
 sc/source/filter/oox/pivottablebuffer.cxx   |   24 -
 sc/source/filter/xml/XMLExportDataPilot.cxx |   10 
 sc/source/filter/xml/xmldpimp.cxx   |   42 +
 sc/source/filter/xml/xmldpimp.hxx   |5 
 sc/source/ui/cctrl/checklistmenu.cxx|   58 ++
 sc/source/ui/cctrl/dpcontrol.cxx|   74 +++
 sc/source/ui/dbgui/PivotLayoutDialog.cxx|4 
 sc/source/ui/dbgui/pvfundlg.cxx |4 
 sc/source/ui/inc/PivotLayoutDialog.hxx  |1 
 sc/source/ui/inc/checklistmenu.hxx  |   12 
 sc/source/ui/inc/dpcontrol.hxx  |8 
 sc/source/ui/inc/gridwin.hxx|   12 
 sc/source/ui/view/gridwin.cxx   |   11 
 sc/source/ui/view/gridwin2.cxx  |  275 ++--
 sc/source/ui/view/gridwin4.cxx  |   16 
 sc/uiconfig/scalc/ui/datafieldoptionsdialog.ui  |1 
 sc/uiconfig/scalc/ui/filterdropdown.ui  |   30 +
 sc/uiconfig/scalc/ui/pivottablelayoutdialog.ui  |   19 
 schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng |   23 +
 xmloff/source/core/xmltoken.cxx |2 
 xmloff/source/token/tokens.txt  |2 
 39 files changed, 989 insertions(+), 91 deletions(-)

New commits:
commit 2f8d10b0b9baa03b8a713e9fd1342fe6c8094fb4
Author: Dennis Francis 
AuthorDate: Wed Jan 25 13:51:17 2023 +0530
Commit: Dennis Francis 
CommitDate: Thu Apr 27 08:35:59 2023 +0200

sc: pivot table compact layout

This implements compact layout for pivot tables. In ooxml each row field
can have a compact layout setting. Support for any such "mixed" layout
of tabular/outline/compact per field is also implemented. This also
implements expand/collpse toggle buttons to field labels to make pivot
tables with compact layout more usable. Such buttons are also available
if other layouts are used.

Conflicts:
sc/qa/unit/pivottable_filters_test.cxx
sc/source/ui/cctrl/checklistmenu.cxx
sc/source/ui/inc/checklistmenu.hxx

Change-Id: Ieaa1f3bd282ebdec804d0b45a0af7b3d95a2027f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151057
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 0fc0127813e7..0c63a31d0818 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -2572,6 +2572,7 @@ namespace xmloff::token {
 XML_TABULAR_LAYOUT,
 XML_OUTLINE_SUBTOTALS_TOP,
 XML_OUTLINE_SUBTOTALS_BOTTOM,
+XML_COMPACT_LAYOUT,
 XML_LAYOUT_MODE,
 XML_DATA_PILOT_LAYOUT_INFO,
 
@@ -2757,6 +2758,7 @@ namespace xmloff::token {
 
 XML_SHOW_FILTER_BUTTON,
 XML_DRILL_DOWN_ON_DOUBLE_CLICK,
+XML_SHOW_DRILL_DOWN_BUTTONS,
 XML_HEADER_GRID_LAYOUT,
 XML_GROUPED_BY,
 XML_DAYS,
diff --git a/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl 
b/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
index 470b671a3028..4bbc233c674e 100644
--- a/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
+++ b/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl
@@ -60,6 +60,18 @@ constants DataPilotFieldLayoutMode
 
 const long OUTLINE_SUBTOTALS_BOTTOM = 2;
 
+/** In compact layout mode, the items from the following field start in 
the row
+below an item's name with an indentation but in the s

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

2023-02-09 Thread Dennis Francis (via logerrit)
 sc/source/ui/view/gridwin4.cxx |   17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit b9516ea478b7df97cd97c48d5462f0e544b6b584
Author: Dennis Francis 
AuthorDate: Fri May 6 10:56:38 2022 +0530
Commit: Andras Timar 
CommitDate: Thu Feb 9 11:44:42 2023 +

lok: do not recreate lok-drawview for every tile paint

This lets the ScLOKDrawView live long enough for non-tile painting
related invocation of its methods and hopefully those of its member objects.

This is a blind fix for the following crash:

/opt/collaboraoffice/program/../program/libsclo.so
(anonymous 
namespace)::ScLOKProxyObjectContact::calculateGridOffsetForViewOjectContact(basegfx::B2DVector&,
 sdr::contact::ViewObjectContact const&) const
...
/opt/collaboraoffice/program/libmergedlo.so

SdrTextObj::NbcSetOutlinerParaObjectForText(std::unique_ptr >, SdrText*)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/svdraw/svdotext.cxx:1379
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::TextProperties::ItemSetChanged(SfxItemSet const&)

/opt/rh/devtoolset-10/root/usr/include/c++/10/bits/unique_ptr.h:360
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::RectangleProperties::ItemSetChanged(SfxItemSet 
const&)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/sdr/properties/rectangleproperties.cxx:54
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::DefaultProperties::SetObjectItem(SfxPoolItem 
const&)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/sdr/properties/defaultproperties.cxx:120
/opt/collaboraoffice/program/libscfiltlo.so
XclTxo::XclTxo(XclExpRoot const&, EditTextObject const&, SdrObject*)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/include/svl/cenumitm.hxx:26
/opt/collaboraoffice/program/libscfiltlo.so
XclObjComment::XclObjComment(XclExpObjectManager&, tools::Rectangle 
const&, EditTextObject const&, SdrCaptionObj*, bool, ScAddress const&, 
tools::Rectangle const&, tools::Rectangle const&)

/opt/rh/devtoolset-10/root/usr/include/c++/10/bits/unique_ptr.h:179
/opt/collaboraoffice/program/libscfiltlo.so
XclExpNote::XclExpNote(XclExpRoot const&, ScAddress const&, 
ScPostIt const*, rtl::OUString const&)
/opt/rh/devtoolset-10/root/usr/include/c++/10/tuple:137
/opt/collaboraoffice/program/libscfiltlo.so
ExcTable::FillAsTableXml()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/include/rtl/ref.hxx:65
/opt/collaboraoffice/program/libscfiltlo.so
ExcDocument::ReadDoc()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/sc/source/filter/excel/excdoc.cxx:747
/opt/collaboraoffice/program/libscfiltlo.so
XclExpXmlStream::exportDocument()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/sc/source/filter/excel/xestream.cxx:1107
/opt/collaboraoffice/program/libooxlo.so

Change-Id: I248395cca1e2da37208fc449aca731175a5aa368
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133914
Tested-by: Andras Timar 
Reviewed-by: Andras Timar 
(cherry picked from commit c17c410706eab6e4d449b2a20a51bf3702329341)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143583
Tested-by: Jenkins CollaboraOffice 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146683
Tested-by: Jenkins

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index a7b814c233fb..6c9c2a7b1819 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1657,13 +1657,16 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 {
 bool bPrintTwipsMsgs = comphelper::LibreOfficeKit::isCompatFlagSet(
 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
-mpLOKDrawView.reset(bPrintTwipsMsgs ?
-new ScLOKDrawView(
-,
-mrViewData) :
-new FmFormView(
-*pModel,
-));
+if (!mpLOKDrawView)
+{
+mpLOKDrawView.reset(bPrintTwipsMsgs ?
+new ScLOKDrawView(
+,
+mrViewData) :
+new FmFormView(
+*pModel,
+));
+}
 
 mpLOKDrawView->SetNegativeX(bLayoutRTL);
 mpLOKDrawView->ShowSdrPage(mpLOKDrawView->GetModel().GetPage(nTab));


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

2023-02-07 Thread Dennis Francis (via logerrit)
 sc/source/ui/view/gridwin4.cxx |   17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit 2422fdacee313eb6fb9db0304dda5a7123aeb8f0
Author: Dennis Francis 
AuthorDate: Fri May 6 10:56:38 2022 +0530
Commit: Andras Timar 
CommitDate: Tue Feb 7 10:40:19 2023 +

lok: do not recreate lok-drawview for every tile paint

This lets the ScLOKDrawView live long enough for non-tile painting
related invocation of its methods and hopefully those of its member objects.

This is a blind fix for the following crash:

/opt/collaboraoffice/program/../program/libsclo.so
(anonymous 
namespace)::ScLOKProxyObjectContact::calculateGridOffsetForViewOjectContact(basegfx::B2DVector&,
 sdr::contact::ViewObjectContact const&) const
...
/opt/collaboraoffice/program/libmergedlo.so

SdrTextObj::NbcSetOutlinerParaObjectForText(std::unique_ptr >, SdrText*)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/svdraw/svdotext.cxx:1379
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::TextProperties::ItemSetChanged(SfxItemSet const&)

/opt/rh/devtoolset-10/root/usr/include/c++/10/bits/unique_ptr.h:360
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::RectangleProperties::ItemSetChanged(SfxItemSet 
const&)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/sdr/properties/rectangleproperties.cxx:54
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::DefaultProperties::SetObjectItem(SfxPoolItem 
const&)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/sdr/properties/defaultproperties.cxx:120
/opt/collaboraoffice/program/libscfiltlo.so
XclTxo::XclTxo(XclExpRoot const&, EditTextObject const&, SdrObject*)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/include/svl/cenumitm.hxx:26
/opt/collaboraoffice/program/libscfiltlo.so
XclObjComment::XclObjComment(XclExpObjectManager&, tools::Rectangle 
const&, EditTextObject const&, SdrCaptionObj*, bool, ScAddress const&, 
tools::Rectangle const&, tools::Rectangle const&)

/opt/rh/devtoolset-10/root/usr/include/c++/10/bits/unique_ptr.h:179
/opt/collaboraoffice/program/libscfiltlo.so
XclExpNote::XclExpNote(XclExpRoot const&, ScAddress const&, 
ScPostIt const*, rtl::OUString const&)
/opt/rh/devtoolset-10/root/usr/include/c++/10/tuple:137
/opt/collaboraoffice/program/libscfiltlo.so
ExcTable::FillAsTableXml()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/include/rtl/ref.hxx:65
/opt/collaboraoffice/program/libscfiltlo.so
ExcDocument::ReadDoc()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/sc/source/filter/excel/excdoc.cxx:747
/opt/collaboraoffice/program/libscfiltlo.so
XclExpXmlStream::exportDocument()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/sc/source/filter/excel/xestream.cxx:1107
/opt/collaboraoffice/program/libooxlo.so

Change-Id: I248395cca1e2da37208fc449aca731175a5aa368
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133914
Tested-by: Andras Timar 
Reviewed-by: Andras Timar 
(cherry picked from commit c17c410706eab6e4d449b2a20a51bf3702329341)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143583
Tested-by: Jenkins CollaboraOffice 

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 31022c43144d..88f8596aea30 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1656,13 +1656,16 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 {
 bool bPrintTwipsMsgs = comphelper::LibreOfficeKit::isCompatFlagSet(
 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
-mpLOKDrawView.reset(bPrintTwipsMsgs ?
-new ScLOKDrawView(
-,
-mrViewData) :
-new FmFormView(
-*pModel,
-));
+if (!mpLOKDrawView)
+{
+mpLOKDrawView.reset(bPrintTwipsMsgs ?
+new ScLOKDrawView(
+,
+mrViewData) :
+new FmFormView(
+*pModel,
+));
+}
 
 mpLOKDrawView->SetNegativeX(bLayoutRTL);
 mpLOKDrawView->ShowSdrPage(mpLOKDrawView->GetModel()->GetPage(nTab));


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

2023-01-28 Thread Dennis Francis (via logerrit)
 sw/qa/extras/tiledrendering/data/savedauthorfield.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx|   16 +++
 sw/source/uibase/uno/unotxdoc.cxx |   19 +-
 3 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit 1f53743af427df517c4da7202cfbd4a529449af2
Author: Dennis Francis 
AuthorDate: Tue Jan 17 12:23:44 2023 +0530
Commit: Andras Timar 
CommitDate: Sat Jan 28 19:40:39 2023 +0100

sw: lok: use redline author for saved author fields(2)

Without the fix author fields will expand to "Unknown author" when
loading files which have author fields in them. But only update the
fields when the first view joins and not for later view joins.

online.git does not expect document to be modified just after load, so
to avoid this situation clear the document modified flag just after
field update.

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

diff --git a/sw/qa/extras/tiledrendering/data/savedauthorfield.odt 
b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt
new file mode 100644
index ..e4b41d28b92a
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 632dc82c36c6..ced79f6beed6 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3831,6 +3831,22 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testAuthorField)
 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", 
sAuthor);
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSavedAuthorField)
+{
+SwXTextDocument* pXTextDocument = createDoc("savedauthorfield.odt");
+const OUString sAuthor("XYZ ABCD");
+uno::Sequence 
aPropertyValues1(comphelper::InitPropertySequence(
+{
+{".uno:Author", uno::makeAny(sAuthor)},
+}));
+pXTextDocument->initializeForTiledRendering(aPropertyValues1);
+
+Scheduler::ProcessEventsToIdle();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", 
sAuthor);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 9cd00ead1c9e..26521c2ccf45 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3568,6 +3568,9 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::SequenceGetRedlineAuthor(SW_MOD()->GetRedlineAuthor());
+OUString sAuthor;
+
 for (const beans::PropertyValue& rValue : rArguments)
 {
 if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has())
@@ -3576,8 +3579,9 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence());
 else if (rValue.Name == ".uno:Author" && rValue.Value.has())
 {
+sAuthor = rValue.Value.get();
 // Store the author name in the view.
-pView->SetRedlineAuthor(rValue.Value.get());
+pView->SetRedlineAuthor(sAuthor);
 // Let the actual author name pick up the value from the current
 // view, which would normally happen only during the next view
 // switch.
@@ -3587,6 +3591,19 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence());
 }
 
+if (!sAuthor.isEmpty() && sAuthor != sOrigAuthor)
+{
+SwView* pFirstView = static_cast(SfxViewShell::GetFirst());
+if (pFirstView && SfxViewShell::GetNext(*pFirstView) == nullptr)
+{
+if (SwEditShell* pShell = >GetWrtShell())
+{
+pShell->SwViewShell::UpdateFields(true);
+pShell->ResetModified();
+}
+}
+}
+
 // Set the initial zoom value to 1; usually it is set in setClientZoom and
 // SwViewShell::PaintTile; zoom value is used for chart in place
 // editing, see postMouseEvent and setGraphicSelection methods.


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

2023-01-17 Thread Dennis Francis (via logerrit)
 sw/qa/extras/tiledrendering/data/savedauthorfield.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx|   16 +++
 sw/source/uibase/uno/unotxdoc.cxx |   19 +-
 3 files changed, 34 insertions(+), 1 deletion(-)

New commits:
commit 5b1f5319fc065eac71267b29472111d81e0dc14e
Author: Dennis Francis 
AuthorDate: Tue Jan 17 12:23:44 2023 +0530
Commit: Miklos Vajna 
CommitDate: Tue Jan 17 14:26:29 2023 +

sw: lok: use redline author for saved author fields(2)

Without the fix author fields will expand to "Unknown author" when
loading files which have author fields in them. But only update the
fields when the first view joins and not for later view joins.

online.git does not expect document to be modified just after load, so
to avoid this situation clear the document modified flag just after
field update.

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

diff --git a/sw/qa/extras/tiledrendering/data/savedauthorfield.odt 
b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt
new file mode 100644
index ..e4b41d28b92a
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 88b4dcc95d7f..3330e419dc8b 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3791,6 +3791,22 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testAuthorField)
 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", 
sAuthor);
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSavedAuthorField)
+{
+SwXTextDocument* pXTextDocument = createDoc("savedauthorfield.odt");
+const OUString sAuthor("XYZ ABCD");
+uno::Sequence 
aPropertyValues1(comphelper::InitPropertySequence(
+{
+{".uno:Author", uno::makeAny(sAuthor)},
+}));
+pXTextDocument->initializeForTiledRendering(aPropertyValues1);
+
+Scheduler::ProcessEventsToIdle();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", 
sAuthor);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index f91fe5626f1b..78af58de3184 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3570,6 +3570,9 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::SequenceGetRedlineAuthor(SW_MOD()->GetRedlineAuthor());
+OUString sAuthor;
+
 for (const beans::PropertyValue& rValue : rArguments)
 {
 if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has())
@@ -3578,8 +3581,9 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence());
 else if (rValue.Name == ".uno:Author" && rValue.Value.has())
 {
+sAuthor = rValue.Value.get();
 // Store the author name in the view.
-pView->SetRedlineAuthor(rValue.Value.get());
+pView->SetRedlineAuthor(sAuthor);
 // Let the actual author name pick up the value from the current
 // view, which would normally happen only during the next view
 // switch.
@@ -3589,6 +3593,19 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence());
 }
 
+if (!sAuthor.isEmpty() && sAuthor != sOrigAuthor)
+{
+SwView* pFirstView = static_cast(SfxViewShell::GetFirst());
+if (pFirstView && SfxViewShell::GetNext(*pFirstView) == nullptr)
+{
+if (SwEditShell* pShell = >GetWrtShell())
+{
+pShell->SwViewShell::UpdateFields(true);
+pShell->ResetModified();
+}
+}
+}
+
 // Set the initial zoom value to 1; usually it is set in setClientZoom and
 // SwViewShell::PaintTile; zoom value is used for chart in place
 // editing, see postMouseEvent and setGraphicSelection methods.


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

2023-01-12 Thread Dennis Francis (via logerrit)
 sw/qa/extras/tiledrendering/data/savedauthorfield.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx|   16 
 sw/source/uibase/uno/unotxdoc.cxx |   16 +++-
 3 files changed, 31 insertions(+), 1 deletion(-)

New commits:
commit d4760b5d4b49fef1c832357059c7e184b3cc0bc4
Author: Dennis Francis 
AuthorDate: Mon Jan 9 14:14:02 2023 +0530
Commit: Miklos Vajna 
CommitDate: Thu Jan 12 11:08:30 2023 +

sw: lok: use redline author for saved author fields

Without the fix author fields will expand to "Unknown author" when
loading files which have author fields in them. But only update the
fields when the first view joins and not for later view joins.

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

diff --git a/sw/qa/extras/tiledrendering/data/savedauthorfield.odt 
b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt
new file mode 100644
index ..a060c5892f12
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index f9c4e77e1631..44accc6d51a7 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3831,6 +3831,22 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testAuthorField)
 assertXPath(pXmlDoc, 
"/root/page[1]/body/txt[1]/SwParaPortion[1]/SwLineLayout[1]/SwFieldPortion[1]", 
"expand", sAuthor);
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSavedAuthorField)
+{
+SwXTextDocument* pXTextDocument = createDoc("savedauthorfield.odt");
+const OUString sAuthor("XYZ ABCD");
+uno::Sequence 
aPropertyValues1(comphelper::InitPropertySequence(
+{
+{".uno:Author", uno::Any(sAuthor)},
+}));
+pXTextDocument->initializeForTiledRendering(aPropertyValues1);
+
+Scheduler::ProcessEventsToIdle();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, 
"/root/page[1]/body/txt[1]/SwParaPortion[1]/SwLineLayout[1]/SwFieldPortion[1]", 
"expand", sAuthor);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 9cd00ead1c9e..22d70bc112da 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3568,6 +3568,9 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::SequenceGetRedlineAuthor(SW_MOD()->GetRedlineAuthor());
+OUString sAuthor;
+
 for (const beans::PropertyValue& rValue : rArguments)
 {
 if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has())
@@ -3576,8 +3579,9 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence());
 else if (rValue.Name == ".uno:Author" && rValue.Value.has())
 {
+sAuthor = rValue.Value.get();
 // Store the author name in the view.
-pView->SetRedlineAuthor(rValue.Value.get());
+pView->SetRedlineAuthor(sAuthor);
 // Let the actual author name pick up the value from the current
 // view, which would normally happen only during the next view
 // switch.
@@ -3587,6 +3591,16 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence());
 }
 
+if (!sAuthor.isEmpty() && sAuthor != sOrigAuthor)
+{
+SwView* pFirstView = static_cast(SfxViewShell::GetFirst());
+if (pFirstView && SfxViewShell::GetNext(*pFirstView) == nullptr)
+{
+if (SwViewShell* pShell = >GetWrtShell())
+pShell->UpdateFields(true);
+}
+}
+
 // Set the initial zoom value to 1; usually it is set in setClientZoom and
 // SwViewShell::PaintTile; zoom value is used for chart in place
 // editing, see postMouseEvent and setGraphicSelection methods.


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

2023-01-11 Thread Dennis Francis (via logerrit)
 sw/qa/extras/tiledrendering/data/savedauthorfield.odt |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx|   16 
 sw/source/uibase/uno/unotxdoc.cxx |   16 +++-
 3 files changed, 31 insertions(+), 1 deletion(-)

New commits:
commit c33e60dd5d5aa8dd585afc9498f87d17ab22fb27
Author: Dennis Francis 
AuthorDate: Mon Jan 9 14:14:02 2023 +0530
Commit: Miklos Vajna 
CommitDate: Thu Jan 12 07:22:05 2023 +

sw: lok: use redline author for saved author fields

Without the fix author fields will expand to "Unknown author" when
loading files which have author fields in them. But only update the
fields when the first view joins and not for later view joins.

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

diff --git a/sw/qa/extras/tiledrendering/data/savedauthorfield.odt 
b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt
new file mode 100644
index ..a060c5892f12
Binary files /dev/null and 
b/sw/qa/extras/tiledrendering/data/savedauthorfield.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 88b4dcc95d7f..3330e419dc8b 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -3791,6 +3791,22 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testAuthorField)
 assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", 
sAuthor);
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSavedAuthorField)
+{
+SwXTextDocument* pXTextDocument = createDoc("savedauthorfield.odt");
+const OUString sAuthor("XYZ ABCD");
+uno::Sequence 
aPropertyValues1(comphelper::InitPropertySequence(
+{
+{".uno:Author", uno::makeAny(sAuthor)},
+}));
+pXTextDocument->initializeForTiledRendering(aPropertyValues1);
+
+Scheduler::ProcessEventsToIdle();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", 
sAuthor);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index f91fe5626f1b..05bddd1f5747 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3570,6 +3570,9 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::SequenceGetRedlineAuthor(SW_MOD()->GetRedlineAuthor());
+OUString sAuthor;
+
 for (const beans::PropertyValue& rValue : rArguments)
 {
 if (rValue.Name == ".uno:HideWhitespace" && rValue.Value.has())
@@ -3578,8 +3581,9 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence());
 else if (rValue.Name == ".uno:Author" && rValue.Value.has())
 {
+sAuthor = rValue.Value.get();
 // Store the author name in the view.
-pView->SetRedlineAuthor(rValue.Value.get());
+pView->SetRedlineAuthor(sAuthor);
 // Let the actual author name pick up the value from the current
 // view, which would normally happen only during the next view
 // switch.
@@ -3589,6 +3593,16 @@ void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence());
 }
 
+if (!sAuthor.isEmpty() && sAuthor != sOrigAuthor)
+{
+SwView* pFirstView = static_cast(SfxViewShell::GetFirst());
+if (pFirstView && SfxViewShell::GetNext(*pFirstView) == nullptr)
+{
+if (SwViewShell* pShell = >GetWrtShell())
+pShell->UpdateFields(true);
+}
+}
+
 // Set the initial zoom value to 1; usually it is set in setClientZoom and
 // SwViewShell::PaintTile; zoom value is used for chart in place
 // editing, see postMouseEvent and setGraphicSelection methods.


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

2023-01-09 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   46 ++
 vcl/source/gdi/pdfobjectcopier.cxx|   24 +
 3 files changed, 69 insertions(+), 1 deletion(-)

New commits:
commit cff10826774a7767cacfb2bf8fef0eea94615627
Author: Dennis Francis 
AuthorDate: Fri Dec 2 13:11:42 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Jan 10 07:14:31 2023 +

vcl: Copy the resource kind object itself if...

some of the items in that resource are themselves dictionaries instead
of references.

Change-Id: I427386b14fe5507dfdfc9745dad27a8fceefd929
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143564
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 4cb521b28e8582eda1a63bc4d92061fd111a2e3d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144438
Tested-by: Jenkins
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145204

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
index 0390ccad8410..fdda33f78231 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ce070a711911..4cf31e708220 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4247,6 +4247,52 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportMediaBoxOrigin)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportResourceItemReference)
+{
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im10 that has reference to Font in 
page 2.
+auto pInnerIm = aDocument.LookupObject(10);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pResources
+= 
dynamic_cast(pInnerIm->Lookup("Resources"));
+CPPUNIT_ASSERT(pResources);
+auto pFontsReference
+= 
dynamic_cast(pResources->LookupElement("Font"));
+CPPUNIT_ASSERT(pFontsReference);
+
+auto pFontsObject = pFontsReference->LookupObject();
+CPPUNIT_ASSERT(pFontsObject);
+
+auto pFontDict
+= 
dynamic_cast(pFontsObject->Lookup("FF132"));
+CPPUNIT_ASSERT(pFontDict);
+
+auto pFontDescriptor = pFontDict->LookupObject("FontDescriptor");
+CPPUNIT_ASSERT(pFontDescriptor);
+
+auto pFontWidths = pFontDict->LookupObject("Widths");
+CPPUNIT_ASSERT(pFontWidths);
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 67f70d10f2a9..2f32cdc27ce1 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -184,6 +184,7 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 
 // Get the rKind subset of the resource dictionary.
 std::map aItems;
+filter::PDFObjectElement* pKindObject = nullptr;
 if (auto pResources = 
dynamic_cast(rPage.Lookup("Resources")))
 {
 // Resources is a direct dictionary.
@@ -202,6 +203,7 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 return {};
 }
 
+pKindObject = pReferenced;
 aItems = pReferenced->GetDictionaryItems();
 }
 }
@@ -210,23 +212,37 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 // Resources is an indirect object.
 filter::PDFElement* pValue = pPageResources->Lookup(rKind);
 if (auto pDictionary = 
dynamic_cast(pValue))
+{
 // Kind is a direct dictionary.
 aItems = pDictionary->GetItems();
+}
 else if (filter::PDFObjectElement* pObject = 
pPageResources->LookupObject(rKind))
+{
 // Kind is an indirect object.
 aItems = pObject->GetDictionaryItems();
+pKindObject = pObject;
+}
 }
 if (aItems.empty())
 return {};
 
 SvMemoryStream&am

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

2023-01-09 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   61 ++
 vcl/source/gdi/pdfwriter_impl.cxx |   29 ++--
 3 files changed, 85 insertions(+), 5 deletions(-)

New commits:
commit d9cab7dc6dbbbe3d80aa765cfd0b3c9f85d73c06
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:47:12 2022 +0530
Commit: Xisco Fauli 
CommitDate: Mon Jan 9 17:08:24 2023 +

vcl: use /MediaBox origin in the ctm...

of the inner XObject, else the clip polypolygon may clip out partly or
whole contents. Adjusting the clip polypolygon is not straightforward.

Change-Id: If3b208ba850c3579c9e16c15e4fb2f947dad4406
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143561
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit a67dcc248a103098de883a4dd2fa9ff2e1cc1f90)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144436
Tested-by: Jenkins
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145202

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
index 598358a636aa..0390ccad8410 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 428f9d5a132a..ce070a711911 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4186,6 +4186,67 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportFilterSingletonArray)
 CPPUNIT_ASSERT(it != pEnd);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportMediaBoxOrigin)
+{
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im10 that contains the rectangle 
drawings in page 2.
+auto pInnerIm = aDocument.LookupObject(10);
+CPPUNIT_ASSERT(pInnerIm);
+
+constexpr sal_Int32 aOrigin[2] = { -800, -600 };
+sal_Int32 aSize[2] = { 0, 0 };
+
+auto pBBox = 
dynamic_cast(pInnerIm->Lookup("BBox"));
+CPPUNIT_ASSERT(pBBox);
+const auto& rElements2 = pBBox->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(4), rElements2.size());
+for (sal_Int32 nIdx = 0; nIdx < 4; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements2[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+if (nIdx < 2)
+CPPUNIT_ASSERT_EQUAL(aOrigin[nIdx], 
static_cast(pNumElement->GetValue()));
+else
+aSize[nIdx - 2] = static_cast(pNumElement->GetValue()) 
- aOrigin[nIdx - 2];
+}
+
+auto pMatrix = 
dynamic_cast(pInnerIm->Lookup("Matrix"));
+CPPUNIT_ASSERT(pMatrix);
+const auto& rElements = pMatrix->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(6), rElements.size());
+sal_Int32 aMatTranslate[6]
+= { // Rotation by $\theta$ $cos(\theta), sin(\theta), -sin(\theta), 
cos(\theta)$
+0, -1, 1, 0,
+// Translate x,y
+-aOrigin[1] - aSize[1] / 2 + aSize[0] / 2, aOrigin[0] + aSize[0] / 
2 + aSize[1] / 2
+  };
+
+for (sal_Int32 nIdx = 0; nIdx < 6; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+CPPUNIT_ASSERT_EQUAL(aMatTranslate[nIdx], 
static_cast(pNumElement->GetValue()));
+}
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index f4a3145c5085..d95a74aeb6af 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8873,6 +8873,21 @@ void PDFWriterImpl::writeReferenceXObject(const 
ReferenceXObjectEmit& rEmit)
 return;
 }
 
+double aOrigin[2] = { 0.0, 0.0 };
+if (auto* pArray = 
dynamic_cast(pPage->Lookup("MediaBox")))
+{
+const auto& rElements = pArray->GetElements();
+if (rElements.size() >= 4)
+{
+// get x1, y1 of the rectangle.
+for (sal_Int32 nIdx = 0; nIdx < 2; 

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

2023-01-02 Thread Dennis Francis (via logerrit)
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   41 +
 sw/source/core/fields/docufld.cxx  |   11 ++
 2 files changed, 51 insertions(+), 1 deletion(-)

New commits:
commit cf9e91f4082a9b01014e99e112e14a12246ce5f2
Author: Dennis Francis 
AuthorDate: Thu May 19 15:27:48 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Jan 3 07:27:10 2023 +

sw: prefer view's redline author name...

to expand SwAuthorFieldType. Redline author name is set in
SwXTextDocument::initializeForTiledRendering each time a new view is
created.

Change-Id: I316e0cae4399796682949de14b6d4b924833eb04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134608
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143649
(cherry picked from commit 8be4a713e9f44bf05aebc0a3054654a18b4de065)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143585
Tested-by: Jenkins

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index e39dc418f8a2..f9c4e77e1631 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -19,6 +19,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -3790,6 +3792,45 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDateContentControl)
 CPPUNIT_ASSERT_EQUAL(OUString("2022-05-30"), 
pTextNode->GetExpandText(pWrtShell->GetLayout()));
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAuthorField)
+{
+SwXTextDocument* pXTextDocument = createDoc();
+const OUString sAuthor("Abcd Xyz");
+
+uno::Sequence 
aPropertyValues1(comphelper::InitPropertySequence(
+{
+{".uno:Author", uno::Any(sAuthor)},
+}));
+pXTextDocument->initializeForTiledRendering(aPropertyValues1);
+
+auto insertAuthorField = [this]()
+{
+uno::Reference const xMSF(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Reference const xTD(mxComponent, 
uno::UNO_QUERY_THROW);
+
+auto const xText = xTD->getText();
+auto const xTextCursor = xText->createTextCursor();
+CPPUNIT_ASSERT(xTextCursor.is());
+
+xTextCursor->gotoEnd(false);
+
+uno::Reference const xTextField(
+xMSF->createInstance("com.sun.star.text.textfield.Author"), 
uno::UNO_QUERY_THROW);
+
+uno::Reference xTextFieldProps(xTextField, 
uno::UNO_QUERY_THROW);
+xTextFieldProps->setPropertyValue("FullName", uno::Any(true));
+
+xText->insertTextContent(xTextCursor, xTextField, false);
+};
+
+insertAuthorField();
+Scheduler::ProcessEventsToIdle();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+assertXPath(pXmlDoc, 
"/root/page[1]/body/txt[1]/SwParaPortion[1]/SwLineLayout[1]/SwFieldPortion[1]", 
"expand", sAuthor);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index 2015216f2a91..98010119566e 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -315,7 +315,16 @@ OUString SwAuthorFieldType::Expand(sal_uLong nFormat)
 {
 SvtUserOptions&  rOpt = SW_MOD()->GetUserOptions();
 if((nFormat & 0xff) == AF_NAME)
-return rOpt.GetFullName();
+{
+// Prefer the view's redline author name.
+// (set in SwXTextDocument::initializeForTiledRendering)
+std::size_t nAuthor = SW_MOD()->GetRedlineAuthor();
+OUString sAuthor = SW_MOD()->GetRedlineAuthor(nAuthor);
+if (sAuthor.isEmpty())
+return rOpt.GetFullName();
+
+return sAuthor;
+}
 
 return rOpt.GetID();
 }


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

2023-01-02 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   46 ++
 vcl/source/gdi/pdfobjectcopier.cxx|   22 
 3 files changed, 68 insertions(+)

New commits:
commit 68540314ecc801ddff06b843ac2e332b02bd7a3b
Author: Dennis Francis 
AuthorDate: Fri Dec 2 13:11:42 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Jan 3 07:26:25 2023 +

vcl: Copy the resource kind object itself if...

some of the items in that resource are themselves dictionaries instead
of references.

Change-Id: I427386b14fe5507dfdfc9745dad27a8fceefd929
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143564
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 4cb521b28e8582eda1a63bc4d92061fd111a2e3d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144438
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
index 0390ccad8410..fdda33f78231 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ce070a711911..4cf31e708220 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4247,6 +4247,52 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportMediaBoxOrigin)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportResourceItemReference)
+{
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im10 that has reference to Font in 
page 2.
+auto pInnerIm = aDocument.LookupObject(10);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pResources
+= 
dynamic_cast(pInnerIm->Lookup("Resources"));
+CPPUNIT_ASSERT(pResources);
+auto pFontsReference
+= 
dynamic_cast(pResources->LookupElement("Font"));
+CPPUNIT_ASSERT(pFontsReference);
+
+auto pFontsObject = pFontsReference->LookupObject();
+CPPUNIT_ASSERT(pFontsObject);
+
+auto pFontDict
+= 
dynamic_cast(pFontsObject->Lookup("FF132"));
+CPPUNIT_ASSERT(pFontDict);
+
+auto pFontDescriptor = pFontDict->LookupObject("FontDescriptor");
+CPPUNIT_ASSERT(pFontDescriptor);
+
+auto pFontWidths = pFontDict->LookupObject("Widths");
+CPPUNIT_ASSERT(pFontWidths);
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 67f70d10f2a9..2f32cdc27ce1 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -184,6 +184,7 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 
 // Get the rKind subset of the resource dictionary.
 std::map aItems;
+filter::PDFObjectElement* pKindObject = nullptr;
 if (auto pResources = 
dynamic_cast(rPage.Lookup("Resources")))
 {
 // Resources is a direct dictionary.
@@ -202,6 +203,7 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 return {};
 }
 
+pKindObject = pReferenced;
 aItems = pReferenced->GetDictionaryItems();
 }
 }
@@ -210,23 +212,37 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 // Resources is an indirect object.
 filter::PDFElement* pValue = pPageResources->Lookup(rKind);
 if (auto pDictionary = 
dynamic_cast(pValue))
+{
 // Kind is a direct dictionary.
 aItems = pDictionary->GetItems();
+}
 else if (filter::PDFObjectElement* pObject = 
pPageResources->LookupObject(rKind))
+{
 // Kind is an indirect object.
 aItems = pObject->GetDictionaryItems();
+pKindObject = pObject;
+}
 }
 if (aItems.empty())
 return {};
 
 SvMemoryStream& rDocBuffer = rPage.GetDocument().GetEditBuffer();
+bool bHasDictValue = false;
 
 for (cons

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

2023-01-02 Thread Dennis Francis (via logerrit)
 vcl/source/gdi/pdfobjectcopier.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c060f449371cebc9e447568ae1e0aa0860137e2d
Author: Dennis Francis 
AuthorDate: Fri Dec 2 12:50:44 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Jan 3 07:26:03 2023 +

vcl: copy /Pattern resources too

Change-Id: I3d99f9083fb67c68ddee24d2d285350230533fda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143563
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit cf923b7f892ee8d5c5122c7bd88cb40a2e390a56)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144437
Tested-by: Jenkins

diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 999be92bd752..67f70d10f2a9 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -260,7 +260,7 @@ void 
PDFObjectCopier::copyPageResources(filter::PDFObjectElement* pPage, OString
 {
 rLine.append(" /Resources <<");
 static const std::initializer_list aKeys
-= { "ColorSpace", "ExtGState", "Font", "XObject", "Shading" };
+= { "ColorSpace", "ExtGState", "Font", "XObject", "Shading", "Pattern" 
};
 for (const auto& rKey : aKeys)
 {
 rLine.append(copyExternalResources(*pPage, rKey, rCopiedResources));


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

2023-01-02 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   61 ++
 vcl/source/gdi/pdfwriter_impl.cxx |   29 ++--
 3 files changed, 85 insertions(+), 5 deletions(-)

New commits:
commit e72f77b8164820569834f5459514c18d2bfd911b
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:47:12 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Jan 3 07:25:42 2023 +

vcl: use /MediaBox origin in the ctm...

of the inner XObject, else the clip polypolygon may clip out partly or
whole contents. Adjusting the clip polypolygon is not straightforward.

Change-Id: If3b208ba850c3579c9e16c15e4fb2f947dad4406
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143561
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit a67dcc248a103098de883a4dd2fa9ff2e1cc1f90)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144436
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
index 598358a636aa..0390ccad8410 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 428f9d5a132a..ce070a711911 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4186,6 +4186,67 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportFilterSingletonArray)
 CPPUNIT_ASSERT(it != pEnd);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportMediaBoxOrigin)
+{
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im10 that contains the rectangle 
drawings in page 2.
+auto pInnerIm = aDocument.LookupObject(10);
+CPPUNIT_ASSERT(pInnerIm);
+
+constexpr sal_Int32 aOrigin[2] = { -800, -600 };
+sal_Int32 aSize[2] = { 0, 0 };
+
+auto pBBox = 
dynamic_cast(pInnerIm->Lookup("BBox"));
+CPPUNIT_ASSERT(pBBox);
+const auto& rElements2 = pBBox->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(4), rElements2.size());
+for (sal_Int32 nIdx = 0; nIdx < 4; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements2[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+if (nIdx < 2)
+CPPUNIT_ASSERT_EQUAL(aOrigin[nIdx], 
static_cast(pNumElement->GetValue()));
+else
+aSize[nIdx - 2] = static_cast(pNumElement->GetValue()) 
- aOrigin[nIdx - 2];
+}
+
+auto pMatrix = 
dynamic_cast(pInnerIm->Lookup("Matrix"));
+CPPUNIT_ASSERT(pMatrix);
+const auto& rElements = pMatrix->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(6), rElements.size());
+sal_Int32 aMatTranslate[6]
+= { // Rotation by $\theta$ $cos(\theta), sin(\theta), -sin(\theta), 
cos(\theta)$
+0, -1, 1, 0,
+// Translate x,y
+-aOrigin[1] - aSize[1] / 2 + aSize[0] / 2, aOrigin[0] + aSize[0] / 
2 + aSize[1] / 2
+  };
+
+for (sal_Int32 nIdx = 0; nIdx < 6; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+CPPUNIT_ASSERT_EQUAL(aMatTranslate[nIdx], 
static_cast(pNumElement->GetValue()));
+}
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index f4a3145c5085..d95a74aeb6af 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8873,6 +8873,21 @@ void PDFWriterImpl::writeReferenceXObject(const 
ReferenceXObjectEmit& rEmit)
 return;
 }
 
+double aOrigin[2] = { 0.0, 0.0 };
+if (auto* pArray = 
dynamic_cast(pPage->Lookup("MediaBox")))
+{
+const auto& rElements = pArray->GetElements();
+if (rElements.size() >= 4)
+{
+// get x1, y1 of the rectangle.
+for (sal_Int32 nIdx = 0; nIdx < 2; ++nIdx)
+{
+if (const auto* pNumElement = 
dynamic_cast(r

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

2022-12-21 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   50 +
 vcl/source/gdi/pdfobjectcopier.cxx |8 +
 2 files changed, 58 insertions(+)

New commits:
commit 76091c828ec7c515a2fced158c395fea3bf47602
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:28:49 2022 +0530
Commit: Xisco Fauli 
CommitDate: Wed Dec 21 11:50:05 2022 +

vcl: /Filter [/FlatDecode] not properly read

Change-Id: I156e153ae1a123cf9cf54eb23e6d3abe8962f677
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143560
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit f5ad4f9dfac27d5675fa5c397f66b8cc45cc31a1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144435
Tested-by: Jenkins
(cherry picked from commit db2757e110c1d99bc6128d80a0c6b9fd63982b89)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144659
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index f18077505abd..428f9d5a132a 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4136,6 +4136,56 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportFilterSingletonArray)
+{
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im5 that contains the rectangle 
drawings.
+auto pInnerIm = aDocument.LookupObject(5);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pFilter = 
dynamic_cast(pInnerIm->Lookup("Filter"));
+CPPUNIT_ASSERT(pFilter);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Filter must be FlateDecode", 
OString("FlateDecode"),
+ pFilter->GetValue());
+
+vcl::filter::PDFStreamElement* pStream = pInnerIm->GetStream();
+CPPUNIT_ASSERT(pStream);
+SvMemoryStream& rObjectStream = pStream->GetMemory();
+// Uncompress it.
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+rObjectStream.Seek(0);
+aZCodec.Decompress(rObjectStream, aUncompressed);
+CPPUNIT_ASSERT(aZCodec.EndCompression());
+
+// Without the fix, the stream is doubly compressed,
+// hence one decompression will not yield the "re" expressions.
+auto pStart = static_cast(aUncompressed.GetData());
+const char* pEnd = pStart + aUncompressed.GetSize();
+OString aImage = "100 0 30 50 re B*\n70 67 50 30 re B*\n";
+auto it = std::search(pStart, pEnd, aImage.getStr(), aImage.getStr() + 
aImage.getLength());
+CPPUNIT_ASSERT(it != pEnd);
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 93b7b4989710..999be92bd752 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -283,6 +283,14 @@ sal_Int32 
PDFObjectCopier::copyPageStreams(std::vectorGetMemory();
 
 auto pFilter = 
dynamic_cast(pContent->Lookup("Filter"));
+auto pFilterArray = 
dynamic_cast(pContent->Lookup("Filter"));
+if (!pFilter && pFilterArray)
+{
+auto& aElements = pFilterArray->GetElements();
+if (!aElements.empty())
+pFilter = dynamic_cast(aElements[0]);
+}
+
 if (pFilter)
 {
 if (pFilter->GetValue() != "FlateDecode")


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

2022-12-21 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   38 ++
 vcl/source/filter/ipdf/pdfdocument.cxx|   21 +-
 3 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit c4072f9a97ec9eefea9c980016139a7e4c505a03
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:18:22 2022 +0530
Commit: Xisco Fauli 
CommitDate: Wed Dec 21 09:20:32 2022 +

vcl: read references to /Kids array...

if the argument of /Kids is not an array.

Conflicts:
vcl/qa/cppunit/pdfexport/pdfexport.cxx

Change-Id: Ib73962d3a27aa7e1ce5ddbe6845a1dd73bd7a343
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143559
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 10185a6aec5d3b74a51e4b9474645e12bf794df8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144434
Tested-by: Jenkins
(cherry picked from commit 9a45d2779ceaa1938feddf820d826922ed17854b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144656
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
new file mode 100644
index ..598358a636aa
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ea8f83e6ba8f..f18077505abd 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -4098,6 +4099,43 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627)
  / aRect[jehtatweel].getWidth());
 #endif
 }
+
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
+{
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources");
+CPPUNIT_ASSERT(pResources);
+
+auto pXObjects
+= 
dynamic_cast(pResources->Lookup("XObject"));
+CPPUNIT_ASSERT(pXObjects);
+
+// Without the fix LookupObject for all /Im's will fail.
+for (auto const& rPair : pXObjects->GetItems())
+{
+if (rPair.first.startsWith("Im"))
+CPPUNIT_ASSERT(pXObjects->LookupObject(rPair.first));
+}
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index 25e731f5352a..19748e241ead 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -1918,7 +1918,26 @@ const std::vector>& 
PDFDocument::GetElements() const
 /// Visits the page tree recursively, looking for page objects.
 static void visitPages(PDFObjectElement* pPages, 
std::vector& rRet)
 {
-auto pKids = dynamic_cast(pPages->Lookup("Kids"));
+auto pKidsRef = pPages->Lookup("Kids");
+auto pKids = dynamic_cast(pKidsRef);
+if (!pKids)
+{
+auto pRefKids = dynamic_cast(pKidsRef);
+if (!pRefKids)
+{
+SAL_WARN("vcl.filter", "visitPages: pages has no kids");
+return;
+}
+auto pObjWithKids = pRefKids->LookupObject();
+if (!pObjWithKids)
+{
+SAL_WARN("vcl.filter", "visitPages: pages has no kids");
+return;
+}
+
+pKids = pObjWithKids->GetArray();
+}
+
 if (!pKids)
 {
 SAL_WARN("vcl.filter", "visitPages: pages has no kids");


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

2022-12-20 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   50 +
 vcl/source/gdi/pdfobjectcopier.cxx |8 +
 2 files changed, 58 insertions(+)

New commits:
commit db2757e110c1d99bc6128d80a0c6b9fd63982b89
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:28:49 2022 +0530
Commit: Miklos Vajna 
CommitDate: Wed Dec 21 07:59:04 2022 +

vcl: /Filter [/FlatDecode] not properly read

Change-Id: I156e153ae1a123cf9cf54eb23e6d3abe8962f677
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143560
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit f5ad4f9dfac27d5675fa5c397f66b8cc45cc31a1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144435
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index f18077505abd..428f9d5a132a 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4136,6 +4136,56 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportFilterSingletonArray)
+{
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im5 that contains the rectangle 
drawings.
+auto pInnerIm = aDocument.LookupObject(5);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pFilter = 
dynamic_cast(pInnerIm->Lookup("Filter"));
+CPPUNIT_ASSERT(pFilter);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Filter must be FlateDecode", 
OString("FlateDecode"),
+ pFilter->GetValue());
+
+vcl::filter::PDFStreamElement* pStream = pInnerIm->GetStream();
+CPPUNIT_ASSERT(pStream);
+SvMemoryStream& rObjectStream = pStream->GetMemory();
+// Uncompress it.
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+rObjectStream.Seek(0);
+aZCodec.Decompress(rObjectStream, aUncompressed);
+CPPUNIT_ASSERT(aZCodec.EndCompression());
+
+// Without the fix, the stream is doubly compressed,
+// hence one decompression will not yield the "re" expressions.
+auto pStart = static_cast(aUncompressed.GetData());
+const char* pEnd = pStart + aUncompressed.GetSize();
+OString aImage = "100 0 30 50 re B*\n70 67 50 30 re B*\n";
+auto it = std::search(pStart, pEnd, aImage.getStr(), aImage.getStr() + 
aImage.getLength());
+CPPUNIT_ASSERT(it != pEnd);
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 93b7b4989710..999be92bd752 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -283,6 +283,14 @@ sal_Int32 
PDFObjectCopier::copyPageStreams(std::vectorGetMemory();
 
 auto pFilter = 
dynamic_cast(pContent->Lookup("Filter"));
+auto pFilterArray = 
dynamic_cast(pContent->Lookup("Filter"));
+if (!pFilter && pFilterArray)
+{
+auto& aElements = pFilterArray->GetElements();
+if (!aElements.empty())
+pFilter = dynamic_cast(aElements[0]);
+}
+
 if (pFilter)
 {
 if (pFilter->GetValue() != "FlateDecode")


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

2022-12-20 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   38 ++
 vcl/source/filter/ipdf/pdfdocument.cxx|   21 +-
 3 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit 9a45d2779ceaa1938feddf820d826922ed17854b
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:18:22 2022 +0530
Commit: Miklos Vajna 
CommitDate: Wed Dec 21 07:58:38 2022 +

vcl: read references to /Kids array...

if the argument of /Kids is not an array.

Conflicts:
vcl/qa/cppunit/pdfexport/pdfexport.cxx

Change-Id: Ib73962d3a27aa7e1ce5ddbe6845a1dd73bd7a343
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143559
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 10185a6aec5d3b74a51e4b9474645e12bf794df8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144434
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
new file mode 100644
index ..598358a636aa
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ea8f83e6ba8f..f18077505abd 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -4098,6 +4099,43 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627)
  / aRect[jehtatweel].getWidth());
 #endif
 }
+
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
+{
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources");
+CPPUNIT_ASSERT(pResources);
+
+auto pXObjects
+= 
dynamic_cast(pResources->Lookup("XObject"));
+CPPUNIT_ASSERT(pXObjects);
+
+// Without the fix LookupObject for all /Im's will fail.
+for (auto const& rPair : pXObjects->GetItems())
+{
+if (rPair.first.startsWith("Im"))
+CPPUNIT_ASSERT(pXObjects->LookupObject(rPair.first));
+}
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index 25e731f5352a..19748e241ead 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -1918,7 +1918,26 @@ const std::vector>& 
PDFDocument::GetElements() const
 /// Visits the page tree recursively, looking for page objects.
 static void visitPages(PDFObjectElement* pPages, 
std::vector& rRet)
 {
-auto pKids = dynamic_cast(pPages->Lookup("Kids"));
+auto pKidsRef = pPages->Lookup("Kids");
+auto pKids = dynamic_cast(pKidsRef);
+if (!pKids)
+{
+auto pRefKids = dynamic_cast(pKidsRef);
+if (!pRefKids)
+{
+SAL_WARN("vcl.filter", "visitPages: pages has no kids");
+return;
+}
+auto pObjWithKids = pRefKids->LookupObject();
+if (!pObjWithKids)
+{
+SAL_WARN("vcl.filter", "visitPages: pages has no kids");
+return;
+}
+
+pKids = pObjWithKids->GetArray();
+}
+
 if (!pKids)
 {
 SAL_WARN("vcl.filter", "visitPages: pages has no kids");


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

2022-12-18 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   32 +---
 1 file changed, 9 insertions(+), 23 deletions(-)

New commits:
commit fb584f373c3c683b602de43f2679a3e46fdf8b13
Author: Dennis Francis 
AuthorDate: Mon Dec 19 10:48:10 2022 +0530
Commit: Miklos Vajna 
CommitDate: Mon Dec 19 07:51:04 2022 +

vcl: use osl_set(clear)Environment in new tests

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

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ab62a54b74db..cf04a7257465 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -14,6 +14,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -3348,18 +3349,16 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testBitmapScaledown)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
 {
-// setenv only works on unix based systems
-#ifndef _WIN32
 // We need to enable PDFium import (and make sure to disable after the 
test)
 bool bResetEnvVar = false;
 if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
 {
 bResetEnvVar = true;
-setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
 }
 comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
 if (bResetEnvVar)
-unsetenv("LO_IMPORT_USE_PDFIUM");
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
 });
 
 // Load the PDF and save as PDF
@@ -3382,24 +3381,20 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportRefToKids)
 if (rPair.first.startsWith("Im"))
 CPPUNIT_ASSERT(pXObjects->LookupObject(rPair.first));
 }
-
-#endif
 }
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportFilterSingletonArray)
 {
-// setenv only works on unix based systems
-#ifndef _WIN32
 // We need to enable PDFium import (and make sure to disable after the 
test)
 bool bResetEnvVar = false;
 if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
 {
 bResetEnvVar = true;
-setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
 }
 comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
 if (bResetEnvVar)
-unsetenv("LO_IMPORT_USE_PDFIUM");
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
 });
 
 // Load the PDF and save as PDF
@@ -3436,23 +3431,20 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportFilterSingletonArray)
 OString aImage = "100 0 30 50 re B*\n70 67 50 30 re B*\n";
 auto it = std::search(pStart, pEnd, aImage.getStr(), aImage.getStr() + 
aImage.getLength());
 CPPUNIT_ASSERT(it != pEnd);
-#endif
 }
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportMediaBoxOrigin)
 {
-// setenv only works on unix based systems
-#ifndef _WIN32
 // We need to enable PDFium import (and make sure to disable after the 
test)
 bool bResetEnvVar = false;
 if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
 {
 bResetEnvVar = true;
-setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
 }
 comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
 if (bResetEnvVar)
-unsetenv("LO_IMPORT_USE_PDFIUM");
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
 });
 
 // Load the PDF and save as PDF
@@ -3490,24 +3482,20 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportMediaBoxOrigin)
 CPPUNIT_ASSERT(pNumElement);
 CPPUNIT_ASSERT_EQUAL(aBBox[nIdx], 
static_cast(pNumElement->GetValue()));
 }
-
-#endif
 }
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportResourceItemReference)
 {
-// setenv only works on unix based systems
-#ifndef _WIN32
 // We need to enable PDFium import (and make sure to disable after the 
test)
 bool bResetEnvVar = false;
 if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
 {
 bResetEnvVar = true;
-setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
 }
 comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
 if (bResetEnvVar)
-unsetenv("LO_IMPORT_USE_PDFIUM");
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
 });
 
 // Load the PDF and save as PDF
@@ -3540,8 +3528,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportResourceItemReference)
 
 auto pFontWidths = pFontDict->LookupObject("Widths");
 CPPUNIT_ASSERT(pFontWidths);
-
-#endif
 }
 
 } // end anonymous namespace


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

2022-12-16 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   50 ++
 vcl/source/gdi/pdfobjectcopier.cxx|   26 +
 3 files changed, 76 insertions(+)

New commits:
commit 4cb521b28e8582eda1a63bc4d92061fd111a2e3d
Author: Dennis Francis 
AuthorDate: Fri Dec 2 13:11:42 2022 +0530
Commit: Miklos Vajna 
CommitDate: Fri Dec 16 13:52:10 2022 +

vcl: Copy the resource kind object itself if...

some of the items in that resource are themselves dictionaries instead
of references.

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

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
index 0390ccad8410..fdda33f78231 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 8b9541e9478e..ab62a54b74db 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3494,6 +3494,56 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportMediaBoxOrigin)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportResourceItemReference)
+{
+// setenv only works on unix based systems
+#ifndef _WIN32
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+unsetenv("LO_IMPORT_USE_PDFIUM");
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im10 that has reference to Font in 
page 2.
+auto pInnerIm = aDocument.LookupObject(10);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pResources
+= 
dynamic_cast(pInnerIm->Lookup("Resources"));
+CPPUNIT_ASSERT(pResources);
+auto pFontsReference
+= 
dynamic_cast(pResources->LookupElement("Font"));
+CPPUNIT_ASSERT(pFontsReference);
+
+auto pFontsObject = pFontsReference->LookupObject();
+CPPUNIT_ASSERT(pFontsObject);
+
+auto pFontDict
+= 
dynamic_cast(pFontsObject->Lookup("FF132"));
+CPPUNIT_ASSERT(pFontDict);
+
+auto pFontDescriptor = pFontDict->LookupObject("FontDescriptor");
+CPPUNIT_ASSERT(pFontDescriptor);
+
+auto pFontWidths = pFontDict->LookupObject("Widths");
+CPPUNIT_ASSERT(pFontWidths);
+
+#endif
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 67f70d10f2a9..cbf3dc308c3b 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -184,6 +184,7 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 
 // Get the rKind subset of the resource dictionary.
 std::map aItems;
+filter::PDFObjectElement* pKindObject = nullptr;
 if (auto pResources = 
dynamic_cast(rPage.Lookup("Resources")))
 {
 // Resources is a direct dictionary.
@@ -202,6 +203,7 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 return {};
 }
 
+pKindObject = pReferenced;
 aItems = pReferenced->GetDictionaryItems();
 }
 }
@@ -210,23 +212,40 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 // Resources is an indirect object.
 filter::PDFElement* pValue = pPageResources->Lookup(rKind);
 if (auto pDictionary = 
dynamic_cast(pValue))
+{
 // Kind is a direct dictionary.
 aItems = pDictionary->GetItems();
+}
 else if (filter::PDFObjectElement* pObject = 
pPageResources->LookupObject(rKind))
+{
 // Kind is an indirect object.
 aItems = pObject->GetDictionaryItems();
+pKindObject = pObject;
+}
 }
 if (aItems.empty())
 return {};
 
 SvMemoryStream& rDocBuffer = rPage.GetDocument().GetEditBuffer();
+bool bHasDictValue = false;
 
 for (const auto& rItem : aItems)
 {
 // For each item copy it over to our output then insert it into aRet.
 auto pReference = 
dyna

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

2022-12-16 Thread Dennis Francis (via logerrit)
 vcl/source/gdi/pdfobjectcopier.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit cf923b7f892ee8d5c5122c7bd88cb40a2e390a56
Author: Dennis Francis 
AuthorDate: Fri Dec 2 12:50:44 2022 +0530
Commit: Miklos Vajna 
CommitDate: Fri Dec 16 13:48:22 2022 +

vcl: copy /Pattern resources too

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

diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 999be92bd752..67f70d10f2a9 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -260,7 +260,7 @@ void 
PDFObjectCopier::copyPageResources(filter::PDFObjectElement* pPage, OString
 {
 rLine.append(" /Resources <<");
 static const std::initializer_list aKeys
-= { "ColorSpace", "ExtGState", "Font", "XObject", "Shading" };
+= { "ColorSpace", "ExtGState", "Font", "XObject", "Shading", "Pattern" 
};
 for (const auto& rKey : aKeys)
 {
 rLine.append(copyExternalResources(*pPage, rKey, rCopiedResources));


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

2022-12-16 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   55 ++
 vcl/source/gdi/pdfwriter_impl.cxx |   29 +++--
 3 files changed, 79 insertions(+), 5 deletions(-)

New commits:
commit a67dcc248a103098de883a4dd2fa9ff2e1cc1f90
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:47:12 2022 +0530
Commit: Miklos Vajna 
CommitDate: Fri Dec 16 13:46:59 2022 +

vcl: use /MediaBox origin in the ctm...

of the inner XObject, else the clip polypolygon may clip out partly or
whole contents. Adjusting the clip polypolygon is not straightforward.

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

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
index 598358a636aa..0390ccad8410 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 0e5a5b621950..8b9541e9478e 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3439,6 +3439,61 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportFilterSingletonArray)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportMediaBoxOrigin)
+{
+// setenv only works on unix based systems
+#ifndef _WIN32
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+unsetenv("LO_IMPORT_USE_PDFIUM");
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im10 that contains the rectangle 
drawings in page 2.
+auto pInnerIm = aDocument.LookupObject(10);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pMatrix = 
dynamic_cast(pInnerIm->Lookup("Matrix"));
+CPPUNIT_ASSERT(pMatrix);
+const auto& rElements = pMatrix->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(6), rElements.size());
+sal_Int32 aMatTranslate[2] = { 600, -400 };
+for (sal_Int32 nIdx = 4; nIdx < 6; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+CPPUNIT_ASSERT_EQUAL(aMatTranslate[nIdx - 4],
+ static_cast(pNumElement->GetValue()));
+}
+
+auto pBBox = 
dynamic_cast(pInnerIm->Lookup("BBox"));
+CPPUNIT_ASSERT(pBBox);
+const auto& rElements2 = pBBox->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(4), rElements2.size());
+sal_Int32 aBBox[2] = { -800, -600 };
+for (sal_Int32 nIdx = 0; nIdx < 2; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements2[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+CPPUNIT_ASSERT_EQUAL(aBBox[nIdx], 
static_cast(pNumElement->GetValue()));
+}
+
+#endif
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index eb861cd69c6b..647f861d31e8 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8517,6 +8517,21 @@ void PDFWriterImpl::writeReferenceXObject(const 
ReferenceXObjectEmit& rEmit)
 return;
 }
 
+double aOrigin[2] = { 0.0, 0.0 };
+if (auto* pArray = 
dynamic_cast(pPage->Lookup("MediaBox")))
+{
+const auto& rElements = pArray->GetElements();
+if (rElements.size() >= 4)
+{
+// get x1, y1 of the rectangle.
+for (sal_Int32 nIdx = 0; nIdx < 2; ++nIdx)
+{
+if (const auto* pNumElement = 
dynamic_cast(rElements[nIdx]))
+aOrigin[nIdx] = pNumElement->GetValue();
+}
+}
+}
+
 std::vector aContentStreams;
 if (filter::PDFObjectElement* pContentStream = 
pPage->LookupObject("Contents"))
 aContentStreams.push_back(pContentStream);
@@ -8618,7 +8633,7 @@ void PDFWriterImpl::writeReferenceXObject(const 
ReferenceXObjectEmit& rEmit)
 // Now transform the object: rotate around the center and make 
sure that the rotation
 // doesn't affect the aspect rati

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

2022-12-16 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   53 +
 vcl/source/gdi/pdfobjectcopier.cxx |8 
 2 files changed, 61 insertions(+)

New commits:
commit f5ad4f9dfac27d5675fa5c397f66b8cc45cc31a1
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:28:49 2022 +0530
Commit: Miklos Vajna 
CommitDate: Fri Dec 16 13:43:01 2022 +

vcl: /Filter [/FlatDecode] not properly read

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

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index b6b6ba7f7fc0..0e5a5b621950 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3386,6 +3386,59 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportFilterSingletonArray)
+{
+// setenv only works on unix based systems
+#ifndef _WIN32
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+unsetenv("LO_IMPORT_USE_PDFIUM");
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im5 that contains the rectangle 
drawings.
+auto pInnerIm = aDocument.LookupObject(5);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pFilter = 
dynamic_cast(pInnerIm->Lookup("Filter"));
+CPPUNIT_ASSERT(pFilter);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Filter must be FlateDecode", 
OString("FlateDecode"),
+ pFilter->GetValue());
+
+vcl::filter::PDFStreamElement* pStream = pInnerIm->GetStream();
+CPPUNIT_ASSERT(pStream);
+SvMemoryStream& rObjectStream = pStream->GetMemory();
+// Uncompress it.
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+rObjectStream.Seek(0);
+aZCodec.Decompress(rObjectStream, aUncompressed);
+CPPUNIT_ASSERT(aZCodec.EndCompression());
+
+// Without the fix, the stream is doubly compressed,
+// hence one decompression will not yield the "re" expressions.
+auto pStart = static_cast(aUncompressed.GetData());
+const char* pEnd = pStart + aUncompressed.GetSize();
+OString aImage = "100 0 30 50 re B*\n70 67 50 30 re B*\n";
+auto it = std::search(pStart, pEnd, aImage.getStr(), aImage.getStr() + 
aImage.getLength());
+CPPUNIT_ASSERT(it != pEnd);
+#endif
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 93b7b4989710..999be92bd752 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -283,6 +283,14 @@ sal_Int32 
PDFObjectCopier::copyPageStreams(std::vectorGetMemory();
 
 auto pFilter = 
dynamic_cast(pContent->Lookup("Filter"));
+auto pFilterArray = 
dynamic_cast(pContent->Lookup("Filter"));
+if (!pFilter && pFilterArray)
+{
+auto& aElements = pFilterArray->GetElements();
+if (!aElements.empty())
+pFilter = dynamic_cast(aElements[0]);
+}
+
 if (pFilter)
 {
 if (pFilter->GetValue() != "FlateDecode")


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

2022-12-16 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   40 ++
 vcl/source/filter/ipdf/pdfdocument.cxx|   21 +
 3 files changed, 60 insertions(+), 1 deletion(-)

New commits:
commit 10185a6aec5d3b74a51e4b9474645e12bf794df8
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:18:22 2022 +0530
Commit: Miklos Vajna 
CommitDate: Fri Dec 16 13:38:14 2022 +

vcl: read references to /Kids array...

if the argument of /Kids is not an array.

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

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
new file mode 100644
index ..598358a636aa
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index df0fea74db6f..b6b6ba7f7fc0 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3346,6 +3346,46 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testBitmapScaledown)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
+{
+// setenv only works on unix based systems
+#ifndef _WIN32
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+unsetenv("LO_IMPORT_USE_PDFIUM");
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources");
+CPPUNIT_ASSERT(pResources);
+
+auto pXObjects
+= 
dynamic_cast(pResources->Lookup("XObject"));
+CPPUNIT_ASSERT(pXObjects);
+
+// Without the fix LookupObject for all /Im's will fail.
+for (auto const& rPair : pXObjects->GetItems())
+{
+if (rPair.first.startsWith("Im"))
+CPPUNIT_ASSERT(pXObjects->LookupObject(rPair.first));
+}
+
+#endif
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index 4430c7217fc7..9ef202ee132b 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -1918,7 +1918,26 @@ const std::vector>& 
PDFDocument::GetElements() const
 /// Visits the page tree recursively, looking for page objects.
 static void visitPages(PDFObjectElement* pPages, 
std::vector& rRet)
 {
-auto pKids = dynamic_cast(pPages->Lookup("Kids"));
+auto pKidsRef = pPages->Lookup("Kids");
+auto pKids = dynamic_cast(pKidsRef);
+if (!pKids)
+{
+auto pRefKids = dynamic_cast(pKidsRef);
+if (!pRefKids)
+{
+SAL_WARN("vcl.filter", "visitPages: pages has no kids");
+return;
+}
+auto pObjWithKids = pRefKids->LookupObject();
+if (!pObjWithKids)
+{
+SAL_WARN("vcl.filter", "visitPages: pages has no kids");
+return;
+}
+
+pKids = pObjWithKids->GetArray();
+}
+
 if (!pKids)
 {
 SAL_WARN("vcl.filter", "visitPages: pages has no kids");


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

2022-12-05 Thread Dennis Francis (via logerrit)
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   41 +
 sw/source/core/fields/docufld.cxx  |   11 ++
 2 files changed, 51 insertions(+), 1 deletion(-)

New commits:
commit 8be4a713e9f44bf05aebc0a3054654a18b4de065
Author: Dennis Francis 
AuthorDate: Thu May 19 15:27:48 2022 +0530
Commit: Miklos Vajna 
CommitDate: Mon Dec 5 11:08:52 2022 +

sw: prefer view's redline author name...

to expand SwAuthorFieldType. Redline author name is set in
SwXTextDocument::initializeForTiledRendering each time a new view is
created.

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

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 28f67f9a8500..88b4dcc95d7f 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -19,6 +19,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -3750,6 +3752,45 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testDateContentControl)
 CPPUNIT_ASSERT_EQUAL(OUString("2022-05-30"), 
pTextNode->GetExpandText(pWrtShell->GetLayout()));
 }
 
+CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testAuthorField)
+{
+SwXTextDocument* pXTextDocument = createDoc();
+const OUString sAuthor("Abcd Xyz");
+
+uno::Sequence 
aPropertyValues1(comphelper::InitPropertySequence(
+{
+{".uno:Author", uno::makeAny(sAuthor)},
+}));
+pXTextDocument->initializeForTiledRendering(aPropertyValues1);
+
+auto insertAuthorField = [this]()
+{
+uno::Reference const xMSF(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Reference const xTD(mxComponent, 
uno::UNO_QUERY_THROW);
+
+auto const xText = xTD->getText();
+auto const xTextCursor = xText->createTextCursor();
+CPPUNIT_ASSERT(xTextCursor.is());
+
+xTextCursor->gotoEnd(false);
+
+uno::Reference const xTextField(
+xMSF->createInstance("com.sun.star.text.textfield.Author"), 
uno::UNO_QUERY_THROW);
+
+uno::Reference xTextFieldProps(xTextField, 
uno::UNO_QUERY_THROW);
+xTextFieldProps->setPropertyValue("FullName", uno::Any(true));
+
+xText->insertTextContent(xTextCursor, xTextField, false);
+};
+
+insertAuthorField();
+Scheduler::ProcessEventsToIdle();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", 
sAuthor);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index a3b5d5a5e12d..0e5777e7bf9e 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -314,7 +314,16 @@ OUString SwAuthorFieldType::Expand(sal_uLong nFormat)
 {
 SvtUserOptions&  rOpt = SW_MOD()->GetUserOptions();
 if((nFormat & 0xff) == AF_NAME)
-return rOpt.GetFullName();
+{
+// Prefer the view's redline author name.
+// (set in SwXTextDocument::initializeForTiledRendering)
+std::size_t nAuthor = SW_MOD()->GetRedlineAuthor();
+OUString sAuthor = SW_MOD()->GetRedlineAuthor(nAuthor);
+if (sAuthor.isEmpty())
+return rOpt.GetFullName();
+
+return sAuthor;
+}
 
 return rOpt.GetID();
 }


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

2022-11-12 Thread Dennis Francis (via logerrit)
 chart2/source/controller/main/ChartController.cxx |   15 +++
 svx/source/svdraw/svdmrkv.cxx |8 
 2 files changed, 23 insertions(+)

New commits:
commit 47c14906d0cc0fe0a193ef0a6a87e4b26110a01f
Author: Dennis Francis 
AuthorDate: Mon Mar 7 12:17:07 2022 +0530
Commit: Aron Budea 
CommitDate: Sat Nov 12 15:22:46 2022 +0100

lokCalcRTL: chart-edit: no bounding box

Fix for selections(svx-marks) similar to the fix for chart edit mode
tile painting

```
4fd2a14c6ee68f0574766ec7ec3dca35debe9d20
lokCalcRTL: global RTL: fix chart edit mode rendering
```

Change-Id: I2b5a2af7023b09254b8471b750122bec10126bde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131091
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142610
Reviewed-by: Aron Budea 

diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index 2e7185fdbd68..a6662e2a023e 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -64,6 +64,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -72,6 +73,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -716,7 +718,20 @@ void ChartController::impl_createDrawViewController()
 {
 if( m_pDrawModelWrapper )
 {
+bool bLokCalcGlobalRTL = false;
+if(comphelper::LibreOfficeKit::isActive() && 
AllSettings::GetLayoutRTL())
+{
+uno::Reference< XChartDocument > xChartDoc(getModel(), 
uno::UNO_QUERY);
+if (xChartDoc.is())
+{
+ChartModel& rModel = dynamic_cast(*xChartDoc);
+uno::Reference 
xSSDoc(rModel.getParent(), uno::UNO_QUERY);
+if (xSSDoc.is())
+bLokCalcGlobalRTL = true;
+}
+}
 m_pDrawViewWrapper.reset( new 
DrawViewWrapper(m_pDrawModelWrapper->getSdrModel(),GetChartWindow()->GetOutDev())
 );
+m_pDrawViewWrapper->SetNegativeX(bLokCalcGlobalRTL);
 m_pDrawViewWrapper->attachParentReferenceDevice( getModel() );
 }
 }
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index b788c2a060c3..f48051e974c0 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -789,6 +789,14 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin))
 {
 Point aOffsetPx = 
pWin->GetOffsetPixelFrom(*pViewShellWindow);
+if (mbNegativeX && AllSettings::GetLayoutRTL())
+{
+// mbNegativeX is set only for Calc in RTL mode.
+// If global RTL flag is set, vcl-window X offset of 
chart window is
+// mirrored w.r.t parent window rectangle. This needs 
to be reverted.
+aOffsetPx.setX(pViewShellWindow->GetOutOffXPixel() + 
pViewShellWindow->GetSizePixel().Width()
+- pWin->GetOutOffXPixel() - 
pWin->GetSizePixel().Width());
+}
 Point aLogicOffset = pWin->PixelToLogic(aOffsetPx);
 addLogicOffset = aLogicOffset;
 aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY());


[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - include/vcl vcl/inc vcl/Library_vcl.mk vcl/source

2022-11-02 Thread Dennis Francis (via logerrit)
 include/vcl/filter/pdfdocument.hxx |2 
 vcl/Library_vcl.mk |1 
 vcl/inc/pdf/ExternalPDFStreams.hxx |2 
 vcl/inc/pdf/pdfcompat.hxx  |   42 
 vcl/source/filter/ipdf/pdfcompat.cxx   |  114 +
 vcl/source/filter/ipdf/pdfdocument.cxx |   14 
 vcl/source/filter/ipdf/pdfread.cxx |  110 ++-
 7 files changed, 183 insertions(+), 102 deletions(-)

New commits:
commit c830ca306d55888c3f4222b7247bc0f9e6947bba
Author: Dennis Francis 
AuthorDate: Tue Oct 18 16:14:37 2022 +0530
Commit: Xisco Fauli 
CommitDate: Wed Nov 2 11:13:43 2022 +0100

vcl: re-exporting broken pdfs -> empty pages

Certain pdf documents when loaded in LO_IMPORT_USE_PDFIUM=1 mode even if
pdf-version < v1.6 sometimes has missing objects referred by other
objects for determing its stream length for instance.  As a result
parsing fails and results in a pdf with empty pages.  A round trip
through pdfium and exporting to v1.6 seems to cure the issue. Possibly
it does some repairing work to determine the length of the stream in a
independent pass through the file.

Conflicts:
vcl/source/filter/ipdf/pdfread.cxx

Change-Id: Id09f67eddab4163ed12a3a3f3a73baf92e2912aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141856
Tested-by: Jenkins
Reviewed-by: Dennis Francis 
(cherry picked from commit 3f9e8ac6172f5b1dfd2869ee1c6aea4f24d3f480)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142137
Reviewed-by: Xisco Fauli 

diff --git a/include/vcl/filter/pdfdocument.hxx 
b/include/vcl/filter/pdfdocument.hxx
index dd03029227d2..fbe0be89cdc6 100644
--- a/include/vcl/filter/pdfdocument.hxx
+++ b/include/vcl/filter/pdfdocument.hxx
@@ -576,6 +576,8 @@ public:
 //@{
 /// Read elements from the start of the stream till its end.
 bool Read(SvStream& rStream);
+/// Calls Read() first and if it fails it tries to fixup and then retry.
+bool ReadWithPossibleFixup(SvStream& rStream);
 void SetSignatureLine(std::vector&& rSignatureLine);
 void SetSignaturePage(size_t nPage);
 /// Sign the read document with xCertificate in the edit buffer.
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 6910927bfde0..1d18d2325ad8 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -451,6 +451,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/filter/ipict/ipict \
 vcl/source/filter/ipsd/ipsd \
 vcl/source/filter/ipict/shape \
+vcl/source/filter/ipdf/pdfcompat \
 vcl/source/filter/ipdf/pdfread \
 vcl/source/filter/ipdf/pdfdocument \
 vcl/source/filter/iras/iras \
diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx 
b/vcl/inc/pdf/ExternalPDFStreams.hxx
index 7840217630c8..45b15f7a74bc 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -42,7 +42,7 @@ struct VCL_DLLPUBLIC ExternalPDFStream
 aPDFStream.WriteBytes(maDataContainer.getData(), 
maDataContainer.getSize());
 aPDFStream.Seek(0);
 auto pPDFDocument = std::make_shared();
-if (!pPDFDocument->Read(aPDFStream))
+if (!pPDFDocument->ReadWithPossibleFixup(aPDFStream))
 {
 SAL_WARN("vcl.pdfwriter",
  "PDFWriterImpl::writeReferenceXObject: reading the 
PDF document failed");
diff --git a/vcl/inc/pdf/pdfcompat.hxx b/vcl/inc/pdf/pdfcompat.hxx
new file mode 100644
index ..8f629b3bc8ee
--- /dev/null
+++ b/vcl/inc/pdf/pdfcompat.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace vcl::pdf
+{
+/// Convert to inch, then assume 96 DPI.
+inline double pointToPixel(const double fPoint, const double fResolutionDPI)
+{
+return o3tl::convert(fPoint, o3tl::Length::pt, o3tl::Length::in) * 
fResolutionDPI;
+}
+
+/// Decide if PDF data is old enough to be compatible.
+bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize);
+
+/// Converts to highest supported format version (currently 1.6).
+/// Usually used to deal with missing referenced objects in the
+/// source pdf stream.
+bool convertToHighestSupported(SvStream& rInStream, SvStream& rOutStream);
+
+/// Takes care of transparently downgrading the version of the PDF stream in
+/// case it's too new for our PDF export.
+bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream);
+
+BinaryDataContainer createBinaryDataContainer(SvStream

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

2022-10-26 Thread Dennis Francis (via logerrit)
 include/vcl/filter/pdfdocument.hxx |2 
 vcl/Library_vcl.mk |1 
 vcl/inc/pdf/ExternalPDFStreams.hxx |2 
 vcl/inc/pdf/pdfcompat.hxx  |   42 
 vcl/source/filter/ipdf/pdfcompat.cxx   |  114 +
 vcl/source/filter/ipdf/pdfdocument.cxx |   14 
 vcl/source/filter/ipdf/pdfread.cxx |  110 ++-
 7 files changed, 183 insertions(+), 102 deletions(-)

New commits:
commit 3f9e8ac6172f5b1dfd2869ee1c6aea4f24d3f480
Author: Dennis Francis 
AuthorDate: Tue Oct 18 16:14:37 2022 +0530
Commit: Dennis Francis 
CommitDate: Thu Oct 27 07:54:59 2022 +0200

vcl: re-exporting broken pdfs -> empty pages

Certain pdf documents when loaded in LO_IMPORT_USE_PDFIUM=1 mode even if
pdf-version < v1.6 sometimes has missing objects referred by other
objects for determing its stream length for instance.  As a result
parsing fails and results in a pdf with empty pages.  A round trip
through pdfium and exporting to v1.6 seems to cure the issue. Possibly
it does some repairing work to determine the length of the stream in a
independent pass through the file.

Conflicts:
vcl/source/filter/ipdf/pdfread.cxx

Change-Id: Id09f67eddab4163ed12a3a3f3a73baf92e2912aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141856
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/include/vcl/filter/pdfdocument.hxx 
b/include/vcl/filter/pdfdocument.hxx
index dd03029227d2..fbe0be89cdc6 100644
--- a/include/vcl/filter/pdfdocument.hxx
+++ b/include/vcl/filter/pdfdocument.hxx
@@ -576,6 +576,8 @@ public:
 //@{
 /// Read elements from the start of the stream till its end.
 bool Read(SvStream& rStream);
+/// Calls Read() first and if it fails it tries to fixup and then retry.
+bool ReadWithPossibleFixup(SvStream& rStream);
 void SetSignatureLine(std::vector&& rSignatureLine);
 void SetSignaturePage(size_t nPage);
 /// Sign the read document with xCertificate in the edit buffer.
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 4b1751005bf0..d0087d682d22 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -452,6 +452,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/filter/ipict/ipict \
 vcl/source/filter/ipsd/ipsd \
 vcl/source/filter/ipict/shape \
+vcl/source/filter/ipdf/pdfcompat \
 vcl/source/filter/ipdf/pdfread \
 vcl/source/filter/ipdf/pdfdocument \
 vcl/source/filter/iras/iras \
diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx 
b/vcl/inc/pdf/ExternalPDFStreams.hxx
index 7840217630c8..45b15f7a74bc 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -42,7 +42,7 @@ struct VCL_DLLPUBLIC ExternalPDFStream
 aPDFStream.WriteBytes(maDataContainer.getData(), 
maDataContainer.getSize());
 aPDFStream.Seek(0);
 auto pPDFDocument = std::make_shared();
-if (!pPDFDocument->Read(aPDFStream))
+if (!pPDFDocument->ReadWithPossibleFixup(aPDFStream))
 {
 SAL_WARN("vcl.pdfwriter",
  "PDFWriterImpl::writeReferenceXObject: reading the 
PDF document failed");
diff --git a/vcl/inc/pdf/pdfcompat.hxx b/vcl/inc/pdf/pdfcompat.hxx
new file mode 100644
index ..8f629b3bc8ee
--- /dev/null
+++ b/vcl/inc/pdf/pdfcompat.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace vcl::pdf
+{
+/// Convert to inch, then assume 96 DPI.
+inline double pointToPixel(const double fPoint, const double fResolutionDPI)
+{
+return o3tl::convert(fPoint, o3tl::Length::pt, o3tl::Length::in) * 
fResolutionDPI;
+}
+
+/// Decide if PDF data is old enough to be compatible.
+bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize);
+
+/// Converts to highest supported format version (currently 1.6).
+/// Usually used to deal with missing referenced objects in the
+/// source pdf stream.
+bool convertToHighestSupported(SvStream& rInStream, SvStream& rOutStream);
+
+/// Takes care of transparently downgrading the version of the PDF stream in
+/// case it's too new for our PDF export.
+bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream);
+
+BinaryDataContainer createBinaryDataContainer(SvStream& rStream);
+
+} // end of vcl::filter::ipdf namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/ipdf/pdfcompa

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - include/vcl vcl/inc vcl/Library_vcl.mk vcl/source

2022-10-26 Thread Dennis Francis (via logerrit)
 include/vcl/filter/pdfdocument.hxx |2 
 vcl/Library_vcl.mk |1 
 vcl/inc/pdf/ExternalPDFStreams.hxx |2 
 vcl/inc/pdf/pdfcompat.hxx  |   42 
 vcl/source/filter/ipdf/pdfcompat.cxx   |  113 +
 vcl/source/filter/ipdf/pdfdocument.cxx |   14 
 vcl/source/filter/ipdf/pdfread.cxx |  104 +-
 7 files changed, 178 insertions(+), 100 deletions(-)

New commits:
commit 03a0b41ba21f7d546160c819e088e0b0023b68bb
Author: Dennis Francis 
AuthorDate: Tue Oct 18 16:14:37 2022 +0530
Commit: Andras Timar 
CommitDate: Wed Oct 26 20:38:17 2022 +0200

vcl: re-exporting broken pdfs -> empty pages

Certain pdf documents when loaded in LO_IMPORT_USE_PDFIUM=1 mode even if
pdf-version < v1.6 sometimes has missing objects referred by other
objects for determing its stream length for instance.  As a result
parsing fails and results in a pdf with empty pages.  A round trip
through pdfium and exporting to v1.6 seems to cure the issue. Possibly
it does some repairing work to determine the length of the stream in a
independent pass through the file.

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

diff --git a/include/vcl/filter/pdfdocument.hxx 
b/include/vcl/filter/pdfdocument.hxx
index dd03029227d2..fbe0be89cdc6 100644
--- a/include/vcl/filter/pdfdocument.hxx
+++ b/include/vcl/filter/pdfdocument.hxx
@@ -576,6 +576,8 @@ public:
 //@{
 /// Read elements from the start of the stream till its end.
 bool Read(SvStream& rStream);
+/// Calls Read() first and if it fails it tries to fixup and then retry.
+bool ReadWithPossibleFixup(SvStream& rStream);
 void SetSignatureLine(std::vector&& rSignatureLine);
 void SetSignaturePage(size_t nPage);
 /// Sign the read document with xCertificate in the edit buffer.
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index b0a6ee533133..25f6a0ef9562 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -450,6 +450,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/filter/ipict/ipict \
 vcl/source/filter/ipsd/ipsd \
 vcl/source/filter/ipict/shape \
+vcl/source/filter/ipdf/pdfcompat \
 vcl/source/filter/ipdf/pdfread \
 vcl/source/filter/ipdf/pdfdocument \
 vcl/source/filter/iras/iras \
diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx 
b/vcl/inc/pdf/ExternalPDFStreams.hxx
index 7840217630c8..45b15f7a74bc 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -42,7 +42,7 @@ struct VCL_DLLPUBLIC ExternalPDFStream
 aPDFStream.WriteBytes(maDataContainer.getData(), 
maDataContainer.getSize());
 aPDFStream.Seek(0);
 auto pPDFDocument = std::make_shared();
-if (!pPDFDocument->Read(aPDFStream))
+if (!pPDFDocument->ReadWithPossibleFixup(aPDFStream))
 {
 SAL_WARN("vcl.pdfwriter",
  "PDFWriterImpl::writeReferenceXObject: reading the 
PDF document failed");
diff --git a/vcl/inc/pdf/pdfcompat.hxx b/vcl/inc/pdf/pdfcompat.hxx
new file mode 100644
index ..8f629b3bc8ee
--- /dev/null
+++ b/vcl/inc/pdf/pdfcompat.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace vcl::pdf
+{
+/// Convert to inch, then assume 96 DPI.
+inline double pointToPixel(const double fPoint, const double fResolutionDPI)
+{
+return o3tl::convert(fPoint, o3tl::Length::pt, o3tl::Length::in) * 
fResolutionDPI;
+}
+
+/// Decide if PDF data is old enough to be compatible.
+bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize);
+
+/// Converts to highest supported format version (currently 1.6).
+/// Usually used to deal with missing referenced objects in the
+/// source pdf stream.
+bool convertToHighestSupported(SvStream& rInStream, SvStream& rOutStream);
+
+/// Takes care of transparently downgrading the version of the PDF stream in
+/// case it's too new for our PDF export.
+bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream);
+
+BinaryDataContainer createBinaryDataContainer(SvStream& rStream);
+
+} // end of vcl::filter::ipdf namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/ipdf/pdfcompat.cxx 
b/vcl/source/filter/ipdf/pdfcompat.cxx
new file mod

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/vcl vcl/inc vcl/Library_vcl.mk vcl/source

2022-10-25 Thread Dennis Francis (via logerrit)
 include/vcl/filter/pdfdocument.hxx |2 
 vcl/Library_vcl.mk |1 
 vcl/inc/pdf/ExternalPDFStreams.hxx |2 
 vcl/inc/pdf/pdfcompat.hxx  |   45 +++
 vcl/source/filter/ipdf/pdfcompat.cxx   |  129 +
 vcl/source/filter/ipdf/pdfdocument.cxx |   19 
 vcl/source/filter/ipdf/pdfread.cxx |  112 +---
 7 files changed, 202 insertions(+), 108 deletions(-)

New commits:
commit 7b5e440dc7b7b710d695a00c51c3b061bc5729ba
Author: Dennis Francis 
AuthorDate: Tue Oct 18 16:14:37 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Oct 25 15:57:57 2022 +0200

vcl: re-exporting broken pdfs -> empty pages

Certain pdf documents when loaded in LO_IMPORT_USE_PDFIUM=1 mode even if
pdf-version < v1.6 sometimes has missing objects referred by other
objects for determing its stream length for instance.  As a result
parsing fails and results in a pdf with empty pages.  A round trip
through pdfium and exporting to v1.6 seems to cure the issue. Possibly
it does some repairing work to determine the length of the stream in a
independent pass through the file.

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

diff --git a/include/vcl/filter/pdfdocument.hxx 
b/include/vcl/filter/pdfdocument.hxx
index 7f7cc8dfb641..6ab6adc2468a 100644
--- a/include/vcl/filter/pdfdocument.hxx
+++ b/include/vcl/filter/pdfdocument.hxx
@@ -575,6 +575,8 @@ public:
 //@{
 /// Read elements from the start of the stream till its end.
 bool Read(SvStream& rStream);
+/// Calls Read() first and if it fails it tries to fixup and then retry.
+bool ReadWithPossibleFixup(SvStream& rStream);
 void SetSignatureLine(const std::vector& rSignatureLine);
 void SetSignaturePage(size_t nPage);
 /// Sign the read document with xCertificate in the edit buffer.
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 9c6e7220330e..8c19497ff6cd 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -428,6 +428,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/filter/GraphicFormatDetector \
 vcl/source/filter/igif/decode \
 vcl/source/filter/igif/gifread \
+vcl/source/filter/ipdf/pdfcompat \
 vcl/source/filter/ipdf/pdfread \
 vcl/source/filter/ipdf/pdfdocument \
 vcl/source/filter/ixbm/xbmread \
diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx 
b/vcl/inc/pdf/ExternalPDFStreams.hxx
index 0a1997fe7dc7..71448910ac0f 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -41,7 +41,7 @@ struct VCL_DLLPUBLIC ExternalPDFStream
 aPDFStream.WriteBytes(maData.data(), maData.size());
 aPDFStream.Seek(0);
 auto pPDFDocument = std::make_shared();
-if (!pPDFDocument->Read(aPDFStream))
+if (!pPDFDocument->ReadWithPossibleFixup(aPDFStream))
 {
 SAL_WARN("vcl.pdfwriter",
  "PDFWriterImpl::writeReferenceXObject: reading the 
PDF document failed");
diff --git a/vcl/inc/pdf/pdfcompat.hxx b/vcl/inc/pdf/pdfcompat.hxx
new file mode 100644
index ..29de3901a436
--- /dev/null
+++ b/vcl/inc/pdf/pdfcompat.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+#include 
+
+namespace vcl::pdf
+{
+#if HAVE_FEATURE_PDFIUM
+
+/// Convert to inch, then assume 96 DPI.
+inline double pointToPixel(const double fPoint, const double fResolutionDPI)
+{
+return fPoint * fResolutionDPI / 72.;
+}
+
+/// Decide if PDF data is old enough to be compatible.
+bool isCompatible(SvStream& rInStream, sal_uInt64 nPos, sal_uInt64 nSize);
+
+/// Converts to highest supported format version (currently 1.6).
+/// Usually used to deal with missing referenced objects in the
+/// source pdf stream.
+bool convertToHighestSupported(SvStream& rInStream, SvStream& rOutStream);
+
+#endif // HAVE_FEATURE_PDFIUM
+
+/// Takes care of transparently downgrading the version of the PDF stream in
+/// case it's too new for our PDF export.
+bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream);
+
+VectorGraphicDataArray createVectorGraphicDataArray(SvStream& rStream);
+
+} // end of vcl::filter::ipdf namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/ipdf/pdfcompat.cxx 
b/vcl/source/filter/ipdf/pdfcompat.cxx
new file mode 10

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

2022-06-09 Thread Dennis Francis (via logerrit)
 sc/source/ui/view/gridwin4.cxx |   17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit c17c410706eab6e4d449b2a20a51bf3702329341
Author: Dennis Francis 
AuthorDate: Fri May 6 10:56:38 2022 +0530
Commit: Andras Timar 
CommitDate: Thu Jun 9 21:32:54 2022 +0200

lok: do not recreate lok-drawview for every tile paint

This lets the ScLOKDrawView live long enough for non-tile painting
related invocation of its methods and hopefully those of its member objects.

This is a blind fix for the following crash:

/opt/collaboraoffice/program/../program/libsclo.so
(anonymous 
namespace)::ScLOKProxyObjectContact::calculateGridOffsetForViewOjectContact(basegfx::B2DVector&,
 sdr::contact::ViewObjectContact const&) const
...
/opt/collaboraoffice/program/libmergedlo.so

SdrTextObj::NbcSetOutlinerParaObjectForText(std::unique_ptr >, SdrText*)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/svdraw/svdotext.cxx:1379
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::TextProperties::ItemSetChanged(SfxItemSet const&)

/opt/rh/devtoolset-10/root/usr/include/c++/10/bits/unique_ptr.h:360
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::RectangleProperties::ItemSetChanged(SfxItemSet 
const&)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/sdr/properties/rectangleproperties.cxx:54
/opt/collaboraoffice/program/libmergedlo.so
sdr::properties::DefaultProperties::SetObjectItem(SfxPoolItem 
const&)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/svx/source/sdr/properties/defaultproperties.cxx:120
/opt/collaboraoffice/program/libscfiltlo.so
XclTxo::XclTxo(XclExpRoot const&, EditTextObject const&, SdrObject*)

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/include/svl/cenumitm.hxx:26
/opt/collaboraoffice/program/libscfiltlo.so
XclObjComment::XclObjComment(XclExpObjectManager&, tools::Rectangle 
const&, EditTextObject const&, SdrCaptionObj*, bool, ScAddress const&, 
tools::Rectangle const&, tools::Rectangle const&)

/opt/rh/devtoolset-10/root/usr/include/c++/10/bits/unique_ptr.h:179
/opt/collaboraoffice/program/libscfiltlo.so
XclExpNote::XclExpNote(XclExpRoot const&, ScAddress const&, 
ScPostIt const*, rtl::OUString const&)
/opt/rh/devtoolset-10/root/usr/include/c++/10/tuple:137
/opt/collaboraoffice/program/libscfiltlo.so
ExcTable::FillAsTableXml()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/include/rtl/ref.hxx:65
/opt/collaboraoffice/program/libscfiltlo.so
ExcDocument::ReadDoc()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/sc/source/filter/excel/excdoc.cxx:747
/opt/collaboraoffice/program/libscfiltlo.so
XclExpXmlStream::exportDocument()

/home/collabora/jenkins/workspace/build_linux_co-2021_online_snapshot/sc/source/filter/excel/xestream.cxx:1107
/opt/collaboraoffice/program/libooxlo.so

Change-Id: I248395cca1e2da37208fc449aca731175a5aa368
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133914
Tested-by: Andras Timar 
Reviewed-by: Andras Timar 

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 2580b25fafd2..0c697bf085ef 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1571,13 +1571,16 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 {
 bool bPrintTwipsMsgs = comphelper::LibreOfficeKit::isCompatFlagSet(
 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs);
-mpLOKDrawView.reset(bPrintTwipsMsgs ?
-new ScLOKDrawView(
-,
-mrViewData) :
-new FmFormView(
-*pModel,
-));
+if (!mpLOKDrawView)
+{
+mpLOKDrawView.reset(bPrintTwipsMsgs ?
+new ScLOKDrawView(
+,
+mrViewData) :
+new FmFormView(
+*pModel,
+));
+}
 
 mpLOKDrawView->SetNegativeX(bLayoutRTL);
 mpLOKDrawView->ShowSdrPage(mpLOKDrawView->GetModel()->GetPage(nTab));


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

2022-05-30 Thread Dennis Francis (via logerrit)
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   43 +
 sw/source/core/fields/docufld.cxx  |   11 +-
 2 files changed, 53 insertions(+), 1 deletion(-)

New commits:
commit 092434c48555bedfd9d72620e6e676e6e17709a4
Author: Dennis Francis 
AuthorDate: Thu May 19 15:27:48 2022 +0530
Commit: Miklos Vajna 
CommitDate: Mon May 30 11:10:22 2022 +0200

sw: prefer view's redline author name...

to expand SwAuthorFieldType. Redline author name is set in
SwXTextDocument::initializeForTiledRendering each time a new view is
created.

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

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 8ac5fcc83e02..f0b8e3923158 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -18,6 +18,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -165,6 +167,7 @@ public:
 void testCondCollCopy();
 void testMoveShapeHandle();
 void testRedlinePortions();
+void testAuthorField();
 
 CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
 CPPUNIT_TEST(testRegisterCallback);
@@ -251,6 +254,7 @@ public:
 CPPUNIT_TEST(testCondCollCopy);
 CPPUNIT_TEST(testMoveShapeHandle);
 CPPUNIT_TEST(testRedlinePortions);
+CPPUNIT_TEST(testAuthorField);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3570,6 +3574,45 @@ void SwTiledRenderingTest::testRedlinePortions()
 assertXPath(pXmlDoc, "//Text[4]", "Portion", " after");
 }
 
+void SwTiledRenderingTest::testAuthorField()
+{
+SwXTextDocument* pXTextDocument = createDoc();
+const OUString sAuthor("Abcd Xyz");
+
+uno::Sequence 
aPropertyValues1(comphelper::InitPropertySequence(
+{
+{".uno:Author", uno::makeAny(sAuthor)},
+}));
+pXTextDocument->initializeForTiledRendering(aPropertyValues1);
+
+auto insertAuthorField = [this]()
+{
+uno::Reference const xMSF(mxComponent, 
uno::UNO_QUERY_THROW);
+uno::Reference const xTD(mxComponent, 
uno::UNO_QUERY_THROW);
+
+auto const xText = xTD->getText();
+auto const xTextCursor = xText->createTextCursor();
+CPPUNIT_ASSERT(xTextCursor.is());
+
+xTextCursor->gotoEnd(false);
+
+uno::Reference const xTextField(
+xMSF->createInstance("com.sun.star.text.textfield.Author"), 
uno::UNO_QUERY_THROW);
+
+uno::Reference xTextFieldProps(xTextField, 
uno::UNO_QUERY_THROW);
+xTextFieldProps->setPropertyValue("FullName", uno::Any(true));
+
+xText->insertTextContent(xTextCursor, xTextField, false);
+};
+
+insertAuthorField();
+Scheduler::ProcessEventsToIdle();
+
+xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+
+assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/Special[1]", "rText", 
sAuthor);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index 574cac74fe37..4a99b8353e82 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -312,7 +312,16 @@ OUString SwAuthorFieldType::Expand(sal_uLong nFormat)
 {
 SvtUserOptions&  rOpt = SW_MOD()->GetUserOptions();
 if((nFormat & 0xff) == AF_NAME)
-return rOpt.GetFullName();
+{
+// Prefer the view's redline author name.
+// (set in SwXTextDocument::initializeForTiledRendering)
+std::size_t nAuthor = SW_MOD()->GetRedlineAuthor();
+OUString sAuthor = SW_MOD()->GetRedlineAuthor(nAuthor);
+if (sAuthor.isEmpty())
+return rOpt.GetFullName();
+
+return sAuthor;
+}
 
 return rOpt.GetID();
 }


[Libreoffice-commits] core.git: include/LibreOfficeKit libreofficekit/source sc/inc sc/source

2022-05-21 Thread Dennis Francis (via logerrit)
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   31 ++
 libreofficekit/source/gtk/lokdocview.cxx |1 
 sc/inc/prnsave.hxx   |3 ++
 sc/source/core/tool/prnsave.cxx  |   32 +++
 sc/source/ui/undo/undotab.cxx|   15 
 sc/source/ui/view/viewfun2.cxx   |   11 +
 6 files changed, 93 insertions(+)

New commits:
commit b846fb660a91130aceee52fed11170a95b2f3934
Author: Dennis Francis 
AuthorDate: Thu May 12 13:13:35 2022 +0530
Commit: Dennis Francis 
CommitDate: Sat May 21 09:14:42 2022 +0200

lok-calc: new callback for print ranges

With this callback the lok clients can read and draw the print ranges on
each sheet of the Calc document.

Conflicts:
include/LibreOfficeKit/LibreOfficeKitEnums.h
libreofficekit/source/gtk/lokdocview.cxx

Change-Id: Ie19351d4420e0f3d4191f6a354ce99ab830aede2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134375
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Pranam Lashkari 
(cherry picked from commit 172bc7a8f4eeab907adac077407186fbbd046a77)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134527
Reviewed-by: Gökay ŞATIR 
(cherry picked from commit 29b7b25d454e0a6cd07c00e13fdb83cc8a381583)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134614
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 0fda66777a09..05544b5473a5 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -811,6 +811,35 @@ typedef enum
  * }
  */
 LOK_CALLBACK_CONTENT_CONTROL = 55,
+
+/**
+ * This is Calc specific. The payload contains print ranges of all
+ * sheets in the document.
+ *
+ * Payload example:
+ * {
+ * "printranges" : [
+ * {
+ * "sheet": 0,
+ * "ranges": [
+ * [0, 0, 4, 5],
+ * [5, 100, 8, 150]
+ * ]
+ * },
+ * {
+ * "sheet": 3,
+ * "ranges": [
+ * [1, 0, 6, 10],
+ * [3, 200, 6, 230]
+ * ]
+ * }
+ * ]
+ * }
+ *
+ * The format of the inner "ranges" array for each sheet is
+ * [, , , ]
+ */
+LOK_CALLBACK_PRINT_RANGES = 56,
 }
 LibreOfficeKitCallbackType;
 
@@ -951,6 +980,8 @@ static inline const char* lokCallbackTypeToString(int nType)
 return "LOK_CALLBACK_SC_FOLLOW_JUMP";
 case LOK_CALLBACK_CONTENT_CONTROL:
 return "LOK_CALLBACK_CONTENT_CONTROL";
+case LOK_CALLBACK_PRINT_RANGES:
+return "LOK_CALLBACK_PRINT_RANGES";
 }
 
 assert(!"Unknown LibreOfficeKitCallbackType type.");
diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index b20cc85af875..aafaa084be9c 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1439,6 +1439,7 @@ callback (gpointer pData)
 case LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR:
 case LOK_COMMAND_BLOCKED:
 case LOK_CALLBACK_SC_FOLLOW_JUMP:
+case LOK_CALLBACK_PRINT_RANGES:
 {
 // TODO: Implement me
 break;
diff --git a/sc/inc/prnsave.hxx b/sc/inc/prnsave.hxx
index ef6f50d587dc..af2824b40cf8 100644
--- a/sc/inc/prnsave.hxx
+++ b/sc/inc/prnsave.hxx
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+namespace tools { class JsonWriter; }
+
 class ScPrintSaverTab
 {
 typedef ::std::vector< ScRange > ScRangeVec;
@@ -59,6 +61,7 @@ public:
 SCTAB   GetTabCount() const { return nTabCount; }
 ScPrintSaverTab&GetTabData(SCTAB nTab);
 const ScPrintSaverTab&  GetTabData(SCTAB nTab) const;
+void GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) const;
 
 booloperator==( const ScPrintRangeSaver& rCmp ) const;
 };
diff --git a/sc/source/core/tool/prnsave.cxx b/sc/source/core/tool/prnsave.cxx
index e5a2e92f1a44..f5700cbd3e08 100644
--- a/sc/source/core/tool/prnsave.cxx
+++ b/sc/source/core/tool/prnsave.cxx
@@ -21,6 +21,7 @@
 #include 
 
 #include 
+#include 
 
 //  Data per table
 
@@ -86,6 +87,37 @@ const ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB 
nTab) const
 return pData[nTab];
 }
 
+void ScPrintRangeSaver::GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) 
const
+{
+// Array for sheets in the document.
+auto printRanges = rPrintRanges.startArray("printranges");
+for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
+{
+auto sheetNode = rPrintRanges.startStruct();
+c

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

2022-05-18 Thread Dennis Francis (via logerrit)
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   31 ++
 libreofficekit/source/gtk/lokdocview.cxx |1 
 sc/inc/prnsave.hxx   |3 ++
 sc/source/core/tool/prnsave.cxx  |   32 +++
 sc/source/ui/undo/undotab.cxx|   15 
 sc/source/ui/view/viewfun2.cxx   |   11 +
 6 files changed, 93 insertions(+)

New commits:
commit 29b7b25d454e0a6cd07c00e13fdb83cc8a381583
Author: Dennis Francis 
AuthorDate: Thu May 12 13:13:35 2022 +0530
Commit: Gökay ŞATIR 
CommitDate: Wed May 18 16:03:27 2022 +0200

lok-calc: new callback for print ranges

With this callback the lok clients can read and draw the print ranges on
each sheet of the Calc document.

Conflicts:
include/LibreOfficeKit/LibreOfficeKitEnums.h
libreofficekit/source/gtk/lokdocview.cxx

Change-Id: Ie19351d4420e0f3d4191f6a354ce99ab830aede2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134375
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Pranam Lashkari 
(cherry picked from commit 172bc7a8f4eeab907adac077407186fbbd046a77)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134527
Reviewed-by: Gökay ŞATIR 

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index 0393e4315e31..1af91bbee22b 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -811,6 +811,35 @@ typedef enum
  * }
  */
 LOK_CALLBACK_CONTENT_CONTROL = 55,
+
+/**
+ * This is Calc specific. The payload contains print ranges of all
+ * sheets in the document.
+ *
+ * Payload example:
+ * {
+ * "printranges" : [
+ * {
+ * "sheet": 0,
+ * "ranges": [
+ * [0, 0, 4, 5],
+ * [5, 100, 8, 150]
+ * ]
+ * },
+ * {
+ * "sheet": 3,
+ * "ranges": [
+ * [1, 0, 6, 10],
+ * [3, 200, 6, 230]
+ * ]
+ * }
+ * ]
+ * }
+ *
+ * The format of the inner "ranges" array for each sheet is
+ * [, , , ]
+ */
+LOK_CALLBACK_PRINT_RANGES = 56,
 }
 LibreOfficeKitCallbackType;
 
@@ -951,6 +980,8 @@ static inline const char* lokCallbackTypeToString(int nType)
 return "LOK_CALLBACK_SC_FOLLOW_JUMP";
 case LOK_CALLBACK_CONTENT_CONTROL:
 return "LOK_CALLBACK_CONTENT_CONTROL";
+case LOK_CALLBACK_PRINT_RANGES:
+return "LOK_CALLBACK_PRINT_RANGES";
 }
 
 assert(!"Unknown LibreOfficeKitCallbackType type.");
diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index e36dec43c720..dfccd9affafb 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1441,6 +1441,7 @@ callback (gpointer pData)
 case LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR:
 case LOK_COMMAND_BLOCKED:
 case LOK_CALLBACK_SC_FOLLOW_JUMP:
+case LOK_CALLBACK_PRINT_RANGES:
 {
 // TODO: Implement me
 break;
diff --git a/sc/inc/prnsave.hxx b/sc/inc/prnsave.hxx
index ef6f50d587dc..af2824b40cf8 100644
--- a/sc/inc/prnsave.hxx
+++ b/sc/inc/prnsave.hxx
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+namespace tools { class JsonWriter; }
+
 class ScPrintSaverTab
 {
 typedef ::std::vector< ScRange > ScRangeVec;
@@ -59,6 +61,7 @@ public:
 SCTAB   GetTabCount() const { return nTabCount; }
 ScPrintSaverTab&GetTabData(SCTAB nTab);
 const ScPrintSaverTab&  GetTabData(SCTAB nTab) const;
+void GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) const;
 
 booloperator==( const ScPrintRangeSaver& rCmp ) const;
 };
diff --git a/sc/source/core/tool/prnsave.cxx b/sc/source/core/tool/prnsave.cxx
index e5a2e92f1a44..d7f33e13f0bf 100644
--- a/sc/source/core/tool/prnsave.cxx
+++ b/sc/source/core/tool/prnsave.cxx
@@ -21,6 +21,7 @@
 #include 
 
 #include 
+#include 
 
 //  Data per table
 
@@ -86,6 +87,37 @@ const ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB 
nTab) const
 return pData[nTab];
 }
 
+void ScPrintRangeSaver::GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) 
const
+{
+// Array for sheets in the document.
+auto printRanges = rPrintRanges.startArray("printranges");
+for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
+{
+auto sheetNode = rPrintRanges.startStruct();
+const ScPrintSaverTab& rPsTab = pData[nTab];
+const std::vector& rRangeVec = rPsTab.GetPrintRanges();
+
+rPrintRanges.put("sheet", static_cast(nTab));
+
+ 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - include/LibreOfficeKit libreofficekit/source sc/inc sc/source

2022-05-17 Thread Dennis Francis (via logerrit)
 include/LibreOfficeKit/LibreOfficeKitEnums.h |   31 ++
 libreofficekit/source/gtk/lokdocview.cxx |1 
 sc/inc/prnsave.hxx   |3 ++
 sc/source/core/tool/prnsave.cxx  |   32 +++
 sc/source/ui/undo/undotab.cxx|   15 
 sc/source/ui/view/viewfun2.cxx   |   11 +
 6 files changed, 93 insertions(+)

New commits:
commit 172bc7a8f4eeab907adac077407186fbbd046a77
Author: Dennis Francis 
AuthorDate: Thu May 12 13:13:35 2022 +0530
Commit: Pranam Lashkari 
CommitDate: Tue May 17 15:17:41 2022 +0200

lok-calc: new callback for print ranges

With this callback the lok clients can read and draw the print ranges on
each sheet of the Calc document.

Change-Id: Ie19351d4420e0f3d4191f6a354ce99ab830aede2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134375
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Pranam Lashkari 

diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h 
b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index e00968a86dc8..0f085d5385a8 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -783,6 +783,35 @@ typedef enum
  * When a user tries to use command which is restricted for that user
  */
 LOK_COMMAND_BLOCKED = 53,
+
+/**
+ * This is Calc specific. The payload contains print ranges of all
+ * sheets in the document.
+ *
+ * Payload example:
+ * {
+ * "printranges" : [
+ * {
+ * "sheet": 0,
+ * "ranges": [
+ * [0, 0, 4, 5],
+ * [5, 100, 8, 150]
+ * ]
+ * },
+ * {
+ * "sheet": 3,
+ * "ranges": [
+ * [1, 0, 6, 10],
+ * [3, 200, 6, 230]
+ * ]
+ * }
+ * ]
+ * }
+ *
+ * The format of the inner "ranges" array for each sheet is
+ * [, , , ]
+ */
+LOK_CALLBACK_PRINT_RANGES = 54,
 }
 LibreOfficeKitCallbackType;
 
@@ -919,6 +948,8 @@ static inline const char* lokCallbackTypeToString(int nType)
 return "LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR";
 case LOK_COMMAND_BLOCKED:
 return "LOK_COMMAND_BLOCKED";
+case LOK_CALLBACK_PRINT_RANGES:
+return "LOK_CALLBACK_PRINT_RANGES";
 }
 
 assert(!"Unknown LibreOfficeKitCallbackType type.");
diff --git a/libreofficekit/source/gtk/lokdocview.cxx 
b/libreofficekit/source/gtk/lokdocview.cxx
index 1d40ebc2db90..045af47704ff 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1416,6 +1416,7 @@ callback (gpointer pData)
 case LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY:
 case LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR:
 case LOK_COMMAND_BLOCKED:
+case LOK_CALLBACK_PRINT_RANGES:
 {
 // TODO: Implement me
 break;
diff --git a/sc/inc/prnsave.hxx b/sc/inc/prnsave.hxx
index ca928f908dd1..a2e6810554e7 100644
--- a/sc/inc/prnsave.hxx
+++ b/sc/inc/prnsave.hxx
@@ -24,6 +24,8 @@
 #include 
 #include 
 
+namespace tools { class JsonWriter; }
+
 class ScPrintSaverTab
 {
 typedef ::std::vector< ScRange > ScRangeVec;
@@ -60,6 +62,7 @@ public:
 SCTAB   GetTabCount() const { return nTabCount; }
 ScPrintSaverTab&GetTabData(SCTAB nTab);
 const ScPrintSaverTab&  GetTabData(SCTAB nTab) const;
+void GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) const;
 
 booloperator==( const ScPrintRangeSaver& rCmp ) const;
 };
diff --git a/sc/source/core/tool/prnsave.cxx b/sc/source/core/tool/prnsave.cxx
index c07eda00f9ed..09e4c7f48473 100644
--- a/sc/source/core/tool/prnsave.cxx
+++ b/sc/source/core/tool/prnsave.cxx
@@ -22,6 +22,7 @@
 #include 
 
 #include 
+#include 
 
 //  Data per table
 
@@ -87,6 +88,37 @@ const ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB 
nTab) const
 return pData[nTab];
 }
 
+void ScPrintRangeSaver::GetPrintRangesInfo(tools::JsonWriter& rPrintRanges) 
const
+{
+// Array for sheets in the document.
+auto printRanges = rPrintRanges.startArray("printranges");
+for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
+{
+auto sheetNode = rPrintRanges.startStruct();
+const ScPrintSaverTab& rPsTab = pData[nTab];
+const std::vector& rRangeVec = rPsTab.GetPrintRanges();
+
+rPrintRanges.put("sheet", static_cast(nTab));
+
+// Array for ranges within each sheet.
+auto sheetRanges = rPrintRanges.startArray("ranges");
+OStringBuffer aRanges;
+sal_Int32 nLast = rRangeVec.size() - 1;
+for (sal_Int32 nIdx = 0; nI

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

2022-04-15 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   30 +++
 1 file changed, 26 insertions(+), 4 deletions(-)

New commits:
commit e7710ecab5da8ba734a0270e87bba269041ae391
Author: Dennis Francis 
AuthorDate: Tue Apr 12 10:43:00 2022 +0530
Commit: Andras Timar 
CommitDate: Fri Apr 15 19:58:58 2022 +0200

unit test: use temp copy in testInvalidEntrySave()

Use a temporary copy of the source file to run this test otherwise it
will execute a .uno:Save on the original document in the git tree!

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

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 9894da18e018..053b8d842019 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -42,6 +42,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -187,10 +189,11 @@ public:
 CPPUNIT_TEST_SUITE_END();
 
 private:
-ScModelObj* createDoc(const char* pName);
+ScModelObj* createDoc(const char* pName, bool bMakeTempCopy = false);
 void setupLibreOfficeKitViewCallback(SfxViewShell* pViewShell);
 static void callback(int nType, const char* pPayload, void* pData);
 void callbackImpl(int nType, const char* pPayload);
+void makeTempCopy(const OUString& rOrigURL);
 
 /// document size changed callback.
 osl::Condition m_aDocSizeCondition;
@@ -198,6 +201,7 @@ private:
 
 uno::Reference mxComponent;
 TestLokCallbackWrapper m_callbackWrapper;
+std::unique_ptr mpTempFile;
 };
 
 ScTiledRenderingTest::ScTiledRenderingTest()
@@ -236,11 +240,29 @@ void ScTiledRenderingTest::tearDown()
 test::BootstrapFixture::tearDown();
 }
 
-ScModelObj* ScTiledRenderingTest::createDoc(const char* pName)
+void ScTiledRenderingTest::makeTempCopy(const OUString& rOrigURL)
+{
+mpTempFile.reset(new utl::TempFile());
+mpTempFile->EnableKillingFile();
+auto const aError = osl::File::copy(rOrigURL, mpTempFile->GetURL());
+CPPUNIT_ASSERT_EQUAL_MESSAGE(
+OUString("<" + rOrigURL + "> -> <" + mpTempFile->GetURL() + 
">").toUtf8().getStr(),
+osl::FileBase::E_None, aError);
+}
+
+ScModelObj* ScTiledRenderingTest::createDoc(const char* pName, bool 
bMakeTempCopy)
 {
 if (mxComponent.is())
 mxComponent->dispose();
-mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) 
+ OUString::createFromAscii(pName), "com.sun.star.sheet.SpreadsheetDocument");
+
+OUString aOriginalSrc = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
OUString::createFromAscii(pName);
+if (bMakeTempCopy)
+makeTempCopy(aOriginalSrc);
+
+mxComponent = loadFromDesktop(
+bMakeTempCopy ? mpTempFile->GetURL() : aOriginalSrc,
+"com.sun.star.sheet.SpreadsheetDocument");
+
 ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
 CPPUNIT_ASSERT(pModelObj);
 
pModelObj->initializeForTiledRendering(uno::Sequence());
@@ -3033,7 +3055,7 @@ void ScTiledRenderingTest::testInvalidEntrySave()
 // Load a document
 comphelper::LibreOfficeKit::setActive();
 
-ScModelObj* pModelObj = createDoc("validity.xlsx");
+ScModelObj* pModelObj = createDoc("validity.xlsx", true /* bMakeTempCopy 
*/);
 const ScDocument* pDoc = pModelObj->GetDocument();
 ViewCallback aView;
 int nView = SfxLokHelper::getView();


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 11 commits - connectivity/source cui/uiconfig sc/inc sc/qa sc/source sw/qa sw/source vcl/inc vcl/qt5 vcl/source writerfilter/source

2022-04-14 Thread Dennis Francis (via logerrit)
 connectivity/source/drivers/dbase/DTable.cxx|2 
 cui/uiconfig/ui/optviewpage.ui  |4 
 sc/inc/scmod.hxx|2 
 sc/qa/unit/tiledrendering/data/validity.xlsx|binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx|   57 +++-
 sc/source/core/data/column2.cxx |2 
 sc/source/ui/app/inputhdl.cxx   |   12 +
 sc/source/ui/app/scmod.cxx  |4 
 sc/source/ui/inc/inputhdl.hxx   |2 
 sc/source/ui/view/tabvwsha.cxx  |   11 +
 sw/qa/extras/rtfexport/data/tdf95706_2.rtf  |   17 ++
 sw/qa/extras/rtfexport/rtfexport4.cxx   |   12 +
 sw/source/core/text/porfld.cxx  |   14 +-
 sw/source/ui/dbui/mmoutputtypepage.cxx  |4 
 vcl/inc/qt5/QtMenu.hxx  |1 
 vcl/qt5/QtData.cxx  |2 
 vcl/qt5/QtMenu.cxx  |8 -
 vcl/source/outdev/text.cxx  |2 
 writerfilter/source/rtftok/rtfdispatchvalue.cxx |4 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx  |  162 +---
 writerfilter/source/rtftok/rtfdocumentimpl.hxx  |1 
 21 files changed, 220 insertions(+), 103 deletions(-)

New commits:
commit 0a8e00063ef6868c1a661c883ccb5b2a93325925
Author: Dennis Francis 
AuthorDate: Thu Apr 7 13:14:59 2022 +0530
Commit: Andras Timar 
CommitDate: Thu Apr 14 13:55:19 2022 +0200

lok: unit test for invalid entry save

Unit test related to the fix

lok: avoid validation-dialog yield when saving
e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593

The test ensures that the document is marked unmodified after save has
been executed in the middle of entering partial data to a validation
cell.

Conflicts:
sc/qa/unit/tiledrendering/tiledrendering.cxx

Change-Id: Idffd6d647034e128d0d800fe8e29efc333c03db6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132657
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier 

diff --git a/sc/qa/unit/tiledrendering/data/validity.xlsx 
b/sc/qa/unit/tiledrendering/data/validity.xlsx
new file mode 100644
index ..54a92acd5979
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/validity.xlsx differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 09c198adbf1b..e17bf999a010 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -126,6 +126,7 @@ public:
 void testSheetViewDataCrash();
 void testTextBoxInsert();
 void testCommentCellCopyPaste();
+void testInvalidEntrySave();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -182,6 +183,7 @@ public:
 CPPUNIT_TEST(testSheetViewDataCrash);
 CPPUNIT_TEST(testTextBoxInsert);
 CPPUNIT_TEST(testCommentCellCopyPaste);
+CPPUNIT_TEST(testInvalidEntrySave);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2691,18 +2693,25 @@ void ScTiledRenderingTest::testSortAscendingDescending()
 CPPUNIT_ASSERT_EQUAL(OString("rows"), aView.m_sInvalidateSheetGeometry);
 }
 
-void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, 
ScTabViewShell* pView, ScModelObj* pModelObj)
+void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, 
ScTabViewShell* pView,
+ScModelObj* pModelObj, bool bInEdit = false, bool bCommit = true)
 {
-pView->SetCursor(nCol, nRow);
+if (!bInEdit)
+pView->SetCursor(nCol, nRow);
+
 for (const char& cChar : aStr)
 {
 pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, cChar, 0);
 pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, cChar, 0);
 Scheduler::ProcessEventsToIdle();
 }
-pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
-pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
-Scheduler::ProcessEventsToIdle();
+
+if (bCommit)
+{
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+Scheduler::ProcessEventsToIdle();
+}
 }
 
 void ScTiledRenderingTest::testAutoInputStringBlock()
@@ -3044,6 +3053,44 @@ void ScTiledRenderingTest::testCommentCellCopyPaste()
 comphelper::LibreOfficeKit::setTiledAnnotations(true);
 }
 
+void ScTiledRenderingTest::testInvalidEntrySave()
+{
+// Load a document
+comphelper::LibreOfficeKit::setActive();
+
+ScModelObj* pModelObj = createDoc("validity.xlsx");
+const ScDocument* pDoc = pModelObj->GetDocument();
+ViewCallback aView;
+int nView = SfxLokHelper::getView();
+
+SfxLokHelper::setView(nView);
+
+ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( 
pModelObj->GetEmbeddedObject() );
+   

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

2022-04-13 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/data/validity.xlsx |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   57 ---
 2 files changed, 52 insertions(+), 5 deletions(-)

New commits:
commit 3c9cbc43b0cdb12e0bdfb95e797357de5b7c74db
Author: Dennis Francis 
AuthorDate: Thu Apr 7 13:14:59 2022 +0530
Commit: Michael Meeks 
CommitDate: Wed Apr 13 21:54:48 2022 +0200

lok: unit test for invalid entry save

Unit test related to the fix

lok: avoid validation-dialog yield when saving
e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593

The test ensures that the document is marked unmodified after save has
been executed in the middle of entering partial data to a validation
cell.

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

diff --git a/sc/qa/unit/tiledrendering/data/validity.xlsx 
b/sc/qa/unit/tiledrendering/data/validity.xlsx
new file mode 100644
index ..54a92acd5979
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/validity.xlsx differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 3364e049c22f..9894da18e018 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -127,6 +127,7 @@ public:
 void testSheetViewDataCrash();
 void testTextBoxInsert();
 void testCommentCellCopyPaste();
+void testInvalidEntrySave();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -182,6 +183,7 @@ public:
 CPPUNIT_TEST(testSheetViewDataCrash);
 CPPUNIT_TEST(testTextBoxInsert);
 CPPUNIT_TEST(testCommentCellCopyPaste);
+CPPUNIT_TEST(testInvalidEntrySave);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2701,18 +2703,25 @@ void ScTiledRenderingTest::testSortAscendingDescending()
 CPPUNIT_ASSERT_EQUAL(OString("rows"), aView.m_sInvalidateSheetGeometry);
 }
 
-void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, 
ScTabViewShell* pView, ScModelObj* pModelObj)
+void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, 
ScTabViewShell* pView,
+ScModelObj* pModelObj, bool bInEdit = false, bool bCommit = true)
 {
-pView->SetCursor(nCol, nRow);
+if (!bInEdit)
+pView->SetCursor(nCol, nRow);
+
 for (const char& cChar : aStr)
 {
 pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, cChar, 0);
 pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, cChar, 0);
 Scheduler::ProcessEventsToIdle();
 }
-pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
-pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
-Scheduler::ProcessEventsToIdle();
+
+if (bCommit)
+{
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+Scheduler::ProcessEventsToIdle();
+}
 }
 
 void ScTiledRenderingTest::testAutoInputExactMatch()
@@ -3019,6 +3028,44 @@ void ScTiledRenderingTest::testCommentCellCopyPaste()
 comphelper::LibreOfficeKit::setTiledAnnotations(true);
 }
 
+void ScTiledRenderingTest::testInvalidEntrySave()
+{
+// Load a document
+comphelper::LibreOfficeKit::setActive();
+
+ScModelObj* pModelObj = createDoc("validity.xlsx");
+const ScDocument* pDoc = pModelObj->GetDocument();
+ViewCallback aView;
+int nView = SfxLokHelper::getView();
+
+SfxLokHelper::setView(nView);
+
+ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( 
pModelObj->GetEmbeddedObject() );
+ScTabViewShell* pTabViewShell = 
dynamic_cast(SfxViewShell::Current());
+CPPUNIT_ASSERT(pTabViewShell);
+
+// Type partial date "7/8" of "7/8/2013" that
+// the validation cell at A8 can accept
+lcl_typeCharsInCell("7/8", 0, 7, pTabViewShell, pModelObj,
+false /* bInEdit */, false /* bCommit */); // Type "7/8" in A8
+
+uno::Sequence aArgs;
+comphelper::dispatchCommand(".uno:Save", aArgs);
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_MESSAGE("Should not be marked modified after save", 
!pDocSh->IsModified());
+
+// Complete the date in A8 by appending "/2013" and commit.
+lcl_typeCharsInCell("/2013", 0, 7, pTabViewShell, pModelObj,
+true /* bInEdit */, true /* bCommit */);
+
+// This would hang if the date entered "7/8/2013" is not acceptable.
+Scheduler::ProcessEventsToIdle();
+
+// Ensure that the correct date is recorded in the document.
+CPPUNIT_ASSERT_EQUAL(double(41463), pDoc->GetValue(ScAddress(0, 7, 0)));
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);


[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - sc/qa

2022-04-12 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   30 +++
 1 file changed, 26 insertions(+), 4 deletions(-)

New commits:
commit cc1013e2c6b806226c888d980f56d13767998546
Author: Dennis Francis 
AuthorDate: Tue Apr 12 10:43:00 2022 +0530
Commit: Christian Lohmaier 
CommitDate: Tue Apr 12 20:31:03 2022 +0200

unit test: use temp copy in testInvalidEntrySave()

Use a temporary copy of the source file to run this test otherwise it
will execute a .uno:Save on the original document in the git tree!

Change-Id: I673aad64453e72a9140efcad2b0ff9c0ceabc038

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index dbad2535fb1d..699e0c687130 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -37,6 +37,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -182,10 +184,11 @@ public:
 CPPUNIT_TEST_SUITE_END();
 
 private:
-ScModelObj* createDoc(const char* pName);
+ScModelObj* createDoc(const char* pName, bool bMakeTempCopy = false);
 void setupLibreOfficeKitViewCallback(SfxViewShell* pViewShell);
 static void callback(int nType, const char* pPayload, void* pData);
 void callbackImpl(int nType, const char* pPayload);
+void makeTempCopy(const OUString& rOrigURL);
 
 /// document size changed callback.
 osl::Condition m_aDocSizeCondition;
@@ -193,6 +196,7 @@ private:
 
 uno::Reference mxComponent;
 TestLokCallbackWrapper m_callbackWrapper;
+std::unique_ptr mpTempFile;
 };
 
 ScTiledRenderingTest::ScTiledRenderingTest()
@@ -231,11 +235,29 @@ void ScTiledRenderingTest::tearDown()
 test::BootstrapFixture::tearDown();
 }
 
-ScModelObj* ScTiledRenderingTest::createDoc(const char* pName)
+void ScTiledRenderingTest::makeTempCopy(const OUString& rOrigURL)
+{
+mpTempFile.reset(new utl::TempFile());
+mpTempFile->EnableKillingFile();
+auto const aError = osl::File::copy(rOrigURL, mpTempFile->GetURL());
+CPPUNIT_ASSERT_EQUAL_MESSAGE(
+OUString("<" + rOrigURL + "> -> <" + mpTempFile->GetURL() + 
">").toUtf8().getStr(),
+osl::FileBase::E_None, aError);
+}
+
+ScModelObj* ScTiledRenderingTest::createDoc(const char* pName, bool 
bMakeTempCopy)
 {
 if (mxComponent.is())
 mxComponent->dispose();
-mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) 
+ OUString::createFromAscii(pName), "com.sun.star.sheet.SpreadsheetDocument");
+
+OUString aOriginalSrc = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
OUString::createFromAscii(pName);
+if (bMakeTempCopy)
+makeTempCopy(aOriginalSrc);
+
+mxComponent = loadFromDesktop(
+bMakeTempCopy ? mpTempFile->GetURL() : aOriginalSrc,
+"com.sun.star.sheet.SpreadsheetDocument");
+
 ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
 CPPUNIT_ASSERT(pModelObj);
 
pModelObj->initializeForTiledRendering(uno::Sequence());
@@ -2911,7 +2933,7 @@ void ScTiledRenderingTest::testInvalidEntrySave()
 // Load a document
 comphelper::LibreOfficeKit::setActive();
 
-ScModelObj* pModelObj = createDoc("validity.xlsx");
+ScModelObj* pModelObj = createDoc("validity.xlsx", true /* bMakeTempCopy 
*/);
 const ScDocument* pDoc = pModelObj->GetDocument();
 ViewCallback aView;
 int nView = SfxLokHelper::getView();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - sc/qa

2022-04-12 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/data/validity.xlsx |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   57 ---
 2 files changed, 52 insertions(+), 5 deletions(-)

New commits:
commit 31167c542b6b9b6482dffee1a253a388ff3c0e2c
Author: Dennis Francis 
AuthorDate: Thu Apr 7 13:14:59 2022 +0530
Commit: Christian Lohmaier 
CommitDate: Tue Apr 12 20:28:44 2022 +0200

lok: unit test for invalid entry save

Unit test related to the fix

lok: avoid validation-dialog yield when saving
e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593

The test ensures that the document is marked unmodified after save has
been executed in the middle of entering partial data to a validation
cell.

Conflicts:
sc/qa/unit/tiledrendering/tiledrendering.cxx

Change-Id: Idffd6d647034e128d0d800fe8e29efc333c03db6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132657
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier 

diff --git a/sc/qa/unit/tiledrendering/data/validity.xlsx 
b/sc/qa/unit/tiledrendering/data/validity.xlsx
new file mode 100644
index ..54a92acd5979
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/validity.xlsx differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 6c6cd5990c3c..dbad2535fb1d 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -122,6 +122,7 @@ public:
 void testTextSelectionBounds();
 void testSheetViewDataCrash();
 void testTextBoxInsert();
+void testInvalidEntrySave();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -177,6 +178,7 @@ public:
 CPPUNIT_TEST(testTextSelectionBounds);
 CPPUNIT_TEST(testSheetViewDataCrash);
 CPPUNIT_TEST(testTextBoxInsert);
+CPPUNIT_TEST(testInvalidEntrySave);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2643,18 +2645,25 @@ void ScTiledRenderingTest::testSortAscendingDescending()
 CPPUNIT_ASSERT_EQUAL(OString("rows"), aView.m_sInvalidateSheetGeometry);
 }
 
-void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, 
ScTabViewShell* pView, ScModelObj* pModelObj)
+void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, 
ScTabViewShell* pView,
+ScModelObj* pModelObj, bool bInEdit = false, bool bCommit = true)
 {
-pView->SetCursor(nCol, nRow);
+if (!bInEdit)
+pView->SetCursor(nCol, nRow);
+
 for (const char& cChar : aStr)
 {
 pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, cChar, 0);
 pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, cChar, 0);
 Scheduler::ProcessEventsToIdle();
 }
-pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
-pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
-Scheduler::ProcessEventsToIdle();
+
+if (bCommit)
+{
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+Scheduler::ProcessEventsToIdle();
+}
 }
 
 void ScTiledRenderingTest::testAutoInputStringBlock()
@@ -2897,6 +2906,44 @@ void ScTiledRenderingTest::testTextBoxInsert()
 Scheduler::ProcessEventsToIdle();
 }
 
+void ScTiledRenderingTest::testInvalidEntrySave()
+{
+// Load a document
+comphelper::LibreOfficeKit::setActive();
+
+ScModelObj* pModelObj = createDoc("validity.xlsx");
+const ScDocument* pDoc = pModelObj->GetDocument();
+ViewCallback aView;
+int nView = SfxLokHelper::getView();
+
+SfxLokHelper::setView(nView);
+
+ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( 
pModelObj->GetEmbeddedObject() );
+ScTabViewShell* pTabViewShell = 
dynamic_cast(SfxViewShell::Current());
+CPPUNIT_ASSERT(pTabViewShell);
+
+// Type partial date "7/8" of "7/8/2013" that
+// the validation cell at A8 can accept
+lcl_typeCharsInCell("7/8", 0, 7, pTabViewShell, pModelObj,
+false /* bInEdit */, false /* bCommit */); // Type "7/8" in A8
+
+uno::Sequence aArgs;
+comphelper::dispatchCommand(".uno:Save", aArgs);
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_MESSAGE("Should not be marked modified after save", 
!pDocSh->IsModified());
+
+// Complete the date in A8 by appending "/2013" and commit.
+lcl_typeCharsInCell("/2013", 0, 7, pTabViewShell, pModelObj,
+true /* bInEdit */, true /* bCommit */);
+
+// This would hang if the date entered "7/8/2013" is not acceptable.
+Scheduler::ProcessEventsToIdle();
+
+// Ensure that the correct date is recorded in the document.
+CPPUNIT_ASSERT_EQUAL(double(41463), pDoc->GetValue(ScAddress(0, 7, 0)));
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);


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

2022-04-12 Thread Dennis Francis (via logerrit)
 sc/inc/scmod.hxx   |2 +-
 sc/source/ui/app/inputhdl.cxx  |   12 +++-
 sc/source/ui/app/scmod.cxx |4 ++--
 sc/source/ui/inc/inputhdl.hxx  |2 +-
 sc/source/ui/view/tabvwsha.cxx |   11 +--
 5 files changed, 24 insertions(+), 7 deletions(-)

New commits:
commit c45ab05455486323763851d6c3b6a168ae1abba6
Author: Dennis Francis 
AuthorDate: Fri Apr 1 14:50:42 2022 +0530
Commit: Christian Lohmaier 
CommitDate: Tue Apr 12 20:28:25 2022 +0200

lok: avoid validation-dialog yield when saving

Disable error dialog box when about to save in lok mode as this
ultimately invokes SvpSalInstance::DoYield() when we want to save
immediately without committing any erroneous input in possibly a cell
with validation rules. After save is complete the user can continue
editing.

Conflicts:
sc/source/ui/app/inputhdl.cxx

Change-Id: Iffa0766ad594db75f57158986c4e1d2646f71da4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132410
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
(cherry picked from commit e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132656
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier 

diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 4a89fd3424cd..70170984d0dc 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -198,7 +198,7 @@ public:
 boolIsInputMode();  // also for SC_INPUT_TYPE
 voidSetInputMode( ScInputMode eMode, const OUString* 
pInitText = nullptr );
 boolInputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit 
= false );
-SC_DLLPUBLIC void   InputEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL );
+SC_DLLPUBLIC void   InputEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
 voidInputCancelHandler();
 voidInputSelection( const EditView* pView );
 voidInputChanged( const EditView* pView );
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index d844401a8807..30f18a075c7c 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -3002,7 +3002,7 @@ static void lcl_SelectionToEnd( EditView* pView )
 }
 }
 
-void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
+void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool 
bBeforeSavingInLOK )
 {
 if (!mbDocumentDisposing && comphelper::LibreOfficeKit::isActive()
 && pActiveViewSh != SfxViewShell::Current())
@@ -3082,6 +3082,16 @@ void ScInputHandler::EnterHandler( ScEnterMode 
nBlockMode )
 pSelEngine->ReleaseMouse();
 }
 
+if (bBeforeSavingInLOK)
+{
+// Invalid entry but not applied to the document model.
+// Exit to complete the "save", leaving the edit view as 
it is
+// for the user to continue after save.
+bInOwnChange = false;
+bInEnterHandler = false;
+return;
+}
+
 if (pData->DoError(pActiveViewSh->GetFrameWeld(), aString, 
aCursorPos))
 bForget = true; // Do not take over input
 }
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index dee33b48a509..3534ecdb69e3 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1356,13 +1356,13 @@ bool ScModule::InputKeyEvent( const KeyEvent& rKEvt, 
bool bStartEdit )
 return pHdl && pHdl->KeyInput( rKEvt, bStartEdit );
 }
 
-void ScModule::InputEnterHandler( ScEnterMode nBlockMode )
+void ScModule::InputEnterHandler( ScEnterMode nBlockMode, bool 
bBeforeSavingInLOK )
 {
 if ( !SfxGetpApp()->IsDowning() ) // Not when quitting the program
 {
 ScInputHandler* pHdl = GetInputHdl();
 if (pHdl)
-pHdl->EnterHandler( nBlockMode );
+pHdl->EnterHandler( nBlockMode, bBeforeSavingInLOK );
 }
 }
 
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index fb3880e97a69..f66688a257ca 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -198,7 +198,7 @@ public:
 voidMergeLanguageAttributes( ScEditEngineDefaulter& 
rDestEngine ) const;
 
 boolKeyInput( const KeyEvent& rKEvt, bool bStartEdit );
-voidEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL 
);
+voidEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
 voidCancelHandler();
 voidSetReference( const ScRange& rRef, const ScDocument& rDoc 
);
 voidAddRefEntry(

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

2022-04-12 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   30 +++
 1 file changed, 26 insertions(+), 4 deletions(-)

New commits:
commit 92caeb1a365d10d9cafaca0aed1368db92bc90f0
Author: Dennis Francis 
AuthorDate: Tue Apr 12 10:43:00 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Apr 12 08:17:17 2022 +0200

unit test: use temp copy in testInvalidEntrySave()

Use a temporary copy of the source file to run this test otherwise it
will execute a .uno:Save on the original document in the git tree!

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

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 7ce8ad47105b..935c04d14d46 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -38,6 +38,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -185,10 +187,11 @@ public:
 CPPUNIT_TEST_SUITE_END();
 
 private:
-ScModelObj* createDoc(const char* pName);
+ScModelObj* createDoc(const char* pName, bool bMakeTempCopy = false);
 void setupLibreOfficeKitViewCallback(SfxViewShell* pViewShell);
 static void callback(int nType, const char* pPayload, void* pData);
 void callbackImpl(int nType, const char* pPayload);
+void makeTempCopy(const OUString& rOrigURL);
 
 /// document size changed callback.
 osl::Condition m_aDocSizeCondition;
@@ -196,6 +199,7 @@ private:
 
 uno::Reference mxComponent;
 TestLokCallbackWrapper m_callbackWrapper;
+std::unique_ptr mpTempFile;
 };
 
 ScTiledRenderingTest::ScTiledRenderingTest()
@@ -236,11 +240,29 @@ void ScTiledRenderingTest::tearDown()
 test::BootstrapFixture::tearDown();
 }
 
-ScModelObj* ScTiledRenderingTest::createDoc(const char* pName)
+void ScTiledRenderingTest::makeTempCopy(const OUString& rOrigURL)
+{
+mpTempFile.reset(new utl::TempFile());
+mpTempFile->EnableKillingFile();
+auto const aError = osl::File::copy(rOrigURL, mpTempFile->GetURL());
+CPPUNIT_ASSERT_EQUAL_MESSAGE(
+OUString("<" + rOrigURL + "> -> <" + mpTempFile->GetURL() + 
">").toUtf8().getStr(),
+osl::FileBase::E_None, aError);
+}
+
+ScModelObj* ScTiledRenderingTest::createDoc(const char* pName, bool 
bMakeTempCopy)
 {
 if (mxComponent.is())
 mxComponent->dispose();
-mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) 
+ OUString::createFromAscii(pName), "com.sun.star.sheet.SpreadsheetDocument");
+
+OUString aOriginalSrc = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
OUString::createFromAscii(pName);
+if (bMakeTempCopy)
+makeTempCopy(aOriginalSrc);
+
+mxComponent = loadFromDesktop(
+bMakeTempCopy ? mpTempFile->GetURL() : aOriginalSrc,
+"com.sun.star.sheet.SpreadsheetDocument");
+
 ScModelObj* pModelObj = dynamic_cast(mxComponent.get());
 CPPUNIT_ASSERT(pModelObj);
 
pModelObj->initializeForTiledRendering(uno::Sequence());
@@ -2928,7 +2950,7 @@ void ScTiledRenderingTest::testInvalidEntrySave()
 // Load a document
 comphelper::LibreOfficeKit::setActive();
 
-ScModelObj* pModelObj = createDoc("validity.xlsx");
+ScModelObj* pModelObj = createDoc("validity.xlsx", true /* bMakeTempCopy 
*/);
 const ScDocument* pDoc = pModelObj->GetDocument();
 ViewCallback aView;
 int nView = SfxLokHelper::getView();


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sc/qa

2022-04-11 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |  102 +++
 1 file changed, 102 insertions(+)

New commits:
commit 22fa5b45720252ad3ca8d93ffc418ad1644c7a5f
Author: Dennis Francis 
AuthorDate: Fri Mar 18 12:48:30 2022 +0530
Commit: Dennis Francis 
CommitDate: Tue Apr 12 07:18:57 2022 +0200

lok: unit-test: add comment unique id checks

Conflicts:
sc/qa/unit/tiledrendering/tiledrendering.cxx

Change-Id: I588484955ad3ad4c5ec3bfa9f5a844096c768ff2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131725
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit 9bafce808b6d301b17ee60da452a41cd4b7cf02c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132256

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index f43f3acf8b31..9c5a19be2d42 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -121,6 +122,7 @@ public:
 void testEditCursorBounds();
 void testTextSelectionBounds();
 void testSheetViewDataCrash();
+void testCommentCellCopyPaste();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -174,6 +176,7 @@ public:
 CPPUNIT_TEST(testEditCursorBounds);
 CPPUNIT_TEST(testTextSelectionBounds);
 CPPUNIT_TEST(testSheetViewDataCrash);
+CPPUNIT_TEST(testCommentCellCopyPaste);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2823,6 +2826,105 @@ void ScTiledRenderingTest::testSheetViewDataCrash()
 Scheduler::ProcessEventsToIdle();
 }
 
+void ScTiledRenderingTest::testCommentCellCopyPaste()
+{
+// Load a document
+comphelper::LibreOfficeKit::setActive();
+// Comments callback are emitted only if tiled annotations are off
+comphelper::LibreOfficeKit::setTiledAnnotations(false);
+
+// FIXME: Hack because previous tests do not destroy ScDocument(with 
annotations) on exit (?).
+ScPostIt::mnLastPostItId = 1;
+
+{
+ScModelObj* pModelObj = createDoc("empty.ods");
+ViewCallback aView;
+int nView = SfxLokHelper::getView();
+
+SfxLokHelper::setView(nView);
+
+ScTabViewShell* pTabViewShell = 
dynamic_cast(SfxViewShell::Current());
+CPPUNIT_ASSERT(pTabViewShell);
+
+lcl_typeCharsInCell("ABC", 0, 0, pTabViewShell, pModelObj); // Type 
"ABC" in A1
+
+pTabViewShell->SetCursor(1, 1);
+
+// Add a new comment
+uno::Sequence 
aArgs(comphelper::InitPropertySequence(
+{
+{"Text", uno::makeAny(OUString("LOK Comment Cell B2"))},
+{"Author", uno::makeAny(OUString("LOK Client"))},
+}));
+comphelper::dispatchCommand(".uno:InsertAnnotation", aArgs);
+Scheduler::ProcessEventsToIdle();
+
+// We received a LOK_CALLBACK_COMMENT callback with comment 'Add' 
action
+CPPUNIT_ASSERT_EQUAL(std::string("Add"), 
aView.m_aCommentCallbackResult.get("action"));
+CPPUNIT_ASSERT_EQUAL(std::string("1"), 
aView.m_aCommentCallbackResult.get("id"));
+CPPUNIT_ASSERT_EQUAL(std::string("0"), 
aView.m_aCommentCallbackResult.get("tab"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Client"), 
aView.m_aCommentCallbackResult.get("author"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Comment Cell B2"), 
aView.m_aCommentCallbackResult.get("text"));
+
+uno::Sequence aCopyPasteArgs;
+
+// We need separate tests for single cell copy-paste and cell-range 
copy-paste
+// since they hit different code paths in ScColumn methods.
+
+// Single cell(with comment) copy paste test
+{
+comphelper::dispatchCommand(".uno:Copy", aCopyPasteArgs);
+Scheduler::ProcessEventsToIdle();
+
+pTabViewShell->SetCursor(1, 49);
+Scheduler::ProcessEventsToIdle();
+comphelper::dispatchCommand(".uno:Paste", aCopyPasteArgs); // 
Paste to cell B50
+Scheduler::ProcessEventsToIdle();
+
+// We received a LOK_CALLBACK_COMMENT callback with comment 'Add' 
action
+CPPUNIT_ASSERT_EQUAL(std::string("Add"), 
aView.m_aCommentCallbackResult.get("action"));
+// Without the fix the id will be "1".
+CPPUNIT_ASSERT_EQUAL(std::string("2"), 
aView.m_aCommentCallbackResult.get("id"));
+CPPUNIT_ASSERT_EQUAL(std::string("0"), 
aView.m_aCommentCallbackResult.get("tab"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Client"), 
aView.m_aCommentCallbackResult.get("author"

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

2022-04-08 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/data/validity.xlsx |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx |   57 ---
 2 files changed, 52 insertions(+), 5 deletions(-)

New commits:
commit 388b4fc1085074da759903a9b1768bded43dd0d3
Author: Dennis Francis 
AuthorDate: Thu Apr 7 13:14:59 2022 +0530
Commit: Dennis Francis 
CommitDate: Fri Apr 8 09:16:08 2022 +0200

lok: unit test for invalid entry save

Unit test related to the fix

lok: avoid validation-dialog yield when saving
e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593

The test ensures that the document is marked unmodified after save has
been executed in the middle of entering partial data to a validation
cell.

Change-Id: Idffd6d647034e128d0d800fe8e29efc333c03db6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132655
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/qa/unit/tiledrendering/data/validity.xlsx 
b/sc/qa/unit/tiledrendering/data/validity.xlsx
new file mode 100644
index ..54a92acd5979
Binary files /dev/null and b/sc/qa/unit/tiledrendering/data/validity.xlsx differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 249cd2420e4a..7ce8ad47105b 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -124,6 +124,7 @@ public:
 void testSheetViewDataCrash();
 void testTextBoxInsert();
 void testCommentCellCopyPaste();
+void testInvalidEntrySave();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -180,6 +181,7 @@ public:
 CPPUNIT_TEST(testSheetViewDataCrash);
 CPPUNIT_TEST(testTextBoxInsert);
 CPPUNIT_TEST(testCommentCellCopyPaste);
+CPPUNIT_TEST(testInvalidEntrySave);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2569,18 +2571,25 @@ void ScTiledRenderingTest::testSortAscendingDescending()
 CPPUNIT_ASSERT_EQUAL(OString("rows"), aView.m_sInvalidateSheetGeometry);
 }
 
-void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, 
ScTabViewShell* pView, ScModelObj* pModelObj)
+void lcl_typeCharsInCell(const std::string& aStr, SCCOL nCol, SCROW nRow, 
ScTabViewShell* pView,
+ScModelObj* pModelObj, bool bInEdit = false, bool bCommit = true)
 {
-pView->SetCursor(nCol, nRow);
+if (!bInEdit)
+pView->SetCursor(nCol, nRow);
+
 for (const char& cChar : aStr)
 {
 pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, cChar, 0);
 pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, cChar, 0);
 Scheduler::ProcessEventsToIdle();
 }
-pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
-pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
-Scheduler::ProcessEventsToIdle();
+
+if (bCommit)
+{
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN);
+pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN);
+Scheduler::ProcessEventsToIdle();
+}
 }
 
 void ScTiledRenderingTest::testAutoInputStringBlock()
@@ -2914,6 +2923,44 @@ void ScTiledRenderingTest::testCommentCellCopyPaste()
 comphelper::LibreOfficeKit::setTiledAnnotations(true);
 }
 
+void ScTiledRenderingTest::testInvalidEntrySave()
+{
+// Load a document
+comphelper::LibreOfficeKit::setActive();
+
+ScModelObj* pModelObj = createDoc("validity.xlsx");
+const ScDocument* pDoc = pModelObj->GetDocument();
+ViewCallback aView;
+int nView = SfxLokHelper::getView();
+
+SfxLokHelper::setView(nView);
+
+ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( 
pModelObj->GetEmbeddedObject() );
+ScTabViewShell* pTabViewShell = 
dynamic_cast(SfxViewShell::Current());
+CPPUNIT_ASSERT(pTabViewShell);
+
+// Type partial date "7/8" of "7/8/2013" that
+// the validation cell at A8 can accept
+lcl_typeCharsInCell("7/8", 0, 7, pTabViewShell, pModelObj,
+false /* bInEdit */, false /* bCommit */); // Type "7/8" in A8
+
+uno::Sequence aArgs;
+comphelper::dispatchCommand(".uno:Save", aArgs);
+Scheduler::ProcessEventsToIdle();
+
+CPPUNIT_ASSERT_MESSAGE("Should not be marked modified after save", 
!pDocSh->IsModified());
+
+// Complete the date in A8 by appending "/2013" and commit.
+lcl_typeCharsInCell("/2013", 0, 7, pTabViewShell, pModelObj,
+true /* bInEdit */, true /* bCommit */);
+
+// This would hang if the date entered "7/8/2013" is not acceptable.
+Scheduler::ProcessEventsToIdle();
+
+// Ensure that the correct date is recorded in the document.
+CPPUNIT_ASSERT_EQUAL(double(41463), pDoc->GetValue(ScAddress(0, 7, 0)));
+}
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);


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

2022-04-08 Thread Dennis Francis (via logerrit)
 sc/inc/scmod.hxx   |2 +-
 sc/source/ui/app/inputhdl.cxx  |   12 +++-
 sc/source/ui/app/scmod.cxx |4 ++--
 sc/source/ui/inc/inputhdl.hxx  |2 +-
 sc/source/ui/view/tabvwsha.cxx |   11 +--
 5 files changed, 24 insertions(+), 7 deletions(-)

New commits:
commit 08d3d0bcfd6a0540b19252730b2090da0b5da2d4
Author: Dennis Francis 
AuthorDate: Fri Apr 1 14:50:42 2022 +0530
Commit: Dennis Francis 
CommitDate: Fri Apr 8 09:15:30 2022 +0200

lok: avoid validation-dialog yield when saving

Disable error dialog box when about to save in lok mode as this
ultimately invokes SvpSalInstance::DoYield() when we want to save
immediately without committing any erroneous input in possibly a cell
with validation rules. After save is complete the user can continue
editing.

Conflicts:
sc/source/ui/app/inputhdl.cxx

Change-Id: Iffa0766ad594db75f57158986c4e1d2646f71da4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132410
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
(cherry picked from commit e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132654
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index a0a6e17e8423..919f4c22056d 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -197,7 +197,7 @@ public:
 boolIsInputMode();  // also for SC_INPUT_TYPE
 voidSetInputMode( ScInputMode eMode, const OUString* 
pInitText = nullptr );
 boolInputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit 
= false );
-SC_DLLPUBLIC void   InputEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL );
+SC_DLLPUBLIC void   InputEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
 voidInputCancelHandler();
 voidInputSelection( const EditView* pView );
 voidInputChanged( const EditView* pView );
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index abd1190475fb..f7a41b13d084 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2993,7 +2993,7 @@ static void lcl_SelectionToEnd( EditView* pView )
 }
 }
 
-void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
+void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool 
bBeforeSavingInLOK )
 {
 if (!mbDocumentDisposing && comphelper::LibreOfficeKit::isActive()
 && pActiveViewSh != SfxViewShell::Current())
@@ -3073,6 +3073,16 @@ void ScInputHandler::EnterHandler( ScEnterMode 
nBlockMode )
 pSelEngine->ReleaseMouse();
 }
 
+if (bBeforeSavingInLOK)
+{
+// Invalid entry but not applied to the document model.
+// Exit to complete the "save", leaving the edit view as 
it is
+// for the user to continue after save.
+bInOwnChange = false;
+bInEnterHandler = false;
+return;
+}
+
 if (pData->DoError(pActiveViewSh->GetFrameWeld(), aString, 
aCursorPos))
 bForget = true; // Do not take over input
 }
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index c4c0584eb6a9..97a5461956ca 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1405,13 +1405,13 @@ bool ScModule::InputKeyEvent( const KeyEvent& rKEvt, 
bool bStartEdit )
 return pHdl && pHdl->KeyInput( rKEvt, bStartEdit );
 }
 
-void ScModule::InputEnterHandler( ScEnterMode nBlockMode )
+void ScModule::InputEnterHandler( ScEnterMode nBlockMode, bool 
bBeforeSavingInLOK )
 {
 if ( !SfxGetpApp()->IsDowning() ) // Not when quitting the program
 {
 ScInputHandler* pHdl = GetInputHdl();
 if (pHdl)
-pHdl->EnterHandler( nBlockMode );
+pHdl->EnterHandler( nBlockMode, bBeforeSavingInLOK );
 }
 }
 
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index 0bc24bcd51db..625d2f7ca1f8 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -196,7 +196,7 @@ public:
 voidMergeLanguageAttributes( ScEditEngineDefaulter& 
rDestEngine ) const;
 
 boolKeyInput( const KeyEvent& rKEvt, bool bStartEdit );
-voidEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL 
);
+voidEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
 voidCancelHandler();
 voidSetReference( const ScRange& rRef, const ScDocument& rDoc 
);
 voidAddRefEntry();
dif

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

2022-04-06 Thread Dennis Francis (via logerrit)
 sc/inc/scmod.hxx   |2 +-
 sc/source/ui/app/inputhdl.cxx  |   12 +++-
 sc/source/ui/app/scmod.cxx |4 ++--
 sc/source/ui/inc/inputhdl.hxx  |2 +-
 sc/source/ui/view/tabvwsha.cxx |   11 +--
 5 files changed, 24 insertions(+), 7 deletions(-)

New commits:
commit e0175ee821eaff56c4b8e0a1b7afa1cabe0ab593
Author: Dennis Francis 
AuthorDate: Fri Apr 1 14:50:42 2022 +0530
Commit: Michael Meeks 
CommitDate: Wed Apr 6 11:37:38 2022 +0200

lok: avoid validation-dialog yield when saving

Disable error dialog box when about to save in lok mode as this
ultimately invokes SvpSalInstance::DoYield() when we want to save
immediately without committing any erroneous input in possibly a cell
with validation rules. After save is complete the user can continue
editing.

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

diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index c139afe9244c..6c0cfbb8b393 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -199,7 +199,7 @@ public:
 boolIsInputMode();  // also for SC_INPUT_TYPE
 voidSetInputMode( ScInputMode eMode, const OUString* 
pInitText = nullptr );
 boolInputKeyEvent( const KeyEvent& rKEvt, bool bStartEdit 
= false );
-SC_DLLPUBLIC void   InputEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL );
+SC_DLLPUBLIC void   InputEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
 voidInputCancelHandler();
 voidInputSelection( const EditView* pView );
 voidInputChanged( const EditView* pView );
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index c04e0db4aa86..c459c3438ca9 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2934,7 +2934,7 @@ static void lcl_SelectionToEnd( EditView* pView )
 }
 }
 
-void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
+void ScInputHandler::EnterHandler( ScEnterMode nBlockMode, bool 
bBeforeSavingInLOK )
 {
 if (!mbDocumentDisposing && comphelper::LibreOfficeKit::isActive()
 && pActiveViewSh != SfxViewShell::Current())
@@ -3016,6 +3016,16 @@ void ScInputHandler::EnterHandler( ScEnterMode 
nBlockMode )
 }
 }
 
+if (bBeforeSavingInLOK)
+{
+// Invalid entry but not applied to the document model.
+// Exit to complete the "save", leaving the edit view as 
it is
+// for the user to continue after save.
+bInOwnChange = false;
+bInEnterHandler = false;
+return;
+}
+
 vcl::Window* pParent = nullptr;
 if (pActiveViewSh)
 pParent = >GetViewFrame()->GetWindow();
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 4163094bd390..d7619d23a156 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1407,13 +1407,13 @@ bool ScModule::InputKeyEvent( const KeyEvent& rKEvt, 
bool bStartEdit )
 return pHdl && pHdl->KeyInput( rKEvt, bStartEdit );
 }
 
-void ScModule::InputEnterHandler( ScEnterMode nBlockMode )
+void ScModule::InputEnterHandler( ScEnterMode nBlockMode, bool 
bBeforeSavingInLOK )
 {
 if ( !SfxGetpApp()->IsDowning() ) // Not when quitting the program
 {
 ScInputHandler* pHdl = GetInputHdl();
 if (pHdl)
-pHdl->EnterHandler( nBlockMode );
+pHdl->EnterHandler( nBlockMode, bBeforeSavingInLOK );
 }
 }
 
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
index ddd3f4f49e8b..a57905d05597 100644
--- a/sc/source/ui/inc/inputhdl.hxx
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -196,7 +196,7 @@ public:
 voidMergeLanguageAttributes( ScEditEngineDefaulter& 
rDestEngine ) const;
 
 boolKeyInput( const KeyEvent& rKEvt, bool bStartEdit );
-voidEnterHandler( ScEnterMode nBlockMode = ScEnterMode::NORMAL 
);
+voidEnterHandler( ScEnterMode nBlockMode = 
ScEnterMode::NORMAL, bool bBeforeSavingInLOK = false );
 voidCancelHandler();
 voidSetReference( const ScRange& rRef, const ScDocument& rDoc 
);
 voidAddRefEntry();
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
index 4a6062fddff5..446854246c89 100644
--- a/sc/source/ui/view/tabvwsha.cxx
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -759,9 +759,16 @@ void ScTabViewShell::ExecuteSave( SfxRequest& rReq )
 // Finish entering unless 'DontTerminateE

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

2022-04-01 Thread Dennis Francis (via logerrit)
 sc/source/core/data/column4.cxx |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 52dcf533a20c97234b6d286a42651e1a952745a1
Author: Dennis Francis 
AuthorDate: Wed Mar 16 11:27:48 2022 +0530
Commit: Andras Timar 
CommitDate: Fri Apr 1 13:49:57 2022 +0200

lok-comments: CopyOneCellFromClip: notify lok clients

Conflicts:
sc/source/core/data/column4.cxx

Change-Id: I4b433c8f7123fe33f1b106cbf45216d2b0c73dba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131691
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit 3902718e6daed24e4fe3653b4241f94e802c4e56)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132255
Reviewed-by: Andras Timar 

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 7acd4b0a9183..57edd94a6a52 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -304,6 +305,14 @@ void ScColumn::CopyOneCellFromClip( 
sc::CopyFromClipContext& rCxt, SCROW nRow1,
 pBlockPos->miCellNotePos =
 maCellNotes.set(
 pBlockPos->miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
+
+// Notify our LOK clients.
+aDestPos.SetRow(nRow1);
+for (size_t i = 0; i < nDestSize; ++i)
+{
+ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
pDocument, aDestPos, aNotes[i]);
+aDestPos.IncRow();
+}
 }
 }
 


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

2022-04-01 Thread Dennis Francis (via logerrit)
 sc/source/core/data/column2.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 53c08c9438a98b2c1a75ed8fa8dc7d2f7c79eebd
Author: Dennis Francis 
AuthorDate: Wed Mar 16 11:29:34 2022 +0530
Commit: Andras Timar 
CommitDate: Fri Apr 1 13:48:57 2022 +0200

lok: CopyCellNotesHandler: use the cloned object

to get correct id for the new cell-note.

Conflicts:
sc/source/core/data/column2.cxx

Change-Id: I4df492ad91faad5797ba513f9a3aa9abd2baf88f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131690
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit acafc2823f917b6f6299fa0b65a0d7461531c8a5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132254
Reviewed-by: Andras Timar 

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 2918e31cd2c4..a8c704a5bef4 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1853,9 +1853,10 @@ public:
 SCROW nDestRow = nRow + mnDestOffset;
 ScAddress aSrcPos(mnSrcCol, nRow, mnSrcTab);
 ScAddress aDestPos(mnDestCol, nDestRow, mnDestTab);
-miPos = mrDestNotes.set(miPos, nDestRow, p->Clone(aSrcPos, 
*mrDestCol.GetDoc(), aDestPos, mbCloneCaption).release());
+ScPostIt* pNew = p->Clone(aSrcPos, *mrDestCol.GetDoc(), aDestPos, 
mbCloneCaption).release();
+miPos = mrDestNotes.set(miPos, nDestRow, pNew);
 // Notify our LOK clients also
-ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
mrDestCol.GetDoc(), aDestPos, p);
+ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
mrDestCol.GetDoc(), aDestPos, pNew);
 }
 };
 


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

2022-04-01 Thread Dennis Francis (via logerrit)
 sc/source/core/data/postit.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 9c156554e59922ce56df061b56292972e0f88549
Author: Dennis Francis 
AuthorDate: Tue Mar 15 13:00:35 2022 +0530
Commit: Andras Timar 
CommitDate: Fri Apr 1 13:48:35 2022 +0200

lok: ensure unique id for annotations

Problem:
When a cell containing comment is copied and pasted to another cell, the
cloned comment/annotation in the target cell has the same id as the
original one. The lok clients depend upon the id of each comment to
identify them and update coordinates when updates are requested through
.uno:ViewAnnotationsPosition. So the client does not have enough
information to distinguish between comments of same id.

Change-Id: Iebd7281113e0830826aff1bbdaae234bd5d5cd4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131689
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit dd229e4cd9a0211c9a80031da1d2f7fb71b6683e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132253
Reviewed-by: Andras Timar 

diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index b92082ef7115..fc7bea8fd718 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -876,7 +877,8 @@ ScPostIt::~ScPostIt()
 std::unique_ptr ScPostIt::Clone( const ScAddress& rOwnPos, 
ScDocument& rDestDoc, const ScAddress& rDestPos, bool bCloneCaption ) const
 {
 CreateCaptionFromInitData( rOwnPos );
-return bCloneCaption ? std::make_unique( rDestDoc, rDestPos, 
*this, mnPostItId ) : std::make_unique( rDestDoc, rDestPos, 
maNoteData, false, mnPostItId );
+sal_uInt32 nPostItId = comphelper::LibreOfficeKit::isActive() ? 0 : 
mnPostItId;
+return bCloneCaption ? std::make_unique( rDestDoc, rDestPos, 
*this, nPostItId ) : std::make_unique( rDestDoc, rDestPos, 
maNoteData, false, mnPostItId );
 }
 
 void ScPostIt::SetDate( const OUString& rDate )


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

2022-03-30 Thread Dennis Francis (via logerrit)
 sc/source/ui/undo/undoblk.cxx |   14 ++
 1 file changed, 14 insertions(+)

New commits:
commit 6ade0f41805261c9c8c7ac784f5bddb2ad47efda
Author: Dennis Francis 
AuthorDate: Thu Mar 24 10:21:11 2022 +0530
Commit: Dennis Francis 
CommitDate: Thu Mar 31 07:42:25 2022 +0200

lok: paste-undo: invalidate sheetgeometry

In case of copy/pasting of whole column(row) and its undo/redo may
result in column(row) width(height) changes. Hence a corresponding
sheet-geometry invalidation message needs to be sent to the lok
client(s).

Change-Id: I7aa471d9770fc21c567a3c6f5d5926df0fd5dacb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132174
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 77a7bc096860..e3b10f78bca8 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1094,6 +1094,11 @@ void ScUndoPaste::DoChange(bool bUndo)
 
 ScRangeList aDrawRanges(maBlockRanges);
 PaintPartFlags nPaint = PaintPartFlags::Grid;
+
+// For sheet geometry invalidation.
+bool bColsAffected = false;
+bool bRowsAffected = false;
+
 for (size_t i = 0, n = aDrawRanges.size(); i < n; ++i)
 {
 ScRange& rDrawRange = aDrawRanges[i];
@@ -1116,11 +1121,13 @@ void ScUndoPaste::DoChange(bool bUndo)
 {
 nPaint |= PaintPartFlags::Top;
 rDrawRange.aEnd.SetCol(rDoc.MaxCol());
+bColsAffected = true;
 }
 if (maBlockRanges[i].aStart.Col() == 0 && 
maBlockRanges[i].aEnd.Col() == rDoc.MaxCol()) // whole row
 {
 nPaint |= PaintPartFlags::Left;
 rDrawRange.aEnd.SetRow(rDoc.MaxRow());
+bRowsAffected = true;
 }
 if (pViewShell && pViewShell->AdjustBlockHeight(false, ))
 {
@@ -1142,6 +1149,13 @@ void ScUndoPaste::DoChange(bool bUndo)
 pDocShell->PostDataChanged();
 if (pViewShell)
 pViewShell->CellContentChanged();
+
+if (bColsAffected || bRowsAffected)
+ScTabViewShell::notifyAllViewsSheetGeomInvalidation(
+pViewShell,
+bColsAffected, bRowsAffected,
+true /* bSizes*/, true /* bHidden */, true /* bFiltered */,
+true /* bGroups */, aDrawRanges[0].aStart.Tab());
 }
 
 void ScUndoPaste::Undo()


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

2022-03-30 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |  102 +++
 1 file changed, 102 insertions(+)

New commits:
commit a8aad2c761ccc18cd24ff2a87e6bd1b5c2b8cfe1
Author: Dennis Francis 
AuthorDate: Fri Mar 18 12:48:30 2022 +0530
Commit: Dennis Francis 
CommitDate: Thu Mar 31 07:40:49 2022 +0200

lok: unit-test: add comment unique id checks

Change-Id: I588484955ad3ad4c5ec3bfa9f5a844096c768ff2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131725
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit 9bafce808b6d301b17ee60da452a41cd4b7cf02c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132173
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 04c22438f74b..249cd2420e4a 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -122,6 +123,7 @@ public:
 void testTextSelectionBounds();
 void testSheetViewDataCrash();
 void testTextBoxInsert();
+void testCommentCellCopyPaste();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -177,6 +179,7 @@ public:
 CPPUNIT_TEST(testTextSelectionBounds);
 CPPUNIT_TEST(testSheetViewDataCrash);
 CPPUNIT_TEST(testTextBoxInsert);
+CPPUNIT_TEST(testCommentCellCopyPaste);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2812,6 +2815,105 @@ void ScTiledRenderingTest::testTextBoxInsert()
 Scheduler::ProcessEventsToIdle();
 }
 
+void ScTiledRenderingTest::testCommentCellCopyPaste()
+{
+// Load a document
+comphelper::LibreOfficeKit::setActive();
+// Comments callback are emitted only if tiled annotations are off
+comphelper::LibreOfficeKit::setTiledAnnotations(false);
+
+// FIXME: Hack because previous tests do not destroy ScDocument(with 
annotations) on exit (?).
+ScPostIt::mnLastPostItId = 1;
+
+{
+ScModelObj* pModelObj = createDoc("empty.ods");
+ViewCallback aView;
+int nView = SfxLokHelper::getView();
+
+SfxLokHelper::setView(nView);
+
+ScTabViewShell* pTabViewShell = 
dynamic_cast(SfxViewShell::Current());
+CPPUNIT_ASSERT(pTabViewShell);
+
+lcl_typeCharsInCell("ABC", 0, 0, pTabViewShell, pModelObj); // Type 
"ABC" in A1
+
+pTabViewShell->SetCursor(1, 1);
+
+// Add a new comment
+uno::Sequence 
aArgs(comphelper::InitPropertySequence(
+{
+{"Text", uno::makeAny(OUString("LOK Comment Cell B2"))},
+{"Author", uno::makeAny(OUString("LOK Client"))},
+}));
+comphelper::dispatchCommand(".uno:InsertAnnotation", aArgs);
+Scheduler::ProcessEventsToIdle();
+
+// We received a LOK_CALLBACK_COMMENT callback with comment 'Add' 
action
+CPPUNIT_ASSERT_EQUAL(std::string("Add"), 
aView.m_aCommentCallbackResult.get("action"));
+CPPUNIT_ASSERT_EQUAL(std::string("1"), 
aView.m_aCommentCallbackResult.get("id"));
+CPPUNIT_ASSERT_EQUAL(std::string("0"), 
aView.m_aCommentCallbackResult.get("tab"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Client"), 
aView.m_aCommentCallbackResult.get("author"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Comment Cell B2"), 
aView.m_aCommentCallbackResult.get("text"));
+
+uno::Sequence aCopyPasteArgs;
+
+// We need separate tests for single cell copy-paste and cell-range 
copy-paste
+// since they hit different code paths in ScColumn methods.
+
+// Single cell(with comment) copy paste test
+{
+comphelper::dispatchCommand(".uno:Copy", aCopyPasteArgs);
+Scheduler::ProcessEventsToIdle();
+
+pTabViewShell->SetCursor(1, 49);
+Scheduler::ProcessEventsToIdle();
+comphelper::dispatchCommand(".uno:Paste", aCopyPasteArgs); // 
Paste to cell B50
+Scheduler::ProcessEventsToIdle();
+
+// We received a LOK_CALLBACK_COMMENT callback with comment 'Add' 
action
+CPPUNIT_ASSERT_EQUAL(std::string("Add"), 
aView.m_aCommentCallbackResult.get("action"));
+// Without the fix the id will be "1".
+CPPUNIT_ASSERT_EQUAL(std::string("2"), 
aView.m_aCommentCallbackResult.get("id"));
+CPPUNIT_ASSERT_EQUAL(std::string("0"), 
aView.m_aCommentCallbackResult.get("tab"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Client"), 
aView.m_aCommentCallbackResult.get("author"));
+CPPUN

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

2022-03-30 Thread Dennis Francis (via logerrit)
 sc/source/core/data/column4.cxx |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 48d0a9423f21b6380c3ca819e090947d3a25e23c
Author: Dennis Francis 
AuthorDate: Wed Mar 16 11:27:48 2022 +0530
Commit: Dennis Francis 
CommitDate: Thu Mar 31 07:40:04 2022 +0200

lok-comments: CopyOneCellFromClip: notify lok clients

Change-Id: I4b433c8f7123fe33f1b106cbf45216d2b0c73dba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131691
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit 3902718e6daed24e4fe3653b4241f94e802c4e56)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132172
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 8bf1e0af8321..e109448c4fce 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -341,6 +342,14 @@ void ScColumn::CopyOneCellFromClip( 
sc::CopyFromClipContext& rCxt, SCROW nRow1,
 pBlockPos->miCellNotePos =
 maCellNotes.set(
 pBlockPos->miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
+
+// Notify our LOK clients.
+aDestPos.SetRow(nRow1);
+for (size_t i = 0; i < nDestSize; ++i)
+{
+ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
, aDestPos, aNotes[i]);
+aDestPos.IncRow();
+}
 }
 
 void ScColumn::SetValues( const SCROW nRow, const std::vector& rVals )


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

2022-03-30 Thread Dennis Francis (via logerrit)
 sc/source/core/data/column2.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 52fb77b4145e1206d164c36f045b367c684c266c
Author: Dennis Francis 
AuthorDate: Wed Mar 16 11:29:34 2022 +0530
Commit: Dennis Francis 
CommitDate: Thu Mar 31 07:39:30 2022 +0200

lok: CopyCellNotesHandler: use the cloned object

to get correct id for the new cell-note.

Change-Id: I4df492ad91faad5797ba513f9a3aa9abd2baf88f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131690
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit acafc2823f917b6f6299fa0b65a0d7461531c8a5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132171
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index f1a803750002..1f0ca6aad9d2 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1903,9 +1903,10 @@ public:
 SCROW nDestRow = nRow + mnDestOffset;
 ScAddress aSrcPos(mnSrcCol, nRow, mnSrcTab);
 ScAddress aDestPos(mnDestCol, nDestRow, mnDestTab);
-miPos = mrDestNotes.set(miPos, nDestRow, p->Clone(aSrcPos, 
mrDestCol.GetDoc(), aDestPos, mbCloneCaption).release());
+ScPostIt* pNew = p->Clone(aSrcPos, mrDestCol.GetDoc(), aDestPos, 
mbCloneCaption).release();
+miPos = mrDestNotes.set(miPos, nDestRow, pNew);
 // Notify our LOK clients also
-ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
(), aDestPos, p);
+ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
(), aDestPos, pNew);
 }
 };
 


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

2022-03-30 Thread Dennis Francis (via logerrit)
 sc/source/core/data/postit.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit d0221fb6c35ecceb53e347d2790ac66b8a021044
Author: Dennis Francis 
AuthorDate: Tue Mar 15 13:00:35 2022 +0530
Commit: Dennis Francis 
CommitDate: Thu Mar 31 07:38:27 2022 +0200

lok: ensure unique id for annotations

Problem:
When a cell containing comment is copied and pasted to another cell, the
cloned comment/annotation in the target cell has the same id as the
original one. The lok clients depend upon the id of each comment to
identify them and update coordinates when updates are requested through
.uno:ViewAnnotationsPosition. So the client does not have enough
information to distinguish between comments of same id.

Conflicts:
sc/source/core/data/postit.cxx

Change-Id: Iebd7281113e0830826aff1bbdaae234bd5d5cd4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131689
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit dd229e4cd9a0211c9a80031da1d2f7fb71b6683e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132170
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index ef7ff3bc4725..cd8acfdceec4 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -877,7 +878,8 @@ ScPostIt::~ScPostIt()
 std::unique_ptr ScPostIt::Clone( const ScAddress& rOwnPos, 
ScDocument& rDestDoc, const ScAddress& rDestPos, bool bCloneCaption ) const
 {
 CreateCaptionFromInitData( rOwnPos );
-return bCloneCaption ? std::make_unique( rDestDoc, rDestPos, 
*this, mnPostItId ) : std::make_unique( rDestDoc, rDestPos, 
maNoteData, false, mnPostItId );
+sal_uInt32 nPostItId = comphelper::LibreOfficeKit::isActive() ? 0 : 
mnPostItId;
+return bCloneCaption ? std::make_unique( rDestDoc, rDestPos, 
*this, nPostItId ) : std::make_unique( rDestDoc, rDestPos, 
maNoteData, false, mnPostItId );
 }
 
 void ScPostIt::SetDate( const OUString& rDate )


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 26 commits - external/liborcus filter/source icon-themes/colibre instsetoo_native/inc_openoffice oox/qa sc/qa sc/source sd/source s

2022-03-30 Thread Dennis Francis (via logerrit)
Rebased ref, commits from common ancestor:
commit fa5575a45fe33edcb6b802c413124327b5b9e2f0
Author: Dennis Francis 
AuthorDate: Thu Mar 24 10:21:11 2022 +0530
Commit: Andras Timar 
CommitDate: Wed Mar 30 12:07:19 2022 +0200

lok: paste-undo: invalidate sheetgeometry

In case of copy/pasting of whole column(row) and its undo/redo may
result in column(row) width(height) changes. Hence a corresponding
sheet-geometry invalidation message needs to be sent to the lok
client(s).

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

diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index e217157b6744..d1ae29a93ee7 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1094,6 +1094,11 @@ void ScUndoPaste::DoChange(bool bUndo)
 
 ScRangeList aDrawRanges(maBlockRanges);
 PaintPartFlags nPaint = PaintPartFlags::Grid;
+
+// For sheet geometry invalidation.
+bool bColsAffected = false;
+bool bRowsAffected = false;
+
 for (size_t i = 0, n = aDrawRanges.size(); i < n; ++i)
 {
 ScRange& rDrawRange = aDrawRanges[i];
@@ -1116,11 +1121,13 @@ void ScUndoPaste::DoChange(bool bUndo)
 {
 nPaint |= PaintPartFlags::Top;
 rDrawRange.aEnd.SetCol(rDoc.MaxCol());
+bColsAffected = true;
 }
 if (maBlockRanges[i].aStart.Col() == 0 && 
maBlockRanges[i].aEnd.Col() == rDoc.MaxCol()) // whole row
 {
 nPaint |= PaintPartFlags::Left;
 rDrawRange.aEnd.SetRow(rDoc.MaxRow());
+bRowsAffected = true;
 }
 if (pViewShell && pViewShell->AdjustBlockHeight(false, ))
 {
@@ -1142,6 +1149,13 @@ void ScUndoPaste::DoChange(bool bUndo)
 pDocShell->PostDataChanged();
 if (pViewShell)
 pViewShell->CellContentChanged();
+
+if (bColsAffected || bRowsAffected)
+ScTabViewShell::notifyAllViewsSheetGeomInvalidation(
+pViewShell,
+bColsAffected, bRowsAffected,
+true /* bSizes*/, true /* bHidden */, true /* bFiltered */,
+true /* bGroups */, aDrawRanges[0].aStart.Tab());
 }
 
 void ScUndoPaste::Undo()
commit 2cec7913df83276e03423bed8f40cd7e341e9be6
Author: Tor Lillqvist 
AuthorDate: Mon Mar 28 14:51:43 2022 +0300
Commit: Andras Timar 
CommitDate: Wed Mar 30 12:07:19 2022 +0200

Make slideshow touch gestures work again in the mobile apps

Need to s/lool/cool/ here, too.

Change-Id: Ib6762f196ca2b1c2e8735c6ff3e591164d34fb0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132202
Tested-by: Tor Lillqvist 
Reviewed-by: Tor Lillqvist 

diff --git a/filter/source/svg/presentation_engine.js 
b/filter/source/svg/presentation_engine.js
index 636fc3a50d37..370bacc5cd72 100644
--- a/filter/source/svg/presentation_engine.js
+++ b/filter/source/svg/presentation_engine.js
@@ -18622,8 +18622,8 @@ SlideShow.prototype.exitSlideShowInApp = function()
 {
 if (window.webkit !== undefined &&
 window.webkit.messageHandlers !== undefined &&
-window.webkit.messageHandlers.lool !== undefined)
-window.webkit.messageHandlers.lool.postMessage('EXITSLIDESHOW', '*');
+window.webkit.messageHandlers.cool !== undefined)
+window.webkit.messageHandlers.cool.postMessage('EXITSLIDESHOW', '*');
 }
 
 SlideShow.prototype.displaySlide = function( nNewSlide, bSkipSlideTransition )
commit 1d84d14d55046039713a22911c86987e732011d3
Author: Szymon Kłos 
AuthorDate: Thu Mar 24 11:29:59 2022 +0100
Commit: Andras Timar 
CommitDate: Wed Mar 30 12:07:18 2022 +0200

lok: use JsonWriter for annotations notification

This will unify received objects in LOK.
boost::property_tree used "string" for number values
we expect them to be a "number" type.

Change-Id: Ie90d7e2dd98bb371fc09878dcc6e96f4cdf73f3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132054
    Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Dennis Francis 

diff --git a/sd/source/core/annotations/Annotation.cxx 
b/sd/source/core/annotations/Annotation.cxx
index 1d1ca39fc9dd..991412f063d5 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -22,8 +22,6 @@
 #include 
 #include 
 
-#include 
-
 #include 
 
 #include 
@@ -38,6 +36,8 @@
 
 #include 
 
+#include 
+
 using namespace css;
 
 namespace com::sun::star::uno { class XComponentContext; }
@@ -342,34 +342,33 @@ namespace
 {
 std::string lcl_LOKGetCommentPayload(CommentNotificationType nType, 
uno::Reference const & rxAnnotation)
 {
-boost::property_tree::ptree aAnnotation;
-aAnnotation.put("action", (nTyp

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

2022-03-29 Thread Dennis Francis (via logerrit)
 sc/source/ui/undo/undoblk.cxx |   14 ++
 1 file changed, 14 insertions(+)

New commits:
commit 066076255277261898278102b49cf91fdd3d2881
Author: Dennis Francis 
AuthorDate: Thu Mar 24 10:21:11 2022 +0530
Commit: Szymon Kłos 
CommitDate: Tue Mar 29 09:51:28 2022 +0200

lok: paste-undo: invalidate sheetgeometry

In case of copy/pasting of whole column(row) and its undo/redo may
result in column(row) width(height) changes. Hence a corresponding
sheet-geometry invalidation message needs to be sent to the lok
client(s).

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

diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index f4ea10273b1e..6391547f23ef 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1096,6 +1096,11 @@ void ScUndoPaste::DoChange(bool bUndo)
 
 ScRangeList aDrawRanges(maBlockRanges);
 PaintPartFlags nPaint = PaintPartFlags::Grid;
+
+// For sheet geometry invalidation.
+bool bColsAffected = false;
+bool bRowsAffected = false;
+
 for (size_t i = 0, n = aDrawRanges.size(); i < n; ++i)
 {
 ScRange& rDrawRange = aDrawRanges[i];
@@ -1118,11 +1123,13 @@ void ScUndoPaste::DoChange(bool bUndo)
 {
 nPaint |= PaintPartFlags::Top;
 rDrawRange.aEnd.SetCol(rDoc.MaxCol());
+bColsAffected = true;
 }
 if (maBlockRanges[i].aStart.Col() == 0 && 
maBlockRanges[i].aEnd.Col() == rDoc.MaxCol()) // whole row
 {
 nPaint |= PaintPartFlags::Left;
 rDrawRange.aEnd.SetRow(rDoc.MaxRow());
+bRowsAffected = true;
 }
 if (pViewShell && pViewShell->AdjustBlockHeight(false, ))
 {
@@ -1144,6 +1151,13 @@ void ScUndoPaste::DoChange(bool bUndo)
 pDocShell->PostDataChanged();
 if (pViewShell)
 pViewShell->CellContentChanged();
+
+if (bColsAffected || bRowsAffected)
+ScTabViewShell::notifyAllViewsSheetGeomInvalidation(
+pViewShell,
+bColsAffected, bRowsAffected,
+true /* bSizes*/, true /* bHidden */, true /* bFiltered */,
+true /* bGroups */, aDrawRanges[0].aStart.Tab());
 }
 
 void ScUndoPaste::Undo()


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

2022-03-24 Thread Dennis Francis (via logerrit)
 sc/qa/unit/tiledrendering/tiledrendering.cxx |  102 +++
 1 file changed, 102 insertions(+)

New commits:
commit 9bafce808b6d301b17ee60da452a41cd4b7cf02c
Author: Dennis Francis 
AuthorDate: Fri Mar 18 12:48:30 2022 +0530
Commit: Szymon Kłos 
CommitDate: Thu Mar 24 14:23:26 2022 +0100

lok: unit-test: add comment unique id checks

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

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index b9b7e698c081..3364e049c22f 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -125,6 +126,7 @@ public:
 void testTextSelectionBounds();
 void testSheetViewDataCrash();
 void testTextBoxInsert();
+void testCommentCellCopyPaste();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -179,6 +181,7 @@ public:
 CPPUNIT_TEST(testTextSelectionBounds);
 CPPUNIT_TEST(testSheetViewDataCrash);
 CPPUNIT_TEST(testTextBoxInsert);
+CPPUNIT_TEST(testCommentCellCopyPaste);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2917,6 +2920,105 @@ void ScTiledRenderingTest::testTextBoxInsert()
 Scheduler::ProcessEventsToIdle();
 }
 
+void ScTiledRenderingTest::testCommentCellCopyPaste()
+{
+// Load a document
+comphelper::LibreOfficeKit::setActive();
+// Comments callback are emitted only if tiled annotations are off
+comphelper::LibreOfficeKit::setTiledAnnotations(false);
+
+// FIXME: Hack because previous tests do not destroy ScDocument(with 
annotations) on exit (?).
+ScPostIt::mnLastPostItId = 1;
+
+{
+ScModelObj* pModelObj = createDoc("empty.ods");
+ViewCallback aView;
+int nView = SfxLokHelper::getView();
+
+SfxLokHelper::setView(nView);
+
+ScTabViewShell* pTabViewShell = 
dynamic_cast(SfxViewShell::Current());
+CPPUNIT_ASSERT(pTabViewShell);
+
+lcl_typeCharsInCell("ABC", 0, 0, pTabViewShell, pModelObj); // Type 
"ABC" in A1
+
+pTabViewShell->SetCursor(1, 1);
+
+// Add a new comment
+uno::Sequence 
aArgs(comphelper::InitPropertySequence(
+{
+{"Text", uno::makeAny(OUString("LOK Comment Cell B2"))},
+{"Author", uno::makeAny(OUString("LOK Client"))},
+}));
+comphelper::dispatchCommand(".uno:InsertAnnotation", aArgs);
+Scheduler::ProcessEventsToIdle();
+
+// We received a LOK_CALLBACK_COMMENT callback with comment 'Add' 
action
+CPPUNIT_ASSERT_EQUAL(std::string("Add"), 
aView.m_aCommentCallbackResult.get("action"));
+CPPUNIT_ASSERT_EQUAL(std::string("1"), 
aView.m_aCommentCallbackResult.get("id"));
+CPPUNIT_ASSERT_EQUAL(std::string("0"), 
aView.m_aCommentCallbackResult.get("tab"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Client"), 
aView.m_aCommentCallbackResult.get("author"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Comment Cell B2"), 
aView.m_aCommentCallbackResult.get("text"));
+
+uno::Sequence aCopyPasteArgs;
+
+// We need separate tests for single cell copy-paste and cell-range 
copy-paste
+// since they hit different code paths in ScColumn methods.
+
+// Single cell(with comment) copy paste test
+{
+comphelper::dispatchCommand(".uno:Copy", aCopyPasteArgs);
+Scheduler::ProcessEventsToIdle();
+
+pTabViewShell->SetCursor(1, 49);
+Scheduler::ProcessEventsToIdle();
+comphelper::dispatchCommand(".uno:Paste", aCopyPasteArgs); // 
Paste to cell B50
+Scheduler::ProcessEventsToIdle();
+
+// We received a LOK_CALLBACK_COMMENT callback with comment 'Add' 
action
+CPPUNIT_ASSERT_EQUAL(std::string("Add"), 
aView.m_aCommentCallbackResult.get("action"));
+// Without the fix the id will be "1".
+CPPUNIT_ASSERT_EQUAL(std::string("2"), 
aView.m_aCommentCallbackResult.get("id"));
+CPPUNIT_ASSERT_EQUAL(std::string("0"), 
aView.m_aCommentCallbackResult.get("tab"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Client"), 
aView.m_aCommentCallbackResult.get("author"));
+CPPUNIT_ASSERT_EQUAL(std::string("LOK Comment Cell B2"), 
aView.m_aCommentCallbackResult.get("text"));
+}
+
+// Cell range (with a comment) copy paste test
+{
+  

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

2022-03-24 Thread Dennis Francis (via logerrit)
 sc/source/core/data/column4.cxx |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 3902718e6daed24e4fe3653b4241f94e802c4e56
Author: Dennis Francis 
AuthorDate: Wed Mar 16 11:27:48 2022 +0530
Commit: Szymon Kłos 
CommitDate: Thu Mar 24 14:23:04 2022 +0100

lok-comments: CopyOneCellFromClip: notify lok clients

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

diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index 827b9d76831b..315b7c94dcb4 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -306,6 +307,14 @@ void ScColumn::CopyOneCellFromClip( 
sc::CopyFromClipContext& rCxt, SCROW nRow1,
 pBlockPos->miCellNotePos =
 maCellNotes.set(
 pBlockPos->miCellNotePos, nRow1, aNotes.begin(), aNotes.end());
+
+// Notify our LOK clients.
+aDestPos.SetRow(nRow1);
+for (size_t i = 0; i < nDestSize; ++i)
+{
+ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
, aDestPos, aNotes[i]);
+aDestPos.IncRow();
+}
 }
 
 void ScColumn::SetValues( const SCROW nRow, const std::vector& rVals )


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

2022-03-24 Thread Dennis Francis (via logerrit)
 sc/source/core/data/column2.cxx |5 +++--
 sc/source/core/data/postit.cxx  |4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit acafc2823f917b6f6299fa0b65a0d7461531c8a5
Author: Dennis Francis 
AuthorDate: Wed Mar 16 11:29:34 2022 +0530
Commit: Szymon Kłos 
CommitDate: Thu Mar 24 14:14:13 2022 +0100

lok: CopyCellNotesHandler: use the cloned object

to get correct id for the new cell-note.

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

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 886dab8f5ab8..25f7bdd12f86 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1866,9 +1866,10 @@ public:
 SCROW nDestRow = nRow + mnDestOffset;
 ScAddress aSrcPos(mnSrcCol, nRow, mnSrcTab);
 ScAddress aDestPos(mnDestCol, nDestRow, mnDestTab);
-miPos = mrDestNotes.set(miPos, nDestRow, p->Clone(aSrcPos, 
mrDestCol.GetDoc(), aDestPos, mbCloneCaption).release());
+ScPostIt* pNew = p->Clone(aSrcPos, mrDestCol.GetDoc(), aDestPos, 
mbCloneCaption).release();
+miPos = mrDestNotes.set(miPos, nDestRow, pNew);
 // Notify our LOK clients also
-ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
(), aDestPos, p);
+ScDocShell::LOKCommentNotify(LOKCommentNotificationType::Add, 
(), aDestPos, pNew);
 }
 };
 
commit dd229e4cd9a0211c9a80031da1d2f7fb71b6683e
Author: Dennis Francis 
AuthorDate: Tue Mar 15 13:00:35 2022 +0530
Commit: Szymon Kłos 
CommitDate: Thu Mar 24 14:13:56 2022 +0100

lok: ensure unique id for annotations

Problem:
When a cell containing comment is copied and pasted to another cell, the
cloned comment/annotation in the target cell has the same id as the
original one. The lok clients depend upon the id of each comment to
identify them and update coordinates when updates are requested through
.uno:ViewAnnotationsPosition. So the client does not have enough
information to distinguish between comments of same id.

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

diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index bafd2e9e901b..2e85eb0faf08 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -876,7 +877,8 @@ ScPostIt::~ScPostIt()
 std::unique_ptr ScPostIt::Clone( const ScAddress& rOwnPos, 
ScDocument& rDestDoc, const ScAddress& rDestPos, bool bCloneCaption ) const
 {
 CreateCaptionFromInitData( rOwnPos );
-return bCloneCaption ? std::make_unique( rDestDoc, rDestPos, 
*this, mnPostItId ) : std::make_unique( rDestDoc, rDestPos, 
maNoteData, false, mnPostItId );
+sal_uInt32 nPostItId = comphelper::LibreOfficeKit::isActive() ? 0 : 
mnPostItId;
+return bCloneCaption ? std::make_unique( rDestDoc, rDestPos, 
*this, nPostItId ) : std::make_unique( rDestDoc, rDestPos, 
maNoteData, false, mnPostItId );
 }
 
 void ScPostIt::SetDate( const OUString& rDate )


[Libreoffice-commits] core.git: chart2/source svx/source

2022-03-15 Thread Dennis Francis (via logerrit)
 chart2/source/controller/main/ChartController.cxx |   15 +++
 svx/source/svdraw/svdmrkv.cxx |8 
 2 files changed, 23 insertions(+)

New commits:
commit 64631ddcf360102d6f72a938a154529a1edc69f7
Author: Dennis Francis 
AuthorDate: Mon Mar 7 12:17:07 2022 +0530
Commit: Dennis Francis 
CommitDate: Tue Mar 15 08:28:46 2022 +0100

lokCalcRTL: chart-edit: no bounding box

Fix for selections(svx-marks) similar to the fix for chart edit mode
tile painting

```
4fd2a14c6ee68f0574766ec7ec3dca35debe9d20
lokCalcRTL: global RTL: fix chart edit mode rendering
```

Conflicts:
chart2/source/controller/main/ChartController.cxx

Change-Id: I2b5a2af7023b09254b8471b750122bec10126bde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131091
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131572
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index 974c36ba20e0..54e950a3b6eb 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -71,6 +71,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -79,6 +80,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -703,7 +705,20 @@ void ChartController::impl_createDrawViewController()
 {
 if( m_pDrawModelWrapper )
 {
+bool bLokCalcGlobalRTL = false;
+if(comphelper::LibreOfficeKit::isActive() && 
AllSettings::GetLayoutRTL())
+{
+rtl::Reference< ChartModel > xChartModel = getChartModel();
+if (xChartModel.is())
+{
+uno::Reference 
xSSDoc(xChartModel->getParent(), uno::UNO_QUERY);
+if (xSSDoc.is())
+bLokCalcGlobalRTL = true;
+}
+}
+
 m_pDrawViewWrapper.reset( new 
DrawViewWrapper(m_pDrawModelWrapper->getSdrModel(),GetChartWindow()->GetOutDev())
 );
+m_pDrawViewWrapper->SetNegativeX(bLokCalcGlobalRTL);
 m_pDrawViewWrapper->attachParentReferenceDevice( getChartModel() );
 }
 }
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index cac8dfc2db51..e831dbc92733 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -786,6 +786,14 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin))
 {
 Point aOffsetPx = 
pWin->GetOffsetPixelFrom(*pViewShellWindow);
+if (mbNegativeX && AllSettings::GetLayoutRTL())
+{
+// mbNegativeX is set only for Calc in RTL mode.
+// If global RTL flag is set, vcl-window X offset of 
chart window is
+// mirrored w.r.t parent window rectangle. This needs 
to be reverted.
+aOffsetPx.setX(pViewShellWindow->GetOutOffXPixel() + 
pViewShellWindow->GetSizePixel().Width()
+- pWin->GetOutOffXPixel() - 
pWin->GetSizePixel().Width());
+}
 Point aLogicOffset = pWin->PixelToLogic(aOffsetPx);
 addLogicOffset = aLogicOffset;
 aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY());


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - chart2/source svx/source

2022-03-11 Thread Dennis Francis (via logerrit)
 chart2/source/controller/main/ChartController.cxx |   15 +++
 svx/source/svdraw/svdmrkv.cxx |8 
 2 files changed, 23 insertions(+)

New commits:
commit be5e01372659897e50c7334ce205ceda4e3d1db5
Author: Dennis Francis 
AuthorDate: Mon Mar 7 12:17:07 2022 +0530
Commit: Szymon Kłos 
CommitDate: Fri Mar 11 10:36:28 2022 +0100

lokCalcRTL: chart-edit: no bounding box

Fix for selections(svx-marks) similar to the fix for chart edit mode
tile painting

```
4fd2a14c6ee68f0574766ec7ec3dca35debe9d20
lokCalcRTL: global RTL: fix chart edit mode rendering
```

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

diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index 137396b3e64b..18165659f9e0 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -71,6 +72,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -721,7 +723,20 @@ void ChartController::impl_createDrawViewController()
 {
 if( m_pDrawModelWrapper )
 {
+bool bLokCalcGlobalRTL = false;
+if(comphelper::LibreOfficeKit::isActive() && 
AllSettings::GetLayoutRTL())
+{
+uno::Reference< XChartDocument > xChartDoc(getModel(), 
uno::UNO_QUERY);
+if (xChartDoc.is())
+{
+ChartModel& rModel = dynamic_cast(*xChartDoc);
+uno::Reference 
xSSDoc(rModel.getParent(), uno::UNO_QUERY);
+if (xSSDoc.is())
+bLokCalcGlobalRTL = true;
+}
+}
 m_pDrawViewWrapper.reset( new 
DrawViewWrapper(m_pDrawModelWrapper->getSdrModel(),GetChartWindow()) );
+m_pDrawViewWrapper->SetNegativeX(bLokCalcGlobalRTL);
 m_pDrawViewWrapper->attachParentReferenceDevice( getModel() );
 }
 }
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 57ab32e44f81..ce6e2532473b 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -775,6 +775,14 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin))
 {
 Point aOffsetPx = 
pWin->GetOffsetPixelFrom(*pViewShellWindow);
+if (mbNegativeX && AllSettings::GetLayoutRTL())
+{
+// mbNegativeX is set only for Calc in RTL mode.
+// If global RTL flag is set, vcl-window X offset of 
chart window is
+// mirrored w.r.t parent window rectangle. This needs 
to be reverted.
+aOffsetPx.setX(pViewShellWindow->GetOutOffXPixel() + 
pViewShellWindow->GetSizePixel().Width()
+- pWin->GetOutOffXPixel() - 
pWin->GetSizePixel().Width());
+}
 Point aLogicOffset = pWin->PixelToLogic(aOffsetPx);
 addLogicOffset = aLogicOffset;
 aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY());


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - 159 commits - basic/qa basic/source bin/lo-all-static-libs canvas/source comphelper/source config_host.mk.in configure.ac connectiv

2022-02-14 Thread Dennis Francis (via logerrit)
Rebased ref, commits from common ancestor:
commit 5c982b3c9ebf50c3f814705363b2381877bed859
Author: Dennis Francis 
AuthorDate: Wed Feb 9 12:31:49 2022 +0530
Commit: Andras Timar 
CommitDate: Mon Feb 14 12:09:34 2022 +0100

lokCalcRTL: global RTL: fix chart edit mode rendering

If global RTL flag is set, vcl-window X offset of chart window is
mirrored w.r.t parent window rectangle. This has to be undone to get the
correct chart bounding box in negative X document coordinates so that
the offset calculations for tile rendering remains the same for RTL
documents irrespective of the system/global RTL setting.

Conflicts:
include/sfx2/lokcharthelper.hxx
sfx2/source/view/lokcharthelper.cxx

Change-Id: I3e181af4e7ab1257bcc88d44bbdb053a7d47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129704
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit 4fd2a14c6ee68f0574766ec7ec3dca35debe9d20)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129778
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/include/sfx2/lokcharthelper.hxx b/include/sfx2/lokcharthelper.hxx
index a05868866ef4..c93c4d2b8459 100644
--- a/include/sfx2/lokcharthelper.hxx
+++ b/include/sfx2/lokcharthelper.hxx
@@ -29,11 +29,13 @@ private:
 css::uno::Reference mxController;
 css::uno::Reference mxDispatcher;
 VclPtr mpWindow;
+bool mbNegativeX;
 
 public:
-LokChartHelper(SfxViewShell* pViewShell)
+LokChartHelper(SfxViewShell* pViewShell, bool bNegativeX = false)
 : mpViewShell(pViewShell)
 , mpWindow(nullptr)
+, mbNegativeX(bNegativeX)
 {}
 
 css::uno::Reference& GetXController();
@@ -43,7 +45,7 @@ public:
 void Invalidate();
 
 bool Hit(const Point& aPos);
-static bool HitAny(const Point& aPos);
+static bool HitAny(const Point& aPos, bool bNegativeX = false);
 void PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& 
rTileRect);
 static void PaintAllChartsOnTile(VirtualDevice& rDevice,
  int nOutputWidth, int nOutputHeight,
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 39019044a7f2..6a0c084388f5 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -725,11 +725,11 @@ void ScModelObj::postMouseEvent(int nType, int nX, int 
nY, int nCount, int nButt
 // check if user hit a chart which is being edited by him
 ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
 SCTAB nTab = pViewData->GetTabNo();
-LokChartHelper aChartHelper(pTabViewShell);
 const ScDocument& rDoc = pDocShell->GetDocument();
 // In LOK RTL mode draw/svx operates in negative X coordinates
 // But the coordinates from client is always positive, so negate nX for 
draw.
 bool bDrawNegativeX = rDoc.IsNegativePage(nTab);
+LokChartHelper aChartHelper(pTabViewShell, bDrawNegativeX);
 int nDrawX = bDrawNegativeX ? -nX : nX;
 if (aChartHelper.postMouseEvent(nType, nDrawX, nY,
 nCount, nButtons, nModifier,
@@ -745,7 +745,7 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, 
int nCount, int nButt
 // and, if so, skip current mouse event
 if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
 {
-if (LokChartHelper::HitAny(aPointTwipDraw))
+if (LokChartHelper::HitAny(aPointTwipDraw, bDrawNegativeX))
 return;
 }
 
diff --git a/sfx2/source/view/lokcharthelper.cxx 
b/sfx2/source/view/lokcharthelper.cxx
index 21ae981fa50b..ebd0ba14c0fc 100644
--- a/sfx2/source/view/lokcharthelper.cxx
+++ b/sfx2/source/view/lokcharthelper.cxx
@@ -141,7 +141,17 @@ tools::Rectangle LokChartHelper::GetChartBoundingBox()
 const auto nYNum = p.first * scaleY.GetDenominator();
 const auto nYDen = p.second * scaleY.GetNumerator();
 
-Point aOffset = 
pWindow->GetOffsetPixelFrom(*pRootWin).scale(nXNum, nXDen, nYNum, nYDen);
+Point aOffset = pWindow->GetOffsetPixelFrom(*pRootWin);
+if (mbNegativeX && AllSettings::GetLayoutRTL())
+{
+// If global RTL flag is set, vcl-window X offset of 
chart window is
+// mirrored w.r.t parent window rectangle. This needs 
to be reverted.
+aOffset.setX(pRootWin->GetOutOffXPixel() + 
pRootWin->GetSizePixel().Width()
+- pWindow->GetOutOffXPixel() - 
pWindow->GetSizePixel().Width());
+
+}
+
+aOffset = aOffset.scale(nXNum, nXDen, nYNum, nYDen);
 Size aSize = pWindow->GetSizePixel().scale(nXNum, nXDen, 
nYNum, nYDen);
 aBBox = tools::Rectangle(aOffset, aSize);

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

2022-02-10 Thread Dennis Francis (via logerrit)
 include/sfx2/lokcomponenthelpers.hxx |6 --
 sc/source/ui/unoobj/docuno.cxx   |4 ++--
 sfx2/source/view/lokcharthelper.cxx  |   18 ++
 3 files changed, 20 insertions(+), 8 deletions(-)

New commits:
commit 59460f4e02cc312062d76a8fc315800129bb9219
Author: Dennis Francis 
AuthorDate: Wed Feb 9 12:31:49 2022 +0530
Commit: Dennis Francis 
CommitDate: Fri Feb 11 05:39:00 2022 +0100

lokCalcRTL: global RTL: fix chart edit mode rendering

If global RTL flag is set, vcl-window X offset of chart window is
mirrored w.r.t parent window rectangle. This has to be undone to get the
correct chart bounding box in negative X document coordinates so that
the offset calculations for tile rendering remains the same for RTL
documents irrespective of the system/global RTL setting.

Conflicts:
include/sfx2/lokcharthelper.hxx
sfx2/source/view/lokcharthelper.cxx

Change-Id: I3e181af4e7ab1257bcc88d44bbdb053a7d47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129704
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit 4fd2a14c6ee68f0574766ec7ec3dca35debe9d20)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129778
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/include/sfx2/lokcomponenthelpers.hxx 
b/include/sfx2/lokcomponenthelpers.hxx
index c9468b7d1c3b..6a3d964689b4 100644
--- a/include/sfx2/lokcomponenthelpers.hxx
+++ b/include/sfx2/lokcomponenthelpers.hxx
@@ -29,11 +29,13 @@ private:
 css::uno::Reference mxController;
 css::uno::Reference mxDispatcher;
 VclPtr mpWindow;
+bool mbNegativeX;
 
 public:
-LokChartHelper(SfxViewShell* pViewShell)
+LokChartHelper(SfxViewShell* pViewShell, bool bNegativeX = false)
 : mpViewShell(pViewShell)
 , mpWindow(nullptr)
+, mbNegativeX(bNegativeX)
 {}
 
 css::uno::Reference& GetXController();
@@ -43,7 +45,7 @@ public:
 void Invalidate();
 
 bool Hit(const Point& aPos);
-static bool HitAny(const Point& aPos);
+static bool HitAny(const Point& aPos, bool bNegativeX = false);
 void PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& 
rTileRect);
 static void PaintAllChartsOnTile(VirtualDevice& rDevice,
  int nOutputWidth, int nOutputHeight,
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index ca7cb56fee5f..563d34b3c2c2 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -725,11 +725,11 @@ void ScModelObj::postMouseEvent(int nType, int nX, int 
nY, int nCount, int nButt
 // check if user hit a chart which is being edited by him
 ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
 SCTAB nTab = pViewData->GetTabNo();
-LokChartHelper aChartHelper(pTabViewShell);
 const ScDocument& rDoc = pDocShell->GetDocument();
 // In LOK RTL mode draw/svx operates in negative X coordinates
 // But the coordinates from client is always positive, so negate nX for 
draw.
 bool bDrawNegativeX = rDoc.IsNegativePage(nTab);
+LokChartHelper aChartHelper(pTabViewShell, bDrawNegativeX);
 int nDrawX = bDrawNegativeX ? -nX : nX;
 if (aChartHelper.postMouseEvent(nType, nDrawX, nY,
 nCount, nButtons, nModifier,
@@ -745,7 +745,7 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, 
int nCount, int nButt
 // and, if so, skip current mouse event
 if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
 {
-if (LokChartHelper::HitAny(aPointTwipDraw))
+if (LokChartHelper::HitAny(aPointTwipDraw, bDrawNegativeX))
 return;
 }
 
diff --git a/sfx2/source/view/lokcharthelper.cxx 
b/sfx2/source/view/lokcharthelper.cxx
index a87388832755..c7941e6aa2ac 100644
--- a/sfx2/source/view/lokcharthelper.cxx
+++ b/sfx2/source/view/lokcharthelper.cxx
@@ -127,7 +127,17 @@ tools::Rectangle LokChartHelper::GetChartBoundingBox()
 const auto nYNum = p.first * scaleY.GetDenominator();
 const auto nYDen = p.second * scaleY.GetNumerator();
 
-Point aOffset = 
pWindow->GetOffsetPixelFrom(*pRootWin).scale(nXNum, nXDen, nYNum, nYDen);
+Point aOffset = pWindow->GetOffsetPixelFrom(*pRootWin);
+if (mbNegativeX && AllSettings::GetLayoutRTL())
+{
+// If global RTL flag is set, vcl-window X offset of 
chart window is
+// mirrored w.r.t parent window rectangle. This needs 
to be reverted.
+aOffset.setX(pRootWin->GetOutOffXPixel() + 
pRootWin->GetSizePixel().Width()
+- pWindow->GetOutOffXPixel() - 
pWindow->GetSizePixel().Width());
+
+}
+
+   

[Libreoffice-commits] core.git: Changes to 'refs/tags/cp-21.06.16-1'

2022-02-10 Thread Dennis Francis (via logerrit)
Tag 'cp-21.06.16-1' created by Andras Timar  at 
2022-02-10 12:00 +

cp-21.06.16-1

Changes since co-21.06.14-1-18:
---
 0 files changed
---


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

2022-02-10 Thread Dennis Francis (via logerrit)
 include/sfx2/lokcharthelper.hxx |6 --
 sc/source/ui/unoobj/docuno.cxx  |4 ++--
 sfx2/source/view/lokcharthelper.cxx |   14 +++---
 3 files changed, 17 insertions(+), 7 deletions(-)

New commits:
commit 4fd2a14c6ee68f0574766ec7ec3dca35debe9d20
Author: Dennis Francis 
AuthorDate: Wed Feb 9 12:31:49 2022 +0530
Commit: Dennis Francis 
CommitDate: Thu Feb 10 11:29:17 2022 +0100

lokCalcRTL: global RTL: fix chart edit mode rendering

If global RTL flag is set, vcl-window X offset of chart window is
mirrored w.r.t parent window rectangle. This has to be undone to get the
correct chart bounding box in negative X document coordinates so that
the offset calculations for tile rendering remains the same for RTL
documents irrespective of the system/global RTL setting.

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

diff --git a/include/sfx2/lokcharthelper.hxx b/include/sfx2/lokcharthelper.hxx
index aa7cfb5867ac..e447562e3dfd 100644
--- a/include/sfx2/lokcharthelper.hxx
+++ b/include/sfx2/lokcharthelper.hxx
@@ -28,11 +28,13 @@ private:
 css::uno::Reference mxController;
 css::uno::Reference mxDispatcher;
 VclPtr mpWindow;
+bool mbNegativeX;
 
 public:
-LokChartHelper(SfxViewShell* pViewShell)
+LokChartHelper(SfxViewShell* pViewShell, bool bNegativeX = false)
 : mpViewShell(pViewShell)
 , mpWindow(nullptr)
+, mbNegativeX(bNegativeX)
 {}
 
 css::uno::Reference& GetXController();
@@ -42,7 +44,7 @@ public:
 void Invalidate();
 
 bool Hit(const Point& aPos);
-static bool HitAny(const Point& aPos);
+static bool HitAny(const Point& aPos, bool bNegativeX = false);
 void PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& 
rTileRect);
 static void PaintAllChartsOnTile(VirtualDevice& rDevice,
  int nOutputWidth, int nOutputHeight,
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 86bd13cb5a16..bfcde729dd0f 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -733,11 +733,11 @@ void ScModelObj::postMouseEvent(int nType, int nX, int 
nY, int nCount, int nButt
 // check if user hit a chart which is being edited by him
 ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
 SCTAB nTab = pViewData->GetTabNo();
-LokChartHelper aChartHelper(pTabViewShell);
 const ScDocument& rDoc = pDocShell->GetDocument();
 // In LOK RTL mode draw/svx operates in negative X coordinates
 // But the coordinates from client is always positive, so negate nX for 
draw.
 bool bDrawNegativeX = rDoc.IsNegativePage(nTab);
+LokChartHelper aChartHelper(pTabViewShell, bDrawNegativeX);
 int nDrawX = bDrawNegativeX ? -nX : nX;
 if (aChartHelper.postMouseEvent(nType, nDrawX, nY,
 nCount, nButtons, nModifier,
@@ -753,7 +753,7 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, 
int nCount, int nButt
 // and, if so, skip current mouse event
 if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
 {
-if (LokChartHelper::HitAny(aPointTwipDraw))
+if (LokChartHelper::HitAny(aPointTwipDraw, bDrawNegativeX))
 return;
 }
 
diff --git a/sfx2/source/view/lokcharthelper.cxx 
b/sfx2/source/view/lokcharthelper.cxx
index b0b71aaa0353..49bdf5860784 100644
--- a/sfx2/source/view/lokcharthelper.cxx
+++ b/sfx2/source/view/lokcharthelper.cxx
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -137,6 +138,13 @@ tools::Rectangle LokChartHelper::GetChartBoundingBox()
 double fXScale( aCWMapMode.GetScaleX() );
 double fYScale( aCWMapMode.GetScaleY() );
 Point aOffset = pWindow->GetOffsetPixelFrom(*pRootWin);
+if (mbNegativeX && AllSettings::GetLayoutRTL())
+{
+// If global RTL flag is set, vcl-window X offset of 
chart window is
+// mirrored w.r.t parent window rectangle. This needs 
to be reverted.
+aOffset.setX(pRootWin->GetOutOffXPixel() + 
pRootWin->GetSizePixel().Width()
+- pWindow->GetOutOffXPixel() - 
pWindow->GetSizePixel().Width());
+}
 aOffset.setX( aOffset.X() * (TWIPS_PER_PIXEL / fXScale) );
 aOffset.setY( aOffset.Y() * (TWIPS_PER_PIXEL / fYScale) );
 Size aSize = pWindow->GetSizePixel();
@@ -171,7 +179,7 @@ bool LokChartHelper::Hit(const Point& aPos)
 return false;
 }
 
-bool LokChartHelper::HitAny(const Point& aPos)
+bool LokChartHelper::HitAny(const Point&

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

2022-02-06 Thread Dennis Francis (via logerrit)
 svx/source/svdraw/sdrpagewindow.cxx |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 69ef42fedda05b2eca65883ebc8e2db4c5811001
Author: Dennis Francis 
AuthorDate: Mon Jan 17 11:36:24 2022 +0530
Commit: Dennis Francis 
CommitDate: Sun Feb 6 11:11:41 2022 +0100

svx-lok: incomplete invalidation when resizing/deleting...

shapes in writer. The problematic commit is

5e37acbaaa0b0891829907331ecacd2d3b67526d
lokCalcRTL: shapes: do not send negative(X) invalidations

The above change forced the lok mode to use the second branch hence avoid 
the
view-transformation based invalidation. This patch restores the old
branching condition, but do the negation of invalidation rectangle in
case of lok-calc-rtl mode(IsNegativeX).

Change-Id: I679473f0610d2edabeb6071edbb32a63a436d053
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128491
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 
(cherry picked from commit 242d2752aa6af2c52affc90e84b58c59c5fa779d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129440
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/svx/source/svdraw/sdrpagewindow.cxx 
b/svx/source/svdraw/sdrpagewindow.cxx
index 5facfc45d237..01be77135674 100644
--- a/svx/source/svdraw/sdrpagewindow.cxx
+++ b/svx/source/svdraw/sdrpagewindow.cxx
@@ -430,8 +430,7 @@ void SdrPageWindow::RedrawLayer(const SdrLayerID* pId,
 // Invalidate call, used from ObjectContact(OfPageView) in 
InvalidatePartOfView(...)
 void SdrPageWindow::InvalidatePageWindow(const basegfx::B2DRange& rRange)
 {
-bool bLOKActive = comphelper::LibreOfficeKit::isActive();
-if (!bLOKActive && GetPageView().IsVisible() && 
GetPaintWindow().OutputToWindow())
+if (GetPageView().IsVisible() && GetPaintWindow().OutputToWindow())
 {
 OutputDevice& rWindow(GetPaintWindow().GetOutputDevice());
 basegfx::B2DRange aDiscreteRange(rRange);
@@ -444,10 +443,14 @@ void SdrPageWindow::InvalidatePageWindow(const 
basegfx::B2DRange& rRange)
 aDiscreteRange.grow(1.0);
 }
 
+// If the shapes use negative X coordinates, make them positive before 
sending
+// the invalidation rectangle.
+bool bNegativeX = mpImpl->mrPageView.GetView().IsNegativeX();
+
 const tools::Rectangle aVCLDiscreteRectangle(
-static_cast(floor(aDiscreteRange.getMinX())),
+static_cast(bNegativeX ? std::max(0.0, 
ceil(-aDiscreteRange.getMaxX())) : floor(aDiscreteRange.getMinX())),
 static_cast(floor(aDiscreteRange.getMinY())),
-static_cast(ceil(aDiscreteRange.getMaxX())),
+static_cast(bNegativeX ? std::max(0.0, 
floor(-aDiscreteRange.getMinX())) : ceil(aDiscreteRange.getMaxX())),
 static_cast(ceil(aDiscreteRange.getMaxY(;
 
 const bool bWasMapModeEnabled(rWindow.IsMapModeEnabled());
@@ -455,7 +458,7 @@ void SdrPageWindow::InvalidatePageWindow(const 
basegfx::B2DRange& rRange)
 GetPageView().GetView().InvalidateOneWin(rWindow, 
aVCLDiscreteRectangle);
 rWindow.EnableMapMode(bWasMapModeEnabled);
 }
-else if (bLOKActive)
+else if (comphelper::LibreOfficeKit::isActive())
 {
 // we don't really have to have a paint window with LOK; OTOH we know
 // that the drawinglayer units are 100ths of mm, so they are easy to


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

2022-02-05 Thread Dennis Francis (via logerrit)
 sc/source/ui/view/tabview.cxx |   16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit 349593166af244566fe0a8d2c11f3bcd73048c1d
Author: Dennis Francis 
AuthorDate: Mon Jan 10 12:03:54 2022 +0530
Commit: Dennis Francis 
CommitDate: Sat Feb 5 09:59:49 2022 +0100

lokCalcRTL: fix chart insertion position

Change-Id: I573cb19643d7a048f3313aba90fa9b5514c9cc74
(cherry picked from commit f1ff0ec57914e8871f8563cd26ee1b87d562f1c8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129365
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 8d8412d3673e..8f0ce9d9bd06 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -1704,9 +1704,12 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, 
const ScRange& rCellRange
 ActivatePart( eUsedPart );
 
 //  get the visible rectangle in logic units
-
+bool bLOKActive = comphelper::LibreOfficeKit::isActive();
 MapMode aDrawMode = pWin->GetDrawMapMode();
-tools::Rectangle aVisible( pWin->PixelToLogic( tools::Rectangle( 
Point(0,0), pWin->GetOutputSizePixel() ), aDrawMode ) );
+tools::Rectangle aVisible(
+bLOKActive ?
+OutputDevice::LogicToLogic( aViewData.getLOKVisibleArea(), 
MapMode(MapUnit::MapTwip), MapMode(MapUnit::Map100thMM) )
+: pWin->PixelToLogic( tools::Rectangle( Point(0,0), 
pWin->GetOutputSizePixel() ), aDrawMode ) );
 
 ScDocument& rDoc = aViewData.GetDocument();
 SCTAB nTab = aViewData.GetTabNo();
@@ -1730,6 +1733,14 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, 
const ScRange& rCellRange
 tools::Rectangle aSelection = rDoc.GetMMRect( rCellRange.aStart.Col(), 
rCellRange.aStart.Row(),
 rCellRange.aEnd.Col(), 
rCellRange.aEnd.Row(), nTab );
 
+if (bLOKActive && bLayoutRTL)
+{
+// In this case we operate in negative X coordinates. The 
rectangle aSelection already
+// has negative X coordinates. So the x coordinates in the 
rectangle aVisible(from getLOKVisibleArea)
+// need be negated to match.
+aVisible = tools::Rectangle(-aVisible.Right(), aVisible.Top(), 
-aVisible.Left(), aVisible.Bottom());
+}
+
 tools::Long nLeftSpace = aSelection.Left() - aVisible.Left();
 tools::Long nRightSpace = aVisible.Right() - aSelection.Right();
 tools::Long nTopSpace = aSelection.Top() - aVisible.Top();
@@ -1756,7 +1767,6 @@ Point ScTabView::GetChartInsertPos( const Size& rSize, 
const ScRange& rCellRange
 else if ( nTopSpace >= nNeededHeight || nBottomSpace >= nNeededHeight )
 {
 // second preference: completely above or below the selection
-
 if ( nBottomSpace > nNeededHeight ) // bottom is 
preferred
 aInsertPos.setY( aSelection.Bottom() + 1 );
 else


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

2022-02-05 Thread Dennis Francis (via logerrit)
 sc/source/ui/view/gridwin4.cxx |9 +
 1 file changed, 9 insertions(+)

New commits:
commit 3cd2d9665fba5723ac84732fcf41dc675577f08c
Author: Dennis Francis 
AuthorDate: Thu Jan 6 15:12:16 2022 +0530
Commit: Dennis Francis 
CommitDate: Sat Feb 5 09:57:03 2022 +0100

lokCalcRTL: trim invalidation rect to ensure +ve X

Change-Id: Ifecb52167e3cddee036e1e1e9bd5782a1138b654
(cherry picked from commit c2cbe0dbe4c9e4ce8014e881ba3663add77f7aca)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129364
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index d83c2bcccde2..f71c73514a27 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1673,6 +1673,15 @@ void ScGridWindow::LogicInvalidate(const 
tools::Rectangle* pRectangle)
 pResultRectangle = 
 }
 
+// Trim invalidation rectangle overlapping negative X region in RTL mode.
+if (pResultRectangle && pResultRectangle->Left() < 0
+&& mrViewData.GetDocument().IsLayoutRTL(mrViewData.GetTabNo()))
+{
+pResultRectangle->SetLeft(0);
+if (pResultRectangle->Right() < 0)
+pResultRectangle->SetRight(0);
+}
+
 ScTabViewShell* pViewShell = mrViewData.GetViewShell();
 SfxLokHelper::notifyInvalidation(pViewShell, pResultRectangle);
 }


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

2022-02-04 Thread Dennis Francis (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 368ae1026db78478b54cb4dc4e06475ce29a3a55
Author: Dennis Francis 
AuthorDate: Thu Jan 6 14:52:56 2022 +0530
Commit: Dennis Francis 
CommitDate: Sat Feb 5 08:03:02 2022 +0100

lok: setClientZoom: check PPTX/Y approx equality too

This is needed because the initial PPTX/Y on document load does not
match the implied PPTX/Y corresponding to the client requested zoomX/Y.

For instance when document is loaded by LOK client and 100% zoom is
requested, the correct PPTX/Y should be (1/15 = 0.067) but the
initial PPTX/Y on the ScViewData is 0.0647702

Change-Id: I996e9f003abd269df0994f3d114e42f84bb2bb20
(cherry picked from commit 04bb404bffa9fe19568655e81bcd5db21f153cbc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129363
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 177a38ca07ad..2c739b909fb2 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -997,7 +997,11 @@ void ScModelObj::setClientZoom(int nTilePixelWidth_, int 
nTilePixelHeight_, int
 const Fraction newZoomX(o3tl::toTwips(nTilePixelWidth_, o3tl::Length::px), 
nTileTwipWidth_);
 const Fraction newZoomY(o3tl::toTwips(nTilePixelHeight_, 
o3tl::Length::px), nTileTwipHeight_);
 
-if (pViewData->GetZoomX() == newZoomX && pViewData->GetZoomY() == newZoomY)
+double fDeltaPPTX = std::abs(ScGlobal::nScreenPPTX * 
static_cast(newZoomX) - pViewData->GetPPTX());
+double fDeltaPPTY = std::abs(ScGlobal::nScreenPPTY * 
static_cast(newZoomY) - pViewData->GetPPTY());
+constexpr double fEps = 1E-08;
+
+if (pViewData->GetZoomX() == newZoomX && pViewData->GetZoomY() == newZoomY 
&& fDeltaPPTX < fEps && fDeltaPPTY < fEps)
 return;
 
 pViewData->SetZoom(newZoomX, newZoomY, true);


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

2022-02-04 Thread Dennis Francis (via logerrit)
 include/sfx2/ipclient.hxx|4 
 include/sfx2/lokcomponenthelpers.hxx |3 ++-
 sc/source/ui/unoobj/docuno.cxx   |3 ---
 sc/source/ui/view/gridwin4.cxx   |7 +++
 sc/source/ui/view/tabvwshb.cxx   |   14 ++
 sfx2/source/view/ipclient.cxx|   26 --
 sfx2/source/view/lokcharthelper.cxx  |6 --
 7 files changed, 55 insertions(+), 8 deletions(-)

New commits:
commit e3e8aaa2517dfbaf9ab5dcf10612547c6c6b0eb4
Author: Dennis Francis 
AuthorDate: Thu Jan 6 10:54:49 2022 +0530
Commit: Dennis Francis 
CommitDate: Sat Feb 5 08:01:23 2022 +0100

lokCalcRTL: fix rendering of charts in edit mode

Inform Sfx2InPlaceClient and LokChartHelper when negated X coordinates
are used. Ensure that invalidation rectangles have positive coordinates
in all cases.

Conflicts:
include/sfx2/lokcharthelper.hxx
sfx2/source/view/ipclient.cxx

Change-Id: I8f5440718e288d8f0d379c8da5f49a29e51f6940
(cherry picked from commit 284068c7eb473bafd5cafeb30a78daab4538cff6)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129362
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/include/sfx2/ipclient.hxx b/include/sfx2/ipclient.hxx
index 3e219514a6f1..6eddf9e9f818 100644
--- a/include/sfx2/ipclient.hxx
+++ b/include/sfx2/ipclient.hxx
@@ -87,6 +87,10 @@ public:
 voidResetObject();
 boolIsUIActive() const;
 
+/// To indicate that negated document X coordinates are used
+voidSetNegativeX(bool bSet);
+boolIsNegativeX() const;
+
 virtual voidFormatChanged(); // object format was changed (used 
for StarMath formulas aligning)
 
 virtual bool IsProtected() const;
diff --git a/include/sfx2/lokcomponenthelpers.hxx 
b/include/sfx2/lokcomponenthelpers.hxx
index cace035b16a1..c9468b7d1c3b 100644
--- a/include/sfx2/lokcomponenthelpers.hxx
+++ b/include/sfx2/lokcomponenthelpers.hxx
@@ -48,7 +48,8 @@ public:
 static void PaintAllChartsOnTile(VirtualDevice& rDevice,
  int nOutputWidth, int nOutputHeight,
  int nTilePosX, int nTilePosY,
- tools::Long nTileWidth, tools::Long 
nTileHeight);
+ tools::Long nTileWidth, tools::Long 
nTileHeight,
+ bool bNegativeX = false);
 bool postMouseEvent(int nType, int nX, int nY,
 int nCount, int nButtons, int nModifier,
 double fScaleX = 1.0, double fScaleY = 1.0);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 7e149c8b7123..177a38ca07ad 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -560,9 +560,6 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight,
 nTilePosX, nTilePosY, nTileWidth, nTileHeight );
 
-LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
- nTilePosX, nTilePosY, nTileWidth, 
nTileHeight);
-
 // Draw Form controls
 ScDrawLayer* pDrawLayer = pDocShell->GetDocument().GetDrawLayer();
 SdrPage* pPage = pDrawLayer->GetPage(sal_uInt16(pViewData->GetTabNo()));
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index ec77fd12be66..d83c2bcccde2 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1625,6 +1626,12 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 DrawContent(rDevice, aTabInfo, aOutputData, true);
 rDevice.SetMapMode(aOriginalMode);
 
+// Paint the chart(s) in edit mode.
+LokChartHelper::PaintAllChartsOnTile(rDevice, nOutputWidth, nOutputHeight,
+nTilePosX, nTilePosY, nTileWidth, nTileHeight, bLayoutRTL);
+
+rDevice.SetMapMode(aOriginalMode);
+
 // Flag drawn formula cells "unchanged".
 rDoc.ResetChanged(ScRange(nTopLeftTileCol, nTopLeftTileRow, nTab, 
nBottomRightTileCol, nBottomRightTileRow, nTab));
 rDoc.PrepareFormulaCalc();
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 6ed88f12e3a6..f2ae3b56a55e 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -80,6 +80,13 @@ void ScTabViewShell::ConnectObject( const SdrOle2Obj* pObj )
 return;
 
 pClient = new ScClient( this, pWin, GetScDrawView()->GetModel(), pObj );
+ScViewData& rViewData = GetViewData();
+ScDocShell* pDocSh = rViewData.GetDocShell();
+ScDocument& rDoc = pDocSh->GetDocument();
+bool bNegativeX = comphelper::LibreOfficeKit::isActive() && 
rDoc.I

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

2022-02-04 Thread Dennis Francis (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |   16 
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 8bd08a18bf58bafc0a68e86d1091295528e257b4
Author: Dennis Francis 
AuthorDate: Tue Jan 4 14:20:41 2022 +0530
Commit: Dennis Francis 
CommitDate: Fri Feb 4 19:22:47 2022 +0100

lokCalcRTL: negate mouse event X for chart and controls

Conflicts:
sc/source/ui/unoobj/docuno.cxx

Change-Id: I389047140d1a3d2c67a861a3e20f799206d937b6
(cherry picked from commit 0f2208a43861ebe94c4a2482a0cf7e5c63bb186e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129361
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 2525b360d1a3..7e149c8b7123 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -727,8 +727,14 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, 
int nCount, int nButt
 
 // check if user hit a chart which is being edited by him
 ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
+SCTAB nTab = pViewData->GetTabNo();
 LokChartHelper aChartHelper(pTabViewShell);
-if (aChartHelper.postMouseEvent(nType, nX, nY,
+const ScDocument& rDoc = pDocShell->GetDocument();
+// In LOK RTL mode draw/svx operates in negative X coordinates
+// But the coordinates from client is always positive, so negate nX for 
draw.
+bool bDrawNegativeX = rDoc.IsNegativePage(nTab);
+int nDrawX = bDrawNegativeX ? -nX : nX;
+if (aChartHelper.postMouseEvent(nType, nDrawX, nY,
 nCount, nButtons, nModifier,
 pViewData->GetPPTX(), 
pViewData->GetPPTY()))
 {
@@ -736,21 +742,23 @@ void ScModelObj::postMouseEvent(int nType, int nX, int 
nY, int nCount, int nButt
 }
 
 Point aPointTwip(nX, nY);
+Point aPointTwipDraw(nDrawX, nY);
 
 // check if the user hit a chart which is being edited by someone else
 // and, if so, skip current mouse event
 if (nType != LOK_MOUSEEVENT_MOUSEMOVE)
 {
-if (LokChartHelper::HitAny(aPointTwip))
+if (LokChartHelper::HitAny(aPointTwipDraw))
 return;
 }
 
 // Check if a control is hit
 Point aPointHMM = o3tl::convert(aPointTwip, o3tl::Length::twip, 
o3tl::Length::mm100);
+Point aPointHMMDraw(bDrawNegativeX ? -aPointHMM.X() : aPointHMM.X(), 
aPointHMM.Y());
 ScDrawLayer* pDrawLayer = pDocShell->GetDocument().GetDrawLayer();
-SdrPage* pPage = pDrawLayer->GetPage(sal_uInt16(pViewData->GetTabNo()));
+SdrPage* pPage = pDrawLayer->GetPage(sal_uInt16(nTab));
 SdrView* pDrawView = pViewData->GetViewShell()->GetScDrawView();
-if (LokControlHandler::postMouseEvent(pPage, pDrawView, *pGridWindow, 
nType, aPointHMM, nCount, nButtons, nModifier))
+if (LokControlHandler::postMouseEvent(pPage, pDrawView, *pGridWindow, 
nType, aPointHMMDraw, nCount, nButtons, nModifier))
 return;
 
 // Calc operates in pixels...


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

2022-02-04 Thread Dennis Francis (via logerrit)
 editeng/source/editeng/editview.cxx |   27 ---
 editeng/source/editeng/impedit.cxx  |   16 +---
 editeng/source/editeng/impedit.hxx  |4 
 include/editeng/editview.hxx|4 
 sc/source/ui/view/gridwin4.cxx  |9 +++--
 svx/source/svdraw/svdedxv.cxx   |3 +++
 6 files changed, 55 insertions(+), 8 deletions(-)

New commits:
commit 226847e385d021bf2feacdfa796b3eb7023d6f0f
Author: Dennis Francis 
AuthorDate: Tue Jan 4 12:55:45 2022 +0530
Commit: Dennis Francis 
CommitDate: Fri Feb 4 19:21:53 2022 +0100

lokCalcRTL: fix editing of shape text

Inform editeng that negated document x coordinates are used in this case
and ensure that editeng generated invalidation rectangles always have
positive X coordinates.

Conflicts:
sc/source/ui/view/gridwin4.cxx

Change-Id: I2e450707ce02f7bcd8e4d299f857c37ebbd5e2c6
(cherry picked from commit 0fe02bb99e5dfa8379a49de75683fc350e4c4dbd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129360
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/editeng/source/editeng/editview.cxx 
b/editeng/source/editeng/editview.cxx
index 0c2f8f43b2a9..c8d12f0388d3 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -195,20 +195,30 @@ tools::Rectangle EditView::GetInvalidateRect() const
 }
 }
 
+namespace {
+
+tools::Rectangle lcl_negateRectX(const tools::Rectangle& rRect)
+{
+return tools::Rectangle(-rRect.Right(), rRect.Top(), -rRect.Left(), 
rRect.Bottom());
+}
+
+}
+
 void EditView::InvalidateWindow(const tools::Rectangle& rClipRect)
 {
+bool bNegativeX = IsNegativeX();
 if (EditViewCallbacks* pEditViewCallbacks = 
pImpEditView->getEditViewCallbacks())
 {
 // do not invalidate and trigger a global repaint, but forward
 // the need for change to the applied EditViewCallback, can e.g.
 // be used to visualize the active edit text in an OverlayObject
-pEditViewCallbacks->EditViewInvalidate(rClipRect);
+pEditViewCallbacks->EditViewInvalidate(bNegativeX ? 
lcl_negateRectX(rClipRect) : rClipRect);
 }
 else
 {
 // classic mode: invalidate and trigger full repaint
 // of the changed area
-GetWindow()->Invalidate(rClipRect);
+GetWindow()->Invalidate(bNegativeX ? lcl_negateRectX(rClipRect) : 
rClipRect);
 }
 }
 
@@ -216,10 +226,11 @@ void EditView::InvalidateOtherViewWindows( const 
tools::Rectangle& rInvRect )
 {
 if (comphelper::LibreOfficeKit::isActive())
 {
+bool bNegativeX = IsNegativeX();
 for (auto& pWin : pImpEditView->aOutWindowSet)
 {
 if (pWin)
-pWin->Invalidate( rInvRect );
+pWin->Invalidate( bNegativeX ? lcl_negateRectX(rInvRect) : 
rInvRect );
 }
 }
 }
@@ -1678,4 +1689,14 @@ bool EditView::IsSuppressLOKMessages() const
 return pImpEditView->IsSuppressLOKMessages();
 }
 
+void EditView::SetNegativeX(bool bSet)
+{
+pImpEditView->SetNegativeX(bSet);
+}
+
+bool EditView::IsNegativeX() const
+{
+return pImpEditView->IsNegativeX();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/impedit.cxx 
b/editeng/source/editeng/impedit.cxx
index 1175c28661cd..cfd6eb5758dc 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -198,7 +198,8 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* 
pEng, vcl::Window* pWindo
 eAnchorMode(EEAnchorMode::TopLeft),
 mpEditViewCallbacks(nullptr),
 mbBroadcastLOKViewCursor(comphelper::LibreOfficeKit::isActive()),
-mbSuppressLOKMessages(false)
+mbSuppressLOKMessages(false),
+mbNegativeX(false)
 {
 aEditSelection.Min() = pEng->GetEditDoc().GetStartPaM();
 aEditSelection.Max() = pEng->GetEditDoc().GetEndPaM();
@@ -875,6 +876,15 @@ void ImpEditView::SetOutputArea( const tools::Rectangle& 
rRect )
 SetScrollDiffX( static_cast(aOutArea.GetWidth()) * 2 / 10 );
 }
 
+namespace {
+
+tools::Rectangle lcl_negateRectX(const tools::Rectangle& rRect)
+{
+return tools::Rectangle(-rRect.Right(), rRect.Top(), -rRect.Left(), 
rRect.Bottom());
+}
+
+}
+
 void ImpEditView::InvalidateAtWindow(const tools::Rectangle& rRect)
 {
 if (EditViewCallbacks* pCallbacks = getEditViewCallbacks())
@@ -882,13 +892,13 @@ void ImpEditView::InvalidateAtWindow(const 
tools::Rectangle& rRect)
 // do not invalidate and trigger a global repaint, but forward
 // the need for change to the applied EditViewCallback, can e.g.
 // be used to visualize the active edit text in an OverlayObject
-pCallbacks->EditViewInvalidate(rRect);
+pCallbacks->EditViewInvalidate(mbNegativeX ? lcl_negateRectX(rRect) : 
rRect);
 }
 else
 {
 // clas

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

2022-02-03 Thread Dennis Francis (via logerrit)
 svx/source/svdraw/svdview.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit 0a95b424c8fd4eb58b439828120ba631048be32f
Author: Dennis Francis 
AuthorDate: Mon Dec 6 13:55:43 2021 +0530
Commit: Dennis Francis 
CommitDate: Fri Feb 4 07:33:46 2022 +0100

lokCalcRTL: shapes: negate mouse-event x coordinate

Conflicts:
svx/source/svdraw/svdview.cxx

Change-Id: I153334940b41859e6fd9dee64217925627f0f292
(cherry picked from commit bb37b46182bcff2f10edcc590cedbc4bb5820c4b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129359
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx
index 52391d0a0b57..d66094def531 100644
--- a/svx/source/svdraw/svdview.cxx
+++ b/svx/source/svdraw/svdview.cxx
@@ -265,6 +265,14 @@ SdrHitKind SdrView::PickAnything(const MouseEvent& rMEvt, 
SdrMouseEventKind nEve
 }
 Point aPnt(rMEvt.GetPosPixel());
 if (pOut!=nullptr) aPnt=pOut->PixelToLogic(aPnt);
+
+if (mbNegativeX)
+{
+// Shape's x coordinates are all negated,
+// Hence negate mouse event's x coord to match.
+aPnt.setX(-aPnt.X());
+}
+
 rVEvt.maLogicPos = aPnt;
 return PickAnything(aPnt,rVEvt);
 }


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

2022-02-02 Thread Dennis Francis (via logerrit)
 sc/source/ui/drawfunc/drawsh.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 26a22407124314479c99b44559ffbbce8c261fa5
Author: Dennis Francis 
AuthorDate: Tue Nov 30 16:06:51 2021 +0530
Commit: Dennis Francis 
CommitDate: Wed Feb 2 13:48:22 2022 +0100

lokCalcRTL: negate the +ve shape handle X coordinate...

...from lok client as all shape X coordinates are negative in lok-RTL
mode.

Conflicts:
sc/source/ui/drawfunc/drawsh.cxx

Change-Id: Ic4ba064888901109c85760bb0afda609b5d5942c
(cherry picked from commit 3df583520ee03bad42df09db7dde4c0c683a228b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129193
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index f35f20caf84a..348fb56d53d6 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace css;
@@ -219,7 +220,9 @@ void ScDrawShell::ExecDrawAttr( SfxRequest& rReq )
 const sal_uLong handleNum = handleNumItem->GetValue();
 const sal_uLong newPosX = 
convertTwipToMm100(newPosXTwips->GetValue());
 const sal_uLong newPosY = 
convertTwipToMm100(newPosYTwips->GetValue());
-pView->MoveShapeHandle(handleNum, Point(newPosX, newPosY), 
OrdNum ? OrdNum->GetValue() : -1);
+
+bool bNegateX = comphelper::LibreOfficeKit::isActive() && 
rViewData.GetDocument().IsLayoutRTL(rViewData.GetTabNo());
+pView->MoveShapeHandle(handleNum, Point(bNegateX ? 
-static_cast(newPosX) : newPosX, newPosY), OrdNum ? 
OrdNum->GetValue() : -1);
 }
 }
 break;


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

2022-02-02 Thread Dennis Francis (via logerrit)
 sc/source/ui/view/tabvwsh2.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 8839705b6f719f8f3bd5275eac57b78e26e4050b
Author: Dennis Francis 
AuthorDate: Tue Nov 30 13:42:33 2021 +0530
Commit: Dennis Francis 
CommitDate: Wed Feb 2 10:15:30 2022 +0100

lokCalcRTL: RTL negation for shape insertion

Conflicts:
sc/source/ui/view/tabvwsh2.cxx

Change-Id: I8e3bb21fadd05a7b67acce34bfdc354fefba076b
(cherry picked from commit 18038bd35c01abf1aad69932c4a7e75988921289)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129192
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
index 0c3b35f56442..f61b8652064b 100644
--- a/sc/source/ui/view/tabvwsh2.cxx
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -337,12 +337,13 @@ void ScTabViewShell::ExecDraw(SfxRequest& rReq)
 {
 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, 
SfxCallMode::ASYNCHRON);
 ScViewData& rViewData = GetViewData();
+tools::Long nLayoutSign = 
rViewData.GetDocument().IsLayoutRTL(rViewData.GetTabNo()) ? -1 : 1;
 aInsertPos = rViewData.getLOKVisibleArea().Center();
 if (comphelper::LibreOfficeKit::isCompatFlagSet(
 comphelper::LibreOfficeKit::Compat::scPrintTwipsMsgs))
 aInsertPos = rViewData.GetPrintTwipsPosFromTileTwips(aInsertPos);
 
-aInsertPos.setX(convertTwipToMm100(aInsertPos.X()));
+aInsertPos.setX(nLayoutSign * convertTwipToMm100(aInsertPos.X()));
 aInsertPos.setY(convertTwipToMm100(aInsertPos.Y()));
 
 aInsertPos.AdjustX( -sal_Int32(nDefaultObjectSizeWidth / 2) );


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

2022-02-02 Thread Dennis Francis (via logerrit)
 sc/source/ui/drawfunc/fusel.cxx |   12 
 1 file changed, 12 insertions(+)

New commits:
commit cc827250ed249202afd97a84db13575648ed9b49
Author: Dennis Francis 
AuthorDate: Thu Nov 25 17:38:14 2021 +0530
Commit: Dennis Francis 
CommitDate: Wed Feb 2 10:13:00 2022 +0100

lokCalcRTL: shape selection: negate mouse X...

as in LOK RTL mode draw objects have negated document X coordinate.

Change-Id: Ie4c00fc0d1aa458a0aa6dd502be227cd6f82be3e
(cherry picked from commit d423a86b3e063da02cfdb302eaa996ca54eed9d0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129191
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx
index 18ba12b792b9..46b7fc47d040 100644
--- a/sc/source/ui/drawfunc/fusel.cxx
+++ b/sc/source/ui/drawfunc/fusel.cxx
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -85,6 +86,14 @@ bool FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
 else
 aMDPos = pWindow->PixelToLogic(rMEvt.GetPosPixel());
 
+if (comphelper::LibreOfficeKit::isActive())
+{
+ScViewData& rViewData = rViewShell.GetViewData();
+ScDocument& rDocument = rViewData.GetDocument();
+if (rDocument.IsNegativePage(rViewData.GetTabNo()))
+aMDPos.setX(-aMDPos.X());
+}
+
 if ( rMEvt.IsLeft() )
 {
 SdrHdl* pHdl = pView->PickHandle(aMDPos);
@@ -351,6 +360,9 @@ bool FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
 ::std::vector< OUString > aExcludedChartNames;
 ScRangeListVector aProtectedChartRangesVector;
 
+if (comphelper::LibreOfficeKit::isActive() && 
rDocument.IsNegativePage(rViewData.GetTabNo()))
+aPnt.setX(-aPnt.X());
+
 if (pView && rMEvt.IsLeft())
 {
 if ( pView->IsDragObj() )


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

2022-02-02 Thread Dennis Francis (via logerrit)
 svx/source/svdraw/svdmrkv.cxx |   27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

New commits:
commit a1e4dad6b98a2a5d4b4ef5db479d6f520331f1d1
Author: Dennis Francis 
AuthorDate: Mon Dec 13 11:36:53 2021 +0530
Commit: Dennis Francis 
CommitDate: Wed Feb 2 10:12:17 2022 +0100

lokCalcRTL: ensure +ve X coords in shape handles/selections msgs

LOK client expects all coordinates to be in +ve document coordinates, so
negate the negative X coordinates of LOK RTL shapes before sending the
selection/handles messages.

Conflicts:
svx/source/svdraw/svdmrkv.cxx

Change-Id: I683581370c5b115efbe315224d6218ec2e74c7f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129190
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 4406b5f535ff..73e530b2cd5e 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -703,6 +703,7 @@ OUString lcl_getDragParameterString( const OUString& rCID )
 bool SdrMarkView::dumpGluePointsToJSON(boost::property_tree::ptree& rTree)
 {
 bool result = false;
+tools::Long nSignX = mbNegativeX ? -1 : 1;
 if (OutputDevice* pOutDev = mpMarkedPV ? 
mpMarkedPV->GetView().GetFirstOutputDevice() : nullptr)
 {
 bool bConvertUnit = false;
@@ -735,7 +736,7 @@ bool 
SdrMarkView::dumpGluePointsToJSON(boost::property_tree::ptree& rTree)
 {
 rPoint = o3tl::convert(rPoint, o3tl::Length::mm100, 
o3tl::Length::twip);
 }
-point.put("x", rPoint.getX());
+point.put("x", nSignX * rPoint.getX());
 point.put("y", rPoint.getY());
 node.add_child("point", point);
 points.push_back(std::make_pair("", node));
@@ -750,7 +751,7 @@ bool 
SdrMarkView::dumpGluePointsToJSON(boost::property_tree::ptree& rTree)
 p = o3tl::convert(p, o3tl::Length::mm100, 
o3tl::Length::twip);
 }
 boost::property_tree::ptree gridOffset;
-gridOffset.put("x", p.getX());
+gridOffset.put("x", nSignX * p.getX());
 gridOffset.put("y", p.getY());
 object.add_child("gridoffset", gridOffset);
 }
@@ -769,6 +770,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 SfxViewShell* pViewShell = GetSfxViewShell();
 
 tools::Rectangle aSelection(rRect);
+tools::Long nSignX = mbNegativeX ? -1 : 1;
 bool bIsChart = false;
 Point addLogicOffset(0, 0);
 bool convertMapMode = false;
@@ -862,7 +864,7 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 if (convertMapMode)
 p = o3tl::convert(p, o3tl::Length::mm100, 
o3tl::Length::twip);
 aExtraInfo.append(",\"gridOffsetX\":");
-aExtraInfo.append(p.getX());
+aExtraInfo.append(nSignX * p.getX());
 aExtraInfo.append(",\"gridOffsetY\":");
 aExtraInfo.append(p.getY());
 }
@@ -966,6 +968,8 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
 const basegfx::B2DPoint 
aB2Point = aPolygon.getB2DPoint(nIndex);
 Point 
aPoint(aB2Point.getX(), aB2Point.getY());
 
aPoint.Move(aLogicOffset.getX(), aLogicOffset.getY());
+if (mbNegativeX)
+
aPoint.setX(-aPoint.X());
 if (nIndex > 0)
 sPolygonElem += " ";
 sPolygonElem += 
aPoint.toString();
@@ -1078,8 +1082,21 @@ void 
SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, const S
 handleArrayStr = handleArrayStr + aStream.str().c_str();
 }
 }
-sSelectionText = aSelection.toString() +
-", " + OString::number(nRotAngle.get());
+
+if (mbNegativeX)
+{
+tools::Rectangle aNegatedRect(aSelection);
+aNegatedRect.SetLeft(-aNegatedRect.Left());
+aNegatedRect.SetRight(-aNegatedRect.Right());
+aNegatedRect.Justify();
+sSelectionText = aNegatedRect.toString() +
+", " + OString::number(nRotAngle.get());
+}
+ 

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

2022-02-02 Thread Dennis Francis (via logerrit)
 include/svx/svdmrkv.hxx |6 ++
 sc/source/ui/unoobj/docuno.cxx  |6 ++
 sc/source/ui/view/drawvie3.cxx  |2 ++
 sc/source/ui/view/gridwin4.cxx  |2 ++
 svx/source/svdraw/sdrpagewindow.cxx |   13 +
 svx/source/svdraw/svdmrkv.cxx   |9 +
 6 files changed, 34 insertions(+), 4 deletions(-)

New commits:
commit 2c250e8f5007e756afb794944f0be791e2d535f4
Author: Dennis Francis 
AuthorDate: Mon Dec 6 13:42:27 2021 +0530
Commit: Dennis Francis 
CommitDate: Wed Feb 2 10:10:07 2022 +0100

lokCalcRTL: shapes: do not send negative(X) invalidations

LOK client expects tile invalidations in positive document coordinates
irrespective of RTL flags.

For this introduce a flag mbNegativeX in svx class SdrMarkView to
indicate the case when all x coordinates are negated (this happens only
for the LOK + Calc + RTL mode). Use this flag to counter negate the
x coordinates before sending invalidation rectangles.

Conflicts:
sc/source/ui/view/drawvie3.cxx

Change-Id: I35d8142718b538e55b668a8ee18f3dd1fe433951
(cherry picked from commit 5e37acbaaa0b0891829907331ecacd2d3b67526d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129195
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index d4ece164bece..ec9055711c3f 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -130,6 +130,9 @@ protected:
 // flag to completely disable handles at the view
 boolmbMarkHandlesHidden : 1;
 
+// flag indicating whether all x coordinates are negated or not
+boolmbNegativeX : 1;
+
 // Helper to get a possible GridOffset from SdrObject
 bool getPossibleGridOffsetForSdrObject(
 basegfx::B2DVector& rOffset,
@@ -240,6 +243,9 @@ public:
 
 bool HasMarkableObj() const { return MarkableObjectsExceed(0); };
 
+/// whether all x coordinates in use are negated or not
+void SetNegativeX(bool bOn) { mbNegativeX = bOn; }
+bool IsNegativeX() const { return mbNegativeX; }
 
 // migrate selections
 
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 80ac5e29db7e..2525b360d1a3 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -578,7 +578,13 @@ void ScModelObj::setPart( int nPart, bool 
/*bAllowChangeFocus*/ )
 ScTabView* pTabView = pViewData->GetView();
 
 if (pTabView)
+{
+if (SdrView* pDrawView = pViewData->GetViewShell()->GetScDrawView())
+pDrawView->SetNegativeX(comphelper::LibreOfficeKit::isActive() &&
+pViewData->GetDocument().IsLayoutRTL(nPart));
+
 pTabView->SelectTabPage(nPart + 1);
+}
 }
 
 int ScModelObj::getParts()
diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx
index 88c74b442bfe..ce4d132b87e4 100644
--- a/sc/source/ui/view/drawvie3.cxx
+++ b/sc/source/ui/view/drawvie3.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -49,6 +50,7 @@ ScDrawView::ScDrawView(
 pDropMarkObj( nullptr ),
 bInConstruct( true )
 {
+SetNegativeX(comphelper::LibreOfficeKit::isActive() && 
rDoc.IsLayoutRTL(nTab));
 // #i73602# Use default from the configuration
 SetBufferedOverlayAllowed(SvtOptionsDrawinglayer::IsOverlayBuffer_Calc());
 
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 5a21738bb9c3..42ce441e53d1 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1609,6 +1609,8 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 new FmFormView(
 *pModel,
 ));
+
+mpLOKDrawView->SetNegativeX(bLayoutRTL);
 mpLOKDrawView->ShowSdrPage(mpLOKDrawView->GetModel()->GetPage(nTab));
 aOutputData.SetDrawView(mpLOKDrawView.get());
 aOutputData.SetSpellCheckContext(mpSpellCheckCxt.get());
diff --git a/svx/source/svdraw/sdrpagewindow.cxx 
b/svx/source/svdraw/sdrpagewindow.cxx
index aeb337d7a8e5..5facfc45d237 100644
--- a/svx/source/svdraw/sdrpagewindow.cxx
+++ b/svx/source/svdraw/sdrpagewindow.cxx
@@ -430,7 +430,8 @@ void SdrPageWindow::RedrawLayer(const SdrLayerID* pId,
 // Invalidate call, used from ObjectContact(OfPageView) in 
InvalidatePartOfView(...)
 void SdrPageWindow::InvalidatePageWindow(const basegfx::B2DRange& rRange)
 {
-if (GetPageView().IsVisible() && GetPaintWindow().OutputToWindow())
+bool bLOKActive = comphelper::LibreOfficeKit::isActive();
+if (!bLOKActive && GetPageView().IsVisible() && 
GetPaintWindow().OutputToWindow())
 {
 OutputDevice& rWindow(GetPaintWindow().GetOutputDevice());
 basegfx::B2DRange aDiscreteRange(rRange);
@@ -454,15 +455,19 @@ void SdrPageWindow:

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

2022-01-31 Thread Dennis Francis (via logerrit)
 sc/source/ui/view/drawview.cxx |   16 +++-
 sc/source/ui/view/gridwin4.cxx |   23 ++-
 2 files changed, 25 insertions(+), 14 deletions(-)

New commits:
commit 3b7aae08f26a2e6dc1112985024aa946550124aa
Author: Dennis Francis 
AuthorDate: Thu Nov 25 16:02:35 2021 +0530
Commit: Dennis Francis 
CommitDate: Tue Feb 1 06:13:30 2022 +0100

lokCalcRTL: adjustments for shapes rendering

In LOK-RTL mode GetScrPos() always returns document pixel coordinates
and not something mirrored w.r.t gridwindow width.

* Grid offset must have the opposite sign since the SdrObjects/ranges
  have negative coordinates with no offset.

* Drawing area rectangle and the pixel-offset for tile rendering device
  also needs adjustments when painting the drawing layers.

Conflicts:
sc/source/ui/view/gridwin4.cxx

Change-Id: I987a6876983aee129c06b3577918dbc62d6e7c4c
(cherry picked from commit 2e7d02ab55754ffbc9e799c98cb7c8e37394a420)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129189
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 71dd9809b0d0..2774e962aa67 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -969,7 +969,7 @@ void ScDrawView::SyncForGrid( SdrObject* pObj )
 Point aCurPosHmm = pGridWin->PixelToLogic(aCurPos, aDrawMode );
 Point aGridOff = aCurPosHmm - aOldPos;
 // fdo#63878 Fix the X position for RTL Sheet
-if( rDoc.IsNegativePage( GetTab() ) )
+if( rDoc.IsNegativePage( GetTab() ) && 
!comphelper::LibreOfficeKit::isActive() )
 aGridOff.setX( aCurPosHmm.getX() + aOldPos.getX() );
 }
 
@@ -1048,13 +1048,16 @@ bool ScDrawView::calculateGridOffsetForSdrObject(
 Point aCurPosHmm(pGridWin->PixelToLogic(aCurPos, aDrawMode));
 Point aGridOff(aCurPosHmm - aOldPos);
 
+bool bLOKActive = comphelper::LibreOfficeKit::isActive();
+bool bNegativePage = rDoc.IsNegativePage(GetTab());
+
 // fdo#63878 Fix the X position for RTL Sheet
-if(rDoc.IsNegativePage(GetTab()))
+if(bNegativePage && !bLOKActive)
 {
 aGridOff.setX(aCurPosHmm.getX() + aOldPos.getX());
 }
 
-rTarget.setX(aGridOff.X());
+rTarget.setX(bNegativePage && bLOKActive ? -aGridOff.X() : aGridOff.X());
 rTarget.setY(aGridOff.Y());
 return true;
 }
@@ -1096,13 +1099,16 @@ bool ScDrawView::calculateGridOffsetForB2DRange(
 Point aCurPosHmm(pGridWin->PixelToLogic(aCurPos, aDrawMode));
 Point aGridOff(aCurPosHmm - aOldPos);
 
+bool bLOKActive = comphelper::LibreOfficeKit::isActive();
+bool bNegativePage = rDoc.IsNegativePage(GetTab());
+
 // fdo#63878 Fix the X position for RTL Sheet
-if(rDoc.IsNegativePage(GetTab()))
+if(bNegativePage && !bLOKActive)
 {
 aGridOff.setX(aCurPosHmm.getX() + aOldPos.getX());
 }
 
-rTarget.setX(aGridOff.X());
+rTarget.setX(bLOKActive && bNegativePage ? -aGridOff.X() : aGridOff.X());
 rTarget.setY(aGridOff.Y());
 return true;
 }
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index c48b206ef891..5a21738bb9c3 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -736,17 +736,20 @@ void ScGridWindow::DrawContent(OutputDevice , 
const ScTableInfo& rTableI
 }
 tools::Rectangle aDrawingRectLogic;
 bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
+bool bLokRTL = bLayoutRTL && bIsTiledRendering;
 std::unique_ptr pLokRTLCtxt(
-bIsTiledRendering && bLayoutRTL ?
+bLokRTL ?
 new ScLokRTLContext(aOutputData, 
o3tl::convert(aOriginalMode.GetOrigin().X(), o3tl::Length::twip, 
o3tl::Length::px)) :
 nullptr);
 
 {
 // get drawing pixel rect
-tools::Rectangle aDrawingRectPixel(Point(nScrX, nScrY), 
Size(aOutputData.GetScrW(), aOutputData.GetScrH()));
+tools::Rectangle aDrawingRectPixel(
+bLokRTL ? Point(-(nScrX + aOutputData.GetScrW()), nScrY) : 
Point(nScrX, nScrY),
+Size(aOutputData.GetScrW(), aOutputData.GetScrH()));
 
 // correct for border (left/right)
-if(rDoc.MaxCol() == nX2)
+if(rDoc.MaxCol() == nX2 && !bLokRTL)
 {
 if(bLayoutRTL)
 {
@@ -970,8 +973,10 @@ void ScGridWindow::DrawContent(OutputDevice , 
const ScTableInfo& rTableI
 if (bIsTiledRendering)
 {
 Point aOrigin = aOriginalMode.GetOrigin();
-Size aPixelOffset(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, 
o3tl::Length::px),
-  o3tl::convert(aOrigin.getY(), o3tl::Length::twip, 
o3tl::Length::px));
+tools::Long nXOffset = bLayoutRTL ?
+(-o3tl::convert(aOrigin.getX(), o3tl::Length::twip, 
o3tl::Length::px) + aOutputData.GetScrW()) :
+o3

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

2022-01-30 Thread Dennis Francis (via logerrit)
 sc/source/ui/cctrl/checklistmenu.cxx |   13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 709111b40441294a0b48cb71feb7d6cf8b299656
Author: Dennis Francis 
AuthorDate: Wed Nov 24 17:44:30 2021 +0530
Commit: Dennis Francis 
CommitDate: Mon Jan 31 06:52:43 2022 +0100

lokCalcRTL: fix autofilter popup position

Change-Id: Iecf41c286e28f849f77da47a0c5f73cbbc02986a
(cherry picked from commit be329f241ee4953a039ab4bb22f46a5ac0ad5859)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128904
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/cctrl/checklistmenu.cxx 
b/sc/source/ui/cctrl/checklistmenu.cxx
index 52f53a34838e..290a6468d1d2 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -1414,8 +1414,17 @@ void ScCheckListMenuControl::launch(weld::Widget* 
pWidget, const tools::Rectangl
 if (maConfig.mbRTL)
 {
 // In RTL mode, the logical "left" is visual "right".
-tools::Long nLeft = aRect.Left() - aRect.GetWidth();
-aRect.SetLeft( nLeft );
+if (!comphelper::LibreOfficeKit::isActive())
+{
+tools::Long nLeft = aRect.Left() - aRect.GetWidth();
+aRect.SetLeft( nLeft );
+}
+else
+{
+// in LOK mode, rRect is in document pixel coordinates, so width 
has to be added
+// to place the popup next to the (visual) left aligned button.
+aRect.Move(aRect.GetWidth(), 0);
+}
 }
 else if (mnWndWidth < aRect.GetWidth())
 {


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

2022-01-30 Thread Dennis Francis (via logerrit)
 sc/source/ui/view/gridwin2.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit f7b439f5d510a021f5c7cce965d9fb09f9929a44
Author: Dennis Francis 
AuthorDate: Wed Nov 24 16:59:47 2021 +0530
Commit: Dennis Francis 
CommitDate: Mon Jan 31 06:52:02 2022 +0100

lokCalcRTL: fix autofilter button hit detection

No mirroring needed when not in tile painting mode. All positions are
in document coordinates.

Conflicts:
sc/source/ui/view/gridwin2.cxx

Change-Id: I45425e2ddce7f5ddc5086dcdce31bb6d081edc41
(cherry picked from commit 2eb5f597c3b1c5a680d6e0f9d0719f9f6977e1a3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128903
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index a7cd96a649ba..7071bd384f4b 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -109,8 +109,9 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW 
nRow, const MouseEvent&
 Point aDiffPix = rMEvt.GetPosPixel();
 
 aDiffPix -= aScrPos;
+bool bLOKActive = comphelper::LibreOfficeKit::isActive();
 bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
-if ( bLayoutRTL )
+if ( bLayoutRTL && !bLOKActive )
 aDiffPix.setX( -aDiffPix.X() );
 
 tools::Long nSizeX, nSizeY;
@@ -121,8 +122,8 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW 
nRow, const MouseEvent&
 
 // Check if the mouse cursor is clicking on the popup arrow box.
 mpFilterButton.reset(new ScDPFieldButton(GetOutDev(), 
().GetStyleSettings(), (), ));
-mpFilterButton->setBoundingBox(aScrPos, aScrSize, bLayoutRTL);
-mpFilterButton->setPopupLeft(bLayoutRTL);   // #i114944# AutoFilter button 
is left-aligned in RTL
+mpFilterButton->setBoundingBox(aScrPos, aScrSize, bLayoutRTL && 
!bLOKActive);
+mpFilterButton->setPopupLeft(bLayoutRTL && bLOKActive ? false : 
bLayoutRTL);   // #i114944# AutoFilter button is left-aligned in RTL
 Point aPopupPos;
 Size aPopupSize;
 mpFilterButton->getPopupBoundingBox(aPopupPos, aPopupSize);


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

2022-01-30 Thread Dennis Francis (via logerrit)
 sc/source/ui/cctrl/dpcontrol.cxx |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit ce76f9245d678f4894e2d4148204b994f0032626
Author: Dennis Francis 
AuthorDate: Wed Nov 24 16:12:32 2021 +0530
Commit: Dennis Francis 
CommitDate: Mon Jan 31 05:56:48 2022 +0100

lokCalcRTL: Workaround to avoid DrawPoly ghost drawings

Conflicts:
sc/source/ui/cctrl/dpcontrol.cxx

Change-Id: Ib6c794766fe68305566a293892c9123d64a2fc47
(cherry picked from commit 85a986f25956518978381df097b1f7d88477fd3d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128902
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx
index f504b6c75089..4c9fbbc6abb3 100644
--- a/sc/source/ui/cctrl/dpcontrol.cxx
+++ b/sc/source/ui/cctrl/dpcontrol.cxx
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -190,7 +191,11 @@ void ScDPFieldButton::drawPopupButton()
 
 // the arrowhead
 Color aArrowColor = mbHasHiddenMember ? mpStyle->GetHighlightTextColor() : 
mpStyle->GetButtonTextColor();
-mpOutDev->SetLineColor(aArrowColor);
+// FIXME: HACK: The following DrawPolygon draws twice in lok rtl mode for 
some reason.
+// => one at the correct location with fill (possibly no outline)
+// => and the other at an x offset with outline and without fill
+// eg. Replacing this with a DrawRect() does not have any such problems.
+comphelper::LibreOfficeKit::isActive() ? mpOutDev->SetLineColor() : 
mpOutDev->SetLineColor(aArrowColor);
 mpOutDev->SetFillColor(aArrowColor);
 
 Point aCenter(aPos.X() + (aSize.Width() / 2), aPos.Y() + (aSize.Height() / 
2));


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

2022-01-30 Thread Dennis Francis (via logerrit)
 sc/source/ui/inc/gridwin.hxx   |4 ++
 sc/source/ui/view/gridwin4.cxx |   57 +
 2 files changed, 44 insertions(+), 17 deletions(-)

New commits:
commit 324b76a3f76acd2bd00c2023a3fe990d4eefd12d
Author: Dennis Francis 
AuthorDate: Wed Nov 24 16:09:29 2021 +0530
Commit: Dennis Francis 
CommitDate: Mon Jan 31 05:55:54 2022 +0100

lokCalcRTL: draw autofilter buttons at correct coordinates

Factor out the transformation from document coordinates to tile device
coordinates in ScLokRTLContext.

Conflicts:
sc/source/ui/view/gridwin4.cxx

Change-Id: I426a179bff253233f6d45b67ddfde8b3bb1344a1
(cherry picked from commit 0145c2c0e4c69d486693488fa24490ee4458349a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128901
Tested-by: Jenkins
Reviewed-by: Dennis Francis 

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index e1ab39eb2446..0aa1d55272c9 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -52,6 +52,7 @@ class ScNoteMarker;
 class SdrHdlList;
 class ScTransferObj;
 struct SpellCallbackInfo;
+class ScLokRTLContext;
 
 //  mouse status (nMouseStatus)
 
@@ -416,7 +417,8 @@ public:
 void DPLaunchFieldPopupMenu(const Point& rScrPos, const Size& rScrSize,
 tools::Long nDimIndex, ScDPObject* pDPObj);
 
-void DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, 
OutputDevice* pContentDev);
+void DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo, 
OutputDevice* pContentDev,
+ ScLokRTLContext* pLokRTLContext);
 
 using Window::Draw;
 voidDraw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 4f1f1cc49130..c48b206ef891 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -627,6 +627,34 @@ private:
 
 }
 
+/**
+ * Used to store the necessary information about the (combined-)tile
+ * area relevant to coordinate transformations in RTL mode.
+ */
+class ScLokRTLContext
+{
+public:
+ScLokRTLContext(const ScOutputData& rOutputData, const tools::Long 
nTileDeviceOriginPixelX):
+mrOutputData(rOutputData),
+mnTileDevOriginX(nTileDeviceOriginPixelX)
+{}
+
+/**
+ * Converts from document x pixel position to the
+ * corresponding pixel position w.r.t the tile device origin.
+ */
+tools::Long docToTilePos(tools::Long nPosX) const
+{
+tools::Long nMirrorX = (-2 * mnTileDevOriginX) + 
mrOutputData.GetScrW();
+return nMirrorX - 1 - nPosX;
+}
+
+
+private:
+const ScOutputData& mrOutputData;
+const tools::Long mnTileDevOriginX;
+};
+
 void ScGridWindow::DrawContent(OutputDevice , const ScTableInfo& 
rTableInfo, ScOutputData& aOutputData,
 bool bLogicText)
 {
@@ -708,6 +736,10 @@ void ScGridWindow::DrawContent(OutputDevice , 
const ScTableInfo& rTableI
 }
 tools::Rectangle aDrawingRectLogic;
 bool bLayoutRTL = rDoc.IsLayoutRTL( nTab );
+std::unique_ptr pLokRTLCtxt(
+bIsTiledRendering && bLayoutRTL ?
+new ScLokRTLContext(aOutputData, 
o3tl::convert(aOriginalMode.GetOrigin().X(), o3tl::Length::twip, 
o3tl::Length::px)) :
+nullptr);
 
 {
 // get drawing pixel rect
@@ -899,9 +931,8 @@ void ScGridWindow::DrawContent(OutputDevice , const 
ScTableInfo& rTableI
 else
 pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
 
-// Autofilter- and Pivot-Buttons
-
-DrawButtons(nX1, nX2, rTableInfo, pContentDev);  // Pixel
+// Autofilter- and Pivot-Buttons
+DrawButtons(nX1, nX2, rTableInfo, pContentDev, pLokRTLCtxt.get()); 
 // Pixel
 
 pContentDev->SetMapMode(MapMode(MapUnit::MapPixel));
 
@@ -1067,12 +1098,8 @@ void ScGridWindow::DrawContent(OutputDevice , 
const ScTableInfo& rTableI
 {
 // Transform the cell range X coordinates such 
that the edit cell area is
 // horizontally mirrored w.r.t the 
(combined-)tile.
-tools::Long nStartTileX = 
-o3tl::convert(aOriginalMode.GetOrigin().X(), o3tl::Length::twip, 
o3tl::Length::px);
-// Note: nStartTileX is scaled by 2 only to 
offset for the addition of
-// the -ve of the same qty (and nScrX) few 
lines below.
-tools::Long nMirrorX = 2 * nStartTileX + 
aOutputData.GetScrW();
-aStart.setX(nMirrorX - 1 - aStart.X());
-aEnd.setX(nMirrorX - 1 - aEnd.X());
+
aStart.setX(pLokRTLCtxt->docToTilePos(aStart.X()));
+ 

  1   2   3   4   5   6   7   8   >