[Libreoffice-commits] core.git: 2 commits - sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Jul 15 21:05:37 UTC 2018
sc/source/filter/excel/xecontent.cxx | 85 ++++++++++++++++++++++++++++++-----
1 file changed, 74 insertions(+), 11 deletions(-)
New commits:
commit 16048ebc230880148346f02403820b7646b2649c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Sun Jul 15 00:18:58 2018 +0200
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Sun Jul 15 23:05:26 2018 +0200
related tdf#117816, only export cond format formula to xlsx when required
Change-Id: I7523d17e9945dfbdf0c346fff8eddd40593f946a
Reviewed-on: https://gerrit.libreoffice.org/57444
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 4e0863d12e1b..04f3a9c0f2bd 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -937,6 +937,27 @@ bool IsTextRule(ScConditionMode eMode)
return false;
}
+bool RequiresFormula(ScConditionMode eMode)
+{
+ if (IsTopBottomRule(eMode))
+ return false;
+ else if (IsTextRule(eMode))
+ return false;
+
+ switch (eMode)
+ {
+ case ScConditionMode::NoError:
+ case ScConditionMode::Error:
+ case ScConditionMode::Duplicate:
+ case ScConditionMode::NotDuplicate:
+ return false;
+ default:
+ break;
+ }
+
+ return true;
+}
+
bool RequiresFixedFormula(ScConditionMode eMode)
{
switch(eMode)
@@ -963,9 +984,9 @@ OString GetFixedFormula(ScConditionMode eMode, const ScAddress& rAddress, const
switch (eMode)
{
case ScConditionMode::Error:
- return "";
+ return OString("ISERROR(" + aPos + ")") ;
case ScConditionMode::NoError:
- return "";
+ return OString("NOT(ISERROR(" + aPos + "))") ;
case ScConditionMode::BeginsWith:
return OString("LEFT(" + aPos + ",LEN(\"" + rText + "\"))=\"" + rText + "\"");
case ScConditionMode::EndsWith:
@@ -1034,7 +1055,7 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
rWorksheet->writeEscaped(aFormula.getStr());
rWorksheet->endElement( XML_formula );
}
- else if(!IsTextRule(eOperation) && !IsTopBottomRule(eOperation))
+ else if(RequiresFormula(eOperation))
{
rWorksheet->startElement( XML_formula, FSEND );
std::unique_ptr<ScTokenArray> pTokenArray(mrFormatEntry.CreateFlatCopiedTokenArray(0));
commit 6df45ae3a85b21d984605a6656282e5feaf8dea9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Sat Jul 14 23:56:44 2018 +0200
Commit: Markus Mohrhard <markus.mohrhard at googlemail.com>
CommitDate: Sun Jul 15 23:05:15 2018 +0200
related tdf#117816, add more work arounds for MS Excel bugs
Another set of cases where MS Excel needs the formula.
Change-Id: I58344a540ad69ff9b8c56aa817730079bd011acd
Reviewed-on: https://gerrit.libreoffice.org/57443
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 6d025f022eeb..4e0863d12e1b 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -937,6 +937,50 @@ bool IsTextRule(ScConditionMode eMode)
return false;
}
+bool RequiresFixedFormula(ScConditionMode eMode)
+{
+ switch(eMode)
+ {
+ case ScConditionMode::NoError:
+ case ScConditionMode::Error:
+ case ScConditionMode::BeginsWith:
+ case ScConditionMode::EndsWith:
+ case ScConditionMode::ContainsText:
+ case ScConditionMode::NotContainsText:
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
+OString GetFixedFormula(ScConditionMode eMode, const ScAddress& rAddress, const OString& rText)
+{
+ OStringBuffer aBuffer;
+ OStringBuffer aPosBuffer = XclXmlUtils::ToOString(aBuffer, rAddress);
+ OString aPos = aPosBuffer.makeStringAndClear();
+ switch (eMode)
+ {
+ case ScConditionMode::Error:
+ return "";
+ case ScConditionMode::NoError:
+ return "";
+ case ScConditionMode::BeginsWith:
+ return OString("LEFT(" + aPos + ",LEN(\"" + rText + "\"))=\"" + rText + "\"");
+ case ScConditionMode::EndsWith:
+ return OString("RIGHT(" + aPos +",LEN(\"" + rText + "\"))=\"" + rText + "\"");
+ case ScConditionMode::ContainsText:
+ return OString("NOT(ISERROR(SEARCH(\"" + rText + "\"," + aPos + ")))");
+ case ScConditionMode::NotContainsText:
+ return OString("ISERROR(SEARCH(\"" + rText + "\"," + aPos + "))");
+ default:
+ break;
+ }
+
+ return OString("");
+}
+
}
void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
@@ -982,7 +1026,15 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
XML_text, aText.getStr(),
XML_dxfId, OString::number( GetDxfs().GetDxfId( mrFormatEntry.GetStyle() ) ).getStr(),
FSEND );
- if(!IsTextRule(eOperation) && !IsTopBottomRule(eOperation))
+
+ if (RequiresFixedFormula(eOperation))
+ {
+ rWorksheet->startElement( XML_formula, FSEND );
+ OString aFormula = GetFixedFormula(eOperation, mrFormatEntry.GetValidSrcPos(), aText);
+ rWorksheet->writeEscaped(aFormula.getStr());
+ rWorksheet->endElement( XML_formula );
+ }
+ else if(!IsTextRule(eOperation) && !IsTopBottomRule(eOperation))
{
rWorksheet->startElement( XML_formula, FSEND );
std::unique_ptr<ScTokenArray> pTokenArray(mrFormatEntry.CreateFlatCopiedTokenArray(0));
@@ -998,16 +1050,6 @@ void XclExpCFImpl::SaveXml( XclExpXmlStream& rStrm )
rWorksheet->endElement( XML_formula );
}
}
- else if (IsTextRule(eOperation))
- {
- OStringBuffer aBufferOld;
- OStringBuffer aBuffer = XclXmlUtils::ToOString(aBufferOld, mrFormatEntry.GetValidSrcPos());
- OString aTextTopCell = aBuffer.makeStringAndClear();
- OString aFormula = "NOT(ISERROR(SEARCH(\"" + aText + "\"," + aTextTopCell + ")))";
- rWorksheet->startElement( XML_formula, FSEND );
- rWorksheet->writeEscaped(aFormula.getStr());
- rWorksheet->endElement( XML_formula );
- }
// OOXTODO: XML_extLst
rWorksheet->endElement( XML_cfRule );
}
More information about the Libreoffice-commits
mailing list