[Libreoffice-commits] core.git: 4 commits - avmedia/source chart2/source include/vcl oox/source sd/qa vcl/source

Zolnai Tamás tamas.zolnai at collabora.com
Wed Sep 17 01:04:33 PDT 2014


 avmedia/source/opengl/oglplayer.cxx            |    2 
 chart2/source/view/main/OpenGLRender.cxx       |    8 +--
 include/vcl/opengl/OpenGLHelper.hxx            |    4 -
 oox/source/ppt/pptshape.cxx                    |   10 +--
 oox/source/ppt/presentationfragmenthandler.cxx |   11 ++++
 sd/qa/unit/data/pptx/bnc584721_1_2.pptx        |binary
 sd/qa/unit/data/pptx/bnc584721_3.pptx          |binary
 sd/qa/unit/import-tests.cxx                    |   64 +++++++++++++++++++++++++
 vcl/source/opengl/OpenGLHelper.cxx             |    4 -
 9 files changed, 89 insertions(+), 14 deletions(-)

New commits:
commit 079c861f08d27aa8b6368aebc37f235979049286
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Wed Sep 17 08:04:36 2014 +0200

    fdo#81237: 2D OpenGL charts was upside-down
    
    The problem is that LO drawinglayer uses a coordinate system
    with an origin at the top-left corner of the screen, while
    OpenGL uses a complete coordinate system (with all four
    quarters, e.g.: allows negative values). The points in
    LO are always positive values which means they are drawn
    in the first quarter of the OpenGL coordinate system which
    also means that the origin is at the bottom-left corner
    of the scene. This difference causes the flipped scene.
    
    * To solve that problem scale the projection matrix with -1.0f
    along the y axis.
    * glDisable(GL_CULL_FACE) is necessary to avoid dropping primitives
    after scaling with -1.0.
    * Since projection matrix mirrors also the textures we don't need to
    do that inside the ConvertBitmapExToRGBATextureBuffer() method.
    
    Change-Id: Ieba642f3e665778a12368fe50a20865ec8f73514

diff --git a/avmedia/source/opengl/oglplayer.cxx b/avmedia/source/opengl/oglplayer.cxx
index a21d5db..c7f0c05 100644
--- a/avmedia/source/opengl/oglplayer.cxx
+++ b/avmedia/source/opengl/oglplayer.cxx
@@ -103,7 +103,7 @@ bool OGLPlayer::create( const OUString& rURL )
                 }
                 BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
                 rFile.buffer = new char[4 * aBitmapEx.GetSizePixel().Width() * aBitmapEx.GetSizePixel().Height()];
-                OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(aBitmapEx, reinterpret_cast<sal_uInt8*>(rFile.buffer));
+                OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(aBitmapEx, reinterpret_cast<sal_uInt8*>(rFile.buffer), true);
                 rFile.imagewidth = aBitmapEx.GetSizePixel().Width();
                 rFile.imageheight = aBitmapEx.GetSizePixel().Height();
             }
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 7c328b9..428b300 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -87,7 +87,7 @@ GLfloat texCoords[] = {
 int OpenGLRender::InitOpenGL()
 {
     glEnable(GL_TEXTURE_2D);
-    glEnable(GL_CULL_FACE);
+    glDisable(GL_CULL_FACE);
     glCullFace(GL_BACK);
     glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
     // Enable depth test
@@ -107,7 +107,8 @@ int OpenGLRender::InitOpenGL()
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
     //Init the Projection matrix
-    m_Projection = glm::ortho(0.f, float(m_iWidth), 0.f, float(m_iHeight), -1.f, 1.f);
+    m_Projection = glm::ortho(0.f, float(m_iWidth), -float(m_iHeight), 0.f, -1.f, 1.f);
+    m_Projection = m_Projection * glm::scale(1.0f, -1.0f, 1.0f);
     m_View       = glm::lookAt(glm::vec3(0,0,1), // Camera is at (4,3,-3), in World Space
                                glm::vec3(0,0,0), // and looks at the origin
                                glm::vec3(0,1,0)  // Head is up (set to 0,-1,0 to look upside-down)
@@ -356,7 +357,8 @@ void OpenGLRender::SetSize(int width, int height)
 {
     m_iWidth = width;
     m_iHeight = height;
-    m_Projection = glm::ortho(0.f, float(m_iWidth), 0.f, float(m_iHeight), -4.f, 3.f);
+    m_Projection = glm::ortho(0.f, float(m_iWidth), -float(m_iHeight), 0.f, -4.f, 3.f);
+    m_Projection = m_Projection * glm::scale(1.0f, -1.0f, 1.0f);
 }
 
 void OpenGLRender::SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b, sal_uInt8 nAlpha)
diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx
index f4ed8ea..8c04e32 100644
--- a/include/vcl/opengl/OpenGLHelper.hxx
+++ b/include/vcl/opengl/OpenGLHelper.hxx
@@ -25,9 +25,9 @@ public:
      * The caller is responsible for allocate the memory for the RGBA buffer, before call
      * this method. RGBA buffer size is assumed to be 4*width*height.
      * Since OpenGL uses textures flipped relative to BitmapEx storage this method
-     * also mirrors the bitmap vertically.
+     * also adds the possibility to mirror the bitmap vertically at the same time.
     **/
-    static void ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer);
+    static void ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer, const bool bFlip = false);
     static BitmapEx ConvertBGRABufferToBitmapEx(const sal_uInt8* const pBuffer, long nWidth, long nHeight);
     static void renderToFile(long nWidth, long nHeight, const OUString& rFileName);
 
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index e1fbb4e..c94e290 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -146,7 +146,7 @@ GLint OpenGLHelper::LoadShaders(const OUString& rVertexShaderName,const OUString
     return ProgramID;
 }
 
