[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3-desktop' - 5 commits - sal/osl sal/rtl svtools/source sw/qa sw/source

Mike Kaganski mike.kaganski at collabora.com
Fri Jan 19 05:04:51 UTC 2018


 sal/osl/unx/file_volume.cxx               |    9 ++++-
 sal/rtl/alloc_arena.cxx                   |    7 ++++
 svtools/source/contnr/treelistbox.cxx     |    7 +---
 sw/qa/extras/uiwriter/data/datasource.ods |binary
 sw/qa/extras/uiwriter/uiwriter.cxx        |   49 ++++++++++++++++++++++++++++++
 sw/source/filter/ww8/ww8atr.cxx           |   44 ++++++++++++++++++++++++++
 6 files changed, 108 insertions(+), 8 deletions(-)

New commits:
commit 1d828cbd4b6f424b0f10f6336afef8aa1b5fd341
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Wed Jan 17 12:41:41 2018 +0300

    tdf#115013: quote columns with spaces and properly escape characters
    
    Unit test updated
    
    Change-Id: If36c90c0ff372ce45666674d2487e6edf2536dbf
    Reviewed-on: https://gerrit.libreoffice.org/48038
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/48078
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit 2425c5cc08b150c9b1b9a6f542b2f5b46a695b40)

diff --git a/sw/qa/extras/uiwriter/data/datasource.ods b/sw/qa/extras/uiwriter/data/datasource.ods
index 076659679575..81d78440656e 100644
Binary files a/sw/qa/extras/uiwriter/data/datasource.ods and b/sw/qa/extras/uiwriter/data/datasource.ods differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 6a065e712bea..5c96aacf7a1e 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -4647,7 +4647,9 @@ void SwUiWriterTest::testTdf104492()
 
 void SwUiWriterTest::testTdf115013()
 {
-    //create new writer document
+   const OUString sColumnName("Name with spaces, \"quotes\" and \\backslashes");
+
+   //create new writer document
     SwDoc* pDoc = createDoc();
 
     {
@@ -4663,7 +4665,7 @@ void SwUiWriterTest::testTdf115013()
         SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
         CPPUNIT_ASSERT(pWrtShell);
         SwDBFieldType* pFieldType = static_cast<SwDBFieldType*>(pWrtShell->InsertFieldType(
-            SwDBFieldType(pDoc, "Name", aDBData)));
+            SwDBFieldType(pDoc, sColumnName, aDBData)));
         CPPUNIT_ASSERT(pFieldType);
 
         // Insert the field into document
@@ -4686,7 +4688,7 @@ void SwUiWriterTest::testTdf115013()
     CPPUNIT_ASSERT(pField);
     OUString sColumn = static_cast<SwDBFieldType*>(pField->GetTyp())->GetColumnName();
     // The column name must come correct after round trip
-    CPPUNIT_ASSERT_EQUAL(OUString("Name"), sColumn);
+    CPPUNIT_ASSERT_EQUAL(sColumnName, sColumn);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index abb637f923a4..7e90c2a27029 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2458,6 +2458,46 @@ void WW8AttributeOutput::WriteExpand( const SwField* pField )
     SwWW8Writer::WriteString16( m_rWW8Export.Strm(), sExpand, false );
 }
 
+namespace
+{
+// Escapes a token string for storing in Word formats. Its import counterpart
+// is lcl_ExtractToken in writerfilter/source/dmapper/DomainMapper_Impl.cxx
+OUString EscapeToken(const OUString& rCommand)
+{
+    bool bWasEscaped = false;
+
+    const int nBufferLen = rCommand.getLength()*1.5;
+    OUStringBuffer sResult(nBufferLen);
+    sResult.append('"'); // opening quote
+    for (sal_Int32 i = 0; i < rCommand.getLength(); ++i)
+    {
+        sal_Unicode ch = rCommand[i];
+        switch (ch)
+        {
+        case '\\':
+        case '"':
+            // Backslashes and doublequotes must be escaped
+            bWasEscaped = true;
+            sResult.append('\\');
+            break;
+        case ' ':
+            // Spaces require quotation
+            bWasEscaped = true;
+            break;
+        }
+        sResult.append(ch);
+    }
+
+    if (bWasEscaped)
+    {
+        sResult.append('"'); // closing quote
+        return sResult.makeStringAndClear();
+    }
+    // No escapement/quotation was required
+    return rCommand;
+}
+}
+
 void AttributeOutputBase::TextField( const SwFormatField& rField )
 {
     const SwField* pField = rField.GetField();
@@ -2535,7 +2575,8 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
         break;
     case RES_DBFLD:
         {
-            OUString sStr = FieldString(ww::eMERGEFIELD) + static_cast<SwDBFieldType *>(pField->GetTyp())->GetColumnName() + " ";
+            OUString sStr = FieldString(ww::eMERGEFIELD)
+                + EscapeToken(static_cast<SwDBFieldType *>(pField->GetTyp())->GetColumnName()) + " ";
             GetExport().OutputField(pField, ww::eMERGEFIELD, sStr);
         }
         break;
commit eb8da99e08ad01f8a6436e8107a6188f4a7f1a7d
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Tue Jan 16 09:40:11 2018 +0300

    tdf#115013: write merge field column into docx merge fields
    
    Change-Id: If1e0a8968407c72e42cb7ca487541d0b8227aabc
    Reviewed-on: https://gerrit.libreoffice.org/47895
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/47975
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit 93c9a14134eb4afbfd7819ac3b4482d109c0c2f3)

