[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - 3 commits - i18npool/Module_i18npool.mk sw/inc sw/qa sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Aug 9 13:17:38 UTC 2018


 i18npool/Module_i18npool.mk                    |    2 -
 sw/inc/tblafmt.hxx                             |    7 +++++
 sw/qa/extras/htmlimport/data/reqif-table.xhtml |   33 +++++++++++++++++++++++++
 sw/qa/extras/htmlimport/htmlimport.cxx         |   18 +++++++++++++
 sw/source/core/doc/tblafmt.cxx                 |   10 +++++++
 sw/source/core/docnode/ndtbl.cxx               |   13 +++------
 sw/source/filter/html/htmltab.cxx              |   21 +++++++++++++++
 sw/source/filter/html/swhtml.cxx               |    5 +++
 sw/source/filter/html/swhtml.hxx               |    5 +++
 9 files changed, 104 insertions(+), 10 deletions(-)

New commits:
commit b279fea89d9cdc82ae2d4b16f31dc8e3fe93892e
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Thu Aug 9 15:05:28 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Aug 9 15:11:14 2018 +0200

    sw HTML import: don't assume default table autoformat is set by the UI
    
    This is not needed on master (towards 6.2), but the 5.4 insert table UI
    doesn't use the default table autoformat when inserting a table.
    
    Given that the HTML import is expected match the behavior of the UI,
    adapt the previous.
    
    Change-Id: Ia44acb8da23c212c823ab13c396a3716d4fcab38

diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index 6c52704d6e2b..94eeacaa705f 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -339,6 +339,7 @@ public:
      * cell in a given table.
      */
     static sal_uInt8 CountPos(sal_uInt32 nCol, sal_uInt32 nCols, sal_uInt32 nRow, sal_uInt32 nRows);
+    static void SetDefaultBoxAttr( SwFrameFormat& rFormat, sal_uInt8 nId, bool bForceNoHtml = false );
 };
 
 class SW_DLLPUBLIC SwTableAutoFormatTable
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index 53ba20616c47..91e33f863d07 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -264,6 +264,9 @@ DECLARE_HTMLIMPORT_TEST(testReqIfTable, "reqif-table.xhtml")
     // This was 0, tables had no borders, even if the default autoformat has
     // borders and the markup allows no custom borders.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(2), aBorder.LineWidth);
+
+    // This was 0x000080 (~blue), table format didn't match the default UI one.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xCell, "BackColor"));
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index ae9e3874de5c..c848d3459f57 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -106,7 +106,7 @@ using namespace ::com::sun::star;
 
 const sal_Unicode T2T_PARA = 0x0a;
 
-static void lcl_SetDfltBoxAttr( SwFrameFormat& rFormat, sal_uInt8 nId )
+void SwTableAutoFormat::SetDefaultBoxAttr( SwFrameFormat& rFormat, sal_uInt8 nId, bool bForceNoHtml )
 {
     bool bTop = false, bBottom = false, bLeft = false, bRight = false;
     switch ( nId )
@@ -117,7 +117,7 @@ static void lcl_SetDfltBoxAttr( SwFrameFormat& rFormat, sal_uInt8 nId )
     case 3: bBottom = bLeft = bRight = true;        break;
     }
 
-    const bool bHTML = rFormat.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE);
+    const bool bHTML = rFormat.getIDocumentSettingAccess().get(DocumentSettingId::HTML_MODE) && !bForceNoHtml;
     Color aCol( bHTML ? COL_GRAY : COL_BLACK );
     SvxBorderLine aLine( &aCol, DEF_LINE_WIDTH_0 );
     if ( bHTML )
@@ -171,7 +171,7 @@ lcl_SetDfltBoxAttr(SwTableBox& rBox, DfltBoxAttrList_t & rBoxFormatArr,
                                     SwTableAutoFormat::UPDATE_BOX,
                                     pDoc->GetNumberFormatter() );
         else
-            ::lcl_SetDfltBoxAttr( *pNewTableBoxFormat, nId );
+            SwTableAutoFormat::SetDefaultBoxAttr( *pNewTableBoxFormat, nId );
 
         (*pMap)[pBoxFrameFormat] = pNewTableBoxFormat;
     }
