diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-01-30 22:43:05 -0500 |
---|---|---|
committer | Fridrich Strba <fridrich@documentfoundation.org> | 2014-02-06 14:38:30 +0000 |
commit | 0003e02b1c96e01607924873697a52fb813343ac (patch) | |
tree | 9ea436561ae183c401d1d3968457bc73f4888a4d /sc | |
parent | 25cb5355ce259c29d481eb9c76a4fab53d03e4cb (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.
Without this, applying background colors to cells, pasting to a
range of cells etc would make the row heights slightly shorter
which is 1) odd, and 2) causes all sorts of rendering issues because
internally we assume these actions wouldn't change the row heights.
Change-Id: I57c3546e1725c5e8b37696242e9642b1617f59c3
(cherry picked from commit 29b322ea0c40423a39efe2f6c2c85a7d2108c512)
Reviewed-on: https://gerrit.libreoffice.org/7774
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/global.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 22 | ||||
-rw-r--r-- | sc/source/filter/excel/colrowst.cxx | 4 |
3 files changed, 12 insertions, 18 deletions
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index 9babb88fbe3f..c7ef42931a97 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -131,10 +131,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 04f127fba81e..018052f9c0a1 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; |