summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-11-13 17:59:39 +0100
committerJan Holesovsky <kendy@collabora.com>2014-11-14 00:07:05 +0100
commit48fa9f1e191ffec9be2dfd41061173c488276705 (patch)
treedd17be18318e810e1bab5454999fb0b34e452f56 /vcl/win
parentf2be14cdba8dbe0128751007acf9e82bde3e60a0 (diff)
Revert "vcl: Abstract the Windows text rendering into a TextRenderImpl descendant."
Turns out it might be easier to actually subclass only the various SalLayout's - let's try it first, and re-introduce this code again if not. This reverts commit 309257ddadfdc3e46506036ed81f6e0695211ebe.
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/source/gdi/salgdi.cxx30
-rw-r--r--vcl/win/source/gdi/salgdi3.cxx131
-rw-r--r--vcl/win/source/gdi/winlayout.cxx8
-rw-r--r--vcl/win/source/gdi/wintextrender.cxx64
4 files changed, 50 insertions, 183 deletions
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index ecbc851bf854..d8d84e865bd4 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -35,7 +35,6 @@
#include "salgdiimpl.hxx"
#include "gdiimpl.hxx"
#include "opengl/win/gdiimpl.hxx"
-#include <wintextrender.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
@@ -501,6 +500,8 @@ void WinSalGraphics::DeInitGraphics()
SelectPen( getHDC(), mhDefPen );
if ( mhDefBrush )
SelectBrush( getHDC(), mhDefBrush );
+ if ( mhDefFont )
+ SelectFont( getHDC(), mhDefFont );
}
HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
@@ -570,22 +571,33 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
mbWindow(eType == WinSalGraphics::WINDOW),
mhWnd(hWnd),
mbScreen(bScreen),
+ mfCurrentFontScale(1.0),
mhRegion(0),
mhDefPen(0),
mhDefBrush(0),
+ mhDefFont(0),
mhDefPal(0),
mpStdClipRgnData(NULL),
+ mpLogFont(NULL),
+ mpFontCharSets(NULL),
+ mpFontAttrCache(NULL),
+ mnFontCharSetCount(0),
+ mpFontKernPairs(NULL),
+ mnFontKernPairCount(0),
+ mbFontKernInit(false),
mnPenWidth(GSL_PEN_WIDTH)
{
if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter)
- {
mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this));
- mpTextRenderImpl.reset((new WinTextRender(mbPrinter, *this)));
- }
else
- {
mpImpl.reset(new WinSalGraphicsImpl(*this));
- mpTextRenderImpl.reset((new WinTextRender(mbPrinter, *this)));
+
+ for( int i = 0; i < MAX_FALLBACK; ++i )
+ {
+ mhFonts[ i ] = 0;
+ mpWinFontData[ i ] = NULL;
+ mpWinFontEntry[ i ] = NULL;
+ mfFontScale[ i ] = 1.0;
}
}
@@ -602,6 +614,12 @@ WinSalGraphics::~WinSalGraphics()
// delete cache data
delete [] mpStdClipRgnData;
+
+ delete mpLogFont;
+
+ delete mpFontCharSets;
+
+ delete mpFontKernPairs;
}
bool WinSalGraphics::isPrinter() const
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index bd697030d51f..f3933d960ab0 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -49,7 +49,6 @@
#include "sft.hxx"
#include "win/saldata.hxx"
#include "win/salgdi.h"
-#include <wintextrender.hxx>
using namespace vcl;
@@ -1358,11 +1357,6 @@ void ImplWinFontData::GetFontCapabilities( HDC hDC ) const
void WinSalGraphics::SetTextColor( SalColor nSalColor )
{
- mpTextRenderImpl->SetTextColor(nSalColor);
-}
-
-void WinTextRender::SetTextColor(SalColor nSalColor)
-{
COLORREF aCol = PALETTERGB( SALCOLOR_RED( nSalColor ),
SALCOLOR_GREEN( nSalColor ),
SALCOLOR_BLUE( nSalColor ) );
@@ -1531,11 +1525,6 @@ HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontS
sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel )
{
- return mpTextRenderImpl->SetFont(pFont, nFallbackLevel);
-}
-
-sal_uInt16 WinTextRender::SetFont(FontSelectPattern* pFont, int nFallbackLevel)
-{
// return early if there is no new font
if( !pFont )
{
@@ -1559,7 +1548,7 @@ sal_uInt16 WinTextRender::SetFont(FontSelectPattern* pFont, int nFallbackLevel)
mpWinFontData[ nFallbackLevel ] = static_cast<const ImplWinFontData*>( pFont->mpFontData );
HFONT hOldFont = 0;
- HFONT hNewFont = mrGraphics.ImplDoSetFont( pFont, mfFontScale[ nFallbackLevel ], hOldFont );
+ HFONT hNewFont = ImplDoSetFont( pFont, mfFontScale[ nFallbackLevel ], hOldFont );
mfCurrentFontScale = mfFontScale[nFallbackLevel];
if( !mhDefFont )
@@ -1610,11 +1599,6 @@ sal_uInt16 WinTextRender::SetFont(FontSelectPattern* pFont, int nFallbackLevel)
void WinSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLevel )
{
- mpTextRenderImpl->GetFontMetric(pMetric, nFallbackLevel);
-}
-
-void WinTextRender::GetFontMetric(ImplFontMetricData* pMetric, int nFallbackLevel)
-{
// temporarily change the HDC to the font in the fallback level
HFONT hOldFont = SelectFont( getHDC(), mhFonts[nFallbackLevel] );
@@ -1689,7 +1673,7 @@ void WinTextRender::GetFontMetric(ImplFontMetricData* pMetric, int nFallbackLeve
pMetric->mnMinKashida = GetMinKashidaWidth();
}
-sal_uLong WinTextRender::GetKernPairs()
+sal_uLong WinSalGraphics::GetKernPairs()
{
if ( mbFontKernInit )
{
@@ -1720,11 +1704,6 @@ sal_uLong WinTextRender::GetKernPairs()
const FontCharMapPtr WinSalGraphics::GetFontCharMap() const
{
- return mpTextRenderImpl->GetFontCharMap();
-}
-
-const FontCharMapPtr WinTextRender::GetFontCharMap() const
-{
if( !mpWinFontData[0] )
{
FontCharMapPtr pDefFontCharMap( new FontCharMap() );
@@ -1735,11 +1714,6 @@ const FontCharMapPtr WinTextRender::GetFontCharMap() const
bool WinSalGraphics::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
{
- return mpTextRenderImpl->GetFontCapabilities(rFontCapabilities);
-}
-
-bool WinTextRender::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
-{
if( !mpWinFontData[0] )
return false;
return mpWinFontData[0]->GetFontCapabilities(rFontCapabilities);
@@ -2050,11 +2024,6 @@ static bool ImplGetFontAttrFromFile( const OUString& rFontFileURL,
bool WinSalGraphics::AddTempDevFont( PhysicalFontCollection* pFontCollection,
const OUString& rFontFileURL, const OUString& rFontName )
{
- return mpTextRenderImpl->AddTempDevFont(pFontCollection, rFontFileURL, rFontName);
-}
-
-bool WinTextRender::AddTempDevFont(PhysicalFontCollection* pFontCollection, const OUString& rFontFileURL, const OUString& rFontName)
-{
SAL_INFO( "vcl.gdi", "WinSalGraphics::AddTempDevFont(): " << OUStringToOString( rFontFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
ImplDevFontAttributes aDFA;
@@ -2110,11 +2079,6 @@ bool WinTextRender::AddTempDevFont(PhysicalFontCollection* pFontCollection, cons
void WinSalGraphics::GetDevFontList( PhysicalFontCollection* pFontCollection )
{
- mpTextRenderImpl->GetDevFontList(pFontCollection);
-}
-
-void WinTextRender::GetDevFontList(PhysicalFontCollection* pFontCollection)
-{
// make sure all fonts are registered at least temporarily
static bool bOnce = true;
if( bOnce )
@@ -2210,21 +2174,11 @@ void WinTextRender::GetDevFontList(PhysicalFontCollection* pFontCollection)
void WinSalGraphics::ClearDevFontCache()
{
- mpTextRenderImpl->ClearDevFontCache();
-}
-
-void WinTextRender::ClearDevFontCache()
-{
//anything to do here ?
}
bool WinSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect )
{
- return mpTextRenderImpl->GetGlyphBoundRect(aGlyphId, rRect);
-}
-
-bool WinTextRender::GetGlyphBoundRect(sal_GlyphId aGlyphId, Rectangle& rRect)
-{
HDC hDC = getHDC();
// use unity matrix
@@ -2256,11 +2210,6 @@ bool WinTextRender::GetGlyphBoundRect(sal_GlyphId aGlyphId, Rectangle& rRect)
bool WinSalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId,
::basegfx::B2DPolyPolygon& rB2DPolyPoly )
{
- return mpTextRenderImpl->GetGlyphOutline(aGlyphId, rB2DPolyPoly);
-}
-
-bool WinTextRender::GetGlyphOutline(sal_GlyphId aGlyphId, ::basegfx::B2DPolyPolygon& rB2DPolyPoly)
-{
rB2DPolyPoly.clear();
HDC hDC = getHDC();
@@ -2440,13 +2389,25 @@ bool WinTextRender::GetGlyphOutline(sal_GlyphId aGlyphId, ::basegfx::B2DPolyPoly
return true;
}
-WinTextRender::ScopedFont::ScopedFont(WinTextRender & rData): m_rData(rData)
+class ScopedFont
+{
+public:
+ explicit ScopedFont(WinSalGraphics & rData);
+
+ ~ScopedFont();
+
+private:
+ WinSalGraphics & m_rData;
+ HFONT m_hOrigFont;
+};
+
+ScopedFont::ScopedFont(WinSalGraphics & rData): m_rData(rData)
{
m_hOrigFont = m_rData.mhFonts[0];
m_rData.mhFonts[0] = 0; // avoid deletion of current font
}
-WinTextRender::ScopedFont::~ScopedFont()
+ScopedFont::~ScopedFont()
{
if( m_hOrigFont )
{
@@ -2490,13 +2451,6 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
const PhysicalFontFace* pFont, sal_GlyphId* pGlyphIds, sal_uInt8* pEncoding,
sal_Int32* pGlyphWidths, int nGlyphCount, FontSubsetInfo& rInfo )
{
- return mpTextRenderImpl->CreateFontSubset(rToFile, pFont, pGlyphIds, pEncoding, pGlyphWidths, nGlyphCount, rInfo);
-}
-
-bool WinTextRender::CreateFontSubset(const OUString& rToFile,
- const PhysicalFontFace* pFont, sal_GlyphId* pGlyphIds, sal_uInt8* pEncoding,
- sal_Int32* pGlyphWidths, int nGlyphCount, FontSubsetInfo& rInfo)
-{
// TODO: use more of the central font-subsetting code, move stuff there if needed
// create matching FontSelectPattern
@@ -2508,7 +2462,7 @@ bool WinTextRender::CreateFontSubset(const OUString& rToFile,
ScopedFont aOldFont(*this);
float fScale = 1.0;
HFONT hOldFont = 0;
- mrGraphics.ImplDoSetFont( &aIFSD, fScale, hOldFont );
+ ImplDoSetFont( &aIFSD, fScale, hOldFont );
ImplWinFontData* pWinFontData = (ImplWinFontData*)aIFSD.mpFontData;
@@ -2651,13 +2605,6 @@ const void* WinSalGraphics::GetEmbedFontData( const PhysicalFontFace* pFont,
const sal_Unicode* pUnicodes, sal_Int32* pCharWidths,
FontSubsetInfo& rInfo, long* pDataLen )
{
- return mpTextRenderImpl->GetEmbedFontData(pFont, pUnicodes, pCharWidths, rInfo, pDataLen);
-}
-
-const void* WinTextRender::GetEmbedFontData(const PhysicalFontFace* pFont,
- const sal_Unicode* pUnicodes, sal_Int32* pCharWidths,
- FontSubsetInfo& rInfo, long* pDataLen)
-{
// create matching FontSelectPattern
// we need just enough to get to the font file data
FontSelectPattern aIFSD( *pFont, Size(0,1000), 1000.0, 0, false );
@@ -2709,23 +2656,13 @@ const void* WinTextRender::GetEmbedFontData(const PhysicalFontFace* pFont,
return (void*)pData;
}
-void WinSalGraphics::FreeEmbedFontData(const void* pData, long nLen)
-{
- mpTextRenderImpl->FreeEmbedFontData(pData, nLen);
-}
-
-void WinTextRender::FreeEmbedFontData(const void* pData, long /*nLen*/)
+void WinSalGraphics::FreeEmbedFontData( const void* pData, long /*nLen*/ )
{
delete[] reinterpret_cast<char*>(const_cast<void*>(pData));
}
const Ucs2SIntMap* WinSalGraphics::GetFontEncodingVector( const PhysicalFontFace* pFont, const Ucs2OStrMap** pNonEncoded )
{
- return mpTextRenderImpl->GetFontEncodingVector(pFont, pNonEncoded);
-}
-
-const Ucs2SIntMap* WinTextRender::GetFontEncodingVector(const PhysicalFontFace* pFont, const Ucs2OStrMap** pNonEncoded)
-{
// TODO: even for builtin fonts we get here... why?
if( !pFont->IsEmbeddable() )
return NULL;
@@ -2754,12 +2691,6 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
Int32Vector& rWidths,
Ucs2UIntMap& rUnicodeEnc )
{
- mpTextRenderImpl->GetGlyphWidths(pFont, bVertical, rWidths, rUnicodeEnc);
-}
-
-void WinTextRender::GetGlyphWidths(const PhysicalFontFace* pFont, bool bVertical,
- Int32Vector& rWidths, Ucs2UIntMap& rUnicodeEnc)
-{
// create matching FontSelectPattern
// we need just enough to get to the font file data
FontSelectPattern aIFSD( *pFont, Size(0,1000), 1000.0, 0, false );
@@ -2769,7 +2700,7 @@ void WinTextRender::GetGlyphWidths(const PhysicalFontFace* pFont, bool bVertical
float fScale = 0.0;
HFONT hOldFont = 0;
- mrGraphics.ImplDoSetFont( &aIFSD, fScale, hOldFont );
+ ImplDoSetFont( &aIFSD, fScale, hOldFont );
if( pFont->IsSubsettable() )
{
@@ -2846,32 +2777,20 @@ void WinTextRender::GetGlyphWidths(const PhysicalFontFace* pFont, bool bVertical
}
}
-void WinSalGraphics::DrawServerFontLayout(const ServerFontLayout& rLayout)
-{
- mpTextRenderImpl->DrawServerFontLayout(rLayout);
-}
-
-void WinTextRender::DrawServerFontLayout(const ServerFontLayout&)
+void WinSalGraphics::DrawServerFontLayout( const ServerFontLayout& )
{}
-SystemFontData WinSalGraphics::GetSysFontData(int nFallbackLevel) const
-{
- return mpTextRenderImpl->GetSysFontData(nFallbackLevel);
-}
-
-SystemFontData WinTextRender::GetSysFontData(int nFallbackLevel) const
+SystemFontData WinSalGraphics::GetSysFontData( int nFallbacklevel ) const
{
SystemFontData aSysFontData;
- if (nFallbackLevel >= MAX_FALLBACK)
- nFallbackLevel = MAX_FALLBACK - 1;
- if (nFallbackLevel < 0)
- nFallbackLevel = 0;
+ if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1;
+ if (nFallbacklevel < 0 ) nFallbacklevel = 0;
- aSysFontData.hFont = mhFonts[nFallbackLevel];
+ aSysFontData.hFont = mhFonts[nFallbacklevel];
OSL_TRACE("\r\n:WinSalGraphics::GetSysFontData(): FontID: %p, Fallback level: %d",
- aSysFontData.hFont, nFallbackLevel);
+ aSysFontData.hFont, nFallbacklevel);
return aSysFontData;
}
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index dc5a2fc79ad5..22028978568e 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -27,7 +27,6 @@
#include "win/salgdi.h"
#include "win/saldata.hxx"
-#include <wintextrender.hxx>
#include "sft.hxx"
#include "sallayout.hxx"
@@ -2820,11 +2819,6 @@ void GraphiteWinLayout::Simplify( bool is_base )
SalLayout* WinSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel )
{
- return mpTextRenderImpl->GetTextLayout(rArgs, nFallbackLevel);
-}
-
-SalLayout* WinTextRender::GetTextLayout(ImplLayoutArgs& rArgs, int nFallbackLevel)
-{
DBG_ASSERT( mpWinFontEntry[nFallbackLevel], "WinSalGraphics mpWinFontEntry==NULL");
WinLayout* pWinLayout = NULL;
@@ -2875,7 +2869,7 @@ SalLayout* WinTextRender::GetTextLayout(ImplLayoutArgs& rArgs, int nFallbackLeve
return pWinLayout;
}
-int WinTextRender::GetMinKashidaWidth()
+int WinSalGraphics::GetMinKashidaWidth()
{
if( !mpWinFontEntry[0] )
return 0;
diff --git a/vcl/win/source/gdi/wintextrender.cxx b/vcl/win/source/gdi/wintextrender.cxx
deleted file mode 100644
index df2382f7efdb..000000000000
--- a/vcl/win/source/gdi/wintextrender.cxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <wintextrender.hxx>
-
-#include <win/salgdi.h>
-#include <win/wincomp.hxx>
-
-WinTextRender::WinTextRender(bool bPrinter, WinSalGraphics& rGraphics)
- : mbPrinter(bPrinter)
- , mrGraphics(rGraphics)
- , mfCurrentFontScale(1.0)
- , mhDefFont(0)
- , mpLogFont(NULL)
- , mpFontAttrCache(NULL)
- , mpFontCharSets(NULL)
- , mnFontCharSetCount(0)
- , mbFontKernInit(false)
- , mpFontKernPairs(NULL)
- , mnFontKernPairCount(0)
-{
- for (int i = 0; i < MAX_FALLBACK; ++i)
- {
- mhFonts[i] = 0;
- mpWinFontData[i] = NULL;
- mpWinFontEntry[i] = NULL;
- mfFontScale[i] = 1.0;
- }
-}
-
-WinTextRender::~WinTextRender()
-{
- if (mhDefFont)
- SelectFont(getHDC(), mhDefFont);
-
- delete[] mpLogFont;
-
- delete[] mpFontCharSets;
-
- delete[] mpFontKernPairs;
-}
-
-HDC WinTextRender::getHDC() const
-{
- return mrGraphics.getHDC();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */