[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - 2 commits - sc/qa sc/source
Dennis Francis (via logerrit)
logerrit at kemper.freedesktop.org
Sun Sep 22 06:51:22 UTC 2019
sc/qa/unit/data/xlsx/conditional_fmt_origin.xlsx |binary
sc/qa/unit/subsequent_export-test.cxx | 15 +++++++++++++++
sc/source/filter/excel/xecontent.cxx | 19 +++++++++++++------
sc/source/filter/inc/xecontent.hxx | 2 +-
sc/source/filter/oox/extlstcontext.cxx | 6 ++----
5 files changed, 31 insertions(+), 11 deletions(-)
New commits:
commit 2310b4264ab550a8dc9d49e1e0dcecea5bde8d06
Author: Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Thu May 9 18:50:22 2019 +0530
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Sep 22 08:50:56 2019 +0200
crashtesting: crash on importing tdf#123420-2.xlsx
since
commit c2f1c68ffb6dfa1ce7de09dcc428d6c53549e88d
Date: Fri Apr 19 23:15:53 2019 +0530
tdf#122590: follow-up : import x14:cfRule priorities
Fix is to import the priorities for iconSet x14:cfRule too.
Thanks to Caolán McNamara for notifying me about the regression.
Change-Id: Ib5b703a6911ab6480d42ac1e004a144043d3ad24
Reviewed-on: https://gerrit.libreoffice.org/72035
Tested-by: Jenkins
Reviewed-by: Dennis Francis <dennis.francis at collabora.com>
(cherry picked from commit ea5f1ec4eec4aa609000223aea1bc9ce202de2c5)
Reviewed-on: https://gerrit.libreoffice.org/72120
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/79223
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/sc/source/filter/oox/extlstcontext.cxx b/sc/source/filter/oox/extlstcontext.cxx
index 533f672ac95c..2a76a93b7349 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -105,6 +105,7 @@ ContextHandlerRef ExtConditionalFormattingContext::onCreateContext(sal_Int32 nEl
OUString aType = rAttribs.getString(XML_type, OUString());
OUString aId = rAttribs.getString(XML_id, OUString());
nPriority = rAttribs.getInteger( XML_priority, -1 );
+ maPriorities.push_back(nPriority);
if (aType == "dataBar")
{
@@ -180,7 +181,6 @@ void ExtConditionalFormattingContext::onEndElement()
case XM_TOKEN(f):
{
rFormulas.push_back(aChars);
- maPriorities.push_back(nPriority);
}
break;
case XLS14_TOKEN( cfRule ):
@@ -225,9 +225,7 @@ void ExtConditionalFormattingContext::onEndElement()
std::vector< std::unique_ptr<ExtCfCondFormat> >& rExtFormats = getCondFormats().importExtCondFormat();
rExtFormats.push_back(o3tl::make_unique<ExtCfCondFormat>(aRange, maEntries, &maPriorities));
- if (isPreviousElementF)
- maPriorities.clear();
-
+ maPriorities.clear();
isPreviousElementF = false;
}
break;
commit 8c1784aef3b7da22198588256469752888c2a76d
Author: Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Thu Apr 25 08:37:58 2019 +0530
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sun Sep 22 08:50:48 2019 +0200
tdf#124953: Use rangelist's combined range top-left address...
as origin address in the conditional format formula on xlsx export.
Excel seems to get confused if anything else is supplied as the
origin in the formula.
For example, before this patch, for a condfmt range over the
range-list [A3:C5 E1:F2], the origin address used in the formula
(for text search type entries) is A3.
<conditionalFormatting sqref="A3:C5 E1:F2">
<cfRule type="containsText" dxfId="0" priority="1" operator="containsText" text="ABC">
<formula>NOT(ISERROR(SEARCH("ABC",A3)))</formula>
</cfRule>
</conditionalFormatting>
In this patch we use the top-left cell address(A1) of the combined range "A1:F5" as
the origin address.
<formula>NOT(ISERROR(SEARCH("ABC",A1)))</formula>
Reviewed-on: https://gerrit.libreoffice.org/71312
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit ca40d4ce9b8134fd8bfc90e9e8289b620163475b)
Change-Id: If08a859bc361f925148ff463758d03ebbc41c0ac
Reviewed-on: https://gerrit.libreoffice.org/72009
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/79222
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
diff --git a/sc/qa/unit/data/xlsx/conditional_fmt_origin.xlsx b/sc/qa/unit/data/xlsx/conditional_fmt_origin.xlsx
new file mode 100644
index 000000000000..aef60b6cb489
Binary files /dev/null and b/sc/qa/unit/data/xlsx/conditional_fmt_origin.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 29849f8531e7..0f278b84de57 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -113,6 +113,7 @@ public:
void testConditionalFormatRangeListXLSX();
void testConditionalFormatContainsTextXLSX();
void testConditionalFormatPriorityCheckXLSX();
+ void testConditionalFormatOriginXLSX();
void testMiscRowHeightExport();
void testNamedRangeBugfdo62729();
void testBuiltinRangesXLSX();
@@ -244,6 +245,7 @@ public:
CPPUNIT_TEST(testConditionalFormatRangeListXLSX);
CPPUNIT_TEST(testConditionalFormatContainsTextXLSX);
CPPUNIT_TEST(testConditionalFormatPriorityCheckXLSX);
+ CPPUNIT_TEST(testConditionalFormatOriginXLSX);
CPPUNIT_TEST(testMiscRowHeightExport);
CPPUNIT_TEST(testNamedRangeBugfdo62729);
CPPUNIT_TEST(testBuiltinRangesXLSX);
@@ -4046,6 +4048,19 @@ void ScExportTest::testConditionalFormatPriorityCheckXLSX()
CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong priorities for A3", bHighPriorityExtensionA3, nA3ExtPriority < nA3NormalPriority);
}
+void ScExportTest::testConditionalFormatOriginXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("conditional_fmt_origin.", FORMAT_XLSX);
+ CPPUNIT_ASSERT(xDocSh.is());
+
+ xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/worksheets/sheet1.xml", FORMAT_XLSX);
+ CPPUNIT_ASSERT(pDoc);
+
+ // tdf#124953 : The range-list is B3:C6 F1:G2, origin address in the formula should be B1, not B3.
+ OUString aFormula = getXPathContent(pDoc, "//x:conditionalFormatting/x:cfRule/x:formula");
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong origin address in formula", OUString("NOT(ISERROR(SEARCH(\"BAC\",B1)))"), aFormula);
+}
+
void ScExportTest::testEscapeCharInNumberFormatXLSX()
{
ScDocShellRef xDocSh = loadDoc("tdf81939.", FORMAT_XLSX);
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index af9030db58aa..b620cd4650e0 100755
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -586,7 +586,7 @@ void XclExpLabelranges::Save( XclExpStream& rStrm )
class XclExpCFImpl : protected XclExpRoot
{
public:
- explicit XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority );
+ explicit XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin );
/** Writes the body of the CF record. */
void WriteBody( XclExpStream& rStrm );
@@ -594,6 +594,7 @@ public:
private:
const ScCondFormatEntry& mrFormatEntry; /// Calc conditional format entry.
+ ScAddress maOrigin; /// Top left cell of the combined range
XclFontData maFontData; /// Font formatting attributes.
XclExpCellBorder maBorder; /// Border formatting attributes.
XclExpCellArea maArea; /// Pattern formatting attributes.
@@ -615,9 +616,10 @@ private:
bool mbFormula2;
};
-XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority ) :
+XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin ) :
XclExpRoot( rRoot ),
mrFormatEntry( rFormatEntry ),
+ maOrigin( aOrigin ),
mnFontColorId( 0 ),
mnType( EXC_CF_TYPE_CELL ),
mnOperator( EXC_CF_CMP_NONE ),
@@ -633,6 +635,10 @@ XclExpCFImpl::XclExpCFImpl( const XclExpRoot& rRoot, const ScCondFormatEntry& rF
mbPattUsed( false ),
mbFormula2(false)
{
+ // Set correct tab for maOrigin from GetValidSrcPos() of the format-entry.
+ ScAddress aValidSrcPos = mrFormatEntry.GetValidSrcPos();
+ maOrigin.SetTab(aValidSrcPos.Tab());
+
/* Get formatting attributes here, and not in WriteBody(). This is needed to
correctly insert all colors into the palette. */
@@ -1058,7 +1064,7 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
if (RequiresFixedFormula(eOperation))
{
rWorksheet->startElement( XML_formula, FSEND );
- OString aFormula = GetFixedFormula(eOperation, mrFormatEntry.GetValidSrcPos(), aText);
+ OString aFormula = GetFixedFormula(eOperation, maOrigin, aText);
rWorksheet->writeEscaped(aFormula.getStr());
rWorksheet->endElement( XML_formula );
}
@@ -1082,10 +1088,10 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
rWorksheet->endElement( XML_cfRule );
}
-XclExpCF::XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority = 0 ) :
+XclExpCF::XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin ) :
XclExpRecord( EXC_ID_CF ),
XclExpRoot( rRoot ),
- mxImpl( new XclExpCFImpl( rRoot, rFormatEntry, nPriority ) )
+ mxImpl( new XclExpCFImpl( rRoot, rFormatEntry, nPriority, aOrigin ) )
{
}
@@ -1294,11 +1300,12 @@ XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat
if( !maXclRanges.empty() )
{
std::vector<XclExpExtCondFormatData> aExtEntries;
+ ScAddress aOrigin = aScRanges.Combine().aStart;
for( size_t nIndex = 0, nCount = rCondFormat.size(); nIndex < nCount; ++nIndex )
if( const ScFormatEntry* pFormatEntry = rCondFormat.GetEntry( nIndex ) )
{
if(pFormatEntry->GetType() == ScFormatEntry::Type::Condition)
- maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), ++rIndex ) );
+ maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), ++rIndex, aOrigin ) );
else if(pFormatEntry->GetType() == ScFormatEntry::Type::ExtCondition)
{
const ScCondFormatEntry& rFormat = static_cast<const ScCondFormatEntry&>(*pFormatEntry);
diff --git a/sc/source/filter/inc/xecontent.hxx b/sc/source/filter/inc/xecontent.hxx
index 0c46c53039ed..66123a29e8a7 100644
--- a/sc/source/filter/inc/xecontent.hxx
+++ b/sc/source/filter/inc/xecontent.hxx
@@ -168,7 +168,7 @@ class XclExpCFImpl;
class XclExpCF : public XclExpRecord, protected XclExpRoot
{
public:
- explicit XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority );
+ explicit XclExpCF( const XclExpRoot& rRoot, const ScCondFormatEntry& rFormatEntry, sal_Int32 nPriority, ScAddress aOrigin );
virtual ~XclExpCF() override;
virtual void SaveXml( XclExpXmlStream& rStrm ) override;
More information about the Libreoffice-commits
mailing list