sc/qa/unit/data/xlsx/tdf117287_comment.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx       |   43 +++++++++++++++++++++++++---
 sc/source/filter/xcl97/xcl97rec.cxx         |   25 +++++-----------
 3 files changed, 47 insertions(+), 21 deletions(-)

New commits:
commit 7010edf9c3cd1a602417421980092dee9ce7ea94
Author:     Ilhan Yesil <ilhanye...@gmx.de>
AuthorDate: Mon Sep 3 12:57:01 2018 +0200
Commit:     Katarina Behrens <katarina.behr...@cib.de>
CommitDate: Wed Sep 5 10:39:57 2018 +0200

    tdf#117287 When saving as Xlsx, export visible flag if comment is visble
    
    The visible flag will be exported now, when a comment is visible and
    the file is saved as Xlsx.
    
    Change-Id: Id05ab5f94ea85f48db123d1043ecdc4813a64382
    Reviewed-on: https://gerrit.libreoffice.org/59934
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <katarina.behr...@cib.de>

diff --git a/sc/qa/unit/data/xlsx/tdf117287_comment.xlsx 
b/sc/qa/unit/data/xlsx/tdf117287_comment.xlsx
new file mode 100644
index 000000000000..486bdef90f84
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf117287_comment.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 596cfe751e20..5d0f1dce5313 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -121,6 +121,7 @@ public:
     void testFormatExportODS();
 
     void testCommentExportXLSX();
+    void testCommentExportXLSX_2_XLSX();
 #if HAVE_MORE_FONTS
     void testCustomColumnWidthExportXLSX();
 #endif
@@ -242,8 +243,8 @@ public:
     CPPUNIT_TEST(testCellNoteExportODS);
     CPPUNIT_TEST(testCellNoteExportXLS);
     CPPUNIT_TEST(testFormatExportODS);
-
     CPPUNIT_TEST(testCommentExportXLSX);
+    CPPUNIT_TEST(testCommentExportXLSX_2_XLSX);
 #if HAVE_MORE_FONTS
     CPPUNIT_TEST(testCustomColumnWidthExportXLSX);
 #endif
@@ -698,8 +699,10 @@ void ScExportTest::testCommentExportXLSX()
     ScDocShellRef xShell = loadDoc("comment.", FORMAT_ODS);
     CPPUNIT_ASSERT(xShell.is());
 
-    std::shared_ptr<utl::TempFile> pXPathFile = 
ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
-    const xmlDocPtr pComments = XPathHelper::parseExport(pXPathFile, 
m_xSFactory, "xl/comments1.xml");
+    std::shared_ptr<utl::TempFile> pXPathFile
+        = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+    const xmlDocPtr pComments
+        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/comments1.xml");
     CPPUNIT_ASSERT(pComments);
 
     assertXPath(pComments, "/x:comments/x:authors/x:author[1]", "BAKO");
@@ -707,7 +710,8 @@ void ScExportTest::testCommentExportXLSX()
 
     assertXPath(pComments, 
"/x:comments/x:commentList/x:comment/x:text/x:r/x:t", "Komentarz");
 
-    const xmlDocPtr pVmlDrawing = XPathHelper::parseExport(pXPathFile, 
m_xSFactory, "xl/drawings/vmlDrawing1.vml");
+    const xmlDocPtr pVmlDrawing
+        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/drawings/vmlDrawing1.vml");
     CPPUNIT_ASSERT(pVmlDrawing);
 
     //assertXPath(pVmlDrawing, "/xml/v:shapetype", "coordsize", "21600,21600");
@@ -720,6 +724,37 @@ void ScExportTest::testCommentExportXLSX()
     assertXPath(pVmlDrawing, "/xml/v:shape/v:shadow", "obscured", "t");
 }
 
