core.git: 2 commits - include/svx sd/inc sd/Library_sd.mk sd/source svx/Library_svxcore.mk svx/source

2024-04-26 Thread Tomaž Vajngerl (via logerrit)
 include/svx/annotation/Annotation.hxx  |   88 +++-
 include/svx/annotation/AnnotationEnumeration.hxx   |   11 -
 include/svx/svdpage.hxx|   13 +
 sd/Library_sd.mk   |1 
 sd/inc/Annotation.hxx  |   37 ---
 sd/inc/sdpage.hxx  |   12 -
 sd/source/core/annotations/Annotation.cxx  |  215 -
 sd/source/core/sdpage2.cxx |   50 ++--
 sd/source/filter/pdf/sdpdffilter.cxx   |7 
 sd/source/ui/annotations/annotationmanager.cxx |   88 
 sd/source/ui/annotations/annotationmanagerimpl.hxx |   20 -
 sd/source/ui/annotations/annotationtag.cxx |   23 +-
 sd/source/ui/annotations/annotationtag.hxx |   11 -
 sd/source/ui/unoidl/unomodel.cxx   |3 
 sd/source/ui/unoidl/unopage.cxx|6 
 svx/Library_svxcore.mk |1 
 svx/source/annotation/Annotation.cxx   |  150 ++
 svx/source/annotation/AnnotationEnumeration.cxx|   46 +---
 svx/source/svdraw/svdpage.cxx  |1 
 19 files changed, 436 insertions(+), 347 deletions(-)

New commits:
commit a0a581ead18f030f59d203539706de0230746cae
Author: Tomaž Vajngerl 
AuthorDate: Fri Apr 19 15:34:06 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Apr 26 10:44:05 2024 +0200

annot: moved more of Annotation and dependencies into svx

Moved the holder of annotations from SdPage to SvxPage, so that
the vector holding the annotations and accessors are on SvxPage
and adapted the code.

This also changes the type od most parameters on most methods
from sd::Annotation to sdr::annotation::Annotation and adapted
the code.

Moved AnnotationEnumeration into svx, as it was needed in svx
already.

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

diff --git a/include/svx/annotation/Annotation.hxx 
b/include/svx/annotation/Annotation.hxx
index 566dd6ef52f4..5ec5e2ec3c34 100644
--- a/include/svx/annotation/Annotation.hxx
+++ b/include/svx/annotation/Annotation.hxx
@@ -13,12 +13,17 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
+#include 
+#include 
+#include 
+#include 
+
 class SdrUndoAction;
 class SfxViewShell;
+class SdrPage;
 
 namespace sdr::annotation
 {
@@ -49,13 +54,15 @@ struct SVXCORE_DLLPUBLIC AnnotationData
 };
 
 class SVXCORE_DLLPUBLIC Annotation
+: public ::comphelper::WeakComponentImplHelper,
+  public ::cppu::PropertySetMixin
 {
 private:
 static sal_uInt32 m_nLastId;
 static sal_uInt32 nextID() { return m_nLastId++; }
 
 protected:
-SdrPage* mpSdrPage;
+SdrPage* mpPage;
 sal_uInt32 m_nId;
 
 css::geometry::RealPoint2D m_Position;
@@ -69,10 +76,19 @@ protected:
 std::unique_ptr createUndoAnnotation();
 
 public:
-Annotation(SdrPage* pPage)
-: mpSdrPage(pPage)
-, m_nId(nextID())
+Annotation(const css::uno::Reference& 
context, SdrPage* pPage);
+Annotation(const Annotation&) = delete;
+Annotation& operator=(const Annotation&) = delete;
+
+// XInterface:
+virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const& type) 
override;
+virtual void SAL_CALL acquire() noexcept override
+{
+
::comphelper::WeakComponentImplHelper::acquire();
+}
+virtual void SAL_CALL release() noexcept override
 {
+
::comphelper::WeakComponentImplHelper::release();
 }
 
 css::geometry::RealPoint2D GetPosition() const { return m_Position; }
@@ -93,11 +109,9 @@ public:
 virtual OUString GetText() = 0;
 virtual void SetText(OUString const& rText) = 0;
 
-SdrModel* GetModel()
-{
-return mpSdrPage != nullptr ? >getSdrModelFromSdrPage() : 
nullptr;
-}
-SdrPage const* getPage() const { return mpSdrPage; }
+SdrModel* GetModel() const;
+SdrPage const* getPage() const { return mpPage; }
+SdrPage* getPage() { return mpPage; }
 
 sal_uInt32 GetId() const { return m_nId; }
 
@@ -106,7 +120,7 @@ public:
 bool isFreeText() const { return m_bIsFreeText; }
 };
 
-//typedef std::vector> AnnotationVector;
+typedef std::vector> AnnotationVector;
 
 } // namespace sdr::annotation
 
diff --git a/sd/inc/AnnotationEnumeration.hxx 
b/include/svx/annotation/AnnotationEnumeration.hxx
similarity index 80%
rename from sd/inc/AnnotationEnumeration.hxx
rename to include/svx/annotation/AnnotationEnumeration.hxx
index ed35b46b4068..a7befcb26946 100644
--- a/sd/inc/AnnotationEnumeration.hxx
+++ b/include/svx/annotation/AnnotationEnumeration.hxx
@@ -20,18 +20,19 @@
 #pragma once
 
 #include 
-
-#include "sdpage.hxx"
+#include 
 
 namespace com::sun::star::office
 {
 class XAnnotationEnumeration;
 }
 
-namespace sd
+namespace 

core.git: include/svx sd/inc sd/source svx/Library_svxcore.mk svx/source

2024-04-24 Thread Tomaž Vajngerl (via logerrit)
 include/svx/annotation/Annotation.hxx |   57 ++
 sd/inc/Annotation.hxx |   18 ++---
 sd/source/core/annotations/Annotation.cxx |8 +---
 svx/Library_svxcore.mk|1 
 svx/source/annotation/Annotation.cxx  |   18 +
 5 files changed, 82 insertions(+), 20 deletions(-)

New commits:
commit a938ed2be520426ce7949c4fd30a6e7e31d7c279
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 18 14:54:52 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 25 07:17:51 2024 +0200

annot: added Annotation impl. to svx, moved some thing from sd

This is an attempt to move the sd::Annotation to the common code
in the svx module. This will need to be done in multiple steps so
the first one is to introduce sdr::annotation::Annotation class in
svx module, which is derived by sd::Annotation. Non-problematic
functionality and members are also moved to the svx Annotation.

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

diff --git a/include/svx/annotation/Annotation.hxx 
b/include/svx/annotation/Annotation.hxx
new file mode 100644
index ..13881a58d070
--- /dev/null
+++ b/include/svx/annotation/Annotation.hxx
@@ -0,0 +1,57 @@
+/* -*- 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 sdr::annotation
+{
+class SVXCORE_DLLPUBLIC Annotation
+{
+private:
+static sal_uInt32 m_nLastId;
+static sal_uInt32 nextID() { return m_nLastId++; }
+
+protected:
+SdrPage* mpSdrPage;
+sal_uInt32 m_nId;
+
+css::geometry::RealPoint2D m_Position;
+css::geometry::RealSize2D m_Size;
+OUString m_Author;
+OUString m_Initials;
+css::util::DateTime m_DateTime;
+bool m_bIsFreeText = false;
+
+public:
+Annotation(SdrPage* pPage)
+: mpSdrPage(pPage)
+, m_nId(nextID())
+{
+}
+
+SdrModel* GetModel()
+{
+return mpSdrPage != nullptr ? >getSdrModelFromSdrPage() : 
nullptr;
+}
+
+sal_uInt32 GetId() const { return m_nId; }
+};
+
+//typedef std::vector> AnnotationVector;
+
+} // namespace sdr::annotation
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/inc/Annotation.hxx b/sd/inc/Annotation.hxx
index 965cbded3719..558271dbc04e 100644
--- a/sd/inc/Annotation.hxx
+++ b/sd/inc/Annotation.hxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "sdpage.hxx"
 #include "textapi.hxx"
@@ -67,19 +68,16 @@ struct SD_DLLPUBLIC CustomAnnotationMarker
 };
 
 class SAL_DLLPUBLIC_RTTI Annotation final :
-   public 
::comphelper::WeakComponentImplHelper,
-   public ::cppu::PropertySetMixin
+public sdr::annotation::Annotation,
+public 
::comphelper::WeakComponentImplHelper,
+ public ::cppu::PropertySetMixin
 {
 public:
 explicit Annotation( const 
css::uno::Reference& context, SdPage* pPage );
 Annotation(const Annotation&) = delete;
 Annotation& operator=(const Annotation&) = delete;
 
-static sal_uInt32 m_nLastId;
-
 SdPage* GetPage() const { return mpPage; }
-SdrModel* GetModel() { return (mpPage != nullptr) ? 
>getSdrModelFromSdrPage() : nullptr; }
-sal_uInt32 GetId() const { return m_nId; }
 
 // XInterface:
 virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) 
override;
@@ -141,17 +139,9 @@ private:
 
 void createChangeUndoImpl(std::unique_lock& g);
 
-sal_uInt32 m_nId;
 SdPage* mpPage;
-css::geometry::RealPoint2D m_Position;
-css::geometry::RealSize2D m_Size;
-OUString m_Author;
-OUString m_Initials;
-css::util::DateTime m_DateTime;
 rtl::Reference m_TextRange;
-
 std::unique_ptr m_pCustomAnnotationMarker;
-bool m_bIsFreeText;
 };
 
 }
diff --git a/sd/source/core/annotations/Annotation.cxx 
b/sd/source/core/annotations/Annotation.cxx
index fee7312bcca2..b3938002b87c 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -115,14 +115,10 @@ void createAnnotation(rtl::Reference& 
xAnnotation, SdPage* pPage )
 pPage->addAnnotation(xAnnotation, -1);
 }
 
-sal_uInt32 Annotation::m_nLastId = 1;
-
 Annotation::Annotation(const uno::Reference& context, 
SdPage* pPage)
-: ::cppu::PropertySetMixin(context, 
IMPLEMENTS_PROPERTY_SET,
-uno::Sequence())
-, m_nId(m_nLastId++)
+: sdr::annotation::Annotation(pPage)
+, 

core.git: 2 commits - sc/inc sc/qa sc/source

2024-04-22 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/pivot/PivotTableFormatOutput.hxx
|1 
 sc/qa/unit/PivotTableFormatsImportExport.cxx   
|  168 ++
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_10_FormatDefinitionNotMatchingPivotTable.xlsx
   |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_11_WholeDataColumnSelected.xlsx
 |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_12_WholeLabelColumnSelected.xlsx
|binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_13_SelectionInLabelAndData.xlsx
 |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_14_TwoRowsDataFieldInColumn_LabelColor.xlsx
 |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_15_TwoDataFieldColumns_WholeDataColumnSelected.xlsx
 |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_2_DataFieldInRow_ColumnLabelColor.xlsx
  |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_8_DataFieldInRow_DataColor.xlsx
 |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_9_MultipleSelections.xlsx
   |binary
 sc/source/core/data/PivotTableFormatOutput.cxx 
|  161 +
 sc/source/filter/oox/PivotTableFormat.cxx  
|2 
 13 files changed, 261 insertions(+), 71 deletions(-)

New commits:
commit c0f44787c0bcbd28ac61dab66483f025578f095c
Author: Tomaž Vajngerl 
AuthorDate: Wed Apr 17 16:08:45 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Apr 22 08:22:04 2024 +0200

pivot: handle whole row/column selections, added many tests

This adds support for selecting whole rows/columns, where the field
reference is set but no indices are present. This means that all
the data cells apply (selecting the whole thing), which are not
subtotals. For this the support for multiple matching and maybe
matching results was added (previously max 1 would apply), which
would apply the pattern to multiple cells in the pivot table.

In addition handle labels of columns with multiple data fields
correctly.

This also adds many more test scenarios, which all cover the
changes mentioned above.

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

diff --git a/sc/inc/pivot/PivotTableFormatOutput.hxx 
b/sc/inc/pivot/PivotTableFormatOutput.hxx
index 0aeb492cc34a..3bbd19b28f36 100644
--- a/sc/inc/pivot/PivotTableFormatOutput.hxx
+++ b/sc/inc/pivot/PivotTableFormatOutput.hxx
@@ -41,6 +41,7 @@ struct FormatOutputField
 tools::Long nDimension = -2;
 OUString aName;
 sal_Int32 nIndex = -1;
+bool bMatchesAll = false;
 bool bSet = false;
 };
 
diff --git a/sc/qa/unit/PivotTableFormatsImportExport.cxx 
b/sc/qa/unit/PivotTableFormatsImportExport.cxx
index f1cf83d225cd..0ea867a1 100644
--- a/sc/qa/unit/PivotTableFormatsImportExport.cxx
+++ b/sc/qa/unit/PivotTableFormatsImportExport.cxx
@@ -335,6 +335,174 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 CPPUNIT_ASSERT_EQUAL(u"60"_ustr, rDoc.GetString(aAddress));
 }
 
+CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
+ PivotTableCellFormatsTest_11_WholeDataColumnSelected)
+{
+auto assertDocument = [](ScDocument& rDoc) {
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"G2"_ustr));
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"G3"_ustr));
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"G4"_ustr));
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"G5"_ustr));
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"G6"_ustr));
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"G7"_ustr));
+
+// Make sure the other cells have the font color or background set to 
default
+auto aEmptyAddresses = std::to_array({
+u"F1"_ustr,
+u"G1"_ustr,
+u"F2"_ustr,
+u"F3"_ustr,
+u"F4"_ustr,
+u"F5"_ustr,
+u"F6"_ustr,
+u"F7"_ustr,
+u"F8"_ustr,
+u"G8"_ustr,
+});
+CPPUNIT_ASSERT_EQUAL(OUString(), checkNonEmptyAddresses(rDoc, 
aEmptyAddresses));
+};
+
+
createScDoc("xlsx/pivot-table/PivotTableCellFormatsTest_11_WholeDataColumnSelected.xlsx");
+assertDocument(*getScDoc());
+saveAndReload("Calc Office Open XML");
+assertDocument(*getScDoc());
+}
+
+CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
+ 

core.git: vcl/source

2024-04-18 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/gdi/salmisc.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 92edab3d95ff5ee8a81a453b3224157839dfd32c
Author: Tomaž Vajngerl 
AuthorDate: Wed Apr 17 22:55:01 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 18 14:11:26 2024 +0200

tdf#160016 tdf#160704 Set the direction from src in StretchAndConvert

The direction of the BitmapBuffer was never set, so it defaulted
to BottomUp. The best is to set the direction to be the same as
source - It's unlikely they would be different.

Regression from 6588c30ed4477627b2623560ca867682b189bc80
"vcl: separate scanline direction from ScanlineFormat"

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

diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx
index ed210bf8475c..b1833855ab8c 100644
--- a/vcl/source/gdi/salmisc.cxx
+++ b/vcl/source/gdi/salmisc.cxx
@@ -234,6 +234,8 @@ std::optional StretchAndConvert(
 FncSetPixel pFncSetPixel;
 std::optional pDstBuffer(std::in_place);
 
+
+pDstBuffer->meDirection = rSrcBuffer.meDirection;
 // set function for getting pixels
 pFncGetPixel = BitmapReadAccess::GetPixelFunction(rSrcBuffer.meFormat);
 if( !pFncGetPixel )


core.git: sc/qa

2024-04-17 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/PivotTableFormatsImportExport.cxx   
  |   35 --
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_10_FormatDefinitionNotMatchingPivotTable.xlsx
 |binary
 2 files changed, 30 insertions(+), 5 deletions(-)

New commits:
commit 3b50c9f54907c656d2ee23fddadc696ffdab1c94
Author: Tomaž Vajngerl 
AuthorDate: Tue Apr 16 22:44:23 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 18 01:33:36 2024 +0200

pivot: test for issue when pivot table format not matching data

Fix was added with [1][2] and this adds the tests to make sure
this keeps working in the future.

[1] 1d5630c5deeec5dca724c29ec8c886bfa71a2099
[2] https://gerrit.libreoffice.org/c/core/+/166138

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

diff --git a/sc/qa/unit/PivotTableFormatsImportExport.cxx 
b/sc/qa/unit/PivotTableFormatsImportExport.cxx
index 40db2afb2292..f1cf83d225cd 100644
--- a/sc/qa/unit/PivotTableFormatsImportExport.cxx
+++ b/sc/qa/unit/PivotTableFormatsImportExport.cxx
@@ -36,20 +36,23 @@ 
ScPivotTableFormatsImportExport::ScPivotTableFormatsImportExport()
 
 namespace
 {
-Color getBackgroundColor(ScDocument& rDoc, OUString const& rAddressString)
+ScAddress parseAddress(ScDocument& rDoc, OUString const& rAddressString)
 {
 ScAddress aAddress;
 aAddress.Parse(rAddressString, rDoc);
-const ScPatternAttr* pPattern = rDoc.GetPattern(aAddress);
+return aAddress;
+}
+
+Color getBackgroundColor(ScDocument& rDoc, OUString const& rAddressString)
+{
+const ScPatternAttr* pPattern = rDoc.GetPattern(parseAddress(rDoc, 
rAddressString));
 const SvxBrushItem& rItem = pPattern->GetItem(ATTR_BACKGROUND);
 return rItem.GetColor();
 }
 
 Color getFontColor(ScDocument& rDoc, OUString const& rAddressString)
 {
-ScAddress aAddress;
-aAddress.Parse(rAddressString, rDoc);
-const ScPatternAttr* pPattern = rDoc.GetPattern(aAddress);
+const ScPatternAttr* pPattern = rDoc.GetPattern(parseAddress(rDoc, 
rAddressString));
 const SvxColorItem& rItem = pPattern->GetItem(ATTR_FONT_COLOR);
 return rItem.getColor();
 }
@@ -310,6 +313,28 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 assertDocument(*getScDoc());
 }
 
+CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
+ 
PivotTableCellFormatsTest_10_FormatDefinitionNotMatchingPivotTable)
+{
+// The pivot table format data in this document doesn't match the pivot 
table data, which can produce
+// a crash during loading and resolving of formats. Specifically
+
+// Load the document, which shouldn't result in a crash
+createScDoc(
+
"xlsx/pivot-table/PivotTableCellFormatsTest_10_FormatDefinitionNotMatchingPivotTable.xlsx");
+ScDocument& rDoc = *getScDoc();
+
+// Let's check the pivot table exists
+ScDPCollection* pCollection = rDoc.GetDPCollection();
+CPPUNIT_ASSERT_EQUAL(size_t(1), pCollection->GetCount());
+
+auto aAddress = parseAddress(rDoc, u"G2"_ustr);
+const ScDPObject* pDPObject = rDoc.GetDPAtCursor(aAddress);
+CPPUNIT_ASSERT(pDPObject);
+
+CPPUNIT_ASSERT_EQUAL(u"60"_ustr, rDoc.GetString(aAddress));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git 
a/sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_10_FormatDefinitionNotMatchingPivotTable.xlsx
 
b/sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_10_FormatDefinitionNotMatchingPivotTable.xlsx
new file mode 100644
index ..c2fe60ccf69f
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_10_FormatDefinitionNotMatchingPivotTable.xlsx
 differ


core.git: sc/source

2024-04-16 Thread Tomaž Vajngerl (via logerrit)
 sc/source/core/data/PivotTableFormatOutput.cxx |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 1d5630c5deeec5dca724c29ec8c886bfa71a2099
Author: Tomaž Vajngerl 
AuthorDate: Tue Apr 16 15:21:49 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Apr 16 14:37:43 2024 +0200

pivot: add checks that prevent reading out of vector bounds

MSO likes to keep formats in the document even when the pivot
table has been changed, so there might be references that contain
indices values that are pointing out of bounds for the current
pivot table result data. To prevent crashing the checks are added
to prevent using an index that is out of vector bounds.

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

diff --git a/sc/source/core/data/PivotTableFormatOutput.cxx 
b/sc/source/core/data/PivotTableFormatOutput.cxx
index fbef219b513b..cdd2ac90914f 100644
--- a/sc/source/core/data/PivotTableFormatOutput.cxx
+++ b/sc/source/core/data/PivotTableFormatOutput.cxx
@@ -64,6 +64,8 @@ public:
 else
 {
 std::vector& rNames = iterator->second;
+if (nIndex >= rNames.size())
+return OUString();
 return rNames[nIndex];
 }
 }
@@ -97,7 +99,7 @@ void initFormatOutputField(size_t nSelectionIndex, 
std::vector 1)
 rOutputField.nIndex = rSelection.nIndices[nSelectionIndex];
@@ -107,8 +109,8 @@ void initFormatOutputField(size_t nSelectionIndex, 
std::vector

core.git: sc/inc sc/qa sc/source

2024-04-16 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/pivot/PivotTableFormats.hxx 
  |2 
 sc/qa/unit/PivotTableFormatsImportExport.cxx   
  |   15 +
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_9_MultipleSelections.xlsx
 |binary
 sc/source/core/data/PivotTableFormatOutput.cxx 
  |   82 +-
 sc/source/filter/excel/xepivotxml.cxx  
  |6 
 sc/source/filter/oox/PivotTableFormat.cxx  
  |2 
 6 files changed, 69 insertions(+), 38 deletions(-)

New commits:
commit ded4d570fde21e55091c9c8c364114e67aa0cdcf
Author: Tomaž Vajngerl 
AuthorDate: Tue Apr 16 00:39:20 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Apr 16 08:31:38 2024 +0200

pivot: suppprt multiple cell format reference indices

This adds support for multiple cell format reference indices, so
the same cell format is applied to multiple cells (defined by
indices) so that each doesn't need to be defined by its own
reference (as they are all the same anyway and only differ by
single index).

The solution is to create multiple format outputs for one format
entry - each for a selection index, but have other data still the
same. This is a bit tricky as previously it was one format output
for one format entry, which is not the case anymore.

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

diff --git a/sc/inc/pivot/PivotTableFormats.hxx 
b/sc/inc/pivot/PivotTableFormats.hxx
index 8c8ebcadffbd..d569c6167e1f 100644
--- a/sc/inc/pivot/PivotTableFormats.hxx
+++ b/sc/inc/pivot/PivotTableFormats.hxx
@@ -29,7 +29,7 @@ struct Selection
 {
 bool bSelected = false;
 sal_Int32 nField = 0;
-sal_uInt32 nDataIndex = 0;
+std::vector nIndices;
 };
 
 /** Holds cell pattern attributes and a selection information to which cells 
in the pivot table
diff --git a/sc/qa/unit/PivotTableFormatsImportExport.cxx 
b/sc/qa/unit/PivotTableFormatsImportExport.cxx
index 1c20cdc3b5ac..40db2afb2292 100644
--- a/sc/qa/unit/PivotTableFormatsImportExport.cxx
+++ b/sc/qa/unit/PivotTableFormatsImportExport.cxx
@@ -295,6 +295,21 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 assertDocument(*getScDoc());
 }
 
+CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
+ PivotTableCellFormatsTest_9_MultipleSelections)
+{
+auto assertDocument = [](ScDocument& rDoc) {
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"I6"_ustr));
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"I7"_ustr));
+CPPUNIT_ASSERT_EQUAL(COL_YELLOW, getBackgroundColor(rDoc, u"I8"_ustr));
+};
+
+
createScDoc("xlsx/pivot-table/PivotTableCellFormatsTest_9_MultipleSelections.xlsx");
+assertDocument(*getScDoc());
+saveAndReload("Calc Office Open XML");
+assertDocument(*getScDoc());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git 
a/sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_9_MultipleSelections.xlsx
 
b/sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_9_MultipleSelections.xlsx
new file mode 100644
index ..6d317d2e45c0
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_9_MultipleSelections.xlsx
 differ
diff --git a/sc/source/core/data/PivotTableFormatOutput.cxx 
b/sc/source/core/data/PivotTableFormatOutput.cxx
index 9f6dcf2355b7..fbef219b513b 100644
--- a/sc/source/core/data/PivotTableFormatOutput.cxx
+++ b/sc/source/core/data/PivotTableFormatOutput.cxx
@@ -84,7 +84,7 @@ void initLines(std::vector& rLines, 
std::vector cons
 }
 }
 
-void initFormatOutputField(std::vector& rOutputFields,
+void initFormatOutputField(size_t nSelectionIndex, 
std::vector& rOutputFields,
std::vector const& rFields,
PivotTableFormat const& rFormat, NameResolver& 
rNameResolver)
 {
@@ -99,19 +99,18 @@ void initFormatOutputField(std::vector& 
rOutputFields,
 {
 if (rSelection.nField == rOutputField.nDimension)
 {
+if (rSelection.nIndices.size() > 1)
+rOutputField.nIndex = rSelection.nIndices[nSelectionIndex];
+else
+rOutputField.nIndex = rSelection.nIndices[0];
+
 if (rOutputField.nDimension == -2)
-{
 rOutputField.aName = "DATA";
-rOutputField.nIndex = rSelection.nDataIndex;
-rOutputField.bSet = true;
-}
 else
-{
 rOutputField.aName
-= rNameResolver.getNameForIndex(rSelection.nDataIndex, 

core.git: sc/inc sc/qa sc/source

2024-04-15 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/pivot/PivotTableFormatOutput.hxx
   |   13 
 sc/qa/unit/PivotTableFormatsImportExport.cxx   
   |  141 ++-
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_2_DataFieldInRow_ColumnLabelColor.xlsx
 |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_8_DataFieldInRow_DataColor.xlsx
|binary
 sc/source/core/data/PivotTableFormatOutput.cxx 
   |  199 ++
 5 files changed, 273 insertions(+), 80 deletions(-)

New commits:
commit 12eba0d6115b05792b302d4a5ad141d9eb528db4
Author: Tomaž Vajngerl 
AuthorDate: Mon Apr 15 11:28:38 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Apr 15 17:48:47 2024 +0200

pivot: improve format matching, add empty cell checking to tests

The patch improves the pivot table cell format matching with the
output data, so we check if there is a complete match or a partial
match. A partial match is when we found one match for a field, but
other fields are not set, and if this partial match is found in
exactly 1 line of output data, then we treat it as a complete match.

This also refactors the code so there is code no duplication for
column and row matching code - they work in the same way, just
in a different orientation.

This also adds checking of empty cells to the tests, so we can
make sure there is no other cell in the pivot table that got the
pivot table cell format applied to. A new test case was also added
to the test class.

Change-Id: I102ec8e33bc7a3f26bc898568ee0e33abe08bd27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166086
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/inc/pivot/PivotTableFormatOutput.hxx 
b/sc/inc/pivot/PivotTableFormatOutput.hxx
index 59cad62c013c..0aeb492cc34a 100644
--- a/sc/inc/pivot/PivotTableFormatOutput.hxx
+++ b/sc/inc/pivot/PivotTableFormatOutput.hxx
@@ -28,12 +28,14 @@ struct ScDPOutLevelData;
 
 namespace sc
 {
+/// Direction or orientation of the results
 enum class FormatResultDirection
 {
 ROW,
 COLUMN
 };
 
+/// A field data for a format output,
 struct FormatOutputField
 {
 tools::Long nDimension = -2;
@@ -42,6 +44,7 @@ struct FormatOutputField
 bool bSet = false;
 };
 
+/// Data for a entry of a format output, which matches a one format entry
 struct FormatOutputEntry
 {
 FormatType eType = FormatType::None;
@@ -52,6 +55,7 @@ struct FormatOutputEntry
 std::vector aColumnOutputFields;
 };
 
+/// data of one "field" that is part of a line
 struct FieldData
 {
 tools::Long mnDimension = -2;
@@ -64,15 +68,19 @@ struct FieldData
 bool bContinue = false;
 };
 
+/// data for a "line" of one row/column axis
 struct LineData
 {
+/// primary axis depending if we are row or column oriented (when 
selecting a column or row we get a "line")
 std::optional oLine = std::nullopt;
+/// secondary axis depending if we are row or column oriented (position in 
a line)
 std::optional oPosition = std::nullopt;
+/// fields of a line
 std::vector maFields;
 };
 
-class NameResolver;
-
+/** Format output class, which is responsible to check if any of the formats 
and matches the
+ *  pivot table output, and applies the cell attributes when the match is 
found. */
 class FormatOutput
 {
 private:
@@ -93,7 +101,6 @@ public:
 void setFormats(sc::PivotTableFormats const& rPivotTableFormats)
 {
 mpFormats.reset(new sc::PivotTableFormats(rPivotTableFormats));
-maFormatOutputEntries.resize(mpFormats->size());
 }
 
 void insertFieldMember(size_t nFieldIndex, const ScDPOutLevelData& rField,
diff --git a/sc/qa/unit/PivotTableFormatsImportExport.cxx 
b/sc/qa/unit/PivotTableFormatsImportExport.cxx
index 401e190b34f5..1c20cdc3b5ac 100644
--- a/sc/qa/unit/PivotTableFormatsImportExport.cxx
+++ b/sc/qa/unit/PivotTableFormatsImportExport.cxx
@@ -12,19 +12,11 @@
 #include "helper/qahelper.hxx"
 
 #include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -61,6 +53,24 @@ Color getFontColor(ScDocument& rDoc, OUString const& 
rAddressString)
 const SvxColorItem& rItem = pPattern->GetItem(ATTR_FONT_COLOR);
 return rItem.getColor();
 }
+
+template  OUString checkNonEmptyAddresses(ScDocument& rDoc, T 
const& rArrayOfAddresses)
+{
+OUString aString;
+for (auto const& rAddressString : rArrayOfAddresses)
+{
+ScAddress aAddress;
+aAddress.Parse(rAddressString, rDoc);
+const ScPatternAttr* pPattern = rDoc.GetPattern(aAddress);
+if (pPattern->GetItem(ATTR_FONT_COLOR).getColor() != COL_BLACK
+|| pPattern->GetItem(ATTR_BACKGROUND).GetColor() != 
COL_TRANSPARENT)
+{
+aString 

core.git: Branch 'distro/collabora/co-24.04' - editeng/inc editeng/source include/editeng include/svx sd/qa svx/source

2024-04-15 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/editdoc.hxx |   14 ++
 editeng/source/editeng/impedit.hxx  |9 +
 editeng/source/editeng/impedit2.cxx |   22 
 editeng/source/editeng/impedit3.cxx |  139 
 include/editeng/editdata.hxx|4 
 include/editeng/outliner.hxx|2 
 include/svx/svdotext.hxx|6 -
 sd/qa/unit/TextFittingTest.cxx  |   12 +-
 sd/qa/unit/data/xml/n593612_0.xml   |4 
 sd/qa/unit/export-tests-ooxml3.cxx  |2 
 svx/source/svdraw/svdotext.cxx  |  133 --
 svx/source/svdraw/svdotextdecomposition.cxx |4 
 svx/source/svdraw/svdotxed.cxx  |2 
 13 files changed, 183 insertions(+), 170 deletions(-)

New commits:
commit 774c1ddfecc6389234f8d0e68d6e17c1fe218cb1
Author: Tomaž Vajngerl 
AuthorDate: Thu Mar 28 12:30:34 2024 +0900
Commit: Miklos Vajna 
CommitDate: Mon Apr 15 14:56:31 2024 +0200

editeng: use text scaling that better mimics MSO text scaling

Implement text scaling algorithm that is similar to MSO text
scaling for text boxes for the compatibility purpuse, so that the
Impress slides better match how the PP slides are layed out.

This also moves the implementation into EditEng, where it is
possible to better control how searching for the best scaling
factor is performed without doing additional irrelevant work or
trigger invalidations that should not be triggered.

An additional change is that the paragraph with no content at the
end are ignored, and are not taken into account when determining
the height of the content. This is done for compatibility reasons.

Fix horizontal spacing of tabs - the spacing shouldn't be scaled
and the tab shouldn't include the space at the beginning of the
line.

Change-Id: Ie37fa67f1cf300e915a4ebaef2a7f968bf6c5744
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165441
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit f61ea135430d7b4a1fac7de1e57a1314fbb1b49e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166087
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 80e3cc34243c..8e17c6c38fa6 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -662,7 +662,9 @@ public:
 class ParaPortionList
 {
 mutable sal_Int32 nLastCache;
-std::vector> maPortions;
+typedef std::vector> ParaPortionContainerType;
+ParaPortionContainerType maPortions;
+
 public:
 ParaPortionList();
 ~ParaPortionList();
@@ -684,6 +686,16 @@ public:
 void Append(std::unique_ptr p);
 sal_Int32 Count() const;
 
+ParaPortion& getRef(sal_Int32 nPosition) { return *maPortions[nPosition]; }
+ParaPortion const& getRef(sal_Int32 nPosition) const { return 
*maPortions[nPosition]; }
+
+sal_Int32 lastIndex() const { return Count() - 1; }
+
+ParaPortionContainerType::iterator begin() { return maPortions.begin(); }
+ParaPortionContainerType::iterator end() { return maPortions.end(); }
+ParaPortionContainerType::const_iterator cbegin() const { return 
maPortions.cbegin(); }
+ParaPortionContainerType::const_iterator cend() const { return 
maPortions.cend(); }
+
 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
 // temporary:
 static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc);
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 34d57e8e9747..988c446aca57 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -530,6 +530,7 @@ private:
 
 Color   maBackgroundColor;
 
+ScalingParameters maCustomScalingParameters;
 ScalingParameters maScalingParameters;
 bool mbRoundToNearestPt;
 
@@ -617,6 +618,7 @@ private:
 voidParaAttribsChanged( ContentNode const * pNode, bool 
bIgnoreUndoCheck = false );
 voidTextModified();
 voidCalcHeight( ParaPortion* pPortion );
+bool isInEmptyClusterAtTheEnd(ParaPortion& rParaPortion);
 
 voidInsertUndo( std::unique_ptr pUndo, bool 
bTryMerge = false );
 voidResetUndoManager();
@@ -880,8 +882,11 @@ public:
 
 void SetMinColumnWrapHeight(tools::Long nVal) { mnMinColumnWrapHeight = 
nVal; }
 
-voidFormatDoc();
-voidFormatFullDoc();
+tools::Long FormatParagraphs(o3tl::sorted_vector& 
rRepaintParagraphs);
+void ScaleContentToFitWindow(o3tl::sorted_vector& 
rRepaintParagraphs);
+void FormatDoc();
+void FormatFullDoc();
+
 voidUpdateViews( EditView* pCurView = nullptr );
 voidPaint( ImpEditView* pView, const tools::Rectangle& 
rRect, 

core.git: Branch 'distro/collabora/co-24.04' - include/svl include/svx oox/inc oox/source sd/qa svx/source

2024-04-15 Thread Tomaž Vajngerl (via logerrit)
 include/svl/solar.hrc  |2 
 include/svx/sdtfsitm.hxx   |   13 +++--
 include/svx/unoshprp.hxx   |   16 ---
 oox/inc/drawingml/textbodyproperties.hxx   |1 
 oox/source/drawingml/diagram/diagram.cxx   |   21 ++---
 oox/source/drawingml/textbodypropertiescontext.cxx |5 +-
 oox/source/token/properties.txt|2 
 sd/qa/unit/export-tests-ooxml2.cxx |   16 +++
 sd/qa/unit/import-tests-smartart.cxx   |   15 +++---
 sd/qa/unit/import-tests2.cxx   |6 +-
 svx/source/svdraw/svdattr.cxx  |5 +-
 svx/source/svdraw/svdotext.cxx |2 
 svx/source/unodraw/unoshape.cxx|   48 -
 13 files changed, 101 insertions(+), 51 deletions(-)

New commits:
commit 134bbf9ad54ad351b859e31bd4f7aecae17e595c
Author: Tomaž Vajngerl 
AuthorDate: Mon Apr 1 20:32:15 2024 +0900
Commit: Miklos Vajna 
CommitDate: Mon Apr 15 14:54:26 2024 +0200

svx: read font and spacing scaling from oox, add bot as UNO prop.

- Read spacing in oox.
- Add spacing scaling as a property.
- Rename property "TextFitToSizeScale" to "TextFitToSizeFontScale"
- Add property "TextFitToSizeSpacingScale"

Change-Id: Icde575e55a3146169d86bb538a57adcf1fa228a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165633
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit db64748f1ee771da9da857f95601b9e08b577166)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165709
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/include/svl/solar.hrc b/include/svl/solar.hrc
index f1ec1a456829..288c3073caa0 100644
--- a/include/svl/solar.hrc
+++ b/include/svl/solar.hrc
@@ -23,7 +23,7 @@
 // defines --
 
 #define OWN_ATTR_VALUE_START3900
-#define OWN_ATTR_VALUE_END  4008
+#define OWN_ATTR_VALUE_END  4020
 
 #define RID_LIB_START   1
 #define RID_LIB_END 1
diff --git a/include/svx/sdtfsitm.hxx b/include/svx/sdtfsitm.hxx
index ccdcb7c4dbe9..55fe48a5fc61 100644
--- a/include/svx/sdtfsitm.hxx
+++ b/include/svx/sdtfsitm.hxx
@@ -42,7 +42,8 @@ public:
 
 SdrTextFitToSizeTypeItem(const SdrTextFitToSizeTypeItem& rItem)
 : SfxEnumItem(rItem)
-, m_nMaxScale(rItem.GetMaxScale())
+, mfFontScale(rItem.getFontScale())
+, mfSpacingScale(rItem.getSpacingScale())
 {
 }
 
@@ -59,10 +60,14 @@ public:
 virtual bool GetBoolValue() const override;
 virtual void SetBoolValue(bool bVal) override;
 
-void SetMaxScale(double nMaxScale) { m_nMaxScale = nMaxScale; }
-double GetMaxScale() const { return m_nMaxScale; }
+void setFontScale(double fScale) { mfFontScale = fScale; }
+double getFontScale() const { return mfFontScale; }
+
+void setSpacingScale(double fScale) { mfSpacingScale = fScale; }
+double getSpacingScale() const { return mfSpacingScale; }
 private:
-double m_nMaxScale = 0.0;
+double mfFontScale = 0.0;
+double mfSpacingScale = 0.0;
 };
 
 #endif
diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index 53561015804b..b5e37ede384d 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -193,11 +193,14 @@
 #define OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE   (OWN_ATTR_VALUE_START+102)
 #define OWN_ATTR_SIGNATURELINE_IS_SIGNED(OWN_ATTR_VALUE_START+103)
 #define OWN_ATTR_QRCODE (OWN_ATTR_VALUE_START+104)
-#define OWN_ATTR_TEXTFITTOSIZESCALE (OWN_ATTR_VALUE_START+105)
-#define OWN_ATTR_TEXTCOLUMNS(OWN_ATTR_VALUE_START+106)
-#define OWN_ATTR_HYPERLINK  (OWN_ATTR_VALUE_START+107)
-#define OWN_ATTR_MISC_OBJ_DECORATIVE(OWN_ATTR_VALUE_START+108)
-// ATTENTION: current maximum is OWN_ATTR_VALUE_START+108 svx; when adding 
values, update
+#define OWN_ATTR_TEXTFITTOSIZE_FONT_SCALE   (OWN_ATTR_VALUE_START+105)
+#define OWN_ATTR_TEXTFITTOSIZE_SPACING_SCALE(OWN_ATTR_VALUE_START+106)
+#define OWN_ATTR_TEXTCOLUMNS(OWN_ATTR_VALUE_START+107)
+#define OWN_ATTR_HYPERLINK  (OWN_ATTR_VALUE_START+108)
+#define OWN_ATTR_MISC_OBJ_DECORATIVE(OWN_ATTR_VALUE_START+109)
+
+// ATTENTION: current maximum is OWN_ATTR_VALUE_START+120 svx; when adding 
values, update
+
 // OWN_ATTR_VALUE_END in include/svl/solar.hrc accordingly
 
 // #FontWork#
@@ -366,7 +369,8 @@
 { UNO_NAME_MISC_OBJ_SIZEPROTECT,  SDRATTR_OBJSIZEPROTECT  , 
cppu::UnoType::get(),  0,  0},\
 { u"UINameSingular"_ustr,  OWN_ATTR_UINAME_SINGULAR, 
::cppu::UnoType::get(),

core.git: Branch 'distro/collabora/co-24.04' - editeng/source include/editeng sd/qa sd/source svx/source

2024-04-15 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editeng.cxx  |   28 ++---
 editeng/source/editeng/impedit.hxx  |   41 
 editeng/source/editeng/impedit2.cxx |4 -
 editeng/source/editeng/impedit3.cxx |   57 
 editeng/source/editeng/impedit4.cxx |   12 +++--
 editeng/source/outliner/outlin2.cxx |   15 +++
 editeng/source/outliner/outliner.cxx|   14 ++
 include/editeng/editdata.hxx|   16 +++
 include/editeng/editeng.hxx |8 +--
 include/editeng/outliner.hxx|9 +++-
 sd/qa/unit/TextFittingTest.cxx  |   12 ++---
 sd/source/ui/view/drtxtob.cxx   |2 
 svx/source/svdraw/svdotext.cxx  |   24 ---
 svx/source/svdraw/svdotextdecomposition.cxx |4 +
 svx/source/svdraw/svdoutl.cxx   |2 
 15 files changed, 115 insertions(+), 133 deletions(-)

New commits:
commit 0b816d1eeb877699018f1bddc22003c6309020e6
Author: Tomaž Vajngerl 
AuthorDate: Mon Apr 1 20:12:09 2024 +0900
Commit: Miklos Vajna 
CommitDate: Mon Apr 15 09:20:18 2024 +0200

editeng: combine scaling parameters into ScalingParameters struct

This makes dealing with scaling parameters much clearer and it
improves readability.

Change-Id: I327b6530ef5587972cc0075390704754a33563a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165632
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 4bdbf0f898e8642b0a34195537d1516cc8eee819)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165712
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 260e8dfb5038..35d025c45021 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2265,35 +2265,19 @@ bool EditEngine::HasText( const SvxSearchItem& 
rSearchItem )
 return pImpEditEngine->HasText( rSearchItem );
 }
 
-void EditEngine::setGlobalScale(double fFontScaleX, double fFontScaleY, double 
fSpacingScaleX, double fSpacingScaleY)
+ScalingParameters EditEngine::getScalingParameters() const
 {
-pImpEditEngine->setScale(fFontScaleX, fFontScaleY, fSpacingScaleX, 
fSpacingScaleY);
+return pImpEditEngine->getScalingParameters();
 }
 
-void EditEngine::getGlobalSpacingScale(double& rX, double& rY) const
+void EditEngine::resetScalingParameters()
 {
-pImpEditEngine->getSpacingScale(rX, rY);
+pImpEditEngine->resetScalingParameters();
 }
 
-basegfx::B2DTuple EditEngine::getGlobalSpacingScale() const
+void EditEngine::setScalingParameters(ScalingParameters const& 
rScalingParameters)
 {
-double x = 0.0;
-double y = 0.0;
-pImpEditEngine->getSpacingScale(x, y);
-return {x, y};
-}
-
-void EditEngine::getGlobalFontScale(double& rX, double& rY) const
-{
-pImpEditEngine->getFontScale(rX, rY);
-}
-
-basegfx::B2DTuple EditEngine::getGlobalFontScale() const
-{
-double x = 0.0;
-double y = 0.0;
-pImpEditEngine->getFontScale(x, y);
-return {x, y};
+pImpEditEngine->setScalingParameters(rScalingParameters);
 }
 
 void EditEngine::setRoundFontSizeToPt(bool bRound) const
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 0aabebe2ab46..34d57e8e9747 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -530,10 +530,7 @@ private:
 
 Color   maBackgroundColor;
 
-double mfFontScaleX;
-double mfFontScaleY;
-double mfSpacingScaleX;
-double mfSpacingScaleY;
+ScalingParameters maScalingParameters;
 bool mbRoundToNearestPt;
 
 CharCompressType mnAsianCompressionMode;
@@ -739,34 +736,34 @@ private:
 
 double scaleXSpacingValue(tools::Long nXValue) const
 {
-if (!maStatus.DoStretch() || mfSpacingScaleX == 100.0)
+if (!maStatus.DoStretch() || maScalingParameters.fSpacingX == 100.0)
 return nXValue;
 
-return double(nXValue) * mfSpacingScaleX / 100.0;
+return double(nXValue) * (maScalingParameters.fSpacingX / 100.0);
 }
 
 double scaleYSpacingValue(sal_uInt16 nYValue) const
 {
-if (!maStatus.DoStretch() || mfSpacingScaleY == 100.0)
+if (!maStatus.DoStretch() || maScalingParameters.fSpacingY == 100.0)
 return nYValue;
 
-return double(nYValue) * mfSpacingScaleY / 100.0;
+return double(nYValue) * (maScalingParameters.fSpacingY / 100.0);
 }
 
-double scaleYFontValue(sal_uInt16 nYValue) const
+double scaleXFontValue(tools::Long nXValue) const
 {
-if (!maStatus.DoStretch() || (mfFontScaleY == 100.0))
-return nYValue;
+if (!maStatus.DoStretch() || (maScalingParameters.fFontX == 100.0))
+return nXValue;
 
-return double(nYValue) * mfFontScaleY / 100.0;
+return 

core.git: sc/inc sc/qa sc/source

2024-04-12 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/pivot/PivotTableFormats.hxx   |   14 ++-
 sc/qa/unit/PivotTableFormatsImportExport.cxx |   14 +++
 sc/source/filter/excel/xepivotxml.cxx|   65 +++
 sc/source/filter/excel/xestyle.cxx   |  115 ---
 sc/source/filter/inc/PivotTableFormat.hxx|5 -
 sc/source/filter/inc/xepivotxml.hxx  |1 
 sc/source/filter/inc/xestyle.hxx |8 +
 sc/source/filter/oox/PivotTableFormat.cxx|   15 ++-
 8 files changed, 184 insertions(+), 53 deletions(-)

New commits:
commit fc8dfe5c880ff4f64bf769df3088587d3358b027
Author: Tomaž Vajngerl 
AuthorDate: Fri Apr 12 22:55:47 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Apr 13 03:00:02 2024 +0200

pivot: Export Pivot Table "formats" element(s)

This change adds the "formats" element tree export for a pivot
table. The source are the formats (sc::PivotTableFormats) added to
the pivot table - in the ScDPSaveData class. This are currently set
on import but in the future hopefully those are also set through
the UI.

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

diff --git a/sc/inc/pivot/PivotTableFormats.hxx 
b/sc/inc/pivot/PivotTableFormats.hxx
index 2665c088625c..3a4d12e16479 100644
--- a/sc/inc/pivot/PivotTableFormats.hxx
+++ b/sc/inc/pivot/PivotTableFormats.hxx
@@ -28,6 +28,7 @@ enum class FormatType
 /** Information to make a selection in the pivot table. */
 struct Selection
 {
+bool bSelected = false;
 sal_Int32 nField = 0;
 sal_uInt32 nDataIndex = 0;
 };
@@ -38,8 +39,17 @@ struct Selection
 struct PivotTableFormat
 {
 FormatType eType = FormatType::None;
+
+bool bDataOnly = true;
+bool bLabelOnly = false;
+bool bSelected = false;
+bool bOutline = false;
+std::optional oFieldPosition = std::nullopt;
+
 std::vector aSelections;
 std::shared_ptr pPattern;
+
+std::vector const& getSelections() const { return aSelections; }
 };
 
 /** A holder for a collection of PivotTableFormat */
@@ -50,9 +60,9 @@ class PivotTableFormats
 public:
 void add(PivotTableFormat const& rPivotTableFormat) { 
maFormats.push_back(rPivotTableFormat); }
 
-size_t size() { return maFormats.size(); }
+size_t size() const { return maFormats.size(); }
 
-std::vector const& getVector() { return maFormats; }
+std::vector const& getVector() const { return maFormats; 
}
 };
 }
 
diff --git a/sc/qa/unit/PivotTableFormatsImportExport.cxx 
b/sc/qa/unit/PivotTableFormatsImportExport.cxx
index 3cffe8cbc510..401e190b34f5 100644
--- a/sc/qa/unit/PivotTableFormatsImportExport.cxx
+++ b/sc/qa/unit/PivotTableFormatsImportExport.cxx
@@ -73,6 +73,8 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 
 
createScDoc("xlsx/pivot-table/PivotTableCellFormatsTest_1_DataFieldInRow_RowLabelColor.xlsx");
 assertDocument(*getScDoc());
+saveAndReload("Calc Office Open XML");
+assertDocument(*getScDoc());
 }
 
 CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
@@ -85,6 +87,8 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 createScDoc(
 
"xlsx/pivot-table/PivotTableCellFormatsTest_2_DataFieldInRow_ColumnLabelColor.xlsx");
 assertDocument(*getScDoc());
+saveAndReload("Calc Office Open XML");
+assertDocument(*getScDoc());
 }
 
 CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
@@ -98,6 +102,8 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 createScDoc(
 
"xlsx/pivot-table/PivotTableCellFormatsTest_3_DataFieldInColumn_ColumnLabelColor.xlsx");
 assertDocument(*getScDoc());
+saveAndReload("Calc Office Open XML");
+assertDocument(*getScDoc());
 }
 
 CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
@@ -110,6 +116,8 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 
 
createScDoc("xlsx/pivot-table/PivotTableCellFormatsTest_4_DataFieldInColumn_DataColor.xlsx");
 assertDocument(*getScDoc());
+saveAndReload("Calc Office Open XML");
+assertDocument(*getScDoc());
 }
 
 CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
@@ -124,6 +132,8 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 createScDoc("xlsx/pivot-table//"
 
"PivotTableCellFormatsTest_5_DataFieldInColumnAndTwoRowFields_DataColor.xlsx");
 assertDocument(*getScDoc());
+saveAndReload("Calc Office Open XML");
+assertDocument(*getScDoc());
 }
 
 CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
@@ -137,6 +147,8 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
 createScDoc(
 
"xlsx/pivot-table//PivotTableCellFormatsTest_6_SingleDataFieldInColumn_DataColor.xlsx");
 assertDocument(*getScDoc());
+saveAndReload("Calc Office Open XML");
+assertDocument(*getScDoc());
 }
 
 CPPUNIT_TEST_FIXTURE(ScPivotTableFormatsImportExport,
@@ -154,6 +166,8 @@ 

core.git: sc/CppunitTest_sc_pivottable_formats_import_export_test.mk sc/inc sc/Library_sc.mk sc/Module_sc.mk sc/qa sc/source

2024-04-12 Thread Tomaž Vajngerl (via logerrit)
 sc/CppunitTest_sc_pivottable_formats_import_export_test.mk 
  |   86 ++
 sc/Library_sc.mk   
  |1 
 sc/Module_sc.mk
  |1 
 sc/inc/dpobject.hxx
  |4 
 sc/inc/dpoutput.hxx
  |   16 
 sc/inc/pivot/DPOutLevelData.hxx
  |   65 +
 sc/inc/pivot/PivotTableFormatOutput.hxx
  |  112 +++
 sc/inc/pivot/PivotTableFormats.hxx 
  |   37 -
 sc/qa/unit/PivotTableFormatsImportExport.cxx   
  |  161 
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_1_DataFieldInRow_RowLabelColor.xlsx
   |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_2_DataFieldInRow_ColumnLabelColor.xlsx
|binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_3_DataFieldInColumn_ColumnLabelColor.xlsx
 |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_4_DataFieldInColumn_DataColor.xlsx
|binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_5_DataFieldInColumnAndTwoRowFields_DataColor.xlsx
 |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_6_SingleDataFieldInColumn_DataColor.xlsx
  |binary
 
sc/qa/unit/data/xlsx/pivot-table/PivotTableCellFormatsTest_7_TwoRowTwoColumnFields_DataColor.xlsx
|binary
 sc/source/core/data/PivotTableFormatOutput.cxx 
  |  348 ++
 sc/source/core/data/dpobject.cxx   
  |   14 
 sc/source/core/data/dpoutput.cxx   
  |   99 --
 sc/source/filter/oox/PivotTableFormat.cxx  
  |   21 
 20 files changed, 860 insertions(+), 105 deletions(-)

New commits:
commit c379168711858664baabe7fa482a4c7dd3bc7891
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 11 16:31:32 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Apr 12 08:21:19 2024 +0200

pivot: PivotTableFormatOutput to resolve and set PT cell format

This adds the PivotTableFormatOutput, which main responsibility
is to resolve the reference for which the pivot table format is
set to. It first prepares the format data into such a structure
that it is easier to match with the pivot table fields and data.
Then the pivot table data is filled during the output, where we
remember the cell positions of the pivot table output. The last
step is to resolve the pivot table format references with the
filled data, where the cell formats are applied to the output.

PivotTableFormatsImportExport was added to test the correctnes of
the functionality.

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

diff --git a/sc/CppunitTest_sc_pivottable_formats_import_export_test.mk 
b/sc/CppunitTest_sc_pivottable_formats_import_export_test.mk
new file mode 100644
index ..827137a7d5f9
--- /dev/null
+++ b/sc/CppunitTest_sc_pivottable_formats_import_export_test.mk
@@ -0,0 +1,86 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call 
gb_CppunitTest_CppunitTest,sc_pivottable_formats_import_export_test))
+
+$(eval $(call 
gb_CppunitTest_use_common_precompiled_header,sc_pivottable_formats_import_export_test))
+
+$(eval $(call 
gb_CppunitTest_add_exception_objects,sc_pivottable_formats_import_export_test, \
+sc/qa/unit/PivotTableFormatsImportExport \
+))
+
+$(eval $(call 
gb_CppunitTest_use_externals,sc_pivottable_formats_import_export_test, \
+boost_headers \
+mdds_headers \
+libxml2 \
+))
+
+$(eval $(call 
gb_CppunitTest_use_libraries,sc_pivottable_formats_import_export_test, \
+basegfx \
+comphelper \
+cppu \
+cppuhelper \
+drawinglayer \
+drawinglayercore \
+editeng \
+for \
+forui \
+i18nlangtag \
+msfilter \
+oox \
+sal \
+salhelper \
+sax \
+   

core.git: sc/source

2024-04-11 Thread Tomaž Vajngerl (via logerrit)
 sc/source/core/data/dpsave.cxx |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

New commits:
commit a9504d55782fb6ce1e64d154b4a3197062277425
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 11 16:27:21 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Apr 12 02:28:12 2024 +0200

pivot: remove duplication in ScDPSaveDimension::GetMemberByName

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

diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index ed888eebd737..6e1d5c56f085 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -458,14 +458,14 @@ ScDPSaveMember* 
ScDPSaveDimension::GetExistingMemberByName(const OUString& rName
 
 ScDPSaveMember* ScDPSaveDimension::GetMemberByName(const OUString& rName)
 {
-auto res = maMemberHash.find (rName);
-if (res != maMemberHash.end())
-return res->second.get();
-
-ScDPSaveMember* pNew = new ScDPSaveMember( rName );
-maMemberHash[rName] = std::unique_ptr(pNew);
-maMemberList.push_back( pNew );
-return pNew;
+ScDPSaveMember* pResult = GetExistingMemberByName(rName);
+if (pResult)
+return pResult;
+
+pResult = new ScDPSaveMember(rName);
+maMemberHash[rName] = std::unique_ptr(pResult);
+maMemberList.push_back(pResult);
+return pResult;
 }
 
 void ScDPSaveDimension::SetMemberPosition( const OUString& rName, sal_Int32 
nNewPos )


core.git: 2 commits - sc/inc sc/source

2024-04-11 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/dptabsrc.hxx   |   45 ++---
 sc/inc/pivot/PivotTableFormats.hxx|   14 +
 sc/source/core/data/dpoutput.cxx  |   19 --
 sc/source/core/data/dptabsrc.cxx  |  245 ++
 sc/source/filter/inc/stylesbuffer.hxx |2 
 sc/source/filter/oox/PivotTableFormat.cxx |6 
 sc/source/filter/oox/stylesbuffer.cxx |5 
 7 files changed, 162 insertions(+), 174 deletions(-)

New commits:
commit f61ffdfa1a56b1b1fa1aa4f269477e1d1d475955
Author: Tomaž Vajngerl 
AuthorDate: Tue Apr 9 14:58:58 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Apr 12 00:59:37 2024 +0200

pivot: ScDPSource prefix members

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

diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index 4476966f212a..d9381c40c64a 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -80,33 +80,32 @@ class ScDPSource final : public cppu::WeakImplHelper<
 css::lang::XServiceInfo >
 {
 private:
-ScDPTableData*  pData;  // data source (ScDPObject 
manages its life time)
-rtl::Reference pDimensions; // api objects
-// settings:
+ScDPTableData* mpData; // data source (ScDPObject manages its life time)
+rtl::Reference mpDimensions; // api objects
 
+// settings:
 std::vector maColDims;
 std::vector maRowDims;
 std::vector maDataDims;
 std::vector maPageDims;
 ScDPResultTree maResFilterSet;
 
-boolbColumnGrand;
-boolbRowGrand;
-boolbIgnoreEmptyRows;
-boolbRepeatIfEmpty;
-
-sal_Int32   nDupCount;
-
-// results:
-std::unique_ptr   pResData;   // keep the rest in 
this!
-std::unique_ptr pColResRoot;
-std::unique_ptr pRowResRoot;
-std::unique_ptr[]> 
pColResults;
-std::unique_ptr[]> 
pRowResults;
-std::vector aColLevelList;
-std::vector aRowLevelList;
-boolbResultOverflow;
-boolbPageFiltered;  // set if page field filters 
have been applied to cache table
+bool mbColumnGrand = true;
+bool mbRowGrand = true;
+bool mbIgnoreEmptyRows = false;
+bool mbRepeatIfEmpty = false;
+sal_Int32 mnDupCount = 0;
+
+// results:
+std::unique_ptr mpResultData; // keep the rest in this!
+std::unique_ptr mpColumnResultRoot;
+std::unique_ptr mpRowResultRoot;
+std::unique_ptr[]> 
mpColumnResults;
+std::unique_ptr[]> 
mpRowResults;
+std::vector maColumnLevelList;
+std::vector maRowLevelList;
+bool mbResultOverflow = false;
+bool mbPageFiltered = false; // set if page field filters have been 
applied to cache table
 
 std::optional mpGrandTotalName;
 
@@ -140,8 +139,8 @@ public:
 ScDPSource( ScDPTableData* pD );
 virtual ~ScDPSource() override;
 
-ScDPTableData*  GetData()   { return pData; }
-const ScDPTableData*GetData() const { return pData; }
+ScDPTableData*  GetData()   { return mpData; }
+const ScDPTableData*GetData() const { return mpData; }
 
 const std::optional &
 GetGrandTotalName() const;
@@ -165,7 +164,7 @@ public:
 boolSubTotalAllowed(sal_Int32 nColumn);  //! 
move to ScDPResultData
 
 ScDPDimension* AddDuplicated(std::u16string_view rNewName);
-sal_Int32GetDupCount() const { return nDupCount; }
+sal_Int32 GetDupCount() const { return mnDupCount; }
 
 sal_Int32GetSourceDim(sal_Int32 nDim);
 
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index a4bf4c990d7c..20ddc28a9f99 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -90,29 +90,22 @@ static bool lcl_GetBoolFromAny( const uno::Any& aAny )
 return b.has_value() && *b;
 }
 
-ScDPSource::ScDPSource( ScDPTableData* pD ) :
-pData( pD ),
-bColumnGrand( true ),   // default is true
-bRowGrand( true ),
-bIgnoreEmptyRows( false ),
-bRepeatIfEmpty( false ),
-nDupCount( 0 ),
-bResultOverflow( false ),
-bPageFiltered( false )
+ScDPSource::ScDPSource(ScDPTableData* pData)
+: mpData(pData)
 {
-pData->SetEmptyFlags( bIgnoreEmptyRows, bRepeatIfEmpty );
+mpData->SetEmptyFlags(mbIgnoreEmptyRows, mbRepeatIfEmpty);
 }
 
 ScDPSource::~ScDPSource()
 {
 // free lists
 
-pColResults.reset();
-pRowResults.reset();
+mpColumnResults.reset();
+mpRowResults.reset();
 
-pColResRoot.reset();
-pRowResRoot.reset();
-pResData.reset();
+mpColumnResultRoot.reset();
+

core.git: 2 commits - sc/inc sc/source

2024-04-11 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/dpoutput.hxx  |6 
 sc/source/core/data/dpoutput.cxx |  254 +--
 2 files changed, 147 insertions(+), 113 deletions(-)

New commits:
commit 6d95493690def02b15c28f2ab1c9b5831675b326
Author: Tomaž Vajngerl 
AuthorDate: Tue Apr 2 23:35:10 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Apr 12 00:59:23 2024 +0200

pivot: also set format on a data field within row/column output

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

diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 1da4fccec769..f19f0ff57f7e 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -1095,7 +1095,10 @@ void ScDPOutput::outputColumnHeaders(SCTAB nTab, 
ScDPOutputImpl& rOutputImpl)
 if (mpFormats)
 {
 auto& rColumnField = mpColFields[nField];
-tools::Long nDimension = rColumnField.mnDim;
+tools::Long nDimension = -2;
+if (!rColumnField.mbDataLayout)
+nDimension = rColumnField.mnDim;
+
 for (auto& aFormat : mpFormats->getVector())
 {
 if (aFormat.nField == nDimension && aFormat.nDataIndex == 
nColumnIndex)
@@ -1197,7 +1200,9 @@ void ScDPOutput::outputRowHeader(SCTAB nTab, 
ScDPOutputImpl& rOutputImpl)
 if (mpFormats)
 {
 auto& rRowField = mpRowFields[nField];
-tools::Long nDimension = rRowField.mnDim;
+tools::Long nDimension = -2;
+if (!rRowField.mbDataLayout)
+nDimension = rRowField.mnDim;
 for (auto& aFormat : mpFormats->getVector())
 {
 if (aFormat.nField == nDimension && aFormat.nDataIndex == 
nRowIndex)
commit 81a24b62c72d722fd4a80878300e7ab257ecdcc7
Author: Tomaž Vajngerl 
AuthorDate: Mon Apr 1 22:27:21 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Apr 12 00:59:11 2024 +0200

pivot: split ScDPOutput::Output to multiple methods

Change-Id: Idad1c4652a9d506d0584570e55855b0a9406959a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165684
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index a1087d182bab..01ae4fb1c600 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -43,6 +43,7 @@ namespace com::sun::star::sheet {
 namespace tools { class Rectangle; }
 class ScDocument;
 struct ScDPOutLevelData;
+class ScDPOutputImpl;
 
 class ScDPOutput
 {
@@ -109,6 +110,11 @@ private:
 /// Find row field index from row position in case of compact layout.
 sal_Int32   GetRowFieldCompact(SCCOL nColQuery, SCROW nRowQuery) const;
 
+void outputPageFields(SCTAB nTab);
+void outputColumnHeaders(SCTAB nTab, ScDPOutputImpl& rOutputImpl);
+void outputRowHeader(SCTAB nTab, ScDPOutputImpl& rOutputImpl);
+void outputDataResults(SCTAB nTab);
+
 public:
 ScDPOutput( ScDocument* pD,
 css::uno::Reference< 
css::sheet::XDimensionsSupplier> xSrc,
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index dd5d9d1577bc..1da4fccec769 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -84,17 +84,17 @@ using ::com::sun::star::sheet::DataPilotTableResultData;
 
 struct ScDPOutLevelData
 {
-tools::LongmnDim;
-tools::LongmnHier;
-tools::LongmnLevel;
-tools::LongmnDimPos;
+tools::Long mnDim;
+tools::Long mnHier;
+tools::Long mnLevel;
+tools::Long mnDimPos;
 sal_uInt32 mnSrcNumFmt; /// Prevailing number format used in the source 
data.
-uno::Sequence  maResult;
-OUStringmaName; /// Name is the internal 
field name.
-OUStringmaCaption;  /// Caption is the name 
visible in the output table.
-boolmbHasHiddenMember:1;
-boolmbDataLayout:1;
-boolmbPageDim:1;
+uno::Sequence maResult;
+OUString maName; /// Name is the internal field name.
+OUString maCaption;  /// Caption is the name visible in the output table.
+bool mbHasHiddenMember:1;
+bool mbDataLayout:1;
+bool mbPageDim:1;
 
 ScDPOutLevelData(tools::Long nDim, tools::Long nHier, tools::Long nLevel, 
tools::Long nDimPos, sal_uInt32 nSrcNumFmt, const 
uno::Sequence  ,
OUString aName, OUString aCaption, bool 
bHasHiddenMember, bool bDataLayout, bool bPageDim) :
@@ -107,18 +107,17 @@ struct 

core.git: sc/source

2024-04-11 Thread Tomaž Vajngerl (via logerrit)
 sc/source/core/data/dpoutput.cxx |   76 ++-
 1 file changed, 44 insertions(+), 32 deletions(-)

New commits:
commit 3146d6759869fca4753edefddc503a5a89a42b91
Author: Tomaž Vajngerl 
AuthorDate: Mon Apr 1 22:08:50 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 11 17:13:29 2024 +0200

pivot: un-abbreviate vars. in ScDPOutput::Output

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

diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index d88a320aeac0..dd5d9d1577bc 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -1020,11 +1020,11 @@ void ScDPOutput::Output()
 
 for (size_t nField = 0; nField < mpPageFields.size(); ++nField)
 {
-SCCOL nHdrCol = maStartPos.Col();
-SCROW nHdrRow = maStartPos.Row() + nField + (mbDoFilter ? 1 : 0);
+SCCOL nHeaderCol = maStartPos.Col();
+SCROW nHeaderRow = maStartPos.Row() + nField + (mbDoFilter ? 1 : 0);
 // draw without frame for consistency with filter button:
-FieldCell(nHdrCol, nHdrRow, nTab, mpPageFields[nField], false);
-SCCOL nFldCol = nHdrCol + 1;
+FieldCell(nHeaderCol, nHeaderRow, nTab, mpPageFields[nField], false);
+SCCOL nFieldCol = nHeaderCol + 1;
 
 OUString aPageValue = ScResId(SCSTR_ALL);
 const uno::Sequence& rRes = 
mpPageFields[nField].maResult;
@@ -1037,13 +1037,15 @@ void ScDPOutput::Output()
 aPageValue = rRes[0].Caption;
 }
 else if (n > 1)
+{
 aPageValue = ScResId(SCSTR_MULTIPLE);
+}
 
 ScSetStringParam aParam;
 aParam.setTextInput();
-mpDocument->SetString(nFldCol, nHdrRow, nTab, aPageValue, );
+mpDocument->SetString(nFieldCol, nHeaderRow, nTab, aPageValue, 
);
 
-lcl_SetFrame(mpDocument, nTab, nFldCol,nHdrRow, nFldCol,nHdrRow, 20);
+lcl_SetFrame(mpDocument, nTab, nFieldCol, nHeaderRow, nFieldCol, 
nHeaderRow, 20);
 }
 
 //  data description
@@ -1066,52 +1068,62 @@ void ScDPOutput::Output()
 mnTabStartCol, mnTabStartRow,
 mnDataStartCol, mnDataStartRow, mnTabEndCol, mnTabEndRow);
 size_t nNumColFields = mpColFields.size();
-for (size_t nField=0; nField(nField);   
   //TODO: check for overflow
+SCCOL nHeaderCol = mnDataStartCol + SCCOL(nField); //TODO: check for 
overflow
+
 if (!mbHasCompactRowField || nNumColFields == 1)
-FieldCell(nHdrCol, mnTabStartRow, nTab, mpColFields[nField], true);
+FieldCell(nHeaderCol, mnTabStartRow, nTab, mpColFields[nField], 
true);
 else if (!nField)
-MultiFieldCell(nHdrCol, mnTabStartRow, nTab, false /* bRowField 
*/);
+MultiFieldCell(nHeaderCol, mnTabStartRow, nTab, false /* bRowField 
*/);
 
-SCROW nRowPos = mnMemberStartRow + static_cast(nField); 
   //TODO: check for overflow
+SCROW nRowPos = mnMemberStartRow + SCROW(nField); //TODO: check for 
overflow
 tools::Long nDimension = mpColFields[nField].mnDim;
 const uno::Sequence rSequence = 
mpColFields[nField].maResult;
-const sheet::MemberResult* pArray = rSequence.getConstArray();
+const sheet::MemberResult* pMemberArray = rSequence.getConstArray();
 tools::Long nThisColCount = rSequence.getLength();
-OSL_ENSURE(nThisColCount == mnColCount, "count mismatch"); //TODO: 
???
+OSL_ENSURE(nThisColCount == mnColCount, "count mismatch"); //TODO: ???
+
 tools::Long nColumnIndex = -1;
-for (tools::Long nCol=0; nCol(nCol); 
   //TODO: check for overflow
-HeaderCell( nColPos, nRowPos, nTab, pArray[nCol], true, nField );
-if ( ( pArray[nCol].Flags & sheet::MemberResultFlags::HASMEMBER ) 
&&
-!( pArray[nCol].Flags & sheet::MemberResultFlags::SUBTOTAL ) )
+
+SCCOL nColPos = mnDataStartCol + SCCOL(nColumn); //TODO: check for 
overflow
+HeaderCell(nColPos, nRowPos, nTab, pMemberArray[nColumn], true, 
nField);
+if ((pMemberArray[nColumn].Flags & 
sheet::MemberResultFlags::HASMEMBER) &&
+   !(pMemberArray[nColumn].Flags & 
sheet::MemberResultFlags::SUBTOTAL))
 {
-tools::Long nEnd = nCol;
-while ( nEnd+1 < nThisColCount && ( pArray[nEnd+1].Flags & 
sheet::MemberResultFlags::CONTINUE ) )
+// Check the number of columns this spreads
+tools::Long nEnd = nColumn;
+while (nEnd + 1 < nThisColCount && (pMemberArray[nEnd + 
1].Flags & sheet::MemberResultFlags::CONTINUE))
 ++nEnd;
-SCCOL nEndColPos = mnDataStartCol + static_cast(nEnd);  
   //TODO: check for overflow
-if ( nField+1 < 

core.git: 2 commits - sc/inc sc/Library_scfilt.mk sc/source

2024-04-11 Thread Tomaž Vajngerl (via logerrit)
 sc/Library_scfilt.mk |2 
 sc/inc/dpoutput.hxx  |8 +
 sc/inc/dpsave.hxx|6 
 sc/inc/pivot/PivotTableFormats.hxx   |   48 +++
 sc/source/core/data/dpobject.cxx |8 -
 sc/source/core/data/dpoutput.cxx |   47 +++
 sc/source/core/data/dpsave.cxx   |   18 ++
 sc/source/filter/inc/PivotTableFormat.hxx|  106 
 sc/source/filter/inc/PivotTableFormatContext.hxx |   49 +++
 sc/source/filter/inc/pivottablebuffer.hxx|4 
 sc/source/filter/oox/PivotTableFormat.cxx|  148 +++
 sc/source/filter/oox/PivotTableFormatContext.cxx |   92 ++
 sc/source/filter/oox/pivottablebuffer.cxx|   12 +
 sc/source/filter/oox/pivottablefragment.cxx  |   19 ++
 14 files changed, 559 insertions(+), 8 deletions(-)

New commits:
commit af5bb01b9430b76ae8042b5ce6ebda65798bbb18
Author: Tomaž Vajngerl 
AuthorDate: Tue Mar 12 21:16:20 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 11 17:13:20 2024 +0200

pivot: forward pivot table format data into the pivot table model

The purpuse of this is to lay out the foundation for the support
of pivot table formatting. This adds the code to forward the
formatting information from the OOXML import into the pivot table
model and uses it in a use case to set the row and column labels
in the pivot table output (DPOutput). In the follow up commits the
support will be extended to support more use cases with tests.

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

diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index 9c9c068c603e..a1087d182bab 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -28,6 +28,7 @@
 #include "address.hxx"
 
 #include "dptypes.hxx"
+#include "pivot/PivotTableFormats.hxx"
 
 #include 
 #include 
@@ -64,6 +65,8 @@ private:
 sal_uInt32 mnSingleNumberFormat;
 size_t mnRowDims; // Including empty ones.
 
+std::unique_ptr mpFormats;
+
 // Output geometry related parameters
 sal_Int32 mnColCount;
 sal_Int32 mnRowCount;
@@ -136,6 +139,11 @@ public:
 voidSetHeaderLayout(bool bUseGrid);
 boolGetHeaderLayout() const { return mbHeaderLayout;}
 
+void setFormats(sc::PivotTableFormats const& rPivotTableFormats)
+{
+mpFormats.reset(new sc::PivotTableFormats(rPivotTableFormats));
+}
+
 static void GetDataDimensionNames(
 OUString& rSourceName, OUString& rGivenName,
 const css::uno::Reference< css::uno::XInterface>& xDim );
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index a54da59d57d8..ad1e393dc879 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -45,6 +45,7 @@ namespace com::sun::star::sheet {
 class ScDPDimensionSaveData;
 class ScDPTableData;
 enum class ScGeneralFunction;
+namespace sc { class PivotTableFormats; }
 
 // classes to save Data Pilot settings
 
@@ -253,6 +254,7 @@ private:
  *  created. */
 bool mbDimensionMembersBuilt;
 
+std::unique_ptr mpFormats;
 std::optional mpGrandTotalName;
 mutable std::unique_ptr mpDimOrder; // dimension order for 
row and column dimensions, to traverse result tree.
 
@@ -265,6 +267,10 @@ public:
 
 bool operator== ( const ScDPSaveData& r ) const;
 
+SC_DLLPUBLIC bool hasFormats();
+SC_DLLPUBLIC sc::PivotTableFormats const& getFormats();
+SC_DLLPUBLIC void setFormats(sc::PivotTableFormats const& 
rPivotTableFormats);
+
 SC_DLLPUBLIC void SetGrandTotalName(const OUString& rName);
 SC_DLLPUBLIC const std::optional & GetGrandTotalName() const;
 
diff --git a/sc/inc/pivot/PivotTableFormats.hxx 
b/sc/inc/pivot/PivotTableFormats.hxx
new file mode 100644
index ..09f181e7e178
--- /dev/null
+++ b/sc/inc/pivot/PivotTableFormats.hxx
@@ -0,0 +1,48 @@
+/* -*- 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 
+
+namespace sc
+{
+struct PivotTableFormat
+{
+sal_Int32 nField;
+sal_Int32 nDataIndex;
+OUString aStyleName;
+
+PivotTableFormat(sal_Int32 _nField, sal_Int32 _nDataIndex, OUString 
_aStyleName)
+: nField(_nField)
+, nDataIndex(_nDataIndex)
+, aStyleName(_aStyleName)
+{
+}
+};
+
+class PivotTableFormats
+{
+std::vector maFormats;
+
+public:
+void add(sal_Int32 nField, sal_Int32 nDataIndex, OUString const& rStyle)
+{
+maFormats.emplace_back(nField, 

core.git: editeng/source

2024-04-03 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/ContentNode.cxx |   32 
 1 file changed, 24 insertions(+), 8 deletions(-)

New commits:
commit 5ebe81f068dba0c141ebe92f64731d0c95179dae
Author: Tomaž Vajngerl 
AuthorDate: Mon Mar 25 16:28:39 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 4 04:06:40 2024 +0200

editeng: make it ContentNode::FindFeature clearer

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

diff --git a/editeng/source/editeng/ContentNode.cxx 
b/editeng/source/editeng/ContentNode.cxx
index a02a3fde0d39..08bf250b6c86 100644
--- a/editeng/source/editeng/ContentNode.cxx
+++ b/editeng/source/editeng/ContentNode.cxx
@@ -947,16 +947,20 @@ EditCharAttrib* CharAttribList::FindEmptyAttrib( 
sal_uInt16 nWhich, sal_Int32 nP
 return nullptr;
 }
 
-namespace {
+namespace
+{
 
 class FindByStartPos
 {
 sal_Int32 mnPos;
 public:
-explicit FindByStartPos(sal_Int32 nPos) : mnPos(nPos) {}
-bool operator() (const std::unique_ptr& r) const
+explicit FindByStartPos(sal_Int32 nPos)
+: mnPos(nPos)
+{}
+
+bool operator() (std::unique_ptr const& pCharAttrib) const
 {
-return r->GetStart() >= mnPos;
+return pCharAttrib->GetStart() >= mnPos;
 }
 };
 
@@ -965,16 +969,28 @@ public:
 const EditCharAttrib* CharAttribList::FindFeature( sal_Int32 nPos ) const
 {
 // First, find the first attribute that starts at or after specified 
position.
-AttribsType::const_iterator it =
+AttribsType::const_iterator iterator =
 std::find_if(maAttribs.begin(), maAttribs.end(), FindByStartPos(nPos));
 
-if (it == maAttribs.end())
+if (iterator == maAttribs.end())
+{
 // All attributes are before the specified position.
 return nullptr;
+}
 
 // And find the first attribute with feature.
-it = std::find_if(it, maAttribs.end(), [](const 
std::unique_ptr& aAttrib) { return aAttrib->IsFeature(); } );
-return it == maAttribs.end() ? nullptr : it->get();
+iterator = std::find_if(iterator, maAttribs.end(), [](const 
std::unique_ptr& aAttrib) {
+return aAttrib->IsFeature();
+});
+
+if (iterator == maAttribs.end())
+{
+// Couldn't find the feature
+return nullptr;
+}
+
+// Found
+return iterator->get();
 }
 
 void CharAttribList::DeleteEmptyAttribs()


core.git: editeng/inc editeng/source

2024-04-03 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/EditLine.hxx|  130 ++--
 editeng/source/editeng/EditLine.cxx |   75 +++-
 2 files changed, 106 insertions(+), 99 deletions(-)

New commits:
commit 7f4d31f2d6f37d280ae3e65c86077a7423dff0cc
Author: Tomaž Vajngerl 
AuthorDate: Wed Mar 20 14:15:23 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 4 04:06:20 2024 +0200

editeng: prefix EditLine members, clean-up

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

diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx
index 7d4a43e0e639..46a2379853e6 100644
--- a/editeng/inc/EditLine.hxx
+++ b/editeng/inc/EditLine.hxx
@@ -31,105 +31,107 @@ public:
 typedef std::vector CharPosArrayType;
 
 private:
-CharPosArrayType aPositions;
-std::vector aKashidaPositions;
-sal_Int32 nTxtWidth = 0;
-sal_Int32 nStartPosX = 0;
-sal_Int32 nNextLinePosXDiff = 0;
-sal_Int32 nStart = 0; // could be replaced by nStartPortion
-sal_Int32 nEnd = 0; // could be replaced by nEndPortion
-sal_Int32 nStartPortion = 0;
-sal_Int32 nEndPortion = 0;
-sal_uInt16 nHeight = 0; //  Total height of the line
-sal_uInt16 nTxtHeight = 0; // Pure Text height
-sal_uInt16 nMaxAscent = 0;
-bool bHangingPunctuation : 1 = false;
-bool bInvalid : 1 = true; // for skillful formatting
+CharPosArrayType maPositions;
+std::vector maKashidaPositions;
+sal_Int32 mnTextWidth = 0;
+sal_Int32 mnStartPosX = 0;
+sal_Int32 mnNextLinePosXDiff = 0;
+sal_Int32 mnStart = 0; // could be replaced by nStartPortion
+sal_Int32 mnEnd = 0; // could be replaced by nEndPortion
+sal_Int32 mnStartPortion = 0;
+sal_Int32 mnEndPortion = 0;
+sal_uInt16 mnHeight = 0; //  Total height of the line
+sal_uInt16 mnTextHeight = 0; // Pure Text height
+sal_uInt16 mnMaxAscent = 0;
+bool mbHangingPunctuation : 1 = false;
+bool mbInvalid : 1 = true; // for skillful formatting
 
 public:
 EditLine() = default;
 EditLine(const EditLine& rEditLine)
-: nStart(rEditLine.nStart)
-, nEnd(rEditLine.nEnd)
-, nStartPortion(rEditLine.nStartPortion)
-, nEndPortion(rEditLine.nEndPortion)
-, bHangingPunctuation(rEditLine.bHangingPunctuation)
-, bInvalid(true)
+: mnStart(rEditLine.mnStart)
+, mnEnd(rEditLine.mnEnd)
+, mnStartPortion(rEditLine.mnStartPortion)
+, mnEndPortion(rEditLine.mnEndPortion)
+, mbHangingPunctuation(rEditLine.mbHangingPunctuation)
 {
 }
 
-bool IsIn(sal_Int32 nIndex) const { return ((nIndex >= nStart) && (nIndex 
< nEnd)); }
+bool IsIn(sal_Int32 nIndex) const { return nIndex >= mnStart && nIndex < 
mnEnd; }
 
-bool IsIn(sal_Int32 nIndex, bool bInclEnd) const
+bool IsIn(sal_Int32 nIndex, bool bIncludeEnd) const
 {
-return ((nIndex >= nStart) && (bInclEnd ? (nIndex <= nEnd) : (nIndex < 
nEnd)));
+return nIndex >= mnStart && (bIncludeEnd ? nIndex <= mnEnd : nIndex < 
mnEnd);
 }
 
-void SetStart(sal_Int32 n) { nStart = n; }
-sal_Int32 GetStart() const { return nStart; }
-sal_Int32& GetStart() { return nStart; }
+void SetStart(sal_Int32 nStart) { mnStart = nStart; }
+sal_Int32 GetStart() const { return mnStart; }
+sal_Int32& GetStart() { return mnStart; }
 
-void SetEnd(sal_Int32 n) { nEnd = n; }
-sal_Int32 GetEnd() const { return nEnd; }
-sal_Int32& GetEnd() { return nEnd; }
+void SetEnd(sal_Int32 nEnd) { mnEnd = nEnd; }
+sal_Int32 GetEnd() const { return mnEnd; }
+sal_Int32& GetEnd() { return mnEnd; }
 
-void SetStartPortion(sal_Int32 n) { nStartPortion = n; }
-sal_Int32 GetStartPortion() const { return nStartPortion; }
-sal_Int32& GetStartPortion() { return nStartPortion; }
+void SetStartPortion(sal_Int32 nStartPortion) { mnStartPortion = 
nStartPortion; }
+sal_Int32 GetStartPortion() const { return mnStartPortion; }
+sal_Int32& GetStartPortion() { return mnStartPortion; }
 
-void SetEndPortion(sal_Int32 n) { nEndPortion = n; }
-sal_Int32 GetEndPortion() const { return nEndPortion; }
-sal_Int32& GetEndPortion() { return nEndPortion; }
+void SetEndPortion(sal_Int32 nEndPortion) { mnEndPortion = nEndPortion; }
+sal_Int32 GetEndPortion() const { return mnEndPortion; }
+sal_Int32& GetEndPortion() { return mnEndPortion; }
 
-void SetHeight(sal_uInt16 nH, sal_uInt16 nTxtH = 0);
-sal_uInt16 GetHeight() const { return nHeight; }
-sal_uInt16 GetTxtHeight() const { return nTxtHeight; }
+void SetHeight(sal_uInt16 nHeight, sal_uInt16 nTextHeight = 0);
+sal_uInt16 GetHeight() const { return mnHeight; }
+sal_uInt16 GetTxtHeight() const { return mnTextHeight; }
 
-void SetTextWidth(sal_Int32 n) { nTxtWidth = n; }
-sal_Int32 GetTextWidth() const { 

core.git: 2 commits - editeng/source include/editeng include/svl include/svx oox/inc oox/source sd/qa svx/source

2024-04-02 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/impedit.hxx |9 +
 editeng/source/editeng/impedit2.cxx|   22 +++
 editeng/source/editeng/impedit3.cxx|  124 ++-
 include/editeng/editdata.hxx   |4 
 include/editeng/outliner.hxx   |2 
 include/svl/solar.hrc  |2 
 include/svx/sdtfsitm.hxx   |   13 +-
 include/svx/svdotext.hxx   |6 
 include/svx/unoshprp.hxx   |   16 +-
 oox/inc/drawingml/textbodyproperties.hxx   |1 
 oox/source/drawingml/diagram/diagram.cxx   |   21 ++-
 oox/source/drawingml/textbodypropertiescontext.cxx |5 
 oox/source/token/properties.txt|2 
 sd/qa/unit/TextFittingTest.cxx |   12 -
 sd/qa/unit/data/xml/n593612_0.xml  |4 
 sd/qa/unit/export-tests-ooxml2.cxx |   16 +-
 sd/qa/unit/export-tests-ooxml3.cxx |2 
 sd/qa/unit/import-tests-smartart.cxx   |   15 +-
 sd/qa/unit/import-tests2.cxx   |6 
 svx/source/svdraw/svdattr.cxx  |5 
 svx/source/svdraw/svdotext.cxx |  133 +++--
 svx/source/svdraw/svdotextdecomposition.cxx|4 
 svx/source/svdraw/svdotxed.cxx |2 
 svx/source/unodraw/unoshape.cxx|   48 +--
 24 files changed, 261 insertions(+), 213 deletions(-)

New commits:
commit f61ea135430d7b4a1fac7de1e57a1314fbb1b49e
Author: Tomaž Vajngerl 
AuthorDate: Thu Mar 28 12:30:34 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Apr 3 04:06:50 2024 +0200

editeng: use text scaling that better mimics MSO text scaling

Implement text scaling algorithm that is similar to MSO text
scaling for text boxes for the compatibility purpuse, so that the
Impress slides better match how the PP slides are layed out.

This also moves the implementation into EditEng, where it is
possible to better control how searching for the best scaling
factor is performed without doing additional irrelevant work or
trigger invalidations that should not be triggered.

An additional change is that the paragraph with no content at the
end are ignored, and are not taken into account when determining
the height of the content. This is done for compatibility reasons.

Fix horizontal spacing of tabs - the spacing shouldn't be scaled
and the tab shouldn't include the space at the beginning of the
line.

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

diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index a694196dbade..e09712f74bad 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -571,6 +571,7 @@ private:
 
 Color   maBackgroundColor;
 
+ScalingParameters maCustomScalingParameters;
 ScalingParameters maScalingParameters;
 bool mbRoundToNearestPt;
 
@@ -657,6 +658,7 @@ private:
 voidParaAttribsChanged( ContentNode const * pNode, bool 
bIgnoreUndoCheck = false );
 voidTextModified();
 voidCalcHeight(ParaPortion& rParaPortion);
+bool isInEmptyClusterAtTheEnd(ParaPortion& rParaPortion);
 
 voidInsertUndo( std::unique_ptr pUndo, bool 
bTryMerge = false );
 voidResetUndoManager();
@@ -977,8 +979,11 @@ public:
 
 void SetMinColumnWrapHeight(tools::Long nVal) { mnMinColumnWrapHeight = 
nVal; }
 
-voidFormatDoc();
-voidFormatFullDoc();
+tools::Long FormatParagraphs(o3tl::sorted_vector& 
rRepaintParagraphs);
+void ScaleContentToFitWindow(o3tl::sorted_vector& 
rRepaintParagraphs);
+void FormatDoc();
+void FormatFullDoc();
+
 voidUpdateViews( EditView* pCurView = nullptr );
 voidPaint( ImpEditView* pView, const tools::Rectangle& 
rRect, OutputDevice* pTargetDevice );
 voidPaint(OutputDevice& rOutDev, tools::Rectangle 
aClipRect, Point aStartPos, bool bStripOnly = false, Degree10 nOrientation = 
0_deg10);
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index d3f07cec65ed..da4d851b3315 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -4388,12 +4388,31 @@ tools::Long ImpEditEngine::GetXPos(ParaPortion const& 
rParaPortion, EditLine con
 return nX;
 }
 
+/** Is true if paragraph is in the empty cluster of paragraphs at the end */
+bool ImpEditEngine::isInEmptyClusterAtTheEnd(ParaPortion& rPortion)
+{
+sal_Int32 nPortion = 

core.git: editeng/source include/editeng sd/qa sd/source svx/source

2024-04-01 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editeng.cxx  |   28 ++---
 editeng/source/editeng/impedit.hxx  |   41 
 editeng/source/editeng/impedit2.cxx |4 -
 editeng/source/editeng/impedit3.cxx |   57 
 editeng/source/editeng/impedit4.cxx |   12 +++--
 editeng/source/outliner/outlin2.cxx |   15 +++
 editeng/source/outliner/outliner.cxx|   14 ++
 include/editeng/editdata.hxx|   16 +++
 include/editeng/editeng.hxx |9 +---
 include/editeng/outliner.hxx|9 +++-
 sd/qa/unit/TextFittingTest.cxx  |   12 ++---
 sd/source/ui/dlg/NotesChildWindow.cxx   |2 
 sd/source/ui/view/drtxtob.cxx   |2 
 svx/source/svdraw/svdotext.cxx  |   24 ---
 svx/source/svdraw/svdotextdecomposition.cxx |4 +
 svx/source/svdraw/svdoutl.cxx   |2 
 16 files changed, 116 insertions(+), 135 deletions(-)

New commits:
commit 4bdbf0f898e8642b0a34195537d1516cc8eee819
Author: Tomaž Vajngerl 
AuthorDate: Mon Apr 1 20:12:09 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Apr 2 05:48:41 2024 +0200

editeng: combine scaling parameters into ScalingParameters struct

This makes dealing with scaling parameters much clearer and it
improves readability.

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

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 2493325ac578..7f13edfcf1be 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2229,35 +2229,19 @@ bool EditEngine::HasText( const SvxSearchItem& 
rSearchItem )
 return getImpl().HasText(rSearchItem);
 }
 
-void EditEngine::setGlobalScale(double fFontScaleX, double fFontScaleY, double 
fSpacingScaleX, double fSpacingScaleY)
+ScalingParameters EditEngine::getScalingParameters() const
 {
-getImpl().setScale(fFontScaleX, fFontScaleY, fSpacingScaleX, 
fSpacingScaleY);
+return getImpl().getScalingParameters();
 }
 
-void EditEngine::getGlobalSpacingScale(double& rX, double& rY) const
+void EditEngine::resetScalingParameters()
 {
-getImpl().getSpacingScale(rX, rY);
+getImpl().resetScalingParameters();
 }
 
-basegfx::B2DTuple EditEngine::getGlobalSpacingScale() const
+void EditEngine::setScalingParameters(ScalingParameters const& 
rScalingParameters)
 {
-double x = 0.0;
-double y = 0.0;
-getImpl().getSpacingScale(x, y);
-return {x, y};
-}
-
-void EditEngine::getGlobalFontScale(double& rX, double& rY) const
-{
-getImpl().getFontScale(rX, rY);
-}
-
-basegfx::B2DTuple EditEngine::getGlobalFontScale() const
-{
-double x = 0.0;
-double y = 0.0;
-getImpl().getFontScale(x, y);
-return {x, y};
+getImpl().setScalingParameters(rScalingParameters);
 }
 
 void EditEngine::setRoundFontSizeToPt(bool bRound)
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index cc469fc867a2..a694196dbade 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -571,10 +571,7 @@ private:
 
 Color   maBackgroundColor;
 
-double mfFontScaleX;
-double mfFontScaleY;
-double mfSpacingScaleX;
-double mfSpacingScaleY;
+ScalingParameters maScalingParameters;
 bool mbRoundToNearestPt;
 
 CharCompressType mnAsianCompressionMode;
@@ -781,34 +778,34 @@ private:
 
 double scaleXSpacingValue(tools::Long nXValue) const
 {
-if (!maStatus.DoStretch() || mfSpacingScaleX == 100.0)
+if (!maStatus.DoStretch() || maScalingParameters.fSpacingX == 100.0)
 return nXValue;
 
-return double(nXValue) * mfSpacingScaleX / 100.0;
+return double(nXValue) * (maScalingParameters.fSpacingX / 100.0);
 }
 
 double scaleYSpacingValue(sal_uInt16 nYValue) const
 {
-if (!maStatus.DoStretch() || mfSpacingScaleY == 100.0)
+if (!maStatus.DoStretch() || maScalingParameters.fSpacingY == 100.0)
 return nYValue;
 
-return double(nYValue) * mfSpacingScaleY / 100.0;
+return double(nYValue) * (maScalingParameters.fSpacingY / 100.0);
 }
 
-double scaleYFontValue(sal_uInt16 nYValue) const
+double scaleXFontValue(tools::Long nXValue) const
 {
-if (!maStatus.DoStretch() || (mfFontScaleY == 100.0))
-return nYValue;
+if (!maStatus.DoStretch() || (maScalingParameters.fFontX == 100.0))
+return nXValue;
 
-return double(nYValue) * mfFontScaleY / 100.0;
+return double(nXValue) * (maScalingParameters.fFontX / 100.0);
 }
 
-double scaleXFontValue(tools::Long nXValue) const
+double scaleYFontValue(sal_uInt16 nYValue) const
 {
-if (!maStatus.DoStretch() || 

core.git: vcl/source

2024-04-01 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/filter/igif/gifread.cxx |   34 --
 1 file changed, 16 insertions(+), 18 deletions(-)

New commits:
commit cf01073667147f35758a2bde06aec666fc14898e
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 23 21:20:16 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Apr 1 08:08:57 2024 +0200

vcl: get rid of NO_PENDING define

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

diff --git a/vcl/source/filter/igif/gifread.cxx 
b/vcl/source/filter/igif/gifread.cxx
index cfb4e84f2363..c3151f3274d0 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -25,8 +25,6 @@
 #include 
 #include 
 
-#define NO_PENDING( rStm ) ( ( rStm ).GetError() != ERRCODE_IO_PENDING )
-
 namespace {
 
 enum GIFAction
@@ -263,13 +261,13 @@ bool GIFReader::ReadGlobalHeader()
 boolbRet = false;
 
 auto nRead = rIStm.ReadBytes(pBuf, 6);
-if (nRead == 6 && NO_PENDING(rIStm))
+if (nRead == 6 && (rIStm.GetError() != ERRCODE_IO_PENDING))
 {
 pBuf[ 6 ] = 0;
 if( !strcmp( pBuf, "GIF87a" ) || !strcmp( pBuf, "GIF89a" ) )
 {
 nRead = rIStm.ReadBytes(pBuf, 7);
-if (nRead == 7 && NO_PENDING(rIStm))
+if (nRead == 7 && (rIStm.GetError() != ERRCODE_IO_PENDING))
 {
 sal_uInt8   nAspect;
 sal_uInt8   nRF;
@@ -289,7 +287,7 @@ bool GIFReader::ReadGlobalHeader()
 else
 nBackgroundColor = 0;
 
-if( NO_PENDING( rIStm ) )
+if (rIStm.GetError() != ERRCODE_IO_PENDING)
 bRet = true;
 }
 }
@@ -309,7 +307,7 @@ void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, 
sal_uLong nCount )
 std::unique_ptr pBuf(new sal_uInt8[ nLen ]);
 std::size_t nRead = rIStm.ReadBytes(pBuf.get(), nLen);
 nCount = nRead/3UL;
-if( !(NO_PENDING( rIStm )) )
+if (rIStm.GetError() == ERRCODE_IO_PENDING)
 return;
 
 sal_uInt8* pTmp = pBuf.get();
@@ -347,7 +345,7 @@ bool GIFReader::ReadExtension()
 // Extension-Label
 sal_uInt8 cFunction(0);
 rIStm.ReadUChar( cFunction );
-if( NO_PENDING( rIStm ) )
+if (rIStm.GetError() != ERRCODE_IO_PENDING)
 {
 boolbOverreadDataBlocks = false;
 sal_uInt8 cSize(0);
@@ -365,7 +363,7 @@ bool GIFReader::ReadExtension()
 sal_uInt8 cByte(0);
 rIStm.ReadUChar(cByte);
 
-if ( NO_PENDING( rIStm ) )
+if (rIStm.GetError() != ERRCODE_IO_PENDING)
 {
 nGCDisposalMethod = ( cFlags >> 2) & 7;
 bGCTransparent = ( cFlags & 1 );
@@ -378,7 +376,7 @@ bool GIFReader::ReadExtension()
 // Application extension
 case 0xff :
 {
-if ( NO_PENDING( rIStm ) )
+if (rIStm.GetError() != ERRCODE_IO_PENDING)
 {
 // by default overread this extension
 bOverreadDataBlocks = true;
@@ -406,7 +404,7 @@ bool GIFReader::ReadExtension()
 rIStm.ReadUChar( cByte );
 
 bStatus = ( cByte == 0 );
-bRet = NO_PENDING( rIStm );
+bRet = rIStm.GetError() != ERRCODE_IO_PENDING;
 bOverreadDataBlocks = false;
 
 // Netscape interprets the loop count
@@ -429,7 +427,7 @@ bool GIFReader::ReadExtension()
 rIStm.ReadUInt32( nLogWidth100 ).ReadUInt32( 
nLogHeight100 );
 rIStm.ReadUChar( cByte );
 bStatus = ( cByte == 0 );
-bRet = NO_PENDING( rIStm );
+bRet = rIStm.GetError() != ERRCODE_IO_PENDING;
 bOverreadDataBlocks = false;
 }
 else
@@ -463,7 +461,7 @@ bool GIFReader::ReadExtension()
 
 bRet = false;
 std::size_t nRead = rIStm.ReadBytes(, 1);
-if (NO_PENDING(rIStm) && nRead == 1)
+if (rIStm.GetError() != ERRCODE_IO_PENDING && nRead == 1)
 {
 bRet = true;
 }
@@ -482,7 +480,7 @@ bool GIFReader::ReadLocalHeader()
 boolbRet = false;
 
 std::size_t nRead = rIStm.ReadBytes(pBuf, 9);
-if (NO_PENDING(rIStm) && nRead == 9)
+if (rIStm.GetError() != ERRCODE_IO_PENDING && nRead == 9)
 {
 SvMemoryStream  aMemStm;
 BitmapPalette*  pPal;
@@ -511,7 +509,7 @@ bool GIFReader::ReadLocalHeader()
 // if we could read everything, we will create the local image;
 // if the global 

core.git: vcl/source

2024-04-01 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/filter/ixpm/xpmread.cxx |  213 -
 1 file changed, 93 insertions(+), 120 deletions(-)

New commits:
commit d8ece6a5f56f012ecf1766cc3f68c85706e3b6cb
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 23 20:59:24 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Apr 1 08:08:39 2024 +0200

vcl: remove partial XPM image loading

This removes the code that handles the IO_PENDING and the graphic
"context" handling from XPM image format.

Partial loading of images complicates the image filter life cycle
a lot (many exceptions) and is not really needed so much today as
this was needed in the past. In most cases we load the whole image
in one pass anyway. Even loading from the network should be fast
enough to not cause issues for the user.

Most image filters don't even implement this like PNG and nobody
noticed for many years that this is not supported.

To handle IO_PENDING case it is probably better to load the
bitstream into memory and then load the whole image after that
in one pass. This can also be implemented all inside (Imp)Graphic
in a very straight forward way.

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

diff --git a/vcl/source/filter/ixpm/xpmread.cxx 
b/vcl/source/filter/ixpm/xpmread.cxx
index eca9b50287bd..1ad06483a712 100644
--- a/vcl/source/filter/ixpm/xpmread.cxx
+++ b/vcl/source/filter/ixpm/xpmread.cxx
@@ -52,8 +52,7 @@ namespace {
 enum ReadState
 {
 XPMREAD_OK,
-XPMREAD_ERROR,
-XPMREAD_NEED_MORE
+XPMREAD_ERROR
 };
 
 }
@@ -112,7 +111,7 @@ private:
 public:
 explicit XPMReader(SvStream& rStream);
 
-ReadState ReadXPM(Graphic& rGraphic);
+ReadState ReadXPM(BitmapEx& rBitmapEx);
 };
 
 }
@@ -123,136 +122,122 @@ XPMReader::XPMReader(SvStream& rStream)
 {
 }
 
-ReadState XPMReader::ReadXPM(Graphic& rGraphic)
+ReadState XPMReader::ReadXPM(BitmapEx& rBitmapEx)
 {
-ReadState   eReadState;
-sal_uInt8   cDummy;
+if (!mrStream.good())
+return XPMREAD_ERROR;
 
-// check if we can real ALL
-mrStream.Seek( STREAM_SEEK_TO_END );
-mrStream.ReadUChar( cDummy );
+ReadState eReadState = XPMREAD_ERROR;
 
-// if we could not read all
-// return and wait for new data
-if (mrStream.GetError() != ERRCODE_IO_PENDING)
+mrStream.Seek( mnLastPos );
+mbStatus = true;
+
+if ( mbStatus )
 {
-mrStream.Seek( mnLastPos );
-mbStatus = true;
+mpStringBuf = new sal_uInt8 [ XPMSTRINGBUF ];
+mpTempBuf = new sal_uInt8 [ XPMTEMPBUFSIZE ];
 
+mbStatus = ImplGetString();
 if ( mbStatus )
 {
-mpStringBuf = new sal_uInt8 [ XPMSTRINGBUF ];
-mpTempBuf = new sal_uInt8 [ XPMTEMPBUFSIZE ];
+mnIdentifier = XPMVALUES;   // fetch Bitmap information
+mnWidth = ImplGetULONG( 0 );
+mnHeight = ImplGetULONG( 1 );
+mnColors = ImplGetULONG( 2 );
+mnCpp = ImplGetULONG( 3 );
+}
+if ( mnColors > ( SAL_MAX_UINT32 / ( 4 + mnCpp ) ) )
+mbStatus = false;
+if ( ( mnWidth * mnCpp ) >= XPMSTRINGBUF )
+mbStatus = false;
+//xpms are a minimum of one character (one byte) per pixel, so if the 
file isn't
+//even that long, it's not all there
+if (mrStream.remainingSize() + mnTempAvail < 
static_cast(mnWidth) * mnHeight)
+mbStatus = false;
+if ( mbStatus && mnWidth && mnHeight && mnColors && mnCpp )
+{
+mnIdentifier = XPMCOLORS;
 
-mbStatus = ImplGetString();
-if ( mbStatus )
+for (sal_uLong i = 0; i < mnColors; ++i)
 {
-mnIdentifier = XPMVALUES;   // fetch Bitmap information
-mnWidth = ImplGetULONG( 0 );
-mnHeight = ImplGetULONG( 1 );
-mnColors = ImplGetULONG( 2 );
-mnCpp = ImplGetULONG( 3 );
+if (!ImplGetColor())
+{
+mbStatus = false;
+break;
+}
 }
-if ( mnColors > ( SAL_MAX_UINT32 / ( 4 + mnCpp ) ) )
-mbStatus = false;
-if ( ( mnWidth * mnCpp ) >= XPMSTRINGBUF )
-mbStatus = false;
-//xpms are a minimum of one character (one byte) per pixel, so if 
the file isn't
-//even that long, it's not all there
-if (mrStream.remainingSize() + mnTempAvail < 
static_cast(mnWidth) * mnHeight)
-mbStatus = false;
-if ( mbStatus && mnWidth && mnHeight && mnColors && mnCpp )
+
+if ( mbStatus )
 {
-mnIdentifier = XPMCOLORS;
+// create a 24bit graphic when more as 256 colours 

core.git: 2 commits - vcl/source

2024-03-30 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/filter/ixbm/xbmread.cxx |  170 +++--
 vcl/source/filter/ixpm/xpmread.cxx |  161 +++
 2 files changed, 143 insertions(+), 188 deletions(-)

New commits:
commit c9edd5e543c5c791171a4c40a226bf0f13a24d80
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 23 20:53:30 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Mar 30 15:23:04 2024 +0100

vcl: cleanup XPMReader class - rename members with clearer names

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

diff --git a/vcl/source/filter/ixpm/xpmread.cxx 
b/vcl/source/filter/ixpm/xpmread.cxx
index 918a75d5a7fb..eca9b50287bd 100644
--- a/vcl/source/filter/ixpm/xpmread.cxx
+++ b/vcl/source/filter/ixpm/xpmread.cxx
@@ -61,99 +61,82 @@ enum ReadState
 class BitmapWriteAccess;
 class Graphic;
 
-namespace {
+namespace
+{
 
 class XPMReader : public GraphicReader
 {
 private:
-
-SvStream&   mrIStm;
-Bitmap  maBmp;
-BitmapScopedWriteAccess mpAcc;
-Bitmap  maMaskBmp;
-BitmapScopedWriteAccess mpMaskAcc;
-tools::LongmnLastPos;
-
-sal_uLong   mnWidth;
-sal_uLong   mnHeight;
-sal_uLong   mnColors;
-sal_uInt32  mnCpp;  // characters 
per pix
-boolmbTransparent;
-boolmbStatus;
-sal_uLong   mnStatus;
-sal_uLong   mnIdentifier;
-sal_uInt8   mcThisByte;
-sal_uInt8   mcLastByte;
-sal_uLong   mnTempAvail;
-sal_uInt8*  mpTempBuf;
-sal_uInt8*  mpTempPtr;
+SvStream& mrStream;
+Bitmap maBitmap;
+BitmapScopedWriteAccess mpWriterAccess;
+Bitmap maMaskBitmap;
+BitmapScopedWriteAccess mpMaskWriterAccess;
+sal_uInt64 mnLastPos;
+
+tools::Long mnWidth = 0;
+tools::Long mnHeight = 0;
+sal_uLong mnColors = 0;
+sal_uInt32 mnCpp = 0; // characters per pix
+bool mbTransparent = false;
+bool mbStatus  = true;
+sal_uLong mnStatus = 0;
+sal_uLong mnIdentifier = XPMIDENTIFIER;
+sal_uInt8 mcThisByte = 0;
+sal_uInt8 mcLastByte = 0;
+sal_uLong mnTempAvail = 0;
+sal_uInt8* mpTempBuf = nullptr;
+sal_uInt8* mpTempPtr = nullptr;
 // each key is ( mnCpp )Byte(s)-> ASCII entry assigned to the colour
 // each colordata is
 // 1 Byte   -> 0xFF if colour is transparent
 // 3 Bytes  -> RGB value of the colour
-typedef std::array colordata;
-typedef std::map colormap;
-colormapmaColMap;
-sal_uLong   mnStringSize;
-sal_uInt8*  mpStringBuf;
-sal_uLong   mnParaSize;
-sal_uInt8*  mpPara;
+typedef std::array ColorData;
+typedef std::map ColorMap;
+ColorMap maColMap;
+sal_uLong mnStringSize = 0;
+sal_uInt8* mpStringBuf = nullptr;
+sal_uLong mnParaSize = 0;
+sal_uInt8* mpPara = nullptr;
 
 boolImplGetString();
 boolImplGetColor();
 boolImplGetScanLine( sal_uLong );
-boolImplGetColSub(colordata );
+boolImplGetColSub(ColorData );
 boolImplGetColKey( sal_uInt8 );
-voidImplGetRGBHex(colordata , sal_uLong);
+voidImplGetRGBHex(ColorData , sal_uLong);
 boolImplGetPara( sal_uLong numb );
 static bool ImplCompare(sal_uInt8 const *, sal_uInt8 const *, 
sal_uLong);
 sal_uLong   ImplGetULONG( sal_uLong nPara );
 
 public:
-explicitXPMReader( SvStream& rStm );
+explicit XPMReader(SvStream& rStream);
 
-ReadState   ReadXPM( Graphic& rGraphic );
+ReadState ReadXPM(Graphic& rGraphic);
 };
 
 }
 
-XPMReader::XPMReader(SvStream& rStm)
-: mrIStm(rStm)
-, mnLastPos(rStm.Tell())
-, mnWidth(0)
-, mnHeight(0)
-, mnColors(0)
-, mnCpp(0)
-, mbTransparent(false)
-, mbStatus(true)
-, mnStatus( 0 )
-, mnIdentifier(XPMIDENTIFIER)
-, mcThisByte(0)
-, mcLastByte(0)
-, mnTempAvail(0)
-, mpTempBuf(nullptr)
-, mpTempPtr(nullptr)
-, mnStringSize(0)
-, mpStringBuf(nullptr)
-, mnParaSize(0)
-, mpPara(nullptr)
+XPMReader::XPMReader(SvStream& rStream)
+: mrStream(rStream)
+, mnLastPos(rStream.Tell())
 {
 }
 
-ReadState XPMReader::ReadXPM( Graphic& rGraphic )
+ReadState XPMReader::ReadXPM(Graphic& rGraphic)
 {
 ReadState   eReadState;
 sal_uInt8   cDummy;
 
 // check if we can real ALL
-mrIStm.Seek( STREAM_SEEK_TO_END );
-mrIStm.ReadUChar( cDummy );
+mrStream.Seek( STREAM_SEEK_TO_END );
+

core.git: 2 commits - vcl/inc vcl/source

2024-03-30 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/impgraph.hxx   |1 
 vcl/source/filter/ixbm/xbmread.cxx |  159 +
 vcl/source/gdi/impgraph.cxx|   15 ++-
 3 files changed, 87 insertions(+), 88 deletions(-)

New commits:
commit 95d7b543059be9cbf97fe28b1705be05b54a3b4f
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 23 20:03:02 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Mar 30 15:22:11 2024 +0100

vcl: add resetLastUsed to ImpGraph

We reset the last used member variable in many places in the same
way, so instead of duplicating the implementation, add that to a
method.

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

diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 35542db74641..23d482aded23 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -217,6 +217,7 @@ private:
 bool canReduceMemory() const override;
 bool reduceMemory() override;
 std::chrono::high_resolution_clock::time_point getLastUsed() const 
override;
+void resetLastUsed() const;
 
 public:
 void resetChecksum() { mnChecksum = 0; }
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 42ea57c1a820..57aece29bcd6 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -230,7 +230,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& 
rImpGraphic )
 mpGfxLink = rImpGraphic.mpGfxLink;
 
 maVectorGraphicData = rImpGraphic.maVectorGraphicData;
-maLastUsed = std::chrono::high_resolution_clock::now();
+resetLastUsed();
 
 changeExisting(mnSizeBytes);
 }
@@ -257,7 +257,7 @@ ImpGraphic& ImpGraphic::operator=(ImpGraphic&& rImpGraphic)
 
 rImpGraphic.clear();
 rImpGraphic.mbDummyContext = false;
-maLastUsed = std::chrono::high_resolution_clock::now();
+resetLastUsed();
 
 changeExisting(mnSizeBytes);
 
@@ -1364,7 +1364,7 @@ bool ImpGraphic::ensureAvailable() const
 bResult = pThis->swapIn();
 }
 
-maLastUsed = std::chrono::high_resolution_clock::now();
+resetLastUsed();
 return bResult;
 }
 
@@ -1491,7 +1491,7 @@ bool ImpGraphic::swapIn()
 
 updateFromLoadedGraphic(aGraphic.ImplGetImpGraphic());
 
-maLastUsed = std::chrono::high_resolution_clock::now();
+resetLastUsed();
 bReturn = true;
 }
 else if (mpGfxLink && mpGfxLink->IsNative())
@@ -1522,7 +1522,7 @@ bool ImpGraphic::swapIn()
 updateFromLoadedGraphic(pImpGraphic);
 }
 
-maLastUsed = std::chrono::high_resolution_clock::now();
+resetLastUsed();
 bReturn = true;
 }
 else
@@ -1774,4 +1774,9 @@ std::chrono::high_resolution_clock::time_point 
ImpGraphic::getLastUsed() const
 return maLastUsed;
 }
 
+void ImpGraphic::resetLastUsed() const
+{
+maLastUsed = std::chrono::high_resolution_clock::now();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 023ae9a825218686d444e2cbe770e743f70c73b9
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 23 20:02:11 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Mar 30 15:22:04 2024 +0100

vcl: cleanup and prefixmembers of XBMReader

Change-Id: Ib424c3818a7441f9a1c3a7fb2be2d0a7b9682ee7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165206
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/source/filter/ixbm/xbmread.cxx 
b/vcl/source/filter/ixbm/xbmread.cxx
index 11fded73ffd4..7b475ddab7de 100644
--- a/vcl/source/filter/ixbm/xbmread.cxx
+++ b/vcl/source/filter/ixbm/xbmread.cxx
@@ -45,78 +45,71 @@ enum ReadState
 
 class XBMReader : public GraphicReader
 {
-SvStream&   rIStm;
-Bitmap  aBmp1;
-BitmapScopedWriteAccess pAcc1;
-std::unique_ptr
-pHexTable;
-BitmapColor aWhite;
-BitmapColor aBlack;
-tools::LongnLastPos;
-tools::LongnWidth;
-tools::LongnHeight;
-boolbStatus;
-
-voidInitTable();
-OString FindTokenLine( SvStream* pInStm, const char* pTok1, const 
char* pTok2 );
-int ParseDefine( const char* pDefine );
-voidParseData( SvStream* pInStm, const OString& aLastLine, 
XBMFormat eFormat );
+SvStream& mrStream;
+Bitmap maBitmap;
+BitmapScopedWriteAccess mpWriteAccess;
+std::array mpHexTable = { 0 };
+BitmapColor maWhite;
+BitmapColor maBlack;
+tools::Long mnLastPos = 0;
+tools::Long nWidth = 0;
+tools::Long nHeight = 0;
+bool bStatus = true;
+
+void InitTable();
+OString FindTokenLine(SvStream* pInStm, const char* pTok1, const char* 
pTok2);
+int ParseDefine(const char* pDefine);
+void ParseData(SvStream* pInStm, const OString& aLastLine, XBMFormat 
eFormat);
 
 public:
 

core.git: vcl/CppunitTest_vcl_graphic_test.mk vcl/inc vcl/qa vcl/source

2024-03-30 Thread Tomaž Vajngerl (via logerrit)
 vcl/CppunitTest_vcl_graphic_test.mk  |1 
 vcl/inc/graphic/Manager.hxx  |   67 ++-
 vcl/inc/graphic/MemoryManaged.hxx|  145 
 vcl/inc/impgraph.hxx |   12 +
 vcl/qa/cppunit/GraphicMemoryTest.cxx |  310 +++
 vcl/source/app/svapp.cxx |4 
 vcl/source/gdi/graph.cxx |   30 +--
 vcl/source/gdi/impgraph.cxx  |   93 +++---
 vcl/source/graphic/Manager.cxx   |  286 +---
 9 files changed, 658 insertions(+), 290 deletions(-)

New commits:
commit 324f2e135427f2f24cf7eb9a4fab4aa903329ae5
Author: Tomaž Vajngerl 
AuthorDate: Mon Mar 18 00:17:54 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Mar 30 15:21:10 2024 +0100

vcl: change (graphic) Manager into a general memory manager

Graphic memory manager was changes so that it can work with any
object that implements a specific interface (MemoryManaged). With
this it will be possible to use other objects (that take a lot of
memory) to be managed by the manager. It is also a first step to
move memory managin responsibilities away from Graphic and move
it into the specific objects instead (BitmapEx, Animation and
VectorGraphic).

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

diff --git a/vcl/CppunitTest_vcl_graphic_test.mk 
b/vcl/CppunitTest_vcl_graphic_test.mk
index 6089512f5b5b..33e818e23f05 100644
--- a/vcl/CppunitTest_vcl_graphic_test.mk
+++ b/vcl/CppunitTest_vcl_graphic_test.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,vcl_graphic_test))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,vcl_graphic_test, \
 vcl/qa/cppunit/GraphicTest \
+vcl/qa/cppunit/GraphicMemoryTest \
 vcl/qa/cppunit/GraphicDescriptorTest \
 vcl/qa/cppunit/GraphicFormatDetectorTest \
 vcl/qa/cppunit/GraphicNativeMetadataTest \
diff --git a/vcl/inc/graphic/Manager.hxx b/vcl/inc/graphic/Manager.hxx
index d239f6a8b01d..0a4ee3fbc84d 100644
--- a/vcl/inc/graphic/Manager.hxx
+++ b/vcl/inc/graphic/Manager.hxx
@@ -11,66 +11,51 @@
 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
-#include 
-#include 
 
 #include 
 #include 
 #include 
 #include 
 
-class ImpGraphic;
-
 namespace vcl::graphic
 {
-class Manager final
+class MemoryManaged;
+
+class VCL_DLLPUBLIC MemoryManager final
 {
 private:
+o3tl::sorted_vector maObjectList;
+sal_Int64 mnTotalSize = 0;
 std::mutex maMutex; // instead of SolarMutex because graphics can live 
past vcl main
-o3tl::sorted_vector m_pImpGraphicList;
-std::chrono::seconds mnAllowedIdleTime;
-bool mbSwapEnabled;
-bool mbReducingGraphicMemory;
-sal_Int64 mnMemoryLimit;
-sal_Int64 mnUsedSize;
-Timer maSwapOutTimer;
-
-Manager();
-
-void registerGraphic(const std::shared_ptr& rImpGraphic);
-void loopGraphicsAndSwapOut(std::unique_lock& rGuard, bool 
bDropAll);
 
-DECL_LINK(SwapOutTimerHandler, Timer*, void);
+std::chrono::seconds mnAllowedIdleTime = std::chrono::seconds(1);
+bool mbSwapEnabled = true;
+bool mbReducingGraphicMemory = false;
+sal_Int64 mnMemoryLimit = 10'000'000;
+Timer maSwapOutTimer;
+sal_Int32 mnTimeout = 1'000;
+sal_Int64 mnSmallFrySize = 100'000;
 
-static sal_Int64 getGraphicSizeBytes(const ImpGraphic* pImpGraphic);
-void reduceGraphicMemory(std::unique_lock& rGuard, bool 
bDropAll = false);
+DECL_LINK(ReduceMemoryTimerHandler, Timer*, void);
 
 public:
-static Manager& get();
-
-void dropCache();
-void dumpState(rtl::OStringBuffer& rState);
+MemoryManager();
+void registerObject(MemoryManaged* pObject);
+void unregisterObject(MemoryManaged* pObject);
+void changeExisting(MemoryManaged* pObject, sal_Int64 nNewSize);
 
-void swappedIn(const ImpGraphic* pImpGraphic, sal_Int64 nSizeBytes);
-void swappedOut(const ImpGraphic* pImpGraphic, sal_Int64 nSizeBytes);
+void swappedIn(MemoryManaged* pObject, sal_Int64 nNewSize);
+void swappedOut(MemoryManaged* pObject, sal_Int64 nNewSize);
 
-void changeExisting(const ImpGraphic* pImpGraphic, sal_Int64 nOldSize);
-void unregisterGraphic(ImpGraphic* pImpGraphic);
+static MemoryManager& get();
+o3tl::sorted_vector const& getManagedObjects() { return 
maObjectList; }
+sal_Int64 getTotalSize() { return mnTotalSize; }
 
-std::shared_ptr copy(std::shared_ptr const& 
pImpGraphic);
-std::shared_ptr newInstance();
-std::shared_ptr newInstance(const BitmapEx& rBitmapEx);
-std::shared_ptr newInstance(std::shared_ptr const& 
rLink,
-sal_Int32 nPageIndex = 0);
-std::shared_ptr
-newInstance(const std::shared_ptr& 
rVectorGraphicDataPtr);
-std::shared_ptr newInstance(const Animation& rAnimation);
-std::shared_ptr 

core.git: editeng/source

2024-03-25 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/impedit.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit f3bbb442e2a9482e9a8e951d956baed08a06b944
Author: Tomaž Vajngerl 
AuthorDate: Mon Mar 25 15:35:22 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Mar 25 10:08:18 2024 +0100

editeng: fix unintended duplication of the line

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

diff --git a/editeng/source/editeng/impedit.cxx 
b/editeng/source/editeng/impedit.cxx
index c43bdfca21a1..94d707cf902e 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1603,7 +1603,6 @@ Pair ImpEditView::Scroll( tools::Long ndX, tools::Long 
ndY, ScrollRangeCheck nRa
 // rectangle ...
 maVisDocStartPos = rOutDev.LogicToPixel(maVisDocStartPos);
 maVisDocStartPos = rOutDev.PixelToLogic(maVisDocStartPos);
-maVisDocStartPos = rOutDev.PixelToLogic(maVisDocStartPos);
 tools::Rectangle aRect(maOutputArea);
 
 if (mpOutputWindow)


core.git: vcl/inc vcl/source

2024-03-22 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/impgraph.hxx|3 +--
 vcl/source/gdi/graph.cxx|6 ++
 vcl/source/gdi/impgraph.cxx |   13 -
 3 files changed, 7 insertions(+), 15 deletions(-)

New commits:
commit e83f7b7c84d5345879c5543b78ce6ad2b32dc2bc
Author: Tomaž Vajngerl 
AuthorDate: Sun Mar 17 23:23:41 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Mar 23 03:06:18 2024 +0100

vcl: set "default" type only thorugh a ImpGraphic constructor

and do some more clean-up.

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

diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 9ef10d19061d..707810b9de2e 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -89,7 +89,7 @@ private:
 bool mbPrepared = false;
 
 public:
-ImpGraphic();
+ImpGraphic(bool bDefault = false);
 ImpGraphic( const ImpGraphic& rImpGraphic );
 ImpGraphic( ImpGraphic&& rImpGraphic ) noexcept;
 ImpGraphic( GraphicExternalLink aExternalLink);
@@ -133,7 +133,6 @@ private:
 voidclear();
 
 GraphicType getType() const { return meType;}
-voidsetDefaultType();
 boolisSupportedGraphic() const;
 
 boolisTransparent() const;
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 4c0efa56beba..252ee189b892 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -287,8 +287,7 @@ bool Graphic::IsNone() const
 
 void Graphic::Clear()
 {
-ImplTestRefCount();
-mxImpGraphic->clear();
+mxImpGraphic = std::make_shared();
 }
 
 GraphicType Graphic::GetType() const
@@ -298,8 +297,7 @@ GraphicType Graphic::GetType() const
 
 void Graphic::SetDefaultType()
 {
-ImplTestRefCount();
-mxImpGraphic->setDefaultType();
+mxImpGraphic = std::make_shared(true);
 }
 
 bool Graphic::IsSupportedGraphic() const
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 2c9f03f3a02e..ceb6c111cf7b 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -81,7 +81,8 @@ SvStream* ImpGraphic::getSwapFileStream() const
 return nullptr;
 }
 
-ImpGraphic::ImpGraphic()
+ImpGraphic::ImpGraphic(bool bDefault)
+: meType(bDefault ? GraphicType::Default : GraphicType::NONE)
 {
 }
 
@@ -149,7 +150,7 @@ ImpGraphic::ImpGraphic(GraphicExternalLink 
aGraphicExternalLink)
 
 ImpGraphic::ImpGraphic(const BitmapEx& rBitmapEx)
 : maBitmapEx(rBitmapEx)
-, meType(!rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE)
+, meType(rBitmapEx.IsEmpty() ? GraphicType::NONE : GraphicType::Bitmap)
 {
 }
 
@@ -408,15 +409,9 @@ void ImpGraphic::clear()
 maGraphicExternalLink.msURL.clear();
 }
 
-void ImpGraphic::setDefaultType()
-{
-clear();
-meType = GraphicType::Default;
-}
-
 bool ImpGraphic::isSupportedGraphic() const
 {
-return( meType != GraphicType::NONE );
+return meType != GraphicType::NONE;
 }
 
 bool ImpGraphic::isTransparent() const


core.git: vcl/inc vcl/qa

2024-03-22 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/bitmap/ScanlineTools.hxx |   56 ---
 vcl/qa/cppunit/ScanlineToolsTest.cxx |   42 --
 2 files changed, 98 deletions(-)

New commits:
commit bbfe52997225a2fb387c94462c867d670954b9b4
Author: Tomaž Vajngerl 
AuthorDate: Wed Mar 13 14:51:47 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Mar 22 07:37:52 2024 +0100

vcl: remove 4-bit scanline transformer

We don't use 4-bit bitmap anymore and haven't for a long time.

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

diff --git a/vcl/inc/bitmap/ScanlineTools.hxx b/vcl/inc/bitmap/ScanlineTools.hxx
index 99ce5dc33aae..1b7db0eadffc 100644
--- a/vcl/inc/bitmap/ScanlineTools.hxx
+++ b/vcl/inc/bitmap/ScanlineTools.hxx
@@ -110,60 +110,6 @@ public:
 }
 };
 
-class ScanlineTransformer_4BitPalette final : public ScanlineTransformer
-{
-private:
-sal_uInt8* pData;
-const BitmapPalette& mrPalette;
-sal_uInt32 mnX;
-sal_uInt32 mnShift;
-
-public:
-explicit ScanlineTransformer_4BitPalette(const BitmapPalette& rPalette)
-: pData(nullptr)
-, mrPalette(rPalette)
-, mnX(0)
-, mnShift(0)
-{
-}
-
-virtual void skipPixel(sal_uInt32 nPixel) override
-{
-mnX += nPixel;
-if (nPixel & 1) // is nPixel an odd number
-mnShift ^= 4;
-}
-
-virtual void startLine(sal_uInt8* pLine) override
-{
-pData = pLine;
-mnX = 0;
-mnShift = 4;
-}
-
-virtual Color readPixel() override
-{
-const sal_uInt32 nDataIndex = mnX / 2;
-const sal_uInt8 nIndex((pData[nDataIndex] >> mnShift) & 0x0f);
-mnX++;
-mnShift ^= 4;
-
-if (nIndex < mrPalette.GetEntryCount())
-return mrPalette[nIndex];
-else
-return COL_BLACK;
-}
-
-virtual void writePixel(Color nColor) override
-{
-const sal_uInt32 nDataIndex = mnX / 2;
-const sal_uInt8 nColorIndex = mrPalette.GetBestIndex(nColor);
-pData[nDataIndex] |= (nColorIndex & 0x0f) << mnShift;
-mnX++;
-mnShift ^= 4;
-}
-};
-
 class ScanlineTransformer_1BitPalette final : public ScanlineTransformer
 {
 private:
@@ -215,8 +161,6 @@ std::unique_ptr 
getScanlineTransformer(sal_uInt16 nBits,
 {
 case 1:
 return std::make_unique(rPalette);
-case 4:
-return std::make_unique(rPalette);
 case 8:
 return std::make_unique(rPalette);
 case 24:
diff --git a/vcl/qa/cppunit/ScanlineToolsTest.cxx 
b/vcl/qa/cppunit/ScanlineToolsTest.cxx
index 97233f2692af..afb44a54f005 100644
--- a/vcl/qa/cppunit/ScanlineToolsTest.cxx
+++ b/vcl/qa/cppunit/ScanlineToolsTest.cxx
@@ -20,14 +20,12 @@ class ScanlineToolsTest : public CppUnit::TestFixture
 void ScanlineTransformer_32_ARGB();
 void ScanlineTransformer_24_BGR();
 void ScanlineTransformer_8bit_Palette();
-void ScanlineTransformer_4bit_Palette();
 void ScanlineTransformer_1bit_Palette();
 
 CPPUNIT_TEST_SUITE(ScanlineToolsTest);
 CPPUNIT_TEST(ScanlineTransformer_32_ARGB);
 CPPUNIT_TEST(ScanlineTransformer_24_BGR);
 CPPUNIT_TEST(ScanlineTransformer_8bit_Palette);
-CPPUNIT_TEST(ScanlineTransformer_4bit_Palette);
 CPPUNIT_TEST(ScanlineTransformer_1bit_Palette);
 CPPUNIT_TEST_SUITE_END();
 };
@@ -129,46 +127,6 @@ void ScanlineToolsTest::ScanlineTransformer_8bit_Palette()
 }
 }
 
-void ScanlineToolsTest::ScanlineTransformer_4bit_Palette()
-{
-std::vector aColors{
-Color(10, 250, 120), Color(30, 230, 110), Color(50, 210, 100),
-Color(70, 190, 90),  Color(90, 170, 80),  Color(110, 150, 70),
-};
-
-BitmapPalette aPalette(16);
-for (size_t i = 0; i < aColors.size(); ++i)
-{
-aPalette[i] = aColors[i];
-}
-
-std::unique_ptr pScanlineTransformer
-= vcl::bitmap::getScanlineTransformer(4, aPalette);
-
-std::vector aScanLine(3, 0); // 6 * 0.5 BytesPerPixel
-pScanlineTransformer->startLine(aScanLine.data());
-
-for (Color const& aColor : aColors)
-{
-pScanlineTransformer->writePixel(aColor);
-}
-
-std::vector aExpectedBytes{ 0x01, 0x23, 0x45 };
-
-for (size_t i = 0; i < aScanLine.size(); ++i)
-{
-CPPUNIT_ASSERT_EQUAL(int(aExpectedBytes[i]), int(aScanLine[i]));
-}
-
-pScanlineTransformer->startLine(aScanLine.data());
-
-for (Color const& rColor : aColors)
-{
-Color aColor = pScanlineTransformer->readPixel();
-CPPUNIT_ASSERT_EQUAL(rColor, aColor);
-}
-}
-
 void ScanlineToolsTest::ScanlineTransformer_1bit_Palette()
 {
 std::vector aColors{


core.git: vcl/inc vcl/source

2024-03-21 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/impgraph.hxx|   13 +++---
 vcl/source/gdi/impgraph.cxx |   92 +---
 2 files changed, 35 insertions(+), 70 deletions(-)

New commits:
commit 4dd52211794adc7da2c19cb3defcdef16985c278
Author: Tomaž Vajngerl 
AuthorDate: Tue Mar 12 12:07:33 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Mar 22 05:50:07 2024 +0100

vcl: simplify constructors of ImpGraphic

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

diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 15d68d00157c..9ef10d19061d 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -73,19 +73,20 @@ private:
 std::shared_ptr mpContext;
 std::shared_ptr mpSwapFile;
 std::shared_ptr mpGfxLink;
-GraphicType  meType;
-mutable sal_uLongmnSizeBytes;
-bool mbSwapOut;
-bool mbDummyContext;
 std::shared_ptr maVectorGraphicData;
+
+GraphicType  meType = GraphicType::NONE;
+mutable sal_uLongmnSizeBytes = 0;
+bool mbSwapOut = false;
+bool mbDummyContext = false;
 // cache checksum computation
 mutable BitmapChecksum   mnChecksum = 0;
 
 std::optional mxGraphicID;
 GraphicExternalLink  maGraphicExternalLink;
 
-std::chrono::high_resolution_clock::time_point maLastUsed;
-bool mbPrepared;
+mutable std::chrono::high_resolution_clock::time_point maLastUsed = 
std::chrono::high_resolution_clock::now();
+bool mbPrepared = false;
 
 public:
 ImpGraphic();
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 7150aab6b0e6..2c9f03f3a02e 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -81,13 +81,7 @@ SvStream* ImpGraphic::getSwapFileStream() const
 return nullptr;
 }
 
-ImpGraphic::ImpGraphic() :
-meType  ( GraphicType::NONE ),
-mnSizeBytes ( 0 ),
-mbSwapOut   ( false ),
-mbDummyContext  ( false ),
-maLastUsed (std::chrono::high_resolution_clock::now()),
-mbPrepared  ( false )
+ImpGraphic::ImpGraphic()
 {
 }
 
@@ -98,18 +92,18 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
 , mpContext(rImpGraphic.mpContext)
 , mpSwapFile(rImpGraphic.mpSwapFile)
 , mpGfxLink(rImpGraphic.mpGfxLink)
+, maVectorGraphicData(rImpGraphic.maVectorGraphicData)
 , meType(rImpGraphic.meType)
 , mnSizeBytes(rImpGraphic.mnSizeBytes)
 , mbSwapOut(rImpGraphic.mbSwapOut)
 , mbDummyContext(rImpGraphic.mbDummyContext)
-, maVectorGraphicData(rImpGraphic.maVectorGraphicData)
 , maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
-, maLastUsed (std::chrono::high_resolution_clock::now())
-, mbPrepared (rImpGraphic.mbPrepared)
+, mbPrepared(rImpGraphic.mbPrepared)
 {
-if( rImpGraphic.mpAnimation )
+// Special case for animations
+if (rImpGraphic.mpAnimation)
 {
-mpAnimation = std::make_unique( *rImpGraphic.mpAnimation );
+mpAnimation = std::make_unique(*rImpGraphic.mpAnimation);
 maBitmapEx = mpAnimation->GetBitmapEx();
 }
 }
@@ -122,13 +116,12 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) noexcept
 , mpContext(std::move(rImpGraphic.mpContext))
 , mpSwapFile(std::move(rImpGraphic.mpSwapFile))
 , mpGfxLink(std::move(rImpGraphic.mpGfxLink))
+, maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
 , meType(rImpGraphic.meType)
 , mnSizeBytes(rImpGraphic.mnSizeBytes)
 , mbSwapOut(rImpGraphic.mbSwapOut)
 , mbDummyContext(rImpGraphic.mbDummyContext)
-, maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
 , maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
-, maLastUsed (std::chrono::high_resolution_clock::now())
 , mbPrepared (rImpGraphic.mbPrepared)
 {
 rImpGraphic.clear();
@@ -138,11 +131,7 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic) noexcept
 ImpGraphic::ImpGraphic(std::shared_ptr xGfxLink, sal_Int32 nPageIndex)
 : mpGfxLink(std::move(xGfxLink))
 , meType(GraphicType::Bitmap)
-, mnSizeBytes(0)
 , mbSwapOut(true)
-, mbDummyContext(false)
-, maLastUsed (std::chrono::high_resolution_clock::now())
-, mbPrepared (false)
 {
 maSwapInfo.mbIsTransparent = true;
 maSwapInfo.mbIsAlpha = true;
@@ -152,59 +141,34 @@ ImpGraphic::ImpGraphic(std::shared_ptr xGfxLink, 
sal_Int32 nPageIndex)
 maSwapInfo.mnPageIndex = nPageIndex;
 }
 
-ImpGraphic::ImpGraphic(GraphicExternalLink aGraphicExternalLink) :
-meType  ( GraphicType::Default ),
-mnSizeBytes ( 0 ),
-mbSwapOut   ( false ),
-mbDummyContext  ( false ),
-

core.git: include/vcl vcl/source

2024-03-21 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/bitmapex.hxx   |1 -
 vcl/source/bitmap/BitmapEx.cxx |   17 ++---
 2 files changed, 6 insertions(+), 12 deletions(-)

New commits:
commit 71efd6046488b952f679936ea1c4a415f4989b18
Author: Tomaž Vajngerl 
AuthorDate: Sun Mar 17 22:46:07 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Mar 22 01:48:12 2024 +0100

vcl: remove SetSizePixel from BitmapEx

Makes no sense (and would case serious problems) to set the size
(pixel) from the outside of the BitmapEx.

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

diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index aa2684d14b22..b102ced8ba9b 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -71,7 +71,6 @@ public:
 const AlphaMask &   GetAlphaMask() const { return maAlphaMask; }
 
 const Size& GetSizePixel() const { return maBitmapSize; }
-SAL_DLLPRIVATE void SetSizePixel(const Size& rNewSize);
 
 const Size& GetPrefSize() const { return maBitmap.GetPrefSize(); }
 voidSetPrefSize( const Size& rPrefSize ) { 
maBitmap.SetPrefSize( rPrefSize ); }
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index 4246861679e4..87c500272160 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -63,7 +63,7 @@ BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, 
Size aSize )
 return;
 
 maBitmap = Bitmap(aSize, rBitmapEx.maBitmap.getPixelFormat());
-SetSizePixel(aSize);
+maBitmapSize = aSize;
 if( rBitmapEx.IsAlpha() )
 maAlphaMask = AlphaMask( aSize );
 
@@ -75,7 +75,7 @@ BitmapEx::BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, 
Size aSize )
 BitmapEx::BitmapEx(Size aSize, vcl::PixelFormat ePixelFormat)
 {
 maBitmap = Bitmap(aSize, ePixelFormat);
-SetSizePixel(aSize);
+maBitmapSize = aSize;
 }
 
 BitmapEx::BitmapEx( const OUString& rIconName )
@@ -251,11 +251,6 @@ BitmapChecksum BitmapEx::GetChecksum() const
 return nCrc;
 }
 
-void BitmapEx::SetSizePixel(const Size& rNewSize)
-{
-maBitmapSize = rNewSize;
-}
-
 bool BitmapEx::Invert()
 {
 bool bRet = false;
@@ -294,7 +289,7 @@ bool BitmapEx::Scale( const double& rScaleX, const double& 
rScaleY, BmpScaleFlag
 maAlphaMask.Scale( rScaleX, rScaleY, nScaleFlag );
 }
 
-SetSizePixel(maBitmap.GetSizePixel());
+maBitmapSize = maBitmap.GetSizePixel();
 
 SAL_WARN_IF( !maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != 
maAlphaMask.GetSizePixel(), "vcl",
 "BitmapEx::Scale(): size mismatch for bitmap and alpha 
mask." );
@@ -352,7 +347,7 @@ bool BitmapEx::Rotate( Degree10 nAngle10, const Color& 
rFillColor )
 maAlphaMask.Rotate( nAngle10, COL_ALPHA_TRANSPARENT );
 }
 
-SetSizePixel(maBitmap.GetSizePixel());
+maBitmapSize = maBitmap.GetSizePixel();
 
 SAL_WARN_IF(!maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != 
maAlphaMask.GetSizePixel(), "vcl",
 "BitmapEx::Rotate(): size mismatch for bitmap and alpha 
mask.");
@@ -372,7 +367,7 @@ bool BitmapEx::Crop( const tools::Rectangle& rRectPixel )
 if( bRet && !maAlphaMask.IsEmpty() )
 maAlphaMask.Crop( rRectPixel );
 
-SetSizePixel(maBitmap.GetSizePixel());
+maBitmapSize = maBitmap.GetSizePixel();
 
 SAL_WARN_IF(!maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != 
maAlphaMask.GetSizePixel(), "vcl",
 "BitmapEx::Crop(): size mismatch for bitmap and alpha 
mask.");
@@ -401,7 +396,7 @@ void BitmapEx::Expand( sal_Int32 nDX, sal_Int32 nDY, bool 
bExpandTransparent )
 maAlphaMask.Expand( nDX, nDY,  );
 }
 
-SetSizePixel(maBitmap.GetSizePixel());
+maBitmapSize = maBitmap.GetSizePixel();
 
 SAL_WARN_IF(!maAlphaMask.IsEmpty() && maBitmap.GetSizePixel() != 
maAlphaMask.GetSizePixel(), "vcl",
 "BitmapEx::Expand(): size mismatch for bitmap and alpha 
mask.");


core.git: 2 commits - svx/source

2024-03-21 Thread Tomaž Vajngerl (via logerrit)
 svx/source/core/graphichelper.cxx |  250 --
 1 file changed, 106 insertions(+), 144 deletions(-)

New commits:
commit 397d87b9786bebd1ab76f18b472c731bd9ed7884
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 16 12:02:37 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Mar 22 01:47:57 2024 +0100

svx: graphichelper - organize UNO types

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

diff --git a/svx/source/core/graphichelper.cxx 
b/svx/source/core/graphichelper.cxx
index 314573780e00..e52594b15c31 100644
--- a/svx/source/core/graphichelper.cxx
+++ b/svx/source/core/graphichelper.cxx
@@ -55,20 +55,7 @@
 
 #include 
 
-using namespace css::uno;
-using namespace css::lang;
-using namespace css::graphic;
-using namespace css::ucb;
-using namespace css::beans;
-using namespace css::io;
-using namespace css::document;
-using namespace css::ui::dialogs;
-using namespace css::container;
-using namespace com::sun::star::task;
-
-using namespace sfx2;
-
-namespace drawing = com::sun::star::drawing;
+using namespace css;
 
 namespace
 {
@@ -151,15 +138,15 @@ OUString GraphicHelper::GetImageType(const Graphic& 
rGraphic)
 namespace {
 
 
-bool lcl_ExecuteFilterDialog( const Sequence< PropertyValue >& rPropsForDialog,
-  Sequence< PropertyValue >& rFilterData )
+bool lcl_ExecuteFilterDialog(const uno::Sequence& 
rPropsForDialog,
+ uno::Sequence& rFilterData)
 {
 bool bStatus = false;
 try
 {
-Reference< XExecutableDialog > xFilterDialog(
-comphelper::getProcessServiceFactory()->createInstance( 
"com.sun.star.svtools.SvFilterOptionsDialog" ), UNO_QUERY );
-Reference< XPropertyAccess > xFilterProperties( xFilterDialog, 
UNO_QUERY );
+uno::Reference xFilterDialog(
+comphelper::getProcessServiceFactory()->createInstance( 
"com.sun.star.svtools.SvFilterOptionsDialog" ), uno::UNO_QUERY);
+uno::Reference xFilterProperties( 
xFilterDialog, uno::UNO_QUERY);
 
 if( xFilterDialog.is() && xFilterProperties.is() )
 {
@@ -167,7 +154,7 @@ bool lcl_ExecuteFilterDialog( const Sequence< PropertyValue 
>& rPropsForDialog,
 if( xFilterDialog->execute() )
 {
 bStatus = true;
-const Sequence< PropertyValue > aPropsFromDialog = 
xFilterProperties->getPropertyValues();
+const uno::Sequence aPropsFromDialog = 
xFilterProperties->getPropertyValues();
 for ( const auto& rProp : aPropsFromDialog )
 {
 if (rProp.Name == "FilterData")
@@ -178,19 +165,19 @@ bool lcl_ExecuteFilterDialog( const Sequence< 
PropertyValue >& rPropsForDialog,
 }
 }
 }
-catch( const NoSuchElementException& e )
+catch (container::NoSuchElementException const& exception)
 {
 // the filter name is unknown
-throw ErrorCodeIOException(
+throw task::ErrorCodeIOException(
 ("lcl_ExecuteFilterDialog: NoSuchElementException"
- " \"" + e.Message + "\": ERRCODE_IO_ABORT"),
-Reference< XInterface >(), 
sal_uInt32(ERRCODE_IO_INVALIDPARAMETER));
+ " \"" + exception.Message + "\": ERRCODE_IO_ABORT"),
+uno::Reference(), 
sal_uInt32(ERRCODE_IO_INVALIDPARAMETER));
 }
-catch( const ErrorCodeIOException& )
+catch (const task::ErrorCodeIOException&)
 {
 throw;
 }
-catch( const Exception& )
+catch (const uno::Exception&)
 {
 TOOLS_WARN_EXCEPTION("sfx.doc", "ignoring");
 }
@@ -201,11 +188,11 @@ bool lcl_ExecuteFilterDialog( const Sequence< 
PropertyValue >& rPropsForDialog,
 
 OUString GraphicHelper::ExportGraphic(weld::Window* pParent, const Graphic& 
rGraphic, const OUString& rGraphicName)
 {
-FileDialogHelper 
aDialogHelper(TemplateDescription::FILESAVE_AUTOEXTENSION, 
FileDialogFlags::NONE, pParent);
-Reference < XFilePicker3 > xFilePicker = aDialogHelper.GetFilePicker();
+sfx2::FileDialogHelper 
aDialogHelper(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, 
FileDialogFlags::NONE, pParent);
+uno::Reference xFilePicker = 
aDialogHelper.GetFilePicker();
 
 // fish out the graphic's name
-aDialogHelper.SetContext(FileDialogHelper::ExportImage);
+aDialogHelper.SetContext(sfx2::FileDialogHelper::ExportImage);
 aDialogHelper.SetTitle( SvxResId(RID_SVXSTR_EXPORT_GRAPHIC_TITLE));
 INetURLObject aURL;
 aURL.SetSmartURL( rGraphicName );
@@ -287,16 +274,17 @@ OUString GraphicHelper::ExportGraphic(weld::Window* 
pParent, const Graphic& rGra
 if ( rGraphic.GetType() == GraphicType::Bitmap )
 {
 Graphic aGraphic = rGraphic;
-Reference xGraphic = aGraphic.GetXGraphic();
+

core.git: include/vcl sd/source solenv/clang-format vcl/Library_vcl.mk vcl/source

2024-03-20 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/bitmap.hxx|   20 --
 include/vcl/bitmap/Vectorizer.hxx |   43 +++
 sd/source/ui/dlg/vectdlg.cxx  |   16 +++
 solenv/clang-format/excludelist   |4 +-
 vcl/Library_vcl.mk|2 -
 vcl/source/bitmap/Vectorizer.cxx  |   52 +++---
 vcl/source/bitmap/bitmap.cxx  |6 
 7 files changed, 77 insertions(+), 66 deletions(-)

New commits:
commit 3ad680135c8852c896ec7ed7b8ff63fd63ed0621
Author: Tomaž Vajngerl 
AuthorDate: Fri Mar 1 15:36:19 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Mar 20 11:17:52 2024 +0100

vcl: move Vectorize out of Bitmap - add Vectorizer class

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

diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index dbe8a364f712..24cc1245e1f5 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -503,26 +503,6 @@ public:
 size_t nColorCount,
 sal_uInt8 const * pTols );
 
-/** Convert the bitmap to a meta file
-
-This works by putting continuous areas of the same color into
-polygons painted in this color, by tracing the area's bounding
-line.
-
-@param rMtf
-The resulting meta file
-
-@param cReduce
-If non-null, minimal size of bound rects for individual polygons. 
Smaller ones are ignored.
-
-@param pProgress
-A callback for showing the progress of the vectorization
- */
-voidVectorize(
-GDIMetaFile& rMtf,
-sal_uInt8 cReduce,
-const Link* pProgress );
-
 /** Change various global color characteristics
 
 @param nLuminancePercent
diff --git a/vcl/source/bitmap/impvect.hxx b/include/vcl/bitmap/Vectorizer.hxx
similarity index 51%
rename from vcl/source/bitmap/impvect.hxx
rename to include/vcl/bitmap/Vectorizer.hxx
index 257d1b5e5a87..225d924233ae 100644
--- a/vcl/source/bitmap/impvect.hxx
+++ b/include/vcl/bitmap/Vectorizer.hxx
@@ -19,14 +19,47 @@
 
 #pragma once
 
-#include 
+#include 
 
-namespace tools { class PolyPolygon; }
+class GDIMetaFile;
+class BitmapEx;
 
-namespace ImplVectorizer
+namespace vcl
 {
-bool ImplVectorize( const Bitmap& rColorBmp, GDIMetaFile& rMtf,
-sal_uInt8 cReduce, const Link* 
pProgress );
+
+/** Convert the bitmap to a meta file
+ *
+ * This works by putting continuous areas of the same color into
+ * polygons painted in this color, by tracing the area's bounding
+ * line.
+ *
+ * @param rMetafile
+ * The resulting meta file
+ *
+ */
+class VCL_DLLPUBLIC Vectorizer
+{
+private:
+/** If not 0, minimal size of bound rects for individual polygons. Smaller 
ones are ignored. */
+sal_uInt8 mnReduce = 0;
+/** A callback for showing the progress of the vectorization */
+Link const* mpProgress = nullptr;
+
+public:
+Vectorizer(sal_uInt8 nReduce)
+: mnReduce(nReduce)
+{}
+
+bool vectorize(BitmapEx const& rBitmap, GDIMetaFile& rMetafile);
+
+void setProgressCallback(const Link* pProgress)
+{
+mpProgress = pProgress;
+}
+
+void updateProgress(tools::Long nProgress);
 };
 
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/dlg/vectdlg.cxx b/sd/source/ui/dlg/vectdlg.cxx
index 92961bb432a9..3ef7aa9ac494 100644
--- a/sd/source/ui/dlg/vectdlg.cxx
+++ b/sd/source/ui/dlg/vectdlg.cxx
@@ -19,6 +19,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -132,18 +133,21 @@ void SdVectorizeDlg::Calculate( Bitmap const & rBmp, 
GDIMetaFile& rMtf )
 m_pDocSh->SetWaitCursor( true );
 m_xPrgs->set_percentage(0);
 
-FractionaScale;
-Bitmap  aTmp( GetPreparedBitmap( rBmp, aScale ) );
+Fraction aScale;
+BitmapEx aBitmapEx(GetPreparedBitmap(rBmp, aScale));
 
-if( !aTmp.IsEmpty() )
+if (!aBitmapEx.IsEmpty())
 {
 const Link<::tools::Long,void> aPrgsHdl( LINK( this, SdVectorizeDlg, 
ProgressHdl ) );
-aTmp.Vectorize( rMtf, 
static_cast(m_xMtReduce->get_value(FieldUnit::NONE)),  );
+sal_uInt8 nReduce = sal_uInt8(m_xMtReduce->get_value(FieldUnit::NONE));
+vcl::Vectorizer aVecotrizer(nReduce);
+aVecotrizer.vectorize(aBitmapEx, rMtf);
+aVecotrizer.setProgressCallback();
 
 if (m_xCbFillHoles->get_active())
 {
-GDIMetaFile aNewMtf;
-BitmapScopedReadAccesspRAcc(aTmp);
+GDIMetaFile aNewMtf;
+BitmapScopedReadAccess pRAcc(aBitmapEx.GetBitmap());
 
 if( pRAcc )
 {
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 

core.git: 2 commits - sc/inc sc/source

2024-03-12 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/dpobject.hxx  |   56 ++--
 sc/inc/dpsave.hxx|   40 +-
 sc/source/core/data/dpobject.cxx |  542 +++
 sc/source/core/data/dpsave.cxx   |  148 +-
 4 files changed, 388 insertions(+), 398 deletions(-)

New commits:
commit 1f93803aa1fdca7ac83f4801b8a6e866908a3bd8
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 9 12:23:33 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Mar 13 00:47:33 2024 +0100

sc: prefix members of ScDPSaveData

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

diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 70937b48a57f..a54da59d57d8 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -240,14 +240,14 @@ public:
 private:
 DimsType m_DimList;
 DupNameCountType maDupNameCounts; /// keep track of number of duplicates 
in each name.
-std::unique_ptr pDimensionData; // settings that 
create new dimensions
-sal_uInt16 nColumnGrandMode;
-sal_uInt16 nRowGrandMode;
-sal_uInt16 nIgnoreEmptyMode;
-sal_uInt16 nRepeatEmptyMode;
-bool bFilterButton; // not passed to DataPilotSource
-bool bDrillDown; // not passed to DataPilotSource
-bool bExpandCollapse; // not passed to DataPilotSource
+std::unique_ptr mpDimensionData; // settings that 
create new dimensions
+sal_uInt16 mnColumnGrandMode;
+sal_uInt16 mnRowGrandMode;
+sal_uInt16 mnIgnoreEmptyMode;
+sal_uInt16 mnRepeatEmptyMode;
+bool mbFilterButton; // not passed to DataPilotSource
+bool mbDrillDown; // not passed to DataPilotSource
+bool mbExpandCollapse; // not passed to DataPilotSource
 
 /** if true, all dimensions already have all of their member instances
  *  created. */
@@ -320,38 +320,30 @@ public:
 
 void SetPosition( ScDPSaveDimension* pDim, tools::Long nNew );
 SC_DLLPUBLIC void SetColumnGrand( bool bSet );
-bool GetColumnGrand() const
-{ return bool(nColumnGrandMode); }
+bool GetColumnGrand() const { return bool(mnColumnGrandMode); }
 
 SC_DLLPUBLIC void SetRowGrand( bool bSet );
-bool GetRowGrand() const
-{ return bool(nRowGrandMode); }
+bool GetRowGrand() const { return bool(mnRowGrandMode); }
 
 SC_DLLPUBLIC void SetIgnoreEmptyRows( bool bSet );
-bool GetIgnoreEmptyRows() const
-{ return bool(nIgnoreEmptyMode); }
+bool GetIgnoreEmptyRows() const { return bool(mnIgnoreEmptyMode); }
 
 SC_DLLPUBLIC void SetRepeatIfEmpty( bool bSet );
-bool GetRepeatIfEmpty() const
-{ return bool(nRepeatEmptyMode); }
+bool GetRepeatIfEmpty() const { return bool(mnRepeatEmptyMode); }
 
 SC_DLLPUBLIC void SetFilterButton( bool bSet );
-bool GetFilterButton() const
-{ return bFilterButton; }
+bool GetFilterButton() const { return mbFilterButton; }
 
 SC_DLLPUBLIC void SetDrillDown( bool bSet );
-bool GetDrillDown() const
-{ return bDrillDown; }
+bool GetDrillDown() const { return mbDrillDown; }
 
 SC_DLLPUBLIC void SetExpandCollapse( bool bSet );
-bool GetExpandCollapse() const
-{ return bExpandCollapse; }
+bool GetExpandCollapse() const { return mbExpandCollapse; }
 
 void WriteToSource( const 
css::uno::Reference& xSource );
 bool IsEmpty() const;
 
-const ScDPDimensionSaveData* GetExistingDimensionData() const
-{ return pDimensionData.get(); }
+const ScDPDimensionSaveData* GetExistingDimensionData() const { return 
mpDimensionData.get(); }
 
 void RemoveAllGroupDimensions( const OUString& rSrcDimName, 
std::vector* pDeletedNames = nullptr );
 
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index b7e00fb898a6..a872a6385475 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -687,74 +687,74 @@ void ScDPSaveDimension::Dump(int nIndent) const
 
 #endif
 
-ScDPSaveData::ScDPSaveData() :
-nColumnGrandMode( SC_DPSAVEMODE_DONTKNOW ),
-nRowGrandMode( SC_DPSAVEMODE_DONTKNOW ),
-nIgnoreEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
-nRepeatEmptyMode( SC_DPSAVEMODE_DONTKNOW ),
-bFilterButton( true ),
-bDrillDown( true ),
-bExpandCollapse( false ),
-mbDimensionMembersBuilt(false)
-{
-}
-
-ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
-nColumnGrandMode( r.nColumnGrandMode ),
-nRowGrandMode( r.nRowGrandMode ),
-nIgnoreEmptyMode( r.nIgnoreEmptyMode ),
-nRepeatEmptyMode( r.nRepeatEmptyMode ),
-bFilterButton( r.bFilterButton ),
-bDrillDown( r.bDrillDown ),
-bExpandCollapse( r.bExpandCollapse ),
-mbDimensionMembersBuilt(r.mbDimensionMembersBuilt),
-mpGrandTotalName(r.mpGrandTotalName)
-{
-if ( r.pDimensionData )
-pDimensionData.reset( new ScDPDimensionSaveData( *r.pDimensionData ) );
-
-for (auto const& it : r.m_DimList)
+ScDPSaveData::ScDPSaveData()
+: 

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

2024-03-07 Thread Tomaž Vajngerl (via logerrit)
 sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 2bf9246a0388c1d3002f4fa90ba759d7d119cdbf
Author: Tomaž Vajngerl 
AuthorDate: Thu Feb 29 23:51:26 2024 +0900
Commit: Christian Lohmaier 
CommitDate: Thu Mar 7 12:12:19 2024 +0100

tdf#83720 Pivot Table: Data field should always at last place

In the pivot table dialog we should always put the "Data" field to
the last place or the cell formats won't be shown correct in the
pivot table.

Change-Id: If4befe4fff1e6f04d9b709615a1955e3b5f4b4cc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164161
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 78065e3798439dd790d1be5ac5c219477285c888)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164126
Reviewed-by: Christian Lohmaier 

diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx 
b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
index 45af29a4f1a4..672de9559c4e 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
@@ -67,6 +67,9 @@ void 
ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
 std::unique_ptr xEachEntry(mxControl->make_iterator());
 if (!mxControl->get_iter_first(*xEachEntry))
 return;
+
+std::optional oDataField;
+
 do
 {
 ScItemValue* pItemValue = 
weld::fromId(mxControl->get_id(*xEachEntry));
@@ -78,8 +81,15 @@ void 
ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
 aField.nFuncMask = rFunctionData.mnFuncMask;
 aField.mnDupCount= rFunctionData.mnDupCount;
 aField.maFieldRef= rFunctionData.maFieldRef;
-rVector.push_back(aField);
+
+if (aField.nCol == PIVOT_DATA_FIELD)
+oDataField = aField;
+else
+rVector.push_back(aField);
 } while (mxControl->iter_next(*xEachEntry));
+
+if (oDataField)
+rVector.push_back(*oDataField);
 }
 
 void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(weld::TreeView& 
/*pSource*/, int /*nTarget*/)


core.git: sc/source

2024-02-29 Thread Tomaž Vajngerl (via logerrit)
 sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

New commits:
commit 78065e3798439dd790d1be5ac5c219477285c888
Author: Tomaž Vajngerl 
AuthorDate: Thu Feb 29 23:51:26 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Mar 1 02:14:39 2024 +0100

tdf#83720 Pivot Table: Data field should always at last place

In the pivot table dialog we should always put the "Data" field to
the last place or the cell formats won't be shown correct in the
pivot table.

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

diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx 
b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
index 45af29a4f1a4..672de9559c4e 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListBase.cxx
@@ -67,6 +67,9 @@ void 
ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
 std::unique_ptr xEachEntry(mxControl->make_iterator());
 if (!mxControl->get_iter_first(*xEachEntry))
 return;
+
+std::optional oDataField;
+
 do
 {
 ScItemValue* pItemValue = 
weld::fromId(mxControl->get_id(*xEachEntry));
@@ -78,8 +81,15 @@ void 
ScPivotLayoutTreeListBase::PushEntriesToPivotFieldVector(ScPivotFieldVector
 aField.nFuncMask = rFunctionData.mnFuncMask;
 aField.mnDupCount= rFunctionData.mnDupCount;
 aField.maFieldRef= rFunctionData.maFieldRef;
-rVector.push_back(aField);
+
+if (aField.nCol == PIVOT_DATA_FIELD)
+oDataField = aField;
+else
+rVector.push_back(aField);
 } while (mxControl->iter_next(*xEachEntry));
+
+if (oDataField)
+rVector.push_back(*oDataField);
 }
 
 void ScPivotLayoutTreeListBase::InsertEntryForSourceTarget(weld::TreeView& 
/*pSource*/, int /*nTarget*/)


core.git: include/vcl vcl/headless vcl/qt5 vcl/quartz vcl/skia vcl/source vcl/win

2024-02-29 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/BitmapBuffer.hxx|3 +
 include/vcl/BitmapInfoAccess.hxx|4 +-
 include/vcl/BitmapReadAccess.hxx|2 -
 include/vcl/Scanline.hxx|   50 +--
 include/vcl/cairo.hxx   |   12 +++
 vcl/headless/BitmapHelper.cxx   |7 ++--
 vcl/headless/CairoCommon.cxx|   23 +-
 vcl/headless/svpbmp.cxx |   10 +++---
 vcl/qt5/QtBitmap.cxx|   11 +++---
 vcl/quartz/salbmp.cxx   |   12 +++
 vcl/skia/salbmp.cxx |   14 
 vcl/source/bitmap/BitmapReadAccess.cxx  |8 ++---
 vcl/source/bitmap/BitmapWriteAccess.cxx |   12 +++
 vcl/source/bitmap/bmpfast.cxx   |   51 ++--
 vcl/source/bitmap/salbmp.cxx|4 +-
 vcl/source/filter/webp/reader.cxx   |6 +--
 vcl/source/gdi/salmisc.cxx  |   23 ++
 vcl/source/helper/canvasbitmap.cxx  |2 -
 vcl/win/gdi/salbmp.cxx  |   22 ++---
 vcl/win/gdi/salgdi2.cxx |   16 +-
 20 files changed, 139 insertions(+), 153 deletions(-)

New commits:
commit 6588c30ed4477627b2623560ca867682b189bc80
Author: Tomaž Vajngerl 
AuthorDate: Mon Feb 26 21:45:35 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Feb 29 16:12:18 2024 +0100

vcl: separate scanline direction from ScanlineFormat

ScanlineFormat enum is used to indicate 2 things - scanline format
type and scanline direction (TopDown or BottomUp). This makes it
complex to manipulate with (using bit arithmetics) and hard to use
in general for no benefit, so this commit separates direction out
from the ScanlineFormat into ScanlineDirection enum. ScanlineFormat
is now just a simple enum class (not a bit field).

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

diff --git a/include/vcl/BitmapBuffer.hxx b/include/vcl/BitmapBuffer.hxx
index aed62ea6b6a4..a9e91c54505f 100644
--- a/include/vcl/BitmapBuffer.hxx
+++ b/include/vcl/BitmapBuffer.hxx
@@ -39,7 +39,8 @@ struct VCL_DLLPUBLIC BitmapBuffer
 tools::Long mnScanlineSize;
 BitmapPalette   maPalette;
 sal_uInt8*  mpBits;
-ScanlineFormat  mnFormat;
+ScanlineFormat  meFormat = ScanlineFormat::NONE;
+ScanlineDirection meDirection = ScanlineDirection::BottomUp;
 ColorMask   maColorMask;
 sal_uInt16  mnBitCount;
 };
diff --git a/include/vcl/BitmapInfoAccess.hxx b/include/vcl/BitmapInfoAccess.hxx
index 7ded0c9a95da..f3ac582b6a16 100644
--- a/include/vcl/BitmapInfoAccess.hxx
+++ b/include/vcl/BitmapInfoAccess.hxx
@@ -52,7 +52,7 @@ public:
 {
 assert(mpBuffer && "Access is not valid!");
 
-return mpBuffer && (mpBuffer->mnFormat & ScanlineFormat::TopDown);
+return mpBuffer && mpBuffer->meDirection == ScanlineDirection::TopDown;
 }
 
 bool IsBottomUp() const { return !IsTopDown(); }
@@ -61,7 +61,7 @@ public:
 {
 assert(mpBuffer && "Access is not valid!");
 
-return mpBuffer ? RemoveScanline(mpBuffer->mnFormat) : 
ScanlineFormat::NONE;
+return mpBuffer ? mpBuffer->meFormat : ScanlineFormat::NONE;
 }
 
 sal_uInt32 GetScanlineSize() const
diff --git a/include/vcl/BitmapReadAccess.hxx b/include/vcl/BitmapReadAccess.hxx
index 5a99adb56bba..0227e4d1df4d 100644
--- a/include/vcl/BitmapReadAccess.hxx
+++ b/include/vcl/BitmapReadAccess.hxx
@@ -49,7 +49,7 @@ public:
 assert(mpBuffer && "Access is not valid!");
 assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
 
-if (mpBuffer->mnFormat & ScanlineFormat::TopDown)
+if (mpBuffer->meDirection == ScanlineDirection::TopDown)
 {
 return mpBuffer->mpBits + (nY * mpBuffer->mnScanlineSize);
 }
diff --git a/include/vcl/Scanline.hxx b/include/vcl/Scanline.hxx
index fbf8cfce1fd7..2e47ad025379 100644
--- a/include/vcl/Scanline.hxx
+++ b/include/vcl/Scanline.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_SCANLINE_HXX
-#define INCLUDED_VCL_SCANLINE_HXX
+#pragma once
 
 #include 
 #include 
@@ -26,35 +25,28 @@
 typedef sal_uInt8*Scanline;
 typedef const sal_uInt8*  ConstScanline;
 
-enum class ScanlineFormat {
-NONE  = 0x,
-
-N1BitMsbPal   = 0x0001,
-
-N8BitPal  = 0x0010,
-
-N24BitTcBgr   = 0x0100,
-N24BitTcRgb   = 0x0200,
-
-N32BitTcAbgr  = 0x0800,
-N32BitTcArgb  = 0x1000,
-N32BitTcBgra  = 0x2000,
-N32BitTcRgba  = 0x4000,
-N32BitTcMask  = 0x8000,
-
-TopDown   = 0x0001 // scanline adjustment
-};
-
-namespace o3tl
+enum class ScanlineFormat : sal_uInt8
 {
-   

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

2024-02-29 Thread Tomaž Vajngerl (via logerrit)
 sc/source/filter/excel/excel.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit b3223e1f236e450fcbb71c415dc64dbd10a7ae0a
Author: Tomaž Vajngerl 
AuthorDate: Fri Feb 16 23:56:52 2024 +0900
Commit: Miklos Vajna 
CommitDate: Thu Feb 29 11:52:58 2024 +0100

sc: Handle xls documents with unknown DRM encryption better

If we can't decrypt the document, don't set the SotStorage to
an empty SvRef. It is possible the document contains a "fallback"
un-encrypted document, which we can show. This is typical for some
Excel add-ons, which encrypt the document, but also add a part
that is un-encrypted to write the instructions on how to get the
add-on.

Change-Id: I6079786b1d0dce3a819a70e057699d0a461a5be5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163511
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 1e1072afa3726266f83d7ef8895ed406580a3450)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163535
Reviewed-by: Miklos Vajna 

diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx
index 8420cc696a90..c92ef75d6998 100644
--- a/sc/source/filter/excel/excel.cxx
+++ b/sc/source/filter/excel/excel.cxx
@@ -183,7 +183,9 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& 
rMedium, ScDocument*
 tools::SvRef xDRMStrm = 
ScfTools::OpenStorageStreamRead(xRootStrg, " DRMContent");
 if (xDRMStrm.is())
 {
-xRootStrg = lcl_DRMDecrypt(rMedium, xRootStrg, aNewStorageStrm);
+auto pDecryptedStorage = lcl_DRMDecrypt(rMedium, xRootStrg, 
aNewStorageStrm);
+if (pDecryptedStorage)
+xRootStrg = pDecryptedStorage;
 }
 
 // try to open the "Book" stream


core.git: sc/source

2024-02-28 Thread Tomaž Vajngerl (via logerrit)
 sc/source/core/data/dpoutput.cxx |   15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

New commits:
commit a8a2c49d1984447297085824b593039908498fe5
Author: Tomaž Vajngerl 
AuthorDate: Tue Feb 27 14:06:40 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Feb 29 08:32:35 2024 +0100

sc: use emplace_back instead of a temporary object and push_back

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

diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index a0e87f19415a..c269e00a3438 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -598,9 +598,8 @@ ScDPOutput::ScDPOutput(ScDocument* pDocument, 
uno::Reference 
aResult = xLevRes->getResults();
 if (!lcl_MemberEmpty(aResult))
 {
-ScDPOutLevelData tmp(nDim, 
nHierarchy, nLev, nDimPos, nNumFmt, aResult, aName,
-   aCaption, 
bHasHiddenMember, bIsDataLayout, false);
-mpColFields.push_back(tmp);
+mpColFields.emplace_back(nDim, 
nHierarchy, nLev, nDimPos, nNumFmt, aResult, aName,
+ aCaption, 
bHasHiddenMember, bIsDataLayout, false);
 }
 }
 break;
@@ -624,9 +623,8 @@ ScDPOutput::ScDPOutput(ScDocument* pDocument, 
uno::Reference 
aResult = getVisiblePageMembersAsResults(xLevel);
 // no check on results for page fields
-ScDPOutLevelData tmp(nDim, nHierarchy, 
nLev, nDimPos, nNumFmt, aResult, aName,
-   aCaption, 
bHasHiddenMember, false, true);
-mpPageFields.push_back(tmp);
+mpPageFields.emplace_back(nDim, 
nHierarchy, nLev, nDimPos, nNumFmt, aResult, aName,
+  aCaption, 
bHasHiddenMember, false, true);
 }
 break;
 default:


core.git: sc/inc sc/source

2024-02-28 Thread Tomaž Vajngerl (via logerrit)
 sc/inc/dpoutput.hxx  |   68 ++--
 sc/source/core/data/dpoutput.cxx |  550 +++
 2 files changed, 305 insertions(+), 313 deletions(-)

New commits:
commit 3e2147537f84bf6ca2f81e3e9a267b5db4bc1788
Author: Tomaž Vajngerl 
AuthorDate: Tue Feb 27 13:34:33 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Feb 29 06:56:12 2024 +0100

sc: prefix ScDPOutput members

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

diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index 94decfa44466..9c9c068c603e 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -46,45 +46,43 @@ struct ScDPOutLevelData;
 class ScDPOutput
 {
 private:
-ScDocument* pDoc;
-css::uno::Reference< css::sheet::XDimensionsSupplier> xSource;
-ScAddress   aStartPos;
-std::vector   pColFields;
-std::vector   pRowFields;
-std::vector   pPageFields;
-css::uno::Sequence< css::uno::Sequence< css::sheet::DataResult> > aData;
-OUStringaDataDescription;
+ScDocument* mpDocument;
+css::uno::Reference mxSource;
+ScAddress maStartPos;
+std::vector mpColFields;
+std::vector mpRowFields;
+std::vector mpPageFields;
+css::uno::Sequence> maData;
+OUString maDataDescription;
 
 // Number format related parameters
-std::unique_ptr
-pColNumFmt;
-std::unique_ptr
-pRowNumFmt;
-std::vector   aRowCompactFlags;
-sal_Int32   nColFmtCount;
-sal_Int32   nRowFmtCount;
-sal_uInt32  nSingleNumFmt;
-size_t  nRowDims; // Including empty ones.
+std::unique_ptr mpColNumberFormat;
+std::unique_ptr mpRowNumberFormat;
+std::vector maRowCompactFlags;
+sal_Int32 mnColFormatCount;
+sal_Int32 mnRowFormatCount;
+sal_uInt32 mnSingleNumberFormat;
+size_t mnRowDims; // Including empty ones.
 
 // Output geometry related parameters
-sal_Int32   nColCount;
-sal_Int32   nRowCount;
-sal_Int32   nHeaderSize;
-SCCOL   nTabStartCol;
-SCROW   nTabStartRow;
-SCCOL   nMemberStartCol;
-SCROW   nMemberStartRow;
-SCCOL   nDataStartCol;
-SCROW   nDataStartRow;
-SCCOL   nTabEndCol;
-SCROW   nTabEndRow;
-boolbDoFilter:1;
-boolbResultsError:1;
-boolbSizesValid:1;
-boolbSizeOverflow:1;
-boolmbHeaderLayout:1;  // true : grid, false : standard
-boolmbHasCompactRowField:1; // true: at least one of 
the row fields has compact layout.
-boolmbExpandCollapse:1; // true: show expand/collapse 
buttons
+sal_Int32 mnColCount;
+sal_Int32 mnRowCount;
+sal_Int32 mnHeaderSize;
+SCCOL mnTabStartCol;
+SCROW mnTabStartRow;
+SCCOL mnMemberStartCol;
+SCROW mnMemberStartRow;
+SCCOL mnDataStartCol;
+SCROW mnDataStartRow;
+SCCOL mnTabEndCol;
+SCROW mnTabEndRow;
+bool mbDoFilter:1;
+bool mbResultsError:1;
+bool mbSizesValid:1;
+bool mbSizeOverflow:1;
+bool mbHeaderLayout:1;  // true : grid, false : standard
+bool mbHasCompactRowField:1; // true: at least one of the row fields has 
compact layout.
+bool mbExpandCollapse:1; // true: show expand/collapse buttons
 
 voidDataCell( SCCOL nCol, SCROW nRow, SCTAB nTab,
 const css::sheet::DataResult& rData );
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index c74f43d10bd7..a0e87f19415a 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -506,36 +506,36 @@ uno::Sequence 
getVisiblePageMembersAsResults( const uno::Re
 
 }
 
-ScDPOutput::ScDPOutput( ScDocument* pD, 
uno::Reference xSrc,
-const ScAddress& rPos, bool bFilter, bool 
bExpandCollapse ) :
-pDoc( pD ),
-xSource(std::move( xSrc )),
-aStartPos( rPos ),
-nColFmtCount( 0 ),
-nRowFmtCount( 0 ),
-nSingleNumFmt( 0 ),
-nRowDims( 0 ),
-nColCount(0),
-nRowCount(0),
-nHeaderSize(0),
-bDoFilter(bFilter),
-bResultsError(false),
-bSizesValid(false),
-bSizeOverflow(false),
-mbHeaderLayout(false),
-mbHasCompactRowField(false),
-mbExpandCollapse(bExpandCollapse)
+ScDPOutput::ScDPOutput(ScDocument* pDocument, 
uno::Reference xSource,
+   const ScAddress& rPosition, bool bFilter, bool 
bExpandCollapse)
+: mpDocument(pDocument)
+, mxSource(std::move(xSource))
+, maStartPos(rPosition)
+, 

core.git: Branch 'distro/collabora/co-24.04' - 3 commits - include/sfx2 include/svx sc/Library_sc.mk sc/qa sc/source sfx2/source svx/source

2024-02-28 Thread Tomaž Vajngerl (via logerrit)
 include/sfx2/IDocumentModelAccessor.hxx |   47 +
 include/sfx2/objsh.hxx  |8 
 include/svx/tbcontrl.hxx|   74 
 sc/Library_sc.mk|1 
 sc/qa/unit/ucalc.cxx|   72 
 sc/source/core/data/docpool.cxx |2 
 sc/source/ui/docshell/DocumentModelAccessor.cxx |   50 +
 sc/source/ui/docshell/docsh.cxx |8 
 sc/source/ui/inc/DocumentModelAccessor.hxx  |   34 +++
 sc/source/ui/inc/docsh.hxx  |1 
 sfx2/source/doc/objcont.cxx |6 
 svx/source/items/numfmtsh.cxx   |5 
 svx/source/tbxctrls/tbcontrl.cxx|  211 +---
 13 files changed, 313 insertions(+), 206 deletions(-)

New commits:
commit e06d6dbc88845b70bf2e6ac04e895813a66053c9
Author: Tomaž Vajngerl 
AuthorDate: Wed Jan 31 00:13:02 2024 +0900
Commit: Caolán McNamara 
CommitDate: Wed Feb 28 17:10:15 2024 +0100

Currency pop-up: move getDocumentCurrencies to cxx, extend test

Test now checks that multiple cells with the same currency still
result in only one entry returned by getDocumentCurrencies.

Change-Id: I34b0fd3b117ce01b3fd462f684d0927dd53f796d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162788
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164089
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Caolán McNamara 

diff --git a/include/sfx2/IDocumentModelAccessor.hxx 
b/include/sfx2/IDocumentModelAccessor.hxx
index d843a1b41ed8..9980ce09992e 100644
--- a/include/sfx2/IDocumentModelAccessor.hxx
+++ b/include/sfx2/IDocumentModelAccessor.hxx
@@ -11,9 +11,13 @@
 #pragma once
 
 #include 
+#include 
+#include 
+#include 
 
 namespace sfx
 {
+/** Currency ID, to identify the currency in the currency list */
 struct SFX2_DLLPUBLIC CurrencyID
 {
 OUString aSymbol;
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index d355dc0782dc..15a88dedc176 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -444,6 +444,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/docshell/docsh6 \
 sc/source/ui/docshell/docsh8 \
 sc/source/ui/docshell/documentlinkmgr \
+sc/source/ui/docshell/DocumentModelAccessor \
 sc/source/ui/docshell/editable \
 sc/source/ui/docshell/externalrefmgr \
 sc/source/ui/docshell/impex \
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 5ef08d8a54d6..e16d92ee6dbd 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6850,7 +6850,7 @@ CPPUNIT_TEST_FIXTURE(Test, 
testDocumentModelAccessor_getDocumentCurrencies)
 {
 m_pDoc->InsertTab(0, "Sheet1");
 
-// Check Document Currencies
+// Check document currencies - expect 0
 auto pAccessor = m_xDocShell->GetDocumentModelAccessor();
 CPPUNIT_ASSERT(pAccessor);
 CPPUNIT_ASSERT_EQUAL(size_t(0), pAccessor->getDocumentCurrencies().size());
@@ -6876,13 +6876,45 @@ CPPUNIT_TEST_FIXTURE(Test, 
testDocumentModelAccessor_getDocumentCurrencies)
 CPPUNIT_ASSERT_EQUAL(u"2,00€"_ustr, m_pDoc->GetString(ScAddress(0, 0, 
0)));
 }
 
-// Check Document Currencies Again
+// Check document currencies again
 auto aCurrencyIDs = pAccessor->getDocumentCurrencies();
 CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
 
 CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
 CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension);
 CPPUNIT_ASSERT_EQUAL(u"€"_ustr, aCurrencyIDs[0].aSymbol);
+
+// Set the same currency to 2 more cells
+{
+m_pDoc->SetValue(ScAddress(1, 1, 0), 5.0);
+m_pDoc->SetValue(ScAddress(2, 2, 0), 7.0);
+
+OUString aCode = u"#.##0,00[$€-424]"_ustr;
+
+sal_Int32 nCheckPos;
+SvNumFormatType eType;
+sal_uInt32 nFormat;
+
+m_pDoc->GetFormatTable()->PutEntry(aCode, nCheckPos, eType, nFormat, 
LANGUAGE_SLOVENIAN);
+CPPUNIT_ASSERT_EQUAL(SvNumFormatType::CURRENCY, eType);
+
+ScPatternAttr aNewAttrs(m_pDoc->GetPool());
+SfxItemSet& rSet = aNewAttrs.GetItemSet();
+rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+m_pDoc->ApplyPattern(1, 1, 0, aNewAttrs); // B2.
+m_pDoc->ApplyPattern(2, 2, 0, aNewAttrs); // C3.
+
+CPPUNIT_ASSERT_EQUAL(u"5,00€"_ustr, m_pDoc->GetString(ScAddress(1, 1, 
0)));
+CPPUNIT_ASSERT_EQUAL(u"7,00€"_ustr, m_pDoc->GetString(ScAddress(2, 2, 
0)));
+}
+
+// Check document currencies again - should be 1 entry only
+aCurrencyIDs = pAccessor->getDocumentCurrencies();
+CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
+
+CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
+CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension);
+CPPUNIT_ASSERT_EQUAL(u"€"_ustr, 

core.git: Branch 'libreoffice-7-6' - sw/inc sw/qa sw/source

2024-02-27 Thread Tomaž Vajngerl (via logerrit)
 sw/inc/pagedesc.hxx |2 -
 sw/qa/extras/uiwriter/uiwriter7.cxx |   40 
 sw/source/core/doc/docfmt.cxx   |   33 +++--
 sw/source/core/layout/pagedesc.cxx  |2 -
 4 files changed, 73 insertions(+), 4 deletions(-)

New commits:
commit 4edcb059e9ccc1a3735ba09382cda0e764f49bac
Author: Tomaž Vajngerl 
AuthorDate: Thu Nov 30 16:42:26 2023 +0900
Commit: Xisco Fauli 
CommitDate: Tue Feb 27 14:43:37 2024 +0100

sw: fix issue with copying stashed frame format

When the PageDesc is copied from one document to another, we
don't make sure the stashed FrameFormat(s) are also properly
copied to the new document (which can happen at copy/paste). This
can cause a crash if the stashed FrameFormats are accessed or
destructed after the original document is destroyed.

This fixes the issue so that when we detect the PageDesc belong
to different documents, the stashed FrameFormats are copied just
like the non-stashed FrameFormats (used for headers and footers).

Change-Id: I948068dba4d39bb47c3725dfa8491c53c5833c7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160065
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164011

diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index 382bbb5f00cd..11bb347aa1fb 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -223,7 +223,7 @@ public:
 const SwFrameFormat* GetStashedFrameFormat(bool bHeader, bool bLeft, bool 
bFirst) const;
 
 /// Checks if the pagedescriptor has a stashed format according to the 
parameters or not.
-bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst);
+bool HasStashedFormat(bool bHeader, bool bLeft, bool bFirst) const;
 
 /// Gives the feature of removing the stashed format by hand if it is 
necessary.
 void RemoveStashedFormat(bool bHeader, bool bLeft, bool bFirst);
diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx 
b/sw/qa/extras/uiwriter/uiwriter7.cxx
index c3b70c8cad08..6715aa9dde00 100644
--- a/sw/qa/extras/uiwriter/uiwriter7.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter7.cxx
@@ -417,6 +417,46 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf69282)
 xSourceDoc->dispose();
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testStashedHeaderFooter)
+{
+createSwDoc();
+SwDoc* pSourceDocument = getSwDoc();
+uno::Reference xSourceDocument = mxComponent;
+mxComponent.clear();
+
+createSwDoc();
+SwDoc* pTargetDocument = getSwDoc();
+uno::Reference xTargetDocument = mxComponent;
+mxComponent.clear();
+
+// Source
+SwPageDesc* pSourcePageDesc = pSourceDocument->MakePageDesc("SourceStyle");
+pSourcePageDesc->ChgFirstShare(false);
+CPPUNIT_ASSERT(!pSourcePageDesc->IsFirstShared());
+pSourcePageDesc->StashFrameFormat(pSourcePageDesc->GetFirstMaster(), true, 
false, true);
+pSourceDocument->ChgPageDesc("SourceStyle", *pSourcePageDesc);
+CPPUNIT_ASSERT(pSourcePageDesc->HasStashedFormat(true, false, true));
+
+// Target
+SwPageDesc* pTargetPageDesc = pTargetDocument->MakePageDesc("TargetStyle");
+
+// Copy source to target
+pTargetDocument->CopyPageDesc(*pSourcePageDesc, *pTargetPageDesc);
+
+// Check the stashed frame format is copied
+CPPUNIT_ASSERT(pTargetPageDesc->HasStashedFormat(true, false, true));
+
+// Check document instance
+auto pSourceStashedFormat = pSourcePageDesc->GetStashedFrameFormat(true, 
false, true);
+CPPUNIT_ASSERT_EQUAL(true, pSourceStashedFormat->GetDoc() == 
pSourceDocument);
+
+auto pTargetStashedFormat = pTargetPageDesc->GetStashedFrameFormat(true, 
false, true);
+CPPUNIT_ASSERT_EQUAL(true, pTargetStashedFormat->GetDoc() == 
pTargetDocument);
+
+xSourceDocument->dispose();
+xTargetDocument->dispose();
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf69282WithMirror)
 {
 createSwDoc();
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 9f0de6aa1e06..17eaf5418e61 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1543,14 +1543,43 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, 
SwPageDesc& rDstDesc,
 
 // Copy the stashed formats as well between the page descriptors...
 for (bool bFirst : { true, false })
+{
 for (bool bLeft : { true, false })
+{
 for (bool bHeader : { true, false })
 {
 if (!bLeft && !bFirst)
 continue;
-if (auto pStashedFormat = 
rSrcDesc.GetStashedFrameFormat(bHeader, bLeft, bFirst))
-rDstDesc.StashFrameFormat(*pStashedFormat, bHeader, bLeft, 
bFirst);
+
+// Copy format only if it exists
+if (auto pStashedFormatSrc = 
rSrcDesc.GetStashedFrameFormat(bHeader, bLeft, bFirst))
+{
+  

core.git: 2 commits - editeng/inc editeng/source sc/inc sc/source

2024-02-17 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/ParagraphPortion.hxx|2 --
 editeng/source/editeng/impedit3.cxx |2 +-
 sc/inc/scerrors.hrc |2 +-
 sc/inc/scerrors.hxx |1 +
 sc/inc/strings.hrc  |3 +++
 sc/source/filter/excel/excel.cxx|9 +
 sc/source/ui/docshell/docsh.cxx |   26 +++---
 sc/source/ui/docshell/docshimp.hxx  |3 +++
 8 files changed, 41 insertions(+), 7 deletions(-)

New commits:
commit 923b1ad7b7bc249838aa619361974f0e3134ab6a
Author: Tomaž Vajngerl 
AuthorDate: Sat Feb 17 00:19:41 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Feb 17 12:07:28 2024 +0100

sc: Show warning for a XLS document with unknown encrypted part

If a document contains a "DRMContent" section that we don't know
how to decrypt, show a warning before showing the un-encrypted
content.

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

diff --git a/sc/inc/scerrors.hrc b/sc/inc/scerrors.hrc
index 88b099f69107..b3fc7bd01ec1 100644
--- a/sc/inc/scerrors.hrc
+++ b/sc/inc/scerrors.hrc
@@ -101,7 +101,7 @@ const ErrMsgCode RID_ERRHDLSC[] =
   SCWARN_EXPORT_NONCONVERTIBLE_CHARS },
 { NC_("RID_ERRHDLSC", "Format error discovered in the file in sub-document 
$(ARG1) at $(ARG2)(row,col)."),
   SCWARN_IMPORT_FILE_ROWCOL },
-{ NC_("RID_ERRHDLSC", "Not all attributes could be read.") ,
+{ NC_("RID_ERRHDLSC", "Not all attributes could be read."),
   SCWARN_IMPORT_FEATURES_LOST },
 { {}, ERRCODE_NONE }
 };
diff --git a/sc/inc/scerrors.hxx b/sc/inc/scerrors.hxx
index dcb734502eae..c425e2fe8862 100644
--- a/sc/inc/scerrors.hxx
+++ b/sc/inc/scerrors.hxx
@@ -47,6 +47,7 @@
 #define SCERR_IMPORT_FILE_ROWCOLErrCode( ErrCodeArea::Sc, 
ErrCodeClass::Read, 16 )
 #define SCERR_IMPORT_FORMAT_ROWCOL  ErrCode( ErrCodeArea::Sc, 
ErrCodeClass::Read, 17 )
 #define SCWARN_IMPORT_FILE_ROWCOL   ErrCode( WarningFlag::Yes, 
ErrCodeArea::Sc, ErrCodeClass::Read, 18 )
+#define SCWARN_IMPORT_UNKNOWN_ENCRYPTION ErrCode(WarningFlag::Yes, 
ErrCodeArea::Sc, ErrCodeClass::Read, 19)
 
 // ErrCodeClass::Write - file related, displays "Write-Error" in MsgBox
 #define SCERR_EXPORT_CONNECTErrCode( ErrCodeArea::Sc,  
ErrCodeClass::Write, 1 )
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 266cb4cc6c5b..070f117a001e 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -412,4 +412,7 @@
 #define STR_CONDITION_CONTAINS_TEXT 
NC_("STR_CONDITION_CONTAINS_TEXT", "containing text")
 #define STR_CONDITION_NOT_CONTAINS_TEXT 
NC_("STR_CONDITION_NOT_CONTAINS_TEXT", "not containing text")
 
+#define STR_CONTENT_WITH_UNKNOWN_ENCRYPTION 
NC_("STR_CONTENT_WITH_UNKNOWN_ENCRYPTION", "Document contains DRM content that 
is encrypted with an unknown encryption method. Only the un-encrypted content 
will be shown.")
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx
index 3542208eb174..862e85d08545 100644
--- a/sc/source/filter/excel/excel.cxx
+++ b/sc/source/filter/excel/excel.cxx
@@ -165,6 +165,8 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& 
rMedium, ScDocument*
 SvStream* pBookStrm = nullptr;// The "Book"/"Workbook" stream 
containing main data.
 XclBiff eBiff = EXC_BIFF_UNKNOWN;   // The BIFF version of the main stream.
 
+bool bUnableToDecryptContent = false;
+
 // try to open an OLE storage
 tools::SvRef xRootStrg;
 tools::SvRef xStrgStrm;
@@ -186,6 +188,10 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( 
SfxMedium& rMedium, ScDocument*
 auto pDecryptedStorage = lcl_DRMDecrypt(rMedium, xRootStrg, 
aNewStorageStrm);
 if (pDecryptedStorage)
 xRootStrg = pDecryptedStorage;
+else
+{
+bUnableToDecryptContent = true;
+}
 }
 
 // try to open the "Book" stream
@@ -250,6 +256,9 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& 
rMedium, ScDocument*
 eRet = xFilter ? xFilter->Read() : SCERR_IMPORT_INTERNAL;
 }
 
+if (bUnableToDecryptContent && eRet == ERRCODE_NONE)
+eRet = SCWARN_IMPORT_UNKNOWN_ENCRYPTION;
+
 return eRet;
 }
 
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 1cfd3778d6be..5f0cf927cd1d 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -775,6 +776,11 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& 
rHint )
 }
 }
 #endif
+
+ScViewData* pViewData = GetViewData();
+SfxViewShell* pViewShell = pViewData ? 

core.git: sc/source

2024-02-16 Thread Tomaž Vajngerl (via logerrit)
 sc/source/filter/excel/excel.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 1e1072afa3726266f83d7ef8895ed406580a3450
Author: Tomaž Vajngerl 
AuthorDate: Fri Feb 16 23:56:52 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Feb 17 03:54:24 2024 +0100

sc: Handle xls documents with unknown DRM encryption better

If we can't decrypt the document, don't set the SotStorage to
an empty SvRef. It is possible the document contains a "fallback"
un-encrypted document, which we can show. This is typical for some
Excel add-ons, which encrypt the document, but also add a part
that is un-encrypted to write the instructions on how to get the
add-on.

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

diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx
index 1d68152127d0..3542208eb174 100644
--- a/sc/source/filter/excel/excel.cxx
+++ b/sc/source/filter/excel/excel.cxx
@@ -183,7 +183,9 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& 
rMedium, ScDocument*
 tools::SvRef xDRMStrm = 
ScfTools::OpenStorageStreamRead(xRootStrg, " DRMContent");
 if (xDRMStrm.is())
 {
-xRootStrg = lcl_DRMDecrypt(rMedium, xRootStrg, aNewStorageStrm);
+auto pDecryptedStorage = lcl_DRMDecrypt(rMedium, xRootStrg, 
aNewStorageStrm);
+if (pDecryptedStorage)
+xRootStrg = pDecryptedStorage;
 }
 
 // try to open the "Book" stream


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

2024-02-14 Thread Tomaž Vajngerl (via logerrit)
 sfx2/source/view/lokhelper.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 5fec109a88b9833a005dd95892eec464a254d268
Author: Tomaž Vajngerl 
AuthorDate: Thu Feb 8 18:55:44 2024 +0900
Commit: Caolán McNamara 
CommitDate: Wed Feb 14 10:06:52 2024 +0100

lok: remove unneeded mutex guard

Change-Id: I9e9ef3fd4ad43c2523c286f534e14e839aada453
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163114
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 21c215a0345feb347c7adeea5aca766ede23f54a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163282
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 3cc4db8084bb..80bdb38aa13a 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -1142,11 +1142,9 @@ void LOKEditViewHistory::Update(bool bRemove)
 if (!comphelper::LibreOfficeKit::isActive())
 return;
 
-static std::mutex aMutex;
 SfxViewShell* pViewShell = SfxViewShell::Current();
 if (pViewShell)
 {
-std::lock_guard aLockGuard{aMutex};
 int nDocId = pViewShell->GetDocId().get();
 if (maEditViewHistory.find(nDocId) != maEditViewHistory.end())
 maEditViewHistory[nDocId].remove(pViewShell);


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

2024-02-12 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx 
|binary
 
sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
|binary
 
sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 |binary
 sc/qa/unit/pivottable_filters_test.cxx 
|   63 ++
 sc/source/filter/oox/pivottablebuffer.cxx  
|   18 ++
 5 files changed, 78 insertions(+), 3 deletions(-)

New commits:
commit 12c69942fb80fcd4cd4a5a4ca4c76f1e050ca20c
Author: Tomaž Vajngerl 
AuthorDate: Sat Feb 10 00:38:35 2024 +0900
Commit: Xisco Fauli 
CommitDate: Mon Feb 12 17:09:55 2024 +0100

sc: pivot table not correct when data and PT cache is not in sync

It can happen that the pivot table is not updated and the sheet
data is changed so much that it doesn't match the pivot table
cached definitions. This is a perfectly valid scenario and
nothing should be wrong (the pivot table can just be updated
once loaded).

At XLSX import we should always check the cached definitions,
because the pivot table description is made using the cached data,
not the actual data.

The issue can occur when looking up the name of a PT field we
however didn't check the cached definition but checked the
sheet data, so because the indices changed so much (many columns
were removed in the sheet data) we can not find the actual field
name. The solution is simple - get the field name from the cached
pivot table definition.

Change-Id: I3b5b33f33f3c484f0b66b97ac97200d9913edcfe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163197
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 9af4b5254cbe6a6770ebe78ba14074266b05471e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163178
Reviewed-by: Xisco Fauli 

diff --git a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx
new file mode 100644
index ..f425f978cb50
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx differ
diff --git 
a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
new file mode 100644
index ..0cb21cd3259c
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
 differ
diff --git 
a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
new file mode 100644
index ..91297320b985
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 differ
diff --git a/sc/qa/unit/pivottable_filters_test.cxx 
b/sc/qa/unit/pivottable_filters_test.cxx
index 8d6b1ad5d39e..31fb49351c8c 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -2647,6 +2647,69 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFiltersTest, 
testPivotTableCompactLayoutXLSX)
 testThis(*getScDoc());
 }
 
+CPPUNIT_TEST_FIXTURE(ScPivotTableFiltersTest,
+ 
testPivotTableXLSX_OutOfSyncPivotTableCachedDefinitionImport)
+{
+// This tests that a out-of-sync sheet data and pivot table cached 
definitions
+// still get imported correctly as expected.
+
+// It is perfectly valid that the sheet data and pivot table are 
out-of-sync,
+// but even if the sheet data is heavily modified, the pivot table should 
still
+// be imported.
+
+// The test document has columns named A-K where only A and K are used in 
the
+// pivot table. The columns B-J were removed in the sheet data, but the 
pivot table
+// was not updated, so the cached data still has those and the pivot table
+// description still relies on those columns to be present.
+
+auto testThis = [](ScDocument& rDocument) {
+ScDPCollection* pDPs = rDocument.GetDPCollection();
+CPPUNIT_ASSERT_MESSAGE("Failed to get a live ScDPCollection 
instance.", pDPs);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one pivot table 
instance.", size_t(1),
+ pDPs->GetCount());
+
+const ScDPObject* pDPObj = &(*pDPs)[0];
+CPPUNIT_ASSERT(pDPObj);
+ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+CPPUNIT_ASSERT(pSaveData);
+
+// Do we have a dim named "A"
+

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

2024-02-11 Thread Tomaž Vajngerl (via logerrit)
 sfx2/source/view/lokhelper.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 21c215a0345feb347c7adeea5aca766ede23f54a
Author: Tomaž Vajngerl 
AuthorDate: Thu Feb 8 18:55:44 2024 +0900
Commit: Miklos Vajna 
CommitDate: Mon Feb 12 08:26:15 2024 +0100

lok: remove unneeded mutex guard

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

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 55d111f1a433..e6fc7e8c7114 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -1146,11 +1146,9 @@ void LOKEditViewHistory::Update(bool bRemove)
 if (!comphelper::LibreOfficeKit::isActive())
 return;
 
-static std::mutex aMutex;
 SfxViewShell* pViewShell = SfxViewShell::Current();
 if (pViewShell)
 {
-std::lock_guard aLockGuard{aMutex};
 int nDocId = pViewShell->GetDocId().get();
 if (maEditViewHistory.find(nDocId) != maEditViewHistory.end())
 maEditViewHistory[nDocId].remove(pViewShell);


core.git: 3 commits - editeng/inc editeng/source

2024-02-11 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/ParagraphPortion.hxx|   83 +---
 editeng/inc/TextPortionList.hxx |7 ++
 editeng/source/editeng/editdbg.cxx  |7 +-
 editeng/source/editeng/editdoc.cxx  |   91 
 editeng/source/editeng/impedit2.cxx |   72 ++--
 editeng/source/editeng/impedit3.cxx |   29 +--
 editeng/source/editeng/impedit4.cxx |6 +-
 7 files changed, 152 insertions(+), 143 deletions(-)

New commits:
commit a476aa8d222a949a67676d95ec07914bbf00e23b
Author: Tomaž Vajngerl 
AuthorDate: Sun Feb 11 12:51:18 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Feb 12 07:27:47 2024 +0100

editeng: make TextPortionList iterable with ranged for

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

diff --git a/editeng/inc/TextPortionList.hxx b/editeng/inc/TextPortionList.hxx
index 7c646ebbbee9..dc6b5e064bd5 100644
--- a/editeng/inc/TextPortionList.hxx
+++ b/editeng/inc/TextPortionList.hxx
@@ -59,6 +59,11 @@ public:
 sal_Int32 GetPos(const TextPortion* p) const;
 
 bool isEmpty() { return Count() == 1 && maPortions[0]->GetLen() == 0; }
+
+PortionsType::iterator begin() { return maPortions.begin(); }
+PortionsType::iterator end() { return maPortions.end(); }
+PortionsType::const_iterator cbegin() const { return maPortions.cbegin(); }
+PortionsType::const_iterator cend() const { return maPortions.cend(); }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 330a37cb2187..9892dfaa783f 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -724,27 +724,28 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
 const sal_Int32 nInvalidEnd =  nInvalidStart + std::abs( nInvalidDiff );
 
 bool bQuickFormat = false;
-if ( !bEmptyNodeWithPolygon && !HasScriptType( nPara, 
i18n::ScriptType::COMPLEX ) )
+
+// Determine if quick formt should be used
+if (!bEmptyNodeWithPolygon && !HasScriptType(nPara, 
i18n::ScriptType::COMPLEX))
 {
-if ( ( rParaPortion.IsSimpleInvalid() ) && ( nInvalidDiff > 0 ) &&
- ( pNode->GetString().indexOf( CH_FEATURE, nInvalidStart ) > 
nInvalidEnd ) )
+if (rParaPortion.IsSimpleInvalid() &&
+rParaPortion.GetInvalidDiff() > 0 &&
+pNode->GetString().indexOf(CH_FEATURE, nInvalidStart) > 
nInvalidEnd)
 {
 bQuickFormat = true;
 }
-else if ( ( rParaPortion.IsSimpleInvalid() ) && ( nInvalidDiff < 0 ) )
+else if (rParaPortion.IsSimpleInvalid() && nInvalidDiff < 0)
 {
 // check if delete over the portion boundaries was done...
 sal_Int32 nStart = nInvalidStart;  // DOUBLE !!!
 sal_Int32 nEnd = nStart - nInvalidDiff;  // negative
 bQuickFormat = true;
 sal_Int32 nPos = 0;
-sal_Int32 nPortions = rParaPortion.GetTextPortions().Count();
-for ( sal_Int32 nTP = 0; nTP < nPortions; nTP++ )
+for (auto const& pTextPortion : rParaPortion.GetTextPortions())
 {
 // There must be no start / end in the deleted area.
-const TextPortion& rTP = rParaPortion.GetTextPortions()[ nTP ];
-nPos = nPos + rTP.GetLen();
-if ( ( nPos > nStart ) && ( nPos < nEnd ) )
+nPos = nPos + pTextPortion->GetLen();
+if (nPos > nStart && nPos < nEnd)
 {
 bQuickFormat = false;
 break;
commit d0d83b8b4a8ee5a889e1ffdf1293b858bf69caaf
Author: Tomaž Vajngerl 
AuthorDate: Sun Feb 11 12:49:09 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Feb 12 07:27:40 2024 +0100

editeng: move isEmpty impl. from ParaPortion to TextPortionList

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

diff --git a/editeng/inc/ParagraphPortion.hxx b/editeng/inc/ParagraphPortion.hxx
index 97b37ebe1134..2b0664ec0c2d 100644
--- a/editeng/inc/ParagraphPortion.hxx
+++ b/editeng/inc/ParagraphPortion.hxx
@@ -111,7 +111,7 @@ public:
 void SetVisible(bool bVisible) { mbVisible = bVisible; }
 bool IsVisible() const { return mbVisible; }
 
-bool IsEmpty() { return GetTextPortions().Count() == 1 && 
GetTextPortions()[0].GetLen() == 0; }
+bool IsEmpty() { return GetTextPortions().isEmpty(); }
 
 tools::Long GetHeight() const { return mbVisible ? mnHeight : 0; }
 sal_Int32 GetFirstLineOffset() const { return mbVisible ? 
mnFirstLineOffset : 0; }
diff --git a/editeng/inc/TextPortionList.hxx b/editeng/inc/TextPortionList.hxx

core.git: editeng/source

2024-02-10 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/impedit.cxx  |8 +-
 editeng/source/editeng/impedit.hxx  |  119 ++--
 editeng/source/editeng/impedit5.cxx |   40 ++--
 3 files changed, 72 insertions(+), 95 deletions(-)

New commits:
commit d0317669ac673d52d6fbe8da4c1dcc9fa17cc290
Author: Tomaž Vajngerl 
AuthorDate: Tue Feb 6 10:33:44 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Feb 10 14:55:38 2024 +0100

editeng: simplify and clean-up struct in for ImpEditEng

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

diff --git a/editeng/source/editeng/impedit.cxx 
b/editeng/source/editeng/impedit.cxx
index 22412fd2fc37..c43bdfca21a1 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -2252,7 +2252,7 @@ void ImpEditView::dragGestureRecognized(const 
css::datatransfer::dnd::DragGestur
 
 if (HasSelection() && mbClickedInSelection)
 {
-mpDragAndDropInfo.reset(new DragAndDropInfo());
+mpDragAndDropInfo.reset(new DragAndDropInfo);
 }
 else
 {
@@ -2263,7 +2263,7 @@ void ImpEditView::dragGestureRecognized(const 
css::datatransfer::dnd::DragGestur
 const SvxFieldItem* pField = GetField( aMousePos, ,  );
 if ( pField )
 {
-mpDragAndDropInfo.reset(new DragAndDropInfo());
+mpDragAndDropInfo.reset(new DragAndDropInfo);
 mpDragAndDropInfo->pField = pField;
 ContentNode* pNode = getEditEngine().GetEditDoc().GetObject( nPara 
);
 aCopySel = EditSelection( EditPaM( pNode, nPos ), EditPaM( pNode, 
nPos+1 ) );
@@ -2274,7 +2274,7 @@ void ImpEditView::dragGestureRecognized(const 
css::datatransfer::dnd::DragGestur
 }
 else if ( IsBulletArea( aMousePos,  ) )
 {
-mpDragAndDropInfo.reset(new DragAndDropInfo());
+mpDragAndDropInfo.reset(new DragAndDropInfo);
 mpDragAndDropInfo->bOutlinerMode = true;
 EditPaM aStartPaM(getEditEngine().GetEditDoc().GetObject(nPara), 
0);
 EditPaM aEndPaM( aStartPaM );
@@ -2487,7 +2487,7 @@ void ImpEditView::dragEnter( const 
css::datatransfer::dnd::DropTargetDragEnterEv
 SolarMutexGuard aVclGuard;
 
 if (!mpDragAndDropInfo)
-mpDragAndDropInfo.reset(new DragAndDropInfo());
+mpDragAndDropInfo.reset(new DragAndDropInfo);
 
 mpDragAndDropInfo->bHasValidData = false;
 
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 199a9cd29f12..31f9b156962c 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -100,49 +100,55 @@ struct CursorFlags
 
 struct DragAndDropInfo
 {
-tools::Rectangle   aCurCursor;
-tools::Rectangle   aCurSavedCursor;
-sal_uInt16  nSensibleRange;
-sal_uInt16  nCursorWidth;
-ESelection  aBeginDragSel;
-EditPaM aDropDest;
-sal_Int32   nOutlinerDropDest;
-ESelection  aDropSel;
-VclPtr pBackground;
-const SvxFieldItem* pField;
-boolbVisCursor  : 1;
-boolbDroppedInMe: 1;
-boolbStarterOfDD: 1;
-boolbHasValidData   : 1;
-boolbUndoAction : 1;
-boolbOutlinerMode   : 1;
-boolbDragAccepted   : 1;
-
-DragAndDropInfo()
-  : nSensibleRange(0), nCursorWidth(0), nOutlinerDropDest(0), 
pBackground(nullptr),
-pField(nullptr), bVisCursor(false), bDroppedInMe(false), 
bStarterOfDD(false),
-bHasValidData(false), bUndoAction(false), bOutlinerMode(false), 
bDragAccepted(false)
-{
-}
+tools::Rectangle aCurCursor;
+tools::Rectangle aCurSavedCursor;
+sal_uInt16 nSensibleRange = 0;
+sal_uInt16 nCursorWidth = 0;
+ESelection aBeginDragSel;
+EditPaM aDropDest;
+sal_Int32 nOutlinerDropDest = 0;
+ESelection aDropSel;
+VclPtr pBackground = nullptr;
+const SvxFieldItem* pField = nullptr;
+bool bVisCursor : 1 = false;
+bool bDroppedInMe : 1 = false;
+bool bStarterOfDD : 1 = false;
+bool bHasValidData : 1 = false;
+bool bUndoAction : 1 = false;
+bool bOutlinerMode : 1 = false;
+bool bDragAccepted : 1 = false;
+
 ~DragAndDropInfo()
 {
-pBackground.disposeAndClear();
+pBackground.disposeAndClear();
 }
 };
 
 struct ImplIMEInfos
 {
-OUStringaOldTextAfterStartPos;
+OUString aOldTextAfterStartPos;
 std::unique_ptr pAttribs;
-EditPaM aPos;
-sal_Int32   nLen;
-boolbWasCursorOverwrite;
+EditPaM aPos;
+sal_Int32 nLen = 0;
+bool bWasCursorOverwrite = false;
 
-ImplIMEInfos( const EditPaM& rPos, OUString aOldTextAfterStartPos 
);
-

core.git: sc/qa sc/source

2024-02-09 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx 
|binary
 
sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
|binary
 
sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 |binary
 sc/qa/unit/pivottable_filters_test.cxx 
|   63 ++
 sc/source/filter/oox/pivottablebuffer.cxx  
|   18 ++
 5 files changed, 78 insertions(+), 3 deletions(-)

New commits:
commit 9af4b5254cbe6a6770ebe78ba14074266b05471e
Author: Tomaž Vajngerl 
AuthorDate: Sat Feb 10 00:38:35 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Feb 10 01:11:44 2024 +0100

sc: pivot table not correct when data and PT cache is not in sync

It can happen that the pivot table is not updated and the sheet
data is changed so much that it doesn't match the pivot table
cached definitions. This is a perfectly valid scenario and
nothing should be wrong (the pivot table can just be updated
once loaded).

At XLSX import we should always check the cached definitions,
because the pivot table description is made using the cached data,
not the actual data.

The issue can occur when looking up the name of a PT field we
however didn't check the cached definition but checked the
sheet data, so because the indices changed so much (many columns
were removed in the sheet data) we can not find the actual field
name. The solution is simple - get the field name from the cached
pivot table definition.

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

diff --git a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx
new file mode 100644
index ..f425f978cb50
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataInSync.xlsx differ
diff --git 
a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
new file mode 100644
index ..0cb21cd3259c
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithCacheData.xlsx
 differ
diff --git 
a/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
new file mode 100644
index ..91297320b985
Binary files /dev/null and 
b/sc/qa/unit/data/xlsx/PivotTable_CachedDefinitionAndDataNotInSync_SheetColumnsRemoved_WithoutCacheData.xlsx
 differ
diff --git a/sc/qa/unit/pivottable_filters_test.cxx 
b/sc/qa/unit/pivottable_filters_test.cxx
index 8d6b1ad5d39e..31fb49351c8c 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -2647,6 +2647,69 @@ CPPUNIT_TEST_FIXTURE(ScPivotTableFiltersTest, 
testPivotTableCompactLayoutXLSX)
 testThis(*getScDoc());
 }
 
+CPPUNIT_TEST_FIXTURE(ScPivotTableFiltersTest,
+ 
testPivotTableXLSX_OutOfSyncPivotTableCachedDefinitionImport)
+{
+// This tests that a out-of-sync sheet data and pivot table cached 
definitions
+// still get imported correctly as expected.
+
+// It is perfectly valid that the sheet data and pivot table are 
out-of-sync,
+// but even if the sheet data is heavily modified, the pivot table should 
still
+// be imported.
+
+// The test document has columns named A-K where only A and K are used in 
the
+// pivot table. The columns B-J were removed in the sheet data, but the 
pivot table
+// was not updated, so the cached data still has those and the pivot table
+// description still relies on those columns to be present.
+
+auto testThis = [](ScDocument& rDocument) {
+ScDPCollection* pDPs = rDocument.GetDPCollection();
+CPPUNIT_ASSERT_MESSAGE("Failed to get a live ScDPCollection 
instance.", pDPs);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one pivot table 
instance.", size_t(1),
+ pDPs->GetCount());
+
+const ScDPObject* pDPObj = &(*pDPs)[0];
+CPPUNIT_ASSERT(pDPObj);
+ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+CPPUNIT_ASSERT(pSaveData);
+
+// Do we have a dim named "A"
+ScDPSaveDimension* pSaveDimA = 
pSaveData->GetExistingDimensionByName(u"A");
+CPPUNIT_ASSERT(pSaveDimA);
+
+// Do we have a dim named "K"
+

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

2024-02-09 Thread Tomaž Vajngerl (via logerrit)
 include/sfx2/notebookbar/SfxNotebookBar.hxx |9 --
 sfx2/source/notebookbar/SfxNotebookBar.cxx  |   99 ++--
 2 files changed, 79 insertions(+), 29 deletions(-)

New commits:
commit ac7503e601968d87e90f0c323e1494ec6b680427
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 29 16:08:48 2024 +0900
Commit: Caolán McNamara 
CommitDate: Fri Feb 9 22:03:38 2024 +0100

lok: introduce NotebookBarViewManager and NotebookBarViewData

NotebookBarViewManager is a singleton which is responsible to hold
NotebookBar view specific data, which is kept in NotebookBarViewData
class. The idea is to have one NotebookBarViewData class instance
per one view (SfxViewShell instance).

This also refactors the existing code and now moves the
m_pWeldedWrapper, m_pNotebookBar and the m_pToolbarUnoDispatcher
into NotebookBarViewData class.

Change-Id: I32f5954fa9f1628acd9f5f9bd5760ac23ca687ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162680
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit da8ebd2c348affbd7fa4975910296f32d3c9d1b0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163173
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx 
b/include/sfx2/notebookbar/SfxNotebookBar.hxx
index cd94ddad7b1e..47bd9cc79901 100644
--- a/include/sfx2/notebookbar/SfxNotebookBar.hxx
+++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx
@@ -16,7 +16,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
@@ -33,8 +32,7 @@ class SfxBindings;
 class SfxViewFrame;
 class SfxViewShell;
 class SystemWindow;
-class ToolbarUnoDispatcher;
-class WeldedTabbedNotebookbar;
+class ViewInstanceManager;
 
 namespace sfx2
 {
@@ -75,11 +73,6 @@ public:
 private:
 static bool m_bLock;
 static bool m_bHide;
-static std::unique_ptr m_xCalcToolboxDispatcher;
-
-static std::map>
-m_pNotebookBarWeldedWrapper;
-static std::map> 
m_pNotebookBarInstance;
 
 static void ResetActiveToolbarModeToDefault(vcl::EnumContext::Application 
eApp);
 static void RemoveCurrentLOKWrapper();
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx 
b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 9c33b3ef5fb9..a5287a82a3b9 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 using namespace sfx2;
@@ -42,9 +42,68 @@ const char MERGE_NOTEBOOKBAR_URL[] = "URL";
 
 bool SfxNotebookBar::m_bLock = false;
 bool SfxNotebookBar::m_bHide = false;
-std::unique_ptr SfxNotebookBar::m_xCalcToolboxDispatcher;
-std::map> 
SfxNotebookBar::m_pNotebookBarWeldedWrapper;
-std::map> 
SfxNotebookBar::m_pNotebookBarInstance;
+
+namespace
+{
+
+/** View specific notebook bar data */
+struct NotebookBarViewData
+{
+std::unique_ptr m_pWeldedWrapper;
+VclPtr m_pNotebookBar;
+std::unique_ptr m_pToolbarUnoDispatcher;
+
+~NotebookBarViewData()
+{
+if (m_pNotebookBar)
+m_pNotebookBar.disposeAndClear();
+}
+};
+
+/** Notebookbar instance manager is a singleton that is used for track the
+ *  per-view instances of view specifc data contained in NotebookBarViewData
+ *  class.
+ **/
+class NotebookBarViewManager final
+{
+private:
+// map contains a view data instance for a view (SfxViewShell pointer)
+std::unordered_map> m_pViewDataList;
+
+// private constructor to prevent any other instantiation outside of get() 
method
+NotebookBarViewManager() = default;
+
+// prevent class copying
+NotebookBarViewManager(const NotebookBarViewManager&) = delete;
+NotebookBarViewManager& operator=(const NotebookBarViewManager&) = delete;
+
+public:
+// Singleton get method - creates an instance on first get() call
+static NotebookBarViewManager& get()
+{
+static NotebookBarViewManager gManager;
+return gManager;
+}
+
+NotebookBarViewData& getViewData(const SfxViewShell* pViewShell)
+{
+auto aFound = m_pViewDataList.find(pViewShell);
+if (aFound != m_pViewDataList.end()) // found
+return *aFound->second;
+
+// Create new view data instance
+NotebookBarViewData* pViewData = new NotebookBarViewData;
+m_pViewDataList.emplace(pViewShell, 
std::unique_ptr(pViewData));
+return *pViewData;
+}
+
+void removeViewData(const SfxViewShell* pViewShell)
+{
+m_pViewDataList.erase(pViewShell);
+}
+};
+
+} // end anonymous namespace
 
 static void NotebookbarAddonValues(
 std::vector& aImageValues,
@@ -200,13 +259,13 @@ static utl::OConfigurationNode 
lcl_getCurrentImplConfigNode(const Reference VclDisposeHdl
-// which clears also m_pNotebookBarWeldedWrapper
-aFound->second.disposeAndClear();
-m_pNotebookBarInstance.erase(aFound);
+  

core.git: Branch 'private/tvajngerl/staging' - 16 commits - basctl/source basegfx/CppunitTest_basegfx.mk basegfx/test chart2/source cui/source drawinglayer/source editeng/source filter/CppunitTest_fil

2024-02-05 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit 36167ff3d9bfca7095b340e33d3c5d7074945f66
Author: Tomaž Vajngerl 
AuthorDate: Sun Mar 5 18:48:23 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Feb 6 13:29:23 2024 +0900

svx: use gfx::Length based types directly in SdrTextObj::NbcResize

Change-Id: I839430b30685994e1767998b353c63b97f461284

diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 7ed97774119d..f1abaf11e1b3 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -122,81 +122,102 @@ void SdrTextObj::NbcMove(const Size& rSize)
 
 void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const 
Fraction& yFact)
 {
-bool bNotSheared=maGeo.m_nShearAngle==0_deg100;
-bool bRotate90=bNotSheared && maGeo.m_nRotationAngle.get() % 9000 ==0;
-bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
-bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
-if (bXMirr || bYMirr) {
+bool bNotSheared = maGeo.m_nShearAngle == 0_deg100;
+bool bRotate90 = bNotSheared && maGeo.m_nRotationAngle.get() % 9000 == 0;
+
+bool bXMirrored = (xFact.GetNumerator() < 0) != (xFact.GetDenominator() < 
0);
+bool bYMirrored = (yFact.GetNumerator() < 0) != (yFact.GetDenominator() < 
0);
+
+double fFactorX = xFact.IsValid() ? double(xFact) : 1.0;
+double fFactorY = yFact.IsValid() ? double(yFact) : 1.0;
+
+if (bXMirrored || bYMirrored)
+{
 Point aRef1(GetSnapRect().Center());
-if (bXMirr) {
+if (bXMirrored)
+{
 Point aRef2(aRef1);
 aRef2.AdjustY( 1 );
 NbcMirrorGluePoints(aRef1,aRef2);
 }
-if (bYMirr) {
+if (bYMirrored)
+{
 Point aRef2(aRef1);
 aRef2.AdjustX( 1 );
 NbcMirrorGluePoints(aRef1,aRef2);
 }
 }
 
-if (maGeo.m_nRotationAngle==0_deg100 && maGeo.m_nShearAngle==0_deg100) {
-auto aRectangle = getRectangle();
-ResizeRect(aRectangle, rRef, xFact, yFact);
-setRectangle(aRectangle);
-if (bYMirr)
+if (maGeo.m_nRotationAngle == 0_deg100 && maGeo.m_nShearAngle == 0_deg100)
+{
+auto eUnit = getSdrModelFromSdrObject().getUnit();
+gfx::Tuple2DL aReference = createTupleFromPoint(rRef, eUnit);
+svx::resizeRange(maRectangleRange, aReference, fFactorX, fFactorY);
+
+if (bYMirrored)
 {
-//maRectangle.Normalize();
-moveRectangle(aRectangle.Right() - aRectangle.Left(), 
aRectangle.Bottom() - aRectangle.Top());
-maGeo.m_nRotationAngle=18000_deg100;
+maRectangleRange.shift(maRectangleRange.getWidth(), 
maRectangleRange.getHeight());
+maGeo.m_nRotationAngle = 18000_deg100;
 maGeo.RecalcSinCos();
 }
 }
 else
 {
-tools::Polygon aPol(Rect2Poly(getRectangle(), maGeo));
+tools::Polygon aPolygon(Rect2Poly(getRectangle(), maGeo));
 
-for(sal_uInt16 a(0); a < aPol.GetSize(); a++)
+for (sal_uInt16 a(0); a < aPolygon.GetSize(); a++)
 {
- ResizePoint(aPol[a], rRef, xFact, yFact);
+ ResizePoint(aPolygon[a], rRef, xFact, yFact);
 }
 
-if(bXMirr != bYMirr)
+if (bXMirrored != bYMirrored)
 {
 // turn polygon and move it a little
-tools::Polygon aPol0(aPol);
+tools::Polygon aPol0(aPolygon);
 
-aPol[0] = aPol0[1];
-aPol[1] = aPol0[0];
-aPol[2] = aPol0[3];
-aPol[3] = aPol0[2];
-aPol[4] = aPol0[1];
+aPolygon[0] = aPol0[1];
+aPolygon[1] = aPol0[0];
+aPolygon[2] = aPol0[3];
+aPolygon[3] = aPol0[2];
+aPolygon[4] = aPol0[1];
 }
-tools::Rectangle aRectangle = svx::polygonToRectangle(aPol, maGeo);
+tools::Rectangle aRectangle = svx::polygonToRectangle(aPolygon, maGeo);
 setRectangle(aRectangle);
 }
 
-if (bRotate90) {
-bool bRota90=maGeo.m_nRotationAngle.get() % 9000 ==0;
-if (!bRota90) { // there's seems to be a rounding error occurring: 
correct it
-Degree100 a=NormAngle36000(maGeo.m_nRotationAngle);
-if (a<4500_deg100) a=0_deg100;
-else if (a<13500_deg100) a=9000_deg100;
-else if (a<22500_deg100) a=18000_deg100;
-else if (a<31500_deg100) a=27000_deg100;
-else a=0_deg100;
-maGeo.m_nRotationAngle=a;
+if (bRotate90)
+{
+bool bRota90 = maGeo.m_nRotationAngle.get() % 9000 == 0;
+if (!bRota90)
+{
+// there's seems to be a rounding error occurring: correct it
+
+Degree100 angle = NormAngle36000(maGeo.m_nRotationAngle);
+if (angle < 4500_deg100)
+angle = 0_deg100;
+else if (angle < 13500_deg100)
+

core.git: Branch 'private/tvajngerl/staging' - 2807 commits - accessibility/inc accessibility/source android/Bootstrap android/Makefile android/source animations/source avmedia/source basctl/inc basct

2024-02-05 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit 2ceedfe4f55109619d9fee699791b951fc451c36
Author: Tomaž Vajngerl 
AuthorDate: Sun Mar 5 18:48:23 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Feb 5 16:18:17 2024 +0900

svx: use gfx::Length based types directly in SdrTextObj::NbcResize

Change-Id: I839430b30685994e1767998b353c63b97f461284

diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 7ed97774119d..f1abaf11e1b3 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -122,81 +122,102 @@ void SdrTextObj::NbcMove(const Size& rSize)
 
 void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const 
Fraction& yFact)
 {
-bool bNotSheared=maGeo.m_nShearAngle==0_deg100;
-bool bRotate90=bNotSheared && maGeo.m_nRotationAngle.get() % 9000 ==0;
-bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
-bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
-if (bXMirr || bYMirr) {
+bool bNotSheared = maGeo.m_nShearAngle == 0_deg100;
+bool bRotate90 = bNotSheared && maGeo.m_nRotationAngle.get() % 9000 == 0;
+
+bool bXMirrored = (xFact.GetNumerator() < 0) != (xFact.GetDenominator() < 
0);
+bool bYMirrored = (yFact.GetNumerator() < 0) != (yFact.GetDenominator() < 
0);
+
+double fFactorX = xFact.IsValid() ? double(xFact) : 1.0;
+double fFactorY = yFact.IsValid() ? double(yFact) : 1.0;
+
+if (bXMirrored || bYMirrored)
+{
 Point aRef1(GetSnapRect().Center());
-if (bXMirr) {
+if (bXMirrored)
+{
 Point aRef2(aRef1);
 aRef2.AdjustY( 1 );
 NbcMirrorGluePoints(aRef1,aRef2);
 }
-if (bYMirr) {
+if (bYMirrored)
+{
 Point aRef2(aRef1);
 aRef2.AdjustX( 1 );
 NbcMirrorGluePoints(aRef1,aRef2);
 }
 }
 
-if (maGeo.m_nRotationAngle==0_deg100 && maGeo.m_nShearAngle==0_deg100) {
-auto aRectangle = getRectangle();
-ResizeRect(aRectangle, rRef, xFact, yFact);
-setRectangle(aRectangle);
-if (bYMirr)
+if (maGeo.m_nRotationAngle == 0_deg100 && maGeo.m_nShearAngle == 0_deg100)
+{
+auto eUnit = getSdrModelFromSdrObject().getUnit();
+gfx::Tuple2DL aReference = createTupleFromPoint(rRef, eUnit);
+svx::resizeRange(maRectangleRange, aReference, fFactorX, fFactorY);
+
+if (bYMirrored)
 {
-//maRectangle.Normalize();
-moveRectangle(aRectangle.Right() - aRectangle.Left(), 
aRectangle.Bottom() - aRectangle.Top());
-maGeo.m_nRotationAngle=18000_deg100;
+maRectangleRange.shift(maRectangleRange.getWidth(), 
maRectangleRange.getHeight());
+maGeo.m_nRotationAngle = 18000_deg100;
 maGeo.RecalcSinCos();
 }
 }
 else
 {
-tools::Polygon aPol(Rect2Poly(getRectangle(), maGeo));
+tools::Polygon aPolygon(Rect2Poly(getRectangle(), maGeo));
 
-for(sal_uInt16 a(0); a < aPol.GetSize(); a++)
+for (sal_uInt16 a(0); a < aPolygon.GetSize(); a++)
 {
- ResizePoint(aPol[a], rRef, xFact, yFact);
+ ResizePoint(aPolygon[a], rRef, xFact, yFact);
 }
 
-if(bXMirr != bYMirr)
+if (bXMirrored != bYMirrored)
 {
 // turn polygon and move it a little
-tools::Polygon aPol0(aPol);
+tools::Polygon aPol0(aPolygon);
 
-aPol[0] = aPol0[1];
-aPol[1] = aPol0[0];
-aPol[2] = aPol0[3];
-aPol[3] = aPol0[2];
-aPol[4] = aPol0[1];
+aPolygon[0] = aPol0[1];
+aPolygon[1] = aPol0[0];
+aPolygon[2] = aPol0[3];
+aPolygon[3] = aPol0[2];
+aPolygon[4] = aPol0[1];
 }
-tools::Rectangle aRectangle = svx::polygonToRectangle(aPol, maGeo);
+tools::Rectangle aRectangle = svx::polygonToRectangle(aPolygon, maGeo);
 setRectangle(aRectangle);
 }
 
-if (bRotate90) {
-bool bRota90=maGeo.m_nRotationAngle.get() % 9000 ==0;
-if (!bRota90) { // there's seems to be a rounding error occurring: 
correct it
-Degree100 a=NormAngle36000(maGeo.m_nRotationAngle);
-if (a<4500_deg100) a=0_deg100;
-else if (a<13500_deg100) a=9000_deg100;
-else if (a<22500_deg100) a=18000_deg100;
-else if (a<31500_deg100) a=27000_deg100;
-else a=0_deg100;
-maGeo.m_nRotationAngle=a;
+if (bRotate90)
+{
+bool bRota90 = maGeo.m_nRotationAngle.get() % 9000 == 0;
+if (!bRota90)
+{
+// there's seems to be a rounding error occurring: correct it
+
+Degree100 angle = NormAngle36000(maGeo.m_nRotationAngle);
+if (angle < 4500_deg100)
+angle = 0_deg100;
+else if (angle < 13500_deg100)
+

core.git: editeng/source

2024-02-02 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editeng.cxx  |   13 +++--
 editeng/source/editeng/editview.cxx |2 +-
 editeng/source/editeng/impedit.cxx  |   34 +-
 editeng/source/editeng/impedit.hxx  |   24 ++--
 editeng/source/editeng/impedit2.cxx |   29 ++---
 editeng/source/editeng/impedit3.cxx |2 +-
 6 files changed, 50 insertions(+), 54 deletions(-)

New commits:
commit f104a9d8c806ccb352c680af6a29422d796114df
Author: Tomaž Vajngerl 
AuthorDate: Fri Feb 2 15:34:25 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Feb 2 11:29:32 2024 +0100

editeng: GetCursorFlags flags to CursorFlags struct of bools

Convert bitflags to struct of bools, which is much easier to read
and you don't need to mess with bitwise operations.

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

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 95f605b1ccbf..2493325ac578 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -996,7 +996,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, 
EditView* pEditView, v
 bool bAllowIdle = true;
 bool bReadOnly  = pEditView->IsReadOnly();
 
-GetCursorFlags nNewCursorFlags = GetCursorFlags::NONE;
+CursorFlags aNewCursorFlags;
 bool bSetCursorFlags = true;
 
 EditSelection aCurSel( pEditView->getImpl().GetEditSelection() );
@@ -1122,9 +1122,9 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, 
EditView* pEditView, v
 
 bMoved = true;
 if ( nCode == KEY_HOME )
-nNewCursorFlags |= GetCursorFlags::StartOfLine;
+aNewCursorFlags.bStartOfLine = true;
 else if ( nCode == KEY_END )
-nNewCursorFlags |= GetCursorFlags::EndOfLine;
+aNewCursorFlags.bEndOfLine = true;
 
 }
 #if OSL_DEBUG_LEVEL > 1
@@ -1402,7 +1402,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, 
EditView* pEditView, v
 }
 
 if (bSetCursorFlags)
-pEditView->getImpl().mnExtraCursorFlags = nNewCursorFlags;
+pEditView->getImpl().maExtraCursorFlags = aNewCursorFlags;
 
 if ( bModified )
 {
@@ -2410,8 +2410,9 @@ tools::Rectangle EditEngine::GetCharacterBounds( const 
EPosition& rPos ) const
 // Check against index, not paragraph
 if ( pNode && ( rPos.nIndex < pNode->Len() ) )
 {
-aBounds = getImpl().PaMtoEditCursor(EditPaM(pNode, rPos.nIndex), 
GetCursorFlags::TextOnly);
-tools::Rectangle aR2 = getImpl().PaMtoEditCursor(EditPaM(pNode, 
rPos.nIndex + 1), GetCursorFlags::TextOnly|GetCursorFlags::EndOfLine);
+aBounds = getImpl().PaMtoEditCursor(EditPaM(pNode, rPos.nIndex), 
CursorFlags{.bTextOnly = true});
+CursorFlags aFlags { .bTextOnly = true, .bEndOfLine = true};
+tools::Rectangle aR2 = getImpl().PaMtoEditCursor(EditPaM(pNode, 
rPos.nIndex + 1), aFlags);
 if ( aR2.Right() > aBounds.Right() )
 aBounds.SetRight( aR2.Right() );
 }
diff --git a/editeng/source/editeng/editview.cxx 
b/editeng/source/editeng/editview.cxx
index c8b702c0de71..e08c3c81d77d 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1006,7 +1006,7 @@ bool EditView::ExecuteSpellPopup(const Point& rPosPixel, 
const LinkLen() && ( aPaM.GetIndex() < 
aPaM.GetNode()->Len() ) )
 {
 // If we are behind a portion, and the next portion has other 
direction, we must change position...
-aEditCursor.SetLeft(getImpEditEngine().PaMtoEditCursor( aPaM, 
GetCursorFlags::TextOnly|GetCursorFlags::PreferPortionStart ).Left() );
+aEditCursor.SetLeft(getImpEditEngine().PaMtoEditCursor(aPaM, 
CursorFlags{.bTextOnly = true, .bPreferPortionStart = true}).Left());
 aEditCursor.SetRight( aEditCursor.Left() );
 
 sal_Int32 nTextPortion = 
rParaPortion.GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, 
true );
@@ -1125,9 +1123,9 @@ tools::Rectangle ImpEditView::ImplGetEditCursor(EditPaM& 
aPaM, GetCursorFlags nS
 else
 {
 EditPaM aNext = getEditEngine().CursorRight( aPaM );
-tools::Rectangle aTmpRect = 
getImpEditEngine().PaMtoEditCursor( aNext, GetCursorFlags::TextOnly );
+tools::Rectangle aTmpRect = 
getImpEditEngine().PaMtoEditCursor(aNext, CursorFlags{ .bTextOnly = true });
 if ( aTmpRect.Top() != aEditCursor.Top() )
-aTmpRect = getImpEditEngine().PaMtoEditCursor( aNext, 
GetCursorFlags::TextOnly|GetCursorFlags::EndOfLine );
+aTmpRect = getImpEditEngine().PaMtoEditCursor(aNext, 
CursorFlags{ .bTextOnly = true, 

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

2024-02-01 Thread Tomaž Vajngerl (via logerrit)
 include/sfx2/IDocumentModelAccessor.hxx |4 +
 sc/Library_sc.mk|1 
 sc/qa/unit/ucalc.cxx|   37 -
 sc/source/ui/docshell/DocumentModelAccessor.cxx |   50 
 sc/source/ui/inc/DocumentModelAccessor.hxx  |   31 --
 5 files changed, 91 insertions(+), 32 deletions(-)

New commits:
commit 15329e96c78232ee37102d24d221c01f0e209a29
Author: Tomaž Vajngerl 
AuthorDate: Wed Jan 31 00:13:02 2024 +0900
Commit: Miklos Vajna 
CommitDate: Thu Feb 1 14:03:22 2024 +0100

Currency pop-up: move getDocumentCurrencies to cxx, extend test

Test now checks that multiple cells with the same currency still
result in only one entry returned by getDocumentCurrencies.

Change-Id: I34b0fd3b117ce01b3fd462f684d0927dd53f796d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162788
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 1276daee3d0d4f30ee8844b6df55d72e0b54093f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162864
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/include/sfx2/IDocumentModelAccessor.hxx 
b/include/sfx2/IDocumentModelAccessor.hxx
index d843a1b41ed8..9980ce09992e 100644
--- a/include/sfx2/IDocumentModelAccessor.hxx
+++ b/include/sfx2/IDocumentModelAccessor.hxx
@@ -11,9 +11,13 @@
 #pragma once
 
 #include 
+#include 
+#include 
+#include 
 
 namespace sfx
 {
+/** Currency ID, to identify the currency in the currency list */
 struct SFX2_DLLPUBLIC CurrencyID
 {
 OUString aSymbol;
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index ec97db031a38..b610693f9946 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -441,6 +441,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/docshell/docsh6 \
 sc/source/ui/docshell/docsh8 \
 sc/source/ui/docshell/documentlinkmgr \
+sc/source/ui/docshell/DocumentModelAccessor \
 sc/source/ui/docshell/editable \
 sc/source/ui/docshell/externalrefmgr \
 sc/source/ui/docshell/impex \
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 35f33633b0ef..ac55a54bc0c8 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -7037,7 +7037,7 @@ void 
Test::testDocumentModelAccessor_getDocumentCurrencies()
 {
 m_pDoc->InsertTab(0, "Sheet1");
 
-// Check Document Currencies
+// Check document currencies - expect 0
 auto pAccessor = m_xDocShell->GetDocumentModelAccessor();
 CPPUNIT_ASSERT(pAccessor);
 CPPUNIT_ASSERT_EQUAL(size_t(0), pAccessor->getDocumentCurrencies().size());
@@ -7062,13 +7062,46 @@ void 
Test::testDocumentModelAccessor_getDocumentCurrencies()
 CPPUNIT_ASSERT_EQUAL(OUString(u"2,00€"), 
m_pDoc->GetString(ScAddress(0, 0, 0)));
 }
 
-// Check Document Currencies Again
+// Check document currencies again
 auto aCurrencyIDs = pAccessor->getDocumentCurrencies();
 CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
 
 CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
 CPPUNIT_ASSERT_EQUAL(OUString(u"-424"), aCurrencyIDs[0].aExtension);
 CPPUNIT_ASSERT_EQUAL(OUString(u"€"), aCurrencyIDs[0].aSymbol);
+
+// Set the same currency to 2 more cells
+{
+m_pDoc->SetValue(ScAddress(1, 1, 0), 5.0);
+m_pDoc->SetValue(ScAddress(2, 2, 0), 7.0);
+
+OUString aCode(u"#.##0,00[$€-424]");
+
+sal_Int32 nCheckPos;
+SvNumFormatType eType;
+sal_uInt32 nFormat;
+
+m_pDoc->GetFormatTable()->PutEntry(aCode, nCheckPos, eType, nFormat, 
LANGUAGE_SLOVENIAN);
+CPPUNIT_ASSERT_EQUAL(SvNumFormatType::CURRENCY, eType);
+
+ScPatternAttr aNewAttrs(m_pDoc->GetPool());
+SfxItemSet& rSet = aNewAttrs.GetItemSet();
+rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+m_pDoc->ApplyPattern(1, 1, 0, aNewAttrs); // B2.
+m_pDoc->ApplyPattern(2, 2, 0, aNewAttrs); // C3.
+
+CPPUNIT_ASSERT_EQUAL(OUString(u"5,00€"), 
m_pDoc->GetString(ScAddress(1, 1, 0)));
+CPPUNIT_ASSERT_EQUAL(OUString(u"7,00€"), 
m_pDoc->GetString(ScAddress(2, 2, 0)));
+}
+
+// Check document currencies again - should be 1 entry only
+aCurrencyIDs = pAccessor->getDocumentCurrencies();
+CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
+
+CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
+CPPUNIT_ASSERT_EQUAL(OUString(u"-424"), aCurrencyIDs[0].aExtension);
+CPPUNIT_ASSERT_EQUAL(OUString(u"€"), aCurrencyIDs[0].aSymbol);
+
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/sc/source/ui/docshell/DocumentModelAccessor.cxx 
b/sc/source/ui/docshell/DocumentModelAccessor.cxx
new file mode 100644
index ..bbe6f5e170af
--- /dev/null
+++ b/sc/source/ui/docshell/DocumentModelAccessor.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

core.git: include/sfx2 sc/Library_sc.mk sc/qa sc/source

2024-01-31 Thread Tomaž Vajngerl (via logerrit)
 include/sfx2/IDocumentModelAccessor.hxx |4 +
 sc/Library_sc.mk|1 
 sc/qa/unit/ucalc.cxx|   36 
 sc/source/ui/docshell/DocumentModelAccessor.cxx |   51 
 sc/source/ui/inc/DocumentModelAccessor.hxx  |   31 --
 5 files changed, 91 insertions(+), 32 deletions(-)

New commits:
commit 1276daee3d0d4f30ee8844b6df55d72e0b54093f
Author: Tomaž Vajngerl 
AuthorDate: Wed Jan 31 00:13:02 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Feb 1 05:00:07 2024 +0100

Currency pop-up: move getDocumentCurrencies to cxx, extend test

Test now checks that multiple cells with the same currency still
result in only one entry returned by getDocumentCurrencies.

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

diff --git a/include/sfx2/IDocumentModelAccessor.hxx 
b/include/sfx2/IDocumentModelAccessor.hxx
index d843a1b41ed8..9980ce09992e 100644
--- a/include/sfx2/IDocumentModelAccessor.hxx
+++ b/include/sfx2/IDocumentModelAccessor.hxx
@@ -11,9 +11,13 @@
 #pragma once
 
 #include 
+#include 
+#include 
+#include 
 
 namespace sfx
 {
+/** Currency ID, to identify the currency in the currency list */
 struct SFX2_DLLPUBLIC CurrencyID
 {
 OUString aSymbol;
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index c8f5b77d0e43..91ffcced298b 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -444,6 +444,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 sc/source/ui/docshell/docsh6 \
 sc/source/ui/docshell/docsh8 \
 sc/source/ui/docshell/documentlinkmgr \
+sc/source/ui/docshell/DocumentModelAccessor \
 sc/source/ui/docshell/editable \
 sc/source/ui/docshell/externalrefmgr \
 sc/source/ui/docshell/impex \
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index be7f19f1d2b6..efd836c89190 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -6865,7 +6865,7 @@ CPPUNIT_TEST_FIXTURE(Test, 
testDocumentModelAccessor_getDocumentCurrencies)
 {
 m_pDoc->InsertTab(0, "Sheet1");
 
-// Check Document Currencies
+// Check document currencies - expect 0
 auto pAccessor = m_xDocShell->GetDocumentModelAccessor();
 CPPUNIT_ASSERT(pAccessor);
 CPPUNIT_ASSERT_EQUAL(size_t(0), pAccessor->getDocumentCurrencies().size());
@@ -6891,13 +6891,45 @@ CPPUNIT_TEST_FIXTURE(Test, 
testDocumentModelAccessor_getDocumentCurrencies)
 CPPUNIT_ASSERT_EQUAL(u"2,00€"_ustr, m_pDoc->GetString(ScAddress(0, 0, 
0)));
 }
 
-// Check Document Currencies Again
+// Check document currencies again
 auto aCurrencyIDs = pAccessor->getDocumentCurrencies();
 CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
 
 CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
 CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension);
 CPPUNIT_ASSERT_EQUAL(u"€"_ustr, aCurrencyIDs[0].aSymbol);
+
+// Set the same currency to 2 more cells
+{
+m_pDoc->SetValue(ScAddress(1, 1, 0), 5.0);
+m_pDoc->SetValue(ScAddress(2, 2, 0), 7.0);
+
+OUString aCode = u"#.##0,00[$€-424]"_ustr;
+
+sal_Int32 nCheckPos;
+SvNumFormatType eType;
+sal_uInt32 nFormat;
+
+m_pDoc->GetFormatTable()->PutEntry(aCode, nCheckPos, eType, nFormat, 
LANGUAGE_SLOVENIAN);
+CPPUNIT_ASSERT_EQUAL(SvNumFormatType::CURRENCY, eType);
+
+ScPatternAttr aNewAttrs(m_pDoc->getCellAttributeHelper());
+SfxItemSet& rSet = aNewAttrs.GetItemSet();
+rSet.Put(SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat));
+m_pDoc->ApplyPattern(1, 1, 0, aNewAttrs); // B2.
+m_pDoc->ApplyPattern(2, 2, 0, aNewAttrs); // C3.
+
+CPPUNIT_ASSERT_EQUAL(u"5,00€"_ustr, m_pDoc->GetString(ScAddress(1, 1, 
0)));
+CPPUNIT_ASSERT_EQUAL(u"7,00€"_ustr, m_pDoc->GetString(ScAddress(2, 2, 
0)));
+}
+
+// Check document currencies again - should be 1 entry only
+aCurrencyIDs = pAccessor->getDocumentCurrencies();
+CPPUNIT_ASSERT_EQUAL(size_t(1), aCurrencyIDs.size());
+
+CPPUNIT_ASSERT_EQUAL(LANGUAGE_SLOVENIAN, aCurrencyIDs[0].eLanguage);
+CPPUNIT_ASSERT_EQUAL(u"-424"_ustr, aCurrencyIDs[0].aExtension);
+CPPUNIT_ASSERT_EQUAL(u"€"_ustr, aCurrencyIDs[0].aSymbol);
 }
 
 
diff --git a/sc/source/ui/docshell/DocumentModelAccessor.cxx 
b/sc/source/ui/docshell/DocumentModelAccessor.cxx
new file mode 100644
index ..0b7425c05d03
--- /dev/null
+++ b/sc/source/ui/docshell/DocumentModelAccessor.cxx
@@ -0,0 +1,51 @@
+/* -*- 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 

core.git: include/sfx2 include/svx sc/qa sc/source sfx2/source svx/source

2024-01-31 Thread Tomaž Vajngerl (via logerrit)
 include/sfx2/IDocumentModelAccessor.hxx|   43 +++
 include/sfx2/objsh.hxx |8 ++-
 include/svx/tbcontrl.hxx   |9 +---
 sc/qa/unit/ucalc.cxx   |   40 ++
 sc/source/core/data/docpool.cxx|2 
 sc/source/ui/docshell/docsh.cxx|8 +++
 sc/source/ui/inc/DocumentModelAccessor.hxx |   63 +
 sc/source/ui/inc/docsh.hxx |1 
 sfx2/source/doc/objcont.cxx|6 ++
 svx/source/items/numfmtsh.cxx  |5 +-
 svx/source/tbxctrls/tbcontrl.cxx   |   59 +--
 11 files changed, 221 insertions(+), 23 deletions(-)

New commits:
commit 2cac2ee38445c19c9281f54c2b961bbc9149cc00
Author: Tomaž Vajngerl 
AuthorDate: Sat Jan 27 00:33:56 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Feb 1 02:47:56 2024 +0100

sc: put used currencies on top of the currency pop-up list

The list of currencies is fairly long and there is no easy way
to search the list, so to make it easier to concurrently fint the
desired currency, put the currencies that are used in the document
on top of the list.

This adds a DocumentModelAccessor class, which is used to access
parts of the document model from other modules throught the
SfxObjectShell.

Change-Id: I81a180b674ae69b373b0422f363678e8bab37194
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162638
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 79da840fac78f11c156801c43d8b79d6d4f32869)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162755
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/sfx2/IDocumentModelAccessor.hxx 
b/include/sfx2/IDocumentModelAccessor.hxx
new file mode 100644
index ..d843a1b41ed8
--- /dev/null
+++ b/include/sfx2/IDocumentModelAccessor.hxx
@@ -0,0 +1,43 @@
+/* -*- 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 
+
+namespace sfx
+{
+struct SFX2_DLLPUBLIC CurrencyID
+{
+OUString aSymbol;
+OUString aExtension;
+LanguageType eLanguage;
+};
+
+/** Document model accessor, used to access parts of the document model.
+ *
+ * This is useful when some common parts of the model are needed, but can
+ * only access the model indirecly from other modules that can access
+ * SfxObjectShell, but don't have a direct access to the document model
+ * (and access through UNO would be inconvenient).
+ *
+ * For example - get information about various parts of the document in
+ * generic dialogs (in CUI).
+ */
+class SFX2_DLLPUBLIC IDocumentModelAccessor
+{
+public:
+virtual std::vector getDocumentCurrencies() const { return {}; 
}
+virtual ~IDocumentModelAccessor() = default;
+};
+
+} // end sfx namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 20e497b6e4af..3175cb283642 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -89,8 +89,11 @@ namespace sfx2
 {
 class SvLinkSource;
 class StyleManager;
+class IXmlIdRegistry;
 }
 
+namespace sfx { class IDocumentModelAccessor; }
+
 namespace com::sun::star::awt { class XWindow; }
 namespace com::sun::star::beans { struct PropertyValue; }
 namespace com::sun::star::document { struct CmisVersion; }
@@ -107,8 +110,6 @@ namespace com::sun::star::task { class XInteractionHandler; 
}
 namespace com::sun::star::lang { class XComponent; }
 namespace com::sun::star::text { class XTextRange; }
 
-namespace sfx2 { class IXmlIdRegistry; }
-
 #define SFX_TITLE_TITLE0
 #define SFX_TITLE_FILENAME 1
 #define SFX_TITLE_FULLNAME 2
@@ -574,7 +575,8 @@ public:
 std::optional GetRecentColor(sal_uInt16 nSlotId);
 void SetRecentColor(sal_uInt16 nSlotId, const NamedColor& rColor);
 
-virtual std::set GetDocColors();
+virtual std::shared_ptr 
GetDocumentModelAccessor() const;
+virtual std::set GetDocColors();
 virtual std::shared_ptr GetThemeColors();
 
 // Accessibility Check
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 9fffced835cb..f930d46b208d 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -146,10 +146,8 @@ class SfxStyleSheetBasePool;
 class SfxTemplateItem;
 class PaletteManager;
 
-namespace svx
-{
-class ToolboxButtonColorUpdaterBase;
-}
+namespace svx { class ToolboxButtonColorUpdaterBase; }
+namespace sfx { struct CurrencyID; }
 
 class SvxStyleToolBoxControl final : public 
cppu::ImplInheritanceHelper
@@ -264,7 +262,8 @@ public:
 * 

core.git: editeng/source include/editeng

2024-01-31 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editdbg.cxx |   12 
 editeng/source/editeng/editeng.cxx | 1085 +
 editeng/source/editeng/impedit.hxx |6 
 editeng/source/editeng/impedit2.cxx|4 
 editeng/source/outliner/overflowingtxt.cxx |2 
 include/editeng/editeng.hxx|   22 
 6 files changed, 544 insertions(+), 587 deletions(-)

New commits:
commit cc2e1e29489994fd28660cff384820e6676cce06
Author: Tomaž Vajngerl 
AuthorDate: Sun Jan 28 23:49:50 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Feb 1 01:42:22 2024 +0100

editeng: access ImpEditEngine with getImpl() not direct

In EditEngine use getImpl() when accessing ImpEditEngine and not
directly via the mpImpEditEngine member variable.

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

diff --git a/editeng/source/editeng/editdbg.cxx 
b/editeng/source/editeng/editdbg.cxx
index 1d43b1dc8487..eb31279034b0 100644
--- a/editeng/source/editeng/editdbg.cxx
+++ b/editeng/source/editeng/editdbg.cxx
@@ -345,9 +345,9 @@ void EditEngine::DumpData(const EditEngine* pEE, bool 
bInfoBox)
 fprintf( fp, 
""
 );
 fprintf( fp, "
==   Document   
" );
 fprintf( fp, "
"
 );
-for ( sal_Int32 nPortion = 0; nPortion < 
pEE->pImpEditEngine->GetParaPortions().Count(); nPortion++)
+for ( sal_Int32 nPortion = 0; nPortion < 
pEE->getImpl().GetParaPortions().Count(); nPortion++)
 {
-ParaPortion const& rPPortion = 
pEE->pImpEditEngine->GetParaPortions().getRef(nPortion);
+ParaPortion const& rPPortion = 
pEE->getImpl().GetParaPortions().getRef(nPortion);
 fprintf( fp, "
Paragraph %" SAL_PRIdINT32 ": Length = %" SAL_PRIdINT32 ", Invalid = %i
Text = '%s'",
  nPortion, rPPortion.GetNode()->Len(), rPPortion.IsInvalid(),
  OUStringToOString(rPPortion.GetNode()->GetString(), 
RTL_TEXTENCODING_UTF8).getStr() );
@@ -434,9 +434,9 @@ void EditEngine::DumpData(const EditEngine* pEE, bool 
bInfoBox)
 fprintf( fp, "
-" 
);
 }
 
-if ( pEE->pImpEditEngine->GetStyleSheetPool() )
+if (pEE->getImpl().GetStyleSheetPool())
 {
-SfxStyleSheetIterator aIter( pEE->pImpEditEngine->GetStyleSheetPool(), 
SfxStyleFamily::All );
+SfxStyleSheetIterator aIter(pEE->getImpl().GetStyleSheetPool(), 
SfxStyleFamily::All);
 sal_uInt16 nStyles = aIter.Count();
 fprintf( fp, "

"
 );
 fprintf( fp, "
==   Stylesheets   
=" );
@@ -458,13 +458,13 @@ void EditEngine::DumpData(const EditEngine* pEE, bool 
bInfoBox)
 fprintf( fp, "

"
 );
 fprintf( fp, "
==   Defaults   
" );
 fprintf( fp, "
"
 );
-DbgOutItemSet( fp, pEE->pImpEditEngine->GetEmptyItemSet(), true, true );
+DbgOutItemSet(fp, pEE->getImpl().GetEmptyItemSet(), true, true);
 
 fprintf( fp, "

"
 );
 fprintf( fp, "
==   EditEngine & Views   
==" );
 fprintf( fp, "
"
 );
 fprintf( fp, "
Control: %x", unsigned( pEE->GetControlWord() ) );
-fprintf( fp, "
RefMapMode: %i", int( pEE->pImpEditEngine->mpRefDev->GetMapMode().GetMapUnit() 
) );
+fprintf( fp, "
RefMapMode: %i", int( pEE->getImpl().mpRefDev->GetMapMode().GetMapUnit()));
 fprintf( fp, "
PaperSize: %" SAL_PRIdINT64 " x %" SAL_PRIdINT64, 
sal_Int64(pEE->GetPaperSize().Width()), sal_Int64(pEE->GetPaperSize().Height()) 
);
 fprintf( fp, "
MaxAutoPaperSize: %" SAL_PRIdINT64 " x %" SAL_PRIdINT64, 
sal_Int64(pEE->GetMaxAutoPaperSize().Width()), 
sal_Int64(pEE->GetMaxAutoPaperSize().Height()) );
 fprintf( fp, "
MinAutoPaperSize: %" SAL_PRIdINT64 " x %" SAL_PRIdINT64 , 
sal_Int64(pEE->GetMinAutoPaperSize().Width()), 
sal_Int64(pEE->GetMinAutoPaperSize().Height()) );
diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 51dce307064b..95f605b1ccbf 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -85,125 +85,122 @@ using namespace ::com::sun::star::linguistic2;
 static bool 

core.git: include/svx svx/source

2024-01-31 Thread Tomaž Vajngerl (via logerrit)
 include/svx/tbcontrl.hxx |   65 ---
 svx/source/tbxctrls/tbcontrl.cxx |  168 +--
 2 files changed, 42 insertions(+), 191 deletions(-)

New commits:
commit 8cccfc82a3038bc28864ae9e94418a141b4aa545
Author: Tomaž Vajngerl 
AuthorDate: Tue Jan 30 22:59:11 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Jan 31 09:03:39 2024 +0100

Revert "store last five MRU currencies in the currency drop-down"

This reverts commit dc6b93011cc5435f367666e43e354c6ab97bbc90.

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

diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 11d41ee4ddde..9fffced835cb 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -249,73 +249,11 @@ public:
 /** Popup controller for currency combo widget **/
 class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) SvxCurrencyToolBoxControl final : 
public svt::PopupWindowController
 {
-public:
-/**
-* Struct containing currency data
-* an instance corresponds to a line in the combo
-**/
-struct SvxCurrencyData {
-/** position of the currency in 
SvxCurrencyToolBoxControl::CurrencySymbols vector **/
-sal_uInt16 m_currencyIdx;
-
-/**
-* False if the instance corresponds to a line of the combo that shows 
only the ISO code
-* True otherwise
-**/
-bool m_onlyIsoCode;
-OUString m_label;
-
-/** Constant for invalid currency **/
-static const sal_uInt16 InvalidCurrency;
-
-/**
-* Constructor
-*
-* @param currencyIdx Position of the currency in 
SvxCurrencyToolBoxControl::CurrencySymbols vector
-* @param onlyIsoCode False if the instance corresponds to a line of 
the combo that shows
-* only the ISO code True otherwise
-**/
-SvxCurrencyData(
-sal_uInt16 currencyIdx = InvalidCurrency,
-bool onlyIsoCode = false
-);
-
-/** Needed by std::find **/
-bool operator == (const SvxCurrencyData& other) const;
-};
-
-/** vector of combo box currencies **/
-typedef std::vector SvxCurrencyVect_t;
-
 private:
 OUString m_aFormatString;
 LanguageType m_eLanguage;
 sal_uInt32   m_nFormatKey;
 
-/** Currencies in the combo **/
-SvxCurrencyVect_t  m_currencies;
-
-
-/** Most recently used currencies **/
-SvxCurrencyVect_t  m_mru_currencies;
-
-/** Adds a currency to the most recently used list **/
-void addMruCurrency(sal_Int16 currencyPosition);
-
-/**
-* Inner static method that polialtes the currency list and the most 
recently used
-* currency list.
-* The method is static for backward compatibility: it is used by the two
-* homonymous public methods, one of which is static while the other is 
instance
-*
-* @param bFlag used by SvxNumberFormatShell::GetCurrencySymbols
-* @param p_mru_currencies output: most recently used currencies
-* @param pCurrencies output: most recently used currencies
-* @see SvxNumberFormatShell::GetCurrencySymbols
-**/
-static void inner_GetCurrencySymbols( bool bFlag, SvxCurrencyVect_t 
_mru_currencies,
-SvxCurrencyVect_t );
-
 public:
 /**
 * Static method used by SvxNumberFormatShell::GetCurrencySymbols
@@ -328,9 +266,6 @@ public:
 static void GetCurrencySymbols( std::vector& rList, bool bFlag,
 std::vector& rCurrencyList );
 
-/** Instance method used by SvxCurrencyList_Impl constructor **/
-const SvxCurrencyVect_t& GetCurrencySymbols();
-
 explicit SvxCurrencyToolBoxControl( const 
css::uno::Reference& rContext );
 virtual ~SvxCurrencyToolBoxControl() override;
 
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 9a3669aac56a..192bf6c6fdd5 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -112,10 +112,6 @@
 
 #define COMBO_WIDTH_IN_CHARS18
 
-#define MAX_MRU_CURRENCIES  5
-
-#define INVALID_CURRENCYsal_uInt16(-2)
-
 // namespaces
 using namespace ::editeng;
 using namespace ::com::sun::star;
@@ -3915,13 +3911,15 @@ namespace
 , m_rSelectedFormat(rSelectedFormat)
 , m_eSelectedLanguage(eSelectedLanguage)
 {
+std::vector< OUString > aList;
+std::vector< sal_uInt16 > aCurrencyList;
 const NfCurrencyTable& rCurrencyTable = 
SvNumberFormatter::GetTheCurrencyTable();
 sal_uInt16 nLen = rCurrencyTable.size();
 
 SvNumberFormatter aFormatter( m_xControl->getContext(), 
LANGUAGE_SYSTEM );
 m_eFormatLanguage = aFormatter.GetLanguage();
 
-const SvxCurrencyToolBoxControl::SvxCurrencyVect_t  = 

core.git: Branch 'distro/collabora/co-23.05' - include/sfx2 include/svx sc/qa sc/source sfx2/source svx/source

2024-01-30 Thread Tomaž Vajngerl (via logerrit)
 include/sfx2/IDocumentModelAccessor.hxx|   42 +++
 include/sfx2/objsh.hxx |8 ++-
 include/svx/tbcontrl.hxx   |9 +---
 sc/qa/unit/ucalc.cxx   |   41 ++
 sc/source/ui/docshell/docsh.cxx|8 +++
 sc/source/ui/inc/DocumentModelAccessor.hxx |   63 +
 sc/source/ui/inc/docsh.hxx |1 
 sfx2/source/doc/objcont.cxx|6 ++
 svx/source/items/numfmtsh.cxx  |5 +-
 svx/source/tbxctrls/tbcontrl.cxx   |   59 +--
 10 files changed, 220 insertions(+), 22 deletions(-)

New commits:
commit 79da840fac78f11c156801c43d8b79d6d4f32869
Author: Tomaž Vajngerl 
AuthorDate: Sat Jan 27 00:33:56 2024 +0900
Commit: Miklos Vajna 
CommitDate: Tue Jan 30 10:38:00 2024 +0100

sc: put used currencies on top of the currency pop-up list

The list of currencies is fairly long and there is no easy way
to search the list, so to make it easier to concurrently fint the
desired currency, put the currencies that are used in the document
on top of the list.

This adds a DocumentModelAccessor class, which is used to access
parts of the document model from other modules throught the
SfxObjectShell.

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

diff --git a/include/sfx2/IDocumentModelAccessor.hxx 
b/include/sfx2/IDocumentModelAccessor.hxx
new file mode 100644
index ..8bd0f6b68c95
--- /dev/null
+++ b/include/sfx2/IDocumentModelAccessor.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 
+
+namespace sfx
+{
+struct SFX2_DLLPUBLIC CurrencyID
+{
+OUString aSymbol;
+OUString aExtension;
+LanguageType eLanguage;
+};
+
+/** Document model accessor, used to access parts of the document model.
+ *
+ * This is useful when some common parts of the model are needed, but can
+ * only access the model indirecly from other modules that can access
+ * SfxObjectShell, but don't have a direct access to the document model
+ * (and access through UNO would be inconvenient).
+ *
+ * For example - get information about various parts of the document in
+ * generic dialogs (in CUI).
+ */
+class SFX2_DLLPUBLIC IDocumentModelAccessor
+{
+public:
+virtual std::vector getDocumentCurrencies() const { return {}; 
}
+};
+
+} // end sfx namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index 0e1ec4d208de..db36fb493452 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -88,8 +88,11 @@ namespace sfx2
 {
 class SvLinkSource;
 class StyleManager;
+class IXmlIdRegistry;
 }
 
+namespace sfx { class IDocumentModelAccessor; }
+
 namespace com::sun::star::awt { class XWindow; }
 namespace com::sun::star::beans { struct PropertyValue; }
 namespace com::sun::star::document { struct CmisVersion; }
@@ -106,8 +109,6 @@ namespace com::sun::star::task { class XInteractionHandler; 
}
 namespace com::sun::star::lang { class XComponent; }
 namespace com::sun::star::text { class XTextRange; }
 
-namespace sfx2 { class IXmlIdRegistry; }
-
 #define SFX_TITLE_TITLE0
 #define SFX_TITLE_FILENAME 1
 #define SFX_TITLE_FULLNAME 2
@@ -564,7 +565,8 @@ public:
 GetDialogContainer();
 StarBASIC*  GetBasic() const;
 
-virtual std::set GetDocColors();
+virtual std::shared_ptr 
GetDocumentModelAccessor() const;
+virtual std::set GetDocColors();
 virtual std::shared_ptr GetThemeColors();
 
 // Accessibility Check
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 8347e3b9df1e..e9984daeab89 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -147,10 +147,8 @@ class SfxStyleSheetBasePool;
 class SfxTemplateItem;
 class PaletteManager;
 
-namespace svx
-{
-class ToolboxButtonColorUpdaterBase;
-}
+namespace svx { class ToolboxButtonColorUpdaterBase; }
+namespace sfx { struct CurrencyID; }
 
 class SvxStyleToolBoxControl final : public 
cppu::ImplInheritanceHelper
@@ -257,7 +255,8 @@ private:
 
 public:
 static void GetCurrencySymbols( std::vector& rList, bool bFlag,
-std::vector& rCurrencyList );
+std::vector& rCurrencyList,
+std::vector const& 
rCurrencyIDs);
 
 explicit 

core.git: sc/source

2024-01-30 Thread Tomaž Vajngerl (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit b1af5dc4f342e4d5fcae8d4c021b6369d6544ea7
Author: Tomaž Vajngerl 
AuthorDate: Tue Jan 30 16:02:31 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 30 10:10:34 2024 +0100

Revert "sc lok: don't set the GridWindow size to document size"

This reverts commit 7bc36867e84f7b9ad091d320b5520d5bb6c287e4.

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

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 8e1db84c65b9..96c4d18f69d7 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -563,7 +563,9 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 // to pass it down to ScGridWindow::PaintFile to avoid computing twice.
 SCCOL nTiledRenderingAreaEndCol = 0;
 SCROW nTiledRenderingAreaEndRow = 0;
-(void)getDocumentSize(nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow);
+Size aDocSize = getDocumentSize(nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow);
+
+pGridWindow->SetOutputSizePixel(Size(aDocSize.Width() * 
pViewData->GetPPTX(), aDocSize.Height() * pViewData->GetPPTY()));
 
 pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight,
 nTilePosX, nTilePosY, nTileWidth, nTileHeight,


core.git: compilerplugins/clang include/sfx2 sfx2/source

2024-01-30 Thread Tomaž Vajngerl (via logerrit)
 compilerplugins/clang/badstatics.cxx|3 
 include/sfx2/notebookbar/SfxNotebookBar.hxx |9 --
 sfx2/source/notebookbar/SfxNotebookBar.cxx  |   99 ++--
 3 files changed, 80 insertions(+), 31 deletions(-)

New commits:
commit 74ee046a04d6893db5b772f8f4219f7db413fbb8
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 29 16:08:48 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 30 10:10:07 2024 +0100

lok: introduce NotebookBarViewManager and NotebookBarViewData

NotebookBarViewManager is a singleton which is responsible to hold
NotebookBar view specific data, which is kept in NotebookBarViewData
class. The idea is to have one NotebookBarViewData class instance
per one view (SfxViewShell instance).

This also refactors the existing code and now moves the
m_pWeldedWrapper, m_pNotebookBar and the m_pToolbarUnoDispatcher
into NotebookBarViewData class.

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

diff --git a/compilerplugins/clang/badstatics.cxx 
b/compilerplugins/clang/badstatics.cxx
index 328218086453..18638695bbeb 100644
--- a/compilerplugins/clang/badstatics.cxx
+++ b/compilerplugins/clang/badstatics.cxx
@@ -210,8 +210,7 @@ public:
 || name == "s_aLOKWindowsMap" // LOK only, guarded by assert, 
and LOK never tries to perform a VCL cleanup
 || name == "s_aLOKWeldBuildersMap" // LOK only, similar case 
as above
 || name == "s_aLOKPopupsMap" // LOK only, similar case as above
-|| name == "m_pNotebookBarWeldedWrapper" // LOK only, warning 
about map's key, no VCL cleanup performed
-|| name == "m_pNotebookBarInstance" // LOK only case, when 
notebookbar is closed - VclPtr instance is removed
+|| name == "gNotebookBarManager" // LOK only case, when 
notebookbar is closed - VclPtr instance is removed
 || name == "gStaticManager" // vcl/source/graphic/Manager.cxx 
- stores non-owning pointers
 || name == "aThreadedInterpreterPool"// 
ScInterpreterContext(Pool), not owning
 || name == "aNonThreadedInterpreterPool" // 
ScInterpreterContext(Pool), not owning
diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx 
b/include/sfx2/notebookbar/SfxNotebookBar.hxx
index cd94ddad7b1e..47bd9cc79901 100644
--- a/include/sfx2/notebookbar/SfxNotebookBar.hxx
+++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx
@@ -16,7 +16,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
@@ -33,8 +32,7 @@ class SfxBindings;
 class SfxViewFrame;
 class SfxViewShell;
 class SystemWindow;
-class ToolbarUnoDispatcher;
-class WeldedTabbedNotebookbar;
+class ViewInstanceManager;
 
 namespace sfx2
 {
@@ -75,11 +73,6 @@ public:
 private:
 static bool m_bLock;
 static bool m_bHide;
-static std::unique_ptr m_xCalcToolboxDispatcher;
-
-static std::map>
-m_pNotebookBarWeldedWrapper;
-static std::map> 
m_pNotebookBarInstance;
 
 static void ResetActiveToolbarModeToDefault(vcl::EnumContext::Application 
eApp);
 static void RemoveCurrentLOKWrapper();
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx 
b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 9c33b3ef5fb9..c6b1cddb34ad 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 using namespace sfx2;
@@ -42,9 +42,68 @@ const char MERGE_NOTEBOOKBAR_URL[] = "URL";
 
 bool SfxNotebookBar::m_bLock = false;
 bool SfxNotebookBar::m_bHide = false;
-std::unique_ptr SfxNotebookBar::m_xCalcToolboxDispatcher;
-std::map> 
SfxNotebookBar::m_pNotebookBarWeldedWrapper;
-std::map> 
SfxNotebookBar::m_pNotebookBarInstance;
+
+namespace
+{
+
+/** View specific notebook bar data */
+struct NotebookBarViewData
+{
+std::unique_ptr m_pWeldedWrapper;
+VclPtr m_pNotebookBar;
+std::unique_ptr m_pToolbarUnoDispatcher;
+
+~NotebookBarViewData()
+{
+if (m_pNotebookBar)
+m_pNotebookBar.disposeAndClear();
+}
+};
+
+/** Notebookbar instance manager is a singleton that is used for track the
+ *  per-view instances of view specifc data contained in NotebookBarViewData
+ *  class.
+ **/
+class NotebookBarViewManager final
+{
+private:
+// map contains a view data instance for a view (SfxViewShell pointer)
+std::unordered_map> m_pViewDataList;
+
+// private constructor to prevent any other instantiation outside of get() 
method
+NotebookBarViewManager() = default;
+
+// prevent class copying
+NotebookBarViewManager(const NotebookBarViewManager&) = delete;
+NotebookBarViewManager& operator=(const NotebookBarViewManager&) = delete;
+
+public:
+// Singleton get method - creates an instance on first get() call
+static 

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

2024-01-29 Thread Tomaž Vajngerl (via logerrit)
 include/sfx2/notebookbar/SfxNotebookBar.hxx |9 --
 sfx2/source/notebookbar/SfxNotebookBar.cxx  |   99 ++--
 2 files changed, 79 insertions(+), 29 deletions(-)

New commits:
commit da8ebd2c348affbd7fa4975910296f32d3c9d1b0
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 29 16:08:48 2024 +0900
Commit: Szymon Kłos 
CommitDate: Mon Jan 29 22:09:30 2024 +0100

lok: introduce NotebookBarViewManager and NotebookBarViewData

NotebookBarViewManager is a singleton which is responsible to hold
NotebookBar view specific data, which is kept in NotebookBarViewData
class. The idea is to have one NotebookBarViewData class instance
per one view (SfxViewShell instance).

This also refactors the existing code and now moves the
m_pWeldedWrapper, m_pNotebookBar and the m_pToolbarUnoDispatcher
into NotebookBarViewData class.

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

diff --git a/include/sfx2/notebookbar/SfxNotebookBar.hxx 
b/include/sfx2/notebookbar/SfxNotebookBar.hxx
index cd94ddad7b1e..47bd9cc79901 100644
--- a/include/sfx2/notebookbar/SfxNotebookBar.hxx
+++ b/include/sfx2/notebookbar/SfxNotebookBar.hxx
@@ -16,7 +16,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 
@@ -33,8 +32,7 @@ class SfxBindings;
 class SfxViewFrame;
 class SfxViewShell;
 class SystemWindow;
-class ToolbarUnoDispatcher;
-class WeldedTabbedNotebookbar;
+class ViewInstanceManager;
 
 namespace sfx2
 {
@@ -75,11 +73,6 @@ public:
 private:
 static bool m_bLock;
 static bool m_bHide;
-static std::unique_ptr m_xCalcToolboxDispatcher;
-
-static std::map>
-m_pNotebookBarWeldedWrapper;
-static std::map> 
m_pNotebookBarInstance;
 
 static void ResetActiveToolbarModeToDefault(vcl::EnumContext::Application 
eApp);
 static void RemoveCurrentLOKWrapper();
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx 
b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index e1a8cfb56bca..657f97840843 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -28,7 +28,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 using namespace sfx2;
@@ -42,9 +42,68 @@ const char MERGE_NOTEBOOKBAR_URL[] = "URL";
 
 bool SfxNotebookBar::m_bLock = false;
 bool SfxNotebookBar::m_bHide = false;
-std::unique_ptr SfxNotebookBar::m_xCalcToolboxDispatcher;
-std::map> 
SfxNotebookBar::m_pNotebookBarWeldedWrapper;
-std::map> 
SfxNotebookBar::m_pNotebookBarInstance;
+
+namespace
+{
+
+/** View specific notebook bar data */
+struct NotebookBarViewData
+{
+std::unique_ptr m_pWeldedWrapper;
+VclPtr m_pNotebookBar;
+std::unique_ptr m_pToolbarUnoDispatcher;
+
+~NotebookBarViewData()
+{
+if (m_pNotebookBar)
+m_pNotebookBar.disposeAndClear();
+}
+};
+
+/** Notebookbar instance manager is a singleton that is used for track the
+ *  per-view instances of view specifc data contained in NotebookBarViewData
+ *  class.
+ **/
+class NotebookBarViewManager final
+{
+private:
+// map contains a view data instance for a view (SfxViewShell pointer)
+std::unordered_map> m_pViewDataList;
+
+// private constructor to prevent any other instantiation outside of get() 
method
+NotebookBarViewManager() = default;
+
+// prevent class copying
+NotebookBarViewManager(const NotebookBarViewManager&) = delete;
+NotebookBarViewManager& operator=(const NotebookBarViewManager&) = delete;
+
+public:
+// Singleton get method - creates an instance on first get() call
+static NotebookBarViewManager& get()
+{
+static NotebookBarViewManager gManager;
+return gManager;
+}
+
+NotebookBarViewData& getViewData(const SfxViewShell* pViewShell)
+{
+auto aFound = m_pViewDataList.find(pViewShell);
+if (aFound != m_pViewDataList.end()) // found
+return *aFound->second;
+
+// Create new view data instance
+NotebookBarViewData* pViewData = new NotebookBarViewData;
+m_pViewDataList.emplace(pViewShell, 
std::unique_ptr(pViewData));
+return *pViewData;
+}
+
+void removeViewData(const SfxViewShell* pViewShell)
+{
+m_pViewDataList.erase(pViewShell);
+}
+};
+
+} // end anonymous namespace
 
 static void NotebookbarAddonValues(
 std::vector& aImageValues,
@@ -200,13 +259,13 @@ static utl::OConfigurationNode 
lcl_getCurrentImplConfigNode(const Reference VclDisposeHdl
-// which clears also m_pNotebookBarWeldedWrapper
-aFound->second.disposeAndClear();
-m_pNotebookBarInstance.erase(aFound);
+// which clears the whole InstanceManager
+rViewData.m_pNotebookBar.disposeAndClear();
 }
 }
 
@@ -374,7 +433,8 @@ bool SfxNotebookBar::StateMethod(SystemWindow* pSysWindow,
 }
 
 

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

2024-01-25 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/drviewsf.cxx |   15 ---
 1 file changed, 15 deletions(-)

New commits:
commit ae17868cb81f593913982454bfd07c863e569941
Author: Tomaž Vajngerl 
AuthorDate: Wed Aug 30 09:15:56 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jan 25 11:02:35 2024 +0100

sd: remove condition to only show ThemeDialog in master view

Change-Id: I09ce07f7b520688aa54dd30107b5ab2218b12894
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156277
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 62804da3c0ab9443cf36f2e02387a2e9c272d5dc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162463
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit 77070aedb602729c523ea166aa92d7c227a88312)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162466
Reviewed-by: Xisco Fauli 

diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 1844d796036d..c8c6933c29a1 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -470,21 +470,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
 }
 break;
 
-case SID_THEME_DIALOG:
-{
-bool bDisable = true;
-SdrPageView* pPageView = mpDrawView->GetSdrPageView();
-if (pPageView)
-{
-SdPage* pPage = 
dynamic_cast(pPageView->GetPage());
-if (pPage && pPage->IsMasterPage())
-bDisable = false;
-}
-if (bDisable)
-rSet.DisableItem(nWhich);
-}
-break;
-
 case SID_STYLE_FAMILY2:
 case SID_STYLE_FAMILY3:
 case SID_STYLE_FAMILY5:


core.git: 2 commits - editeng/source include/editeng

2024-01-25 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editeng.cxx  |   47 +--
 editeng/source/editeng/editsel.cxx  |8 
 editeng/source/editeng/editundo.cxx |   52 +--
 editeng/source/editeng/editview.cxx |  361 
 editeng/source/editeng/edtspell.cxx |   11 
 editeng/source/editeng/impedit.cxx  |  520 ++--
 editeng/source/editeng/impedit.hxx  |  138 +
 editeng/source/editeng/impedit2.cxx |   98 +++---
 editeng/source/editeng/impedit3.cxx |   18 -
 editeng/source/editeng/impedit4.cxx |   84 ++---
 editeng/source/editeng/impedit5.cxx |2 
 editeng/source/editeng/textconv.cxx |6 
 include/editeng/editview.hxx|4 
 13 files changed, 677 insertions(+), 672 deletions(-)

New commits:
commit da1df4cc483f10667c3d42369581d53a5b34f421
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 22 00:26:48 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Jan 25 11:02:13 2024 +0100

editeng: prefix members of ImpEditView

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

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 61b979abd320..51dce307064b 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1400,7 +1400,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, 
EditView* pEditView, v
 if ( ( !IsEffectivelyVertical() && ( nCode != KEY_UP ) && ( nCode != 
KEY_DOWN ) ) ||
  ( IsEffectivelyVertical() && ( nCode != KEY_LEFT ) && ( nCode != 
KEY_RIGHT ) ))
 {
-pEditView->getImpl().nTravelXPos = TRAVEL_X_DONTKNOW;
+pEditView->getImpl().mnTravelXPos = TRAVEL_X_DONTKNOW;
 }
 
 if ( /* ( nCode != KEY_HOME ) && ( nCode != KEY_END ) && */
@@ -1410,8 +1410,8 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, 
EditView* pEditView, v
 pEditView->getImpl().SetCursorBidiLevel( CURSOR_BIDILEVEL_DONTKNOW );
 }
 
-if ( bSetCursorFlags )
-pEditView->getImpl().nExtraCursorFlags = nNewCursorFlags;
+if (bSetCursorFlags)
+pEditView->getImpl().mnExtraCursorFlags = nNewCursorFlags;
 
 if ( bModified )
 {
diff --git a/editeng/source/editeng/editview.cxx 
b/editeng/source/editeng/editview.cxx
index 791902f4e486..c8b702c0de71 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -183,11 +183,11 @@ EditEngine& EditView::getEditEngine() const
 
 tools::Rectangle EditView::GetInvalidateRect() const
 {
-if ( !getImpl().DoInvalidateMore() )
-return getImpl().aOutArea;
+if (!getImpl().DoInvalidateMore())
+return getImpl().maOutputArea;
 else
 {
-tools::Rectangle aRect( getImpl().aOutArea );
+tools::Rectangle aRect(getImpl().maOutputArea);
 tools::Long nMore = getImpl().GetOutputDevice().PixelToLogic( Size( 
getImpl().GetInvalidateMore(), 0 ) ).Width();
 aRect.AdjustLeft( -nMore );
 aRect.AdjustRight(nMore );
@@ -229,7 +229,7 @@ void EditView::InvalidateOtherViewWindows( const 
tools::Rectangle& rInvRect )
 if (comphelper::LibreOfficeKit::isActive())
 {
 bool bNegativeX = IsNegativeX();
-for (auto& pWin : getImpl().aOutWindowSet)
+for (auto& pWin : getImpl().maOutWindowSet)
 {
 if (pWin)
 {
@@ -249,12 +249,12 @@ void EditView::Invalidate()
 
 void EditView::SetReadOnly( bool bReadOnly )
 {
-getImpl().bReadOnly = bReadOnly;
+getImpl().mbReadOnly = bReadOnly;
 }
 
 bool EditView::IsReadOnly() const
 {
-return getImpl().bReadOnly;
+return getImpl().mbReadOnly;
 }
 
 void EditView::SetSelection( const ESelection& rESel )
@@ -364,15 +364,15 @@ void EditView::setEditEngine(EditEngine* pEditEngine)
 getImpl().SetEditSelection( aStartSel );
 }
 
-void EditView::SetWindow( vcl::Window* pWin )
+void EditView::SetWindow(vcl::Window* pWindow)
 {
-getImpl().pOutWin = pWin;
+getImpl().mpOutputWindow = pWindow;
 getImpEditEngine().GetSelEngine().Reset();
 }
 
 vcl::Window* EditView::GetWindow() const
 {
-return getImpl().pOutWin;
+return getImpl().mpOutputWindow;
 }
 
 OutputDevice& EditView::GetOutputDevice() const
@@ -390,7 +390,7 @@ LanguageType EditView::GetInputLanguage() const
 
 bool EditView::HasOtherViewWindow( vcl::Window* pWin )
 {
-OutWindowSet& rOutWindowSet = getImpl().aOutWindowSet;
+OutWindowSet& rOutWindowSet = getImpl().maOutWindowSet;
 auto found = std::find(rOutWindowSet.begin(), rOutWindowSet.end(), pWin);
 return (found != rOutWindowSet.end());
 }
@@ -399,13 +399,13 @@ bool EditView::AddOtherViewWindow( vcl::Window* pWin )
 {
 if (HasOtherViewWindow(pWin))
 return false;
-getImpl().aOutWindowSet.emplace_back(pWin);
+getImpl().maOutWindowSet.emplace_back(pWin);
 return true;
 }
 
 bool EditView::RemoveOtherViewWindow( vcl::Window* 

core.git: sd/source

2024-01-24 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/drviewsf.cxx |   15 ---
 1 file changed, 15 deletions(-)

New commits:
commit ad8248bcc7ed19285147aeff71a508453a61
Author: Tomaž Vajngerl 
AuthorDate: Wed Aug 30 09:15:56 2023 +0200
Commit: Caolán McNamara 
CommitDate: Wed Jan 24 10:45:14 2024 +0100

sd: remove condition to only show ThemeDialog in master view

Change-Id: I09ce07f7b520688aa54dd30107b5ab2218b12894
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156277
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 62804da3c0ab9443cf36f2e02387a2e9c272d5dc)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162463
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 979225bb06dd..cb0e6495323d 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -470,21 +470,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
 }
 break;
 
-case SID_THEME_DIALOG:
-{
-bool bDisable = true;
-SdrPageView* pPageView = mpDrawView->GetSdrPageView();
-if (pPageView)
-{
-SdPage* pPage = 
dynamic_cast(pPageView->GetPage());
-if (pPage && pPage->IsMasterPage())
-bDisable = false;
-}
-if (bDisable)
-rSet.DisableItem(nWhich);
-}
-break;
-
 case SID_STYLE_FAMILY2:
 case SID_STYLE_FAMILY3:
 case SID_STYLE_FAMILY5:


core.git: editeng/source forms/source include/editeng sc/source sd/qa sd/source starmath/source svx/source sw/source

2024-01-20 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editeng.cxx  |5 
 editeng/source/editeng/editundo.cxx |2 
 editeng/source/editeng/editview.cxx |  270 +++
 editeng/source/editeng/edtspell.cxx |   36 +-
 editeng/source/editeng/impedit.cxx  |  347 ++--
 editeng/source/editeng/impedit.hxx  |6 
 editeng/source/editeng/textconv.cxx |   40 +-
 editeng/source/misc/urlfieldhelper.cxx  |2 
 editeng/source/outliner/outlvw.cxx  |   20 -
 forms/source/richtext/specialdispatchers.cxx|8 
 include/editeng/editeng.hxx |2 
 include/editeng/editview.hxx|   14 
 sc/source/ui/Accessibility/AccessibleDocument.cxx   |4 
 sc/source/ui/Accessibility/AccessibleEditObject.cxx |4 
 sc/source/ui/Accessibility/AccessibleText.cxx   |   17 
 sc/source/ui/app/inputhdl.cxx   |   53 +--
 sc/source/ui/app/inputwin.cxx   |   14 
 sc/source/ui/docshell/docsh4.cxx|2 
 sc/source/ui/view/cellsh3.cxx   |2 
 sc/source/ui/view/editsh.cxx|   58 +--
 sc/source/ui/view/gridwin.cxx   |   10 
 sc/source/ui/view/gridwin4.cxx  |   13 
 sc/source/ui/view/spelldialog.cxx   |2 
 sc/source/ui/view/tabview3.cxx  |3 
 sc/source/ui/view/viewdata.cxx  |   31 -
 sd/qa/unit/TextFittingTest.cxx  |   29 -
 sd/source/ui/annotations/annotationwindow.cxx   |2 
 sd/source/ui/docshell/docshel3.cxx  |2 
 sd/source/ui/func/futext.cxx|   13 
 sd/source/ui/view/sdwindow.cxx  |2 
 sd/source/ui/view/viewshel.cxx  |2 
 starmath/source/edit.cxx|   16 
 svx/source/dialog/weldeditview.cxx  |2 
 svx/source/theme/ThemeColorChangerCommon.cxx|   12 
 sw/source/uibase/docvw/SidebarTxtControl.cxx|   10 
 sw/source/uibase/shells/drwtxtsh.cxx|2 
 sw/source/uibase/shells/langhelper.cxx  |   24 -
 sw/source/uibase/uno/unotxdoc.cxx   |4 
 38 files changed, 540 insertions(+), 545 deletions(-)

New commits:
commit 049bbd95c190e0844da3a8dd88b1ce7a9ccf83b7
Author: Tomaž Vajngerl 
AuthorDate: Sat Jan 20 15:04:43 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Jan 21 00:54:54 2024 +0100

editeng: change EditEngine getter to ref in {Imp}EditView

{Imp}EditView always needs to have EditEngine set (or it would
crash otherwise), so we can change the getter to return a referece
instead of a pointer. This simplifies things a bit because we get
rid of all the nullptr checks and makes the interface more clear.

Also change direct access to mpEditEngine in {Imp}EditView to use
getEditEngine() and getImpEditEngine() (returning a reference)
instead.

Change-Id: Ib8f9c565b8364144bb9c35c3093c4975af1970c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162333
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index c55ace752c2b..26e8fe3099b4 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -88,6 +88,11 @@ static bool bDebugPaint = false;
 
 static rtl::Reference pGlobalPool;
 
+ImpEditEngine& EditEngine::getImpl()
+{
+return *pImpEditEngine;
+}
+
 EditEngine::EditEngine( SfxItemPool* pItemPool )
 {
 pImpEditEngine.reset( new ImpEditEngine( this, pItemPool ) );
diff --git a/editeng/source/editeng/editundo.cxx 
b/editeng/source/editeng/editundo.cxx
index 378e1f8f268e..b13ff7109791 100644
--- a/editeng/source/editeng/editundo.cxx
+++ b/editeng/source/editeng/editundo.cxx
@@ -29,7 +29,7 @@
 static void lcl_DoSetSelection( EditView const * pView, sal_uInt16 nPara )
 {
 EPaM aEPaM( nPara, 0 );
-EditPaM aPaM( pView->GetImpEditEngine()->CreateEditPaM( aEPaM ) );
+EditPaM aPaM = pView->getImpEditEngine().CreateEditPaM(aEPaM);
 aPaM.SetIndex( aPaM.GetNode()->Len() );
 EditSelection aSel( aPaM, aPaM );
 pView->GetImpEditView()->SetEditSelection( aSel );
diff --git a/editeng/source/editeng/editview.cxx 
b/editeng/source/editeng/editview.cxx
index ff979af96698..c8a974df8ec1 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -151,9 +151,10 @@ EditViewCallbacks::~EditViewCallbacks()
 {
 }
 
-EditView::EditView( EditEngine* pEng, vcl::Window* pWindow )
+EditView::EditView(EditEngine* pEditEngine, vcl::Window* pWindow)
+: pImpEditView(new ImpEditView(this, pEditEngine, pWindow))
 {
-pImpEditView.reset( new ImpEditView( this, pEng, pWindow ) );
+

core.git: editeng/source

2024-01-20 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/impedit3.cxx |   76 ++--
 1 file changed, 38 insertions(+), 38 deletions(-)

New commits:
commit 06aea80b0482c03e8f0a5f735d3a31ec816a07fe
Author: Tomaž Vajngerl 
AuthorDate: Tue Jan 16 10:37:16 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Jan 21 00:49:57 2024 +0100

editeng: in ImpEditEngine::Paint rename confusing variables

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

diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 30462d21b169..b03c9d0f330b 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -3340,19 +3340,19 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
 
 // Over all the paragraphs...
 
-for ( sal_Int32 n = 0; n < GetParaPortions().Count(); n++ )
+for (sal_Int32 nParaPortion = 0; nParaPortion < GetParaPortions().Count(); 
nParaPortion++)
 {
-ParaPortion const& rPortion = GetParaPortions().getRef(n);
+ParaPortion const& rParaPortion = 
GetParaPortions().getRef(nParaPortion);
 // if when typing idle formatting,  asynchronous Paint.
 // Invisible Portions may be invalid.
-if (rPortion.IsVisible() && rPortion.IsInvalid())
+if (rParaPortion.IsVisible() && rParaPortion.IsInvalid())
 return;
 
 if ( pPDFExtOutDevData )
 
pPDFExtOutDevData->WrapBeginStructureElement(vcl::PDFWriter::Paragraph);
 
-const tools::Long nParaHeight = rPortion.GetHeight();
-if (rPortion.IsVisible() && (
+const tools::Long nParaHeight = rParaPortion.GetHeight();
+if (rParaPortion.IsVisible() && (
 ( !IsEffectivelyVertical() && ( ( aStartPos.Y() + nParaHeight 
) > aClipRect.Top() ) ) ||
 ( IsEffectivelyVertical() && IsTopToBottom() && ( ( 
aStartPos.X() - nParaHeight ) < aClipRect.Right() ) ) ||
 ( IsEffectivelyVertical() && !IsTopToBottom() && ( ( 
aStartPos.X() + nParaHeight ) > aClipRect.Left() ) ) ) )
@@ -3362,21 +3362,21 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
 
 // Over the lines of the paragraph...
 
-const sal_Int32 nLines = rPortion.GetLines().Count();
+const sal_Int32 nLines = rParaPortion.GetLines().Count();
 const sal_Int32 nLastLine = nLines-1;
 
 bool bEndOfParagraphWritten(false);
 
-adjustYDirectionAware(aStartPos, rPortion.GetFirstLineOffset());
+adjustYDirectionAware(aStartPos, 
rParaPortion.GetFirstLineOffset());
 
-const SvxLineSpacingItem& rLSItem = 
rPortion.GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
+const SvxLineSpacingItem& rLSItem = 
rParaPortion.GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
 sal_uInt16 nSBL = ( rLSItem.GetInterLineSpaceRule() == 
SvxInterLineSpaceRule::Fix )
 ? 
scaleYSpacingValue(rLSItem.GetInterLineSpace()) : 0;
 bool bPaintBullet (false);
 
 for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ )
 {
-EditLine const& rLine = rPortion.GetLines()[nLine];
+EditLine const& rLine = rParaPortion.GetLines()[nLine];
 sal_Int32 nIndex = rLine.GetStart();
 tools::Long nLineHeight = rLine.GetHeight();
 if (nLine != nLastLine)
@@ -3400,10 +3400,10 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
 {
 Point aLineStart(aStartPos);
 adjustYDirectionAware(aLineStart, -nLineHeight);
-GetEditEnginePtr()->PaintingFirstLine(n, aLineStart, 
aOrigin, nOrientation, rOutDev);
+GetEditEnginePtr()->PaintingFirstLine(nParaPortion, 
aLineStart, aOrigin, nOrientation, rOutDev);
 
 // Remember whether a bullet was painted.
-const SfxBoolItem& rBulletState = 
mpEditEngine->GetParaAttrib(n, EE_PARA_BULLETSTATE);
+const SfxBoolItem& rBulletState = 
mpEditEngine->GetParaAttrib(nParaPortion, EE_PARA_BULLETSTATE);
 bPaintBullet = rBulletState.GetValue();
 }
 
@@ -3415,10 +3415,10 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, 
tools::Rectangle aClipRect, Po
 
 for ( sal_Int32 nPortion = rLine.GetStartPortion(); 
nPortion <= rLine.GetEndPortion(); nPortion++ )
 {
-DBG_ASSERT(rPortion.GetTextPortions().Count(), "Line 
without Textportion in Paint!");
-const TextPortion& rTextPortion = 
rPortion.GetTextPortions()[nPortion];
+

core.git: Branch 'distro/collabora/co-24.04' - 3 commits - sc/qa sc/source

2024-01-16 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   86 
++
 sc/source/ui/unoobj/docuno.cxx |7 
 sc/source/ui/view/gridwin.cxx  |2 
 sc/source/ui/view/viewdata.cxx |4 
 5 files changed, 96 insertions(+), 3 deletions(-)

New commits:
commit d815fa555d3717c76d961ee964c41929de36dc03
Author: Tomaž Vajngerl 
AuthorDate: Thu Jan 11 15:08:21 2024 +0900
Commit: Andras Timar 
CommitDate: Tue Jan 16 23:43:17 2024 +0100

sc lok: set the GridWindow size to the client area size + test

This solves the issue when we click on a long first column (size
800px - default GridWindow size) at a right end position (>800px)
and the selection jumped to the neighbouring cell. This solution
reverts the workaround for this issue and properly sets the
GridWindow to the current reported client visible area size (set
with the ScModelObj::setClientVisibleArea call).

Also includes a test for this issue.

Change-Id: Ia5449893a90ffa0072aad68d772ad9b00206f113
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161907
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161957
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods 
b/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods
new file mode 100644
index ..27fc3f45c543
Binary files /dev/null and 
b/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index ee2b50522e3f..f59635769343 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -3349,6 +3349,92 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testSidebarLocale)
 CPPUNIT_ASSERT_EQUAL(std::string("de-DE"), aLocale);
 }
 
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testLongFirstColumnMouseClick)
+{
+// Document has a long first column. We want to mouse-click on the column 
and
+// check the selection changed to this column.
+
+// The issue we want to reproduce is that the click on a cell in the first 
column that is
+// very long (longer than ~800px default size of GridWindow) triggers a 
code-path where the cell
+// selected is the neighbouring cell even when we clicked on the area of 
the first cell.
+
+ScModelObj* pModelObj = createDoc("DocumentWithLongFirstColumn.ods");
+CPPUNIT_ASSERT(pModelObj);
+
pModelObj->initializeForTiledRendering(uno::Sequence());
+
+// Fetch current view data
+ScViewData* pViewData = ScDocShell::GetViewData();
+CPPUNIT_ASSERT(pViewData);
+double nPPTX = pViewData->GetPPTX();
+double nPPTY = pViewData->GetPPTX();
+
+// Set click position
+
+// Left side of the first cell
+int leftCellSideX = 1 / nPPTX; // convert pixels to logical units
+
+// Right side of the first cell. First cell is long so click somewhere 
more than 800px (default of GridWindow size).
+int rightCellSideX = 1000 / nPPTX; // convert pixels to logical units
+
+// Vettical position - doesn't matter - select the first row
+int y = 1 / nPPTY;
+
+// Setup view #1
+ViewCallback aView1;
+// Set client rect to 2000 x 2000 pixels
+pModelObj->setClientVisibleArea(tools::Rectangle(0, 0, 2000 / nPPTX, 2000 
/ nPPTY));
+Scheduler::ProcessEventsToIdle();
+
+// Click at on the left side of A1 cell
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, leftCellSideX, 
y, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, leftCellSideX, y, 
/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+Scheduler::ProcessEventsToIdle();
+
+// Check the A1 cell is selected in view #1
+CPPUNIT_ASSERT_EQUAL(SCCOL(0), ScDocShell::GetViewData()->GetCurX());
+CPPUNIT_ASSERT_EQUAL(SCROW(0), ScDocShell::GetViewData()->GetCurY());
+
+// Click at on the right side of A1 cell
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, rightCellSideX, 
y, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, rightCellSideX, y, 
/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+Scheduler::ProcessEventsToIdle();
+
+// Check the A1 cell is selected in view #1
+CPPUNIT_ASSERT_EQUAL(SCCOL(0), ScDocShell::GetViewData()->GetCurX());
+CPPUNIT_ASSERT_EQUAL(SCROW(0), ScDocShell::GetViewData()->GetCurY());
+
+// Try to check the same scenario in a new view
+
+// Setup view #2
+SfxLokHelper::createView();
+int nView2 = SfxLokHelper::getView();
+ViewCallback aView2;
+// Set client rect to 2000 x 

core.git: sc/source

2024-01-16 Thread Tomaž Vajngerl (via logerrit)
 sc/source/ui/unoobj/docuno.cxx |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 7bc36867e84f7b9ad091d320b5520d5bb6c287e4
Author: Tomaž Vajngerl 
AuthorDate: Thu Jan 11 16:07:41 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 16 13:03:53 2024 +0100

sc lok: don't set the GridWindow size to document size

We now set the GridWindow size to the size of the client area
so no need to set it to the document size (which can get enormous
in Calc). There are no ill effects AFAICS, but needs a lot more
testing.

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

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index a7f0a5a7674f..275b91ba694f 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -563,9 +563,7 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
 // to pass it down to ScGridWindow::PaintFile to avoid computing twice.
 SCCOL nTiledRenderingAreaEndCol = 0;
 SCROW nTiledRenderingAreaEndRow = 0;
-Size aDocSize = getDocumentSize(nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow);
-
-pGridWindow->SetOutputSizePixel(Size(aDocSize.Width() * 
pViewData->GetPPTX(), aDocSize.Height() * pViewData->GetPPTY()));
+(void)getDocumentSize(nTiledRenderingAreaEndCol, 
nTiledRenderingAreaEndRow);
 
 pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight,
 nTilePosX, nTilePosY, nTileWidth, nTileHeight,


core.git: editeng/CppunitTest_editeng_core.mk editeng/qa

2024-01-16 Thread Tomaž Vajngerl (via logerrit)
 editeng/CppunitTest_editeng_core.mk  |1 
 editeng/qa/unit/EditLineListTest.cxx |  173 +++
 2 files changed, 174 insertions(+)

New commits:
commit dcff97abcd4e8d31032c316892cb09b5742ca1ec
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 15 12:39:54 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 16 13:02:27 2024 +0100

editeng: add EditLineList test

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

diff --git a/editeng/CppunitTest_editeng_core.mk 
b/editeng/CppunitTest_editeng_core.mk
index 9352ddbd83e2..46a232d97f38 100644
--- a/editeng/CppunitTest_editeng_core.mk
+++ b/editeng/CppunitTest_editeng_core.mk
@@ -16,6 +16,7 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,editeng_core, \
 editeng/qa/unit/ESelectionTest \
 editeng/qa/unit/EPaMTest \
 editeng/qa/unit/EditLineTest \
+editeng/qa/unit/EditLineListTest \
 editeng/qa/unit/EditPaMTest \
 editeng/qa/unit/EditSelectionTest \
 ))
diff --git a/editeng/qa/unit/EditLineListTest.cxx 
b/editeng/qa/unit/EditLineListTest.cxx
new file mode 100644
index ..c6240c4e055c
--- /dev/null
+++ b/editeng/qa/unit/EditLineListTest.cxx
@@ -0,0 +1,173 @@
+/* -*- 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/.
+ */
+
+#include 
+#include 
+
+namespace
+{
+class EditLineListTest : public test::BootstrapFixture
+{
+};
+
+CPPUNIT_TEST_FIXTURE(EditLineListTest, testConstruction)
+{
+EditLineList aNewList;
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.Count());
+}
+
+CPPUNIT_TEST_FIXTURE(EditLineListTest, testAppendAndInsert)
+{
+// Test case:
+// Append EditLine1
+// Append EditLine3
+// Insert EditLine2 in-between EditLine1 and pEditLine3
+
+EditLineList aNewList;
+
+EditLine* pEditLine1 = new EditLine;
+EditLine* pEditLine2 = new EditLine;
+EditLine* pEditLine3 = new EditLine;
+
+aNewList.Append(std::unique_ptr(pEditLine1));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aNewList.Count());
+
+aNewList.Append(std::unique_ptr(pEditLine3));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.Count());
+
+CPPUNIT_ASSERT_EQUAL(pEditLine1, [0]);
+CPPUNIT_ASSERT_EQUAL(pEditLine3, [1]);
+
+aNewList.Insert(1, std::unique_ptr(pEditLine2));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aNewList.Count());
+
+CPPUNIT_ASSERT_EQUAL(pEditLine1, [0]);
+CPPUNIT_ASSERT_EQUAL(pEditLine2, [1]);
+CPPUNIT_ASSERT_EQUAL(pEditLine3, [2]);
+}
+
+CPPUNIT_TEST_FIXTURE(EditLineListTest, testReset)
+{
+EditLineList aNewList;
+
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aNewList.Count());
+
+aNewList.Reset();
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNewList.Count());
+}
+
+CPPUNIT_TEST_FIXTURE(EditLineListTest, testDeleteFrom)
+{
+EditLineList aNewList;
+
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+
+aNewList[0].SetStart(10);
+aNewList[1].SetStart(11);
+aNewList[2].SetStart(12);
+aNewList[3].SetStart(13);
+aNewList[4].SetStart(14);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aNewList.Count());
+
+aNewList.DeleteFromLine(2);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aNewList.Count());
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNewList[0].GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aNewList[1].GetStart());
+
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+aNewList.Append(std::make_unique());
+
+aNewList[2].SetStart(15);
+aNewList[3].SetStart(16);
+aNewList[4].SetStart(17);
+aNewList[5].SetStart(18);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(6), aNewList.Count());
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNewList[0].GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aNewList[1].GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(15), aNewList[2].GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aNewList[3].GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(17), aNewList[4].GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(18), aNewList[5].GetStart());
+
+aNewList.DeleteFromLine(4);
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), aNewList.Count());
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNewList[0].GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aNewList[1].GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(15), 

core.git: editeng/inc editeng/qa editeng/source

2024-01-15 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/ParagraphPortionList.hxx |   23 ++
 editeng/qa/unit/core-test.cxx|8 
 editeng/source/editeng/editdbg.cxx   |   32 +--
 editeng/source/editeng/editdoc.cxx   |   20 --
 editeng/source/editeng/editeng.cxx   |   21 +-
 editeng/source/editeng/impedit.cxx   |   16 -
 editeng/source/editeng/impedit.hxx   |4 
 editeng/source/editeng/impedit2.cxx  |  109 ++--
 editeng/source/editeng/impedit3.cxx  |  298 ++-
 editeng/source/editeng/impedit4.cxx  |   33 +--
 editeng/source/editeng/impedit5.cxx  |   23 +-
 11 files changed, 302 insertions(+), 285 deletions(-)

New commits:
commit bf6cf27763b88583b7562c41c791fff45308362d
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 15 11:57:08 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jan 15 14:28:11 2024 +0100

editeng: return ParaPortion from the list as a ref.

Change operator[] for getRef(..) method, so instead of returning
a pointer, return a reference to ParaPortion instead. This also
needs changes to the code, because we now need to make sure before
hand that the ParaPortion is really available in the list and when
this is not possible or convenient, the change the call to use
existing "SafeGetObject" instead. Add "exists" to check if the
object is available in the ParaPortionList.

In addition add "lastIndex" method to return the index of the
last ParaPortion in the list (shortcut for Count() - 1).

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

diff --git a/editeng/inc/ParagraphPortionList.hxx 
b/editeng/inc/ParagraphPortionList.hxx
index aa7862afa8d7..7ee252132d4e 100644
--- a/editeng/inc/ParagraphPortionList.hxx
+++ b/editeng/inc/ParagraphPortionList.hxx
@@ -38,18 +38,33 @@ public:
 tools::Long GetYOffset(const ParaPortion* pPPortion) const;
 sal_Int32 FindParagraph(tools::Long nYOffset) const;
 
-const ParaPortion* SafeGetObject(sal_Int32 nPos) const;
-ParaPortion* SafeGetObject(sal_Int32 nPos);
+const ParaPortion* SafeGetObject(sal_Int32 nPos) const
+{
+return exists(nPos) ? maPortions[nPos].get() : nullptr;
+}
+
+ParaPortion* SafeGetObject(sal_Int32 nPos)
+{
+return exists(nPos) ? maPortions[nPos].get() : nullptr;
+}
 
 sal_Int32 GetPos(const ParaPortion* p) const;
-ParaPortion* operator[](sal_Int32 nPos);
-const ParaPortion* operator[](sal_Int32 nPos) const;
+
+ParaPortion& getRef(sal_Int32 nPosition) { return *maPortions[nPosition]; }
+ParaPortion const& getRef(sal_Int32 nPosition) const { return 
*maPortions[nPosition]; }
 
 std::unique_ptr Release(sal_Int32 nPos);
 void Remove(sal_Int32 nPos);
 void Insert(sal_Int32 nPos, std::unique_ptr p);
 void Append(std::unique_ptr p);
 sal_Int32 Count() const;
+sal_Int32 lastIndex() const { return Count() - 1; }
+
+bool exists(sal_Int32 nPosition) const
+{
+return nPosition >= 0 && o3tl::make_unsigned(nPosition) < 
maPortions.size()
+   && maPortions[nPosition];
+}
 
 ParaPortionContainerType::iterator begin() { return maPortions.begin(); }
 ParaPortionContainerType::iterator end() { return maPortions.end(); }
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index e0fb7ada253c..097602ec6b4c 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -199,8 +199,8 @@ void Test::testLineSpacing()
 aEditEngine.QuickSetAttribs(*pSet, aSelection);
 
 // Assert changes
-ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0];
-ContentNode* const pNode = pParaPortion->GetNode();
+ParaPortion const& rParaPortion = 
aEditEngine.GetParaPortions().getRef(0);
+ContentNode* const pNode = rParaPortion.GetNode();
 const SvxLineSpacingItem& rLSItem = 
pNode->GetContentAttribs().GetItem(EE_PARA_SBL);
 CPPUNIT_ASSERT_EQUAL(SvxInterLineSpaceRule::Prop, 
rLSItem.GetInterLineSpaceRule());
 CPPUNIT_ASSERT_EQUAL(nSpace, rLSItem.GetPropLineSpace());
@@ -2094,7 +2094,7 @@ void Test::testCreateLines()
 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), rParagraphPortionList.Count());
 
 {
-EditLineList& rLines = rParagraphPortionList[0]->GetLines();
+EditLineList& rLines = rParagraphPortionList.getRef(0).GetLines();
 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), rLines.Count());
 EditLine const& rLine = rLines[0];
 
@@ -2110,7 +2110,7 @@ void Test::testCreateLines()
 }
 
 {
-EditLineList& rLines = rParagraphPortionList[1]->GetLines();
+EditLineList& rLines = rParagraphPortionList.getRef(1).GetLines();
 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), rLines.Count());
 
 {
diff --git a/editeng/source/editeng/editdbg.cxx 
b/editeng/source/editeng/editdbg.cxx
index 74cd266d8bb8..1d43b1dc8487 

core.git: 2 commits - sc/qa sc/source

2024-01-15 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   86 
++
 sc/source/ui/unoobj/docuno.cxx |7 
 sc/source/ui/view/gridwin.cxx  |2 
 sc/source/ui/view/viewdata.cxx |8 
 5 files changed, 96 insertions(+), 7 deletions(-)

New commits:
commit da9f8f9f93a1146f90c21ceec143a827063e24f5
Author: Tomaž Vajngerl 
AuthorDate: Thu Jan 11 13:25:16 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jan 15 10:04:00 2024 +0100

sc: don't stop if we can't cast one view to ScTabViewShell

Probably the intention here was to skip the view if we can't
cast it to ScTabViewShell and not stop updating all the other
views when we can't cast.

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

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 446badbb1244..186243702985 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -6375,7 +6375,7 @@ void ScGridWindow::updateOtherKitSelections() const
 {
 auto pOther = dynamic_cast(it);
 if (!pOther)
-return;
+continue;
 
 // Fetch pixels & convert for each view separately.
 tools::Rectangle aBoundingBox;
commit a4e429f18cc61b091ee5f0e85e2786b7dd22ccd3
Author: Tomaž Vajngerl 
AuthorDate: Thu Jan 11 15:08:21 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jan 15 10:03:54 2024 +0100

sc lok: set the GridWindow size to the client area size + test

This solves the issue when we click on a long first column (size
800px - default GridWindow size) at a right end position (>800px)
and the selection jumped to the neighbouring cell. This solution
reverts the workaround for this issue and properly sets the
GridWindow to the current reported client visible area size (set
with the ScModelObj::setClientVisibleArea call).

Also includes a test for this issue.

Change-Id: Ia5449893a90ffa0072aad68d772ad9b00206f113
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161907
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161957
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods 
b/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods
new file mode 100644
index ..27fc3f45c543
Binary files /dev/null and 
b/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 902fee6293ef..f31eff1bd001 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -3277,6 +3277,92 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, 
testSidebarLocale)
 CPPUNIT_ASSERT_EQUAL(std::string("de-DE"), aLocale);
 }
 
+CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testLongFirstColumnMouseClick)
+{
+// Document has a long first column. We want to mouse-click on the column 
and
+// check the selection changed to this column.
+
+// The issue we want to reproduce is that the click on a cell in the first 
column that is
+// very long (longer than ~800px default size of GridWindow) triggers a 
code-path where the cell
+// selected is the neighbouring cell even when we clicked on the area of 
the first cell.
+
+ScModelObj* pModelObj = createDoc("DocumentWithLongFirstColumn.ods");
+CPPUNIT_ASSERT(pModelObj);
+
pModelObj->initializeForTiledRendering(uno::Sequence());
+
+// Fetch current view data
+ScViewData* pViewData = ScDocShell::GetViewData();
+CPPUNIT_ASSERT(pViewData);
+double nPPTX = pViewData->GetPPTX();
+double nPPTY = pViewData->GetPPTX();
+
+// Set click position
+
+// Left side of the first cell
+int leftCellSideX = 1 / nPPTX; // convert pixels to logical units
+
+// Right side of the first cell. First cell is long so click somewhere 
more than 800px (default of GridWindow size).
+int rightCellSideX = 1000 / nPPTX; // convert pixels to logical units
+
+// Vettical position - doesn't matter - select the first row
+int y = 1 / nPPTY;
+
+// Setup view #1
+ViewCallback aView1;
+// Set client rect to 2000 x 2000 pixels
+pModelObj->setClientVisibleArea(tools::Rectangle(0, 0, 2000 / nPPTX, 2000 
/ nPPTY));
+Scheduler::ProcessEventsToIdle();
+
+// Click at on the left side of A1 cell
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, leftCellSideX, 
y, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+

core.git: 2 commits - editeng/source include/editeng

2024-01-14 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editeng.cxx  |   10 -
 editeng/source/editeng/impedit.cxx  |   22 +-
 editeng/source/editeng/impedit.hxx  |   34 +--
 editeng/source/editeng/impedit2.cxx |  275 +++
 editeng/source/editeng/impedit3.cxx |  317 +---
 include/editeng/editeng.hxx |6 
 6 files changed, 321 insertions(+), 343 deletions(-)

New commits:
commit 01092e632994a9b73ebcb29a4173d6eec6f1141c
Author: Tomaž Vajngerl 
AuthorDate: Sun Jan 14 13:49:48 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Jan 14 16:06:17 2024 +0100

editeng: change the ParaPortion parameter from pointer to ref.

In most cases we expect the ParaPortion pointer to be not-null,
so it makes more sense to have the ParaPortion parameter as a ref.
and not a raw pointer.

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

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index d7a30a60b935..300b2fc65a0d 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -865,16 +865,14 @@ EditSelection EditEngine::SelectWord(
 return pImpEditEngine->SelectWord(rCurSelection, nWordType);
 }
 
-tools::Long EditEngine::GetXPos(
-const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 
nIndex, bool bPreferPortionStart) const
+tools::Long EditEngine::GetXPos(ParaPortion const& rParaPortion, EditLine 
const& rLine, sal_Int32 nIndex, bool bPreferPortionStart) const
 {
-return pImpEditEngine->GetXPos(pParaPortion, rLine, nIndex, 
bPreferPortionStart);
+return pImpEditEngine->GetXPos(rParaPortion, rLine, nIndex, 
bPreferPortionStart);
 }
 
-Range EditEngine::GetLineXPosStartEnd(
-const ParaPortion* pParaPortion, EditLine const& rLine) const
+Range EditEngine::GetLineXPosStartEnd(ParaPortion const& rParaPortion, 
EditLine const& rLine) const
 {
-return pImpEditEngine->GetLineXPosStartEnd(pParaPortion, rLine);
+return pImpEditEngine->GetLineXPosStartEnd(rParaPortion, rLine);
 }
 
 bool EditEngine::IsFormatted() const
diff --git a/editeng/source/editeng/impedit.cxx 
b/editeng/source/editeng/impedit.cxx
index c1f20e9e55df..46c9928e300f 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -576,7 +576,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, 
vcl::Region* pRegion,
 nEndIndex = nStartIndex;
 
 tools::Rectangle 
aTmpRect(pEditEngine->pImpEditEngine->GetEditCursor(
-, *rInfo.pLine, nStartIndex, 
GetCursorFlags::NONE));
+rInfo.rPortion, *rInfo.pLine, nStartIndex, 
GetCursorFlags::NONE));
 const Size aLineOffset = 
pEditEngine->pImpEditEngine->getTopLeftDocOffset(rInfo.aArea);
 aTmpRect.Move(0, aLineOffset.Height());
 
@@ -595,7 +595,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, 
vcl::Region* pRegion,
 // Now that we have Bidi, the first/last index doesn't have to be 
the 'most outside' position
 if (!bPartOfLine)
 {
-Range aLineXPosStartEnd = 
pEditEngine->GetLineXPosStartEnd(, *rInfo.pLine);
+Range aLineXPosStartEnd = 
pEditEngine->GetLineXPosStartEnd(rInfo.rPortion, *rInfo.pLine);
 aTmpRect.SetLeft(aLineXPosStartEnd.Min());
 aTmpRect.SetRight(aLineXPosStartEnd.Max());
 aTmpRect.Move(aLineOffset.Width(), 0);
@@ -616,8 +616,8 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, 
vcl::Region* pRegion,
 
 DBG_ASSERT(nTmpEndIndex > nTmpStartIndex, 
"DrawSelectionXOR, Start >= End?");
 
-tools::Long nX1 = pEditEngine->GetXPos(, 
*rInfo.pLine, nTmpStartIndex, true);
-tools::Long nX2 = pEditEngine->GetXPos(, 
*rInfo.pLine, nTmpEndIndex);
+tools::Long nX1 = pEditEngine->GetXPos(rInfo.rPortion, 
*rInfo.pLine, nTmpStartIndex, true);
+tools::Long nX2 = pEditEngine->GetXPos(rInfo.rPortion, 
*rInfo.pLine, nTmpEndIndex);
 
 aTmpRect.SetLeft(std::min(nX1, nX2));
 aTmpRect.SetRight(std::max(nX1, nX2));
@@ -1103,8 +1103,7 @@ boost::property_tree::ptree getHyperlinkPropTree(const 
OUString& sText, const OU
 
 } // End of anon namespace
 
-tools::Rectangle ImpEditView::ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags 
nShowCursorFlags, sal_Int32& nTextPortionStart,
-const ParaPortion* pParaPortion) const
+tools::Rectangle ImpEditView::ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags 
nShowCursorFlags, sal_Int32& nTextPortionStart, ParaPortion const& 
rParaPortion) const
 {
 tools::Rectangle aEditCursor = 
pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, nShowCursorFlags );
 if ( !IsInsertMode() && 

core.git: editeng/CppunitTest_editeng_core.mk editeng/qa

2024-01-13 Thread Tomaž Vajngerl (via logerrit)
 editeng/CppunitTest_editeng_core.mk |1 
 editeng/qa/unit/core-test.cxx   |   74 
 2 files changed, 75 insertions(+)

New commits:
commit 67abfa11b611dc4ed98a660ec238fe76475200fa
Author: Tomaž Vajngerl 
AuthorDate: Fri Jan 12 12:56:00 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Jan 14 04:51:36 2024 +0100

editeng: add simple test for CreateLines method

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

diff --git a/editeng/CppunitTest_editeng_core.mk 
b/editeng/CppunitTest_editeng_core.mk
index 3fc6d9bde688..9352ddbd83e2 100644
--- a/editeng/CppunitTest_editeng_core.mk
+++ b/editeng/CppunitTest_editeng_core.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_CppunitTest_use_externals,editeng_core,\
 
 $(eval $(call gb_CppunitTest_set_include,editeng_core,\
 -I$(SRCDIR)/editeng/inc \
+-I$(SRCDIR)/editeng/source/editeng \
 $$(INCLUDE) \
 ))
 
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index c17fccf1caef..e0fb7ada253c 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -14,6 +14,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -114,6 +115,7 @@ public:
 
 void testSingleLine();
 void testMoveParagraph();
+void testCreateLines();
 
 DECL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, void );
 
@@ -141,6 +143,7 @@ public:
 CPPUNIT_TEST(testTdf148148);
 CPPUNIT_TEST(testSingleLine);
 CPPUNIT_TEST(testMoveParagraph);
+CPPUNIT_TEST(testCreateLines);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2073,6 +2076,77 @@ void Test::testMoveParagraph()
 CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 5"), aEditEngine.GetText(4));
 }
 
+void Test::testCreateLines()
+{
+ScopedVclPtrInstance 
pVirtualDevice(DeviceFormat::WITHOUT_ALPHA);
+
+EditEngine aEditEngine(mpItemPool.get());
+aEditEngine.SetRefDevice(pVirtualDevice.get());
+aEditEngine.SetPaperSize(Size(500, 500));
+aEditEngine.SetText("ABC
ABC DEF ABC DEFGH");
+
+CPPUNIT_ASSERT_EQUAL(true, aEditEngine.IsFormatted());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aEditEngine.GetParagraphCount());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aEditEngine.GetLineCount(0));
+CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aEditEngine.GetLineCount(1));
+
+ParaPortionList& rParagraphPortionList = aEditEngine.GetParaPortions();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(2), rParagraphPortionList.Count());
+
+{
+EditLineList& rLines = rParagraphPortionList[0]->GetLines();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(1), rLines.Count());
+EditLine const& rLine = rLines[0];
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rLine.GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(3), rLine.GetEnd());
+
+std::vector const& rArray = rLine.GetCharPosArray();
+CPPUNIT_ASSERT_EQUAL(size_t(3), rArray.size());
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(173), rArray[0]);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(333), rArray[1]);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(493), rArray[2]);
+}
+
+{
+EditLineList& rLines = rParagraphPortionList[1]->GetLines();
+CPPUNIT_ASSERT_EQUAL(sal_Int32(5), rLines.Count());
+
+{
+EditLine const& rLine = rLines[0];
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rLine.GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), rLine.GetEnd());
+}
+
+{
+EditLine const& rLine = rLines[1];
+CPPUNIT_ASSERT_EQUAL(sal_Int32(4), rLine.GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(8), rLine.GetEnd());
+}
+
+{
+EditLine const& rLine = rLines[2];
+CPPUNIT_ASSERT_EQUAL(sal_Int32(8), rLine.GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(12), rLine.GetEnd());
+}
+
+{
+EditLine const& rLine = rLines[3];
+CPPUNIT_ASSERT_EQUAL(sal_Int32(12), rLine.GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(15), rLine.GetEnd());
+}
+
+{
+EditLine const& rLine = rLines[4];
+CPPUNIT_ASSERT_EQUAL(sal_Int32(15), rLine.GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(17), rLine.GetEnd());
+}
+}
+
+// CPPUNIT_ASSERT_MESSAGE("INTENTIONALLY FALSE", false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }


core.git: 2 commits - editeng/inc editeng/source

2024-01-13 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/EditLineList.hxx|7 +-
 editeng/source/editeng/impedit.hxx  |6 +-
 editeng/source/editeng/impedit3.cxx |  101 
 editeng/source/editeng/impedit4.cxx |5 -
 4 files changed, 69 insertions(+), 50 deletions(-)

New commits:
commit bf82669bf76428d00cc2c6041daf2c7a4812ceae
Author: Tomaž Vajngerl 
AuthorDate: Fri Jan 12 12:54:15 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Jan 14 04:51:27 2024 +0100

editeng: use unique_ptr for Append and Insert into a EditLineList

We can better handle the lifecycle of the EditLine this way.

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

diff --git a/editeng/inc/EditLineList.hxx b/editeng/inc/EditLineList.hxx
index a3a547d7ce24..e28ce6692764 100644
--- a/editeng/inc/EditLineList.hxx
+++ b/editeng/inc/EditLineList.hxx
@@ -64,10 +64,11 @@ public:
 const EditLine& operator[](sal_Int32 nPos) const { return *maLines[nPos]; }
 EditLine& operator[](sal_Int32 nPos) { return *maLines[nPos]; }
 
-void Append(EditLine* p) { 
maLines.push_back(std::unique_ptr(p)); }
-void Insert(sal_Int32 nPos, EditLine* p)
+void Append(std::unique_ptr pEditLine) { 
maLines.push_back(std::move(pEditLine)); }
+
+void Insert(sal_Int32 nPos, std::unique_ptr pEditLine)
 {
-maLines.insert(maLines.begin() + nPos, std::unique_ptr(p));
+maLines.insert(maLines.begin() + nPos, std::move(pEditLine));
 }
 };
 
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 6dcf3fcdbff6..49e0015280f1 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -702,8 +702,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
 
 if ( pParaPortion->GetLines().Count() == 0 )
 {
-EditLine* pLine = new EditLine;
-pParaPortion->GetLines().Append(pLine);
+pParaPortion->GetLines().Append(std::make_unique());
 }
 
 // Get Paragraph attributes...
@@ -1725,7 +1724,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
 if ( nIndex < pNode->Len() )
 {
 pLine = new EditLine;
-pParaPortion->GetLines().Insert(++nLine, pLine);
+pParaPortion->GetLines().Insert(++nLine, 
std::unique_ptr(pLine));
 }
 else if ( nIndex && bLineBreak && GetTextRanger() )
 {
@@ -1734,7 +1733,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, 
sal_uInt32 nStartPosY )
 TextPortion* pDummyPortion = new TextPortion( 0 );
 pParaPortion->GetTextPortions().Append(pDummyPortion);
 pLine = new EditLine;
-pParaPortion->GetLines().Insert(++nLine, pLine);
+pParaPortion->GetLines().Insert(++nLine, 
std::unique_ptr(pLine));
 bForceOneRun = true;
 bProcessingEmptyLine = true;
 }
@@ -1775,7 +1774,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine( 
ParaPortion* pParaPortion )
 EditLine* pTmpLine = new EditLine;
 pTmpLine->SetStart( pParaPortion->GetNode()->Len() );
 pTmpLine->SetEnd( pParaPortion->GetNode()->Len() );
-pParaPortion->GetLines().Append(pTmpLine);
+pParaPortion->GetLines().Append(std::unique_ptr(pTmpLine));
 
 bool bLineBreak = pParaPortion->GetNode()->Len() > 0;
 sal_Int32 nSpaceBefore = 0;
diff --git a/editeng/source/editeng/impedit4.cxx 
b/editeng/source/editeng/impedit4.cxx
index 337d30b096df..6140fc9a7250 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1148,8 +1148,7 @@ std::unique_ptr 
ImpEditEngine::CreateTextObject( EditSelection a
 for ( n = 0; n < nCount; n++ )
 {
 const EditLine& rLine = pParaPortion->GetLines()[n];
-EditLine* pNew = rLine.Clone();
-pX->aLines.Append(pNew);
+pX->aLines.Append(std::unique_ptr(rLine.Clone()));
 }
 #ifdef DBG_UTIL
 sal_uInt16 nTest;
@@ -1348,7 +1347,7 @@ EditSelection ImpEditEngine::InsertTextObject( const 
EditTextObject& rTextObject
 const EditLine& rLine = rXP.aLines[m];
 EditLine* pNew = rLine.Clone();
 pNew->SetInvalid(); // Paint again!
-pParaPortion->GetLines().Append(pNew);
+
pParaPortion->GetLines().Append(std::unique_ptr(pNew));
 }
 #ifdef DBG_UTIL
 sal_uInt16 nTest;
commit c00f1227d3b9086c94aacea1c25496b73d32dc93
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 8 17:08:11 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Jan 14 04:51:18 2024 +0100

editeng: split up some 

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

2024-01-11 Thread Tomaž Vajngerl (via logerrit)
 sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods |binary
 sc/qa/unit/tiledrendering/tiledrendering.cxx   |   88 
++
 sc/source/ui/unoobj/docuno.cxx |7 
 sc/source/ui/view/viewdata.cxx |8 
 4 files changed, 97 insertions(+), 6 deletions(-)

New commits:
commit 22a185a977f90d706c3e9d182adeaac310b6f348
Author: Tomaž Vajngerl 
AuthorDate: Thu Jan 11 15:08:21 2024 +0900
Commit: Miklos Vajna 
CommitDate: Thu Jan 11 17:16:53 2024 +0100

sc lok: set the GridWindow size to the client area size + test

This solves the issue when we click on a long first column (size
800px - default GridWindow size) at a right end position (>800px)
and the selection jumped to the neighbouring cell. This solution
reverts the workaround for this issue and properly sets the
GridWindow to the current reported client visible area size (set
with the ScModelObj::setClientVisibleArea call).

Also includes a test for this issue.

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

diff --git a/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods 
b/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods
new file mode 100644
index ..27fc3f45c543
Binary files /dev/null and 
b/sc/qa/unit/tiledrendering/data/DocumentWithLongFirstColumn.ods differ
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 62155a3efd81..d49fa95c62c5 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -162,6 +162,7 @@ public:
 void testOpenURL();
 void testInvalidateForSplitPanes();
 void testStatusBarLocale();
+void testLongFirstColumnMouseClick();
 
 CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
 CPPUNIT_TEST(testRowColumnHeaders);
@@ -234,6 +235,7 @@ public:
 CPPUNIT_TEST(testOpenURL);
 CPPUNIT_TEST(testInvalidateForSplitPanes);
 CPPUNIT_TEST(testStatusBarLocale);
+CPPUNIT_TEST(testLongFirstColumnMouseClick);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3540,6 +3542,92 @@ void ScTiledRenderingTest::testStatusBarLocale()
 CPPUNIT_ASSERT_EQUAL(std::string("de-DE"), aLocale);
 }
 
+void ScTiledRenderingTest::testLongFirstColumnMouseClick()
+{
+// Document has a long first column. We want to mouse-click on the column 
and
+// check the selection changed to this column.
+
+// The issue we want to reproduce is that the click on a cell in the first 
column that is
+// very long (longer than ~800px default size of GridWindow) triggers a 
code-path where the cell
+// selected is the neighbouring cell even when we clicked on the area of 
the first cell.
+
+ScModelObj* pModelObj = createDoc("DocumentWithLongFirstColumn.ods");
+CPPUNIT_ASSERT(pModelObj);
+
pModelObj->initializeForTiledRendering(uno::Sequence());
+
+// Fetch current view data
+ScViewData* pViewData = ScDocShell::GetViewData();
+CPPUNIT_ASSERT(pViewData);
+double nPPTX = pViewData->GetPPTX();
+double nPPTY = pViewData->GetPPTX();
+
+// Set click position
+
+// Left side of the first cell
+int leftCellSideX = 1 / nPPTX; // convert pixels to logical units
+
+// Right side of the first cell. First cell is long so click somewhere 
more than 800px (default of GridWindow size).
+int rightCellSideX = 1000 / nPPTX; // convert pixels to logical units
+
+// Vettical position - doesn't matter - select the first row
+int y = 1 / nPPTY;
+
+// Setup view #1
+ViewCallback aView1;
+// Set client rect to 2000 x 2000 pixels
+pModelObj->setClientVisibleArea(tools::Rectangle(0, 0, 2000 / nPPTX, 2000 
/ nPPTY));
+Scheduler::ProcessEventsToIdle();
+
+// Click at on the left side of A1 cell
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, leftCellSideX, 
y, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, leftCellSideX, y, 
/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+Scheduler::ProcessEventsToIdle();
+
+// Check the A1 cell is selected in view #1
+CPPUNIT_ASSERT_EQUAL(SCCOL(0), ScDocShell::GetViewData()->GetCurX());
+CPPUNIT_ASSERT_EQUAL(SCROW(0), ScDocShell::GetViewData()->GetCurY());
+
+// Click at on the right side of A1 cell
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, rightCellSideX, 
y, /*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+pModelObj->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, rightCellSideX, y, 
/*count=*/ 1, /*buttons=*/ 1, /*modifier=*/0);
+Scheduler::ProcessEventsToIdle();
+
+// Check the A1 cell is selected in view #1
+CPPUNIT_ASSERT_EQUAL(SCCOL(0), ScDocShell::GetViewData()->GetCurX());
+

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

2024-01-11 Thread Tomaž Vajngerl (via logerrit)
 sc/source/ui/view/gridwin.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ffbf4dc7339572b7cab4405222ac93fb03ec6d51
Author: Tomaž Vajngerl 
AuthorDate: Thu Jan 11 13:25:16 2024 +0900
Commit: Miklos Vajna 
CommitDate: Thu Jan 11 11:36:41 2024 +0100

sc: don't stop if we can't cast one view to ScTabViewShell

Probably the intention here was to skip the view if we can't
cast it to ScTabViewShell and not stop updating all the other
views when we can't cast.

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

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index f4a1d6e6f5dd..9bd88d69d10d 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -6304,7 +6304,7 @@ void ScGridWindow::updateOtherKitSelections() const
 {
 auto pOther = dynamic_cast(it);
 if (!pOther)
-return;
+continue;
 
 // Fetch pixels & convert for each view separately.
 tools::Rectangle aBoundingBox;


core.git: editeng/source

2024-01-09 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editdoc.cxx |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit 89b9302ccf870c4fdbc1071751536b80429a7d27
Author: Tomaž Vajngerl 
AuthorDate: Fri Jan 5 11:59:46 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Jan 10 03:40:40 2024 +0100

editeng: move for loop to range based

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

diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index efc95b944833..7dbee3890a6c 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -892,11 +892,10 @@ void EditDoc::CreateDefFont( bool bUseStyles )
 maDefFont.SetVertical( IsEffectivelyVertical() );
 maDefFont.SetOrientation( Degree10(IsEffectivelyVertical() ? 
(IsTopToBottom() ? 2700 : 900) : 0) );
 
-for ( sal_Int32 nNode = 0; nNode < Count(); nNode++ )
+for (std::unique_ptr& pNode : maContents)
 {
-ContentNode* pNode = GetObject( nNode );
 pNode->GetCharAttribs().GetDefFont() = maDefFont;
-if ( bUseStyles )
+if (bUseStyles)
 pNode->CreateDefFont();
 }
 }


core.git: sc/source

2024-01-09 Thread Tomaž Vajngerl (via logerrit)
 sc/source/ui/view/viewdata.cxx |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit e1abdcef4404c2a1b8d6d87ae295451a457aeae4
Author: Tomaž Vajngerl 
AuthorDate: Fri Jan 5 21:05:50 2024 +0900
Commit: Caolán McNamara 
CommitDate: Tue Jan 9 14:25:43 2024 +0100

sc: LOK work-around for mouse click selecting the wrong cell

Don't increase the cell selection if we detect the mouse click
was out of the screen (grid window) area. Only do this when LOK
is enabled.

Change-Id: I97922e9d02500d7cedeaa5fa29d4ca344950ff47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161662
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161816
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 25e602669e80..d09c0a9e0aec 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2851,15 +2851,19 @@ void ScViewData::GetPosFromPixel( tools::Long nClickX, 
tools::Long nClickY, ScSp
 }
 }
 
+bool bLOK = comphelper::LibreOfficeKit::isActive();
 //  cells too big?
-if ( rPosX == nStartPosX && nClickX > 0 )
+// Work-around this for LOK, because the screen size is in not set 
correctly
+// for all views and we will geturn the wrong position in case we send a 
click
+// that is outside the set screen grid area
+if (rPosX == nStartPosX && nClickX > 0 && !bLOK)
 {
  if (pView)
 aScrSize.setWidth( pView->GetGridWidth(eHWhich) );
  if ( nClickX > aScrSize.Width() )
 ++rPosX;
 }
-if ( rPosY == nStartPosY && nClickY > 0 )
+if (rPosY == nStartPosY && nClickY > 0 && !bLOK)
 {
 if (pView)
 aScrSize.setHeight( pView->GetGridHeight(eVWhich) );


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

2024-01-08 Thread Tomaž Vajngerl (via logerrit)
 sc/source/ui/view/viewdata.cxx |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 1380a8290b799f44ef767e2fb6813e3cd387ff6c
Author: Tomaž Vajngerl 
AuthorDate: Fri Jan 5 21:05:50 2024 +0900
Commit: Miklos Vajna 
CommitDate: Mon Jan 8 11:05:12 2024 +0100

sc: LOK work-around for mouse click selecting the wrong cell

Don't increase the cell selection if we detect the mouse click
was out of the screen (grid window) area. Only do this when LOK
is enabled.

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

diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 57ef3e5487d0..8fc254aa8fce 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2849,15 +2849,19 @@ void ScViewData::GetPosFromPixel( tools::Long nClickX, 
tools::Long nClickY, ScSp
 }
 }
 
+bool bLOK = comphelper::LibreOfficeKit::isActive();
 //  cells too big?
-if ( rPosX == nStartPosX && nClickX > 0 )
+// Work-around this for LOK, because the screen size is in not set 
correctly
+// for all views and we will geturn the wrong position in case we send a 
click
+// that is outside the set screen grid area
+if (rPosX == nStartPosX && nClickX > 0 && !bLOK)
 {
  if (pView)
 aScrSize.setWidth( pView->GetGridWidth(eHWhich) );
  if ( nClickX > aScrSize.Width() )
 ++rPosX;
 }
-if ( rPosY == nStartPosY && nClickY > 0 )
+if (rPosY == nStartPosY && nClickY > 0 && !bLOK)
 {
 if (pView)
 aScrSize.setHeight( pView->GetGridHeight(eVWhich) );


core.git: editeng/source

2024-01-02 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/impedit2.cxx |   38 
 1 file changed, 22 insertions(+), 16 deletions(-)

New commits:
commit 548f0b1883e18ff2870a40bccf047864ff35c18b
Author: Tomaž Vajngerl 
AuthorDate: Tue Jan 2 15:29:52 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 2 09:56:55 2024 +0100

editeng: preserve ContentNode in a unique_ptr when moving paras

When we move the paragraphs, we can just take the unique_ptr of
ContetNodes out of the EditDoc and move it to new position inside
EditDoc, like it is done for ParaPortions in ParaPortionList.
No need to muck with the raw pointers and releasing the ContentNode
from a unique_ptr and later moving it back again.
Also just use a std::vector for ParaPortions instead of a new
instance of ParaPortionList.

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

diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index 78a56dc926bc..6e9351a7c80e 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2199,36 +2199,42 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range 
aOldPositions, sal_Int32 n
 // do not lose sight of the Position !
 ParaPortion* pDestPortion = GetParaPortions().SafeGetObject( nNewPos );
 
-ParaPortionList aTmpPortionList;
+// Temporary containers used for moving the paragraph portions and content 
nodes to a new location
+std::vector> aParagraphPortionVector;
+std::vector> aContentNodeVector;
+
+// Take the paragraph portions and content nodes out of its containers
 for (tools::Long i = aOldPositions.Min(); i <= aOldPositions.Max(); i++  )
 {
-// always aOldPositions.Min(), since Remove().
-std::unique_ptr pTmpPortion = 
GetParaPortions().Release(aOldPositions.Min());
-auto pContentNode = maEditDoc.Release(aOldPositions.Min());
-pContentNode.release();
-aTmpPortionList.Append(std::move(pTmpPortion));
+// always aOldPositions.Min() as the index, since we remove and the 
elements from the containers and the
+// other elements shift to the left.
+std::unique_ptr pPortion = 
GetParaPortions().Release(aOldPositions.Min());
+aParagraphPortionVector.push_back(std::move(pPortion));
+
+std::unique_ptr pContentNode = 
maEditDoc.Release(aOldPositions.Min());
+aContentNodeVector.push_back(std::move(pContentNode));
 }
 
+// Determine the new location for paragraphs
 sal_Int32 nRealNewPos = pDestPortion ? GetParaPortions().GetPos( 
pDestPortion ) : GetParaPortions().Count();
 assert( nRealNewPos != EE_PARA_NOT_FOUND && "ImpMoveParagraphs: Invalid 
Position!" );
 
+// Add the paragraph portions and content nodes to a new position
 sal_Int32 i = 0;
-while( aTmpPortionList.Count() > 0 )
+for (auto& pPortion : aParagraphPortionVector)
 {
-std::unique_ptr pTmpPortion = aTmpPortionList.Release(0);
-if ( i == 0 )
-aSelection.Min().SetNode( pTmpPortion->GetNode() );
-
-aSelection.Max().SetNode( pTmpPortion->GetNode() );
-aSelection.Max().SetIndex( pTmpPortion->GetNode()->Len() );
+if (i == 0)
+aSelection.Min().SetNode(pPortion->GetNode());
+aSelection.Max().SetNode(pPortion->GetNode());
+aSelection.Max().SetIndex(pPortion->GetNode()->Len());
 
-ContentNode* pNode = pTmpPortion->GetNode();
-maEditDoc.Insert(nRealNewPos+i, std::unique_ptr(pNode));
+maEditDoc.Insert(nRealNewPos + i, std::move(aContentNodeVector[i]));
+GetParaPortions().Insert(nRealNewPos + i, std::move(pPortion));
 
-GetParaPortions().Insert(nRealNewPos+i, std::move(pTmpPortion));
 ++i;
 }
 
+// Signal end of paragraph moving
 maEndMovingParagraphsHdl.Call( aMoveParagraphsInfo );
 
 if ( GetNotifyHdl().IsSet() )


core.git: editeng/inc editeng/source

2024-01-01 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/ParagraphPortionList.hxx |   14 +-
 editeng/source/editeng/impedit3.cxx  |3 +--
 2 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit e7e7449729fe2b750506b4b165c4be993834fd16
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 1 14:34:04 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 2 04:12:51 2024 +0100

editeng: add begin, end, MarkAllSelectionsInvalid to ParaPortionList

begin, end to make iteration work with range for

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

diff --git a/editeng/inc/ParagraphPortionList.hxx 
b/editeng/inc/ParagraphPortionList.hxx
index 23654adc5e43..aa7862afa8d7 100644
--- a/editeng/inc/ParagraphPortionList.hxx
+++ b/editeng/inc/ParagraphPortionList.hxx
@@ -28,7 +28,8 @@ class EditDoc;
 class ParaPortionList
 {
 mutable sal_Int32 nLastCache = 0;
-std::vector> maPortions;
+typedef std::vector> ParaPortionContainerType;
+ParaPortionContainerType maPortions;
 
 public:
 ParaPortionList() = default;
@@ -50,6 +51,17 @@ public:
 void Append(std::unique_ptr p);
 sal_Int32 Count() const;
 
+ParaPortionContainerType::iterator begin() { return maPortions.begin(); }
+ParaPortionContainerType::iterator end() { return maPortions.end(); }
+ParaPortionContainerType::const_iterator cbegin() const { return 
maPortions.cbegin(); }
+ParaPortionContainerType::const_iterator cend() const { return 
maPortions.cend(); }
+
+void MarkAllSelectionsInvalid(sal_Int32 nStart)
+{
+for (auto& pParaPortion : maPortions)
+pParaPortion->MarkSelectionInvalid(nStart);
+}
+
 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
 // temporary:
 static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc);
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index a4e0a54aaa0d..d50c2eb1338e 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -393,8 +393,7 @@ bool ImpEditEngine::IsPageOverflow( ) const
 
 void ImpEditEngine::FormatFullDoc()
 {
-for ( sal_Int32 nPortion = 0; nPortion < GetParaPortions().Count(); 
nPortion++ )
-GetParaPortions()[nPortion]->MarkSelectionInvalid( 0 );
+GetParaPortions().MarkAllSelectionsInvalid(0);
 FormatDoc();
 }
 


core.git: editeng/source

2024-01-01 Thread Tomaž Vajngerl (via logerrit)
 editeng/source/editeng/editeng.cxx  |   84 +++
 editeng/source/editeng/impedit.hxx  |  153 +--
 editeng/source/editeng/impedit2.cxx |  182 
 editeng/source/editeng/impedit3.cxx |  114 ++--
 editeng/source/editeng/impedit4.cxx |  199 +---
 editeng/source/editeng/impedit5.cxx |   20 +--
 6 files changed, 374 insertions(+), 378 deletions(-)

New commits:
commit de385412949e2ca52c999546677744ed070d189c
Author: Tomaž Vajngerl 
AuthorDate: Mon Jan 1 14:31:13 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 2 04:12:32 2024 +0100

editeng: prefix members of ImpEditEngine

Change-Id: I05a738be8956ebaa2912c6c8a20a05002d67b789
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161529
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index c5db1b5ca9ab..7af59f499e12 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -393,7 +393,7 @@ void EditEngine::SetPaperSize( const Size& rNewSize )
 if ( !(bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() )) )
 return;
 
-for (EditView* pView : pImpEditEngine->aEditViews)
+for (EditView* pView : pImpEditEngine->maEditViews)
 {
 if ( bAutoPageSize )
 pView->pImpEditView->RecalcOutputArea();
@@ -414,7 +414,7 @@ void EditEngine::SetPaperSize( const Size& rNewSize )
 pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() );
 
 if ( pImpEditEngine->IsUpdateLayout() && 
pImpEditEngine->GetActiveView() )
-pImpEditEngine->pActiveView->ShowCursor( false, false );
+pImpEditEngine->mpActiveView->ShowCursor( false, false );
 }
 }
 
@@ -685,7 +685,7 @@ void EditEngine::CheckIdleFormatter()
 
 bool EditEngine::IsIdleFormatterActive() const
 {
-return pImpEditEngine->aIdleFormatter.IsActive();
+return pImpEditEngine->maIdleFormatter.IsActive();
 }
 
 ParaPortion* EditEngine::FindParaPortion(ContentNode const * pNode)
@@ -725,7 +725,7 @@ bool EditEngine::IsCallParaInsertedOrDeleted() const
 
 void EditEngine::AppendDeletedNodeInfo(DeletedNodeInfo* pInfo)
 {
-
pImpEditEngine->aDeletedNodes.push_back(std::unique_ptr(pInfo));
+
pImpEditEngine->maDeletedNodes.push_back(std::unique_ptr(pInfo));
 }
 
 void EditEngine::UpdateSelections()
@@ -969,12 +969,12 @@ EditPaM EditEngine::DeleteSelected(const EditSelection& 
rSel)
 
 void EditEngine::HandleBeginPasteOrDrop(PasteOrDropInfos& rInfos)
 {
-pImpEditEngine->aBeginPasteOrDropHdl.Call(rInfos);
+pImpEditEngine->maBeginPasteOrDropHdl.Call(rInfos);
 }
 
 void EditEngine::HandleEndPasteOrDrop(PasteOrDropInfos& rInfos)
 {
-pImpEditEngine->aEndPasteOrDropHdl.Call(rInfos);
+pImpEditEngine->maEndPasteOrDropHdl.Call(rInfos);
 }
 
 bool EditEngine::HasText() const
@@ -984,7 +984,7 @@ bool EditEngine::HasText() const
 
 const EditSelectionEngine& EditEngine::GetSelectionEngine() const
 {
-return pImpEditEngine->aSelEngine;
+return pImpEditEngine->maSelEngine;
 }
 
 void EditEngine::SetInSelectionMode(bool b)
@@ -1049,7 +1049,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, 
EditView* pEditView, v
 sal_Int32 nParas = GetParagraphCount();
 Point aPos;
 Point aViewStart( pEditView->GetOutputArea().TopLeft() );
-tools::Long n20 = 40 * pImpEditEngine->nOnePixelInRef;
+tools::Long n20 = 40 * pImpEditEngine->mnOnePixelInRef;
 for ( sal_Int32 n = 0; n < nParas; n++ )
 {
 tools::Long nH = GetTextHeight( n );
@@ -1316,7 +1316,7 @@ bool EditEngine::PostKeyEvent( const KeyEvent& rKeyEvent, 
EditView* pEditView, v
 // Only at end of word...
 sal_Int32 nIndex = aCurSel.Max().GetIndex();
 if ( ( nIndex >= aCurSel.Max().GetNode()->Len() ) ||
- ( pImpEditEngine->aWordDelimiters.indexOf( 
aCurSel.Max().GetNode()->GetChar( nIndex ) ) != -1 ) )
+ ( pImpEditEngine->maWordDelimiters.indexOf( 
aCurSel.Max().GetNode()->GetChar( nIndex ) ) != -1 ) )
 {
 EditPaM aStart( pImpEditEngine->WordLeft( 
aCurSel.Max() ) );
 OUString aWord = pImpEditEngine->GetSelected( 
EditSelection( aStart, aCurSel.Max() ) );
@@ -1327,18 +1327,18 @@ bool EditEngine::PostKeyEvent( const KeyEvent& 
rKeyEvent, EditView* pEditView, v
 LanguageType eLang = 
pImpEditEngine->GetLanguage( EditPaM( aStart.GetNode(), 
aStart.GetIndex()+1)).nLang;
 LanguageTag aLanguageTag( eLang);
 
-if 

core.git: editeng/inc editeng/source

2024-01-01 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/editdoc.hxx |2 --
 editeng/source/editeng/editdoc.cxx  |   10 --
 editeng/source/editeng/edtspell.cxx |6 +++---
 editeng/source/editeng/impedit.hxx  |8 
 editeng/source/editeng/impedit2.cxx |   10 +-
 5 files changed, 12 insertions(+), 24 deletions(-)

New commits:
commit 92a9fa82f412daa4e5ccb5889076a1267648e0c1
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 31 19:15:38 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 2 04:11:16 2024 +0100

editeng: remove operator[] for EditDoc (use GetObject instead)

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

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 974447bd806c..0c2bcd28fa97 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -205,8 +205,6 @@ public:
 const ContentNode* GetObject(sal_Int32 nPos) const;
 ContentNode* GetObject(sal_Int32 nPos);
 sal_Int32 Count() const;
-const ContentNode* operator[](sal_Int32 nPos) const;
-ContentNode* operator[](sal_Int32 nPos);
 void Insert(sal_Int32 nPos, std::unique_ptr p);
 /// deletes
 void Remove(sal_Int32 nPos);
diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index 07d61802c773..efc95b944833 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -933,16 +933,6 @@ ContentNode* EditDoc::GetObject(sal_Int32 nPos)
 return 0 <= nPos && o3tl::make_unsigned(nPos) < maContents.size() ? 
maContents[nPos].get() : nullptr;
 }
 
-const ContentNode* EditDoc::operator[](sal_Int32 nPos) const
-{
-return GetObject(nPos);
-}
-
-ContentNode* EditDoc::operator[](sal_Int32 nPos)
-{
-return GetObject(nPos);
-}
-
 void EditDoc::Insert(sal_Int32 nPos, std::unique_ptr pNode)
 {
 if (nPos < 0 || nPos == SAL_MAX_INT32)
diff --git a/editeng/source/editeng/edtspell.cxx 
b/editeng/source/editeng/edtspell.cxx
index c07361bd196b..36e9f5fd84ae 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -613,8 +613,8 @@ OUString const* EdtAutoCorrDoc::GetPrevPara(bool const)
 
 bAllowUndoAction = false;   // Not anymore ...
 
-EditDoc& rNodes = mpEditEngine->GetEditDoc();
-sal_Int32 nPos = rNodes.GetPos( pCurNode );
+EditDoc& rEditDoc = mpEditEngine->GetEditDoc();
+sal_Int32 nPos = rEditDoc.GetPos( pCurNode );
 
 // Special case: Bullet => Paragraph start => simply return NULL...
 const SfxBoolItem& rBulletState = mpEditEngine->GetParaAttrib( nPos, 
EE_PARA_BULLETSTATE );
@@ -632,7 +632,7 @@ OUString const* EdtAutoCorrDoc::GetPrevPara(bool const)
 for ( sal_Int32 n = nPos; n; )
 {
 n--;
-ContentNode* pNode = rNodes[n];
+ContentNode* pNode = rEditDoc.GetObject(n);
 if ( pNode->Len() )
 return & pNode->GetString();
 }
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 7269c0e0b614..ef699b0b28ad 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -1090,8 +1090,8 @@ public:
 EditPaM CreateEditPaM( const EPaM& rEPaM )
 {
 DBG_ASSERT( rEPaM.nPara < maEditDoc.Count(), "CreateEditPaM: invalid 
paragraph" );
-DBG_ASSERT( maEditDoc[ rEPaM.nPara ]->Len() >= rEPaM.nIndex, 
"CreateEditPaM: invalid Index" );
-return EditPaM( maEditDoc[ rEPaM.nPara], rEPaM.nIndex );
+DBG_ASSERT(maEditDoc.GetObject(rEPaM.nPara)->Len() >= rEPaM.nIndex, 
"CreateEditPaM: invalid Index");
+return EditPaM(maEditDoc.GetObject(rEPaM.nPara), rEPaM.nIndex);
 }
 
 ESelection CreateESel(const EditSelection& rSel) const
@@ -,9 +,9 @@ public:
 DBG_ASSERT( rSel.nStartPara < maEditDoc.Count(), "CreateSel: invalid 
start paragraph" );
 DBG_ASSERT( rSel.nEndPara < maEditDoc.Count(), "CreateSel: invalid end 
paragraph" );
 EditSelection aSel;
-aSel.Min().SetNode( maEditDoc[ rSel.nStartPara ] );
+aSel.Min().SetNode(maEditDoc.GetObject(rSel.nStartPara));
 aSel.Min().SetIndex( rSel.nStartPos );
-aSel.Max().SetNode( maEditDoc[ rSel.nEndPara ] );
+aSel.Max().SetNode(maEditDoc.GetObject(rSel.nEndPara));
 aSel.Max().SetIndex( rSel.nEndPos );
 DBG_ASSERT( !aSel.DbgIsBuggy( maEditDoc ), "CreateSel: incorrect 
selection!" );
 return aSel;
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index 488873edd266..2b8263cc62cd 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -236,8 +236,8 @@ void ImpEditEngine::InitDoc(bool bKeepParaAttribs)
 sal_Int32 nParas = maEditDoc.Count();
 for ( sal_Int32 n = bKeepParaAttribs ? 1 : 0; n < nParas; n++ )
 {
-if ( maEditDoc[n]->GetStyleSheet() )
-

core.git: 2 commits - editeng/inc editeng/qa editeng/source include/editeng

2024-01-01 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/editdoc.hxx |2 
 editeng/qa/unit/core-test.cxx   |   93 +++-
 editeng/source/editeng/editdoc.cxx  |9 +--
 editeng/source/editeng/editeng.cxx  |4 -
 editeng/source/editeng/editundo.cxx |   45 -
 editeng/source/editeng/editundo.hxx |9 +--
 editeng/source/editeng/impedit.hxx  |2 
 editeng/source/editeng/impedit2.cxx |   31 ++--
 editeng/source/editeng/impedit3.cxx |8 +--
 include/editeng/editeng.hxx |2 
 10 files changed, 149 insertions(+), 56 deletions(-)

New commits:
commit e71934471442a8bbba7e661d3ebe5f708627c5d6
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 31 11:26:04 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 2 01:21:00 2024 +0100

editeng: add max paper size constant

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

diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index 94f4c6ccfa8f..488873edd266 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -88,11 +88,13 @@ static sal_uInt16 lcl_CalcExtraSpace( const 
SvxLineSpacingItem& rLSItem )
 return nExtra;
 }
 
+constexpr tools::Long constMaxPaperSize = 0x7FFF;
+
 ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) :
 pSharedVCL(EditDLL::Get().GetSharedVclResources()),
-maPaperSize( 0x7FFF, 0x7FFF ),
-maMinAutoPaperSize( 0x0, 0x0 ),
-maMaxAutoPaperSize( 0x7FFF, 0x7FFF ),
+maPaperSize(constMaxPaperSize, constMaxPaperSize),
+maMinAutoPaperSize(0, 0),
+maMaxAutoPaperSize(constMaxPaperSize, constMaxPaperSize),
 maEditDoc( pItemPool ),
 pEditEngine(pEE),
 pActiveView(nullptr),
commit 3461a0027cf5c54ae164462d177ea222ccc76f39
Author: Tomaž Vajngerl 
AuthorDate: Sat Dec 30 22:27:42 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Jan 2 01:20:53 2024 +0100

editeng: better lifecycle control for ContentNode in EditDoc

Don't use raw pointers, when it is possible to move the unique_ptr
around into another object that is responsible for the object's
ownership.
The ContentNode is either in a vector in the EditDoc class or it
is moved to the EditUndoDelContent class for the undo/redo action.
Those 2 classes are responsible for freeing the ContentNode.

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

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index e9016989e840..974447bd806c 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -211,7 +211,7 @@ public:
 /// deletes
 void Remove(sal_Int32 nPos);
 /// does not delete
-void Release(sal_Int32 nPos);
+std::unique_ptr Release(sal_Int32 nPos);
 
 static OUString GetSepStr( LineEnd eEnd );
 };
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index b5320f90e448..c17fccf1caef 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -113,6 +113,7 @@ public:
 void testTdf148148();
 
 void testSingleLine();
+void testMoveParagraph();
 
 DECL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, void );
 
@@ -139,6 +140,7 @@ public:
 CPPUNIT_TEST(testTdf147196);
 CPPUNIT_TEST(testTdf148148);
 CPPUNIT_TEST(testSingleLine);
+CPPUNIT_TEST(testMoveParagraph);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -555,8 +557,7 @@ IMPL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, 
pInfo, void )
 void Test::testHyperlinkCopyPaste()
 {
 // Create Outliner instance
-Outliner aOutliner(mpItemPool.get(), OutlinerMode
-::TextObject);
+Outliner aOutliner(mpItemPool.get(), OutlinerMode::TextObject);
 aOutliner.SetCalcFieldValueHdl( LINK( nullptr, Test, CalcFieldValueHdl ) );
 
 // Create EditEngine's instance
@@ -1984,6 +1985,94 @@ void Test::testSingleLine()
 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aEditEngine.GetLineCount(0));
 }
 
+void Test::testMoveParagraph()
+{
+EditEngine aEditEngine(mpItemPool.get());
+aEditEngine.SetPaperSize(Size(5000, 5000));
+aEditEngine.SetText("Paragraph 1
Paragraph 2
Paragraph 3
Paragraph 4
Paragraph 5");
+
+CPPUNIT_ASSERT_EQUAL(true, aEditEngine.IsFormatted());
+
+CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aEditEngine.GetParagraphCount());
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 1"), aEditEngine.GetText(0));
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 2"), aEditEngine.GetText(1));
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 3"), aEditEngine.GetText(2));
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 4"), aEditEngine.GetText(3));
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 5"), aEditEngine.GetText(4));
+
+

core.git: editeng/inc editeng/source

2024-01-01 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/editdoc.hxx |7 +--
 editeng/source/editeng/editdoc.cxx  |   18 +-
 editeng/source/editeng/impedit2.cxx |6 +++---
 editeng/source/editeng/impedit3.cxx |2 +-
 4 files changed, 18 insertions(+), 15 deletions(-)

New commits:
commit 417d1d56b39453b5ae8396a8286d8291061f049b
Author: Tomaž Vajngerl 
AuthorDate: Sat Dec 30 11:25:34 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jan 1 09:21:14 2024 +0100

editeng: make it clear EditDoc is responsible for ContentNodes

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

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 7fc29556957c..e9016989e840 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -100,7 +100,10 @@ public:
 };
 
 
-
+/** Edit document
+ *
+ * Holder, responsible for the content nodes and the manipulation of those.
+ */
 class EditDoc
 {
 private:
@@ -204,7 +207,7 @@ public:
 sal_Int32 Count() const;
 const ContentNode* operator[](sal_Int32 nPos) const;
 ContentNode* operator[](sal_Int32 nPos);
-void Insert(sal_Int32 nPos, ContentNode* p);
+void Insert(sal_Int32 nPos, std::unique_ptr p);
 /// deletes
 void Remove(sal_Int32 nPos);
 /// does not delete
diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index 0afcc9cdd81c..c44c0b5a123c 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -943,14 +943,14 @@ ContentNode* EditDoc::operator[](sal_Int32 nPos)
 return GetObject(nPos);
 }
 
-void EditDoc::Insert(sal_Int32 nPos, ContentNode* p)
+void EditDoc::Insert(sal_Int32 nPos, std::unique_ptr pNode)
 {
 if (nPos < 0 || nPos == SAL_MAX_INT32)
 {
 SAL_WARN( "editeng", "EditDoc::Insert - overflow pos " << nPos);
 return;
 }
-maContents.insert(maContents.begin()+nPos, 
std::unique_ptr(p));
+maContents.insert(maContents.begin()+nPos, std::move(pNode));
 }
 
 void EditDoc::Remove(sal_Int32 nPos)
@@ -1057,8 +1057,8 @@ EditPaM EditDoc::Clear()
 {
 maContents.clear();
 
-ContentNode* pNode = new ContentNode( GetItemPool() );
-Insert(0, pNode);
+ContentNode* pNode = new ContentNode(GetItemPool());
+Insert(0, std::unique_ptr(pNode));
 
 CreateDefFont(false);
 
@@ -1100,8 +1100,8 @@ EditPaM EditDoc::RemoveText()
 
 maContents.clear();
 
-ContentNode* pNode = new ContentNode( GetItemPool() );
-Insert(0, pNode);
+ContentNode* pNode = new ContentNode(GetItemPool());
+Insert(0, std::unique_ptr(pNode));
 
 pNode->SetStyleSheet(pPrevStyle, false);
 pNode->GetContentAttribs().GetItems().Set( aPrevSet );
@@ -1109,7 +1109,7 @@ EditPaM EditDoc::RemoveText()
 
 SetModified(true);
 
-return EditPaM( pNode, 0 );
+return EditPaM(pNode, 0);
 }
 
 EditPaM EditDoc::InsertText( EditPaM aPaM, std::u16string_view rStr )
@@ -1143,7 +1143,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool 
bKeepEndingAttribs )
 aContentAttribs.GetItems().Put( SfxBoolItem( EE_PARA_BULLETSTATE, true) );
 
 // ContentNode constructor copies also the paragraph attributes
-ContentNode* pNode = new ContentNode( aStr, std::move(aContentAttribs) );
+ContentNode* pNode = new ContentNode(aStr, std::move(aContentAttribs));
 
 // Copy the Default Font
 pNode->GetCharAttribs().GetDefFont() = 
aPaM.GetNode()->GetCharAttribs().GetDefFont();
@@ -1161,7 +1161,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool 
bKeepEndingAttribs )
 // Character attributes may need to be copied or trimmed:
 pNode->CopyAndCutAttribs( aPaM.GetNode(), GetItemPool(), 
bKeepEndingAttribs );
 
-Insert(nPos+1, pNode);
+Insert(nPos+1, std::unique_ptr(pNode));
 
 SetModified(true);
 
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index d3a62cb2b9de..b7a1aca97e2f 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -2218,8 +2218,8 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range 
aOldPositions, sal_Int32 n
 aSelection.Max().SetNode( pTmpPortion->GetNode() );
 aSelection.Max().SetIndex( pTmpPortion->GetNode()->Len() );
 
-ContentNode* pN = pTmpPortion->GetNode();
-maEditDoc.Insert(nRealNewPos+i, pN);
+ContentNode* pNode = pTmpPortion->GetNode();
+maEditDoc.Insert(nRealNewPos+i, std::unique_ptr(pNode));
 
 GetParaPortions().Insert(nRealNewPos+i, std::move(pTmpPortion));
 ++i;
@@ -2998,7 +2998,7 @@ EditPaM ImpEditEngine::ImpFastInsertParagraph( sal_Int32 
nPara )
 if ( GetStatus().DoOnlineSpelling() )
 pNode->CreateWrongList();
 
-maEditDoc.Insert(nPara, pNode);
+maEditDoc.Insert(nPara, std::unique_ptr(pNode));
 
 GetParaPortions().Insert(nPara, std::make_unique( pNode ));
 if 

core.git: 2 commits - editeng/inc editeng/source

2024-01-01 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/ParagraphPortion.hxx |   26 +++---
 editeng/inc/ParagraphPortionList.hxx |5 +-
 editeng/inc/editdoc.hxx  |   60 ++--
 editeng/source/editeng/editdoc.cxx   |   64 +--
 4 files changed, 75 insertions(+), 80 deletions(-)

New commits:
commit 252c0316c3be09079e08afc9fa512ca5a60ea957
Author: Tomaž Vajngerl 
AuthorDate: Fri Dec 29 21:55:54 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jan 1 09:21:06 2024 +0100

editeng: prefix members of EditDoc

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

diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 738c0b2d5772..7fc29556957c 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -104,20 +104,20 @@ public:
 class EditDoc
 {
 private:
-mutable sal_Int32 nLastCache;
-std::vector > maContents;
+mutable sal_Int32 mnLastCache;
+std::vector> maContents;
 
-rtl::Reference pItemPool;
-Link  aModifyHdl;
+rtl::Reference mpItemPool;
+Link maModifyHdl;
 
 SvxFont maDefFont;   //faster than ever from the pool!!
-sal_uInt16  nDefTab;
-boolbIsVertical:1;
+sal_uInt16  mnDefTab;
+boolmbIsVertical:1;
 TextRotationmnRotation;
-boolbIsFixedCellHeight:1;
+boolmbIsFixedCellHeight:1;
 
-boolbModified:1;
-boolbDisableAttributeExpanding:1;
+boolmbModified:1;
+boolmbDisableAttributeExpanding:1;
 
 public:
 EditDoc( SfxItemPool* pItemPool );
@@ -126,28 +126,44 @@ public:
 voiddumpAsXml(xmlTextWriterPtr pWriter) const;
 voidClearSpellErrors();
 
-boolIsModified() const  { return bModified; }
+boolIsModified() const  { return mbModified; }
 voidSetModified( bool b );
 
-voidDisableAttributeExpanding() { bDisableAttributeExpanding = 
true; }
+voidDisableAttributeExpanding() { mbDisableAttributeExpanding 
= true; }
 
-voidSetModifyHdl( const Link& rLink ) { 
aModifyHdl = rLink; }
+voidSetModifyHdl(const Link& rLink)
+{
+maModifyHdl = rLink;
+}
 
 voidCreateDefFont( bool bUseStyles );
 const SvxFont&  GetDefFont() const { return maDefFont; }
 
-voidSetDefTab( sal_uInt16 nTab ){ nDefTab = nTab ? nTab : 
DEFTAB; }
-sal_uInt16  GetDefTab() const   { return nDefTab; }
+voidSetDefTab(sal_uInt16 nTab)
+{
+mnDefTab = nTab ? nTab : DEFTAB;
+}
 
-voidSetVertical( bool bVertical )   { bIsVertical = bVertical; 
}
+sal_uInt16  GetDefTab() const
+{
+return mnDefTab;
+}
+
+voidSetVertical( bool bVertical )   { mbIsVertical = 
bVertical; }
 boolIsEffectivelyVertical() const;
 boolIsTopToBottom() const;
 boolGetVertical() const;
 voidSetRotation( TextRotation nRotation )   { mnRotation = 
nRotation; }
 TextRotationGetRotation() const { return 
mnRotation; }
 
-voidSetFixedCellHeight( bool bUseFixedCellHeight )  { 
bIsFixedCellHeight = bUseFixedCellHeight; }
-boolIsFixedCellHeight() const   { return 
bIsFixedCellHeight; }
+voidSetFixedCellHeight( bool bUseFixedCellHeight )
+{
+mbIsFixedCellHeight = bUseFixedCellHeight;
+}
+boolIsFixedCellHeight() const
+{
+return mbIsFixedCellHeight;
+}
 
 EditPaM Clear();
 EditPaM RemoveText();
@@ -166,8 +182,14 @@ public:
 EditPaM GetStartPaM() const;
 EditPaM GetEndPaM() const;
 
-SfxItemPool&GetItemPool()   { return *pItemPool; }
-const SfxItemPool&  GetItemPool() const { return *pItemPool; }
+SfxItemPool&GetItemPool()
+{
+return *mpItemPool;
+}
+const SfxItemPool&  GetItemPool() const
+{
+return *mpItemPool;
+}
 
 voidInsertAttrib( const SfxPoolItem& rItem, ContentNode* 
pNode, sal_Int32 nStart, sal_Int32 nEnd );
 voidInsertAttrib( ContentNode* pNode, sal_Int32 nStart, 
sal_Int32 nEnd, const SfxPoolItem& rPoolItem );
diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index fdfd74edb09a..0afcc9cdd81c 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -790,14 +790,14 @@ void EditSelection::Adjust( const EditDoc& rNodes )
 }
 
 EditDoc::EditDoc( SfxItemPool* pPool ) :
-nLastCache(0),
-pItemPool(pPool ? pPool : new EditEngineItemPool()),
-  

core.git: editeng/inc

2023-12-31 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/ParagraphPortionList.hxx |   60 +++
 editeng/inc/editdoc.hxx  |   33 ---
 2 files changed, 61 insertions(+), 32 deletions(-)

New commits:
commit 275860e607c172825bc47f70eba5562e5a9208f4
Author: Tomaž Vajngerl 
AuthorDate: Fri Dec 29 20:58:40 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jan 1 04:34:28 2024 +0100

editeng: move ParaPortionList into its own header file

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

diff --git a/editeng/inc/ParagraphPortionList.hxx 
b/editeng/inc/ParagraphPortionList.hxx
new file mode 100644
index ..8964c9767ba7
--- /dev/null
+++ b/editeng/inc/ParagraphPortionList.hxx
@@ -0,0 +1,60 @@
+/* -*- 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 "ParagraphPortion.hxx"
+
+#include 
+
+class EditDoc;
+
+class ParaPortionList
+{
+mutable sal_Int32 nLastCache;
+std::vector> maPortions;
+
+public:
+ParaPortionList();
+~ParaPortionList();
+
+void Reset();
+tools::Long GetYOffset(const ParaPortion* pPPortion) const;
+sal_Int32 FindParagraph(tools::Long nYOffset) const;
+
+const ParaPortion* SafeGetObject(sal_Int32 nPos) const;
+ParaPortion* SafeGetObject(sal_Int32 nPos);
+
+sal_Int32 GetPos(const ParaPortion* p) const;
+ParaPortion* operator[](sal_Int32 nPos);
+const ParaPortion* operator[](sal_Int32 nPos) const;
+
+std::unique_ptr Release(sal_Int32 nPos);
+void Remove(sal_Int32 nPos);
+void Insert(sal_Int32 nPos, std::unique_ptr p);
+void Append(std::unique_ptr p);
+sal_Int32 Count() const;
+
+#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
+// temporary:
+static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc);
+#endif
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 1b93d52a6a88..738c0b2d5772 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -19,6 +19,7 @@
 
 #pragma once
 
+#include "ParagraphPortionList.hxx"
 #include "editattr.hxx"
 #include "edtspell.hxx"
 #include "eerdll2.hxx"
@@ -37,7 +38,6 @@
 #include "EditLineList.hxx"
 #include "EditPaM.hxx"
 #include "EditSelection.hxx"
-#include "ParagraphPortion.hxx"
 
 #include 
 #include 
@@ -82,37 +82,6 @@ enum class DeleteMode {
 Simple, RestOfWord, RestOfContent
 };
 
-class ParaPortionList
-{
-mutable sal_Int32 nLastCache;
-std::vector> maPortions;
-public:
-ParaPortionList();
-~ParaPortionList();
-
-voidReset();
-tools::Long GetYOffset(const ParaPortion* pPPortion) const;
-sal_Int32 FindParagraph(tools::Long nYOffset) const;
-
-const ParaPortion* SafeGetObject(sal_Int32 nPos) const;
-ParaPortion* SafeGetObject(sal_Int32 nPos);
-
-sal_Int32 GetPos(const ParaPortion* p) const;
-ParaPortion* operator[](sal_Int32 nPos);
-const ParaPortion* operator[](sal_Int32 nPos) const;
-
-std::unique_ptr Release(sal_Int32 nPos);
-void Remove(sal_Int32 nPos);
-void Insert(sal_Int32 nPos, std::unique_ptr p);
-void Append(std::unique_ptr p);
-sal_Int32 Count() const;
-
-#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
-// temporary:
-static void DbgCheck(ParaPortionList const&, EditDoc const& rDoc);
-#endif
-};
-
 class DeletedNodeInfo
 {
 private:


core.git: 2 commits - editeng/inc editeng/Library_editeng.mk editeng/source solenv/clang-format

2023-12-31 Thread Tomaž Vajngerl (via logerrit)
 editeng/Library_editeng.mk |1 
 editeng/inc/ParagraphPortion.hxx   |  133 +
 editeng/inc/TextPortionList.hxx|   32 +-
 editeng/inc/editdoc.hxx|  104 --
 editeng/source/editeng/TextPortionList.cxx |   95 
 editeng/source/editeng/editdoc.cxx |  113 
 solenv/clang-format/excludelist|1 
 7 files changed, 254 insertions(+), 225 deletions(-)

New commits:
commit 916268c70a5673680c86eaac11c543fd45b90eb3
Author: Tomaž Vajngerl 
AuthorDate: Fri Dec 29 20:54:43 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jan 1 04:34:20 2024 +0100

editeng: move ParaPortion into its own header file

Change-Id: I3fefe4a9fc5d391b1c3af335893a084eaeddba4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161475
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/editeng/inc/ParagraphPortion.hxx b/editeng/inc/ParagraphPortion.hxx
new file mode 100644
index ..93eb8356f611
--- /dev/null
+++ b/editeng/inc/ParagraphPortion.hxx
@@ -0,0 +1,133 @@
+/* -*- 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 "EditLineList.hxx"
+#include "TextPortionList.hxx"
+
+struct ScriptTypePosInfo
+{
+short nScriptType;
+sal_Int32 nStartPos;
+sal_Int32 nEndPos;
+
+ScriptTypePosInfo(short Type, sal_Int32 Start, sal_Int32 End)
+: nScriptType(Type)
+, nStartPos(Start)
+, nEndPos(End)
+{
+}
+};
+
+typedef std::vector ScriptTypePosInfos;
+
+struct WritingDirectionInfo
+{
+sal_uInt8 nType;
+sal_Int32 nStartPos;
+sal_Int32 nEndPos;
+
+WritingDirectionInfo(sal_uInt8 Type, sal_Int32 Start, sal_Int32 End)
+: nType(Type)
+, nStartPos(Start)
+, nEndPos(End)
+{
+}
+};
+
+typedef std::vector WritingDirectionInfos;
+
+class ParaPortion
+{
+friend class ImpEditEngine; // to adjust the height
+private:
+EditLineList aLineList;
+TextPortionList aTextPortionList;
+ContentNode* pNode;
+tools::Long nHeight;
+
+ScriptTypePosInfos aScriptInfos;
+WritingDirectionInfos aWritingDirectionInfos;
+
+sal_Int32 nInvalidPosStart;
+sal_Int32 nFirstLineOffset; // For Writer-LineSpacing-Interpretation
+sal_Int32 nBulletX;
+sal_Int32 nInvalidDiff;
+
+bool bInvalid : 1;
+bool bSimple : 1; // only linear Tap
+bool bVisible : 1; // Belongs to the node!
+bool bForceRepaint : 1;
+
+ParaPortion(const ParaPortion&) = delete;
+
+public:
+ParaPortion(ContentNode* pNode);
+~ParaPortion();
+
+sal_Int32 GetLineNumber(sal_Int32 nIndex) const;
+
+EditLineList& GetLines() { return aLineList; }
+const EditLineList& GetLines() const { return aLineList; }
+
+bool IsInvalid() const { return bInvalid; }
+bool IsSimpleInvalid() const { return bSimple; }
+void SetValid()
+{
+bInvalid = false;
+bSimple = true;
+}
+
+bool MustRepaint() const { return bForceRepaint; }
+void SetMustRepaint(bool bRP) { bForceRepaint = bRP; }
+
+sal_Int32 GetBulletX() const { return nBulletX; }
+void SetBulletX(sal_Int32 n) { nBulletX = n; }
+
+void MarkInvalid(sal_Int32 nStart, sal_Int32 nDiff);
+void MarkSelectionInvalid(sal_Int32 nStart);
+
+void SetVisible(bool bVisible);
+bool IsVisible() const { return bVisible; }
+
+bool IsEmpty() { return GetTextPortions().Count() == 1 && 
GetTextPortions()[0].GetLen() == 0; }
+
+tools::Long GetHeight() const { return (bVisible ? nHeight : 0); }
+sal_Int32 GetFirstLineOffset() const { return (bVisible ? nFirstLineOffset 
: 0); }
+void ResetHeight()
+{
+nHeight = 0;
+nFirstLineOffset = 0;
+}
+
+ContentNode* GetNode() const { return pNode; }
+TextPortionList& GetTextPortions() { return aTextPortionList; }
+const TextPortionList& GetTextPortions() const { return aTextPortionList; }
+
+sal_Int32 GetInvalidPosStart() const { return nInvalidPosStart; }
+short GetInvalidDiff() const { 

core.git: editeng/inc

2023-12-31 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/TextPortionList.hxx |   48 
 editeng/inc/editdoc.hxx |   25 
 2 files changed, 49 insertions(+), 24 deletions(-)

New commits:
commit e3267cadcaa8cfc64705e24bd484815469b8814f
Author: Tomaž Vajngerl 
AuthorDate: Fri Dec 29 16:47:30 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Jan 1 03:06:57 2024 +0100

editeng: move TextPortionList into its own header file

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

diff --git a/editeng/inc/TextPortionList.hxx b/editeng/inc/TextPortionList.hxx
new file mode 100644
index ..3e2272f4de9c
--- /dev/null
+++ b/editeng/inc/TextPortionList.hxx
@@ -0,0 +1,48 @@
+/* -*- 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 "TextPortion.hxx"
+#include 
+
+class TextPortionList
+{
+typedef std::vector> PortionsType;
+PortionsType maPortions;
+
+public:
+TextPortionList();
+~TextPortionList();
+
+void Reset();
+sal_Int32 FindPortion(sal_Int32 nCharPos, sal_Int32& rPortionStart,
+  bool bPreferStartingPortion = false) const;
+sal_Int32 GetStartPos(sal_Int32 nPortion);
+void DeleteFromPortion(sal_Int32 nDelFrom);
+sal_Int32 Count() const;
+const TextPortion& operator[](sal_Int32 nPos) const;
+TextPortion& operator[](sal_Int32 nPos);
+
+void Append(TextPortion* p);
+void Insert(sal_Int32 nPos, TextPortion* p);
+void Remove(sal_Int32 nPos);
+sal_Int32 GetPos(const TextPortion* p) const;
+};
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index ee4f4433c307..f81eac050b76 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include "TextPortion.hxx"
+#include "TextPortionList.hxx"
 #include "ItemList.hxx"
 #include "ContentNode.hxx"
 #include "EditLineList.hxx"
@@ -113,30 +114,6 @@ enum class DeleteMode {
 Simple, RestOfWord, RestOfContent
 };
 
-class TextPortionList
-{
-typedef std::vector > PortionsType;
-PortionsType maPortions;
-
-public:
-TextPortionList();
-~TextPortionList();
-
-voidReset();
-sal_Int32 FindPortion(
-sal_Int32 nCharPos, sal_Int32& rPortionStart, bool 
bPreferStartingPortion = false) const;
-sal_Int32 GetStartPos(sal_Int32 nPortion);
-void DeleteFromPortion(sal_Int32 nDelFrom);
-sal_Int32 Count() const;
-const TextPortion& operator[](sal_Int32 nPos) const;
-TextPortion& operator[](sal_Int32 nPos);
-
-void Append(TextPortion* p);
-void Insert(sal_Int32 nPos, TextPortion* p);
-void Remove(sal_Int32 nPos);
-sal_Int32 GetPos(const TextPortion* p) const;
-};
-
 class ParaPortion
 {
 friend class ImpEditEngine; // to adjust the height


core.git: editeng/CppunitTest_editeng_core.mk editeng/inc editeng/qa editeng/source

2023-12-31 Thread Tomaž Vajngerl (via logerrit)
 editeng/CppunitTest_editeng_core.mk   |1 
 editeng/inc/EditSelection.hxx |   25 -
 editeng/qa/unit/EditSelectionTest.cxx |  143 ++
 editeng/source/editeng/editdoc.cxx|   23 -
 4 files changed, 162 insertions(+), 30 deletions(-)

New commits:
commit 5b4dfce8933b1a2c18b9fc00d2b8a9a8ce37b510
Author: Tomaž Vajngerl 
AuthorDate: Wed Dec 27 14:31:53 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Dec 31 10:32:00 2023 +0100

editeng: cleanup operators and constructors for EditSelection + test

Move the constructors into class body, cleanup operators so they
use more standard class based operators and use default for !=
as it will just be a neagtion of ==.

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

diff --git a/editeng/CppunitTest_editeng_core.mk 
b/editeng/CppunitTest_editeng_core.mk
index 47be49fbcd96..3fc6d9bde688 100644
--- a/editeng/CppunitTest_editeng_core.mk
+++ b/editeng/CppunitTest_editeng_core.mk
@@ -17,6 +17,7 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,editeng_core, \
 editeng/qa/unit/EPaMTest \
 editeng/qa/unit/EditLineTest \
 editeng/qa/unit/EditPaMTest \
+editeng/qa/unit/EditSelectionTest \
 ))
 
 $(eval $(call gb_CppunitTest_use_library_objects,editeng_core,editeng))
diff --git a/editeng/inc/EditSelection.hxx b/editeng/inc/EditSelection.hxx
index c94fce2c0881..9d11a9685c30 100644
--- a/editeng/inc/EditSelection.hxx
+++ b/editeng/inc/EditSelection.hxx
@@ -28,10 +28,19 @@ private:
 EditPaM aEndPaM;
 
 public:
-EditSelection();
+EditSelection() = default;
 
-EditSelection(const EditPaM& rStartAndAnd);
-EditSelection(const EditPaM& rStart, const EditPaM& rEnd);
+EditSelection(const EditPaM& rStartAndEnd)
+: aStartPaM(rStartAndEnd)
+, aEndPaM(rStartAndEnd)
+{
+}
+
+EditSelection(const EditPaM& rStart, const EditPaM& rEnd)
+: aStartPaM(rStart)
+, aEndPaM(rEnd)
+{
+}
 
 EditPaM& Min() { return aStartPaM; }
 EditPaM& Max() { return aEndPaM; }
@@ -45,12 +54,14 @@ public:
 
 void Adjust(const EditDoc& rNodes);
 
-EditSelection& operator=(const EditPaM& r);
-bool operator==(const EditSelection& r) const
+EditSelection& operator=(const EditPaM& rPaM)
 {
-return (aStartPaM == r.aStartPaM) && (aEndPaM == r.aEndPaM);
+aStartPaM = rPaM;
+aEndPaM = rPaM;
+return *this;
 }
-bool operator!=(const EditSelection& r) const { return !(r == *this); }
+
+bool operator==(const EditSelection& rOther) const = default;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/qa/unit/EditSelectionTest.cxx 
b/editeng/qa/unit/EditSelectionTest.cxx
new file mode 100644
index ..b3308fbc2fa9
--- /dev/null
+++ b/editeng/qa/unit/EditSelectionTest.cxx
@@ -0,0 +1,143 @@
+/* -*- 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/.
+ */
+
+#include 
+#include 
+#include 
+
+namespace
+{
+class EditSelectionTest : public test::BootstrapFixture
+{
+protected:
+rtl::Reference mpItemPool;
+
+public:
+void setUp() override
+{
+test::BootstrapFixture::setUp();
+mpItemPool = new EditEngineItemPool();
+}
+
+void tearDown() override
+{
+mpItemPool.clear();
+test::BootstrapFixture::tearDown();
+}
+};
+
+CPPUNIT_TEST_FIXTURE(EditSelectionTest, testConstruction)
+{
+// Check empty selections
+EditSelection aEmpty;
+CPPUNIT_ASSERT(aEmpty.Min().GetNode() == nullptr);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aEmpty.Min().GetIndex());
+
+CPPUNIT_ASSERT(aEmpty.Max().GetNode() == nullptr);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aEmpty.Max().GetIndex());
+
+// Create content nodes
+ContentNode aContentNode1(*mpItemPool);
+ContentNode* pContentNode1 = 
+ContentNode aContentNode2(*mpItemPool);
+ContentNode* pContentNode2 = 
+
+// Check selection with (node1 10, node1 20)
+{
+EditSelection aNew(EditPaM(, 10), 
EditPaM(, 20));
+
+CPPUNIT_ASSERT_EQUAL(true, aNew.Min().GetNode() == pContentNode1);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNew.Min().GetIndex());
+
+CPPUNIT_ASSERT_EQUAL(true, aNew.Max().GetNode() == pContentNode1);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(20), aNew.Max().GetIndex());
+}
+
+// Check selection with (node1 10, node2 10)
+{
+EditSelection aNew(EditPaM(, 10), 
EditPaM(, 10));
+
+CPPUNIT_ASSERT_EQUAL(true, aNew.Min().GetNode() == pContentNode1);
+

core.git: editeng/CppunitTest_editeng_core.mk editeng/inc editeng/qa editeng/source

2023-12-30 Thread Tomaž Vajngerl (via logerrit)
 editeng/CppunitTest_editeng_core.mk |1 
 editeng/inc/EditPaM.hxx |   18 +---
 editeng/qa/unit/EditPaMTest.cxx |   74 
 editeng/source/editeng/editdoc.cxx  |   20 -
 4 files changed, 86 insertions(+), 27 deletions(-)

New commits:
commit ac481d5df48c9db1f662903af52a5dd50bbe66df
Author: Tomaž Vajngerl 
AuthorDate: Mon Dec 25 00:41:53 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Dec 31 07:49:39 2023 +0100

editeng: cleanup operators and constructors for EditPaM + test

Move the constructors into class body, cleanup operators so they
use more standard class based operators and use default for !=
as it will just be a neagtion of ==.

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

diff --git a/editeng/CppunitTest_editeng_core.mk 
b/editeng/CppunitTest_editeng_core.mk
index d28c7fcb4365..47be49fbcd96 100644
--- a/editeng/CppunitTest_editeng_core.mk
+++ b/editeng/CppunitTest_editeng_core.mk
@@ -16,6 +16,7 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,editeng_core, \
 editeng/qa/unit/ESelectionTest \
 editeng/qa/unit/EPaMTest \
 editeng/qa/unit/EditLineTest \
+editeng/qa/unit/EditPaMTest \
 ))
 
 $(eval $(call gb_CppunitTest_use_library_objects,editeng_core,editeng))
diff --git a/editeng/inc/EditPaM.hxx b/editeng/inc/EditPaM.hxx
index 2aa733f5ea74..9a33ad5a0990 100644
--- a/editeng/inc/EditPaM.hxx
+++ b/editeng/inc/EditPaM.hxx
@@ -26,24 +26,28 @@ class EditDoc;
 class EditPaM
 {
 private:
-ContentNode* pNode;
-sal_Int32 nIndex;
+ContentNode* pNode = nullptr;
+sal_Int32 nIndex = 0;
 
 public:
-EditPaM();
-EditPaM(ContentNode* p, sal_Int32 n);
+EditPaM() = default;
+EditPaM(ContentNode* p, sal_Int32 n)
+: pNode(p)
+, nIndex(n)
+{
+}
 
 const ContentNode* GetNode() const { return pNode; }
 ContentNode* GetNode() { return pNode; }
-void SetNode(ContentNode* p);
+void SetNode(ContentNode* p) { pNode = p; }
 
 sal_Int32 GetIndex() const { return nIndex; }
 void SetIndex(sal_Int32 n) { nIndex = n; }
 
 bool DbgIsBuggy(EditDoc const& rDoc) const;
 
-friend bool operator==(const EditPaM& r1, const EditPaM& r2);
-friend bool operator!=(const EditPaM& r1, const EditPaM& r2);
+bool operator==(const EditPaM& rOther) const = default;
+
 bool operator!() const { return !pNode && !nIndex; }
 };
 
diff --git a/editeng/qa/unit/EditPaMTest.cxx b/editeng/qa/unit/EditPaMTest.cxx
new file mode 100644
index ..12f0fa9741c9
--- /dev/null
+++ b/editeng/qa/unit/EditPaMTest.cxx
@@ -0,0 +1,74 @@
+/* -*- 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/.
+ */
+
+#include 
+#include 
+#include 
+
+namespace
+{
+class EditPaMTest : public test::BootstrapFixture
+{
+protected:
+rtl::Reference mpItemPool;
+
+public:
+void setUp() override
+{
+test::BootstrapFixture::setUp();
+mpItemPool = new EditEngineItemPool();
+}
+
+void tearDown() override
+{
+mpItemPool.clear();
+test::BootstrapFixture::tearDown();
+}
+};
+
+CPPUNIT_TEST_FIXTURE(EditPaMTest, testConstruction)
+{
+EditPaM aEmpty;
+CPPUNIT_ASSERT(aEmpty.GetNode() == nullptr);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aEmpty.GetIndex());
+
+ContentNode aContentNode(*mpItemPool);
+EditPaM aNew(, 10);
+
+CPPUNIT_ASSERT(aNew.GetNode() != nullptr);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(10), aNew.GetIndex());
+}
+
+CPPUNIT_TEST_FIXTURE(EditPaMTest, testEquals)
+{
+ContentNode aContentNode(*mpItemPool);
+
+EditPaM aEditPaMEmpty1;
+EditPaM aEditPaMEmpty2;
+
+CPPUNIT_ASSERT_EQUAL(true, aEditPaMEmpty1 == aEditPaMEmpty2);
+CPPUNIT_ASSERT_EQUAL(false, aEditPaMEmpty1 != aEditPaMEmpty2);
+
+EditPaM aEditPaM1(, 10);
+
+CPPUNIT_ASSERT_EQUAL(false, aEditPaMEmpty1 == aEditPaM1);
+CPPUNIT_ASSERT_EQUAL(true, aEditPaMEmpty1 != aEditPaM1);
+
+EditPaM aEditPaM2(, 15);
+CPPUNIT_ASSERT_EQUAL(false, aEditPaM2 == aEditPaM1);
+CPPUNIT_ASSERT_EQUAL(true, aEditPaM2 != aEditPaM1);
+
+EditPaM aEditPaM3(, 10);
+CPPUNIT_ASSERT_EQUAL(true, aEditPaM3 == aEditPaM1);
+CPPUNIT_ASSERT_EQUAL(false, aEditPaM3 != aEditPaM1);
+}
+
+} // end anonymous namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index 153cc25dfc1f..d61683619a84 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -890,15 +890,6 @@ void 

core.git: 2 commits - editeng/inc

2023-12-30 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/EditPaM.hxx   |   50 +++
 editeng/inc/EditSelection.hxx |   56 +++
 editeng/inc/editdoc.hxx   |   60 +-
 3 files changed, 108 insertions(+), 58 deletions(-)

New commits:
commit 5c1f9ec049a724071bd47bca2d76553c0dfb1718
Author: Tomaž Vajngerl 
AuthorDate: Mon Dec 25 00:16:25 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Dec 31 02:34:59 2023 +0100

editeng: move EditSelection into its own header file

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

diff --git a/editeng/inc/EditSelection.hxx b/editeng/inc/EditSelection.hxx
new file mode 100644
index ..c94fce2c0881
--- /dev/null
+++ b/editeng/inc/EditSelection.hxx
@@ -0,0 +1,56 @@
+/* -*- 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 "EditPaM.hxx"
+
+class EditSelection
+{
+private:
+EditPaM aStartPaM;
+EditPaM aEndPaM;
+
+public:
+EditSelection();
+
+EditSelection(const EditPaM& rStartAndAnd);
+EditSelection(const EditPaM& rStart, const EditPaM& rEnd);
+
+EditPaM& Min() { return aStartPaM; }
+EditPaM& Max() { return aEndPaM; }
+
+const EditPaM& Min() const { return aStartPaM; }
+const EditPaM& Max() const { return aEndPaM; }
+
+bool HasRange() const { return aStartPaM != aEndPaM; }
+bool IsInvalid() const { return !aStartPaM || !aEndPaM; }
+bool DbgIsBuggy(EditDoc const& rDoc) const;
+
+void Adjust(const EditDoc& rNodes);
+
+EditSelection& operator=(const EditPaM& r);
+bool operator==(const EditSelection& r) const
+{
+return (aStartPaM == r.aStartPaM) && (aEndPaM == r.aEndPaM);
+}
+bool operator!=(const EditSelection& r) const { return !(r == *this); }
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 6bba498440f6..ee4f4433c307 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -35,6 +35,7 @@
 #include "ContentNode.hxx"
 #include "EditLineList.hxx"
 #include "EditPaM.hxx"
+#include "EditSelection.hxx"
 
 #include 
 #include 
@@ -237,40 +238,6 @@ public:
 #endif
 };
 
-
-
-class EditSelection
-{
-private:
-EditPaM aStartPaM;
-EditPaM aEndPaM;
-
-public:
-EditSelection();// No constructor and destructor
-// are automatically executed 
correctly!
-EditSelection( const EditPaM& rStartAndAnd );
-EditSelection( const EditPaM& rStart, const EditPaM& rEnd 
);
-
-EditPaM&Min()   { return aStartPaM; }
-EditPaM&Max()   { return aEndPaM; }
-
-const EditPaM&  Min() const { return aStartPaM; }
-const EditPaM&  Max() const { return aEndPaM; }
-
-boolHasRange() const{ return aStartPaM != aEndPaM; }
-boolIsInvalid() const { return !aStartPaM || !aEndPaM; }
-boolDbgIsBuggy( EditDoc const & rDoc ) const;
-
-voidAdjust( const EditDoc& rNodes );
-
-EditSelection&  operator = ( const EditPaM& r );
-booloperator == ( const EditSelection& r ) const
-{ return ( aStartPaM == r.aStartPaM ) && ( aEndPaM == 
r.aEndPaM ); }
-booloperator != ( const EditSelection& r ) const { return !( r 
== *this ); }
-};
-
-
-
 class DeletedNodeInfo
 {
 private:
commit 291fe245284806538d74b40d45dfa20b3fbab172
Author: Tomaž Vajngerl 
AuthorDate: Mon Dec 25 00:14:00 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Dec 31 02:34:52 2023 +0100

editeng: move EditPaM into its own header file

Change-Id: I13c5d4f2ea0bd7ef942ac0cacb9dce4b58909b19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161362
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/editeng/inc/EditPaM.hxx b/editeng/inc/EditPaM.hxx
new 

core.git: editeng/inc editeng/source

2023-12-30 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/EditLineList.hxx   |   53 +++---
 editeng/inc/editdoc.hxx|1 
 editeng/source/editeng/editdoc.cxx |   64 -
 3 files changed, 41 insertions(+), 77 deletions(-)

New commits:
commit 020444ed98d7a31403787238cd753e112a6a56fb
Author: Tomaž Vajngerl 
AuthorDate: Mon Dec 25 00:06:07 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Dec 30 14:17:16 2023 +0100

editeng: move EditLineList methods definition into header

Class is simple enough and more or less just wraps the vector
anyway.

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

diff --git a/editeng/inc/EditLineList.hxx b/editeng/inc/EditLineList.hxx
index 2b3874913cad..a3a547d7ce24 100644
--- a/editeng/inc/EditLineList.hxx
+++ b/editeng/inc/EditLineList.hxx
@@ -19,8 +19,12 @@
 
 #pragma once
 
+#include "EditLine.hxx"
+
+#include 
 #include 
 #include 
+#include 
 
 class EditLineList
 {
@@ -28,18 +32,43 @@ class EditLineList
 LinesType maLines;
 
 public:
-EditLineList();
-~EditLineList();
-
-void Reset();
-void DeleteFromLine(sal_Int32 nDelFrom);
-sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd);
-sal_Int32 Count() const;
-const EditLine& operator[](sal_Int32 nPos) const;
-EditLine& operator[](sal_Int32 nPos);
-
-void Append(EditLine* p);
-void Insert(sal_Int32 nPos, EditLine* p);
+EditLineList() = default;
+
+void Reset() { maLines.clear(); }
+
+void DeleteFromLine(sal_Int32 nDelFrom)
+{
+assert(nDelFrom <= (static_cast(maLines.size()) - 1));
+LinesType::iterator it = maLines.begin();
+std::advance(it, nDelFrom);
+maLines.erase(it, maLines.end());
+}
+
+sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd)
+{
+sal_Int32 n = maLines.size();
+for (sal_Int32 i = 0; i < n; ++i)
+{
+const EditLine& rLine = *maLines[i];
+if ((bInclEnd && (rLine.GetEnd() >= nChar)) || (rLine.GetEnd() > 
nChar))
+{
+return i;
+}
+}
+
+DBG_ASSERT(!bInclEnd, "Line not found: FindLine");
+return n - 1;
+}
+
+sal_Int32 Count() const { return maLines.size(); }
+const EditLine& operator[](sal_Int32 nPos) const { return *maLines[nPos]; }
+EditLine& operator[](sal_Int32 nPos) { return *maLines[nPos]; }
+
+void Append(EditLine* p) { 
maLines.push_back(std::unique_ptr(p)); }
+void Insert(sal_Int32 nPos, EditLine* p)
+{
+maLines.insert(maLines.begin() + nPos, std::unique_ptr(p));
+}
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 3db8a8a64a63..e400a3b42e4a 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -33,7 +33,6 @@
 #include "TextPortion.hxx"
 #include "ItemList.hxx"
 #include "ContentNode.hxx"
-#include "EditLine.hxx"
 #include "EditLineList.hxx"
 
 #include 
diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index e37bc47a7fa3..153cc25dfc1f 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -890,70 +890,6 @@ void ConvertAndPutItems( SfxItemSet& rDest, const 
SfxItemSet& rSource, const Map
 }
 }
 
-EditLineList::EditLineList()
-{
-}
-
-EditLineList::~EditLineList()
-{
-Reset();
-}
-
-void EditLineList::Reset()
-{
-maLines.clear();
-}
-
-void EditLineList::DeleteFromLine(sal_Int32 nDelFrom)
-{
-assert(nDelFrom <= (static_cast(maLines.size()) - 1));
-LinesType::iterator it = maLines.begin();
-std::advance(it, nDelFrom);
-maLines.erase(it, maLines.end());
-}
-
-sal_Int32 EditLineList::FindLine(sal_Int32 nChar, bool bInclEnd)
-{
-sal_Int32 n = maLines.size();
-for (sal_Int32 i = 0; i < n; ++i)
-{
-const EditLine& rLine = *maLines[i];
-if ( (bInclEnd && (rLine.GetEnd() >= nChar)) ||
- (rLine.GetEnd() > nChar) )
-{
-return i;
-}
-}
-
-DBG_ASSERT( !bInclEnd, "Line not found: FindLine" );
-return n - 1;
-}
-
-sal_Int32 EditLineList::Count() const
-{
-return maLines.size();
-}
-
-const EditLine& EditLineList::operator[](sal_Int32 nPos) const
-{
-return *maLines[nPos];
-}
-
-EditLine& EditLineList::operator[](sal_Int32 nPos)
-{
-return *maLines[nPos];
-}
-
-void EditLineList::Append(EditLine* p)
-{
-maLines.push_back(std::unique_ptr(p));
-}
-
-void EditLineList::Insert(sal_Int32 nPos, EditLine* p)
-{
-maLines.insert(maLines.begin()+nPos, std::unique_ptr(p));
-}
-
 EditPaM::EditPaM() : pNode(nullptr), nIndex(0) {}
 EditPaM::EditPaM(ContentNode* p, sal_Int32 n) : pNode(p), nIndex(n) {}
 


core.git: 2 commits - editeng/inc editeng/Library_editeng.mk editeng/source solenv/clang-format

2023-12-30 Thread Tomaž Vajngerl (via logerrit)
 editeng/Library_editeng.mk  |1 
 editeng/inc/EditLine.hxx|4 +
 editeng/inc/EditLineList.hxx|   45 ++
 editeng/inc/editdoc.hxx |   23 -
 editeng/source/editeng/EditLine.cxx |   90 
 editeng/source/editeng/editdoc.cxx  |   66 --
 solenv/clang-format/excludelist |1 
 7 files changed, 142 insertions(+), 88 deletions(-)

New commits:
commit 4acb0979b10bf35cf929078e53ea249e1416
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 24 23:55:58 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Dec 30 14:17:08 2023 +0100

editeng: move EditLineList to its own header file

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

diff --git a/editeng/inc/EditLineList.hxx b/editeng/inc/EditLineList.hxx
new file mode 100644
index ..2b3874913cad
--- /dev/null
+++ b/editeng/inc/EditLineList.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/.
+ *
+ * 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 
+#include 
+
+class EditLineList
+{
+typedef std::vector> LinesType;
+LinesType maLines;
+
+public:
+EditLineList();
+~EditLineList();
+
+void Reset();
+void DeleteFromLine(sal_Int32 nDelFrom);
+sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd);
+sal_Int32 Count() const;
+const EditLine& operator[](sal_Int32 nPos) const;
+EditLine& operator[](sal_Int32 nPos);
+
+void Append(EditLine* p);
+void Insert(sal_Int32 nPos, EditLine* p);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index c53abc62949c..3db8a8a64a63 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -34,6 +34,7 @@
 #include "ItemList.hxx"
 #include "ContentNode.hxx"
 #include "EditLine.hxx"
+#include "EditLineList.hxx"
 
 #include 
 #include 
@@ -159,28 +160,6 @@ public:
 sal_Int32 GetPos(const TextPortion* p) const;
 };
 
-class EditLineList
-{
-typedef std::vector > LinesType;
-LinesType maLines;
-
-public:
-EditLineList();
-~EditLineList();
-
-void Reset();
-void DeleteFromLine(sal_Int32 nDelFrom);
-sal_Int32 FindLine(sal_Int32 nChar, bool bInclEnd);
-sal_Int32 Count() const;
-const EditLine& operator[](sal_Int32 nPos) const;
-EditLine& operator[](sal_Int32 nPos);
-
-void Append(EditLine* p);
-void Insert(sal_Int32 nPos, EditLine* p);
-};
-
-
-
 class ParaPortion
 {
 friend class ImpEditEngine; // to adjust the height
commit 9a62dcf59af3513a82fb5640314021d064d8b9b7
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 24 22:45:54 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Dec 30 14:16:59 2023 +0100

editeng: move impl. of EditLine methods to own cxx sourcefile

Change-Id: I9856302967de59368dc60b3e01f4a36fdb97e00e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161359
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk
index e0834b96f983..49225b910d14 100644
--- a/editeng/Library_editeng.mk
+++ b/editeng/Library_editeng.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
 editeng/source/editeng/editdbg \
 editeng/source/editeng/editdoc \
 editeng/source/editeng/editeng \
+editeng/source/editeng/EditLine \
 editeng/source/editeng/editobj \
 editeng/source/editeng/editsel \
 editeng/source/editeng/editundo \
diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx
index df1dec9f0ae2..165f3fcf0a59 100644
--- a/editeng/inc/EditLine.hxx
+++ b/editeng/inc/EditLine.hxx
@@ -19,6 +19,10 @@
 
 #pragma once
 
+#include 
+#include 
+#include 
+
 class ParaPortion;
 
 class EditLine
diff --git a/editeng/source/editeng/EditLine.cxx 
b/editeng/source/editeng/EditLine.cxx
new file mode 100644
index ..7724f8f12a79
--- /dev/null
+++ b/editeng/source/editeng/EditLine.cxx
@@ 

core.git: editeng/CppunitTest_editeng_core.mk editeng/inc editeng/qa editeng/source

2023-12-30 Thread Tomaž Vajngerl (via logerrit)
 editeng/CppunitTest_editeng_core.mk |1 
 editeng/inc/EditLine.hxx|   58 +-
 editeng/qa/unit/EditLineTest.cxx|  111 
 editeng/source/editeng/editdoc.cxx  |   63 
 4 files changed, 154 insertions(+), 79 deletions(-)

New commits:
commit 72fde57386eb7b53f4b1a0954a1595e36cf17e5f
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 24 22:34:40 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Dec 30 14:16:43 2023 +0100

editeng: EditLine test and refactor constructors, operators

Change-Id: Ia60ce07073725bf66bf299edaf7b3cd24cfe59c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161358
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/editeng/CppunitTest_editeng_core.mk 
b/editeng/CppunitTest_editeng_core.mk
index 43df48cbe38a..d28c7fcb4365 100644
--- a/editeng/CppunitTest_editeng_core.mk
+++ b/editeng/CppunitTest_editeng_core.mk
@@ -15,6 +15,7 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,editeng_core, \
 editeng/qa/unit/core-test \
 editeng/qa/unit/ESelectionTest \
 editeng/qa/unit/EPaMTest \
+editeng/qa/unit/EditLineTest \
 ))
 
 $(eval $(call gb_CppunitTest_use_library_objects,editeng_core,editeng))
diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx
index 2b6bc2a71efb..df1dec9f0ae2 100644
--- a/editeng/inc/EditLine.hxx
+++ b/editeng/inc/EditLine.hxx
@@ -29,22 +29,29 @@ public:
 private:
 CharPosArrayType aPositions;
 std::vector aKashidaPositions;
-sal_Int32 nTxtWidth;
-sal_Int32 nStartPosX;
-sal_Int32 nStart; // could be replaced by nStartPortion
-sal_Int32 nEnd; // could be replaced by nEndPortion
-sal_Int32 nStartPortion;
-sal_Int32 nEndPortion;
-sal_uInt16 nHeight; //  Total height of the line
-sal_uInt16 nTxtHeight; // Pure Text height
-sal_uInt16 nMaxAscent;
-bool bHangingPunctuation : 1;
-bool bInvalid : 1; // for skillful formatting
+sal_Int32 nTxtWidth = 0;
+sal_Int32 nStartPosX = 0;
+sal_Int32 nStart = 0; // could be replaced by nStartPortion
+sal_Int32 nEnd = 0; // could be replaced by nEndPortion
+sal_Int32 nStartPortion = 0;
+sal_Int32 nEndPortion = 0;
+sal_uInt16 nHeight = 0; //  Total height of the line
+sal_uInt16 nTxtHeight = 0; // Pure Text height
+sal_uInt16 nMaxAscent = 0;
+bool bHangingPunctuation : 1 = false;
+bool bInvalid : 1 = true; // for skillful formatting
 
 public:
-EditLine();
-EditLine(const EditLine&);
-~EditLine();
+EditLine() = default;
+EditLine(const EditLine& rEditLine)
+: nStart(rEditLine.nStart)
+, nEnd(rEditLine.nEnd)
+, nStartPortion(rEditLine.nStartPortion)
+, nEndPortion(rEditLine.nEndPortion)
+, bHangingPunctuation(rEditLine.bHangingPunctuation)
+, bInvalid(true)
+{
+}
 
 bool IsIn(sal_Int32 nIndex) const { return ((nIndex >= nStart) && (nIndex 
< nEnd)); }
 
@@ -103,8 +110,27 @@ public:
 
 EditLine* Clone() const;
 
-EditLine& operator=(const EditLine& rLine);
-friend bool operator==(const EditLine& r1, const EditLine& r2);
+EditLine& operator=(const EditLine& rLine)
+{
+nEnd = rLine.nEnd;
+nStart = rLine.nStart;
+nEndPortion = rLine.nEndPortion;
+nStartPortion = rLine.nStartPortion;
+return *this;
+}
+
+bool operator==(const EditLine& rLine) const
+{
+return nStart == rLine.nStart && nEnd == rLine.nEnd && nStartPortion 
== rLine.nStartPortion
+   && nEndPortion == rLine.nEndPortion;
+}
 };
 
+template 
+inline std::basic_ostream& operator<<(std::basic_ostream& stream,
+ EditLine const& rLine)
+{
+return stream << "EditLine(" << rLine.GetStart() << ", " << rLine.GetEnd() 
<< ")";
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/qa/unit/EditLineTest.cxx b/editeng/qa/unit/EditLineTest.cxx
new file mode 100644
index ..6991ba67755c
--- /dev/null
+++ b/editeng/qa/unit/EditLineTest.cxx
@@ -0,0 +1,111 @@
+/* -*- 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/.
+ */
+
+#include 
+#include 
+
+namespace
+{
+class EditLineTest : public test::BootstrapFixture
+{
+};
+
+CPPUNIT_TEST_FIXTURE(EditLineTest, testConstruction)
+{
+EditLine aNew;
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetStart());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetEnd());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetStartPortion());
+CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aNew.GetEndPortion());
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), aNew.GetMaxAscent());
+

core.git: editeng/inc

2023-12-29 Thread Tomaž Vajngerl (via logerrit)
 editeng/inc/EditLine.hxx |  110 +++
 editeng/inc/editdoc.hxx  |   92 ---
 2 files changed, 111 insertions(+), 91 deletions(-)

New commits:
commit 2ffe4a6580a17d178794fabeba6916c1ff4c744c
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 24 16:46:16 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sat Dec 30 03:09:49 2023 +0100

editeng: move EditLine in its own header file

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

diff --git a/editeng/inc/EditLine.hxx b/editeng/inc/EditLine.hxx
new file mode 100644
index ..2b6bc2a71efb
--- /dev/null
+++ b/editeng/inc/EditLine.hxx
@@ -0,0 +1,110 @@
+/* -*- 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
+
+class ParaPortion;
+
+class EditLine
+{
+public:
+typedef std::vector CharPosArrayType;
+
+private:
+CharPosArrayType aPositions;
+std::vector aKashidaPositions;
+sal_Int32 nTxtWidth;
+sal_Int32 nStartPosX;
+sal_Int32 nStart; // could be replaced by nStartPortion
+sal_Int32 nEnd; // could be replaced by nEndPortion
+sal_Int32 nStartPortion;
+sal_Int32 nEndPortion;
+sal_uInt16 nHeight; //  Total height of the line
+sal_uInt16 nTxtHeight; // Pure Text height
+sal_uInt16 nMaxAscent;
+bool bHangingPunctuation : 1;
+bool bInvalid : 1; // for skillful formatting
+
+public:
+EditLine();
+EditLine(const EditLine&);
+~EditLine();
+
+bool IsIn(sal_Int32 nIndex) const { return ((nIndex >= nStart) && (nIndex 
< nEnd)); }
+
+bool IsIn(sal_Int32 nIndex, bool bInclEnd) const
+{
+return ((nIndex >= nStart) && (bInclEnd ? (nIndex <= nEnd) : (nIndex < 
nEnd)));
+}
+
+void SetStart(sal_Int32 n) { nStart = n; }
+sal_Int32 GetStart() const { return nStart; }
+sal_Int32& GetStart() { return nStart; }
+
+void SetEnd(sal_Int32 n) { nEnd = n; }
+sal_Int32 GetEnd() const { return nEnd; }
+sal_Int32& GetEnd() { return nEnd; }
+
+void SetStartPortion(sal_Int32 n) { nStartPortion = n; }
+sal_Int32 GetStartPortion() const { return nStartPortion; }
+sal_Int32& GetStartPortion() { return nStartPortion; }
+
+void SetEndPortion(sal_Int32 n) { nEndPortion = n; }
+sal_Int32 GetEndPortion() const { return nEndPortion; }
+sal_Int32& GetEndPortion() { return nEndPortion; }
+
+void SetHeight(sal_uInt16 nH, sal_uInt16 nTxtH = 0);
+sal_uInt16 GetHeight() const { return nHeight; }
+sal_uInt16 GetTxtHeight() const { return nTxtHeight; }
+
+void SetTextWidth(sal_Int32 n) { nTxtWidth = n; }
+sal_Int32 GetTextWidth() const { return nTxtWidth; }
+
+void SetMaxAscent(sal_uInt16 n) { nMaxAscent = n; }
+sal_uInt16 GetMaxAscent() const { return nMaxAscent; }
+
+void SetHangingPunctuation(bool b) { bHangingPunctuation = b; }
+bool IsHangingPunctuation() const { return bHangingPunctuation; }
+
+sal_Int32 GetLen() const { return nEnd - nStart; }
+
+sal_Int32 GetStartPosX() const { return nStartPosX; }
+void SetStartPosX(sal_Int32 start);
+Size CalcTextSize(ParaPortion& rParaPortion);
+
+bool IsInvalid() const { return bInvalid; }
+bool IsValid() const { return !bInvalid; }
+void SetInvalid() { bInvalid = true; }
+void SetValid() { bInvalid = false; }
+
+bool IsEmpty() const { return nEnd <= nStart; }
+
+CharPosArrayType& GetCharPosArray() { return aPositions; }
+const CharPosArrayType& GetCharPosArray() const { return aPositions; }
+
+std::vector& GetKashidaArray() { return aKashidaPositions; }
+const std::vector& GetKashidaArray() const { return 
aKashidaPositions; }
+
+EditLine* Clone() const;
+
+EditLine& operator=(const EditLine& rLine);
+friend bool operator==(const EditLine& r1, const EditLine& r2);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 9840d1ff8337..c53abc62949c 100644
--- a/editeng/inc/editdoc.hxx
+++ 

core.git: 2 commits - editeng/inc editeng/Library_editeng.mk editeng/source solenv/clang-format

2023-12-29 Thread Tomaž Vajngerl (via logerrit)
 editeng/Library_editeng.mk |1 
 editeng/inc/ContentNode.hxx|9 
 editeng/source/editeng/ContentNode.cxx | 1000 +
 editeng/source/editeng/editdoc.cxx |  984 
 solenv/clang-format/excludelist|1 
 5 files changed, 1005 insertions(+), 990 deletions(-)

New commits:
commit 5c198a8d1345a5f658a46085de9cdd76d49a959e
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 24 16:37:58 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Dec 29 12:38:11 2023 +0100

editeng: simplify and remove unneded const. of ContentNode & co

ContentNode, CharAttribList, ContentAttribs constructors and
destructors can be simplified and in some cases removed (if they
are empty).

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

diff --git a/editeng/inc/ContentNode.hxx b/editeng/inc/ContentNode.hxx
index d89612ddeac8..391953d7f4ae 100644
--- a/editeng/inc/ContentNode.hxx
+++ b/editeng/inc/ContentNode.hxx
@@ -37,7 +37,7 @@ class SvxTabStop;
 class ContentAttribs
 {
 private:
-SfxStyleSheet* mpStyle;
+SfxStyleSheet* mpStyle = nullptr;
 SfxItemSetFixed maAttribSet;
 
 public:
@@ -68,12 +68,9 @@ public:
 private:
 AttribsType maAttribs;
 SvxFont maDefFont; // faster than ever from the pool!
-bool mbHasEmptyAttribs;
+bool mbHasEmptyAttribs = false;
 
 public:
-CharAttribList();
-~CharAttribList();
-
 void dumpAsXml(xmlTextWriterPtr pWriter) const;
 
 void DeleteEmptyAttribs();
@@ -122,7 +119,7 @@ private:
 public:
 ContentNode(SfxItemPool& rItemPool);
 ContentNode(const OUString& rStr, const ContentAttribs& rContentAttribs);
-~ContentNode();
+
 ContentNode(const ContentNode&) = delete;
 ContentNode& operator=(const ContentNode&) = delete;
 
diff --git a/editeng/source/editeng/ContentNode.cxx 
b/editeng/source/editeng/ContentNode.cxx
index 16d6a1ed808b..0cc3a72da65c 100644
--- a/editeng/source/editeng/ContentNode.cxx
+++ b/editeng/source/editeng/ContentNode.cxx
@@ -40,10 +40,6 @@ ContentNode::ContentNode( const OUString& rStr, const 
ContentAttribs& rContentAt
 {
 }
 
-ContentNode::~ContentNode()
-{
-}
-
 void ContentNode::ExpandAttribs( sal_Int32 nIndex, sal_Int32 nNew )
 {
 if ( !nNew )
@@ -653,12 +649,10 @@ void ContentNode::checkAndDeleteEmptyAttribs() const
 }
 
 ContentAttribs::ContentAttribs( SfxItemPool& rPool )
-: mpStyle(nullptr)
-, maAttribSet( rPool )
+: maAttribSet(rPool)
 {
 }
 
-
 SvxTabStop ContentAttribs::FindTabStop( sal_Int32 nCurPos, sal_uInt16 nDefTab )
 {
 const SvxTabStopItem& rTabs = GetItem( EE_PARA_TABS );
@@ -741,15 +735,6 @@ struct LessByStart
 
 }
 
-CharAttribList::CharAttribList()
-: mbHasEmptyAttribs(false)
-{
-}
-
-CharAttribList::~CharAttribList()
-{
-}
-
 void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib )
 {
 // !
commit 62aee46df1f8e4b863e2927e0b9d3b6bcd270008
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 24 16:33:46 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Dec 29 12:38:04 2023 +0100

editeng: move source of ContentNode & co. to own sourcefile

Move ContentNode, CharAttribList, ContentAttribs methods to own
source class.

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

diff --git a/editeng/Library_editeng.mk b/editeng/Library_editeng.mk
index 7f7f3581b62f..e0834b96f983 100644
--- a/editeng/Library_editeng.mk
+++ b/editeng/Library_editeng.mk
@@ -50,6 +50,7 @@ $(eval $(call gb_Library_add_exception_objects,editeng,\
 endif
 
 $(eval $(call gb_Library_add_exception_objects,editeng,\
+editeng/source/editeng/ContentNode \
 editeng/source/editeng/editattr \
 editeng/source/editeng/editdata \
 editeng/source/editeng/editdbg \
diff --git a/editeng/source/editeng/ContentNode.cxx 
b/editeng/source/editeng/ContentNode.cxx
new file mode 100644
index ..16d6a1ed808b
--- /dev/null
+++ b/editeng/source/editeng/ContentNode.cxx
@@ -0,0 +1,1015 @@
+/* -*- 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 

  1   2   3   4   5   6   7   8   9   10   >