Resolves: tdf#100123 prefer notation priority in detecting range/address
i.e. try and parse whether something is a range or an address in order of document address convention, Calc A1, Excel A1 and Excel R1C1, rather than check if something is a range in any of those conventions before checking if it might be an address in any of those conventions. Change-Id: Ibb744c3eda78a80f33bdbfa5f5ddf0aa5b6361af Reviewed-on: https://gerrit.libreoffice.org/27821 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
committed by
Eike Rathke
parent
8c80a56ea9
commit
405db7afbd
@@ -69,48 +69,95 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
static ScRefFlags lcl_ParseRange(ScRange& rScRange, const OUString& aAddress, ScDocument* pDoc)
|
namespace
|
||||||
{
|
{
|
||||||
// start with the address convention set in the document
|
enum class DetectFlags
|
||||||
formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
|
{
|
||||||
ScRefFlags nResult = rScRange.Parse(aAddress, pDoc, eConv);
|
NONE,
|
||||||
if ( nResult & ScRefFlags::VALID )
|
RANGE,
|
||||||
return nResult;
|
ADDRESS
|
||||||
|
};
|
||||||
|
|
||||||
// try the default Calc (A1) address convention
|
struct ScRefFlagsAndType
|
||||||
nResult = rScRange.Parse(aAddress, pDoc);
|
{
|
||||||
if ( nResult & ScRefFlags::VALID )
|
ScRefFlags nResult;
|
||||||
return nResult;
|
DetectFlags eDetected;
|
||||||
|
};
|
||||||
|
|
||||||
// try the Excel A1 address convention
|
ScRefFlagsAndType lcl_ParseRangeOrAddress(ScRange& rScRange, ScAddress& rScAddress,
|
||||||
nResult = rScRange.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_A1);
|
const OUString& aAddress, ScDocument* pDoc)
|
||||||
if ( nResult & ScRefFlags::VALID )
|
{
|
||||||
return nResult;
|
ScRefFlagsAndType aRet;
|
||||||
|
|
||||||
// try Excel R1C1 address convention
|
formula::FormulaGrammar::AddressConvention eConv;
|
||||||
return rScRange.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_R1C1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ScRefFlags lcl_ParseAddress(ScAddress& rScAddress, const OUString& aAddress, ScDocument* pDoc)
|
// start with the address convention set in the document
|
||||||
{
|
eConv = pDoc->GetAddressConvention();
|
||||||
// start with the address convention set in the document
|
aRet.nResult = rScRange.Parse(aAddress, pDoc, eConv);
|
||||||
formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
|
if (aRet.nResult & ScRefFlags::VALID)
|
||||||
ScRefFlags nResult = rScAddress.Parse(aAddress, pDoc, eConv);
|
{
|
||||||
if ( nResult & ScRefFlags::VALID )
|
aRet.eDetected = DetectFlags::RANGE;
|
||||||
return nResult;
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
// try the default Calc (A1) address convention
|
aRet.nResult = rScAddress.Parse(aAddress, pDoc, eConv);
|
||||||
nResult = rScAddress.Parse(aAddress, pDoc);
|
if (aRet.nResult & ScRefFlags::VALID)
|
||||||
if ( nResult & ScRefFlags::VALID )
|
{
|
||||||
return nResult;
|
aRet.eDetected = DetectFlags::ADDRESS;
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
// try the Excel A1 address convention
|
// try the default Calc (A1) address convention
|
||||||
nResult = rScAddress.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_A1);
|
aRet.nResult = rScRange.Parse(aAddress, pDoc);
|
||||||
if ( nResult & ScRefFlags::VALID )
|
if (aRet.nResult & ScRefFlags::VALID)
|
||||||
return nResult;
|
{
|
||||||
|
aRet.eDetected = DetectFlags::RANGE;
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
// try Excel R1C1 address convention
|
aRet.nResult = rScAddress.Parse(aAddress, pDoc);
|
||||||
return rScAddress.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_R1C1);
|
if (aRet.nResult & ScRefFlags::VALID)
|
||||||
|
{
|
||||||
|
aRet.eDetected = DetectFlags::ADDRESS;
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try the Excel A1 address convention
|
||||||
|
aRet.nResult = rScRange.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_A1);
|
||||||
|
if (aRet.nResult & ScRefFlags::VALID)
|
||||||
|
{
|
||||||
|
aRet.eDetected = DetectFlags::RANGE;
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try the Excel A1 address convention
|
||||||
|
aRet.nResult = rScAddress.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_A1);
|
||||||
|
if (aRet.nResult & ScRefFlags::VALID)
|
||||||
|
{
|
||||||
|
aRet.eDetected = DetectFlags::ADDRESS;
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try Excel R1C1 address convention
|
||||||
|
aRet.nResult = rScRange.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_R1C1);
|
||||||
|
if (aRet.nResult & ScRefFlags::VALID)
|
||||||
|
{
|
||||||
|
aRet.eDetected = DetectFlags::RANGE;
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
aRet.nResult = rScAddress.Parse(aAddress, pDoc, formula::FormulaGrammar::CONV_XL_R1C1);
|
||||||
|
if (aRet.nResult & ScRefFlags::VALID)
|
||||||
|
{
|
||||||
|
aRet.eDetected = DetectFlags::ADDRESS;
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
aRet.nResult = ScRefFlags::ZERO;
|
||||||
|
aRet.eDetected = DetectFlags::NONE;
|
||||||
|
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScTabViewShell::Execute( SfxRequest& rReq )
|
void ScTabViewShell::Execute( SfxRequest& rReq )
|
||||||
@@ -278,12 +325,13 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
|
|||||||
ScMarkData& rMark = rViewData.GetMarkData();
|
ScMarkData& rMark = rViewData.GetMarkData();
|
||||||
ScRange aScRange;
|
ScRange aScRange;
|
||||||
ScAddress aScAddress;
|
ScAddress aScAddress;
|
||||||
ScRefFlags nResult = lcl_ParseRange(aScRange, aAddress, pDoc);
|
ScRefFlagsAndType aResult = lcl_ParseRangeOrAddress(aScRange, aScAddress, aAddress, pDoc);
|
||||||
|
ScRefFlags nResult = aResult.nResult;
|
||||||
SCTAB nTab = rViewData.GetTabNo();
|
SCTAB nTab = rViewData.GetTabNo();
|
||||||
bool bMark = true;
|
bool bMark = true;
|
||||||
|
|
||||||
// Is this a range ?
|
// Is this a range ?
|
||||||
if( nResult & ScRefFlags::VALID )
|
if (aResult.eDetected == DetectFlags::RANGE)
|
||||||
{
|
{
|
||||||
if ( nResult & ScRefFlags::TAB_3D )
|
if ( nResult & ScRefFlags::TAB_3D )
|
||||||
{
|
{
|
||||||
@@ -297,7 +345,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Is this a cell ?
|
// Is this a cell ?
|
||||||
else if ( (nResult = lcl_ParseAddress(aScAddress, aAddress, pDoc)) & ScRefFlags::VALID )
|
else if (aResult.eDetected == DetectFlags::ADDRESS)
|
||||||
{
|
{
|
||||||
if ( nResult & ScRefFlags::TAB_3D )
|
if ( nResult & ScRefFlags::TAB_3D )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user