summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-03 11:41:27 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-29 08:09:33 +0100
commitc209ac1c79da10c75739f6ed507acbd9a4acf8b1 (patch)
tree2abd0acdf9ef532c78ce6b01e0ec4d9648a494f2 /chart2
parentd5fb04b1092801d5148d892dacdecf5d03110911 (diff)
some improvements for text rendering
Change-Id: Ifa52fbd0f5359c505f12d12281ec7bdfb959d8c5
Diffstat (limited to 'chart2')
-rw-r--r--chart2/Library_chartopengl.mk1
-rw-r--r--chart2/inc/ChartModel.hxx1
-rw-r--r--chart2/source/view/main/DummyXShape.cxx65
-rwxr-xr-xchart2/source/view/main/OpenGLRender.cxx7
-rwxr-xr-xchart2/source/view/main/OpenGLRender.hxx3
5 files changed, 57 insertions, 20 deletions
diff --git a/chart2/Library_chartopengl.mk b/chart2/Library_chartopengl.mk
index aa4a77e7a1bb..f0e4372721ae 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 d987cdd765a6..8e965ba203af 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 4523e0c79c9d..f5817cd46699 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -24,6 +24,7 @@
#include <tools/gen.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <editeng/unoprnms.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <algorithm>
@@ -530,26 +531,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 7339ab138ac3..1b9372aff3c7 100755
--- 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 90408369827b..ce353b78536a 100755
--- 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);