[Libreoffice-commits] core.git: 3 commits - chart2/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Sun Feb 16 02:54:43 CET 2014


 chart2/source/view/inc/DummyXShape.hxx         |    7 +++
 chart2/source/view/main/DummyXShape.cxx        |   49 ++++++++++++++++++++++---
 chart2/source/view/main/OpenGLRender.cxx       |    9 +++-
 chart2/source/view/main/OpenGLRender.hxx       |    2 +
 chart2/source/view/main/OpenglShapeFactory.cxx |    2 -
 5 files changed, 60 insertions(+), 9 deletions(-)

New commits:
commit 24f51d315cd75715cb57709a86c7470c42dbb595
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Feb 16 02:53:17 2014 +0100

    text position for legend improvements
    
    Change-Id: I06d8baf8cfe59999cd6b417fc6e70c1bd6eede27

diff --git a/chart2/source/view/inc/DummyXShape.hxx b/chart2/source/view/inc/DummyXShape.hxx
index 3a9dccb..45f6dc4 100644
--- a/chart2/source/view/inc/DummyXShape.hxx
+++ b/chart2/source/view/inc/DummyXShape.hxx
@@ -332,13 +332,18 @@ class DummyText : public DummyXShape
 {
 public:
     DummyText(const OUString& rText, const tNameSequence& rNames,
-            const tAnySequence& rValues, const uno::Any& rTrans );
+            const tAnySequence& rValues, const uno::Any& rTrans, com::sun::star::uno::Reference<
+            com::sun::star::drawing::XShapes > xTarget);
 
     virtual void render() SAL_OVERRIDE;
 
     virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
 
+    virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) throw(::com::sun::star::uno::RuntimeException);
+
 private:
+    void setTransformatAsProperty(const com::sun::star::drawing::HomogenMatrix3& rMatrix);
+
     OUString maText;
     uno::Any maTrans;
     BitmapEx maBitmap;
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 478226c..134d6cc 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -714,7 +714,7 @@ private:
 }
 
 DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
-        const tAnySequence& rValues, const uno::Any& rTrans ):
+        const tAnySequence& rValues, const uno::Any& rTrans, uno::Reference< drawing::XShapes > xTarget ):
     maText(rText),
     maTrans(rTrans)
 {
@@ -744,12 +744,25 @@ DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
         setPosition(awt::Point(aTrans.Line1.Column3, aTrans.Line2.Column3));
         aTrans.Line1.Column1 = 20 * bmpWidth;
         aTrans.Line2.Column2 = 20 * bmpHeight;
-        uno::Any aNewTrans;
-        aNewTrans <<= aTrans;
-        setPropertyValue("Transformation", aNewTrans);
+        setTransformatAsProperty(aTrans);
     }
     else
+    {
         setSize(awt::Size(20*bmpWidth, 20*bmpHeight));
+        uno::Reference< drawing::XShape > xTargetShape(xTarget, uno::UNO_QUERY);
+        drawing::HomogenMatrix3 aTrans;
+        aTrans.Line1.Column1 = 20 * bmpWidth;
+        aTrans.Line2.Column2 = 20 * bmpHeight;
+        aTrans.Line3.Column3 = 1;
+        if(xTargetShape.is())
+        {
+            const awt::Point rPoint = xTargetShape->getPosition();
+            setPosition(rPoint);
+            aTrans.Line1.Column3 = rPoint.X;
+            aTrans.Line2.Column3 = rPoint.Y;
+        }
+        setTransformatAsProperty(aTrans);
+    }
 }
 
 void DummyText::render()
@@ -788,6 +801,34 @@ void DummyText::setPropertyValue( const OUString& rName, const uno::Any& rValue)
     DummyXShape::setPropertyValue(rName, rValue);
 }
 
