summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2016-01-20 20:47:19 +1100
committerChris Sherlock <chris.sherlock79@gmail.com>2016-01-20 11:40:01 +0000
commitab6f80909877f1e14de252c456dd2acd84c43974 (patch)
tree313139b1b1f7a155de4812cc23b25b597e6cc3fe /vcl
parente46baa9e04a7715f35b7a068dde6cbabc6dd4775 (diff)
vcl: add more property functions to Font
Added increase and decrease quality functions to Font class, and also charset mutator and accessor function. See commit description in 8bfccd3a71d911b6d ("vcl: Create accessor and mutator for font scaling in FontMetric") for reasoning behind patch. Unit test change in vcl/qa/cppunit/font.cxx: - enhanced to check increase and decrease quality functions Change-Id: I2f5970438f6ef1ad185163d5fdcec5bbc88912a4 Reviewed-on: https://gerrit.libreoffice.org/21622 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/fontattributes.hxx2
-rw-r--r--vcl/inc/impfont.hxx8
-rw-r--r--vcl/qa/cppunit/font.cxx8
-rw-r--r--vcl/source/font/font.cxx30
4 files changed, 29 insertions, 19 deletions
diff --git a/vcl/inc/fontattributes.hxx b/vcl/inc/fontattributes.hxx
index cd534008a5f6..0168a3284965 100644
--- a/vcl/inc/fontattributes.hxx
+++ b/vcl/inc/fontattributes.hxx
@@ -50,6 +50,7 @@ public:
void SetItalic(const FontItalic eItalic ) { meItalic = eItalic; }
void SetWeight(const FontWeight eWeight ) { meWeight = eWeight; }
void SetWidthType(const FontWidth eWidthType) { meWidthType = eWidthType; }
+ void SetCharSet( const rtl_TextEncoding );
void SetSymbolFlag(const bool );
@@ -89,7 +90,6 @@ public:
void SetEmbeddableFlag ( bool bEmbeddable ) { mbEmbeddable = bEmbeddable; }
void SetSubsettableFlag( bool bSubsettable ) { mbSubsettable = bSubsettable; }
void SetOrientationFlag( bool bCanRotate ) { mbOrientation = bCanRotate; }
- void SetCharSet( const rtl_TextEncoding );
private:
// device independent variables
diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx
index c425ea79f371..26616930e0d9 100644
--- a/vcl/inc/impfont.hxx
+++ b/vcl/inc/impfont.hxx
@@ -51,6 +51,7 @@ public:
FontPitch GetPitchNoAsk() const { return mePitch; }
FontWidth GetWidthType() { if(meWidthType==WIDTH_DONTKNOW) AskConfig(); return meWidthType; }
FontWidth GetWidthTypeNoAsk() const { return meWidthType; }
+ rtl_TextEncoding GetCharSet() const { return meCharSet; }
bool IsSymbolFont() const { return mbSymbol; }
@@ -68,9 +69,9 @@ public:
// device dependent functions
int GetQuality() const { return mnQuality; }
- void SetQuality( int nQuality ) { mnQuality = nQuality; }
- void IncreaseQualityBy( int nQualityAmount ) { mnQuality += nQualityAmount; }
- void DecreaseQualityBy( int nQualityAmount ) { mnQuality -= nQualityAmount; }
+ void SetQuality( int nQuality ) { mnQuality = nQuality; }
+ void IncreaseQualityBy( int nQualityAmount ) { mnQuality += nQualityAmount; }
+ void DecreaseQualityBy( int nQualityAmount ) { mnQuality -= nQualityAmount; }
/* Missing function: OUString GetMapNames() const; */
/* Missing function: bool IsBuiltInFont() const; */
@@ -86,6 +87,7 @@ public:
/* Missing function: void SetEmbeddableFlag( bool ); */
/* Missing function: void SetSettableFlag( bool ); */
/* missing function: void SetOrientationFlag( bool ); */
+ void SetCharSet( const rtl_TextEncoding eCharSet ) { meCharSet = eCharSet; }
bool operator==( const ImplFont& ) const;
diff --git a/vcl/qa/cppunit/font.cxx b/vcl/qa/cppunit/font.cxx
index f4fcf1892996..5649b329ba59 100644
--- a/vcl/qa/cppunit/font.cxx
+++ b/vcl/qa/cppunit/font.cxx
@@ -100,7 +100,13 @@ void VclFontTest::testQuality()
CPPUNIT_ASSERT_EQUAL( (int)0, aFont.GetQuality() );
aFont.SetQuality( 100 );
- CPPUNIT_ASSERT_EQUAL( (int)100, aFont.GetQuality());
+ CPPUNIT_ASSERT_EQUAL( (int)100, aFont.GetQuality() );
+
+ aFont.IncreaseQualityBy( 50 );
+ CPPUNIT_ASSERT_EQUAL( (int)150, aFont.GetQuality() );
+
+ aFont.DecreaseQualityBy( 100 );
+ CPPUNIT_ASSERT_EQUAL( (int)50, aFont.GetQuality() );
}
diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx
index 7fe618aa3f31..c2e676be2b22 100644
--- a/vcl/source/font/font.cxx
+++ b/vcl/source/font/font.cxx
@@ -169,35 +169,35 @@ void Font::SetFamily( FontFamily eFamily )
void Font::SetCharSet( rtl_TextEncoding eCharSet )
{
- if( mpImplFont->meCharSet != eCharSet )
+ if( mpImplFont->GetCharSet() != eCharSet )
{
MakeUnique();
- mpImplFont->meCharSet = eCharSet;
+ mpImplFont->SetCharSet( eCharSet );
if ( eCharSet == RTL_TEXTENCODING_SYMBOL )
- mpImplFont->mbSymbol = true;
+ mpImplFont->SetSymbolFlag( true );
else
- mpImplFont->mbSymbol = false;
+ mpImplFont->SetSymbolFlag( false );
}
}
bool Font::IsSymbolFont() const
{
- return mpImplFont->mbSymbol;
+ return mpImplFont->IsSymbolFont();
}
void Font::SetSymbolFlag( bool bSymbol )
{
- mpImplFont->mbSymbol = bSymbol;
+ mpImplFont->SetSymbolFlag( bSymbol );
- if ( bSymbol )
+ if ( IsSymbolFont() )
{
- mpImplFont->meCharSet = RTL_TEXTENCODING_SYMBOL;
+ mpImplFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
}
else
{
- if ( mpImplFont->meCharSet == RTL_TEXTENCODING_SYMBOL )
- mpImplFont->meCharSet = RTL_TEXTENCODING_DONTKNOW;
+ if ( mpImplFont->GetCharSet() == RTL_TEXTENCODING_SYMBOL )
+ mpImplFont->SetCharSet( RTL_TEXTENCODING_DONTKNOW );
}
}
@@ -466,7 +466,7 @@ void Font::GetFontAttributes( FontAttributes& rAttrs ) const
rAttrs.SetItalic( mpImplFont->GetItalicNoAsk() );
rAttrs.SetWeight( mpImplFont->GetWeightNoAsk() );
rAttrs.SetWidthType( WIDTH_DONTKNOW );
- rAttrs.SetSymbolFlag( mpImplFont->meCharSet == RTL_TEXTENCODING_SYMBOL );
+ rAttrs.SetSymbolFlag( mpImplFont->GetCharSet() == RTL_TEXTENCODING_SYMBOL );
}
SvStream& ReadImplFont( SvStream& rIStm, ImplFont& rImplFont )
@@ -480,7 +480,7 @@ SvStream& ReadImplFont( SvStream& rIStm, ImplFont& rImplFont )
rImplFont.maStyleName = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
ReadPair( rIStm, rImplFont.maSize );
- rIStm.ReadUInt16( nTmp16 ); rImplFont.meCharSet = (rtl_TextEncoding) nTmp16;
+ rIStm.ReadUInt16( nTmp16 ); rImplFont.SetCharSet( (rtl_TextEncoding) nTmp16 );
rIStm.ReadUInt16( nTmp16 ); rImplFont.meFamily = (FontFamily) nTmp16;
rIStm.ReadUInt16( nTmp16 ); rImplFont.SetPitch( (FontPitch) nTmp16 );
rIStm.ReadUInt16( nTmp16 ); rImplFont.SetWeight( (FontWeight) nTmp16 );
@@ -521,7 +521,7 @@ SvStream& WriteImplFont( SvStream& rOStm, const ImplFont& rImplFont )
rOStm.WriteUniOrByteString( rImplFont.maStyleName, rOStm.GetStreamCharSet() );
WritePair( rOStm, rImplFont.maSize );
- rOStm.WriteUInt16( GetStoreCharSet( rImplFont.meCharSet ) );
+ rOStm.WriteUInt16( GetStoreCharSet( rImplFont.GetCharSet() ) );
rOStm.WriteUInt16( rImplFont.GetFamilyNoAsk() );
rOStm.WriteUInt16( rImplFont.GetPitchNoAsk() );
rOStm.WriteUInt16( rImplFont.GetWeightNoAsk() );
@@ -785,7 +785,7 @@ long Font::GetHeight() const { return mpImplFont->maSize.Height(); }
void Font::SetWidth( long nWidth ) { SetSize( Size( nWidth, mpImplFont->maSize.Height() ) ); }
long Font::GetWidth() const { return mpImplFont->maSize.Width(); }
-rtl_TextEncoding Font::GetCharSet() const { return mpImplFont->meCharSet; }
+rtl_TextEncoding Font::GetCharSet() const { return mpImplFont->GetCharSet(); }
const LanguageTag& Font::GetLanguageTag() const { return mpImplFont->maLanguageTag; }
const LanguageTag& Font::GetCJKContextLanguageTag() const { return mpImplFont->maCJKLanguageTag; }
@@ -810,6 +810,8 @@ FontFamily Font::GetFamily() const { return mpImplFont->GetFamilyNoAsk(); }
int Font::GetQuality() const { return mpImplFont->GetQuality(); }
void Font::SetQuality( int nQuality ) { mpImplFont->SetQuality( nQuality ); }
+void Font::IncreaseQualityBy( int nQualityAmount ) { mpImplFont->IncreaseQualityBy( nQualityAmount ); }
+void Font::DecreaseQualityBy( int nQualityAmount ) { mpImplFont->DecreaseQualityBy( nQualityAmount ); }
bool Font::IsOutline() const { return mpImplFont->mbOutline; }
bool Font::IsShadow() const { return mpImplFont->mbShadow; }