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

Noel Grandin noel.grandin at collabora.co.uk
Wed Dec 20 11:45:12 UTC 2017


 sw/inc/hintids.hxx                   |   21 +++++++++------------
 sw/qa/extras/uiwriter/uiwriter.cxx   |   10 +++++-----
 sw/source/core/doc/docfmt.cxx        |    2 +-
 sw/source/core/doc/doclay.cxx        |    3 ++-
 sw/source/core/doc/textboxhelper.cxx |    2 +-
 5 files changed, 18 insertions(+), 20 deletions(-)

New commits:
commit fcfd55ffd7b3288db0fb42b21bed54bbef2b7ad7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Dec 19 11:28:46 2017 +0200

    convert RES_FMT constants to TypedWhichId
    
    Change-Id: Ie6c484cd8bde9ba3a3d5175fdf357873fe53bb89
    Reviewed-on: https://gerrit.libreoffice.org/46811
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index bb20ee86704d..ef869ddfe559 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -259,18 +259,15 @@ RES_FRMATR_END
 #define RES_UNKNOWNATR_END (151)
 
 // Format IDs
-enum RES_FMT
-{
-RES_FMT_BEGIN = RES_UNKNOWNATR_END,
-    RES_CHRFMT = RES_FMT_BEGIN,                     // 151
-    RES_FRMFMT,                                     // 152
-    RES_FLYFRMFMT,                                  // 153
-    RES_TXTFMTCOLL,                                 // 154
-    RES_GRFFMTCOLL,                                 // 155
-    RES_DRAWFRMFMT,                                 // 156
-    RES_CONDTXTFMTCOLL,                             // 157
-RES_FMT_END
-};
+#define RES_FMT_BEGIN RES_UNKNOWNATR_END
+#define     RES_CHRFMT                TypedWhichId<SwCharFormat>(RES_FMT_BEGIN)  // 151
+#define     RES_FRMFMT                TypedWhichId<SwFrameFormat>(152)
+#define     RES_FLYFRMFMT             TypedWhichId<SwFlyFrameFormat>(153)
+#define     RES_TXTFMTCOLL            TypedWhichId<SwTextFormatColl>(154)
+#define     RES_GRFFMTCOLL            TypedWhichId<SwGrfFormatColl>(155)
+#define     RES_DRAWFRMFMT            TypedWhichId<SwDrawFrameFormat>(156)
+#define     RES_CONDTXTFMTCOLL        TypedWhichId<SwConditionTextFormatColl>(157)
+#define RES_FMT_END 158
 
 // ID's for Messages in the Formats
 #define RES_MSG_BEGIN RES_FMT_END
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 9641350c13e0..6d6469c376d4 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -1111,14 +1111,14 @@ void SwUiWriterTest::testShapeTextboxSelect()
     SdrObject* pObject = pPage->GetObj(1);
     SwContact* pTextBox = static_cast<SwContact*>(pObject->GetUserCall());
     // First, make sure that pTextBox is a fly frame (textbox of a shape).
-    CPPUNIT_ASSERT_EQUAL(RES_FLYFRMFMT, static_cast<RES_FMT>(pTextBox->GetFormat()->Which()));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_FLYFRMFMT), pTextBox->GetFormat()->Which());
 
     // Then select it.
     pWrtShell->SelectObj(Point(), 0, pObject);
     const SdrMarkList& rMarkList = pWrtShell->GetDrawView()->GetMarkedObjectList();
     SwDrawContact* pShape = static_cast<SwDrawContact*>(rMarkList.GetMark(0)->GetMarkedSdrObj()->GetUserCall());
     // And finally make sure the shape got selected, not just the textbox itself.
-    CPPUNIT_ASSERT_EQUAL(RES_DRAWFRMFMT, static_cast<RES_FMT>(pShape->GetFormat()->Which()));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_DRAWFRMFMT), pShape->GetFormat()->Which());
 }
 
 void SwUiWriterTest::testShapeTextboxDelete()
