some improvements for text rendering
Change-Id: Ifa52fbd0f5359c505f12d12281ec7bdfb959d8c5
This commit is contained in:
@@ -46,6 +46,7 @@ $(eval $(call gb_Library_use_libraries,chartopengl,\
|
|||||||
svt \
|
svt \
|
||||||
svxcore \
|
svxcore \
|
||||||
tl \
|
tl \
|
||||||
|
tk \
|
||||||
ucbhelper \
|
ucbhelper \
|
||||||
utl \
|
utl \
|
||||||
vcl \
|
vcl \
|
||||||
|
@@ -148,7 +148,6 @@ private:
|
|||||||
/** is only valid if m_xDataProvider is set. If m_xDataProvider is set to an
|
/** is only valid if m_xDataProvider is set. If m_xDataProvider is set to an
|
||||||
external data provider this reference must be set to 0
|
external data provider this reference must be set to 0
|
||||||
*/
|
*/
|
||||||
bool mbInternalDataProvider;
|
|
||||||
::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xInternalDataProvider;
|
::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xInternalDataProvider;
|
||||||
|
|
||||||
::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
|
::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include <tools/gen.hxx>
|
#include <tools/gen.hxx>
|
||||||
#include <cppuhelper/supportsservice.hxx>
|
#include <cppuhelper/supportsservice.hxx>
|
||||||
#include <editeng/unoprnms.hxx>
|
#include <editeng/unoprnms.hxx>
|
||||||
|
#include <toolkit/helper/vclunohelper.hxx>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -530,26 +531,64 @@ DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
|
|||||||
setProperties(rNames, rValues, maProperties);
|
setProperties(rNames, rValues, maProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct FontAttribSetter
|
||||||
|
{
|
||||||
|
FontAttribSetter(Font& rFont):
|
||||||
|
mrFont(rFont) {}
|
||||||
|
|
||||||
|
void operator()(const std::pair<OUString, uno::Any>& rProp)
|
||||||
|
{
|
||||||
|
const OUString& rPropName = rProp.first;
|
||||||
|
if(rPropName == "CharFontName")
|
||||||
|
{
|
||||||
|
OUString aName = rProp.second.get<OUString>();
|
||||||
|
mrFont.SetName(aName);
|
||||||
|
}
|
||||||
|
else if(rPropName == "CharColor")
|
||||||
|
{
|
||||||
|
sal_Int32 nColor = rProp.second.get<sal_Int32>();
|
||||||
|
mrFont.SetFillColor(nColor);
|
||||||
|
}
|
||||||
|
else if(rPropName == "CharHeight")
|
||||||
|
{
|
||||||
|
//float fHeight = rProp.second.get<float>();
|
||||||
|
mrFont.SetSize(Size(0,100)); //taken from the MCW implementation
|
||||||
|
}
|
||||||
|
else if(rPropName == "CharUnderline")
|
||||||
|
{
|
||||||
|
FontUnderline eUnderline = static_cast<FontUnderline>(rProp.second.get<sal_Int16>());
|
||||||
|
mrFont.SetUnderline(eUnderline);
|
||||||
|
}
|
||||||
|
else if(rPropName == "CharWeight")
|
||||||
|
{
|
||||||
|
float fWeight = rProp.second.get<float>();
|
||||||
|
FontWeight eFontWeight = VCLUnoHelper::ConvertFontWeight(fWeight);
|
||||||
|
mrFont.SetWeight(eFontWeight);
|
||||||
|
}
|
||||||
|
else if(rPropName == "ChartWidth")
|
||||||
|
{
|
||||||
|
float fWidth = rProp.second.get<float>();
|
||||||
|
FontWidth eFontWidth = VCLUnoHelper::ConvertFontWidth(fWidth);
|
||||||
|
mrFont.SetWidth(eFontWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Font& mrFont;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void DummyText::render()
|
void DummyText::render()
|
||||||
{
|
{
|
||||||
debugProperties(maProperties);
|
debugProperties(maProperties);
|
||||||
|
|
||||||
//get text color, the output value always be white, so we use black color to text
|
Font aFont;
|
||||||
std::map< OUString, uno::Any >::const_iterator itr = maProperties.find("CharColor");
|
std::for_each(maProperties.begin(), maProperties.end(), FontAttribSetter(aFont));
|
||||||
sal_Int32 nColor = 0;
|
|
||||||
if(itr != maProperties.end())
|
|
||||||
{
|
|
||||||
uno::Any co = itr->second;
|
|
||||||
nColor = co.get<sal_Int32>();
|
|
||||||
}
|
|
||||||
|
|
||||||
//get font, assuming that every font has a set font name
|
|
||||||
uno::Any font = maProperties.find("CharFontName")->second;
|
|
||||||
OUString aFontName = font.get<OUString>();
|
|
||||||
|
|
||||||
sal_Int32 nRot = 0;
|
|
||||||
DummyChart* pChart = getRootShape();
|
DummyChart* pChart = getRootShape();
|
||||||
pChart->m_GLRender.CreateTextTexture(maText, nColor, aFontName, maPosition, maSize, nRot);
|
pChart->m_GLRender.CreateTextTexture(maText, 0, aFont, maPosition, maSize, 0);
|
||||||
pChart->m_GLRender.RenderTextShape();
|
pChart->m_GLRender.RenderTextShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1334,13 +1334,10 @@ int OpenGLRender::RenderRectangleShape()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, ::rtl::OUString font, awt::Point aPos, awt::Size aSize, long rotation)
|
int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, const Font& rFont, awt::Point aPos, awt::Size aSize, long rotation)
|
||||||
{
|
{
|
||||||
VirtualDevice aDevice;
|
VirtualDevice aDevice;
|
||||||
Font aFont(font, Size(0, 100));
|
aDevice.SetFont(rFont);
|
||||||
aFont.SetWeight(WEIGHT_BOLD);
|
|
||||||
aFont.SetItalic(ITALIC_NORMAL);
|
|
||||||
aDevice.SetFont(aFont);
|
|
||||||
Rectangle aRect;
|
Rectangle aRect;
|
||||||
aDevice.GetTextBoundRect(aRect, textValue);
|
aDevice.GetTextBoundRect(aRect, textValue);
|
||||||
int screenWidth = (aRect.BottomRight().X() + 3) & ~3;
|
int screenWidth = (aRect.BottomRight().X() + 3) & ~3;
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <com/sun/star/drawing/XDrawPage.hpp>
|
#include <com/sun/star/drawing/XDrawPage.hpp>
|
||||||
|
#include <vcl/font.hxx>
|
||||||
|
|
||||||
#if defined( _WIN32 )
|
#if defined( _WIN32 )
|
||||||
#include "prewin.h"
|
#include "prewin.h"
|
||||||
@@ -176,7 +177,7 @@ public:
|
|||||||
int RenderRectangleShape();
|
int RenderRectangleShape();
|
||||||
int RectangleShapePoint(float x, float y, float directionX, float directionY);
|
int RectangleShapePoint(float x, float y, float directionX, float directionY);
|
||||||
|
|
||||||
int CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, ::rtl::OUString font, awt::Point aPos, awt::Size aSize, long rotation);
|
int CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, const Font& rFont, awt::Point aPos, awt::Size aSize, long rotation);
|
||||||
int RenderTextShape();
|
int RenderTextShape();
|
||||||
private:
|
private:
|
||||||
GLint LoadShaders(const char *vertexShader,const char *fragmentShader);
|
GLint LoadShaders(const char *vertexShader,const char *fragmentShader);
|
||||||
|
Reference in New Issue
Block a user