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

Tor Lillqvist tml at collabora.com
Wed Mar 8 12:53:14 UTC 2017


 sc/qa/unit/data/ods/comment.ods       |binary
 sc/qa/unit/subsequent_export-test.cxx |   21 +++++++++++++++++++++
 sc/source/filter/excel/excdoc.cxx     |    8 +++++---
 sc/source/filter/excel/xecontent.cxx  |   18 ++++++++++++++----
 sc/source/filter/excel/xeescher.cxx   |    9 +++++++++
 sc/source/filter/excel/xestyle.cxx    |    2 ++
 sc/source/filter/inc/xecontent.hxx    |    3 ++-
 sc/source/filter/inc/xestream.hxx     |    4 ++--
 sc/source/filter/inc/xltable.hxx      |    2 +-
 sc/source/filter/xcl97/xcl97rec.cxx   |   21 ++++++++++++++++++++-
 10 files changed, 76 insertions(+), 12 deletions(-)

New commits:
commit fb644433728e0648ec0952b2b805fddf7569dc3e
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Mar 8 09:50:46 2017 +0200

    Re-introduce a check I dropped in 47b5f3a07236bb07a681e99e509c78e3af18c0b5
    
    Without fully understanding the code, best to let the condition be
    there. Use the same function to check for validity as before.
    (IsValid() which was renamed to IsValidForXml().)
    
    (cherry picked from commit a77908a2d82986ad9d2d9597536d1e22ce2cafd2)
    
    Change-Id: If50df539737352f12cb0178706cbc38512a99366

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index e691de7..7448b18 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1454,7 +1454,8 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtL
                         itr != pCondFmtList->end(); ++itr)
         {
             XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), **itr, xExtLst, nIndex ));
-            maCondfmtList.AppendRecord( xCondfmtRec );
+            if( xCondfmtRec->IsValidForXml() )
+                maCondfmtList.AppendRecord( xCondfmtRec );
         }
     }
 }
commit a0ce73f4ebfa4fae1f229b417d9595f1124f34ba
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Mar 7 22:40:55 2017 +0200

    A 'CondFmt' record can have a maximum of three CF records following (eek)
    
    What an odd restriction. Oh well. Don't export the conditional formats
    for the cell(s) in that case then.
    
    See https://msdn.microsoft.com/en-us/library/03AE6098-BDC2-475B-BA2C-B8AEF7882174
    
    Change-Id: I4eeec8d33f9fbc572a02f727f38564d6c43b4f10

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 1f5418d..e691de7 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1246,14 +1246,24 @@ XclExpCondfmt::~XclExpCondfmt()
 {
 }
 
-bool XclExpCondfmt::IsValid() const
+bool XclExpCondfmt::IsValidForBinary() const
+{
+    // ccf (2 bytes): An unsigned integer that specifies the count of CF records that follow this
+    // record. MUST be greater than or equal to 0x0001, and less than or equal to 0x0003.
+
+    SAL_WARN_IF( maCFList.GetSize() > 3, "sc.filter", "More than 3 conditional filters for cell(s), won't export");
+
+    return !maCFList.IsEmpty() && maCFList.GetSize() <= 3 && !maXclRanges.empty();
+}
+
+bool XclExpCondfmt::IsValidForXml() const
 {
     return !maCFList.IsEmpty() && !maXclRanges.empty();
 }
 
 void XclExpCondfmt::Save( XclExpStream& rStrm )
 {
-    if( IsValid() )
+    if( IsValidForBinary() )
     {
         XclExpRecord::Save( rStrm );
         maCFList.Save( rStrm );
@@ -1273,7 +1283,7 @@ void XclExpCondfmt::WriteBody( XclExpStream& rStrm )
 
 void XclExpCondfmt::SaveXml( XclExpXmlStream& rStrm )
 {
-    if( !IsValid() )
+    if( !IsValidForXml() )
         return;
 
     sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
@@ -1444,8 +1454,7 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot, XclExtL
                         itr != pCondFmtList->end(); ++itr)
         {
             XclExpCondfmtList::RecordRefType xCondfmtRec( new XclExpCondfmt( GetRoot(), **itr, xExtLst, nIndex ));
-            if( xCondfmtRec->IsValid() )
-                maCondfmtList.AppendRecord( xCondfmtRec );
+            maCondfmtList.AppendRecord( xCondfmtRec );
         }
     }
 }
