Kaydet (Commit) 7b7aac24 authored tarafından Eike Rathke's avatar Eike Rathke

Resolves: tdf#83365 push proper references in INDIRECT

... that take relative/absolute addressing and sheet 3D flag into
account to be fed to reference extension via range operator.

Change-Id: Iabe13ae384577e2d71ca87af6482ddccbf7ad0ac
(cherry picked from commit fb6dd2a7)
üst a60fc4bf
...@@ -57,6 +57,8 @@ public: ...@@ -57,6 +57,8 @@ public:
void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab ); void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
/// InitAddressRel: InitFlags and set address, everything relative to rPos /// InitAddressRel: InitFlags and set address, everything relative to rPos
void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos ); void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos );
/// InitFlags and set address, relative to rPos if rRef says so.
void InitFromRefAddress( const ScRefAddress& rRef, const ScAddress& rPos );
sal_uInt8 FlagValue() const { return mnFlagValue;} sal_uInt8 FlagValue() const { return mnFlagValue;}
void SetColRel( bool bVal ) { Flags.bColRel = bVal; } void SetColRel( bool bVal ) { Flags.bColRel = bVal; }
...@@ -135,6 +137,9 @@ struct ScComplexRefData ...@@ -135,6 +137,9 @@ struct ScComplexRefData
Ref2.InitAddress( nCol2, nRow2, nTab2 ); Ref2.InitAddress( nCol2, nRow2, nTab2 );
} }
/// InitFlags and set range, relative to rPos if rRef1 and rRef2 say so.
void InitFromRefAddresses( const ScRefAddress& rRef1, const ScRefAddress& rRef2, const ScAddress& rPos );
bool Valid() const; bool Valid() const;
/** In external references nTab is -1 for the start tab and -1 for the end /** In external references nTab is -1 for the start tab and -1 for the end
......
...@@ -333,6 +333,8 @@ void PushExternalSingleRef(sal_uInt16 nFileId, const OUString& rTabName, ...@@ -333,6 +333,8 @@ void PushExternalSingleRef(sal_uInt16 nFileId, const OUString& rTabName,
void PushExternalDoubleRef(sal_uInt16 nFileId, const OUString& rTabName, void PushExternalDoubleRef(sal_uInt16 nFileId, const OUString& rTabName,
SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
SCCOL nCol2, SCROW nRow2, SCTAB nTab2); SCCOL nCol2, SCROW nRow2, SCTAB nTab2);
void PushSingleRef( const ScRefAddress& rRef );
void PushDoubleRef( const ScRefAddress& rRef1, const ScRefAddress& rRef2 );
void PushMatrix( const sc::RangeMatrix& rMat ); void PushMatrix( const sc::RangeMatrix& rMat );
void PushMatrix(const ScMatrixRef& pMat); void PushMatrix(const ScMatrixRef& pMat);
void PushError( sal_uInt16 nError ); void PushError( sal_uInt16 nError );
......
...@@ -7052,8 +7052,7 @@ void ScInterpreter::ScIndirect() ...@@ -7052,8 +7052,7 @@ void ScInterpreter::ScIndirect()
aRefAd2.Col(), aRefAd2.Row(), aRefAd2.Tab()); aRefAd2.Col(), aRefAd2.Row(), aRefAd2.Tab());
} }
else else
PushDoubleRef( aRefAd.Col(), aRefAd.Row(), aRefAd.Tab(), PushDoubleRef( aRefAd, aRefAd2);
aRefAd2.Col(), aRefAd2.Row(), aRefAd2.Tab() );
} }
else if (ConvertSingleRef(pDok, sRefStr, nTab, aRefAd, aDetails, &aExtInfo)) else if (ConvertSingleRef(pDok, sRefStr, nTab, aRefAd, aDetails, &aExtInfo))
{ {
...@@ -7063,7 +7062,7 @@ void ScInterpreter::ScIndirect() ...@@ -7063,7 +7062,7 @@ void ScInterpreter::ScIndirect()
aExtInfo.mnFileId, aExtInfo.maTabName, aRefAd.Col(), aRefAd.Row(), aRefAd.Tab()); aExtInfo.mnFileId, aExtInfo.maTabName, aRefAd.Col(), aRefAd.Row(), aRefAd.Tab());
} }
else else
PushSingleRef( aRefAd.Col(), aRefAd.Row(), aRefAd.Tab() ); PushSingleRef( aRefAd);
} }
else else
{ {
......
...@@ -1968,6 +1968,26 @@ void ScInterpreter::PushExternalDoubleRef( ...@@ -1968,6 +1968,26 @@ void ScInterpreter::PushExternalDoubleRef(
} }
} }
void ScInterpreter::PushSingleRef( const ScRefAddress& rRef )
{
if (!IfErrorPushError())
{
ScSingleRefData aRef;
aRef.InitFromRefAddress( rRef, aPos);
PushTempTokenWithoutError( new ScSingleRefToken( aRef ) );
}
}
void ScInterpreter::PushDoubleRef( const ScRefAddress& rRef1, const ScRefAddress& rRef2 )
{
if (!IfErrorPushError())
{
ScComplexRefData aRef;
aRef.InitFromRefAddresses( rRef1, rRef2, aPos);
PushTempTokenWithoutError( new ScDoubleRefToken( aRef ) );
}
}
void ScInterpreter::PushMatrix( const sc::RangeMatrix& rMat ) void ScInterpreter::PushMatrix( const sc::RangeMatrix& rMat )
{ {
if (!rMat.isRangeValid()) if (!rMat.isRangeValid())
......
...@@ -41,6 +41,16 @@ void ScSingleRefData::InitAddressRel( const ScAddress& rAdr, const ScAddress& rP ...@@ -41,6 +41,16 @@ void ScSingleRefData::InitAddressRel( const ScAddress& rAdr, const ScAddress& rP
SetAddress(rAdr, rPos); SetAddress(rAdr, rPos);
} }
void ScSingleRefData::InitFromRefAddress( const ScRefAddress& rRef, const ScAddress& rPos )
{
InitFlags();
SetColRel( rRef.IsRelCol());
SetRowRel( rRef.IsRelRow());
SetTabRel( rRef.IsRelTab());
SetFlag3D( rRef.Tab() != rPos.Tab());
SetAddress( rRef.GetAddress(), rPos);
}
void ScSingleRefData::SetAbsCol( SCCOL nVal ) void ScSingleRefData::SetAbsCol( SCCOL nVal )
{ {
Flags.bColRel = false; Flags.bColRel = false;
...@@ -257,6 +267,20 @@ void ScSingleRefData::Dump( int nIndent ) const ...@@ -257,6 +267,20 @@ void ScSingleRefData::Dump( int nIndent ) const
} }
#endif #endif
void ScComplexRefData::InitFromRefAddresses( const ScRefAddress& rRef1, const ScRefAddress& rRef2, const ScAddress& rPos )
{
InitFlags();
Ref1.SetColRel( rRef1.IsRelCol());
Ref1.SetRowRel( rRef1.IsRelRow());
Ref1.SetTabRel( rRef1.IsRelTab());
Ref1.SetFlag3D( rRef1.Tab() != rPos.Tab() || rRef1.Tab() != rRef2.Tab());
Ref2.SetColRel( rRef2.IsRelCol());
Ref2.SetRowRel( rRef2.IsRelRow());
Ref2.SetTabRel( rRef2.IsRelTab());
Ref2.SetFlag3D( rRef1.Tab() != rRef2.Tab());
SetRange( ScRange( rRef1.GetAddress(), rRef2.GetAddress()), rPos);
}
ScComplexRefData& ScComplexRefData::Extend( const ScSingleRefData & rRef, const ScAddress & rPos ) ScComplexRefData& ScComplexRefData::Extend( const ScSingleRefData & rRef, const ScAddress & rPos )
{ {
bool bInherit3D = (Ref1.IsFlag3D() && !Ref2.IsFlag3D() && !rRef.IsFlag3D()); bool bInherit3D = (Ref1.IsFlag3D() && !Ref2.IsFlag3D() && !rRef.IsFlag3D());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment