[Libreoffice-commits] core.git: Branch 'feature/chart-opengl2' - chart2/inc chart2/Library_chartopengl.mk chart2/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Fri Jan 3 00:43:30 PST 2014
chart2/Library_chartopengl.mk | 1
chart2/inc/ChartModel.hxx | 1
chart2/source/view/main/DummyXShape.cxx | 65 ++++++++++++++++++++++++-------
chart2/source/view/main/OpenGLRender.cxx | 7 ---
chart2/source/view/main/OpenGLRender.hxx | 3 -
5 files changed, 57 insertions(+), 20 deletions(-)
New commits:
commit 04ec79e2ad022198e9e91b11900da0d35e67ec6b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jan 3 11:41:27 2014 +0100
some improvements for text rendering
Change-Id: Ifa52fbd0f5359c505f12d12281ec7bdfb959d8c5
diff --git a/chart2/Library_chartopengl.mk b/chart2/Library_chartopengl.mk
index aa4a77e..f0e4372 100644
--- a/chart2/Library_chartopengl.mk
+++ b/chart2/Library_chartopengl.mk
@@ -46,6 +46,7 @@ $(eval $(call gb_Library_use_libraries,chartopengl,\
svt \
svxcore \
tl \
+ tk \
ucbhelper \
utl \
vcl \
diff --git a/chart2/inc/ChartModel.hxx b/chart2/inc/ChartModel.hxx
index c04a5b8..2f7e27f 100644
--- a/chart2/inc/ChartModel.hxx
+++ b/chart2/inc/ChartModel.hxx
@@ -148,7 +148,6 @@ private:
/** 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
*/
- bool mbInternalDataProvider;
::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xInternalDataProvider;
::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier >
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index b372834..8e8d2c8 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -23,6 +23,7 @@
#include <vcl/window.hxx>
#include <tools/gen.hxx>
#include <editeng/unoprnms.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <algorithm>
@@ -536,26 +537,64 @@ DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
setProperties(rNames, rValues, maProperties);
}
-void DummyText::render()
+namespace {
+
+struct FontAttribSetter
{
- debugProperties(maProperties);
+ FontAttribSetter(Font& rFont):
+ mrFont(rFont) {}
- //get text color, the output value always be white, so we use black color to text
- std::map< OUString, uno::Any >::const_iterator itr = maProperties.find("CharColor");
- sal_Int32 nColor = 0;
- if(itr != maProperties.end())
+ void operator()(const std::pair<OUString, uno::Any>& rProp)
{
- uno::Any co = itr->second;
- nColor = co.get<sal_Int32>();
+ 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()
+{
+ debugProperties(maProperties);
- //get font, assuming that every font has a set font name
- uno::Any font = maProperties.find("CharFontName")->second;
- OUString aFontName = font.get<OUString>();
+ Font aFont;
+ std::for_each(maProperties.begin(), maProperties.end(), FontAttribSetter(aFont));
- sal_Int32 nRot = 0;
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();
}
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 7d4717e..17fac5f 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1334,13 +1334,10 @@ int OpenGLRender::RenderRectangleShape()
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;
- Font aFont(font, Size(0, 100));
- aFont.SetWeight(WEIGHT_BOLD);
- aFont.SetItalic(ITALIC_NORMAL);
- aDevice.SetFont(aFont);
+ aDevice.SetFont(rFont);
Rectangle aRect;
aDevice.GetTextBoundRect(aRect, textValue);
int screenWidth = (aRect.BottomRight().X() + 3) & ~3;
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 9040836..ce353b7 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -8,6 +8,7 @@
*/
#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <vcl/font.hxx>
#if defined( _WIN32 )
#include "prewin.h"
@@ -176,7 +177,7 @@ public:
int RenderRectangleShape();
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();
private:
GLint LoadShaders(const char *vertexShader,const char *fragmentShader);
More information about the Libreoffice-commits
mailing list