sc/qa/unit/data/xml/wrap-and-shrink.xml |   82 ++++++++++++++++++++++++++++++++
 sc/qa/unit/subsequent_filters_test2.cxx |   34 +++++++++++++
 sc/source/filter/orcus/interface.cxx    |    6 ++
 3 files changed, 122 insertions(+)

New commits:
commit 14c0efccba84a002050d081c961bb0b6e90b009f
Author:     Kohei Yoshida <ko...@libreoffice.org>
AuthorDate: Thu Jan 26 19:41:16 2023 -0500
Commit:     Kohei Yoshida <ko...@libreoffice.org>
CommitDate: Fri Jan 27 01:38:03 2023 +0000

    tdf#147620: Pick up wrap-text and shrink-to-fit flags in Excel 2003 XML
    
    Change-Id: I8afd0522b441a90b431ff433ff87e0c095c8cb95
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146222
    Tested-by: Jenkins
    Reviewed-by: Kohei Yoshida <ko...@libreoffice.org>

diff --git a/sc/qa/unit/data/xml/wrap-and-shrink.xml 
b/sc/qa/unit/data/xml/wrap-and-shrink.xml
new file mode 100644
index 000000000000..429110c64399
--- /dev/null
+++ b/sc/qa/unit/data/xml/wrap-and-shrink.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0"?>
+<?mso-application progid="Excel.Sheet"?>
+<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
+ xmlns:o="urn:schemas-microsoft-com:office:office"
+ xmlns:x="urn:schemas-microsoft-com:office:excel"
+ xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
+ xmlns:html="http://www.w3.org/TR/REC-html40";>
+ <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
+  <Author>Kohei Yoshida</Author>
+  <LastAuthor>Kohei Yoshida</LastAuthor>
+  <Created>2022-05-18T00:46:32Z</Created>
+  <LastSaved>2022-05-18T01:44:54Z</LastSaved>
+  <Version>16.00</Version>
+ </DocumentProperties>
+ <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
+  <AllowPNG/>
+ </OfficeDocumentSettings>
+ <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
+  <WindowHeight>15990</WindowHeight>
+  <WindowWidth>29040</WindowWidth>
+  <WindowTopX>32767</WindowTopX>
+  <WindowTopY>32767</WindowTopY>
+  <ProtectStructure>False</ProtectStructure>
+  <ProtectWindows>False</ProtectWindows>
+ </ExcelWorkbook>
+ <Styles>
+  <Style ss:ID="Default" ss:Name="Normal">
+   <Alignment ss:Vertical="Bottom"/>
+   <Borders/>
+   <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" 
ss:Color="#000000"/>
+   <Interior/>
+   <NumberFormat/>
+   <Protection/>
+  </Style>
+  <Style ss:ID="s16">
+   <Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
+  </Style>
+  <Style ss:ID="s17">
+   <Alignment ss:Vertical="Bottom" ss:ShrinkToFit="1"/>
+  </Style>
+ </Styles>
+ <Worksheet ss:Name="Sheet1">
+  <Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="3" x:FullColumns="1"
+   x:FullRows="1" ss:DefaultRowHeight="15">
+   <Column ss:AutoFitWidth="0" ss:Width="85.5"/>
+   <Column ss:AutoFitWidth="0" ss:Width="88.5"/>
+   <Row>
+    <Cell><Data ss:Type="String">Default</Data></Cell>
+    <Cell><Data ss:Type="String">Text long enough to spill over</Data></Cell>
+   </Row>
+   <Row ss:Height="30">
+    <Cell><Data ss:Type="String">Wrap text</Data></Cell>
+    <Cell ss:StyleID="s16"><Data ss:Type="String">Text long enough to spill 
over</Data></Cell>
+   </Row>
+   <Row>
+    <Cell><Data ss:Type="String">Shrink to fit</Data></Cell>
+    <Cell ss:StyleID="s17"><Data ss:Type="String">Text long enough to spill 
over</Data></Cell>
+   </Row>
+  </Table>
+  <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
+   <PageSetup>
+    <Header x:Margin="0.3"/>
+    <Footer x:Margin="0.3"/>
+    <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
+   </PageSetup>
+   <Print>
+    <ValidPrinterInfo/>
+    <VerticalResolution>0</VerticalResolution>
+   </Print>
+   <Selected/>
+   <Panes>
+    <Pane>
+     <Number>3</Number>
+     <ActiveRow>9</ActiveRow>
+     <ActiveCol>14</ActiveCol>
+    </Pane>
+   </Panes>
+   <ProtectObjects>False</ProtectObjects>
+   <ProtectScenarios>False</ProtectScenarios>
+  </WorksheetOptions>
+ </Worksheet>
+</Workbook>
diff --git a/sc/qa/unit/subsequent_filters_test2.cxx 
b/sc/qa/unit/subsequent_filters_test2.cxx
index da79b48af6b5..56e5e85ecdf6 100644
--- a/sc/qa/unit/subsequent_filters_test2.cxx
+++ b/sc/qa/unit/subsequent_filters_test2.cxx
@@ -153,6 +153,7 @@ public:
     void testHiddenRowsColumnsXLSXML();
     void testColumnWidthRowHeightXLSXML();
     void testCharacterSetXLSXML();
