diff options
author | Jonathan Clark <jonathan@libreoffice.org> | 2025-01-14 11:26:56 -0700 |
---|---|---|
committer | Jonathan Clark <jonathan@libreoffice.org> | 2025-01-15 15:06:11 +0100 |
commit | bf54efbe21d6c6fcb910f7fa3d9f43978dc555c9 (patch) | |
tree | 281a71dc259e6fe92a447fb3a5c1f88046d9f474 /svx | |
parent | 4d5b3e99911acb3085dba5d66627b5737c885d85 (diff) |
tdf#34837 sc: Use border from correct cell for merged cells in RTL
This change fixes a bug causing borders to fail to render for merged
cells in RTL spreadsheets.
The root cause for this bug was framelinkarray utility code using the
top-left cell as the source for border styles of merged cells. This use
was correct for LTR spreadsheets. However, this framelinkarray data is
mirrored for RTL documents. After mirroring, the correct cell containing
border styles is the top-right one.
This change also reverts and reimplements a prior fix for tdf#135843
(commit 586a0f149f332c0b0e53c0bb30568d4bd411b0e3), which violated the
framelinkarray contract that edge styles for merged cells must be added
to the top-left underlying cell of a merged cell.
Change-Id: I27eec416d54f9f99cd5df1151a12c758f350c789
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180256
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/CppunitTest_svx_unit.mk | 1 | ||||
-rw-r--r-- | svx/qa/unit/framelinkarray.cxx | 196 | ||||
-rw-r--r-- | svx/source/dialog/framelinkarray.cxx | 45 | ||||
-rw-r--r-- | svx/source/table/viewcontactoftableobj.cxx | 24 |
4 files changed, 242 insertions, 24 deletions
diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk index 95c76b2d0733..0cad5af02c26 100644 --- a/svx/CppunitTest_svx_unit.mk +++ b/svx/CppunitTest_svx_unit.mk @@ -26,6 +26,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \ svx/qa/unit/svdraw/test_SdrTextObject \ svx/qa/unit/customshapes \ svx/qa/unit/classicshapes \ + svx/qa/unit/framelinkarray \ svx/qa/unit/gluepointTest \ svx/qa/unit/sdr \ svx/qa/unit/svdraw \ diff --git a/svx/qa/unit/framelinkarray.cxx b/svx/qa/unit/framelinkarray.cxx new file mode 100644 index 000000000000..f94077a702b1 --- /dev/null +++ b/svx/qa/unit/framelinkarray.cxx @@ -0,0 +1,196 @@ +/* -*- 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 <test/unoapi_test.hxx> + +#include <svx/framelinkarray.hxx> +#include <svx/framelink.hxx> + +using namespace com::sun::star; + +class FrameLinkArrayTest : public UnoApiTest +{ +public: + FrameLinkArrayTest() + : UnoApiTest(u"svx/qa/unit/data/"_ustr) + { + } +}; + +CPPUNIT_TEST_FIXTURE(FrameLinkArrayTest, testSingleCell) +{ + svx::frame::Array stArr; + stArr.Initialize(10, 10); + + stArr.SetCellStyleLeft(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::ENGRAVED, 1.0 }); + stArr.SetCellStyleRight(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOTTED, 1.0 }); + stArr.SetCellStyleTop(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DASHED, 1.0 }); + stArr.SetCellStyleBottom(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOUBLE, 1.0 }); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED, stArr.GetCellStyleLeft(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED, stArr.GetCellStyleRight(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED, stArr.GetCellStyleTop(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, stArr.GetCellStyleBottom(2, 4).Type()); +} + +CPPUNIT_TEST_FIXTURE(FrameLinkArrayTest, testSingleCellRtl) +{ + svx::frame::Array stArr; + stArr.Initialize(10, 10); + + stArr.SetCellStyleLeft(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::ENGRAVED, 1.0 }); + stArr.SetCellStyleRight(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOTTED, 1.0 }); + stArr.SetCellStyleTop(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DASHED, 1.0 }); + stArr.SetCellStyleBottom(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOUBLE, 1.0 }); + + stArr.MirrorSelfX(); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(2, 4).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED, stArr.GetCellStyleLeft(7, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED, stArr.GetCellStyleRight(7, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED, stArr.GetCellStyleTop(7, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, stArr.GetCellStyleBottom(7, 4).Type()); +} + +CPPUNIT_TEST_FIXTURE(FrameLinkArrayTest, testMergedCell) +{ + svx::frame::Array stArr; + stArr.Initialize(10, 10); + + stArr.SetCellStyleLeft(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::ENGRAVED, 1.0 }); + stArr.SetCellStyleRight(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOTTED, 1.0 }); + stArr.SetCellStyleTop(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DASHED, 1.0 }); + stArr.SetCellStyleBottom(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOUBLE, 1.0 }); + stArr.SetMergedRange(/*first col*/ 2, /*first row*/ 4, /*last col*/ 4, /*last row*/ 6); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED, stArr.GetCellStyleLeft(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED, stArr.GetCellStyleTop(2, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(2, 4).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(3, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(3, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED, stArr.GetCellStyleTop(3, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(3, 4).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(4, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED, stArr.GetCellStyleRight(4, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED, stArr.GetCellStyleTop(4, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(4, 4).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED, stArr.GetCellStyleLeft(2, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(2, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(2, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(2, 5).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(3, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(3, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(3, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(3, 5).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(4, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED, stArr.GetCellStyleRight(4, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(4, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(4, 5).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED, stArr.GetCellStyleLeft(2, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(2, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(2, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, stArr.GetCellStyleBottom(2, 6).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(3, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(3, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(3, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, stArr.GetCellStyleBottom(3, 6).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(4, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED, stArr.GetCellStyleRight(4, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(4, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, stArr.GetCellStyleBottom(4, 6).Type()); +} + +CPPUNIT_TEST_FIXTURE(FrameLinkArrayTest, testMergedCellRtl) +{ + svx::frame::Array stArr; + stArr.Initialize(10, 10); + + stArr.SetCellStyleLeft(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::ENGRAVED, 1.0 }); + stArr.SetCellStyleRight(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOTTED, 1.0 }); + stArr.SetCellStyleTop(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DASHED, 1.0 }); + stArr.SetCellStyleBottom(/*col*/ 2, /*row*/ 4, + svx::frame::Style{ 1.0, 1.0, 1.0, SvxBorderLineStyle::DOUBLE, 1.0 }); + stArr.SetMergedRange(/*first col*/ 2, /*first row*/ 4, /*last col*/ 4, /*last row*/ 6); + stArr.MirrorSelfX(); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED, stArr.GetCellStyleLeft(5, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(5, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED, stArr.GetCellStyleTop(5, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(5, 4).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(6, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(6, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED, stArr.GetCellStyleTop(6, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(6, 4).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(7, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED, stArr.GetCellStyleRight(7, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DASHED, stArr.GetCellStyleTop(7, 4).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(7, 4).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED, stArr.GetCellStyleLeft(5, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(5, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(5, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(5, 5).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(6, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(6, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(6, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(6, 5).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(7, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED, stArr.GetCellStyleRight(7, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(7, 5).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleBottom(7, 5).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOTTED, stArr.GetCellStyleLeft(5, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(5, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(5, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, stArr.GetCellStyleBottom(5, 6).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(6, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleRight(6, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(6, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, stArr.GetCellStyleBottom(6, 6).Type()); + + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleLeft(7, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::ENGRAVED, stArr.GetCellStyleRight(7, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::SOLID, stArr.GetCellStyleTop(7, 6).Type()); + CPPUNIT_ASSERT_EQUAL(SvxBorderLineStyle::DOUBLE, stArr.GetCellStyleBottom(7, 6).Type()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/framelinkarray.cxx b/svx/source/dialog/framelinkarray.cxx index 02332d5e6de8..e1b420762f3b 100644 --- a/svx/source/dialog/framelinkarray.cxx +++ b/svx/source/dialog/framelinkarray.cxx @@ -317,6 +317,7 @@ struct ArrayImpl mutable bool mbXCoordsDirty; mutable bool mbYCoordsDirty; bool mbMayHaveCellRotation; + bool mbXMirrored = false; explicit ArrayImpl( sal_Int32 nWidth, sal_Int32 nHeight ); ~ArrayImpl(); @@ -334,8 +335,7 @@ struct ArrayImpl sal_Int32 GetMergedLastCol( sal_Int32 nCol, sal_Int32 nRow ) const; sal_Int32 GetMergedLastRow( sal_Int32 nCol, sal_Int32 nRow ) const; - const Cell* GetMergedOriginCell( sal_Int32 nCol, sal_Int32 nRow ) const; - const Cell* GetMergedLastCell( sal_Int32 nCol, sal_Int32 nRow ) const; + const Cell* GetMergedStyleSourceCell(sal_Int32 nCol, sal_Int32 nRow) const; bool IsMergedOverlappedLeft( sal_Int32 nCol, sal_Int32 nRow ) const; bool IsMergedOverlappedRight( sal_Int32 nCol, sal_Int32 nRow ) const; @@ -454,14 +454,14 @@ sal_Int32 ArrayImpl::GetMergedLastRow( sal_Int32 nCol, sal_Int32 nRow ) const return nLastRow - 1; } -const Cell* ArrayImpl::GetMergedOriginCell( sal_Int32 nCol, sal_Int32 nRow ) const +const Cell* ArrayImpl::GetMergedStyleSourceCell(sal_Int32 nCol, sal_Int32 nRow) const { - return GetCell( GetMergedFirstCol( nCol, nRow ), GetMergedFirstRow( nCol, nRow ) ); -} + if (mbXMirrored) + { + return GetCell(GetMergedLastCol(nCol, nRow), GetMergedFirstRow(nCol, nRow)); + } -const Cell* ArrayImpl::GetMergedLastCell( sal_Int32 nCol, sal_Int32 nRow ) const -{ - return GetCell( GetMergedLastCol( nCol, nRow ), GetMergedLastRow( nCol, nRow ) ); + return GetCell(GetMergedFirstCol(nCol, nRow), GetMergedFirstRow(nCol, nRow)); } bool ArrayImpl::IsMergedOverlappedLeft( sal_Int32 nCol, sal_Int32 nRow ) const @@ -783,15 +783,16 @@ const Style& Array::GetCellStyleLeft( sal_Int32 nCol, sal_Int32 nRow ) const return OBJ_STYLE_NONE; // left clipping border: always own left style if( nCol == mxImpl->mnFirstClipCol ) - return mxImpl->GetMergedOriginCell( nCol, nRow )->GetStyleLeft(); + return mxImpl->GetMergedStyleSourceCell(nCol, nRow)->GetStyleLeft(); // right clipping border: always right style of left neighbor cell if( nCol == mxImpl->mnLastClipCol + 1 ) - return mxImpl->GetMergedOriginCell( nCol - 1, nRow )->GetStyleRight(); + return mxImpl->GetMergedStyleSourceCell(nCol - 1, nRow)->GetStyleRight(); // outside clipping columns: invisible if( !mxImpl->IsColInClipRange( nCol ) ) return OBJ_STYLE_NONE; // inside clipping range: maximum of own left style and right style of left neighbor cell - return std::max( mxImpl->GetMergedOriginCell( nCol, nRow )->GetStyleLeft(), mxImpl->GetMergedOriginCell( nCol - 1, nRow )->GetStyleRight() ); + return std::max(mxImpl->GetMergedStyleSourceCell(nCol, nRow)->GetStyleLeft(), + mxImpl->GetMergedStyleSourceCell(nCol - 1, nRow)->GetStyleRight()); } const Style& Array::GetCellStyleRight( sal_Int32 nCol, sal_Int32 nRow ) const @@ -801,15 +802,16 @@ const Style& Array::GetCellStyleRight( sal_Int32 nCol, sal_Int32 nRow ) const return OBJ_STYLE_NONE; // left clipping border: always left style of right neighbor cell if( nCol + 1 == mxImpl->mnFirstClipCol ) - return mxImpl->GetMergedOriginCell( nCol + 1, nRow )->GetStyleLeft(); + return mxImpl->GetMergedStyleSourceCell(nCol + 1, nRow)->GetStyleLeft(); // right clipping border: always own right style if( nCol == mxImpl->mnLastClipCol ) - return mxImpl->GetMergedLastCell( nCol, nRow )->GetStyleRight(); + return mxImpl->GetMergedStyleSourceCell(nCol, nRow)->GetStyleRight(); // outside clipping columns: invisible if( !mxImpl->IsColInClipRange( nCol ) ) return OBJ_STYLE_NONE; // inside clipping range: maximum of own right style and left style of right neighbor cell - return std::max( mxImpl->GetMergedOriginCell( nCol, nRow )->GetStyleRight(), mxImpl->GetMergedOriginCell( nCol + 1, nRow )->GetStyleLeft() ); + return std::max(mxImpl->GetMergedStyleSourceCell(nCol, nRow)->GetStyleRight(), + mxImpl->GetMergedStyleSourceCell(nCol + 1, nRow)->GetStyleLeft()); } const Style& Array::GetCellStyleTop( sal_Int32 nCol, sal_Int32 nRow ) const @@ -819,15 +821,16 @@ const Style& Array::GetCellStyleTop( sal_Int32 nCol, sal_Int32 nRow ) const return OBJ_STYLE_NONE; // top clipping border: always own top style if( nRow == mxImpl->mnFirstClipRow ) - return mxImpl->GetMergedOriginCell( nCol, nRow )->GetStyleTop(); + return mxImpl->GetMergedStyleSourceCell(nCol, nRow)->GetStyleTop(); // bottom clipping border: always bottom style of top neighbor cell if( nRow == mxImpl->mnLastClipRow + 1 ) - return mxImpl->GetMergedOriginCell( nCol, nRow - 1 )->GetStyleBottom(); + return mxImpl->GetMergedStyleSourceCell(nCol, nRow - 1)->GetStyleBottom(); // outside clipping rows: invisible if( !mxImpl->IsRowInClipRange( nRow ) ) return OBJ_STYLE_NONE; // inside clipping range: maximum of own top style and bottom style of top neighbor cell - return std::max( mxImpl->GetMergedOriginCell( nCol, nRow )->GetStyleTop(), mxImpl->GetMergedOriginCell( nCol, nRow - 1 )->GetStyleBottom() ); + return std::max(mxImpl->GetMergedStyleSourceCell(nCol, nRow)->GetStyleTop(), + mxImpl->GetMergedStyleSourceCell(nCol, nRow - 1)->GetStyleBottom()); } const Style& Array::GetCellStyleBottom( sal_Int32 nCol, sal_Int32 nRow ) const @@ -837,15 +840,16 @@ const Style& Array::GetCellStyleBottom( sal_Int32 nCol, sal_Int32 nRow ) const return OBJ_STYLE_NONE; // top clipping border: always top style of bottom neighbor cell if( nRow + 1 == mxImpl->mnFirstClipRow ) - return mxImpl->GetMergedOriginCell( nCol, nRow + 1 )->GetStyleTop(); + return mxImpl->GetMergedStyleSourceCell(nCol, nRow + 1)->GetStyleTop(); // bottom clipping border: always own bottom style if( nRow == mxImpl->mnLastClipRow ) - return mxImpl->GetMergedLastCell( nCol, nRow )->GetStyleBottom(); + return mxImpl->GetMergedStyleSourceCell(nCol, nRow)->GetStyleBottom(); // outside clipping rows: invisible if( !mxImpl->IsRowInClipRange( nRow ) ) return OBJ_STYLE_NONE; // inside clipping range: maximum of own bottom style and top style of bottom neighbor cell - return std::max( mxImpl->GetMergedOriginCell( nCol, nRow )->GetStyleBottom(), mxImpl->GetMergedOriginCell( nCol, nRow + 1 )->GetStyleTop() ); + return std::max(mxImpl->GetMergedStyleSourceCell(nCol, nRow)->GetStyleBottom(), + mxImpl->GetMergedStyleSourceCell(nCol, nRow + 1)->GetStyleTop()); } const Style& Array::GetCellStyleTLBR( sal_Int32 nCol, sal_Int32 nRow ) const @@ -1165,6 +1169,7 @@ void Array::MirrorSelfX() std::reverse( mxImpl->maWidths.begin(), mxImpl->maWidths.end() ); mxImpl->mbXCoordsDirty = true; + mxImpl->mbXMirrored = !mxImpl->mbXMirrored; } // drawing diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx index f76a6c4da9f8..73940db300f5 100644 --- a/svx/source/table/viewcontactoftableobj.cxx +++ b/svx/source/table/viewcontactoftableobj.cxx @@ -249,11 +249,27 @@ namespace sdr::contact if(xCurrentCell.is()) { + // tdf#135843: Find correct neighbor cell index for merged cells + auto nNextCol = aCellPos.mnCol + xCurrentCell->getColumnSpan(); + auto nNextRow = aCellPos.mnRow + xCurrentCell->getRowSpan(); + // copy styles for current cell to CellBorderArray for primitive creation - aArray.SetCellStyleLeft(aCellPos.mnCol, aCellPos.mnRow, impGetLineStyle(rTableLayouter, aCellPos.mnCol, aCellPos.mnRow, false, nColCount, nRowCount, bIsRTL)); - aArray.SetCellStyleRight(aCellPos.mnCol, aCellPos.mnRow, impGetLineStyle(rTableLayouter, aCellPos.mnCol + 1, aCellPos.mnRow, false, nColCount, nRowCount, bIsRTL)); - aArray.SetCellStyleTop(aCellPos.mnCol, aCellPos.mnRow, impGetLineStyle(rTableLayouter, aCellPos.mnCol, aCellPos.mnRow, true, nColCount, nRowCount, bIsRTL)); - aArray.SetCellStyleBottom(aCellPos.mnCol, aCellPos.mnRow, impGetLineStyle(rTableLayouter, aCellPos.mnCol, aCellPos.mnRow + 1, true, nColCount, nRowCount, bIsRTL)); + aArray.SetCellStyleLeft( + aCellPos.mnCol, aCellPos.mnRow, + impGetLineStyle(rTableLayouter, aCellPos.mnCol, aCellPos.mnRow, + false, nColCount, nRowCount, bIsRTL)); + aArray.SetCellStyleRight( + aCellPos.mnCol, aCellPos.mnRow, + impGetLineStyle(rTableLayouter, nNextCol, aCellPos.mnRow, false, + nColCount, nRowCount, bIsRTL)); + aArray.SetCellStyleTop( + aCellPos.mnCol, aCellPos.mnRow, + impGetLineStyle(rTableLayouter, aCellPos.mnCol, aCellPos.mnRow, + true, nColCount, nRowCount, bIsRTL)); + aArray.SetCellStyleBottom( + aCellPos.mnCol, aCellPos.mnRow, + impGetLineStyle(rTableLayouter, aCellPos.mnCol, nNextRow, true, + nColCount, nRowCount, bIsRTL)); // ignore merged cells (all except the top-left of a merged cell) if(!xCurrentCell->isMerged()) |