summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2014-04-27 14:37:48 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2014-04-27 20:53:29 +1000
commitc08856c17375fd7edcc35c13823ce92bf829c373 (patch)
treeaea69dd998de6e4f57b17c468606d2261bcb03c7 /vcl
parenta9574c492b604ffa1eccb433a1d8c835265240f6 (diff)
VCL: rearrange font functions, move functions into OutputDevice
I have rearrange the various functions of OutputDevice to better group them in outdev.hxx. Also moved ImplRotatePos and ImplDrawWavePixel into the OutputDevice class. Change-Id: I0b384a4d094dffcfb3ee19c29562630cfb3a2167
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/outdev/font.cxx158
-rw-r--r--vcl/source/outdev/outdev.cxx80
-rw-r--r--vcl/source/outdev/outdevstate.cxx111
-rw-r--r--vcl/source/outdev/textline.cxx14
4 files changed, 184 insertions, 179 deletions
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index abec7828f7ea..0abe0257cb0e 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -61,57 +61,6 @@ using namespace ::rtl;
using namespace ::vcl;
using namespace ::utl;
-void ImplRotatePos( long nOriginX, long nOriginY, long& rX, long& rY,
- int nOrientation )
-{
- if ( (nOrientation >= 0) && !(nOrientation % 900) )
- {
- if ( (nOrientation >= 3600) )
- nOrientation %= 3600;
-
- if ( nOrientation )
- {
- rX -= nOriginX;
- rY -= nOriginY;
-
- if ( nOrientation == 900 )
- {
- long nTemp = rX;
- rX = rY;
- rY = -nTemp;
- }
- else if ( nOrientation == 1800 )
- {
- rX = -rX;
- rY = -rY;
- }
- else /* ( nOrientation == 2700 ) */
- {
- long nTemp = rX;
- rX = -rY;
- rY = nTemp;
- }
-
- rX += nOriginX;
- rY += nOriginY;
- }
- }
- else
- {
- double nRealOrientation = nOrientation*F_PI1800;
- double nCos = cos( nRealOrientation );
- double nSin = sin( nRealOrientation );
-
- // Translation...
- long nX = rX-nOriginX;
- long nY = rY-nOriginY;
-
- // Rotation...
- rX = +((long)(nCos*nX + nSin*nY)) + nOriginX;
- rY = -((long)(nSin*nX - nCos*nY)) + nOriginY;
- }
-}
-
void OutputDevice::ImplClearFontData( const bool bNewFontLists )
{
// the currently selected logical font is no longer needed
@@ -1806,113 +1755,6 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
mpMetaFile = pOldMetaFile;
}
-void OutputDevice::SetFont( const Font& rNewFont )
-{
-
- Font aFont( rNewFont );
- aFont.SetLanguage(rNewFont.GetLanguage());
- if ( mnDrawMode & (DRAWMODE_BLACKTEXT | DRAWMODE_WHITETEXT | DRAWMODE_GRAYTEXT | DRAWMODE_GHOSTEDTEXT | DRAWMODE_SETTINGSTEXT |
- DRAWMODE_BLACKFILL | DRAWMODE_WHITEFILL | DRAWMODE_GRAYFILL | DRAWMODE_NOFILL |
- DRAWMODE_GHOSTEDFILL | DRAWMODE_SETTINGSFILL ) )
- {
- Color aTextColor( aFont.GetColor() );
-
- if ( mnDrawMode & DRAWMODE_BLACKTEXT )
- aTextColor = Color( COL_BLACK );
- else if ( mnDrawMode & DRAWMODE_WHITETEXT )
- aTextColor = Color( COL_WHITE );
- else if ( mnDrawMode & DRAWMODE_GRAYTEXT )
- {
- const sal_uInt8 cLum = aTextColor.GetLuminance();
- aTextColor = Color( cLum, cLum, cLum );
- }
- else if ( mnDrawMode & DRAWMODE_SETTINGSTEXT )
- aTextColor = GetSettings().GetStyleSettings().GetFontColor();
-
- if ( mnDrawMode & DRAWMODE_GHOSTEDTEXT )
- {
- aTextColor = Color( (aTextColor.GetRed() >> 1 ) | 0x80,
- (aTextColor.GetGreen() >> 1 ) | 0x80,
- (aTextColor.GetBlue() >> 1 ) | 0x80 );
- }
-
- aFont.SetColor( aTextColor );
-
- bool bTransFill = aFont.IsTransparent();
- if ( !bTransFill )
- {
- Color aTextFillColor( aFont.GetFillColor() );
-
- if ( mnDrawMode & DRAWMODE_BLACKFILL )
- aTextFillColor = Color( COL_BLACK );
- else if ( mnDrawMode & DRAWMODE_WHITEFILL )
- aTextFillColor = Color( COL_WHITE );
- else if ( mnDrawMode & DRAWMODE_GRAYFILL )
- {
- const sal_uInt8 cLum = aTextFillColor.GetLuminance();
- aTextFillColor = Color( cLum, cLum, cLum );
- }
- else if( mnDrawMode & DRAWMODE_SETTINGSFILL )
- aTextFillColor = GetSettings().GetStyleSettings().GetWindowColor();
- else if ( mnDrawMode & DRAWMODE_NOFILL )
- {
- aTextFillColor = Color( COL_TRANSPARENT );
- bTransFill = true;
- }
-
- if ( !bTransFill && (mnDrawMode & DRAWMODE_GHOSTEDFILL) )
- {
- aTextFillColor = Color( (aTextFillColor.GetRed() >> 1) | 0x80,
- (aTextFillColor.GetGreen() >> 1) | 0x80,
- (aTextFillColor.GetBlue() >> 1) | 0x80 );
- }
-
- aFont.SetFillColor( aTextFillColor );
- }
- }
-
- if ( mpMetaFile )
- {
- mpMetaFile->AddAction( new MetaFontAction( aFont ) );
- // the color and alignment actions don't belong here
- // TODO: get rid of them without breaking anything...
- mpMetaFile->AddAction( new MetaTextAlignAction( aFont.GetAlign() ) );
- mpMetaFile->AddAction( new MetaTextFillColorAction( aFont.GetFillColor(), !aFont.IsTransparent() ) );
- }
-
- if ( !maFont.IsSameInstance( aFont ) )
- {
- // Optimization MT/HDU: COL_TRANSPARENT means SetFont should ignore the font color,
- // because SetTextColor() is used for this.
- // #i28759# maTextColor might have been changed behind our back, commit then, too.
- if( aFont.GetColor() != COL_TRANSPARENT
- && (aFont.GetColor() != maFont.GetColor() || aFont.GetColor() != maTextColor ) )
- {
- maTextColor = aFont.GetColor();
- mbInitTextColor = true;
- if( mpMetaFile )
- mpMetaFile->AddAction( new MetaTextColorAction( aFont.GetColor() ) );
- }
- maFont = aFont;
- mbNewFont = true;
-
- if( mpAlphaVDev )
- {
- // #i30463#
- // Since SetFont might change the text color, apply that only
- // selectively to alpha vdev (which normally paints opaque text
- // with COL_BLACK)
- if( aFont.GetColor() != COL_TRANSPARENT )
- {
- mpAlphaVDev->SetTextColor( COL_BLACK );
- aFont.SetColor( COL_TRANSPARENT );
- }
-
- mpAlphaVDev->SetFont( aFont );
- }
- }
-}
-
SalLayout* OutputDevice::getFallbackFont(ImplFontEntry &rFallbackFont,
FontSelectPattern &rFontSelData, int nFallbackLevel,
ImplLayoutArgs& rLayoutArgs) const
diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx
index 4e65d98657a2..9fab8b434e20 100644
--- a/vcl/source/outdev/outdev.cxx
+++ b/vcl/source/outdev/outdev.cxx
@@ -78,20 +78,6 @@ namespace {
#endif
-bool OutputDevice::ImplIsAntiparallel() const
-{
- bool bRet = false;
- if( AcquireGraphics() )
- {
- if( ( (mpGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) && ! IsRTLEnabled() ) ||
- ( ! (mpGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) && IsRTLEnabled() ) )
- {
- bRet = true;
- }
- }
- return bRet;
-}
-
OutputDevice::OutputDevice() :
maRegion(true),
maFillColor( COL_WHITE ),
@@ -451,6 +437,57 @@ bool OutputDevice::supportsOperation( OutDevSupportType eType ) const
return bHasSupport;
}
+void OutputDevice::ImplRotatePos( long nOriginX, long nOriginY, long& rX, long& rY,
+ int nOrientation )
+{
+ if ( (nOrientation >= 0) && !(nOrientation % 900) )
+ {
+ if ( (nOrientation >= 3600) )
+ nOrientation %= 3600;
+
+ if ( nOrientation )
+ {
+ rX -= nOriginX;
+ rY -= nOriginY;
+
+ if ( nOrientation == 900 )
+ {
+ long nTemp = rX;
+ rX = rY;
+ rY = -nTemp;
+ }
+ else if ( nOrientation == 1800 )
+ {
+ rX = -rX;
+ rY = -rY;
+ }
+ else /* ( nOrientation == 2700 ) */
+ {
+ long nTemp = rX;
+ rX = -rY;
+ rY = nTemp;
+ }
+
+ rX += nOriginX;
+ rY += nOriginY;
+ }
+ }
+ else
+ {
+ double nRealOrientation = nOrientation*F_PI1800;
+ double nCos = cos( nRealOrientation );
+ double nSin = sin( nRealOrientation );
+
+ // Translation...
+ long nX = rX-nOriginX;
+ long nY = rY-nOriginY;
+
+ // Rotation...
+ rX = +((long)(nCos*nX + nSin*nY)) + nOriginX;
+ rY = -((long)(nSin*nX - nCos*nY)) + nOriginY;
+ }
+}
+
void OutputDevice::EnableRTL( bool bEnable )
{
mbEnableRTL = bEnable;
@@ -464,6 +501,21 @@ bool OutputDevice::HasMirroredGraphics() const
return ( AcquireGraphics() && (mpGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) );
}
+
+bool OutputDevice::ImplIsAntiparallel() const
+{
+ bool bRet = false;
+ if( AcquireGraphics() )
+ {
+ if( ( (mpGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) && ! IsRTLEnabled() ) ||
+ ( ! (mpGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) && IsRTLEnabled() ) )
+ {
+ bRet = true;
+ }
+ }
+ return bRet;
+}
+
// note: the coordiantes to be remirrored are in frame coordiantes !
void OutputDevice::ReMirror( Point &rPoint ) const
diff --git a/vcl/source/outdev/outdevstate.cxx b/vcl/source/outdev/outdevstate.cxx
index e0602678f12e..43636991b028 100644
--- a/vcl/source/outdev/outdevstate.cxx
+++ b/vcl/source/outdev/outdevstate.cxx
@@ -19,6 +19,10 @@
#include <sal/types.h>
+#include <vcl/outdev.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/settings.hxx>
+
#include <vcl/mapmod.hxx>
#include <vcl/region.hxx>
#include <vcl/font.hxx>
@@ -55,4 +59,111 @@ OutDevState::~OutDevState()
delete mpRefPoint;
}
+void OutputDevice::SetFont( const Font& rNewFont )
+{
+
+ Font aFont( rNewFont );
+ aFont.SetLanguage(rNewFont.GetLanguage());
+ if ( mnDrawMode & (DRAWMODE_BLACKTEXT | DRAWMODE_WHITETEXT | DRAWMODE_GRAYTEXT | DRAWMODE_GHOSTEDTEXT | DRAWMODE_SETTINGSTEXT |
+ DRAWMODE_BLACKFILL | DRAWMODE_WHITEFILL | DRAWMODE_GRAYFILL | DRAWMODE_NOFILL |
+ DRAWMODE_GHOSTEDFILL | DRAWMODE_SETTINGSFILL ) )
+ {
+ Color aTextColor( aFont.GetColor() );
+
+ if ( mnDrawMode & DRAWMODE_BLACKTEXT )
+ aTextColor = Color( COL_BLACK );
+ else if ( mnDrawMode & DRAWMODE_WHITETEXT )
+ aTextColor = Color( COL_WHITE );
+ else if ( mnDrawMode & DRAWMODE_GRAYTEXT )
+ {
+ const sal_uInt8 cLum = aTextColor.GetLuminance();
+ aTextColor = Color( cLum, cLum, cLum );
+ }
+ else if ( mnDrawMode & DRAWMODE_SETTINGSTEXT )
+ aTextColor = GetSettings().GetStyleSettings().GetFontColor();
+
+ if ( mnDrawMode & DRAWMODE_GHOSTEDTEXT )
+ {
+ aTextColor = Color( (aTextColor.GetRed() >> 1 ) | 0x80,
+ (aTextColor.GetGreen() >> 1 ) | 0x80,
+ (aTextColor.GetBlue() >> 1 ) | 0x80 );
+ }
+
+ aFont.SetColor( aTextColor );
+
+ bool bTransFill = aFont.IsTransparent();
+ if ( !bTransFill )
+ {
+ Color aTextFillColor( aFont.GetFillColor() );
+
+ if ( mnDrawMode & DRAWMODE_BLACKFILL )
+ aTextFillColor = Color( COL_BLACK );
+ else if ( mnDrawMode & DRAWMODE_WHITEFILL )
+ aTextFillColor = Color( COL_WHITE );
+ else if ( mnDrawMode & DRAWMODE_GRAYFILL )
+ {
+ const sal_uInt8 cLum = aTextFillColor.GetLuminance();
+ aTextFillColor = Color( cLum, cLum, cLum );
+ }
+ else if( mnDrawMode & DRAWMODE_SETTINGSFILL )
+ aTextFillColor = GetSettings().GetStyleSettings().GetWindowColor();
+ else if ( mnDrawMode & DRAWMODE_NOFILL )
+ {
+ aTextFillColor = Color( COL_TRANSPARENT );
+ bTransFill = true;
+ }
+
+ if ( !bTransFill && (mnDrawMode & DRAWMODE_GHOSTEDFILL) )
+ {
+ aTextFillColor = Color( (aTextFillColor.GetRed() >> 1) | 0x80,
+ (aTextFillColor.GetGreen() >> 1) | 0x80,
+ (aTextFillColor.GetBlue() >> 1) | 0x80 );
+ }
+
+ aFont.SetFillColor( aTextFillColor );
+ }
+ }
+
+ if ( mpMetaFile )
+ {
+ mpMetaFile->AddAction( new MetaFontAction( aFont ) );
+ // the color and alignment actions don't belong here
+ // TODO: get rid of them without breaking anything...
+ mpMetaFile->AddAction( new MetaTextAlignAction( aFont.GetAlign() ) );
+ mpMetaFile->AddAction( new MetaTextFillColorAction( aFont.GetFillColor(), !aFont.IsTransparent() ) );
+ }
+
+ if ( !maFont.IsSameInstance( aFont ) )
+ {
+ // Optimization MT/HDU: COL_TRANSPARENT means SetFont should ignore the font color,
+ // because SetTextColor() is used for this.
+ // #i28759# maTextColor might have been changed behind our back, commit then, too.
+ if( aFont.GetColor() != COL_TRANSPARENT
+ && (aFont.GetColor() != maFont.GetColor() || aFont.GetColor() != maTextColor ) )
+ {
+ maTextColor = aFont.GetColor();
+ mbInitTextColor = true;
+ if( mpMetaFile )
+ mpMetaFile->AddAction( new MetaTextColorAction( aFont.GetColor() ) );
+ }
+ maFont = aFont;
+ mbNewFont = true;
+
+ if( mpAlphaVDev )
+ {
+ // #i30463#
+ // Since SetFont might change the text color, apply that only
+ // selectively to alpha vdev (which normally paints opaque text
+ // with COL_BLACK)
+ if( aFont.GetColor() != COL_TRANSPARENT )
+ {
+ mpAlphaVDev->SetTextColor( COL_BLACK );
+ aFont.SetColor( COL_TRANSPARENT );
+ }
+
+ mpAlphaVDev->SetFont( aFont );
+ }
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx
index 11e325080f50..862e1ac3b8dd 100644
--- a/vcl/source/outdev/textline.cxx
+++ b/vcl/source/outdev/textline.cxx
@@ -60,13 +60,13 @@ void OutputDevice::ImplInitAboveTextLineSize()
mpFontEntry->maMetric.ImplInitAboveTextLineSize();
}
-static void ImplDrawWavePixel( long nOriginX, long nOriginY,
- long nCurX, long nCurY,
- short nOrientation,
- SalGraphics* pGraphics,
- OutputDevice* pOutDev,
- bool bDrawPixAsRect,
- long nPixWidth, long nPixHeight )
+void OutputDevice::ImplDrawWavePixel( long nOriginX, long nOriginY,
+ long nCurX, long nCurY,
+ short nOrientation,
+ SalGraphics* pGraphics,
+ OutputDevice* pOutDev,
+ bool bDrawPixAsRect,
+ long nPixWidth, long nPixHeight )
{
if ( nOrientation )
ImplRotatePos( nOriginX, nOriginY, nCurX, nCurY, nOrientation );