Kaydet (Commit) 4c60f722 authored tarafından Matteo Casalin's avatar Matteo Casalin

sal_uInt16 to more proper types, constify, avoid unneeded casts

Change-Id: Ib7b6b9ac4c2b164984d1fd23dc8cf0905f244668
üst 2d5a7c36
...@@ -60,19 +60,18 @@ using namespace ::com::sun::star; ...@@ -60,19 +60,18 @@ using namespace ::com::sun::star;
// Pack columns // Pack columns
static void lcl_FillSvxColumn(const SwFmtCol& rCol, static void lcl_FillSvxColumn(const SwFmtCol& rCol,
sal_uInt16 nTotalWidth, long nTotalWidth,
SvxColumnItem& rColItem, SvxColumnItem& rColItem,
long nDistance) long nDistance)
{ {
const SwColumns& rCols = rCol.GetColumns(); const SwColumns& rCols = rCol.GetColumns();
sal_uInt16 nWidth = 0;
bool bOrtho = rCol.IsOrtho() && rCols.size(); bool bOrtho = rCol.IsOrtho() && rCols.size();
long nInnerWidth = 0; long nInnerWidth = 0;
if( bOrtho ) if( bOrtho )
{ {
nInnerWidth = nTotalWidth; nInnerWidth = nTotalWidth;
for ( sal_uInt16 i = 0; i < rCols.size(); ++i ) for ( size_t i = 0; i < rCols.size(); ++i )
{ {
const SwColumn* pCol = &rCols[i]; const SwColumn* pCol = &rCols[i];
nInnerWidth -= pCol->GetLeft() + pCol->GetRight(); nInnerWidth -= pCol->GetLeft() + pCol->GetRight();
...@@ -82,15 +81,17 @@ static void lcl_FillSvxColumn(const SwFmtCol& rCol, ...@@ -82,15 +81,17 @@ static void lcl_FillSvxColumn(const SwFmtCol& rCol,
else else
nInnerWidth /= rCols.size(); nInnerWidth /= rCols.size();
} }
for ( sal_uInt16 i = 0; i < rCols.size(); ++i )
long nWidth = 0;
for ( size_t i = 0; i < rCols.size(); ++i )
{ {
const SwColumn* pCol = &rCols[i]; const SwColumn* pCol = &rCols[i];
const sal_uInt16 nStart = sal_uInt16(pCol->GetLeft() + nWidth + nDistance); const long nStart = pCol->GetLeft() + nWidth + nDistance;
if( bOrtho ) if( bOrtho )
nWidth = static_cast< sal_uInt16 >(nWidth + nInnerWidth + pCol->GetLeft() + pCol->GetRight()); nWidth += nInnerWidth + pCol->GetLeft() + pCol->GetRight();
else else
nWidth = static_cast< sal_uInt16 >(nWidth + rCol.CalcColWidth(i, nTotalWidth)); nWidth += rCol.CalcColWidth(i, static_cast< sal_uInt16 >(nTotalWidth));
const sal_uInt16 nEnd = sal_uInt16(nWidth - pCol->GetRight() + nDistance); const long nEnd = nWidth - pCol->GetRight() + nDistance;
SvxColumnDescription aColDesc(nStart, nEnd, true); SvxColumnDescription aColDesc(nStart, nEnd, true);
rColItem.Append(aColDesc); rColItem.Append(aColDesc);
...@@ -99,7 +100,7 @@ static void lcl_FillSvxColumn(const SwFmtCol& rCol, ...@@ -99,7 +100,7 @@ static void lcl_FillSvxColumn(const SwFmtCol& rCol,
// Transfer ColumnItem in ColumnInfo // Transfer ColumnItem in ColumnInfo
static void lcl_ConvertToCols(const SvxColumnItem& rColItem, static void lcl_ConvertToCols(const SvxColumnItem& rColItem,
sal_uInt16 nTotalWidth, long nTotalWidth,
SwFmtCol& rCols) SwFmtCol& rCols)
{ {
OSL_ENSURE( rCols.GetNumCols() == rColItem.Count(), "Column count mismatch" ); OSL_ENSURE( rCols.GetNumCols() == rColItem.Count(), "Column count mismatch" );
...@@ -117,19 +118,13 @@ static void lcl_ConvertToCols(const SvxColumnItem& rColItem, ...@@ -117,19 +118,13 @@ static void lcl_ConvertToCols(const SvxColumnItem& rColItem,
for( sal_uInt16 i=0; i < rColItem.Count()-1; ++i ) for( sal_uInt16 i=0; i < rColItem.Count()-1; ++i )
{ {
OSL_ENSURE(rColItem[i+1].nStart >= rColItem[i].nEnd,"overlapping columns" ); OSL_ENSURE(rColItem[i+1].nStart >= rColItem[i].nEnd,"overlapping columns" );
sal_uInt16 nStart = static_cast< sal_uInt16 >(rColItem[i+1].nStart); const long nStart = std::max(rColItem[i+1].nStart, rColItem[i].nEnd);
sal_uInt16 nEnd = static_cast< sal_uInt16 >(rColItem[i].nEnd); const sal_uInt16 nRight = static_cast<sal_uInt16>((nStart - rColItem[i].nEnd) / 2);
if(nStart < nEnd)
nStart = nEnd;
const sal_uInt16 nDiff = nStart - nEnd;
const sal_uInt16 nRight = nDiff / 2;
sal_uInt16 nWidth = static_cast< sal_uInt16 >(rColItem[i].nEnd - rColItem[i].nStart); const long nWidth = rColItem[i].nEnd - rColItem[i].nStart + nLeft + nRight;
nWidth += nLeft + nRight;
SwColumn* pCol = &rArr[i]; SwColumn* pCol = &rArr[i];
pCol->SetWishWidth( sal_uInt16(long(rCols.GetWishWidth()) * long(nWidth) / pCol->SetWishWidth( sal_uInt16(long(rCols.GetWishWidth()) * nWidth / nTotalWidth ));
long(nTotalWidth) ));
pCol->SetLeft( nLeft ); pCol->SetLeft( nLeft );
pCol->SetRight( nRight ); pCol->SetRight( nRight );
nSumAll += pCol->GetWishWidth(); nSumAll += pCol->GetWishWidth();
...@@ -198,7 +193,7 @@ void ResizeFrameCols(SwFmtCol& rCol, ...@@ -198,7 +193,7 @@ void ResizeFrameCols(SwFmtCol& rCol,
// If the desired width is getting too large, then all values // If the desired width is getting too large, then all values
// must be scaled appropriately. // must be scaled appropriately.
long nScale = (0xffffl << 8)/ nNewWishWidth; long nScale = (0xffffl << 8)/ nNewWishWidth;
for(sal_uInt16 i = 0; i < rArr.size(); i++) for(size_t i = 0; i < rArr.size(); ++i)
{ {
SwColumn* pCol = &rArr[i]; SwColumn* pCol = &rArr[i];
long nVal = pCol->GetWishWidth(); long nVal = pCol->GetWishWidth();
...@@ -343,9 +338,9 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -343,9 +338,9 @@ void SwView::ExecTabWin( SfxRequest& rReq )
aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld ); aLongLR.SetLeft( nOld > aLongLR.GetLeft() ? 0 : aLongLR.GetLeft() - nOld );
nOld = rDesc.GetMaster().GetLRSpace().GetRight(); nOld = rDesc.GetMaster().GetLRSpace().GetRight();
aLongLR.SetRight( nOld > (sal_uInt16)aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld ); aLongLR.SetRight( nOld > aLongLR.GetRight() ? 0 : aLongLR.GetRight() - nOld );
aLR.SetLeft((sal_uInt16)aLongLR.GetLeft()); aLR.SetLeft(aLongLR.GetLeft());
aLR.SetRight((sal_uInt16)aLongLR.GetRight()); aLR.SetRight(aLongLR.GetRight());
if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt ) if ( nFrmType & FRMTYPE_HEADER && pHeaderFmt )
pHeaderFmt->SetFmtAttr( aLR ); pHeaderFmt->SetFmtAttr( aLR );
...@@ -389,8 +384,8 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -389,8 +384,8 @@ void SwView::ExecTabWin( SfxRequest& rReq )
} }
else else
{ // Adjust page margins { // Adjust page margins
aLR.SetLeft((sal_uInt16)aLongLR.GetLeft()); aLR.SetLeft(aLongLR.GetLeft());
aLR.SetRight((sal_uInt16)aLongLR.GetRight()); aLR.SetRight(aLongLR.GetRight());
SwapPageMargin( rDesc, aLR ); SwapPageMargin( rDesc, aLR );
SwPageDesc aDesc( rDesc ); SwPageDesc aDesc( rDesc );
aDesc.GetMaster().SetFmtAttr( aLR ); aDesc.GetMaster().SetFmtAttr( aLR );
...@@ -408,8 +403,8 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -408,8 +403,8 @@ void SwView::ExecTabWin( SfxRequest& rReq )
SwPageDesc aDesc( rDesc ); SwPageDesc aDesc( rDesc );
{ {
SvxLRSpaceItem aLR( RES_LR_SPACE ); SvxLRSpaceItem aLR( RES_LR_SPACE );
aLR.SetLeft((sal_uInt16)aLongLR.GetLeft()); aLR.SetLeft(aLongLR.GetLeft());
aLR.SetRight((sal_uInt16)aLongLR.GetRight()); aLR.SetRight(aLongLR.GetRight());
SwapPageMargin( rDesc, aLR ); SwapPageMargin( rDesc, aLR );
aDesc.GetMaster().SetFmtAttr( aLR ); aDesc.GetMaster().SetFmtAttr( aLR );
} }
...@@ -621,7 +616,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -621,7 +616,7 @@ void SwView::ExecTabWin( SfxRequest& rReq )
case SID_ATTR_TABSTOP: case SID_ATTR_TABSTOP:
if (pReqArgs) if (pReqArgs)
{ {
sal_uInt16 nWhich = GetPool().GetWhich(nSlot); const sal_uInt16 nWhich = GetPool().GetWhich(nSlot);
SvxTabStopItem aTabStops( (const SvxTabStopItem&)pReqArgs-> SvxTabStopItem aTabStops( (const SvxTabStopItem&)pReqArgs->
Get( nWhich )); Get( nWhich ));
aTabStops.SetWhich(RES_PARATR_TABSTOP); aTabStops.SetWhich(RES_PARATR_TABSTOP);
...@@ -792,10 +787,10 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -792,10 +787,10 @@ void SwView::ExecTabWin( SfxRequest& rReq )
IsTabColFromDoc() ? IsTabColFromDoc() ?
rSh.IsMouseTableRightToLeft(m_aTabColFromDocPos) rSh.IsMouseTableRightToLeft(m_aTabColFromDocPos)
: rSh.IsTableRightToLeft(); : rSh.IsTableRightToLeft();
const size_t nColCount = aColItem.Count() - 1;
if(bIsTableRTL) if(bIsTableRTL)
{ {
sal_uInt16 nColCount = aColItem.Count() - 1; for ( size_t i = 0; i < nColCount && i < aTabCols.Count(); ++i )
for ( sal_uInt16 i = 0; i < nColCount && i < aTabCols.Count(); ++i )
{ {
const SvxColumnDescription& rCol = aColItem[nColCount - i]; const SvxColumnDescription& rCol = aColItem[nColCount - i];
aTabCols[i] = aTabCols.GetRight() - rCol.nStart; aTabCols[i] = aTabCols.GetRight() - rCol.nStart;
...@@ -804,7 +799,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -804,7 +799,7 @@ void SwView::ExecTabWin( SfxRequest& rReq )
} }
else else
{ {
for ( sal_uInt16 i = 0; i < aColItem.Count()-1 && i < aTabCols.Count(); ++i ) for ( size_t i = 0; i < nColCount && i < aTabCols.Count(); ++i )
{ {
const SvxColumnDescription& rCol = aColItem[i]; const SvxColumnDescription& rCol = aColItem[i];
aTabCols[i] = rCol.nEnd + aTabCols.GetLeft(); aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
...@@ -848,7 +843,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -848,7 +843,7 @@ void SwView::ExecTabWin( SfxRequest& rReq )
(const SwFmtCol&)aSet.Get( RES_COL, false )); (const SwFmtCol&)aSet.Get( RES_COL, false ));
SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED); SwRect aCurRect = rSh.GetAnyCurRect(bSect ? RECT_SECTION_PRT : RECT_FLY_PRT_EMBEDDED);
const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width(); const long lWidth = bVerticalWriting ? aCurRect.Height() : aCurRect.Width();
::lcl_ConvertToCols( aColItem, sal_uInt16(lWidth), aCols ); ::lcl_ConvertToCols( aColItem, lWidth, aCols );
aSet.Put( aCols ); aSet.Put( aCols );
if(bSect) if(bSect)
rSh.SetSectionAttr( aSet, pSectFmt ); rSh.SetSectionAttr( aSet, pSectFmt );
...@@ -872,7 +867,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -872,7 +867,7 @@ void SwView::ExecTabWin( SfxRequest& rReq )
SwFmtCol aCols( rDesc.GetMaster().GetCol() ); SwFmtCol aCols( rDesc.GetMaster().GetCol() );
const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT); const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT);
::lcl_ConvertToCols( aColItem, ::lcl_ConvertToCols( aColItem,
sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width()), bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width(),
aCols ); aCols );
SwPageDesc aDesc( rDesc ); SwPageDesc aDesc( rDesc );
aDesc.GetMaster().SetFmtAttr( aCols ); aDesc.GetMaster().SetFmtAttr( aCols );
...@@ -909,9 +904,10 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -909,9 +904,10 @@ void SwView::ExecTabWin( SfxRequest& rReq )
aTabCols.SetRight( nBorder ); aTabCols.SetRight( nBorder );
} }
const size_t nColItems = aColItem.Count() - 1;
if(bVerticalWriting) if(bVerticalWriting)
{ {
for ( sal_uInt16 i = aColItem.Count() - 1; i; --i ) for ( size_t i = nColItems; i; --i )
{ {
const SvxColumnDescription& rCol = aColItem[i - 1]; const SvxColumnDescription& rCol = aColItem[i - 1];
long nColumnPos = aTabCols.GetRight() - rCol.nEnd ; long nColumnPos = aTabCols.GetRight() - rCol.nEnd ;
...@@ -921,7 +917,7 @@ void SwView::ExecTabWin( SfxRequest& rReq ) ...@@ -921,7 +917,7 @@ void SwView::ExecTabWin( SfxRequest& rReq )
} }
else else
{ {
for ( sal_uInt16 i = 0; i < aColItem.Count()-1; ++i ) for ( size_t i = 0; i < nColItems; ++i )
{ {
const SvxColumnDescription& rCol = aColItem[i]; const SvxColumnDescription& rCol = aColItem[i];
aTabCols[i] = rCol.nEnd + aTabCols.GetLeft(); aTabCols[i] = rCol.nEnd + aTabCols.GetLeft();
...@@ -1097,8 +1093,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1097,8 +1093,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
if( aRect.Width() ) if( aRect.Width() )
{ {
// make relative to page position: // make relative to page position:
aLongLR.SetLeft ((long)( aRect.Left() - rPageRect.Left() )); aLongLR.SetLeft(aRect.Left() - rPageRect.Left());
aLongLR.SetRight((long)( rPageRect.Right() - aRect.Right())); aLongLR.SetRight(rPageRect.Right() - aRect.Right());
} }
} }
if( nWhich == SID_ATTR_LONG_LRSPACE ) if( nWhich == SID_ATTR_LONG_LRSPACE )
...@@ -1138,15 +1134,15 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1138,15 +1134,15 @@ void SwView::StateTabWin(SfxItemSet& rSet)
{ {
// Convert document coordinates into page coordinates. // Convert document coordinates into page coordinates.
const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt); const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
aLongUL.SetUpper((sal_uInt16)(rRect.Top() - rPageRect.Top() )); aLongUL.SetUpper(rRect.Top() - rPageRect.Top());
aLongUL.SetLower((sal_uInt16)(rPageRect.Bottom() - rRect.Bottom() )); aLongUL.SetLower(rPageRect.Bottom() - rRect.Bottom());
} }
else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER ) else if ( nFrmType & FRMTYPE_HEADER || nFrmType & FRMTYPE_FOOTER )
{ {
SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt)); SwRect aRect( rSh.GetAnyCurRect( RECT_HEADERFOOTER, pPt));
aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos(); aRect.Pos() -= rSh.GetAnyCurRect( RECT_PAGE, pPt ).Pos();
aLongUL.SetUpper( (sal_uInt16)aRect.Top() ); aLongUL.SetUpper( aRect.Top() );
aLongUL.SetLower( (sal_uInt16)(nPageHeight - aRect.Bottom()) ); aLongUL.SetLower( nPageHeight - aRect.Bottom() );
} }
else if( nFrmType & FRMTYPE_DRAWOBJ) else if( nFrmType & FRMTYPE_DRAWOBJ)
{ {
...@@ -1298,8 +1294,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1298,8 +1294,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
aCoreSet.Put( aBoxInfo ); aCoreSet.Put( aBoxInfo );
rSh.GetFlyFrmAttr( aCoreSet ); rSh.GetFlyFrmAttr( aCoreSet );
const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX); const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet.Get(RES_BOX);
aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT )); aDistLR.SetLeft(rBox.GetDistance(BOX_LINE_LEFT));
aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT)); aDistLR.SetRight(rBox.GetDistance(BOX_LINE_RIGHT));
//add the paragraph border distance //add the paragraph border distance
SfxItemSet aCoreSet1( GetPool(), SfxItemSet aCoreSet1( GetPool(),
...@@ -1307,8 +1303,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1307,8 +1303,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
0 ); 0 );
rSh.GetCurAttr( aCoreSet1 ); rSh.GetCurAttr( aCoreSet1 );
const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX); const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT )); aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(BOX_LINE_LEFT));
aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT)); aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(BOX_LINE_RIGHT));
} }
rSet.Put(aDistLR); rSet.Put(aDistLR);
m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft()); m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
...@@ -1327,15 +1323,15 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1327,15 +1323,15 @@ void SwView::StateTabWin(SfxItemSet& rSet)
aCoreSet2.Put(aBoxInfo); aCoreSet2.Put(aBoxInfo);
rSh.GetTabBorders( aCoreSet2 ); rSh.GetTabBorders( aCoreSet2 );
const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX); const SvxBoxItem& rBox = (const SvxBoxItem&)aCoreSet2.Get(RES_BOX);
aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT )); aDistLR.SetLeft(rBox.GetDistance(BOX_LINE_LEFT));
aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT)); aDistLR.SetRight(rBox.GetDistance(BOX_LINE_RIGHT));
//add the border distance of the paragraph //add the border distance of the paragraph
SfxItemSet aCoreSet1( GetPool(), RES_BOX, RES_BOX ); SfxItemSet aCoreSet1( GetPool(), RES_BOX, RES_BOX );
rSh.GetCurAttr( aCoreSet1 ); rSh.GetCurAttr( aCoreSet1 );
const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX); const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSet1.Get(RES_BOX);
aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT )); aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(BOX_LINE_LEFT));
aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT)); aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(BOX_LINE_RIGHT));
rSet.Put(aDistLR); rSet.Put(aDistLR);
m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft()); m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight()); m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
...@@ -1345,8 +1341,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1345,8 +1341,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
//get the page/header/footer border distance //get the page/header/footer border distance
const SwFrmFmt& rMaster = rDesc.GetMaster(); const SwFrmFmt& rMaster = rDesc.GetMaster();
const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX); const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetAttrSet().Get(RES_BOX);
aDistLR.SetLeft((sal_uInt16)rBox.GetDistance(BOX_LINE_LEFT )); aDistLR.SetLeft(rBox.GetDistance(BOX_LINE_LEFT));
aDistLR.SetRight((sal_uInt16)rBox.GetDistance(BOX_LINE_RIGHT)); aDistLR.SetRight(rBox.GetDistance(BOX_LINE_RIGHT));
const SvxBoxItem* pBox = 0; const SvxBoxItem* pBox = 0;
if(nFrmType & FRMTYPE_HEADER) if(nFrmType & FRMTYPE_HEADER)
...@@ -1366,8 +1362,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1366,8 +1362,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
} }
if(pBox) if(pBox)
{ {
aDistLR.SetLeft((sal_uInt16)pBox->GetDistance(BOX_LINE_LEFT )); aDistLR.SetLeft(pBox->GetDistance(BOX_LINE_LEFT));
aDistLR.SetRight((sal_uInt16)pBox->GetDistance(BOX_LINE_RIGHT)); aDistLR.SetRight(pBox->GetDistance(BOX_LINE_RIGHT));
} }
//add the border distance of the paragraph //add the border distance of the paragraph
...@@ -1376,8 +1372,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1376,8 +1372,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 ); SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
rSh.GetCurAttr( aCoreSetTmp ); rSh.GetCurAttr( aCoreSetTmp );
const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX); const SvxBoxItem& rParaBox = (const SvxBoxItem&)aCoreSetTmp.Get(RES_BOX);
aDistLR.SetLeft(aDistLR.GetLeft() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_LEFT )); aDistLR.SetLeft(aDistLR.GetLeft() + rParaBox.GetDistance(BOX_LINE_LEFT));
aDistLR.SetRight(aDistLR.GetRight() + (sal_uInt16)rParaBox.GetDistance(BOX_LINE_RIGHT)); aDistLR.SetRight(aDistLR.GetRight() + rParaBox.GetDistance(BOX_LINE_RIGHT));
rSet.Put(aDistLR); rSet.Put(aDistLR);
m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft()); m_nLeftBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetLeft());
m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight()); m_nRightBorderDistance = static_cast< sal_uInt16 >(aDistLR.GetRight());
...@@ -1452,8 +1448,8 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1452,8 +1448,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
SvxColumnItem aColItem(nNum, nL, nR); SvxColumnItem aColItem(nNum, nL, nR);
sal_uInt16 nStart = 0, long nStart = 0;
nEnd; long nEnd = 0;
//columns in right-to-left tables need to be mirrored //columns in right-to-left tables need to be mirrored
bool bIsTableRTL = bool bIsTableRTL =
...@@ -1465,11 +1461,10 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1465,11 +1461,10 @@ void SwView::StateTabWin(SfxItemSet& rSet)
for ( size_t i = aTabCols.Count(); i; --i ) for ( size_t i = aTabCols.Count(); i; --i )
{ {
const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 ); const SwTabColsEntry& rEntry = aTabCols.GetEntry( i - 1 );
nEnd = (sal_uInt16)aTabCols.GetRight(); nEnd = aTabCols.GetRight() - rEntry.nPos;
nEnd = nEnd - (sal_uInt16)rEntry.nPos;
SvxColumnDescription aColDesc( nStart, nEnd, SvxColumnDescription aColDesc( nStart, nEnd,
(sal_uInt16(aTabCols.GetRight() - rEntry.nMax)), aTabCols.GetRight() - rEntry.nMax,
(sal_uInt16(aTabCols.GetRight() - rEntry.nMin)), aTabCols.GetRight() - rEntry.nMin,
!aTabCols.IsHidden(i - 1) ); !aTabCols.IsHidden(i - 1) );
aColItem.Append(aColDesc); aColItem.Append(aColDesc);
nStart = nEnd; nStart = nEnd;
...@@ -1483,7 +1478,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1483,7 +1478,7 @@ void SwView::StateTabWin(SfxItemSet& rSet)
for ( size_t i = 0; i < aTabCols.Count(); ++i ) for ( size_t i = 0; i < aTabCols.Count(); ++i )
{ {
const SwTabColsEntry& rEntry = aTabCols.GetEntry( i ); const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
nEnd = static_cast< sal_uInt16 >(rEntry.nPos - aTabCols.GetLeft()); nEnd = rEntry.nPos - aTabCols.GetLeft();
SvxColumnDescription aColDesc( nStart, nEnd, SvxColumnDescription aColDesc( nStart, nEnd,
rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(), rEntry.nMin - aTabCols.GetLeft(), rEntry.nMax - aTabCols.GetLeft(),
!aTabCols.IsHidden(i) ); !aTabCols.IsHidden(i) );
...@@ -1529,14 +1524,14 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1529,14 +1524,14 @@ void SwView::StateTabWin(SfxItemSet& rSet)
SwRect aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt); SwRect aRect = rSh.GetAnyCurRect(RECT_SECTION_PRT, pPt);
const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt); const SwRect aTmpRect = rSh.GetAnyCurRect(RECT_SECTION, pPt);
::lcl_FillSvxColumn(rCol, sal_uInt16(bVerticalWriting ? aRect.Height() : aRect.Width()), aColItem, 0); ::lcl_FillSvxColumn(rCol, bVerticalWriting ? aRect.Height() : aRect.Width(), aColItem, 0);
if(bVerticalWriting) if(bVerticalWriting)
{ {
aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top()); aRect.Pos() += Point(aTmpRect.Left(), aTmpRect.Top());
aRect.Pos().Y() -= rPageRect.Top(); aRect.Pos().Y() -= rPageRect.Top();
aColItem.SetLeft ((sal_uInt16)(aRect.Top())); aColItem.SetLeft(aRect.Top());
aColItem.SetRight((sal_uInt16)(nPageHeight - aRect.Bottom() )); aColItem.SetRight(nPageHeight - aRect.Bottom());
} }
else else
{ {
...@@ -1570,20 +1565,20 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1570,20 +1565,20 @@ void SwView::StateTabWin(SfxItemSet& rSet)
const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width(); const long lWidth = bUseVertical ? rSizeRect.Height() : rSizeRect.Width();
const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt); const SwRect &rRect = rSh.GetAnyCurRect(RECT_FLY_EMBEDDED, pPt);
long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2; long nDist2 = ((bUseVertical ? rRect.Height() : rRect.Width()) - lWidth) /2;
::lcl_FillSvxColumn(rCol, sal_uInt16(lWidth), aColItem, nDist2); ::lcl_FillSvxColumn(rCol, lWidth, aColItem, nDist2);
SfxItemSet aFrameSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE); SfxItemSet aFrameSet(GetPool(), RES_LR_SPACE, RES_LR_SPACE);
rSh.GetFlyFrmAttr( aFrameSet ); rSh.GetFlyFrmAttr( aFrameSet );
if(bUseVertical) if(bUseVertical)
{ {
aColItem.SetLeft ((sal_uInt16)(rRect.Top()- rPageRect.Top())); aColItem.SetLeft(rRect.Top()- rPageRect.Top());
aColItem.SetRight((sal_uInt16)(nPageHeight + rPageRect.Top() - rRect.Bottom() )); aColItem.SetRight(nPageHeight + rPageRect.Top() - rRect.Bottom());
} }
else else
{ {
aColItem.SetLeft ((sal_uInt16)(rRect.Left() - rPageRect.Left() )); aColItem.SetLeft(rRect.Left() - rPageRect.Left());
aColItem.SetRight((sal_uInt16)(rPageRect.Right() - rRect.Right() )); aColItem.SetRight(rPageRect.Right() - rRect.Right());
} }
aColItem.SetOrtho(aColItem.CalcOrtho()); aColItem.SetOrtho(aColItem.CalcOrtho());
...@@ -1609,7 +1604,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1609,7 +1604,7 @@ void SwView::StateTabWin(SfxItemSet& rSet)
lcl_FillSvxColumn( lcl_FillSvxColumn(
aCol, aCol,
sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width() ), bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width(),
aColItem, nDist); aColItem, nDist);
if(bBrowse) if(bBrowse)
...@@ -1670,8 +1665,6 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1670,8 +1665,6 @@ void SwView::StateTabWin(SfxItemSet& rSet)
!(nFrmType & FRMTYPE_COLSECT ) ) ) !(nFrmType & FRMTYPE_COLSECT ) ) )
{ {
SwTabCols aTabCols; SwTabCols aTabCols;
//no current value necessary
sal_uInt16 nNum = 0;
if ( ( m_bSetTabRowFromDoc = IsTabRowFromDoc() ) ) if ( ( m_bSetTabRowFromDoc = IsTabRowFromDoc() ) )
{ {
rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos ); rSh.GetMouseTabRows( aTabCols, m_aTabColFromDocPos );
...@@ -1682,50 +1675,52 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1682,50 +1675,52 @@ void SwView::StateTabWin(SfxItemSet& rSet)
} }
const int nLft = aTabCols.GetLeftMin(); const int nLft = aTabCols.GetLeftMin();
const int nRgt = (sal_uInt16)(bVerticalWriting ? nPageWidth : nPageHeight) - const int nRgt = (bVerticalWriting ? nPageWidth : nPageHeight) -
(aTabCols.GetLeftMin() + (aTabCols.GetLeftMin() + aTabCols.GetRight());
aTabCols.GetRight());
const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0); const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0); const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
SvxColumnItem aColItem(nNum, nL, nR); SvxColumnItem aColItem(0, nL, nR);
sal_uInt16 nStart = 0, long nStart = 0;
nEnd; long nEnd = 0;
for ( size_t i = 0; i < aTabCols.Count(); ++i ) for ( size_t i = 0; i < aTabCols.Count(); ++i )
{ {
const SwTabColsEntry& rEntry = aTabCols.GetEntry( i ); const SwTabColsEntry& rEntry = aTabCols.GetEntry( i );
if(bVerticalWriting) if(bVerticalWriting)
{ {
nEnd = sal_uInt16(aTabCols.GetRight() - rEntry.nPos); nEnd = aTabCols.GetRight() - rEntry.nPos;
SvxColumnDescription aColDesc( nStart, nEnd, SvxColumnDescription aColDesc( nStart, nEnd,
aTabCols.GetRight() - rEntry.nMax, aTabCols.GetRight() - rEntry.nMin, aTabCols.GetRight() - rEntry.nMax,
aTabCols.GetRight() - rEntry.nMin,
!aTabCols.IsHidden(i) ); !aTabCols.IsHidden(i) );
aColItem.Append(aColDesc); aColItem.Append(aColDesc);
} }
else else
{ {
nEnd = sal_uInt16(rEntry.nPos - aTabCols.GetLeft()); nEnd = rEntry.nPos - aTabCols.GetLeft();
SvxColumnDescription aColDesc( nStart, nEnd, SvxColumnDescription aColDesc( nStart, nEnd,
sal_uInt16(rEntry.nMin - aTabCols.GetLeft()), sal_uInt16(rEntry.nMax - aTabCols.GetLeft()), rEntry.nMin - aTabCols.GetLeft(),
rEntry.nMax - aTabCols.GetLeft(),
!aTabCols.IsHidden(i) ); !aTabCols.IsHidden(i) );
aColItem.Append(aColDesc); aColItem.Append(aColDesc);
} }
nStart = nEnd; nStart = nEnd;
} }
if(bVerticalWriting) if(bVerticalWriting)
nEnd = static_cast< sal_uInt16 >(aTabCols.GetRight()); nEnd = aTabCols.GetRight();
else else
nEnd = static_cast< sal_uInt16 >(aTabCols.GetLeft()); nEnd = aTabCols.GetLeft();
// put a position protection when the last row cannot be moved // put a position protection when the last row cannot be moved
// due to a page break inside of a row // due to a page break inside of a row
if(!aTabCols.IsLastRowAllowedToChange()) if(!aTabCols.IsLastRowAllowedToChange())
bPutContentProtection = true; bPutContentProtection = true;
SvxColumnDescription aColDesc( nStart, nEnd, SvxColumnDescription aColDesc( nStart, nEnd,
aTabCols.GetRight(), aTabCols.GetRight(), aTabCols.GetRight(),
aTabCols.GetRight(),
false ); false );
aColItem.Append(aColDesc); aColItem.Append(aColDesc);
...@@ -1758,7 +1753,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1758,7 +1753,7 @@ void SwView::StateTabWin(SfxItemSet& rSet)
rSh.GetTabCols( aTabCols ); rSh.GetTabCols( aTabCols );
const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft(); const int nLft = aTabCols.GetLeftMin() + aTabCols.GetLeft();
const int nRgt = (sal_uInt16)nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight()); const int nRgt = nPageWidth -(aTabCols.GetLeftMin() + aTabCols.GetRight());
const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0); const sal_uInt16 nL = static_cast< sal_uInt16 >(nLft > 0 ? nLft : 0);
const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0); const sal_uInt16 nR = static_cast< sal_uInt16 >(nRgt > 0 ? nRgt : 0);
...@@ -1783,7 +1778,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1783,7 +1778,7 @@ void SwView::StateTabWin(SfxItemSet& rSet)
&rDesc.GetMaster().GetCol(); &rDesc.GetMaster().GetCol();
const SwColumns& rCols = pCols->GetColumns(); const SwColumns& rCols = pCols->GetColumns();
sal_uInt16 nNum = rSh.GetCurOutColNum(); sal_uInt16 nNum = rSh.GetCurOutColNum();
sal_uInt16 nCount = std::min(sal_uInt16(nNum + 1), sal_uInt16(rCols.size())); const sal_uInt16 nCount = std::min(sal_uInt16(nNum + 1), sal_uInt16(rCols.size()));
const SwRect aRect( rSh.GetAnyCurRect( pFmt const SwRect aRect( rSh.GetAnyCurRect( pFmt
? RECT_FLY_PRT_EMBEDDED ? RECT_FLY_PRT_EMBEDDED
: RECT_PAGE_PRT, pPt )); : RECT_PAGE_PRT, pPt ));
...@@ -1881,7 +1876,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1881,7 +1876,7 @@ void SwView::StateTabWin(SfxItemSet& rSet)
); );
//So you can also drag with the mouse, without being in the table. //So you can also drag with the mouse, without being in the table.
CurRectType eRecType = RECT_PAGE_PRT; CurRectType eRecType = RECT_PAGE_PRT;
sal_uInt16 nNum = IsTabColFromDoc() ? size_t nNum = IsTabColFromDoc() ?
rSh.GetCurMouseColNum( m_aTabColFromDocPos ): rSh.GetCurMouseColNum( m_aTabColFromDocPos ):
rSh.GetCurOutColNum(); rSh.GetCurOutColNum();
const SwFrmFmt* pFmt = NULL; const SwFrmFmt* pFmt = NULL;
...@@ -1925,11 +1920,11 @@ void SwView::StateTabWin(SfxItemSet& rSet) ...@@ -1925,11 +1920,11 @@ void SwView::StateTabWin(SfxItemSet& rSet)
nNum = rCols.size(); nNum = rCols.size();
} }
for( sal_uInt16 i = 0; i < nNum; ++i ) for( size_t i = 0; i < nNum; ++i )
{ {
const SwColumn* pCol = &rCols[i]; const SwColumn* pCol = &rCols[i];
nStart = pCol->GetLeft() + nWidth; nStart = pCol->GetLeft() + nWidth;
nWidth += pCols->CalcColWidth( i, nTotalWidth ); nWidth += pCols->CalcColWidth( static_cast<sal_uInt16>(i), nTotalWidth );
nEnd = nWidth - pCol->GetRight(); nEnd = nWidth - pCol->GetRight();
} }
if( bFrame || bColSct ) if( bFrame || bColSct )
......
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