diff --git a/sc/source/filter/inc/xecontent.hxx b/sc/source/filter/inc/xecontent.hxx
index ba1ff95..f283787 100644
--- a/sc/source/filter/inc/xecontent.hxx
+++ b/sc/source/filter/inc/xecontent.hxx
@@ -232,7 +232,8 @@ public:
     virtual             ~XclExpCondfmt();
 
     /** Returns true, if this conditional format contains at least one cell range and CF record. */
-    bool                IsValid() const;
+    bool                IsValidForBinary() const;
+    bool                IsValidForXml() const;
 
     /** Writes the CONDFMT record with following CF records, if there is valid data. */
     virtual void        Save( XclExpStream& rStrm ) override;
commit d94a8044445d57f05f7e927f9046f479d676f4ea
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Mar 7 21:53:34 2017 +0200

    Make sure that the 'stAuthor' field of a 'NoteSh' structure filfills the spec
    
    Its length must be greater than or equal to 1 and less than or equal
    to 54, so if the author is empty, use a single space, and otherwise
    truncate to max 54 characters.
    
    See https://msdn.microsoft.com/en-us/library/dd945371
    
    Change-Id: I7604ae9e1d8eea336b42116ea7d305e183e6ca51
    (cherry picked from commit 27e34a7dbb9aa2ce52ca529ec835d54c6a5508fc)

diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index 2513fb1..086b7df 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -1207,7 +1207,13 @@ XclExpNote::XclExpNote( const XclExpRoot& rRoot, const ScAddress& rScPos,
                     mbRowHidden = (rRoot.GetDoc().RowHidden(maScPos.Row(),maScPos.Tab()));
                     mbColHidden = (rRoot.GetDoc().ColHidden(maScPos.Col(),maScPos.Tab()));
                 }
-                maAuthor = XclExpString( pScNote->GetAuthor() );
+                // stAuthor (variable): An XLUnicodeString that specifies the name of the comment
+                // author. String length MUST be greater than or equal to 1 and less than or equal
+                // to 54.
+                if( pScNote->GetAuthor().isEmpty() )
+                    maAuthor = XclExpString( " " );
+                else
+                    maAuthor = XclExpString( pScNote->GetAuthor(), EXC_STR_DEFAULT, 54 );
             }
 
             SetRecSize( 9 + maAuthor.GetSize() );
commit b61abf2d3d8638ace8abd08911b06a3ab1478799
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
Date:   Sat Dec 17 10:53:12 2016 +0100

    tdf#104729 FILESAVE Save author name in comment during export to .xlsx
    
    Change-Id: I59d46f6a713e4f252844cda0f631ace239d73cdb
    Reviewed-on: https://gerrit.libreoffice.org/32115
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>
    (cherry picked from commit 36cdf3c35459df63ce137e550a6840a61865c0ca)

diff --git a/sc/qa/unit/data/ods/comment.ods b/sc/qa/unit/data/ods/comment.ods
new file mode 100644
index 0000000..b772a6f
Binary files /dev/null and b/sc/qa/unit/data/ods/comment.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 2746e85..f0ec98f 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -108,6 +108,8 @@ public:
     void testCellNoteExportXLS();
     void testFormatExportODS();
 
+
+    void testCommentExportXLSX();
     void testCustomColumnWidthExportXLSX();
     void testXfDefaultValuesXLSX();
     void testColumnWidthResaveXLSX();
@@ -189,6 +191,7 @@ public:
     CPPUNIT_TEST(testCellNoteExportXLS);
     CPPUNIT_TEST(testFormatExportODS);
 
+    CPPUNIT_TEST(testCommentExportXLSX);
     CPPUNIT_TEST(testCustomColumnWidthExportXLSX);
     CPPUNIT_TEST(testXfDefaultValuesXLSX);
     CPPUNIT_TEST(testColumnWidthResaveXLSX);