+    void testWrapAndShrinkXLSXML();
     void testTdf137091();
     void testTdf141495();
     void testTdf70455();
@@ -272,6 +273,7 @@ public:
     CPPUNIT_TEST(testHiddenRowsColumnsXLSXML);
     CPPUNIT_TEST(testColumnWidthRowHeightXLSXML);
     CPPUNIT_TEST(testCharacterSetXLSXML);
+    CPPUNIT_TEST(testWrapAndShrinkXLSXML);
     CPPUNIT_TEST(testCondFormatFormulaListenerXLSX);
     CPPUNIT_TEST(testTdf137091);
     CPPUNIT_TEST(testTdf141495);
@@ -1986,6 +1988,38 @@ void ScFiltersTest2::testCharacterSetXLSXML()
     CPPUNIT_ASSERT_EQUAL(aExpected, aVal);
 }
 
+void ScFiltersTest2::testWrapAndShrinkXLSXML()
+{
+    createScDoc("xml/wrap-and-shrink.xml");
+    ScDocument* pDoc = getScDoc();
+
+    CPPUNIT_ASSERT_EQUAL(SCTAB(1), pDoc->GetTableCount());
+
+    struct Check
+    {
+        SCCOL nCol;
+        SCROW nRow;
+
+        bool bWrapText;
+        bool bShrinkToFit;
+    };
+
+    constexpr Check aChecks[] = {
+        { 1, 0, false, false },
+        { 1, 1, true, false },
+        { 1, 2, false, true },
+    };
+
+    for (const auto& rC : aChecks)
+    {
+        const ScLineBreakCell* pLB = pDoc->GetAttr(rC.nCol, rC.nRow, 0, 
ATTR_LINEBREAK);
+        CPPUNIT_ASSERT_EQUAL(pLB->GetValue(), rC.bWrapText);
+
+        const ScShrinkToFitCell* pSTF = pDoc->GetAttr(rC.nCol, rC.nRow, 0, 
ATTR_SHRINKTOFIT);
+        CPPUNIT_ASSERT_EQUAL(pSTF->GetValue(), rC.bShrinkToFit);
+    }
+}
+
 void ScFiltersTest2::testCondFormatXLSB()
 {
     createScDoc("xlsb/cond_format.xlsb");
diff --git a/sc/source/filter/orcus/interface.cxx 
b/sc/source/filter/orcus/interface.cxx
index a26beeb5a19c..1563a46f6299 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -2258,6 +2258,12 @@ void ScOrcusStyles::applyXfToItemSet( SfxItemSet& rSet, 
const ScOrcusXf& rXf )
         rSet.Put(SvxJustifyMethodItem(rXf.meHorAlignMethod, 
ATTR_HOR_JUSTIFY_METHOD));
         rSet.Put(SvxJustifyMethodItem(rXf.meVerAlignMethod, 
ATTR_VER_JUSTIFY_METHOD));
     }
+
+    if (rXf.mbWrapText)
+        rSet.Put(ScLineBreakCell(*rXf.mbWrapText));
+
+    if (rXf.mbShrinkToFit)
+        rSet.Put(ScShrinkToFitCell(*rXf.mbShrinkToFit));
 }
 
 void ScOrcusStyles::applyXfToItemSet( SfxItemSet& rSet, std::size_t xfId )

Reply via email to