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

Stephan Bergmann sbergman at redhat.com
Mon Sep 14 05:44:51 PDT 2015


 sw/source/uibase/inc/swcont.hxx    |    2 +-
 sw/source/uibase/utlui/navicfg.cxx |   13 +++++++++----
 sw/source/uibase/utlui/navipi.cxx  |    2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)

New commits:
commit a4462f247fb92233a1f89a98c689e32af33d3e3f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Sep 14 14:40:25 2015 +0200

    Set ContentTypeId::UNKNOWN to -1
    
    ...which matches the original situation better, where ContentTypeId was
    sal_uInt16, and so the default -1 for
    /org.openoffice.Office/Writer/Navigator/RootType happened to match UNKNOWN being
    USHRT_MAX.  Follow-up to 874cc6cb72e6e795f48bcee5d4fe5c595fb1f702 "Don't read
    out-of-range ContentTypeId from configuration."
    
    Change-Id: I6d136412982c3cfb06ddef3b6c1acd800d92ae05

diff --git a/sw/source/uibase/inc/swcont.hxx b/sw/source/uibase/inc/swcont.hxx
index 153661b1..29179d7 100644
--- a/sw/source/uibase/inc/swcont.hxx
+++ b/sw/source/uibase/inc/swcont.hxx
@@ -41,7 +41,7 @@ enum class ContentTypeId
     POSTIT         = 10,
     DRAWOBJECT     = 11,
     LAST           = DRAWOBJECT,
-    UNKNOWN        = USHRT_MAX
+    UNKNOWN        = -1
 };
 
 // strings for context menus
diff --git a/sw/source/uibase/utlui/navicfg.cxx b/sw/source/uibase/utlui/navicfg.cxx
index f9440e7..d7dcab6 100644
--- a/sw/source/uibase/utlui/navicfg.cxx
+++ b/sw/source/uibase/utlui/navicfg.cxx
@@ -75,11 +75,16 @@ SwNavigationConfig::SwNavigationConfig() :
                 {
                     case 0:
                     {
-                        sal_uInt32 nTmp;
+                        sal_Int32 nTmp;
                         if (pValues[nProp] >>= nTmp)
                         {
-                            if (nTmp > sal_uInt32(ContentTypeId::LAST)) {
-                                nTmp = sal_uInt32(ContentTypeId::UNKNOWN);
+                            if (nTmp < sal_Int32(ContentTypeId::UNKNOWN)
+                                || nTmp > sal_Int32(ContentTypeId::LAST))
+                            {
+                                SAL_WARN(
+                                    "sw",
+                                    "out-of-bounds ContentTypeId " << nTmp);
+                                nTmp = sal_Int32(ContentTypeId::UNKNOWN);
                             }
                             nRootType = static_cast<ContentTypeId>(nTmp);
                         }
@@ -117,7 +122,7 @@ void SwNavigationConfig::ImplCommit()
     {
         switch(nProp)
         {
-            case 0: pValues[nProp] <<= static_cast<sal_uInt32>(nRootType);     break;
+            case 0: pValues[nProp] <<= static_cast<sal_Int32>(nRootType);     break;
             case 1: pValues[nProp] <<= nSelectedPos;  break;
             case 2: pValues[nProp] <<= nOutlineLevel; break;
             case 3: pValues[nProp] <<= static_cast<sal_uInt16>(nRegionMode); break;
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index 200a8d2..075c3bd 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -1295,7 +1295,7 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent,
     SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
 
     const ContentTypeId nRootType = pNaviConfig->GetRootType();
-    if( nRootType <= ContentTypeId::LAST )
+    if( nRootType != ContentTypeId::UNKNOWN )
     {
         pNavi->aContentTree->SetRootType(nRootType);
         pNavi->aContentToolBox->CheckItem(FN_SHOW_ROOT);


More information about the Libreoffice-commits mailing list