oox/source/export/drawingml.cxx              |    7 ++-
 sc/inc/colorscale.hxx                        |    2 
 sc/qa/unit/data/xlsx/tdf119565.xlsx          |binary
 sc/qa/unit/subsequent_export_test2.cxx       |   28 +++++++++++++
 sc/qa/unit/ucalc_condformat.cxx              |   52 +++++++++++++++++++++++++
 sc/source/core/data/colorscale.cxx           |   18 ++++++++
 sw/qa/extras/ooxmlexport/data/tdf138093.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx   |   56 +++++++++++++++++++++++++++
 writerfilter/source/dmapper/SdtHelper.cxx    |    4 +
 9 files changed, 164 insertions(+), 3 deletions(-)

New commits:
commit 63e1a98e07b12edd967cea48f23e307cf47efea8
Author:     Czeber László Ádám <czeber.laszloa...@nisz.hu>
AuthorDate: Tue Apr 18 15:01:14 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Apr 28 10:53:50 2023 +0200

    tdf#138093 DOCX import: fix broken date selector control in table
    
    In tables, first character of the text value of the date selector
    control left outside of the control during the import, resulting
    broken date selector, e.g. 2[023] instead of [2023]. (Clicking on
    the broken control, according to the year *023*, the selector listed
    the lowest possible value, year 1900, and selecting that, the result
    became 2[1900].)
    
    Note: the fix works well with nested tables, too, so likely the
    condition with tables is obsolete.
    
    Perhaps regression from commit b36ef83ea59eeaca239e58b95aa0b1acdcb99efc
    "tdf126701: MSForms: Fix import of date field at the end of the
    paragraph." and commit 68e1be4ccbb90ee9a788962219a88312c4ffbea2
    "MSForms: Rework text-based date form field's representation".
    
    Change-Id: Ib217a3a06522bfe7b3b0fbc884f98504f628fc59
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150575
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151053
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf138093.docx 
b/sw/qa/extras/ooxmlexport/data/tdf138093.docx
new file mode 100644
index 000000000000..097fbb1351cc
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf138093.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index ebb5ae15a87e..2f412a7d85f1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/drawing/XShapes.hpp>
 #include <com/sun/star/util/XRefreshable.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/awt/FontSlant.hpp>
 #include <com/sun/star/awt/FontWeight.hpp>
@@ -38,6 +39,7 @@
 #include <wrtsh.hxx>
 #include <IDocumentLayoutAccess.hxx>
 #include <rootfrm.hxx>