diff --git a/sw/qa/extras/uiwriter/data/datasource.ods b/sw/qa/extras/uiwriter/data/datasource.ods
new file mode 100644
index 000000000000..076659679575
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/datasource.ods differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index d022e2fb26c6..6a065e712bea 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -55,6 +55,7 @@
 #include <editeng/fontitem.hxx>
 #include <editeng/wghtitem.hxx>
 #include <reffld.hxx>
+#include <dbfld.hxx>
 #include <txatbase.hxx>
 #include <ftnidx.hxx>
 #include <txtftn.hxx>
@@ -240,6 +241,7 @@ public:
     void testTdf107976();
     void testCreateDocxAnnotation();
     void testTdf113790();
+    void testTdf115013();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -368,6 +370,7 @@ public:
     CPPUNIT_TEST(testTdf107976);
     CPPUNIT_TEST(testCreateDocxAnnotation);
     CPPUNIT_TEST(testTdf113790);
+    CPPUNIT_TEST(testTdf115013);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4642,6 +4645,50 @@ void SwUiWriterTest::testTdf104492()
     assertXPath(pXmlDoc, "//page", 3);
 }
 
+void SwUiWriterTest::testTdf115013()
+{
+    //create new writer document
+    SwDoc* pDoc = createDoc();
+
+    {
+        // Load and register data source
+        const OUString aDataSourceURI(m_directories.getURLFromSrc(DATA_DIRECTORY) + "datasource.ods");
+        OUString sDataSource = SwDBManager::LoadAndRegisterDataSource(aDataSourceURI, nullptr, nullptr, nullptr);
+        CPPUNIT_ASSERT(!sDataSource.isEmpty());
+
+        // Insert a new field type for the mailmerge field
+        SwDBData aDBData;
+        aDBData.sDataSource = sDataSource;
+        aDBData.sCommand = "Sheet1";
+        SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+        CPPUNIT_ASSERT(pWrtShell);
+        SwDBFieldType* pFieldType = static_cast<SwDBFieldType*>(pWrtShell->InsertFieldType(
+            SwDBFieldType(pDoc, "Name", aDBData)));
+        CPPUNIT_ASSERT(pFieldType);
+
+        // Insert the field into document
+        SwDBField aField(pFieldType);
+        pWrtShell->Insert(aField);
+    }
+    // Save it as DOCX & load it again
+    reload("Office Open XML Text", "mm-field.docx");
+
+    CPPUNIT_ASSERT(mxComponent.get());
+    pDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get())->GetDocShell()->GetDoc();
+    CPPUNIT_ASSERT(pDoc);
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+    SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
+    CPPUNIT_ASSERT(pCursor);
+
+    // Get the field at the beginning of the document
+    SwDBField* pField = dynamic_cast<SwDBField*>(SwCursorShell::GetFieldAtCursor(pCursor, true));
+    CPPUNIT_ASSERT(pField);
+    OUString sColumn = static_cast<SwDBFieldType*>(pField->GetTyp())->GetColumnName();
+    // The column name must come correct after round trip
+    CPPUNIT_ASSERT_EQUAL(OUString("Name"), sColumn);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index f8d35a0edae1..abb637f923a4 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -122,6 +122,7 @@
 #include <chpfld.hxx>
 #include <fmthdft.hxx>
 #include <authfld.hxx>
+#include <dbfld.hxx>
 
 #include <sprmids.hxx>
 
@@ -2534,7 +2535,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
         break;
     case RES_DBFLD:
         {
-            OUString sStr = FieldString(ww::eMERGEFIELD) + pField->GetPar1() + " ";
+            OUString sStr = FieldString(ww::eMERGEFIELD) + static_cast<SwDBFieldType *>(pField->GetTyp())->GetColumnName() + " ";
             GetExport().OutputField(pField, ww::eMERGEFIELD, sStr);
         }
         break;