@@ -467,6 +470,24 @@ void ScExportTest::testFormatExportODS()
     xDocSh->DoClose();
 }
 
+
+void ScExportTest::testCommentExportXLSX()
+{
+    //tdf#104729 FILESAVE OpenOffice do not save author of the comment during export to .xlsx
+    ScDocShellRef xShell = loadDoc("comment.", FORMAT_ODS);
+    CPPUNIT_ASSERT(xShell.Is());
+
+    std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+    xmlDocPtr pSheet = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/comments1.xml");
+    CPPUNIT_ASSERT(pSheet);
+
+    assertXPath(pSheet, "/x:comments/x:authors/x:author[1]", "BAKO");
+    assertXPath(pSheet, "/x:comments/x:authors/x:author", 1);
+
+    assertXPath(pSheet, "/x:comments/x:commentList/x:comment/x:text/x:r/x:t", "Komentarz");
+
+}
+
 void ScExportTest::testCustomColumnWidthExportXLSX()
 {
     //tdf#100946 FILESAVE Excel on OS X ignored column widths in XLSX last saved by LO
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index a835a43..2513fb1 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -1187,6 +1187,7 @@ XclExpNote::XclExpNote( const XclExpRoot& rRoot, const ScAddress& rScPos,
         {
             // TODO: additional text
             if( pScNote )
+            {
                 if( SdrCaptionObj* pCaption = pScNote->GetOrCreateCaption( maScPos ) )
                 {
                     lcl_GetFromTo( rRoot, pCaption->GetLogicRect(), maScPos.Tab(), maCommentFrom, maCommentTo );
@@ -1206,6 +1207,8 @@ XclExpNote::XclExpNote( const XclExpRoot& rRoot, const ScAddress& rScPos,
                     mbRowHidden = (rRoot.GetDoc().RowHidden(maScPos.Row(),maScPos.Tab()));
                     mbColHidden = (rRoot.GetDoc().ColHidden(maScPos.Col(),maScPos.Tab()));
                 }
+                maAuthor = XclExpString( pScNote->GetAuthor() );
+            }
 
             SetRecSize( 9 + maAuthor.GetSize() );
         }
commit f72628f71f80915749eb0b9a746e1454981fc9f7
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Mar 7 20:38:34 2017 +0200

    Write the 'FtNts' subrecord of 'Obj' when necessary
    
    See https://msdn.microsoft.com/en-us/library/dd952807 :
    
    nts (26 bytes): An optional FtNts structure that specifies the
    properties of this comment object. This field MUST exist if and only
    if cmo.ot is equal to 0x19.
    
    Change-Id: Ib4a007940c29a4f8eac1087601cfc7d242cfebd3
    (cherry picked from commit 20a7d4b16d600101f4073ad4ce669a7566bf14c1)

diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index 8f5ac14..7e69b90 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -33,6 +33,7 @@
 #include <tools/urlobj.hxx>
 
 #include <rtl/math.hxx>
+#include <rtl/uuid.h>
 #include <svl/zformat.hxx>
 #include "formulacell.hxx"
 #include "drwlayer.hxx"
@@ -461,8 +462,26 @@ void XclObj::Save( XclExpStream& rStrm )
     SaveTextRecs( rStrm );
 }
 
-void XclObj::WriteSubRecs( XclExpStream& /*rStrm*/ )
+void XclObj::WriteSubRecs( XclExpStream& rStrm )
 {
+    if( mnObjType == EXC_OBJTYPE_NOTE )
+    {
+        // FtNts subrecord
+        AddRecSize( 26 );
+        // ft, cb
+        rStrm << EXC_ID_OBJNTS << sal_uInt16(0x0016);
+        sal_uInt8 aGUID[16];
+        rtl_createUuid( aGUID, nullptr, false );
+        // guid
+        rStrm.SetSliceSize( 16 );
+        for( int i = 0; i < 16; i++ )
+            rStrm << aGUID[i];
+        rStrm.SetSliceSize( 0 );
+        // fSharedNote
+        rStrm << sal_uInt16(0);
+        // unused
+        rStrm.WriteZeroBytes( 4 );
+    }
 }
 
 void XclObj::SaveTextRecs( XclExpStream& rStrm )
commit fba05d0979da9d70ae9b9fe7186fe7679ff8011a
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Mar 7 18:20:55 2017 +0200

    It's SetSliceSize, not SetSliceLen
    
    Change-Id: Ife4449f5afa7321c18e8eb963878d9c037f6d623
    (cherry picked from commit 93a53e0ebba62873c768d887c6aa1125967aa9e4)

diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx
index dd10a6f..15592f0 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -61,9 +61,9 @@ typedef std::shared_ptr< XclExpBiff8Encrypter > XclExpEncrypterRef;
     If some data exceeds the record size limit, a CONTINUE record is started automatically
     and the new data will be written to this record.
 
-    If specific data pieces must not be splitted, use SetSliceLen(). For instance:
+    If specific data pieces must not be splitted, use SetSliceSize(). For instance:
     To write a sequence of 16-bit values, where 4 values form a unit and cannot be
-    split, call SetSliceLen( 8 ) first (4*2 bytes == 8).
+    split, call SetSliceSize( 8 ) first (4*2 bytes == 8).
 
     To write unicode character arrays, call WriteUnicodeBuffer(). It creates CONTINUE
     records and repeats the unicode string flag byte automatically. This function is used
commit 4dc3fe8288da5d09b52028da7dbe6627a8a00ecf
Author: Tor Lillqvist <tml at collabora.com>
Date:   Tue Mar 7 13:55:53 2017 +0200

    Use symbolic constants instead of hardcoded numbers
    
    The constants were commented out, so uncomment them.
    
    Probably lots of the same left.
    
    Change-Id: Iac87bef3bc331ae126741efbb4d58cc539e5a42a

diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 925a522..1c3546e 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -56,6 +56,7 @@
 #include "excdoc.hxx"
 #include "namebuff.hxx"
 #include "xeextlst.hxx"
+#include "biffhelper.hxx"
 
 #include "xcl97rec.hxx"
 #include "xcl97esc.hxx"
@@ -105,7 +106,7 @@ static void lcl_AddCalcPr( XclExpRecordList<>& aRecList, ExcTable& self )
     aRecList.AppendNewRecord( new XclRefmode( rDoc ) );
     aRecList.AppendNewRecord( new XclIteration( rDoc ) );
     aRecList.AppendNewRecord( new XclDelta( rDoc ) );
-    aRecList.AppendNewRecord( new XclExpBoolRecord(0x005F, true) ); // SAVERECALC
+    aRecList.AppendNewRecord( new XclExpBoolRecord(oox::xls::BIFF_ID_SAVERECALC, true) );
     aRecList.AppendNewRecord( new XclExpXmlEndSingleElementRecord() );  // XML_calcPr
 }
 
@@ -510,9 +511,9 @@ void ExcTable::FillAsTableBinary( SCTAB nCodeNameIdx )
     if (pTabProtect && pTabProtect->isProtected())
     {
         Add( new XclExpProtection(true) );
-        Add( new XclExpBoolRecord(0x00DD, pTabProtect->isOptionEnabled(ScTableProtection::SCENARIOS)) );
+        Add( new XclExpBoolRecord(oox::xls::BIFF_ID_SCENPROTECT, pTabProtect->isOptionEnabled(ScTableProtection::SCENARIOS)) );
         if (pTabProtect->isOptionEnabled(ScTableProtection::OBJECTS))
-            Add( new XclExpBoolRecord(0x0063, true ));
+            Add( new XclExpBoolRecord(oox::xls::BIFF_ID_OBJECTPROTECT, true ));
         Add( new XclExpPassHash(pTabProtect->getPasswordHash(PASSHASH_XL)) );
     }
 
commit 65e57811d61b95391b3f598d90b703893ecf64f5
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Mar 6 20:42:46 2017 +0200

    The 'fLockObj' field of an 'ObjProtect' MUST be 0x0001 says the spec
    
    So generate such a record only when the protection state is on.
    
    See https://msdn.microsoft.com/en-us/library/dd922139(v=office.12).aspx
    
    Change-Id: I710395527cd53dc47018806e51fcc699e11fb461
    (cherry picked from commit 4a332d54b80bbc502ccc98bf924a269e00c10070)

diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index 75a7677..925a522 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -511,7 +511,8 @@ void ExcTable::FillAsTableBinary( SCTAB nCodeNameIdx )
     {
         Add( new XclExpProtection(true) );
         Add( new XclExpBoolRecord(0x00DD, pTabProtect->isOptionEnabled(ScTableProtection::SCENARIOS)) );
-        Add( new XclExpBoolRecord(0x0063, pTabProtect->isOptionEnabled(ScTableProtection::OBJECTS)) );
+        if (pTabProtect->isOptionEnabled(ScTableProtection::OBJECTS))
+            Add( new XclExpBoolRecord(0x0063, true ));
         Add( new XclExpPassHash(pTabProtect->getPasswordHash(PASSHASH_XL)) );
     }
 
commit 1c8684d644d4a711999125c73a548a520d86fd91
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Mar 6 20:28:02 2017 +0200

    The 'reserved1' bit of a 'Formula' MUST be zero according to current spec
    
    See https://msdn.microsoft.com/en-us/library/dd908919(v=office.12).aspx .
    
    This means we will never set the EXC_FORMULA_RECALC_ONLOAD flag, hmm?
    
    Change-Id: Ic081caa7f98426394cbc7b0b320fa1a5a9a34f6c
    (cherry picked from commit 727ee3f92a8882914ac3f68eaf53ac519ace5f38)

diff --git a/sc/source/filter/inc/xltable.hxx b/sc/source/filter/inc/xltable.hxx
index 4d06dd2..44aea94 100644
--- a/sc/source/filter/inc/xltable.hxx
+++ b/sc/source/filter/inc/xltable.hxx
@@ -65,7 +65,7 @@ const sal_uInt16 EXC_ID4_FORMULA            = 0x0406;
 const sal_uInt16 EXC_FORMULA_RECALC_ALWAYS  = 0x0001;
 const sal_uInt16 EXC_FORMULA_RECALC_ONLOAD  = 0x0002;
 const sal_uInt16 EXC_FORMULA_SHARED         = 0x0008;
-const sal_uInt16 EXC_FORMULA_DEFAULTFLAGS   = EXC_FORMULA_RECALC_ONLOAD;
+const sal_uInt16 EXC_FORMULA_DEFAULTFLAGS   = 0x0000;
 
 const sal_uInt8 EXC_FORMULA_RES_STRING      = 0x00;     /// Result is a string.
 const sal_uInt8 EXC_FORMULA_RES_BOOL        = 0x01;     /// Result is Boolean value.
commit 77db32a75540cf2aacb5727927deff5cad6bfa7c
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Mar 6 20:11:24 2017 +0200

    Set the 'unused2' bit of 'Font' to 1 iff 'uls' is greater than 0 per spec
    
    See https://msdn.microsoft.com/en-us/library/dd906117(v=office.12).aspx .
    
    Change-Id: I4ff278f4cdd388947bbe81b88b6c39ff2b208b1a
    (cherry picked from commit 970f8dc7847967719652590f71f0f19e46ba7268)

diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 39697ac..c11cd98 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -992,6 +992,8 @@ void XclExpFont::WriteBody( XclExpStream& rStrm )
 {
     sal_uInt16 nAttr = EXC_FONTATTR_NONE;
     ::set_flag( nAttr, EXC_FONTATTR_ITALIC, maData.mbItalic );
+    if( maData.mnUnderline > 0 )
+        ::set_flag( nAttr, EXC_FONTATTR_UNDERLINE, true );
     ::set_flag( nAttr, EXC_FONTATTR_STRIKEOUT, maData.mbStrikeout );
     ::set_flag( nAttr, EXC_FONTATTR_OUTLINE, maData.mbOutline );
     ::set_flag( nAttr, EXC_FONTATTR_SHADOW, maData.mbShadow );


More information about the Libreoffice-commits mailing list