@@ -4569,7 +4569,7 @@ void SwUiWriterTest::testTdf84695()
     SdrObject* pObject = pPage->GetObj(1);
     SwContact* pTextBox = static_cast<SwContact*>(pObject->GetUserCall());
     // First, make sure that pTextBox is a fly frame (textbox of a shape).
-    CPPUNIT_ASSERT_EQUAL(RES_FLYFRMFMT, static_cast<RES_FMT>(pTextBox->GetFormat()->Which()));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_FLYFRMFMT), pTextBox->GetFormat()->Which());
 
     // Then select it.
     pWrtShell->SelectObj(Point(), 0, pObject);
@@ -4593,7 +4593,7 @@ void SwUiWriterTest::testTdf84695NormalChar()
     SdrObject* pObject = pPage->GetObj(1);
     SwContact* pTextBox = static_cast<SwContact*>(pObject->GetUserCall());
     // First, make sure that pTextBox is a fly frame (textbox of a shape).
-    CPPUNIT_ASSERT_EQUAL(RES_FLYFRMFMT, static_cast<RES_FMT>(pTextBox->GetFormat()->Which()));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_FLYFRMFMT), pTextBox->GetFormat()->Which());
 
     // Then select it.
     pWrtShell->SelectObj(Point(), 0, pObject);
@@ -4616,7 +4616,7 @@ void SwUiWriterTest::testTdf84695Tab()
     SdrObject* pObject = pPage->GetObj(0);
     SwContact* pShape = static_cast<SwContact*>(pObject->GetUserCall());
     // First, make sure that pShape is a draw shape.
-    CPPUNIT_ASSERT_EQUAL(RES_DRAWFRMFMT, static_cast<RES_FMT>(pShape->GetFormat()->Which()));
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(RES_DRAWFRMFMT), pShape->GetFormat()->Which());
 
     // Then select it.
     pWrtShell->SelectObj(Point(), 0, pObject);
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 8cd67e260830..532c492e5ca2 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -306,7 +306,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg,
     if (GetIDocumentUndoRedo().DoesUndo())
     {
         SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg,
-            static_cast<sal_uInt16>(bTextAttr ? RES_CONDTXTFMTCOLL : RES_TXTFMTCOLL ));
+            bTextAttr ? sal_uInt16(RES_CONDTXTFMTCOLL) : sal_uInt16(RES_TXTFMTCOLL) );
         if( !rAttrs.empty() )
         {
             pUndo->SetAttrs( rAttrs );
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 3516ff000f80..fd6d5f415310 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -1279,8 +1279,9 @@ SwFlyFrameFormat* SwDoc::InsertDrawLabel(
     return pNewFormat;
 }
 
-static OUString lcl_GetUniqueFlyName(const SwDoc* pDoc, const char* pDefStrId, RES_FMT eType)
+static OUString lcl_GetUniqueFlyName(const SwDoc* pDoc, const char* pDefStrId, sal_uInt16 eType)
 {
+    assert(eType >= RES_FMT_BEGIN && eType < RES_FMT_END);
     if( pDoc->IsInMailMerge())
     {
         OUString newName = "MailMergeFly"
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 7ec48abc9eaa..12389c209e8a 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -134,7 +134,7 @@ bool SwTextBoxHelper::isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType)
     if (!pFormat || pFormat->Which() != nType || !pFormat->GetAttrSet().HasItem(RES_CNTNT))
         return false;
 
-    sal_uInt16 nOtherType = (pFormat->Which() == RES_FLYFRMFMT) ? RES_DRAWFRMFMT : RES_FLYFRMFMT;
+    sal_uInt16 nOtherType = (pFormat->Which() == RES_FLYFRMFMT) ? sal_uInt16(RES_DRAWFRMFMT) : sal_uInt16(RES_FLYFRMFMT);
     SwFrameFormat* pOtherFormat = pFormat->GetOtherTextBoxFormat();
     if (!pOtherFormat)
         return false;


More information about the Libreoffice-commits mailing list