+void ScExportTest::testCommentExportXLSX_2_XLSX()
+{
+    //tdf#117287 FILESAVE XLSX: Comments always disappear after opening the 
exported XLSX file with Excel
+    ScDocShellRef xShell = loadDoc("tdf117287_comment.", FORMAT_XLSX);
+    CPPUNIT_ASSERT(xShell.is());
+
+
+    ScDocument& rDoc = xShell->GetDocument();
+    ScAddress aPosC9(2, 8, 0);
+    ScPostIt *pNote = rDoc.GetNote(aPosC9);
+
+    CPPUNIT_ASSERT(pNote);
+    CPPUNIT_ASSERT(!pNote->IsCaptionShown());
+
+    pNote->ShowCaption(aPosC9, true);
+
+    std::shared_ptr<utl::TempFile> pXPathFile
+        = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+    const xmlDocPtr pComments
+        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/comments1.xml");
+    CPPUNIT_ASSERT(pComments);
+
+    assertXPath(pComments, 
"/x:comments/x:commentList/x:comment/x:text/x:r/x:t", "visible comment");
+
+    const xmlDocPtr pVmlDrawing
+        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/drawings/vmlDrawing1.vml");
+    CPPUNIT_ASSERT(pVmlDrawing);
+
+    assertXPath(pVmlDrawing, "/xml/v:shape/x:ClientData/x:Visible", 0);
+}
+
 #if HAVE_MORE_FONTS
 void ScExportTest::testCustomColumnWidthExportXLSX()
 {
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx 
b/sc/source/filter/xcl97/xcl97rec.cxx
index a23ad826ed7c..b1e082154374 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -537,22 +537,10 @@ static void lcl_FillProps( EscherPropertyContainer& 
rPropOpt, SdrObject* pCaptio
             if( !rPropOpt.GetOpt( ESCHER_Prop_FitTextToShape, nValue ) )
                 rPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 );     
 // bool field
 
-            if( rPropOpt.GetOpt( ESCHER_Prop_fillColor, nValue ) )
-            {
-                // If the Colour is the same as the 'ToolTip' System colour 
then
-                // use the default rather than the explicit colour value. This 
will
-                // be incorrect where user has chosen to use this colour 
explicitly.
-                Color aColor( static_cast<sal_uInt8>(nValue), 
static_cast<sal_uInt8>( nValue >> 8 ), static_cast<sal_uInt8>( nValue >> 16 ) );
-                const StyleSettings& rSett = 
Application::GetSettings().GetStyleSettings();
-                if( aColor == rSett.GetHelpColor() )
-                {
-                    rPropOpt.AddOpt( ESCHER_Prop_fillColor, 0x08000050 );
-                    rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0x08000050 );
-                }
-            }
-            else
-                rPropOpt.AddOpt( ESCHER_Prop_fillColor, 0x08000050 );
-
+            // Maybe the colour is the same as the 'ToolTip' System colour, 
but the tooltip
+            // colour shouldn't have influence on the fill colour of the 
exported shape
+            if( !rPropOpt.GetOpt( ESCHER_Prop_fillColor, nValue ) )
+                 rPropOpt.AddOpt( ESCHER_Prop_fillColor, 0x08000050 );
             if( !rPropOpt.GetOpt( ESCHER_Prop_fillBackColor, nValue ) )
                 rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0x08000050 );
             if( !rPropOpt.GetOpt( ESCHER_Prop_fNoFillHitTest, nValue ) )
@@ -682,7 +670,10 @@ void VmlCommentExporter::EndShape( sal_Int32 nShapeElement 
)
     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Anchor ), pAnchor 
);
     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_AutoFill ), 
"False" );
     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Row ), 
maScPos.Row() );
-    XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Column ), 
sal_Int32( maScPos.Col() ) );
+    XclXmlUtils::WriteElement( pVmlDrawing, FSNS(XML_x, XML_Column), 
sal_Int32(maScPos.Col()));
+    if(mbVisible)
+        pVmlDrawing->singleElement( FSNS(XML_x, XML_Visible),
+            FSEND);
     pVmlDrawing->endElement( FSNS( XML_x, XML_ClientData ) );
 
     VMLExport::EndShape( nShapeElement );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to