[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - sc/inc sc/qa sc/source test/source

2023-04-12 Thread Balazs Varga (via logerrit)
 sc/inc/drwlayer.hxx |1 
 sc/inc/table.hxx|2 
 sc/qa/unit/filters-test.cxx |   16 
 sc/qa/unit/scshapetest.cxx  |2 
 sc/qa/unit/ucalc.cxx|   10 
 sc/source/core/data/drwlayer.cxx|  333 +---
 sc/source/core/data/table5.cxx  |3 
 sc/source/filter/xml/xmlexprt.cxx   |4 
 sc/source/filter/xml/xmlimprt.cxx   |   32 -
 sc/source/filter/xml/xmlimprt.hxx   |3 
 test/source/sheet/xsheetannotationshapesupplier.cxx |2 
 11 files changed, 108 insertions(+), 300 deletions(-)

New commits:
commit 9cb9c54748ec586695780778b3f4d94cf74392ad
Author: Balazs Varga 
AuthorDate: Tue Apr 11 20:38:15 2023 +0200
Commit: Balazs Varga 
CommitDate: Wed Apr 12 12:37:32 2023 +0200

Revert "Improve 'resize with cell' handling"

This reverts commit f43ac75e8e3d8520aef8a5baeda4543bdae44b10.

Except adding GetObjectsAnchoredToCols to drwlayer.hxx
and using ScTable::SetRowHidden and ScTable::SetColHidden
modifications from the original commit.

Change-Id: I1fcc724ed49ca0d2faedaae02009ec006106672f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150267
Tested-by: Balazs Varga 
Reviewed-by: Balazs Varga 

diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index dd6e875bdcb9..7327affb7a81 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -136,7 +136,6 @@ public:
 
 voidMoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL 
nCol2,SCROW nRow2,
 SCCOL nDx,SCROW nDy, bool bInsDel, bool 
bUpdateNoteCaptionPos );
-void InitializeCellAnchoredObj(SdrObject* pObj, ScDrawObjData& rData);
 voidRecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool 
bNegativePage, bool bUpdateNoteCaptionPos );
 
 boolHasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW 
nEndRow );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e1e21588278d..96702d1213e0 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -77,7 +77,7 @@ class RowHeightContext;
 class CompileFormulaContext;
 struct SetFormulaDirtyContext;
 class ColumnIterator;
-class ScDrawObjData;
+
 }
 
 class SfxItemSet;
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index 6733cb5d80d3..33887536e681 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -557,8 +557,11 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
 ScDocShellRef xDocSh = 
loadDoc("legacycellanchoredrotatedhiddenshape.", FORMAT_ODS, true);
 ScDocument& rDoc = xDocSh->GetDocument();
 // ensure the imported legacy rotated shape is in the expected position
-tools::Rectangle aRect( 6000, -2000, 8000, 4000 );
-
+// when a shape is fully hidden reloading seems to result is in some 
errors, usually
+// ( same but different error happens pre-patch ) - we should do 
better here, I regard it
+// as a pre-existing bug though (#FIXME)
+//Rectangle aRect( 6000, -2000, 8000, 4000 ); // proper dimensions
+tools::Rectangle aRect( 6000, -2000, 7430, 4000 );
 // ensure the imported (and converted) anchor (note we internally now 
store the anchor in
 // terms of the rotated shape) is more or less contains the correct 
info
 ScDrawObjData aAnchor;
@@ -568,11 +571,10 @@ void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
 aAnchor.maEnd.SetCol( 7 );
 rDoc.ShowRows(0, 9, 0, true); // show relevant rows
 rDoc.SetDrawPageSize(0); // trigger recalcpos
-impl_testLegacyCellAnchoredRotatedShape( rDoc, aRect, aAnchor);
-// test save and reload
-xDocSh = saveAndReload( &(*xDocSh), FORMAT_ODS);
-ScDocument& rDoc2 = xDocSh->GetDocument();
-impl_testLegacyCellAnchoredRotatedShape( rDoc2, aRect, aAnchor );
+
+// apply hefty (1 mm) tolerance here, as some opensuse tinderbox
+// failing
+impl_testLegacyCellAnchoredRotatedShape( rDoc, aRect, aAnchor, 100 );
 
 xDocSh->DoClose();
 }
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 7f2d762bc34d..8e3cbe2c7802 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -151,7 +151,7 @@ void ScShapeTest::testCustomShapeCellAnchoredRotatedShape()
 CPPUNIT_ASSERT(pObj);
 
 // Check Position and Size
-tools::Rectangle aRect(2400, 751, 5772, 3693); // expected snap rect
+tools::Rectangle aRect(2406, 754, 5774, 3692); // expected snap rect
 rDoc.SetDrawPageSize(0); // trigger recalcpos
 const tools::Rectangle& rShapeRect(pObj->GetSnapRect());
 const OUString sPosSizeErrors(lcl_compareRectWithTolerance(aRect, 
rShapeRect, 1));
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
ind

