[Libreoffice-commits] core.git: 2 commits - sw/inc sw/qa

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Wed Dec 17 17:52:00 PST 2014


 sw/inc/ndindex.hxx                 |    2 -
 sw/qa/extras/uiwriter/uiwriter.cxx |   44 +++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit e57b0ebeb7e75d36546f6abef3a26a8edc7dea7f
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Dec 17 23:12:27 2014 +0100

    fdo#85876: add unittest
    
    rather uglyish unittest, but still worth it as cutting nothing needing
    to have sideeffects is really kind of non-obvious and prone to return
    
    Change-Id: I02bbfb05f019874d873670cdae060ac3183f5ca6

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 313df37..5de79d3 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -7,6 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <com/sun/star/awt/FontWeight.hpp>
 #include <com/sun/star/i18n/TextConversionOption.hpp>
 #include <swmodeltestbase.hxx>
 #include <ndtxt.hxx>
@@ -29,6 +30,11 @@
 #include <svx/svdpage.hxx>
 #include <svx/svdview.hxx>
 
+#include <editeng/eeitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/wghtitem.hxx>
+
 #include "UndoManager.hxx"
 
 static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/";
@@ -65,6 +71,7 @@ public:
     void testMergeDoc();
     void testCreatePortions();
     void testBookmarkUndo();
+    void testFdo85876();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -93,6 +100,7 @@ public:
     CPPUNIT_TEST(testMergeDoc);
     CPPUNIT_TEST(testCreatePortions);
     CPPUNIT_TEST(testBookmarkUndo);
+    CPPUNIT_TEST(testFdo85876);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -716,6 +724,42 @@ void SwUiWriterTest::testBookmarkUndo()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pMarkAccess->getAllMarksCount());
 }
 
+static void lcl_setWeight(SwWrtShell* pWrtShell, FontWeight aWeight)
+{
+    SvxWeightItem aWeightItem(aWeight, EE_CHAR_WEIGHT);
+    SvxScriptSetItem aScriptSetItem(SID_ATTR_CHAR_WEIGHT, pWrtShell->GetAttrPool());
+    aScriptSetItem.PutItemForScriptType(SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX, aWeightItem);
+    pWrtShell->SetAttrSet(aScriptSetItem.GetItemSet());
+}
+
+void SwUiWriterTest::testFdo85876()
+{
+    SwDoc* const pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    lcl_setWeight(pWrtShell, WEIGHT_BOLD);
+    pWrtShell->Insert("test");
+    lcl_setWeight(pWrtShell, WEIGHT_NORMAL);
+    pWrtShell->SplitNode();
+    pWrtShell->SplitNode();
+    pWrtShell->Up(false);
+    pWrtShell->Insert("test");
+    auto xText = getParagraph(1)->getText();
+    CPPUNIT_ASSERT(xText.is());
+    {
+        auto xCursor(xText->createTextCursorByRange(getParagraph(1)));
+        CPPUNIT_ASSERT(xCursor.is());
+        xCursor->collapseToStart();
+        CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xCursor, "CharWeight"));
+    }
+    {
+        auto xCursor(xText->createTextCursorByRange(getParagraph(2)));
+        CPPUNIT_ASSERT(xCursor.is());
+        xCursor->collapseToStart();
+        // this used to be BOLD too with fdo#85876
+        CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xCursor, "CharWeight"));
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
commit ab2b384cd761c5c44fd00c19a8907ff220dd36c3
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date:   Wed Dec 10 12:53:05 2014 +0100

    SwNodeIndex should really be final
    
    Change-Id: I2ae917b43b18b14dce01121902a678d45ad520fe

diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx
index c8221c2..836e4b8 100644
--- a/sw/inc/ndindex.hxx
+++ b/sw/inc/ndindex.hxx
@@ -30,7 +30,7 @@ class SwNode;
 class SwNodes;
 
 /// Marks a node in the document model.
-class SW_DLLPUBLIC SwNodeIndex
+class SW_DLLPUBLIC SwNodeIndex SAL_FINAL
 {
     friend void SwNodes::RegisterIndex( SwNodeIndex& );
     friend void SwNodes::DeRegisterIndex( SwNodeIndex& );


More information about the Libreoffice-commits mailing list