+void DummyText::setPosition(const awt::Point& rPosition )
+    throw(uno::RuntimeException)
+{
+    DummyXShape::setPosition(rPosition);
+    if(maTrans.hasValue())
+        return;
+
+    std::map<OUString, uno::Any>::const_iterator itr =
+        maProperties.find("Transformation");
+    if(itr != maProperties.end())
+    {
+        if(itr->second.hasValue())
+        {
+            drawing::HomogenMatrix3 aTrans = itr->second.get<drawing::HomogenMatrix3>();
+            aTrans.Line1.Column3 = rPosition.X;
+            aTrans.Line2.Column3 = rPosition.Y;
+            setTransformatAsProperty(aTrans);
+        }
+    }
+}
+
+void DummyText::setTransformatAsProperty(const drawing::HomogenMatrix3& rMatrix)
+{
+    uno::Any aNewTrans;
+    aNewTrans <<= rMatrix;
+    setPropertyValue("Transformation", aNewTrans);
+}
+
 DummyFormattedText::DummyFormattedText(uno::Sequence< uno::Reference<
         chart2::XFormattedString > >& rFormattedString):
     maFormattedString(rFormattedString)
diff --git a/chart2/source/view/main/OpenglShapeFactory.cxx b/chart2/source/view/main/OpenglShapeFactory.cxx
index c2ae65d..5b19a5b 100644
--- a/chart2/source/view/main/OpenglShapeFactory.cxx
+++ b/chart2/source/view/main/OpenglShapeFactory.cxx
@@ -401,7 +401,7 @@ uno::Reference< drawing::XShape >
                     , const uno::Any& rATransformation )
 {
     dummy::DummyText* pText = new dummy::DummyText( rText, rPropNames, rPropValues,
-            rATransformation );
+            rATransformation, xTarget );
     xTarget->add(pText);
     return pText;
 }
commit a5e48409e9576d1081d5b981a22a1927b18be93c
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat Feb 15 22:28:09 2014 +0100

    improve bubble positioning
    
    Change-Id: Ifeecb23b0f2ee3218b052aaf688dcd51bcc30d58

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index a418432..4d0f25e 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1031,10 +1031,10 @@ int OpenGLRender::Bubble2DShapePoint(float x, float y, float directionX, float d
     float actualX = (x / OPENGL_SCALE_VALUE);
     float actualY = (y / OPENGL_SCALE_VALUE);
     Bubble2DPointList aBubble2DPointList;
-    aBubble2DPointList.x = actualX;
-    aBubble2DPointList.y = actualY;
     aBubble2DPointList.xScale = directionX / OPENGL_SCALE_VALUE;
     aBubble2DPointList.yScale = directionY / OPENGL_SCALE_VALUE;
+    aBubble2DPointList.x = actualX + aBubble2DPointList.xScale / 2;
+    aBubble2DPointList.y = actualY + aBubble2DPointList.yScale / 2;
 
     m_Bubble2DShapePointList.push_back(aBubble2DPointList);
     return 0;
commit 5afc5d1bfd1bc8ca52d2a03d6b7758c72eb9698e
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sat Feb 15 22:20:23 2014 +0100

    improve text positioning
    
    Change-Id: I9a6d99105ae32a2e03e4756983a87cb4ad174ea2

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 8ecc888..a418432 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1290,6 +1290,9 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point&
     aTextInfo.vertex[10] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[11] = m_fZStep;
 
+    aTextInfo.bmpWidth = bmpWidth;
+    aTextInfo.bmpHeight = bmpHeight;
+
     //if has ratotion, we must re caculate the central pos
     if (!rtl::math::approxEqual(0, rotation))
     {
@@ -1324,7 +1327,7 @@ int OpenGLRender::RenderTextShape()
     for (size_t i = 0; i < listNum; i++)
     {
         TextInfo &textInfo = m_TextInfoList.front();
-        PosVecf3 trans = {0, 0, 0};
+        PosVecf3 trans = { (float)-textInfo.bmpWidth/2.0f, (float)-textInfo.bmpHeight/2.0f, 0};
         PosVecf3 angle = {0.0f, 0.0f, float(textInfo.rotation)};
         PosVecf3 scale = {1.0, 1.0, 1.0f};
         MoveModelf(trans, angle, scale);
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 2a934cf..b91d5f3 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -81,6 +81,8 @@ struct TextInfo
     GLuint texture;
     double rotation;
     float vertex[12];
+    long bmpWidth;
+    long bmpHeight;
 };
 
 typedef std::vector<GLfloat> Area2DPointList;


More information about the Libreoffice-commits mailing list