@@ -187,7 +187,7 @@ static SwTableBoxFormat *lcl_CreateDfltBoxFormat( SwDoc &rDoc, std::vector<SwTab
         if( USHRT_MAX != nCols )
             pBoxFormat->SetFormatAttr( SwFormatFrameSize( ATT_VAR_SIZE,
                                             USHRT_MAX / nCols, 0 ));
-        ::lcl_SetDfltBoxAttr( *pBoxFormat, nId );
+        SwTableAutoFormat::SetDefaultBoxAttr( *pBoxFormat, nId );
         rBoxFormatArr[ nId ] = pBoxFormat;
     }
     return rBoxFormatArr[nId];
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 18f6bdcc8693..46888e64f5fe 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -1502,20 +1502,10 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
         if (m_pParser->IsReqIF())
         {
             // ReqIF case, cells would have no formatting. Apply the default
-            // table autoformat on them, so imported and UI-created tables look
+            // box attributes on them, so imported and UI-created tables look
             // the same.
-            SwTableAutoFormatTable& rTable = m_pParser->GetDoc()->GetTableStyles();
-            SwTableAutoFormat* pTableFormat = rTable.FindAutoFormat(
-                SwStyleNameMapper::GetUIName(RES_POOLTABSTYLE_DEFAULT, OUString()));
-            if (pTableFormat)
-            {
-                sal_uInt8 nPos = SwTableAutoFormat::CountPos(nCol, m_nCols, nRow, m_nRows);
-                pTableFormat->UpdateToSet(nPos,
-                                          const_cast<SfxItemSet&>(static_cast<SfxItemSet const&>(
-                                              pFrameFormat->GetAttrSet())),
-                                          SwTableAutoFormat::UPDATE_BOX,
-                                          pFrameFormat->GetDoc()->GetNumberFormatter());
-            }
+            sal_uInt8 nPos = (nCol < m_nCols - 1 ? 0 : 1) + (nRow ? 2 : 0 );
+            SwTableAutoFormat::SetDefaultBoxAttr(*pFrameFormat, nPos, /*bForceNoHtml=*/true);
         }
     }
     else
commit efabdef1f739ba7cf244c4b5e56a37a8787fb2d0
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Wed Aug 8 14:15:23 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Aug 9 14:21:46 2018 +0200

    sw HTML import: apply default table autoformat on cells in reqif mode
    
    The reqif xhtml subset doesn't allow formatting of cells, which means
    that the tables created with the UI and imported tables look different,
    e.g. the later ones have no borders.
    
    Fix this inconsistency by applying the default table autoformat during
    import (in reqif mode). The import result looks better this way, and the
    export will ignore it anyway.
    
    Reviewed-on: https://gerrit.libreoffice.org/58741
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins
    (cherry picked from commit 63c91b9cb3f73b66a915875721b0efd65b8aebac)
    
    Conflicts:
            sw/qa/extras/htmlimport/htmlimport.cxx
            sw/source/filter/html/htmltab.cxx
            sw/source/filter/html/swhtml.hxx
    
    Change-Id: I310770594e7a00e62f23d9df8cb16c2b95e1e44a

diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index 5092eddb6cc1..6c52704d6e2b 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -333,6 +333,12 @@ public:
     OUString GetTableTemplateCellSubName(const SwBoxAutoFormat& rBoxFormat) const;
     /// Returns a vector of indexes in aBoxAutoFormat array. Returned indexes points to cells which are mapped to a table-template.
     static const std::vector<sal_Int32>& GetTableTemplateMap();
+
+    /**
+     * Calculates the relevant position in the table autoformat for a given
+     * cell in a given table.
+     */
+    static sal_uInt8 CountPos(sal_uInt32 nCol, sal_uInt32 nCols, sal_uInt32 nRow, sal_uInt32 nRows);
 };
 
 class SW_DLLPUBLIC SwTableAutoFormatTable