+#include <xmloff/odffields.hxx>
 
 class Test : public SwModelTestBase
 {
@@ -88,6 +90,60 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148380_createField, 
"tdf148380_createField.docx"
     CPPUNIT_ASSERT_EQUAL(OUString("yesterday at noon"), 
xField->getPresentation(false));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf138093, "tdf138093.docx")
+{
+    if (isExported())
+    {
+        xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+        assertXPath(pXmlDoc, "//w:sdt", 3);
+        uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+        uno::Reference<container::XIndexAccess> 
xTables(xTablesSupplier->getTextTables(),
+                                                        uno::UNO_QUERY);
+        uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+        uno::Reference<table::XCell> xCell = xTable->getCellByName("B1");
+        uno::Reference<container::XEnumerationAccess> xParagraphsAccess(xCell, 
uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xParagraphs
+            = xParagraphsAccess->createEnumeration();
+        uno::Reference<container::XEnumerationAccess> 
xParagraph(xParagraphs->nextElement(),
+                                                                 
uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xPortions = 
xParagraph->createEnumeration();
+        uno::Reference<beans::XPropertySet> 
xTextPortion(xPortions->nextElement(), uno::UNO_QUERY);
+
+        OUString aPortionType;
+        xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType;
+        CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType);
+
+        uno::Reference<text::XTextContent> xContentControl;
+        xTextPortion->getPropertyValue("ContentControl") >>= xContentControl;
+        uno::Reference<beans::XPropertySet> 
xContentControlProps(xContentControl, uno::UNO_QUERY);
+        bool bDate{};
+        xContentControlProps->getPropertyValue("Date") >>= bDate;
+        CPPUNIT_ASSERT(bDate);
+        uno::Reference<container::XEnumerationAccess> 
xContentControlEnumAccess(xContentControl,
+                                                                               
 uno::UNO_QUERY);
+        uno::Reference<container::XEnumeration> xContentControlEnum
+            = xContentControlEnumAccess->createEnumeration();
+        uno::Reference<text::XTextRange> 
xTextPortionRange(xContentControlEnum->nextElement(),
+                                                           uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(OUString("2017"), xTextPortionRange->getString());
+    }
+    else
+    {
+        SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+        CPPUNIT_ASSERT(pTextDoc);
+        SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+        IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMarkAccess->getAllMarksCount());
+
+        ::sw::mark::IDateFieldmark* pFieldmark
+            = 
dynamic_cast<::sw::mark::IDateFieldmark*>(*pMarkAccess->getAllMarksBegin());
+        CPPUNIT_ASSERT(pFieldmark);
+        CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), 
pFieldmark->GetFieldname());
+        CPPUNIT_ASSERT_EQUAL(OUString("2017"), pFieldmark->GetContent());
+    }
+}
+
+
 DECLARE_OOXMLEXPORT_TEST(testTdf148380_fldLocked, "tdf148380_fldLocked.docx")
 {
     getParagraph(2, "4/5/2022 4:29:00 PM");
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx 
b/writerfilter/source/dmapper/SdtHelper.cxx
index a6a6b6cb08f8..f71af1340884 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -380,8 +380,10 @@ void SdtHelper::createDateContentControl()
     try
     {
         xCrsr->gotoRange(m_xDateFieldStartRange, false);
+        // tdf#138093: Date selector reset, if placed inside table
+        // Modified to XOR relationship
         bool bIsInTable = (m_rDM_Impl.hasTableManager() && 
m_rDM_Impl.getTableManager().isInTable())
-                          || (m_rDM_Impl.m_nTableDepth > 0);
+                          != (m_rDM_Impl.m_nTableDepth > 0);
         if (bIsInTable)
             xCrsr->goRight(1, false);
         xCrsr->gotoEnd(true);
commit f2034af7eee1174481c4220decea51d00e8b8ab0
Author:     Tibor Nagy <nagy.tib...@nisz.hu>
AuthorDate: Mon Apr 24 09:08:14 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Apr 28 10:53:43 2023 +0200

    tdf#154906 tdf#129813 tdf#129814 sc: fix conditional format color scale
    
    This is a follow up to commit 3f614f431475e1bf3bb3bbeac59b0681309628b7
    (tdf#95295: don't add duplicate conditional formats)
    The above commit clearly describes how this fix works.
    
    Change-Id: I064fb3fe0443705553c6bbfcc34f2d717e0f6bd6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150899
    Tested-by: Jenkins
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151055

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index de74030dbc85..513eb11cf2f4 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -270,6 +270,8 @@ public:
     std::optional<Color> GetColor(const ScAddress& rAddr) const;
     void AddEntry(ScColorScaleEntry* pEntry);
 
+    bool IsEqual(const ScFormatEntry& r, bool bIgnoreSrcPos) const override;
+
     virtual void UpdateReference( sc::RefUpdateContext& rCxt ) override;
     virtual void UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) 
override;
     virtual void UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) 
override;
diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx
index b637d724ca6d..e523968e4e37 100644
--- a/sc/qa/unit/ucalc_condformat.cxx
+++ b/sc/qa/unit/ucalc_condformat.cxx
@@ -93,6 +93,7 @@ public:
     void testCondFormatInsertRow();
     void testCondFormatInsertCol();
     void testCondFormatInsertDeleteSheets();
+    void testColorScaleCondCopyPaste();
     void testCondCopyPaste();
     void testCondCopyPasteSingleCell(); //e.g. fdo#82503
     void testCondCopyPasteSingleCellToRange(); //e.g. fdo#82503
@@ -138,6 +139,7 @@ public:
     CPPUNIT_TEST(testCondFormatInsertRow);
     CPPUNIT_TEST(testCondFormatInsertCol);
     CPPUNIT_TEST(testCondFormatInsertDeleteSheets);
+    CPPUNIT_TEST(testColorScaleCondCopyPaste);
     CPPUNIT_TEST(testCondCopyPaste);
     CPPUNIT_TEST(testCondCopyPasteSingleCell);
     CPPUNIT_TEST(testCondCopyPasteSingleCellToRange);
@@ -351,6 +353,56 @@ void TestCondformat::testCondFormatInsertDeleteSheets()
     m_pDoc->DeleteTab(0);
 }
 