-void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer)
+void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx, sal_uInt8* o_pRGBABuffer, const bool bFlip)
 {
     long nBmpWidth = rBitmapEx.GetSizePixel().Width();
     long nBmpHeight = rBitmapEx.GetSizePixel().Height();
@@ -156,7 +156,7 @@ void OpenGLHelper::ConvertBitmapExToRGBATextureBuffer(const BitmapEx& rBitmapEx,
     Bitmap::ScopedReadAccess pReadAccces( aBitmap );
     AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha );
     size_t i = 0;
-    for (long ny = nBmpHeight - 1; ny >= 0; ny--)
+    for (long ny = (bFlip ? nBmpHeight - 1 : 0); (bFlip ? ny >= 0 : ny < nBmpHeight); (bFlip ? ny-- : ny++))
     {
         Scanline pAScan = pAlphaReadAccess ? pAlphaReadAccess->GetScanline(ny) : 0;
         for(long nx = 0; nx < nBmpWidth; nx++)
commit b3d50feaa87b670baf68288974005ac26ad31736
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Tue Sep 16 17:51:12 2014 +0200

    bnc#584721: Import subtitle block to master slides
    
    For some reason subtitle block was skipped for
    layouts. It seems we can enable it for layout too,
    it appears well on master slides.
    
    Change-Id: I23ec7d4fcce045099bfca9e94a8c9335beaf7468

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index a9ed0b9..cc94f60 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -144,12 +144,9 @@ void PPTShape::addShape(
                     break;
                     case XML_subTitle :
                     {
-                        if ( ( meShapeLocation == Master ) || ( meShapeLocation == Layout ) )
-                            sServiceName = OUString();
-                        else {
-                            sServiceName = "com.sun.star.presentation.SubtitleShape";
-                            aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle();
-                        }
+                        sServiceName = "com.sun.star.presentation.SubtitleShape";
+                        aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle();
+                        bClearText = true;
                     }
                     break;
                        case XML_obj :
diff --git a/sd/qa/unit/data/pptx/bnc584721_3.pptx b/sd/qa/unit/data/pptx/bnc584721_3.pptx
new file mode 100644
index 0000000..3866257
Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc584721_3.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 3f8d144..91fec0f 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -80,6 +80,7 @@ public:
     void testCreationDate();
     void testBnc584721_1();
     void testBnc584721_2();
+    void testBnc584721_3();
 
     CPPUNIT_TEST_SUITE(SdFiltersTest);
     CPPUNIT_TEST(testDocumentLayout);
@@ -104,6 +105,7 @@ public:
     CPPUNIT_TEST(testCreationDate);
     CPPUNIT_TEST(testBnc584721_1);
     CPPUNIT_TEST(testBnc584721_2);
+    CPPUNIT_TEST(testBnc584721_3);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -746,6 +748,31 @@ void SdFiltersTest::testBnc584721_2()
     xDocShRef->DoClose();
 }
 
+void SdFiltersTest::testBnc584721_3()
+{
+    // Subtitle was simply skipped on master slides.
+    // Check whether the second shape is a subtitle shape with the right text.
+
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_3.pptx"), PPTX);
+
+    SdDrawDocument *pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+    const SdrPage *pPage = &(pDoc->GetPage(1)->TRG_GetMasterPage());
+    CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+    SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(1) );
+    CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
+
+    // Check the shape type
+    uno::Reference< drawing::XShape > xShape( pTxtObj->getUnoShape(), uno::UNO_QUERY );
+    CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.presentation.SubtitleShape"), xShape->getShapeType());
+
+    // Check the text
+    const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
+    CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master subtitle style"), aEdit.GetText(0));
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 3f1749f4958d3c167e6134703e0f5e41e6bde0d6
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Wed Sep 17 09:53:50 2014 +0200

    bnc#584721: Do not add extra title and outliner blocks to master slide
    
    There are master slides / layouts imported from PPTX in which
    there is no title or body layout block, but so far Impress
    added these by default to the master slides if they were
    missing.
    Now they are skipped by the importer code.
    
    Change-Id: I256a4e78639ea39d0f87a94e6676422c7dbcde4a

diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index bef84de..811550e 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -465,9 +465,20 @@ bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlide
     SlidePersistPtr pMasterPersistPtr( pSlidePersistPtr->getMasterPersist() );
     if ( pMasterPersistPtr.get() )
     {
+        // Setting "Layout" property adds extra title and outliner preset shapes to the master slide
+        Reference< drawing::XDrawPage > xMasterSlide(pMasterPersistPtr->getPage());
+        const int nCount = xMasterSlide->getCount();
+
         const OUString sLayout = "Layout";
         uno::Reference< beans::XPropertySet > xSet( xSlide, uno::UNO_QUERY_THROW );
         xSet->setPropertyValue( sLayout, Any( pMasterPersistPtr->getLayoutFromValueToken() ) );
+
+        while( nCount < xMasterSlide->getCount())
+        {
+            Reference< drawing::XShape > xShape;
+            xMasterSlide->getByIndex(xMasterSlide->getCount()-1) >>= xShape;
+            xMasterSlide->remove(xShape);
+        }
     }
     while( xSlide->getCount() )
     {
diff --git a/sd/qa/unit/data/pptx/bnc584721_1.pptx b/sd/qa/unit/data/pptx/bnc584721_1_2.pptx
similarity index 100%
rename from sd/qa/unit/data/pptx/bnc584721_1.pptx
rename to sd/qa/unit/data/pptx/bnc584721_1_2.pptx
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 3036a58..3f8d144 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -79,6 +79,7 @@ public:
     void testBnc480256();
     void testCreationDate();
     void testBnc584721_1();
+    void testBnc584721_2();
 
     CPPUNIT_TEST_SUITE(SdFiltersTest);
     CPPUNIT_TEST(testDocumentLayout);
@@ -102,6 +103,7 @@ public:
     CPPUNIT_TEST(testBnc480256);
     CPPUNIT_TEST(testCreationDate);
     CPPUNIT_TEST(testBnc584721_1);
+    CPPUNIT_TEST(testBnc584721_2);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -715,7 +717,7 @@ void SdFiltersTest::testBnc584721_1()
 {
     // Title text shape on the master page contained wrong text.
 
-    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1.pptx"), PPTX);
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
 
     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
@@ -729,6 +731,21 @@ void SdFiltersTest::testBnc584721_1()
     xDocShRef->DoClose();
 }
 
+void SdFiltersTest::testBnc584721_2()
+{
+    // Import created an extra/unneeded outliner shape on the master slide next to the imported title shape.
+
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
+
+    SdDrawDocument *pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+    const SdrPage *pPage = &(pDoc->GetPage(1)->TRG_GetMasterPage());
+    CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+    CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
commit 25fb9471552c3b17eb7e9ae622b3ac89e7e997d0
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date:   Sat Sep 13 21:01:18 2014 +0200

    bnc#584721: Right text inside the title area on master page
    
    With setting bClearText to true the default text used inside
    LO will be removed.
    Before that change the imported text was appended to the end of
    the LO default text.
    Now it contains only the imported text.
    
    Change-Id: I9f5eb0e20468a35c64130a433367cd3845ac7e3c

diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index f454f44..a9ed0b9 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -139,6 +139,7 @@ void PPTShape::addShape(
                     {
                         sServiceName = "com.sun.star.presentation.TitleTextShape";
                         aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle();
+                        bClearText = true;
                     }
                     break;
                     case XML_subTitle :
diff --git a/sd/qa/unit/data/pptx/bnc584721_1.pptx b/sd/qa/unit/data/pptx/bnc584721_1.pptx
new file mode 100644
index 0000000..dbbcabd
Binary files /dev/null and b/sd/qa/unit/data/pptx/bnc584721_1.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index f49d6aa..3036a58 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -78,6 +78,7 @@ public:
     void testBnc887225();
     void testBnc480256();
     void testCreationDate();
+    void testBnc584721_1();
 
     CPPUNIT_TEST_SUITE(SdFiltersTest);
     CPPUNIT_TEST(testDocumentLayout);
@@ -100,6 +101,7 @@ public:
     CPPUNIT_TEST(testBnc887225);
     CPPUNIT_TEST(testBnc480256);
     CPPUNIT_TEST(testCreationDate);
+    CPPUNIT_TEST(testBnc584721_1);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -709,6 +711,24 @@ void SdFiltersTest::testBnc480256()
     xDocShRef->DoClose();
 }
 
+void SdFiltersTest::testBnc584721_1()
+{
+    // Title text shape on the master page contained wrong text.
+
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1.pptx"), PPTX);
+
+    SdDrawDocument *pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+    const SdrPage *pPage = &(pDoc->GetPage (1)->TRG_GetMasterPage());
+    CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+    SdrObject *pObj = pPage->GetObj(0);
+    SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
+    CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
+    const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
+    CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master title style"), aEdit.GetText(0));
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list