[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - sc/inc sc/qa sc/source

2023-04-12 Thread Balazs Varga (via logerrit)
 dev/null |binary
 sc/inc/document.hxx  |1 
 sc/inc/table.hxx |1 
 sc/qa/unit/scshapetest.cxx   |   47 ---
 sc/source/core/data/document.cxx |8 --
 sc/source/core/data/drwlayer.cxx |   16 +
 sc/source/core/data/table5.cxx   |   22 --
 7 files changed, 2 insertions(+), 93 deletions(-)

New commits:
commit bac8f52748e43a9aa5b19b4010efbadf975c4748
Author: Balazs Varga 
AuthorDate: Tue Apr 11 20:24:43 2023 +0200
Commit: Balazs Varga 
CommitDate: Wed Apr 12 12:36:47 2023 +0200

Revert "tdf#154005 sc ods fileopen: fix dropdown form control size"

This reverts commit 1d9c9ebd552b9394a025fbb9e692451ba9d3460c.

Change-Id: I62f4f13d963df698d84e9d8c908f22c942682834
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150266
Tested-by: Balazs Varga 
Reviewed-by: Balazs Varga 

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 03a4345ead15..4cc98b01096e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1919,7 +1919,6 @@ public:
 SC_DLLPUBLIC SCROW  FirstVisibleRow(SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab) const;
 SC_DLLPUBLIC SCROW  LastVisibleRow(SCROW nStartRow, SCROW nEndRow, 
SCTAB nTab) const;
 SCROW   CountVisibleRows(SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab) const;
-SCCOL   CountVisibleCols(SCROW nStartCol, SCROW 
nEndCol, SCTAB nTab) const;
 
 boolRowFiltered(SCROW nRow, SCTAB nTab, SCROW* 
pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
 boolHasFilteredRows(SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index cc90bd31b980..e1e21588278d 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -905,7 +905,6 @@ public:
 SCROW   FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
 SCROW   LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
 SCROW   CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
-SCCOL   CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const;
 sal_uInt32  GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero = true) const;
 
 SCCOLROWLastHiddenColRow(SCCOLROW nPos, bool bCol) const;
diff --git a/sc/qa/unit/data/ods/tdf154005.ods 
b/sc/qa/unit/data/ods/tdf154005.ods
deleted file mode 100644
index 1b52a4dba556..
Binary files a/sc/qa/unit/data/ods/tdf154005.ods and /dev/null differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 55a2b0a8537c..7f2d762bc34d 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
@@ -34,12 +33,10 @@ public:
 
 void testFitToCellSize();
 void testCustomShapeCellAnchoredRotatedShape();
-void testFormSizeWithHiddenCol();
 
 CPPUNIT_TEST_SUITE(ScShapeTest);
 CPPUNIT_TEST(testFitToCellSize);
 CPPUNIT_TEST(testCustomShapeCellAnchoredRotatedShape);
-CPPUNIT_TEST(testFormSizeWithHiddenCol);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -174,50 +171,6 @@ void ScShapeTest::testCustomShapeCellAnchoredRotatedShape()
 pDocSh->DoClose();
 }
 
-void ScShapeTest::testFormSizeWithHiddenCol()
-{
-// The document contains a form (Listbox) shape anchored "To Cell (resize 
with cell)" with starts in cell B5 and
-// ends in cell D5. The error was the form shape was resized if there was 
hidden col/row.
-OUString aFileURL;
-createFileURL("tdf154005.ods", aFileURL);
-uno::Reference xComponent = 
loadFromDesktop(aFileURL);
-CPPUNIT_ASSERT(xComponent.is());
-
-// Get the document model
-SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
-CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
-
-ScDocShell* pDocSh = dynamic_cast(pFoundShell);
-CPPUNIT_ASSERT(pDocSh);
-
-// Get the shape
-ScDocument& rDoc = pDocSh->GetDocument();
-ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
-CPPUNIT_ASSERT(pDrawLayer);
-
-const SdrPage* pPage = pDrawLayer->GetPage(0);
-CPPUNIT_ASSERT(pPage);
-
-SdrUnoObj* pObj = dynamic_cast(pPage->GetObj(0));
-CPPUNIT_ASSERT(pObj);
-
-// Check Position and Size
-rDoc.SetDrawPageSize(0); // trigger recalcpos
-tools::Rectangle aRect(2432, 3981, 4932, 4631); // expected snap rect from 
values in file
-const tools::Rectangle& rShapeRect(pObj->GetSnapRect());
-const OUString sPosSizeErrors(lcl_compareRectWithTolerance(aRect, 
rShapeRect, 1));
-CPPUNIT_ASSERT_EQUAL(OUString(), sPosSizeErrors);
-
-// Check anchor
-ScDrawObjData* pData = ScDrawLayer::GetObjData(pObj);
-CPPUNIT_ASSERT_MESSAGE("expected object meta data", pData);
-const OUString sActual("start col " + 
OUString::number(pData->maSt

[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - sc/inc sc/qa sc/source

2023-03-15 Thread Balazs Varga (via logerrit)
 sc/inc/document.hxx   |1 
 sc/inc/table.hxx  |1 
 sc/qa/unit/data/ods/tdf154005.ods |binary
 sc/qa/unit/scshapetest.cxx|   47 ++
 sc/source/core/data/document.cxx  |8 ++
 sc/source/core/data/drwlayer.cxx  |   16 +++-
 sc/source/core/data/table5.cxx|   22 +
 7 files changed, 93 insertions(+), 2 deletions(-)

New commits:
commit 1d9c9ebd552b9394a025fbb9e692451ba9d3460c
Author: Balazs Varga 
AuthorDate: Sun Mar 12 17:49:53 2023 +0100
Commit: Thorsten Behrens 
CommitDate: Thu Mar 16 01:51:29 2023 +

tdf#154005 sc ods fileopen: fix dropdown form control size

Dropdown form control size was increased by the size of hidden
rows or columns.

Regression from commit: 1f0b3c7a40edfa81bbc7a58d123a6a2dfd83e4ca
(Improve 'resize with cell' handling)

Change-Id: Ic903a488cab22286f95cfdf4ee559013fd7bfa02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148738
Tested-by: Thorsten Behrens 
Reviewed-by: Thorsten Behrens 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148874

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 4cc98b01096e..03a4345ead15 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1919,6 +1919,7 @@ public:
 SC_DLLPUBLIC SCROW  FirstVisibleRow(SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab) const;
 SC_DLLPUBLIC SCROW  LastVisibleRow(SCROW nStartRow, SCROW nEndRow, 
SCTAB nTab) const;
 SCROW   CountVisibleRows(SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab) const;
+SCCOL   CountVisibleCols(SCROW nStartCol, SCROW 
nEndCol, SCTAB nTab) const;
 
 boolRowFiltered(SCROW nRow, SCTAB nTab, SCROW* 
pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
 boolHasFilteredRows(SCROW nStartRow, SCROW 
nEndRow, SCTAB nTab) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e1e21588278d..cc90bd31b980 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -905,6 +905,7 @@ public:
 SCROW   FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
 SCROW   LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const;
 SCROW   CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const;
+SCCOL   CountVisibleCols(SCCOL nStartCol, SCCOL nEndCol) const;
 sal_uInt32  GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow, bool 
bHiddenAsZero = true) const;
 
 SCCOLROWLastHiddenColRow(SCCOLROW nPos, bool bCol) const;
diff --git a/sc/qa/unit/data/ods/tdf154005.ods 
b/sc/qa/unit/data/ods/tdf154005.ods
new file mode 100644
index ..1b52a4dba556
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf154005.ods differ
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index 7f2d762bc34d..55a2b0a8537c 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -33,10 +34,12 @@ public:
 
 void testFitToCellSize();
 void testCustomShapeCellAnchoredRotatedShape();
+void testFormSizeWithHiddenCol();
 
 CPPUNIT_TEST_SUITE(ScShapeTest);
 CPPUNIT_TEST(testFitToCellSize);
 CPPUNIT_TEST(testCustomShapeCellAnchoredRotatedShape);
+CPPUNIT_TEST(testFormSizeWithHiddenCol);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -171,6 +174,50 @@ void ScShapeTest::testCustomShapeCellAnchoredRotatedShape()
 pDocSh->DoClose();
 }
 
+void ScShapeTest::testFormSizeWithHiddenCol()
+{
+// The document contains a form (Listbox) shape anchored "To Cell (resize 
with cell)" with starts in cell B5 and
+// ends in cell D5. The error was the form shape was resized if there was 
hidden col/row.
+OUString aFileURL;
+createFileURL("tdf154005.ods", aFileURL);
+uno::Reference xComponent = 
loadFromDesktop(aFileURL);
+CPPUNIT_ASSERT(xComponent.is());
+
+// Get the document model
+SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
+CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
+
+ScDocShell* pDocSh = dynamic_cast(pFoundShell);
+CPPUNIT_ASSERT(pDocSh);
+
+// Get the shape
+ScDocument& rDoc = pDocSh->GetDocument();
+ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+CPPUNIT_ASSERT(pDrawLayer);
+
+const SdrPage* pPage = pDrawLayer->GetPage(0);
+CPPUNIT_ASSERT(pPage);
+
+SdrUnoObj* pObj = dynamic_cast(pPage->GetObj(0));
+CPPUNIT_ASSERT(pObj);
+
+// Check Position and Size
+rDoc.SetDrawPageSize(0); // trigger recalcpos
+tools::Rectangle aRect(2432, 3981, 4932, 4631); // expected snap rect from 
values in file
+const tools::Rectangle& rShapeRect(pObj->GetSnapRect());
+const OUString sPosSizeErrors(lcl_compareRectWithTolerance(aRect, 
rShapeRect, 1));
+CPPUNIT_ASSERT_EQUAL(OUString(), sPosSizeErrors);
+
+// Chec

[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-4' - sc/inc sc/qa sc/source test/source

2022-11-30 Thread Regina Henschel (via logerrit)
 sc/inc/drwlayer.hxx |2 
 sc/inc/table.hxx|2 
 sc/qa/unit/filters-test.cxx |   16 
 sc/qa/unit/scshapetest.cxx  |2 
 sc/qa/unit/ucalc.cxx|   10 
 sc/source/core/data/drwlayer.cxx|  357 +++-
 sc/source/core/data/table5.cxx  |   41 ++
 sc/source/filter/xml/xmlexprt.cxx   |4 
 sc/source/filter/xml/xmlimprt.cxx   |   32 +
 sc/source/filter/xml/xmlimprt.hxx   |3 
 test/source/sheet/xsheetannotationshapesupplier.cxx |2 
 11 files changed, 361 insertions(+), 110 deletions(-)

New commits:
commit f43ac75e8e3d8520aef8a5baeda4543bdae44b10
Author: Regina Henschel 
AuthorDate: Sat Oct 10 17:55:31 2020 +0200
Commit: Balazs Varga 
CommitDate: Wed Nov 30 09:53:03 2022 +0100

Improve 'resize with cell' handling

The patch contains a larger rework of RecalcPos and connected areas
and covers several bugs. Essentials in short:
Move initialization from RecalcPos to own method and use it in
ScXMLImport::endDocument
Do not change hidden objects, which includes not setting width or
height to zero, and be consistent in using object visibility.
Special handling of vertical flipped customshapes.
Repair anchor on import of line and measure line.
ODF conformance: Create logical rectangle from anchor instead using
size.

Details:
tdf#137044
ScDrawLayer::SetPageSize is called several times while loading a
document. It includes a call to ScDrawLayer::RecalcPos for all cell
anchored objects. An object gets initialized with the first call.
Problem was, that the row heights were not finished at that time and
anchor cells and offsets were partly calculated based on default cell
height. That results in wrong height and offset of objects.
The solution separates initialization from RecalcPos and puts it into
an own method ScDrawLayer::InitializeCellAnchoredObj. This is then
called from ScXMLImport::endDocument when row height settings are
finished.
The call to RecalcPos is not totally removed from SetPageSize but only
excluded while loading, because it is needed for size changes after
the document is loaded.

tdf#137576 partly
For measure lines and ordinary lines, which were anchored 'To cell
(resize with cell)', LibreOffice has written wrong end-cell info to
file. So reopening results in wrong lines. The geometry of lines is
based on two points. Fortunatelly the combination of position of the
cell, which contains the shape, and start and end points gives correct
absolute position of these points.
Solution is, to regenerate the initial ScDrawObjData infos from these
points and do not use the stored end-cell info. For a total fix
implementation of NbcSetSnapRect for SdrMeasureObj is needed, which is
not included here.

tdf#137020
Cell anchored shapes are contained in a cell in file. To determine
size and position of the shape a rectangle is used, so defined, that
after applying transformation you get the desired shape. In case of
custom shapes, a vertical flip is not contained in the transformation
but it is an attribute inside the shape and flip is done at the shape
center and will not change the rectangle.
This rectangle determines start and end addresses and offsets in
ScDrawObjData in rNoRotatedAnchor. The info is used directly in XML
export. It is correctly build while loading the file.
But in case of vertical flipped custom shapes the logical rectangle
of the shape has an additional 180deg rotation. Changing that behavior
is currently out of scope. Therefore special handling of vertical
flipped custom shapes was added.

tdf#99549
ODF specifies that in case of existence of end-cell attribute, size
attributes have to be ignored. But LO has based the logical rectangle
on size. In addition it has written zero width and height in case of
hidden row and cols. Result was, that objects are 'lost' on opening
although they still exists in the file.
With the patch the object size is recalculated from anchor on opening.

tdf#137355, tdf#137044, tdf#115655
The old solution has recalculated the snap rectangle based on current
state of hidden row or column. That has produced shapes of zero width
or height and loss of offset in case start or end cell of the shape
was hidden. In running LO it was partly offset by using cached infos
in ScDrawObjData. That failed in case of save and reload.
Solution is, to only change visible shapes. It is enough to adapt the
shape when it becomes visible. That is introduced in RecalcPos and
SetCellAnchoredFromPosition.

tdf#137216
Shapes anchored