+void TestCondformat::testColorScaleCondCopyPaste()
+{
+    m_pDoc->InsertTab(0, "Test");
+
+    auto pFormat = std::make_unique<ScConditionalFormat>(1, m_pDoc);
+    ScRange aCondFormatRange(0, 0, 0, 2, 0, 0);
+    ScRangeList aRangeList(aCondFormatRange);
+    pFormat->SetRange(aRangeList);
+
+    ScColorScaleFormat* pColorScaleFormat = new ScColorScaleFormat(m_pDoc);
+    ScColorScaleEntry* pEntryBlue = new ScColorScaleEntry(0, COL_BLUE);
+    ScColorScaleEntry* pEntryGreen = new ScColorScaleEntry(1, COL_GREEN);
+    ScColorScaleEntry* pEntryRed = new ScColorScaleEntry(2, COL_RED);
+    pColorScaleFormat->AddEntry(pEntryBlue);
+    pColorScaleFormat->AddEntry(pEntryGreen);
+    pColorScaleFormat->AddEntry(pEntryRed);
+
+    pFormat->AddEntry(pColorScaleFormat);
+    sal_uLong nIndex = m_pDoc->AddCondFormat(std::move(pFormat), 0);
+
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    copyToClip(m_pDoc, aCondFormatRange, &aClipDoc);
+
+    ScRange aTargetRange(0, 3, 0, 2, 3, 0);
+    pasteFromClip(m_pDoc, aTargetRange, &aClipDoc);
+
+    // Pasting the same conditional format must modify existing format, making 
its range
+    // combined of previous range and newly pasted range having the 
conditional format.
+    // No new conditional formats must be created.
+    CPPUNIT_ASSERT_EQUAL(size_t(1), m_pDoc->GetCondFormList(0)->size());
+    aRangeList.Join(aTargetRange);
+    for (SCCOL nCol = 0; nCol < 3; ++nCol)
+    {
+        ScConditionalFormat* pPastedFormat = m_pDoc->GetCondFormat(nCol, 3, 0);
+        CPPUNIT_ASSERT(pPastedFormat);
+        CPPUNIT_ASSERT_EQUAL(aRangeList, pPastedFormat->GetRange());
+
+        sal_uLong nPastedKey = pPastedFormat->GetKey();
+        CPPUNIT_ASSERT_EQUAL(nIndex, nPastedKey);
+
+        const SfxPoolItem* pItem = m_pDoc->GetAttr(nCol, 3, 0, 
ATTR_CONDITIONAL);
+        const ScCondFormatItem* pCondFormatItem = static_cast<const 
ScCondFormatItem*>(pItem);
+        CPPUNIT_ASSERT(pCondFormatItem);
+        CPPUNIT_ASSERT_EQUAL(size_t(1), 
pCondFormatItem->GetCondFormatData().size());
+        CPPUNIT_ASSERT_EQUAL(sal_uInt32(nIndex), 
pCondFormatItem->GetCondFormatData().front());
+    }
+
+    m_pDoc->DeleteTab(0);
+}
+
 void TestCondformat::testCondCopyPaste()
 {
     m_pDoc->InsertTab(0, "Test");
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 0a357828c61e..192dd1cea78c 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -404,6 +404,24 @@ void ScColorScaleFormat::AddEntry( ScColorScaleEntry* 
pEntry )
     maColorScales.back()->SetRepaintCallback(mpParent);
 }
 
