summaryrefslogtreecommitdiff
path: root/sc/source/ui/unoobj/cellsuno.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/unoobj/cellsuno.cxx')
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx94
1 files changed, 78 insertions, 16 deletions
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 5bacf8a856b8..b86f03e6df06 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1475,6 +1475,8 @@ const ScMarkData* ScCellRangesBase::GetMarkData()
return pMarkData.get();
}
+void ScCellRangesBase::AdjustUpdatedRanges(UpdateRefMode) {}
+
void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
const SfxHintId nId = rHint.GetId();
@@ -1546,18 +1548,7 @@ void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
if ( aRanges.UpdateReference( pRefHint->GetMode(), &rDoc, pRefHint->GetRange(),
pRefHint->GetDx(), pRefHint->GetDy(), pRefHint->GetDz() ) )
{
- if ( pRefHint->GetMode() == URM_INSDEL
- && aRanges.size() == 1
- && dynamic_cast<ScTableSheetObj*>(this)
- )
- {
- // #101755#; the range size of a sheet does not change
- ScRange & rR = aRanges.front();
- rR.aStart.SetCol(0);
- rR.aStart.SetRow(0);
- rR.aEnd.SetCol(rDoc.MaxCol());
- rR.aEnd.SetRow(rDoc.MaxRow());
- }
+ AdjustUpdatedRanges(pRefHint->GetMode());
RefChanged();
// any change of the range address is broadcast to value (modify) listeners
@@ -4398,11 +4389,11 @@ sal_Int32 SAL_CALL ScCellRangesObj::getCount()
uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
{
SolarMutexGuard aGuard;
- uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
+ rtl::Reference<ScCellRangeObj> xRange(GetObjectByIndex_Impl(nIndex));
if (!xRange.is())
throw lang::IndexOutOfBoundsException();
- return uno::Any(xRange);
+ return uno::Any(uno::Reference<table::XCellRange>(xRange));
}
@@ -4508,6 +4499,12 @@ uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
{
+ return getScCellRangeByPosition(nLeft, nTop, nRight, nBottom);
+}
+
+rtl::Reference<ScCellRangeObj> ScCellRangeObj::getScCellRangeByPosition(
+ sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
+{
SolarMutexGuard aGuard;
ScDocShell* pDocSh = GetDocShell();
@@ -4533,6 +4530,33 @@ uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPositio
throw lang::IndexOutOfBoundsException();
}
+rtl::Reference<ScTableRowsObj> ScCellRangeObj::getScRowsByPosition(SolarMutexGuard& /*rGuard*/,
+ sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ throw uno::RuntimeException();
+
+ if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
+ {
+ sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
+ sal_Int32 nStartY = aRange.aStart.Row() + nTop;
+ sal_Int32 nEndX = aRange.aStart.Col() + nRight;
+ sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
+
+ if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
+ nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
+ {
+ ScRange aNew( static_cast<SCCOL>(nStartX), static_cast<SCROW>(nStartY), aRange.aStart.Tab(),
+ static_cast<SCCOL>(nEndX), static_cast<SCROW>(nEndY), aRange.aEnd.Tab() );
+ return new ScTableRowsObj( pDocSh, aNew.aStart.Tab(),
+ aNew.aStart.Row(), aNew.aEnd.Row() );
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+}
+
uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
const OUString& aName )
{
@@ -4605,6 +4629,11 @@ uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns()
uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows()
{
+ return getScRows();
+}
+
+rtl::Reference<ScTableRowsObj> ScCellRangeObj::getScRows()
+{
SolarMutexGuard aGuard;
ScDocShell* pDocSh = GetDocShell();
if (pDocSh)
@@ -6354,6 +6383,17 @@ SCTAB ScTableSheetObj::GetTab_Impl() const
return 0;
}
+void ScTableSheetObj::AdjustUpdatedRanges(UpdateRefMode mode)
+{
+ if (mode == URM_INSDEL)
+ {
+ ScRangeList& rRanges = AccessRanges();
+ // #101755#, tdf#47479: the range of a sheet does not change
+ rRanges.RemoveAll();
+ rRanges.push_back(GetRange());
+ }
+}
+
// former XSheet
uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts()
@@ -8157,6 +8197,17 @@ const SfxItemPropertyMap& ScTableColumnObj::GetItemPropertyMap()
return pColPropSet->getPropertyMap();
}
+void ScTableColumnObj::AdjustUpdatedRanges(UpdateRefMode mode)
+{
+ if (mode == URM_INSDEL)
+ {
+ ScRangeList& rRanges = AccessRanges();
+ // tdf#47479: the range of a column does not change
+ rRanges.RemoveAll();
+ rRanges.push_back(GetRange());
+ }
+}
+
ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, pDocSh->GetDocument().MaxCol(),nRow,nTab) ),
pRowPropSet(lcl_GetRowPropertySet())
@@ -8306,6 +8357,17 @@ const SfxItemPropertyMap& ScTableRowObj::GetItemPropertyMap()
return pRowPropSet->getPropertyMap();
}
+void ScTableRowObj::AdjustUpdatedRanges(UpdateRefMode mode)
+{
+ if (mode == URM_INSDEL)
+ {
+ ScRangeList& rRanges = AccessRanges();
+ // tdf#47479: the range of a row does not change
+ rRanges.RemoveAll();
+ rRanges.push_back(GetRange());
+ }
+}
+
ScCellsObj::ScCellsObj(ScDocShell* pDocSh, ScRangeList aR) :
pDocShell( pDocSh ),
aRanges(std::move( aR ))
@@ -8575,11 +8637,11 @@ uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
{
SolarMutexGuard aGuard;
- uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
+ rtl::Reference<ScCellRangeObj> xRange(GetObjectByIndex_Impl(nIndex));
if (!xRange.is())
throw lang::IndexOutOfBoundsException();
- return uno::Any(xRange);
+ return uno::Any(uno::Reference<table::XCellRange>(xRange));
}