summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/inc/viewdata.hxx12
-rw-r--r--sc/source/ui/view/viewdata.cxx34
2 files changed, 33 insertions, 13 deletions
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 889df879a665..5292f06e8152 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -200,6 +200,18 @@ private:
void ReadUserDataSequence(
const css::uno::Sequence <css::beans::PropertyValue>& rSettings,
ScViewData& rViewData, SCTAB nTab, bool& rHasZoom);
+
+ /** Sanitize the active split range value to not point into a grid window
+ that would never be initialized due to non-matching split modes.
+
+ This is to be done when reading settings from file formats or
+ configurations that could have arbitrary values. The caller is
+ reponsible for actually assigning the new value to eWhichActive because
+ we want this function to be const to be able to call the check from
+ anywhere.
+ */
+ SAL_WARN_UNUSED_RESULT ScSplitPos SanitizeWhichActive() const;
+
public:
~ScViewDataTable();
};
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 64998f7cc2f6..e28704470b4e 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -293,8 +293,12 @@ void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>
pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosY);
else
pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nVSplitPos);
+ // Prevent writing odd settings that would make crash versions that
+ // don't apply SanitizeWhichActive() when reading the settings.
+ // See tdf#117093
+ const ScSplitPos eActiveSplitRange = SanitizeWhichActive();
pSettings[SC_ACTIVE_SPLIT_RANGE].Name = SC_ACTIVESPLITRANGE;
- pSettings[SC_ACTIVE_SPLIT_RANGE].Value <<= sal_Int16(eWhichActive);
+ pSettings[SC_ACTIVE_SPLIT_RANGE].Value <<= sal_Int16(eActiveSplitRange);
pSettings[SC_POSITION_LEFT].Name = SC_POSITIONLEFT;
pSettings[SC_POSITION_LEFT].Value <<= sal_Int32(nPosX[SC_SPLIT_LEFT]);
pSettings[SC_POSITION_RIGHT].Name = SC_POSITIONRIGHT;
@@ -451,6 +455,7 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV
// Fallback to common SdrModel processing
else rViewData.GetDocument()->GetDrawLayer()->ReadUserDataSequenceValue(&aSettings[i]);
}
+
if (eHSplitMode == SC_SPLIT_FIX)
nFixPosX = SanitizeCol( static_cast<SCCOL>( bHasHSplitInTwips ? nTempPosHTw : nTempPosH ));
else
@@ -460,6 +465,20 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV
nFixPosY = SanitizeRow( static_cast<SCROW>( bHasVSplitInTwips ? nTempPosVTw : nTempPosV ));
else
nVSplitPos = bHasVSplitInTwips ? static_cast< long >( nTempPosVTw * rViewData.GetPPTY() ) : nTempPosV;
+
+ eWhichActive = SanitizeWhichActive();
+}
+
+ScSplitPos ScViewDataTable::SanitizeWhichActive() const
+{
+ if ((WhichH(eWhichActive) == SC_SPLIT_RIGHT && eHSplitMode == SC_SPLIT_NONE) ||
+ (WhichV(eWhichActive) == SC_SPLIT_TOP && eVSplitMode == SC_SPLIT_NONE))
+ {
+ SAL_WARN("sc.ui","ScViewDataTable::SanitizeWhichActive - bad eWhichActive " << eWhichActive);
+ // The default always initialized grid window is SC_SPLIT_BOTTOMLEFT.
+ return SC_SPLIT_BOTTOMLEFT;
+ }
+ return eWhichActive;
}
ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh ) :
@@ -2776,18 +2795,7 @@ void ScViewData::ReadUserData(const OUString& rData)
maTabData[nPos]->nPosY[0] = SanitizeRow( aTabOpt.getToken(9,cTabSep).toInt32());
maTabData[nPos]->nPosY[1] = SanitizeRow( aTabOpt.getToken(10,cTabSep).toInt32());
- // test whether the active part according to SplitMode exists at all
- // (Bug #44516#)
- ScSplitPos eTest = maTabData[nPos]->eWhichActive;
- if ( ( WhichH( eTest ) == SC_SPLIT_RIGHT &&
- maTabData[nPos]->eHSplitMode == SC_SPLIT_NONE ) ||
- ( WhichV( eTest ) == SC_SPLIT_TOP &&
- maTabData[nPos]->eVSplitMode == SC_SPLIT_NONE ) )
- {
- // then back to default again (bottom left)
- maTabData[nPos]->eWhichActive = SC_SPLIT_BOTTOMLEFT;
- OSL_FAIL("SplitPos had to be corrected");
- }
+ maTabData[nPos]->eWhichActive = maTabData[nPos]->SanitizeWhichActive();
}
++nPos;
}