commit 542795fc32f4703f205cd74a3281c913ead43aed
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 28 14:34:17 2017 +0100

    Resolves: tdf#112656 don't reset to default font if a custom font was set
    
    the list has been laid out with the smaller custom font, including
    calculating the bounding box of the entry, then rendered with the
    default larger font
    
    Change-Id: I2ae569c9857d4e1016cbf55da4c3334c63dcf5f6
    Reviewed-on: https://gerrit.libreoffice.org/42910
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 3043863d688c5bbd5101ebd5ddd8a9452e05ca50)
    Reviewed-on: https://gerrit.libreoffice.org/43031
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit f9c6022d109062d9b13339463f363892b2439d7d)
    (cherry picked from commit d157eb5469348d2aeccfd405fd20b013ca6e7761)

diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx
index 0ee0c866b67c..c88dc8f5ec26 100644
--- a/svtools/source/contnr/treelistbox.cxx
+++ b/svtools/source/contnr/treelistbox.cxx
@@ -3592,12 +3592,9 @@ void SvTreeListBox::StateChanged( StateChangedType eType )
 
 void SvTreeListBox::ApplySettings(vcl::RenderContext& rRenderContext)
 {
-    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
-    vcl::Font aFont;
-    aFont = rStyleSettings.GetFieldFont();
-    aFont.SetColor(rStyleSettings.GetWindowTextColor());
-    SetPointFont(rRenderContext, aFont);
+    SetPointFont(rRenderContext, GetPointFont(*this));
 
+    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
     rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor());
     rRenderContext.SetTextFillColor();
     rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
commit 73cc320bf3dfa30277b4dd444f6414b9d187fd90
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Feb 23 12:10:08 2017 +0100

    -Werror=format-truncation
    
    Change-Id: I1b27289724389018bd4048573e8c8e4cf28eb983
    (cherry picked from commit 280cd27dbdab438e63ecb2599ab5dd20e04d71d5)
    (cherry picked from commit 778c9d539326309abc93652cc06fbe8b28c8a0a1)

diff --git a/sal/osl/unx/file_volume.cxx b/sal/osl/unx/file_volume.cxx
index 28ce4a9762a4..722b18dd564e 100644
--- a/sal/osl/unx/file_volume.cxx
+++ b/sal/osl/unx/file_volume.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <cassert>
+
 #include "osl/file.h"
 
 #include "osl/diagnose.h"
@@ -353,7 +357,7 @@ static rtl_uString* oslMakeUStrFromPsz(const sal_Char* pszStr, rtl_uString** ust
 oslFileError osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath )
 {
     oslVolumeDeviceHandleImpl* pItem = static_cast<oslVolumeDeviceHandleImpl*>(Handle);
-    sal_Char Buffer[PATH_MAX];
+    sal_Char Buffer[RTL_CONSTASCII_LENGTH("file://") + PATH_MAX];
 
     Buffer[0] = '\0';
 
@@ -367,7 +371,8 @@ oslFileError osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uSt
         return osl_File_E_INVAL;
     }
 
-    snprintf(Buffer, sizeof(Buffer), "file://%s", pItem->pszMountPoint);
+    int n = snprintf(Buffer, sizeof(Buffer), "file://%s", pItem->pszMountPoint);
+    assert(n >= 0 && unsigned(n) < sizeof(Buffer)); (void) n;
 
 #ifdef DEBUG_OSL_FILE
     fprintf(stderr,"Mount Point is: '%s'\n",Buffer);
commit e8974c1384abe27cba41e011cba1119dd95d37c5
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed May 3 10:12:45 2017 +0200

    Work around GCC 7 mis-feature
    
    <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80354> "Poor support to silence
    -Wformat-truncation=1"
    
    Change-Id: I486f8a3a12896df3d9506f53bca44a318e23c991
    (cherry picked from commit 1b12d5ecb1be36267534e0b980d7c53d50645511)
    (cherry picked from commit b4f26014c380ecc3d93875a161747da489db72e4)

diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx
index 234a3d5c6755..941f26b9a196 100644
--- a/sal/rtl/alloc_arena.cxx
+++ b/sal/rtl/alloc_arena.cxx
@@ -669,6 +669,10 @@ rtl_arena_destructor (void * obj)
 
 /** rtl_arena_activate()
  */
+#if defined __GNUC__ && __GNUC__ >= 7
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-truncation"
+#endif
 rtl_arena_type *
 rtl_arena_activate (
     rtl_arena_type *   arena,
@@ -716,6 +720,9 @@ rtl_arena_activate (
             {
                 size = i * arena->m_quantum;
                 (void) snprintf (namebuf, sizeof(namebuf), "%s_%" SAL_PRIuUINTPTR, arena->m_name, size);
+#if defined __GNUC__ && __GNUC__ >= 7
+#pragma GCC diagnostic pop
+#endif
                 arena->m_qcache_ptr[i - 1] = rtl_cache_create(namebuf, size, 0, nullptr, nullptr, nullptr, nullptr, arena, RTL_CACHE_FLAG_QUANTUMCACHE);
             }
         }


More information about the Libreoffice-commits mailing list