+bool ScColorScaleFormat::IsEqual(const ScFormatEntry& rOther, bool 
/*bIgnoreSrcPos*/) const
+{
+    if (GetType() != rOther.GetType())
+        return false;
+
+    const ScColorScaleFormat& r = static_cast<const 
ScColorScaleFormat&>(rOther);
+
+    for (size_t i = 0; i < maColorScales.size(); ++i)
+    {
+        if 
(!maColorScales[i]->GetColor().IsRGBEqual(r.maColorScales[i]->GetColor().GetRGBColor())
+            || maColorScales[i]->GetType() != r.maColorScales[i]->GetType()
+            || maColorScales[i]->GetValue() != r.maColorScales[i]->GetValue())
+            return false;
+    }
+
+    return true;
+}
+
 double ScColorScaleFormat::GetMinValue() const
 {
     ScColorScaleEntries::const_iterator itr = maColorScales.begin();
commit 6a865763291752af0975da8f5765443096ef5181
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Tue Apr 18 12:01:18 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Apr 28 10:53:35 2023 +0200

    tdf#119565 XLSX export: fix lost line properties inherited from theme
    
    Line properties (LineWidth and LineJoint) of shape
    inherited from theme lost after export.
    
    Perhaps regression from commit 5391d4872e71d1edba7acc4ad2d2e3b5b97e1723
    "ooxml: Preserve shape style and theme attributes for line".
    
    Change-Id: I9977bb20f16245f3c95ccbe2c5c8033b5b0c9cc4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150547
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150927
    Tested-by: Jenkins

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 4af853619967..f39951ade707 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1069,7 +1069,8 @@ void DrawingML::WriteOutline( const 
Reference<XPropertySet>& rXPropSet, Referenc
     mpFS->startElementNS( XML_a, XML_ln,
                           XML_cap, cap,
                           XML_w, 
sax_fastparser::UseIf(OString::number(nEmuLineWidth),
-                              nLineWidth == 0 || (nLineWidth > 1 && 
nStyleLineWidth != nLineWidth)) );
+                              nLineWidth == 0 || GetDocumentType() == 
DOCUMENT_XLSX    // tdf#119565 LO doesn't export the actual theme.xml in XLSX.
+                                  || (nLineWidth > 1 && nStyleLineWidth != 
nLineWidth)));
 
     if( bColorSet )
     {
@@ -1236,7 +1237,9 @@ void DrawingML::WriteOutline( const 
Reference<XPropertySet>& rXPropSet, Referenc
     {
         LineJoint eLineJoint = mAny.get<LineJoint>();
 
-        if( aStyleLineJoint == LineJoint_NONE || aStyleLineJoint != eLineJoint 
)
+        // tdf#119565 LO doesn't export the actual theme.xml in XLSX.
+        if (aStyleLineJoint == LineJoint_NONE || GetDocumentType() == 
DOCUMENT_XLSX
+            || aStyleLineJoint != eLineJoint)
         {
             // style-defined line joint does not exist, or is different from 
the shape's joint
             switch( eLineJoint )
diff --git a/sc/qa/unit/data/xlsx/tdf119565.xlsx 
b/sc/qa/unit/data/xlsx/tdf119565.xlsx
new file mode 100644
index 000000000000..de530c0131f2
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf119565.xlsx differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 32f557463ed3..56d7ac158151 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -42,6 +42,7 @@
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
+#include <com/sun/star/drawing/LineJoint.hpp>
 #include <com/sun/star/drawing/XDrawPage.hpp>
 #include <com/sun/star/drawing/XDrawPages.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
@@ -191,6 +192,7 @@ public:
     void testEmbeddedTextInDecimal();
     void testTotalsRowFunction();
     void testAutofilterHiddenButton();
+    void testTdf119565();
 
     CPPUNIT_TEST_SUITE(ScExportTest2);
 
@@ -322,6 +324,7 @@ public:
     CPPUNIT_TEST(testEmbeddedTextInDecimal);
     CPPUNIT_TEST(testTotalsRowFunction);
     CPPUNIT_TEST(testAutofilterHiddenButton);
+    CPPUNIT_TEST(testTdf119565);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -2941,6 +2944,31 @@ void ScExportTest2::testAutofilterHiddenButton()
     }
 }
 
+void ScExportTest2::testTdf119565()
+{
+    createScDoc("xlsx/tdf119565.xlsx");
+    saveAndReload("Calc Office Open XML");
+
+    uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, 
uno::UNO_QUERY_THROW);
+    uno::Reference<drawing::XDrawPage> 
xPage(xDoc->getDrawPages()->getByIndex(0),
+                                             uno::UNO_QUERY_THROW);
+    uno::Reference<beans::XPropertySet> xShapeProps(xPage->getByIndex(0), 
uno::UNO_QUERY_THROW);
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 35
+    // - Actual  : 0
+    // i.e. line width inherited from theme lost after export.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(35),
+                         
xShapeProps->getPropertyValue("LineWidth").get<sal_Int32>());
+
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 3
+    // - Actual  : 4
+    // i.e. line joint inherited from theme lost after export.
+    CPPUNIT_ASSERT_EQUAL(drawing::LineJoint_MITER,
+                         
xShapeProps->getPropertyValue("LineJoint").get<drawing::LineJoint>());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to