diff --git a/sw/qa/extras/htmlimport/data/reqif-table.xhtml b/sw/qa/extras/htmlimport/data/reqif-table.xhtml
new file mode 100644
index 000000000000..242201de817d
--- /dev/null
+++ b/sw/qa/extras/htmlimport/data/reqif-table.xhtml
@@ -0,0 +1,33 @@
+<reqif-xhtml:div><reqif-xhtml:p>Before.</reqif-xhtml:p>
+<reqif-xhtml:table width="100%" cellpadding="4" cellspacing="0">
+	<reqif-xhtml:col width="128*"/>
+
+	<reqif-xhtml:col width="128*"/>
+
+	<reqif-xhtml:tr valign="top">
+		<reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none">
+			<reqif-xhtml:br/>
+
+			</reqif-xhtml:p>
+		</reqif-xhtml:td>
+		<reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none">
+			<reqif-xhtml:br/>
+
+			</reqif-xhtml:p>
+		</reqif-xhtml:td>
+	</reqif-xhtml:tr>
+	<reqif-xhtml:tr valign="top">
+		<reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none">
+			<reqif-xhtml:br/>
+
+			</reqif-xhtml:p>
+		</reqif-xhtml:td>
+		<reqif-xhtml:td><reqif-xhtml:p align="left" style="text-decoration: none">
+			<reqif-xhtml:br/>
+
+			</reqif-xhtml:p>
+		</reqif-xhtml:td>
+	</reqif-xhtml:tr>
+</reqif-xhtml:table>
+<reqif-xhtml:p>After.</reqif-xhtml:p>
+</reqif-xhtml:div>
diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx
index 02e2417a2b0e..53ba20616c47 100644
--- a/sw/qa/extras/htmlimport/htmlimport.cxx
+++ b/sw/qa/extras/htmlimport/htmlimport.cxx
@@ -251,6 +251,21 @@ DECLARE_HTMLIMPORT_TEST(testReqIfBr, "reqif-br.xhtml")
     CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("aaa\nbbb"));
 }
 
+DECLARE_HTMLIMPORT_TEST(testReqIfTable, "reqif-table.xhtml")
+{
+    // Load a table with xhtmlns=reqif-xhtml filter param.
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
+                                                    uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xTables->getCount());
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
+    auto aBorder = getProperty<table::BorderLine2>(xCell, "TopBorder");
+    // This was 0, tables had no borders, even if the default autoformat has
+    // borders and the markup allows no custom borders.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(2), aBorder.LineWidth);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index b258620d0774..40129504f13b 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -1135,6 +1135,16 @@ const std::vector<sal_Int32>& SwTableAutoFormat::GetTableTemplateMap()
     return *pTableTemplateMap;
 }
 
