summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2016-02-03 10:13:00 +1100
committerChris Sherlock <chris.sherlock79@gmail.com>2016-02-04 03:17:26 +0000
commit697d445ed0c7b60e463243db89af32e2145b475b (patch)
tree5a74d57cdc97f82bc78a686dee345a229a082a72 /editeng
parent91a7580e03d5b47c6e2513afce85ddee45e730b6 (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 'editeng')
-rw-r--r--editeng/source/editeng/editattr.cxx2
-rw-r--r--editeng/source/editeng/editdoc.cxx2
-rw-r--r--editeng/source/editeng/editeng.cxx2
-rw-r--r--editeng/source/editeng/eertfpar.cxx2
-rw-r--r--editeng/source/editeng/impedit3.cxx28
-rw-r--r--editeng/source/editeng/impedit4.cxx2
-rw-r--r--editeng/source/items/bulitem.cxx2
-rw-r--r--editeng/source/items/svxfont.cxx8
-rw-r--r--editeng/source/outliner/outliner.cxx4
-rw-r--r--editeng/source/uno/unofdesc.cxx6
10 files changed, 29 insertions, 29 deletions
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index ff71dbf40d99..acb3dfe97777 100644
--- a/editeng/source/editeng/editattr.cxx
+++ b/editeng/source/editeng/editattr.cxx
@@ -163,7 +163,7 @@ EditCharAttribFontHeight::EditCharAttribFontHeight( const SvxFontHeightItem& rAt
void EditCharAttribFontHeight::SetFont( SvxFont& rFont, OutputDevice* )
{
// Property is ignored
- rFont.SetSize( Size( rFont.GetSize().Width(), static_cast<const SvxFontHeightItem*>(GetItem())->GetHeight() ) );
+ rFont.SetFontSize( Size( rFont.GetFontSize().Width(), static_cast<const SvxFontHeightItem*>(GetItem())->GetHeight() ) );
}
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 8ab16b79da7d..6f026127967d 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2047,7 +2047,7 @@ void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, bool bSearchInParent, S
if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_BKGCOLOR ) == SfxItemState::SET ) )
rFont.SetFillColor( static_cast<const SvxBackgroundColorItem&>(rSet.Get( EE_CHAR_BKGCOLOR )).GetValue() );
if ( bSearchInParent || ( rSet.GetItemState( nWhich_FontHeight ) == SfxItemState::SET ) )
- rFont.SetSize( Size( rFont.GetSize().Width(), static_cast<const SvxFontHeightItem&>(rSet.Get( nWhich_FontHeight ) ).GetHeight() ) );
+ rFont.SetFontSize( Size( rFont.GetFontSize().Width(), static_cast<const SvxFontHeightItem&>(rSet.Get( nWhich_FontHeight ) ).GetHeight() ) );
if ( bSearchInParent || ( rSet.GetItemState( nWhich_Weight ) == SfxItemState::SET ) )
rFont.SetWeight( static_cast<const SvxWeightItem&>(rSet.Get( nWhich_Weight )).GetWeight() );
if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_UNDERLINE ) == SfxItemState::SET ) )
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index 3d909a59ccd1..efcf60790b61 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2566,7 +2566,7 @@ void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const SvxFont& rFont )
{
rSet.Put( SvxLanguageItem( rFont.GetLanguage(), EE_CHAR_LANGUAGE ) );
rSet.Put( SvxFontItem( rFont.GetFamilyType(), rFont.GetFamilyName(), OUString(), rFont.GetPitch(), rFont.GetCharSet(), EE_CHAR_FONTINFO ) );
- rSet.Put( SvxFontHeightItem( rFont.GetSize().Height(), 100, EE_CHAR_FONTHEIGHT ) );
+ rSet.Put( SvxFontHeightItem( rFont.GetFontSize().Height(), 100, EE_CHAR_FONTHEIGHT ) );
rSet.Put( SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH ) );
rSet.Put( SvxShadowedItem( rFont.IsShadow(), EE_CHAR_SHADOW ) );
rSet.Put( SvxEscapementItem( rFont.GetEscapement(), rFont.GetPropr(), EE_CHAR_ESCAPEMENT ) );
diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx
index 341adca793c2..65ea358246a7 100644
--- a/editeng/source/editeng/eertfpar.cxx
+++ b/editeng/source/editeng/eertfpar.cxx
@@ -341,7 +341,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet )
nEsc *= 10; //HalPoints => Twips was embezzled in RTFITEM.CXX!
SvxFont aFont;
mpEditEngine->SeekCursor(aStartPaM.GetNode(), aStartPaM.GetIndex()+1, aFont);
- nEsc = nEsc * 100 / aFont.GetSize().Height();
+ nEsc = nEsc * 100 / aFont.GetFontSize().Height();
SvxEscapementItem aEscItem( (short) nEsc, static_cast<const SvxEscapementItem*>(pItem)->GetProportionalHeight(), EE_CHAR_ESCAPEMENT );
rSet.GetAttrSet().Put( aEscItem );
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 9b1edb499e10..4426fdf0b20e 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -836,7 +836,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
ImplInitDigitMode(GetRefDevice(), aTmpFont.GetLanguage());
if ( IsFixedCellHeight() )
- nTextLineHeight = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetHeight() );
+ nTextLineHeight = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() );
else
nTextLineHeight = aTmpFont.GetPhysTxtSize( GetRefDevice(), OUString() ).Height();
// Metrics can be greater
@@ -1090,7 +1090,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
if ( ( aTmpFont.GetFixKerning() > 0 ) && ( ( nTmpPos + pPortion->GetLen() ) < pNode->Len() ) )
pPortion->GetSize().Width() += aTmpFont.GetFixKerning();
if ( IsFixedCellHeight() )
- pPortion->GetSize().Height() = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetHeight() );
+ pPortion->GetSize().Height() = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() );
}
if ( bCalcCharPositions )
{
@@ -1304,7 +1304,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
ImplInitDigitMode(pRefDev, aTmpFont.GetLanguage());
if ( IsFixedCellHeight() )
- aTextSize.Height() = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetHeight() );
+ aTextSize.Height() = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() );
else
aTextSize.Height() = aTmpFont.GetPhysTxtSize( pRefDev, OUString() ).Height();
pLine->SetHeight( (sal_uInt16)aTextSize.Height() );
@@ -1638,7 +1638,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uIn
TextPortion* pDummyPortion = new TextPortion( 0 );
pDummyPortion->GetSize() = aTmpFont.GetPhysTxtSize( pRefDev, OUString() );
if ( IsFixedCellHeight() )
- pDummyPortion->GetSize().Height() = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetHeight() );
+ pDummyPortion->GetSize().Height() = ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() );
pParaPortion->GetTextPortions().Append(pDummyPortion);
FormatterFontMetric aFormatterMetrics;
RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont );
@@ -2599,9 +2599,9 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo
rFont.SetFamily( rFontItem.GetFamily() );
rFont.SetPitch( rFontItem.GetPitch() );
rFont.SetCharSet( rFontItem.GetCharSet() );
- Size aSz( rFont.GetSize() );
+ Size aSz( rFont.GetFontSize() );
aSz.Height() = static_cast<const SvxFontHeightItem&>(pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_FONTHEIGHT, nScriptType ) ) ).GetHeight();
- rFont.SetSize( aSz );
+ rFont.SetFontSize( aSz );
rFont.SetWeight( static_cast<const SvxWeightItem&>(pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_WEIGHT, nScriptType ))).GetWeight() );
rFont.SetItalic( static_cast<const SvxPostureItem&>(pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_ITALIC, nScriptType ))).GetPosture() );
rFont.SetLanguage( static_cast<const SvxLanguageItem&>(pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ))).GetLanguage() );
@@ -2694,7 +2694,7 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo
// Set the font as we want it to look like & reset the Propr attribute
// so that it is not counted twice.
- Size aRealSz( aMetric.GetSize() );
+ Size aRealSz( aMetric.GetFontSize() );
rFont.SetPropr( 100 );
if ( aStatus.DoStretch() )
@@ -2750,7 +2750,7 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFo
aRealSz.Width() *= nRelWidth;
aRealSz.Width() /= 100;
}
- rFont.SetSize( aRealSz );
+ rFont.SetFontSize( aRealSz );
// Font is not restored ...
}
@@ -2827,8 +2827,8 @@ void ImpEditEngine::RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics
if ( IsFixedCellHeight() )
{
- nAscent = sal::static_int_cast< sal_uInt16 >( rFont.GetHeight() );
- nDescent= sal::static_int_cast< sal_uInt16 >( ImplCalculateFontIndependentLineSpacing( rFont.GetHeight() ) - nAscent );
+ nAscent = sal::static_int_cast< sal_uInt16 >( rFont.GetFontHeight() );
+ nDescent= sal::static_int_cast< sal_uInt16 >( ImplCalculateFontIndependentLineSpacing( rFont.GetFontHeight() ) - nAscent );
}
else
{
@@ -2856,7 +2856,7 @@ void ImpEditEngine::RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics
{
// Now in consideration of Escape/Propr
// possibly enlarge Ascent or Descent
- short nDiff = (short)(rFont.GetSize().Height()*rFont.GetEscapement()/100L);
+ short nDiff = (short)(rFont.GetFontSize().Height()*rFont.GetEscapement()/100L);
if ( rFont.GetEscapement() > 0 )
{
nAscent = (sal_uInt16) (((long)nAscent)*nPropr/100 + nDiff);
@@ -3368,7 +3368,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
// In case of high/low do it yourself:
if ( aTmpFont.GetEscapement() )
{
- long nDiff = aTmpFont.GetSize().Height() * aTmpFont.GetEscapement() / 100L;
+ long nDiff = aTmpFont.GetFontSize().Height() * aTmpFont.GetEscapement() / 100L;
if ( !IsVertical() )
aOutPos.Y() -= nDiff;
else
@@ -3498,7 +3498,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
short _nEsc = aTmpFont.GetEscapement();
if( _nEsc )
{
- long nShift = ((_nEsc*long(aTmpFont.GetSize().Height()))/ 100L);
+ long nShift = ((_nEsc*long(aTmpFont.GetFontSize().Height()))/ 100L);
if( !IsVertical() )
aRedLineTmpPos.Y() -= nShift;
else
@@ -3507,7 +3507,7 @@ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRect, Point aSt
}
Color aOldColor( pOutDev->GetLineColor() );
pOutDev->SetLineColor( Color( GetColorConfig().GetColorValue( svtools::SPELL ).nColor ) );
- lcl_DrawRedLines( pOutDev, aTmpFont.GetSize().Height(), aRedLineTmpPos, (size_t)nIndex, (size_t)nIndex + rTextPortion.GetLen(), pDXArray, pPortion->GetNode()->GetWrongList(), nOrientation, aOrigin, IsVertical(), rTextPortion.IsRightToLeft() );
+ lcl_DrawRedLines( pOutDev, aTmpFont.GetFontSize().Height(), aRedLineTmpPos, (size_t)nIndex, (size_t)nIndex + rTextPortion.GetLen(), pDXArray, pPortion->GetNode()->GetWrongList(), nOrientation, aOrigin, IsVertical(), rTextPortion.IsRightToLeft() );
pOutDev->SetLineColor( aOldColor );
}
}
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 0ca6114b1093..3a57c5dfb709 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -967,7 +967,7 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput,
SeekCursor( pNode, nPos, aFont );
MapMode aPntMode( MAP_POINT );
long nFontHeight = GetRefDevice()->LogicToLogic(
- aFont.GetSize(), &GetRefMapMode(), &aPntMode ).Height();
+ aFont.GetFontSize(), &GetRefMapMode(), &aPntMode ).Height();
nFontHeight *=2; // Half Points
sal_uInt16 const nProp = static_cast<const SvxEscapementItem&>(rItem).GetProportionalHeight();
sal_uInt16 nProp100 = nProp*100; // For SWG-Token Prop in 100th percent.
diff --git a/editeng/source/items/bulitem.cxx b/editeng/source/items/bulitem.cxx
index 8b41023f79f2..8599beab8005 100644
--- a/editeng/source/items/bulitem.cxx
+++ b/editeng/source/items/bulitem.cxx
@@ -87,7 +87,7 @@ vcl::Font SvxBulletItem::CreateFont( SvStream& rStream, sal_uInt16 nVer )
{
sal_Int32 nHeight(0), nWidth(0);
rStream.ReadInt32( nHeight ); rStream.ReadInt32( nWidth ); Size aSize( nWidth, nHeight );
- aFont.SetSize( aSize );
+ aFont.SetFontSize( aSize );
}
bool bTemp;
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx
index 83b21f675859..3fa6dd55cc4d 100644
--- a/editeng/source/items/svxfont.cxx
+++ b/editeng/source/items/svxfont.cxx
@@ -321,8 +321,8 @@ void SvxFont::SetPhysFont( OutputDevice *pOut ) const
else
{
Font aNewFont( *this );
- Size aSize( aNewFont.GetSize() );
- aNewFont.SetSize( Size( aSize.Width() * nPropr / 100L,
+ Size aSize( aNewFont.GetFontSize() );
+ aNewFont.SetFontSize( Size( aSize.Width() * nPropr / 100L,
aSize.Height() * nPropr / 100L ) );
if ( !rCurrentFont.IsSameInstance( aNewFont ) )
pOut->SetFont( aNewFont );
@@ -460,7 +460,7 @@ void SvxFont::QuickDrawText( OutputDevice *pOut,
if ( nEsc )
{
- long nDiff = GetSize().Height();
+ long nDiff = GetFontSize().Height();
nDiff *= nEsc;
nDiff /= 100;
@@ -518,7 +518,7 @@ void SvxFont::DrawPrev( OutputDevice *pOut, Printer* pPrinter,
nTmpEsc = -20;
else
nTmpEsc = nEsc;
- Size aSize = ( this->GetSize() );
+ Size aSize = ( this->GetFontSize() );
aPos.Y() -= ( ( nTmpEsc * long( aSize.Height() ) ) / 100L );
}
Font aOldFont( ChgPhysFont( pOut ) );
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index f741f1371d2f..0b96792963a4 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -889,12 +889,12 @@ vcl::Font Outliner::ImpCalcBulletFont( sal_Int32 nPara ) const
GetGlobalCharStretching(nStretchX, nStretchY);
sal_uInt16 nScale = pFmt->GetBulletRelSize() * nStretchY / 100;
- sal_uLong nScaledLineHeight = aStdFont.GetSize().Height();
+ sal_uLong nScaledLineHeight = aStdFont.GetFontSize().Height();
nScaledLineHeight *= nScale*10;
nScaledLineHeight /= 1000;
aBulletFont.SetAlignment( ALIGN_BOTTOM );
- aBulletFont.SetSize( Size( 0, nScaledLineHeight ) );
+ aBulletFont.SetFontSize( Size( 0, nScaledLineHeight ) );
bool bVertical = IsVertical();
aBulletFont.SetVertical( bVertical );
aBulletFont.SetOrientation( bVertical ? 2700 : 0 );
diff --git a/editeng/source/uno/unofdesc.cxx b/editeng/source/uno/unofdesc.cxx
index 59390d2034b6..cf387b1bce88 100644
--- a/editeng/source/uno/unofdesc.cxx
+++ b/editeng/source/uno/unofdesc.cxx
@@ -42,7 +42,7 @@ void SvxUnoFontDescriptor::ConvertToFont( const awt::FontDescriptor& rDesc, vcl:
{
rFont.SetFamilyName( rDesc.Name );
rFont.SetStyleName( rDesc.StyleName );
- rFont.SetSize( Size( rDesc.Width, rDesc.Height ) );
+ rFont.SetFontSize( Size( rDesc.Width, rDesc.Height ) );
rFont.SetFamily( (FontFamily)rDesc.Family );
rFont.SetCharSet( (rtl_TextEncoding)rDesc.CharSet );
rFont.SetPitch( (FontPitch)rDesc.Pitch );
@@ -59,8 +59,8 @@ void SvxUnoFontDescriptor::ConvertFromFont( const vcl::Font& rFont, awt::FontDes
{
rDesc.Name = rFont.GetFamilyName();
rDesc.StyleName = rFont.GetStyleName();
- rDesc.Width = sal::static_int_cast< sal_Int16 >(rFont.GetSize().Width());
- rDesc.Height = sal::static_int_cast< sal_Int16 >(rFont.GetSize().Height());
+ rDesc.Width = sal::static_int_cast< sal_Int16 >(rFont.GetFontSize().Width());
+ rDesc.Height = sal::static_int_cast< sal_Int16 >(rFont.GetFontSize().Height());
rDesc.Family = sal::static_int_cast< sal_Int16 >(rFont.GetFamilyType());
rDesc.CharSet = rFont.GetCharSet();
rDesc.Pitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch());