summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-01-30 22:43:05 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-01-30 22:46:25 -0500
commit29b322ea0c40423a39efe2f6c2c85a7d2108c512 (patch)
treed3f60a178e1ea6f910962fbb3743a49f7d5fb805
parentd6f97891c1fb0d45e1405afe724aafd1e86efd29 (diff)
Keep the standard row height situation under control.
With this change, applying cell attributes to default cells will no longer change the row heights inadvertently. Change-Id: I57c3546e1725c5e8b37696242e9642b1617f59c3
-rw-r--r--sc/inc/global.hxx4
-rw-r--r--sc/source/core/data/column2.cxx22
-rw-r--r--sc/source/filter/excel/colrowst.cxx4
3 files changed, 12 insertions, 18 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index a381224bb34b..13e4cdfcea1d 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -132,10 +132,6 @@ const SCSIZE MAXSUBTOTAL = 3;
/* standard row height: text + margin - STD_ROWHEIGHT_DIFF */
#define STD_ROWHEIGHT_DIFF 23
-/// use ScGlobal::nStdRowHeight instead of STD_ROW_HEIGHT !
-
-#define STD_ROW_HEIGHT (12.8 * TWIPS_PER_POINT) /* 256 Twips, 0.45 cm */
-
namespace sc
{
inline long TwipsToHMM( long nTwips ) { return (nTwips * 127 + 36) / 72; }
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 794a4621ef1a..e1f832dfea4d 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -725,10 +725,11 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
static sal_uInt16 lcl_GetAttribHeight( const ScPatternAttr& rPattern, sal_uInt16 nFontHeightId )
{
- sal_uInt16 nHeight = (sal_uInt16) ((const SvxFontHeightItem&) rPattern.GetItem(nFontHeightId)).GetHeight();
- const SvxMarginItem* pMargin = (const SvxMarginItem*) &rPattern.GetItem(ATTR_MARGIN);
- nHeight += nHeight / 5;
- // for 10pt gives 240
+ const SvxFontHeightItem& rFontHeight =
+ static_cast<const SvxFontHeightItem&>(rPattern.GetItem(nFontHeightId));
+
+ sal_uInt16 nHeight = rFontHeight.GetHeight();
+ nHeight *= 1.18;
if ( ((const SvxEmphasisMarkItem&)rPattern.
GetItem(ATTR_FONT_EMPHASISMARK)).GetEmphasisMark() != EMPHASISMARK_NONE )
@@ -738,19 +739,16 @@ static sal_uInt16 lcl_GetAttribHeight( const ScPatternAttr& rPattern, sal_uInt16
nHeight += nHeight / 4;
}
- if ( nHeight + 240 > ScGlobal::nDefFontHeight )
- {
- nHeight = sal::static_int_cast<sal_uInt16>( nHeight + ScGlobal::nDefFontHeight );
- nHeight -= 240;
- }
+ const SvxMarginItem& rMargin =
+ static_cast<const SvxMarginItem&>(rPattern.GetItem(ATTR_MARGIN));
- // Standard height: TextHeight + margin - 23
- // -> 257 for Windows
+ nHeight += rMargin.GetTopMargin() + rMargin.GetBottomMargin();
if (nHeight > STD_ROWHEIGHT_DIFF)
nHeight -= STD_ROWHEIGHT_DIFF;
- nHeight += pMargin->GetTopMargin() + pMargin->GetBottomMargin();
+ if (nHeight < ScGlobal::nStdRowHeight)
+ nHeight = ScGlobal::nStdRowHeight;
return nHeight;
}
diff --git a/sc/source/filter/excel/colrowst.cxx b/sc/source/filter/excel/colrowst.cxx
index bc43a1e1984e..dc6eae07b07d 100644
--- a/sc/source/filter/excel/colrowst.cxx
+++ b/sc/source/filter/excel/colrowst.cxx
@@ -50,7 +50,7 @@ XclImpColRowSettings::XclImpColRowSettings( const XclImpRoot& rRoot ) :
maHiddenRows(0, MAXROWCOUNT, false),
mnLastScRow( -1 ),
mnDefWidth( STD_COL_WIDTH ),
- mnDefHeight( static_cast< sal_uInt16 >( STD_ROW_HEIGHT ) ),
+ mnDefHeight( static_cast< sal_uInt16 >( ScGlobal::nStdRowHeight ) ),
mnDefRowFlags( EXC_DEFROW_DEFAULTFLAGS ),
mbHasStdWidthRec( false ),
mbHasDefHeight( false ),
@@ -117,7 +117,7 @@ void XclImpColRowSettings::SetDefHeight( sal_uInt16 nDefHeight, sal_uInt16 nFlag
mnDefRowFlags = nFlags;
if( mnDefHeight == 0 )
{
- mnDefHeight = static_cast< sal_uInt16 >( STD_ROW_HEIGHT );
+ mnDefHeight = static_cast< sal_uInt16 >( ScGlobal::nStdRowHeight );
::set_flag( mnDefRowFlags, EXC_DEFROW_HIDDEN );
}
mbHasDefHeight = true;