+sal_uInt8 SwTableAutoFormat::CountPos(sal_uInt32 nCol, sal_uInt32 nCols, sal_uInt32 nRow,
+                                      sal_uInt32 nRows)
+{
+    sal_uInt8 nRet = static_cast<sal_uInt8>(
+        !nRow ? 0 : ((nRow + 1 == nRows) ? 12 : (4 * (1 + ((nRow - 1) & 1)))));
+    nRet = nRet
+           + static_cast<sal_uInt8>(!nCol ? 0 : (nCol + 1 == nCols ? 3 : (1 + ((nCol - 1) & 1))));
+    return nRet;
+}
+
 struct SwTableAutoFormatTable::Impl
 {
     std::vector<std::unique_ptr<SwTableAutoFormat>> m_AutoFormats;
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 7c6305e01151..ae9e3874de5c 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -491,10 +491,7 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTableOpts,
             SwTableBoxFormat *pBoxF;
             if( pTAFormat )
             {
-                sal_uInt8 nId = static_cast<sal_uInt8>(!n ? 0 : (( n+1 == nRows )
-                                        ? 12 : (4 * (1 + ((n-1) & 1 )))));
-                nId = nId + static_cast<sal_uInt8>( !i ? 0 :
-                            ( i+1 == nCols ? 3 : (1 + ((i-1) & 1))));
+                sal_uInt8 nId = SwTableAutoFormat::CountPos(i, nCols, n, nRows);
                 pBoxF = ::lcl_CreateAFormatBoxFormat( *this, aBoxFormatArr, *pTAFormat,
                                                 nCols, nId );
 
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 0a499420f247..18f6bdcc8693 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -57,6 +57,8 @@
 #include "swhtml.hxx"
 #include "swcss1.hxx"
 #include <numrule.hxx>
+#include <tblafmt.hxx>
+#include <SwStyleNameMapper.hxx>
 
 #define NETSCAPE_DFLT_BORDER 1
 #define NETSCAPE_DFLT_CELLSPACING 2
@@ -1076,6 +1078,16 @@ HTMLTable::HTMLTable( SwHTMLParser* pPars, HTMLTable *pTopTab,
         m_pColumns->push_back(o3tl::make_unique<HTMLTableColumn>());
 }
 
+SwDoc* SwHTMLParser::GetDoc() const
+{
+    return m_xDoc.get();
+}
+
+bool SwHTMLParser::IsReqIF() const
+{
+    return m_bReqIF;
+}
+
 HTMLTable::~HTMLTable()
 {
     delete m_pResizeDrawObjects;
@@ -1486,6 +1498,25 @@ void HTMLTable::FixFrameFormat( SwTableBox *pBox,
             pFrameFormat->ResetFormatAttr( RES_VERT_ORIENT );
             pFrameFormat->ResetFormatAttr( RES_BOXATR_FORMAT );
         }
+
+        if (m_pParser->IsReqIF())
+        {
+            // ReqIF case, cells would have no formatting. Apply the default
+            // table autoformat on them, so imported and UI-created tables look
+            // the same.
+            SwTableAutoFormatTable& rTable = m_pParser->GetDoc()->GetTableStyles();
+            SwTableAutoFormat* pTableFormat = rTable.FindAutoFormat(
+                SwStyleNameMapper::GetUIName(RES_POOLTABSTYLE_DEFAULT, OUString()));
+            if (pTableFormat)
+            {
+                sal_uInt8 nPos = SwTableAutoFormat::CountPos(nCol, m_nCols, nRow, m_nRows);
+                pTableFormat->UpdateToSet(nPos,
+                                          const_cast<SfxItemSet&>(static_cast<SfxItemSet const&>(
+                                              pFrameFormat->GetAttrSet())),
+                                          SwTableAutoFormat::UPDATE_BOX,
+                                          pFrameFormat->GetDoc()->GetNumberFormatter());
+            }
+        }
     }
     else
     {
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 434ff5d82d2e..2dc52ea140e9 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -5581,8 +5581,11 @@ void SwHTMLParser::SetupFilterOptions()
     const OUString aXhtmlNsKey("xhtmlns=");
     if (aFilterOptions.startsWith(aXhtmlNsKey))
     {
-        SetNamespace(aFilterOptions.copy(aXhtmlNsKey.getLength()));
+        OUString aNamespace = aFilterOptions.copy(aXhtmlNsKey.getLength());
+        SetNamespace(aNamespace);
         m_bXHTML = true;
+        if (aNamespace == "reqif-xhtml")
+            m_bReqIF = true;
     }
 }
 
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index c20e791f62b8..05aa01fa6431 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -483,6 +483,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
     SfxViewFrame* m_pTempViewFrame;
 
     bool m_bXHTML = false;
+    bool m_bReqIF = false;
 
     /**
      * Non-owning pointers to already inserted OLE nodes, matching opened
@@ -905,6 +906,10 @@ public:
     virtual bool ParseMetaOptions( const css::uno::Reference<css::document::XDocumentProperties>&,
             SvKeyValueIterator* ) override;
 
+    SwDoc* GetDoc() const;
+
+    bool IsReqIF() const;
+
     /// Strips query and fragment from a URL path if base URL is a file:// one.
     static OUString StripQueryFromPath(const OUString& rBase, const OUString& rPath);
 };
commit f32f180558efd21d4808bdc15868cb7dbcc657d6
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Thu Aug 9 13:35:38 2018 +0200
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Aug 9 13:35:38 2018 +0200

    i18npool: disable CppunitTest_i18npool_test_breakiterator for system icu
    
    The internal icu doesn't build with gcc7 on this vendor branch, but the
    system one results in this test failing. Disable the test so other test
    failures can be noticed fast.
    
    Change-Id: I7405e2f465fa7930b291a06de800508c0d18e31e

diff --git a/i18npool/Module_i18npool.mk b/i18npool/Module_i18npool.mk
index 022d053a6f50..58f2ce533c03 100644
--- a/i18npool/Module_i18npool.mk
+++ b/i18npool/Module_i18npool.mk
@@ -39,7 +39,7 @@ $(eval $(call gb_Module_add_targets_for_build,i18npool,\
 ))
 
 $(eval $(call gb_Module_add_check_targets,i18npool,\
-	CppunitTest_i18npool_test_breakiterator \
+	$(if $(SYSTEM_ICU),,CppunitTest_i18npool_test_breakiterator) \
 	CppunitTest_i18npool_test_characterclassification \
 	CppunitTest_i18npool_test_ordinalsuffix \
 	CppunitTest_i18npool_test_textsearch \


More information about the Libreoffice-commits mailing list