diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-03 10:13:00 +1100 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-04 03:17:26 +0000 |
commit | 697d445ed0c7b60e463243db89af32e2145b475b (patch) | |
tree | 5a74d57cdc97f82bc78a686dee345a229a082a72 /sc | |
parent | 91a7580e03d5b47c6e2513afce85ddee45e730b6 (diff) |
vcl: take into account the font width is the average font width
I'm changing the Font class function names:
- SetSize -> SetFontSize
- GetSize -> GetFontSize
- SetHeight -> SetFontHeight
- GetHeight -> GetFontHeight
- SetWidth -> SetAverageFontWidth
- GetWidth -> GetAverageFontWidth
That's because it really makes no sense to say that there is a
single constant font width because obviously proportional fonts
don't have one - the best we can do is an average font width,
which is what folks like Microsoft sort of do already. On a fixed
font, the average is still accurate, for obvious reasons :-)
I'm also not a fan of GetSize/SetSize as I find it a might too
generic.
Change-Id: Ib80a604ba62d6883fd6cbc7994da763976be5c70
Reviewed-on: https://gerrit.libreoffice.org/22069
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/helper/qahelper.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/patattr.cxx | 4 | ||||
-rw-r--r-- | sc/source/filter/excel/xlstyle.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/Accessibility/AccessibleCsvControl.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/cctrl/checklistmenu.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/cctrl/dpcontrol.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/dbgui/csvgrid.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/autofmt.cxx | 18 | ||||
-rw-r--r-- | sc/source/ui/sidebar/CellLineStyleValueSet.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/tabview.cxx | 2 |
14 files changed, 35 insertions, 35 deletions
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index cd9aae6617cc..0779ad35ca36 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -191,11 +191,11 @@ void testFormats(ScBootstrapFixture* pTest, ScDocument* pDoc, sal_Int32 nFormat) pPattern = pDoc->GetPattern(0,0,1); vcl::Font aFont; pPattern->GetFont(aFont,SC_AUTOCOL_RAW); - CPPUNIT_ASSERT_EQUAL_MESSAGE("font size should be 10", 200l, aFont.GetSize().getHeight()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("font size should be 10", 200l, aFont.GetFontSize().getHeight()); CPPUNIT_ASSERT_EQUAL_MESSAGE("font color should be black", COL_AUTO, aFont.GetColor().GetColor()); pPattern = pDoc->GetPattern(0,1,1); pPattern->GetFont(aFont, SC_AUTOCOL_RAW); - CPPUNIT_ASSERT_EQUAL_MESSAGE("font size should be 12", 240l, aFont.GetSize().getHeight()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("font size should be 12", 240l, aFont.GetFontSize().getHeight()); pPattern = pDoc->GetPattern(0,2,1); pPattern->GetFont(aFont, SC_AUTOCOL_RAW); CPPUNIT_ASSERT_EQUAL_MESSAGE("font should be italic", ITALIC_NORMAL, aFont.GetItalic()); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 01dde573414e..07bd2a647b7d 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -304,7 +304,7 @@ long ScColumn::GetNeededSize( if ( bBreak && !rOptions.bTotalSize ) { // limit size for line break - long nCmp = pDev->GetFont().GetSize().Height() * SC_ROT_BREAK_FACTOR; + long nCmp = pDev->GetFont().GetFontSize().Height() * SC_ROT_BREAK_FACTOR; if ( nHeight > nCmp ) nHeight = nCmp; } @@ -485,7 +485,7 @@ long ScColumn::GetNeededSize( if ( bBreak && !rOptions.bTotalSize ) { // limit size for line break - long nCmp = aOldFont.GetSize().Height() * SC_ROT_BREAK_FACTOR; + long nCmp = aOldFont.GetFontSize().Height() * SC_ROT_BREAK_FACTOR; if ( nValue > nCmp ) nValue = nCmp; } diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index c5a886aa3406..61d88799f775 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -399,11 +399,11 @@ void ScPatternAttr::GetFont( aDestMode.SetScaleY( aFractOne ); aEffSize = OutputDevice::LogicToLogic( aSize, aSrcMode, aDestMode ); } - rFont.SetSize( aEffSize ); + rFont.SetFontSize( aEffSize ); } else /* if pOutDev != NULL */ { - rFont.SetSize( Size( 0, (long) nFontHeight ) ); + rFont.SetFontSize( Size( 0, (long) nFontHeight ) ); } // determine effective font color diff --git a/sc/source/filter/excel/xlstyle.cxx b/sc/source/filter/excel/xlstyle.cxx index ebabba382ed0..505c50808500 100644 --- a/sc/source/filter/excel/xlstyle.cxx +++ b/sc/source/filter/excel/xlstyle.cxx @@ -203,7 +203,7 @@ void XclFontData::FillFromVclFont( const vcl::Font& rFont ) maColor = rFont.GetColor(); SetScUnderline( rFont.GetUnderline() ); mnEscapem = EXC_FONTESC_NONE; - SetScHeight( rFont.GetSize().Height() ); + SetScHeight( rFont.GetFontSize().Height() ); SetScWeight( rFont.GetWeight() ); SetScFamily( rFont.GetFamilyType() ); SetFontEncoding( rFont.GetCharSet() ); diff --git a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx index 439caba1b7a2..65d2b5eab4f0 100644 --- a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx +++ b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx @@ -315,7 +315,7 @@ static inline void lcl_FillProperty( PropertyValue& rVal, const OUString& rPropN static void lcl_FillFontAttributes( Sequence< PropertyValue >& rSeq, const vcl::Font& rFont ) { SvxFontItem aFontItem( rFont.GetFamilyType(), rFont.GetFamilyName(), rFont.GetStyleName(), rFont.GetPitch(), rFont.GetCharSet(), ATTR_FONT ); - SvxFontHeightItem aHeightItem( rFont.GetSize().Height(), 100, ATTR_FONT_HEIGHT ); + SvxFontHeightItem aHeightItem( rFont.GetFontSize().Height(), 100, ATTR_FONT_HEIGHT ); SvxLanguageItem aLangItem( rFont.GetLanguage(), ATTR_FONT_LANGUAGE ); sal_Int32 nIndex = lcl_ExpandSequence( rSeq, 7 ); diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 4c4e81147d68..e61945a94842 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1384,7 +1384,7 @@ ScTextWnd::ScTextWnd(ScInputBarGroup* pParent, ScTabViewShell* pViewSh) // always use application font, so a font with cjk chars can be installed vcl::Font aAppFont = GetFont(); aTextFont = aAppFont; - aTextFont.SetSize(PixelToLogic(aAppFont.GetSize(), MAP_TWIP)); // AppFont is in pixels + aTextFont.SetFontSize(PixelToLogic(aAppFont.GetFontSize(), MAP_TWIP)); // AppFont is in pixels const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index a167c130d933..bf1e6383abca 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -89,7 +89,7 @@ ScMenuFloatingWindow::ScMenuFloatingWindow(vcl::Window* pParent, ScDocument* pDo sal_Int32 nScaleFactor = GetDPIScaleFactor(); const sal_uInt16 nPopupFontHeight = 12 * nScaleFactor; maLabelFont = rStyle.GetLabelFont(); - maLabelFont.SetHeight(nPopupFontHeight); + maLabelFont.SetFontHeight(nPopupFontHeight); } ScMenuFloatingWindow::~ScMenuFloatingWindow() @@ -361,14 +361,14 @@ void ScMenuFloatingWindow::drawMenuItem(vcl::RenderContext& rRenderContext, size DecorationView aDecoView(&rRenderContext); long nXOffset = 5; - long nYOffset = (aSize.Height() - maLabelFont.GetHeight())/2; + long nYOffset = (aSize.Height() - maLabelFont.GetFontHeight())/2; rRenderContext. DrawCtrlText(Point(aPos.X()+nXOffset, aPos.Y() + nYOffset), maMenuItems[nPos].maText, 0, maMenuItems[nPos].maText.getLength(), maMenuItems[nPos].mbEnabled ? DrawTextFlags::Mnemonic : DrawTextFlags::Disable); if (maMenuItems[nPos].mpSubMenuWin) { - long nFontHeight = maLabelFont.GetHeight(); + long nFontHeight = maLabelFont.GetFontHeight(); Point aMarkerPos = aPos; aMarkerPos.Y() += aSize.Height() / 2 - nFontHeight / 4 + 1; aMarkerPos.X() += aSize.Width() - nFontHeight + nFontHeight / 4; @@ -723,8 +723,8 @@ void ScMenuFloatingWindow::getMenuItemPosSize(size_t nPos, Point& rPos, Size& rS const sal_uInt16 nLeftMargin = 5; const sal_uInt16 nTopMargin = 5; - const sal_uInt16 nMenuItemHeight = static_cast<sal_uInt16>(maLabelFont.GetHeight()*1.8); - const sal_uInt16 nSepHeight = static_cast<sal_uInt16>(maLabelFont.GetHeight()*0.8); + const sal_uInt16 nMenuItemHeight = static_cast<sal_uInt16>(maLabelFont.GetFontHeight()*1.8); + const sal_uInt16 nSepHeight = static_cast<sal_uInt16>(maLabelFont.GetFontHeight()*0.8); Point aPos1(nLeftMargin, nTopMargin); rPos = aPos1; @@ -939,7 +939,7 @@ void ScCheckListMenuWindow::getSectionPosSize( const long nSingleItemBtnAreaHeight = 32 * nScaleFactor; // height of the middle area below the list box where the single-action buttons are. const long nBottomBtnAreaHeight = 50 * nScaleFactor; // height of the bottom area where the OK and Cancel buttons are. const long nBtnWidth = 90 * nScaleFactor; - const long nLabelHeight = getLabelFont().GetHeight(); + const long nLabelHeight = getLabelFont().GetFontHeight(); const long nBtnHeight = nLabelHeight * 2; const long nBottomMargin = 10 * nScaleFactor; const long nMenuListMargin = 5 * nScaleFactor; diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index a2375a03a838..65d9a541217a 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -123,7 +123,7 @@ void ScDPFieldButton::draw() vcl::Font aAttrFont; static_cast<const ScPatternAttr&>(mpDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)). GetFont( aAttrFont, SC_AUTOCOL_BLACK, mpOutDev, &maZoomY ); - aTextFont.SetSize( aAttrFont.GetSize() ); + aTextFont.SetFontSize( aAttrFont.GetFontSize() ); } mpOutDev->SetFont(aTextFont); mpOutDev->SetTextColor(mpStyle->GetButtonTextColor()); diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index ce7c978e5694..ab07f6fb1ba1 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -227,7 +227,7 @@ void ScCsvGrid::InitColors() void ScCsvGrid::InitFonts() { maMonoFont = OutputDevice::GetDefaultFont( DefaultFontType::FIXED, LANGUAGE_ENGLISH_US, GetDefaultFontFlags::NONE ); - maMonoFont.SetSize( Size( maMonoFont.GetSize().Width(), maHeaderFont.GetSize().Height() ) ); + maMonoFont.SetFontSize( Size( maMonoFont.GetFontSize().Width(), maHeaderFont.GetFontSize().Height() ) ); /* *** Set edit engine defaults *** maMonoFont for Latin script, smaller default font for Asian and Complex script. */ @@ -245,7 +245,7 @@ void ScCsvGrid::InitFonts() aDefSet.Put( aComplexItem ); // set Asian/Complex font size to height of character in Latin font - sal_uLong nFontHt = static_cast< sal_uLong >( maMonoFont.GetSize().Height() ); + sal_uLong nFontHt = static_cast< sal_uLong >( maMonoFont.GetFontSize().Height() ); aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CJK ) ); aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CTL ) ); diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx index 302a48cc184d..b5b49315d078 100644 --- a/sc/source/ui/miscdlgs/autofmt.cxx +++ b/sc/source/ui/miscdlgs/autofmt.cxx @@ -116,7 +116,7 @@ void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font if ( pCurData ) { rFont = rCJKFont = rCTLFont = GetFont(); - Size aFontSize( rFont.GetSize().Width(), 10 * GetDPIScaleFactor() ); + Size aFontSize( rFont.GetFontSize().Width(), 10 * GetDPIScaleFactor() ); const SvxFontItem* pFontItem = static_cast<const SvxFontItem*> (pCurData->GetItem( nIndex, ATTR_FONT )); const SvxWeightItem* pWeightItem = static_cast<const SvxWeightItem*> (pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT )); @@ -145,14 +145,14 @@ void ScAutoFmtPreview::MakeFonts( sal_uInt16 nIndex, vcl::Font& rFont, vcl::Font #define SETONALLFONTS( MethodName, Value ) \ rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value ); - SETONALLFONTS( SetUnderline, (FontLineStyle)pUnderlineItem->GetValue() ) - SETONALLFONTS( SetOverline, (FontLineStyle)pOverlineItem->GetValue() ) - SETONALLFONTS( SetStrikeout, (FontStrikeout)pCrossedOutItem->GetValue() ) - SETONALLFONTS( SetOutline, pContourItem->GetValue() ) - SETONALLFONTS( SetShadow, pShadowedItem->GetValue() ) - SETONALLFONTS( SetColor, aColor ) - SETONALLFONTS( SetSize, aFontSize ) - SETONALLFONTS( SetTransparent, true ) + SETONALLFONTS( SetUnderline, (FontLineStyle)pUnderlineItem->GetValue() ) + SETONALLFONTS( SetOverline, (FontLineStyle)pOverlineItem->GetValue() ) + SETONALLFONTS( SetStrikeout, (FontStrikeout)pCrossedOutItem->GetValue() ) + SETONALLFONTS( SetOutline, pContourItem->GetValue() ) + SETONALLFONTS( SetShadow, pShadowedItem->GetValue() ) + SETONALLFONTS( SetColor, aColor ) + SETONALLFONTS( SetFontSize, aFontSize ) + SETONALLFONTS( SetTransparent, true ) #undef SETONALLFONTS } diff --git a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx index 6040969e8de2..ec05c9168667 100644 --- a/sc/source/ui/sidebar/CellLineStyleValueSet.cxx +++ b/sc/source/ui/sidebar/CellLineStyleValueSet.cxx @@ -81,9 +81,9 @@ void CellLineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt ) Color aOldFillColor = pDev->GetFillColor(); vcl::Font aFont(OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, MsLangId::getSystemLanguage(), GetDefaultFontFlags::OnlyOne)); - Size aSize = aFont.GetSize(); + Size aSize = aFont.GetFontSize(); aSize.Height() = nRectHeight*3/5; - aFont.SetSize( aSize ); + aFont.SetFontSize( aSize ); long nTLX = aBLPos.X() + 5, nTLY = aBLPos.Y() + ( nRectHeight - nItemId )/2; long nTRX = aBLPos.X() + nRectWidth * 7 / 9 - 15, nTRY = aBLPos.Y() + ( nRectHeight - nItemId )/2; diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 866660b63f0a..9005f8b5b672 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -109,7 +109,7 @@ static void lcl_DrawOneFrame( vcl::RenderContext* pDev, const Rectangle& rInnerP // everything else from application font vcl::Font aAppFont = pDev->GetSettings().GetStyleSettings().GetAppFont(); - aAppFont.SetSize( aAttrFont.GetSize() ); + aAppFont.SetFontSize( aAttrFont.GetFontSize() ); aAppFont.SetAlignment( ALIGN_TOP ); pDev->SetFont( aAppFont ); @@ -1281,14 +1281,14 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, else { // find right font size for DrawText - aFont.SetSize( Size( 0,100 ) ); + aFont.SetFontSize( Size( 0,100 ) ); rRenderContext.SetFont( aFont ); Size aSize100(rRenderContext.GetTextWidth( aThisPageStr ), rRenderContext.GetTextHeight() ); // 40% of width or 60% of height long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width(); long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height(); - aFont.SetSize( Size( 0,std::min(nSizeX,nSizeY) ) ); + aFont.SetFontSize( Size( 0,std::min(nSizeX,nSizeY) ) ); rRenderContext.SetFont( aFont ); // centered output with DrawText diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 6cd5ed5be3c3..75d60d988a7d 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -235,9 +235,9 @@ void ScDrawStringsVars::SetShrinkScale( long nScale, SvtScriptType nScript ) aFraction *= pOutput->aZoomY; vcl::Font aTmpFont; pPattern->GetFont( aTmpFont, SC_AUTOCOL_RAW, pFmtDevice, &aFraction, pCondSet, nScript ); - long nNewHeight = aTmpFont.GetHeight(); + long nNewHeight = aTmpFont.GetFontHeight(); if ( nNewHeight > 0 ) - aFont.SetHeight( nNewHeight ); + aFont.SetFontHeight( nNewHeight ); // set font and dependent variables as in SetPattern diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index cf82bf897559..ecb50caa53cc 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -348,7 +348,7 @@ void ScTabView::DoResize( const Point& rOffset, const Size& rSize, bool bInner ) const StyleSettings& rStyleSettings = pFrameWin->GetSettings().GetStyleSettings(); - sal_Int32 nTabWidth = pFrameWin->GetFont().GetHeight() + WIDTH_MARGIN; + sal_Int32 nTabWidth = pFrameWin->GetFont().GetFontHeight() + WIDTH_MARGIN; if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE ) { |