Kaydet (Commit) a4462f24 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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 874cc6cb "Don't read
out-of-range ContentTypeId from configuration."

Change-Id: I6d136412982c3cfb06ddef3b6c1acd800d92ae05
üst 8cdf71a9
...@@ -41,7 +41,7 @@ enum class ContentTypeId ...@@ -41,7 +41,7 @@ enum class ContentTypeId
POSTIT = 10, POSTIT = 10,
DRAWOBJECT = 11, DRAWOBJECT = 11,
LAST = DRAWOBJECT, LAST = DRAWOBJECT,
UNKNOWN = USHRT_MAX UNKNOWN = -1
}; };
// strings for context menus // strings for context menus
......
...@@ -75,11 +75,16 @@ SwNavigationConfig::SwNavigationConfig() : ...@@ -75,11 +75,16 @@ SwNavigationConfig::SwNavigationConfig() :
{ {
case 0: case 0:
{ {
sal_uInt32 nTmp; sal_Int32 nTmp;
if (pValues[nProp] >>= nTmp) if (pValues[nProp] >>= nTmp)
{ {
if (nTmp > sal_uInt32(ContentTypeId::LAST)) { if (nTmp < sal_Int32(ContentTypeId::UNKNOWN)
nTmp = sal_uInt32(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); nRootType = static_cast<ContentTypeId>(nTmp);
} }
...@@ -117,7 +122,7 @@ void SwNavigationConfig::ImplCommit() ...@@ -117,7 +122,7 @@ void SwNavigationConfig::ImplCommit()
{ {
switch(nProp) 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 1: pValues[nProp] <<= nSelectedPos; break;
case 2: pValues[nProp] <<= nOutlineLevel; break; case 2: pValues[nProp] <<= nOutlineLevel; break;
case 3: pValues[nProp] <<= static_cast<sal_uInt16>(nRegionMode); break; case 3: pValues[nProp] <<= static_cast<sal_uInt16>(nRegionMode); break;
......
...@@ -1295,7 +1295,7 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent, ...@@ -1295,7 +1295,7 @@ SwNavigationChild::SwNavigationChild( vcl::Window* pParent,
SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig(); SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig();
const ContentTypeId nRootType = pNaviConfig->GetRootType(); const ContentTypeId nRootType = pNaviConfig->GetRootType();
if( nRootType <= ContentTypeId::LAST ) if( nRootType != ContentTypeId::UNKNOWN )
{ {
pNavi->aContentTree->SetRootType(nRootType); pNavi->aContentTree->SetRootType(nRootType);
pNavi->aContentToolBox->CheckItem(FN_SHOW_ROOT); pNavi->aContentToolBox->CheckItem(FN_SHOW_ROOT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment