tdf#154803 - Check if range is entirely merged
Regression from commit b9411e5875
where I
missinterpreted the check to get merged cells.
Regression:
tdf#147122 - Return cell object when a simple selection is merged
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145378
Change-Id: I2e39599a206cf102b1da8c7fc4bb2d8c0a4b106c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150412
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
This commit is contained in:
@@ -911,6 +911,38 @@ CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf147122)
|
||||
CPPUNIT_ASSERT_EQUAL(Any(OUString("This is a test")), aRet);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf154803)
|
||||
{
|
||||
mxComponent = loadFromDesktop("private:factory/scalc");
|
||||
|
||||
css::uno::Reference<css::document::XEmbeddedScripts> xDocScr(mxComponent, UNO_QUERY_THROW);
|
||||
auto xLibs = xDocScr->getBasicLibraries();
|
||||
auto xLibrary = xLibs->createLibrary("TestLibrary");
|
||||
xLibrary->insertByName(
|
||||
"TestModule",
|
||||
uno::Any(
|
||||
OUString("Function TestExtendedMergedSelection\n"
|
||||
// Merge A1:B2 cell range
|
||||
" oActiveSheet = ThisComponent.CurrentController.ActiveSheet\n"
|
||||
" oRange = oActiveSheet.getCellRangeByName(\"A1:B2\")\n"
|
||||
" ThisComponent.getCurrentController.Select(oRange)\n"
|
||||
" oActiveCell = ThisComponent.CurrentSelection\n"
|
||||
" oActiveCell.Merge(True)\n"
|
||||
// Select A1:B3 range and check for its implementation name
|
||||
" oRange = oActiveSheet.getCellRangeByName(\"A1:B3\")\n"
|
||||
" ThisComponent.getCurrentController.Select(oRange)\n"
|
||||
" TestExtendedMergedSelection = ThisComponent.CurrentSelection.ImplementationName\n"
|
||||
"End Function\n")));
|
||||
|
||||
Any aRet = executeMacro("vnd.sun.Star.script:TestLibrary.TestModule.TestExtendedMergedSelection?"
|
||||
"language=Basic&location=document");
|
||||
// Without the fix in place, this test would have failed with
|
||||
// - Expected : ScCellRangeObj
|
||||
// - Actual : ScCellObj
|
||||
// i.e. the selection was interpreted as a single cell instead of a range
|
||||
CPPUNIT_ASSERT_EQUAL(Any(OUString("ScCellRangeObj")), aRet);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(ScMacrosTest, testTdf116127)
|
||||
{
|
||||
mxComponent = loadFromDesktop("private:factory/scalc");
|
||||
|
@@ -54,6 +54,7 @@
|
||||
#include <prevwsh.hxx>
|
||||
#include <docsh.hxx>
|
||||
#include <drwlayer.hxx>
|
||||
#include <attrib.hxx>
|
||||
#include <drawview.hxx>
|
||||
#include <fupoor.hxx>
|
||||
#include <sc.hrc>
|
||||
@@ -873,13 +874,20 @@ uno::Any SAL_CALL ScTabViewObj::getSelection()
|
||||
ScMarkType eMarkType = rViewData.GetSimpleArea(aRange);
|
||||
if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
|
||||
{
|
||||
// tdf#147122 - return cell object when a simple selection is merged
|
||||
// tdf#154803 - check if range is entirely merged
|
||||
ScDocument& rDoc = pDocSh->GetDocument();
|
||||
const ScPatternAttr* pMarkPattern = rDoc.GetPattern(aRange.aStart);
|
||||
const ScMergeAttr* pMergeAttr = rDoc.GetAttr(aRange.aStart, ATTR_MERGE);
|
||||
SCCOL nColSpan = 1;
|
||||
SCROW nRowSpan = 1;
|
||||
if (pMergeAttr && pMergeAttr->IsMerged())
|
||||
{
|
||||
nColSpan = pMergeAttr->GetColMerge();
|
||||
nRowSpan = pMergeAttr->GetRowMerge();
|
||||
}
|
||||
// tdf#147122 - return cell object when a simple selection is entirely merged
|
||||
if (aRange.aStart == aRange.aEnd
|
||||
|| (pMarkPattern
|
||||
&& pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false)
|
||||
== SfxItemState::SET))
|
||||
|| (aRange.aEnd.Col() - aRange.aStart.Col() == nColSpan - 1
|
||||
&& aRange.aEnd.Row() - aRange.aStart.Row() == nRowSpan - 1))
|
||||
pObj = new ScCellObj( pDocSh, aRange.aStart );
|
||||
else
|
||||
pObj = new ScCellRangeObj( pDocSh, aRange );
|
||||
|
Reference in New Issue
Block a user