summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2012-08-02 12:06:16 +0200
committerPetr Mladek <pmladek@suse.cz>2012-08-02 15:38:28 +0200
commit1fd46495c055db749cdf84191d6e086b1523241f (patch)
treeda6fd0273e4d6543271f38ad31379d352685d501 /sw
parent0e79ad05e76bed420383156aaafcad08d5e34fa8 (diff)
sw: fix some warnings
Signed-off-by: Petr Mladek <pmladek@suse.cz>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/number.cxx4
-rw-r--r--sw/source/filter/ww1/w1filter.cxx2
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx2
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx8
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx2
-rw-r--r--sw/source/ui/app/docsh.cxx11
-rw-r--r--sw/source/ui/dialog/ascfldlg.cxx2
-rw-r--r--sw/source/ui/misc/num.cxx5
-rw-r--r--sw/source/ui/table/tabledlg.cxx6
-rw-r--r--sw/source/ui/utlui/unotools.cxx6
10 files changed, 33 insertions, 15 deletions
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index c6e26fe9aa0b..a49055fe0075 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -1128,9 +1128,9 @@ namespace numfunc
}
inline sal_Unicode GetChar( sal_uInt8 p_nListLevel ) const
{
- if ( p_nListLevel > MAXLEVEL )
+ if (p_nListLevel >= MAXLEVEL)
{
- p_nListLevel = MAXLEVEL;
+ p_nListLevel = MAXLEVEL - 1;
}
return mnLevelChars[p_nListLevel];
diff --git a/sw/source/filter/ww1/w1filter.cxx b/sw/source/filter/ww1/w1filter.cxx
index 0a7af7d57800..458a6c09bb6e 100644
--- a/sw/source/filter/ww1/w1filter.cxx
+++ b/sw/source/filter/ww1/w1filter.cxx
@@ -1380,7 +1380,7 @@ SvxFontItem Ww1Fonts::GetFont(sal_uInt16 nFCode)
FAMILY_DONTKNOW, FAMILY_ROMAN, FAMILY_SWISS, FAMILY_MODERN,
FAMILY_SCRIPT, FAMILY_DECORATIVE
};
- if (b < sizeof(eFamilyA))
+ if (b < (sizeof(eFamilyA)/sizeof(eFamilyA[0])))
eFamily = eFamilyA[b];
}
else
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 9cde7c4f7656..0a48c5a58f89 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -268,7 +268,7 @@ static void SetFill( SfxItemSet& rSet, WW8_DP_FILL& rFill )
else
{
rSet.Put(XFillStyleItem(XFILL_SOLID)); // necessary for textbox
- if (nPat <= 1 || nPat > sizeof(nPatA))
+ if (nPat <= 1 || ((sizeof(nPatA)/sizeof(nPatA[0])) <= nPat))
{
// Solid Background or unknown
rSet.Put(XFillColorItem(aEmptyStr, WW8TransCol(rFill.dlpcBg)));
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 0a24803c4e11..3047380885f7 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -1025,10 +1025,16 @@ long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
if (bNested)
return 0;
- sal_uInt16 n = ( aF.nId <= eMax ) ? aF.nId : static_cast< sal_uInt16 >(eMax); // alle > 91 werden 92
+ sal_uInt16 n = (aF.nId <= eMax) ? aF.nId : static_cast<sal_uInt16>(eMax);
sal_uInt16 nI = n / 32; // # des sal_uInt32
sal_uLong nMask = 1 << ( n % 32 ); // Maske fuer Bits
+ if ((sizeof(nFieldTagAlways)/sizeof(nFieldTagAlways[0])) <= nI)
+ { // if indexes larger than 95 are needed, then a new configuration
+ // item has to be added, and nFieldTagAlways/nFieldTagBad expanded!
+ return aF.nLen;
+ }
+
if( nFieldTagAlways[nI] & nMask ) // Flag: Tag it
return Read_F_Tag( &aF ); // Resultat nicht als Text
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 5010d4b2055c..786bc00278a5 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3468,7 +3468,7 @@ bool SwWW8ImplReader::GetFontParams( sal_uInt16 nFCode, FontFamily& reFamily,
break;
}
}
- if( b < sizeof( eFamilyA ) )
+ if (b < (sizeof(eFamilyA)/sizeof(eFamilyA[0])))
reFamily = eFamilyA[b];
else
reFamily = FAMILY_DONTKNOW;
diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx
index b4e89352c961..aae70396bed3 100644
--- a/sw/source/ui/app/docsh.cxx
+++ b/sw/source/ui/app/docsh.cxx
@@ -1230,7 +1230,7 @@ uno::Reference< frame::XController >
return aRet;
}
-static const char* pEventNames[] =
+static const char* s_EventNames[] =
{
"OnPageCountChange",
"OnMailMerge",
@@ -1239,6 +1239,7 @@ static const char* pEventNames[] =
"OnFieldMergeFinished",
"OnLayoutFinished"
};
+static sal_Int32 const s_nEvents(sizeof(s_EventNames)/sizeof(s_EventNames[0]));
Sequence< OUString > SwDocShell::GetEventNames()
{
@@ -1256,12 +1257,12 @@ Sequence< OUString > SwDocShell::GetEventNames()
return aRet;
}
-static sal_Int32 nEvents=13;
-
rtl::OUString SwDocShell::GetEventName( sal_Int32 nIndex )
{
- if ( nIndex<nEvents )
- return ::rtl::OUString::createFromAscii(pEventNames[nIndex]);
+ if (nIndex < s_nEvents)
+ {
+ return ::rtl::OUString::createFromAscii(s_EventNames[nIndex]);
+ }
return rtl::OUString();
}
diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index d6ca4072e6d9..2f0305640c28 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -115,8 +115,6 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh,
{
aBuffer[ nBytesRead ] = '0';
aBuffer[ nBytesRead+1 ] = '0';
- if( 0 != ( nBytesRead & 0x00000001 ) )
- aBuffer[ nBytesRead + 2 ] = '0';
}
sal_Bool bCR = sal_False, bLF = sal_False, bNullChar = sal_False;
diff --git a/sw/source/ui/misc/num.cxx b/sw/source/ui/misc/num.cxx
index 80a6173ddfd7..9b0be5015599 100644
--- a/sw/source/ui/misc/num.cxx
+++ b/sw/source/ui/misc/num.cxx
@@ -262,6 +262,11 @@ void SwNumPositionTabPage::InitControls()
nMask <<= 1;
}
+ if (MAXLEVEL <= nLvl)
+ {
+ OSL_ENSURE(false, "cannot happen.");
+ return;
+ }
if(bSameDistBorderNum)
{
long nDistBorderNum;
diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx
index 9053b156935c..3aba29744b6e 100644
--- a/sw/source/ui/table/tabledlg.cxx
+++ b/sw/source/ui/table/tabledlg.cxx
@@ -1010,6 +1010,12 @@ void SwTableColumnPage::ModifyHdl( PercentField* pEdit )
if(pEdit == pFieldArr[i])
break;
+ if (MET_FIELDS <= i)
+ {
+ OSL_ENSURE(false, "cannot happen.");
+ return;
+ }
+
SetVisibleWidth(aValueTbl[i], static_cast< SwTwips >(pEdit->DenormalizePercent(pEdit->GetValue( FUNIT_TWIP ))) );
nAktPos = aValueTbl[i];
diff --git a/sw/source/ui/utlui/unotools.cxx b/sw/source/ui/utlui/unotools.cxx
index 98eb46ecc3a8..8e67543a2290 100644
--- a/sw/source/ui/utlui/unotools.cxx
+++ b/sw/source/ui/utlui/unotools.cxx
@@ -408,7 +408,8 @@ void SwOneExampleFrame::CreatePopup(const Point& rPt)
sal_Int16 nZoom = 0;
aZoom >>= nZoom;
- for(sal_uInt16 i = 0; i < 5; i++ )
+ for (sal_uInt16 i = 0;
+ i < (sizeof(nZoomValues)/sizeof(nZoomValues[0])); ++i)
{
String sTemp;
sTemp = String::CreateFromInt32(nZoomValues[i]);
@@ -427,7 +428,8 @@ void SwOneExampleFrame::CreatePopup(const Point& rPt)
IMPL_LINK(SwOneExampleFrame, PopupHdl, Menu*, pMenu )
{
sal_uInt16 nId = pMenu->GetCurItemId();
- if( nId > ITEM_ZOOM && nId < ITEM_ZOOM + 100 )
+ if ((nId > ITEM_ZOOM) &&
+ (nId <= (ITEM_ZOOM + (sizeof(nZoomValues)/sizeof(nZoomValues[0])))))
{
sal_Int16 nZoom = nZoomValues[nId - ITEM_ZOOM - 1];
uno::Reference< view::XViewSettingsSupplier > xSettings(_xController, uno::UNO_QUERY);