[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - sc/qa sc/source

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Fri May 10 06:26:35 UTC 2019


 sc/qa/unit/data/contentCSV/new_cond_format_test_sheet2.csv |    2 -
 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/excel/xestyle.cxx                         |    2 -
 sc/source/filter/inc/xecontent.hxx                         |    2 -
 6 files changed, 31 insertions(+), 9 deletions(-)

New commits:
commit 8a27eeb12b1700e9a3f181addc28e6282a11f1e3
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: Fri May 10 08:26:14 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>

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 831c98750454..e7d98154777a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -112,6 +112,7 @@ public:
     void testConditionalFormatRangeListXLSX();
     void testConditionalFormatContainsTextXLSX();
     void testConditionalFormatPriorityCheckXLSX();
+    void testConditionalFormatOriginXLSX();
     void testMiscRowHeightExport();
     void testNamedRangeBugfdo62729();
     void testBuiltinRangesXLSX();
@@ -240,6 +241,7 @@ public:
     CPPUNIT_TEST(testConditionalFormatRangeListXLSX);
     CPPUNIT_TEST(testConditionalFormatContainsTextXLSX);
     CPPUNIT_TEST(testConditionalFormatPriorityCheckXLSX);
+    CPPUNIT_TEST(testConditionalFormatOriginXLSX);
     CPPUNIT_TEST(testMiscRowHeightExport);
     CPPUNIT_TEST(testNamedRangeBugfdo62729);
     CPPUNIT_TEST(testBuiltinRangesXLSX);
@@ -3979,6 +3981,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::parseExport(*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 557ef69f3d93..8c0b6e5e3964 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -581,7 +581,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 );
@@ -589,6 +589,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.
@@ -610,9 +611,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 ),
@@ -628,6 +630,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. */
 
@@ -1053,7 +1059,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 );
     }
@@ -1077,10 +1083,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 ) )
 {
 }
 
@@ -1289,11 +1295,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 eabc51bc88f9..5102bf837179 100644
--- a/sc/source/filter/inc/xecontent.hxx
+++ b/sc/source/filter/inc/xecontent.hxx
@@ -170,7 +170,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;
commit baf7d49fe3a707cd39650d50b1591557031ac916
Author:     Markus Mohrhard <markus.mohrhard at googlemail.com>
AuthorDate: Sun Jul 15 00:35:21 2018 +0200
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Fri May 10 08:26:02 2019 +0200

    related tdf#117816, the dxf ID is a global and not a sheet property
    
    Change-Id: I4c5ca66ce550de74d8b9396aa0213c558b7f884f
    Reviewed-on: https://gerrit.libreoffice.org/57445
    Tested-by: Jenkins
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    (cherry picked from commit 0f0466c6498287c3eb790136655ac65f501b9f0f)
    Reviewed-on: https://gerrit.libreoffice.org/72008
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sc/qa/unit/data/contentCSV/new_cond_format_test_sheet2.csv b/sc/qa/unit/data/contentCSV/new_cond_format_test_sheet2.csv
index b35f4e58e25b..9bbdfede11ac 100644
--- a/sc/qa/unit/data/contentCSV/new_cond_format_test_sheet2.csv
+++ b/sc/qa/unit/data/contentCSV/new_cond_format_test_sheet2.csv
@@ -1,3 +1,3 @@
 2.00,2
-1,1.00
+1,1.000
 4.00,3
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 91b08673f936..c3cd6d49842f 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -2983,12 +2983,12 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
     mxFormatter->FillKeywordTableForExcel( *mpKeywordTable );
 
     SCTAB nTables = rRoot.GetDoc().GetTableCount();
+    sal_Int32 nIndex = 0;
     for(SCTAB nTab = 0; nTab < nTables; ++nTab)
     {
         ScConditionalFormatList* pList = rRoot.GetDoc().GetCondFormList(nTab);
         if (pList)
         {
-            sal_Int32 nIndex = 0;
             for (ScConditionalFormatList::const_iterator itr = pList->begin();
                     itr != pList->end(); ++itr)
             {


More information about the Libreoffice-commits mailing list