[Libreoffice-commits] .: 2 commits - cppcanvas/source xmloff/source

Radek Doulík rodo at kemper.freedesktop.org
Thu Jul 19 02:09:20 PDT 2012


 cppcanvas/source/inc/implrenderer.hxx    |    2 -
 cppcanvas/source/mtfrenderer/emfplus.cxx |   54 ++++++++++++++++++++++---------
 xmloff/source/core/xmlexp.cxx            |    3 +
 xmloff/source/draw/sdxmlexp.cxx          |    5 --
 xmloff/source/draw/shapeexport4.cxx      |    5 ++
 xmloff/source/draw/ximpcustomshape.cxx   |    7 ++++
 6 files changed, 53 insertions(+), 23 deletions(-)

New commits:
commit d8720d4e390143279ccae8eed05decf54240e8fa
Author: Radek Doulik <rodo at novell.com>
Date:   Thu Jul 19 11:06:50 2012 +0200

    odf: export arcangleto commands in enhanced path (use drawooo namespace)
    
    Change-Id: I43a2c08ee8dfc0abe4d05579b837b5be0944c0fe

diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 82c414e..cbf9ef3 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -375,7 +375,8 @@ void SvXMLExport::_InitCtor()
                 GetXMLToken(XML_NP_TABLE_EXT), GetXMLToken(XML_N_TABLE_EXT), XML_NAMESPACE_TABLE_EXT);
             mpNamespaceMap->Add(
                 GetXMLToken(XML_NP_CALC_EXT), GetXMLToken(XML_N_CALC_EXT), XML_NAMESPACE_CALC_EXT);
-
+            mpNamespaceMap->Add(
+                GetXMLToken(XML_NP_DRAW_EXT), GetXMLToken(XML_N_DRAW_EXT), XML_NAMESPACE_DRAW_EXT);
         }
     }
     if( (getExportFlags() & (EXPORT_MASTERSTYLES|EXPORT_CONTENT) ) != 0 )
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index ce4d418..8927e92 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -641,11 +641,6 @@ void SAL_CALL SdXMLExport::setSourceDocument( const Reference< lang::XComponent
             GetXMLToken(XML_NP_OFFICE_EXT),
             GetXMLToken(XML_N_OFFICE_EXT),
             XML_NAMESPACE_OFFICE_EXT);
-
-        _GetNamespaceMap().Add(
-            GetXMLToken(XML_NP_DRAW_EXT),
-            GetXMLToken(XML_N_DRAW_EXT),
-            XML_NAMESPACE_DRAW_EXT);
     }
 
     GetShapeExport()->enableLayerExport();
diff --git a/xmloff/source/draw/shapeexport4.cxx b/xmloff/source/draw/shapeexport4.cxx
index aa4701d..43e75f9 100644
--- a/xmloff/source/draw/shapeexport4.cxx
+++ b/xmloff/source/draw/shapeexport4.cxx
@@ -329,6 +329,7 @@ void ImpExportEnhancedPath( SvXMLExport& rExport,
 
     rtl::OUString       aStr;
     rtl::OUStringBuffer aStrBuffer;
+    sal_uInt16 aNamespace = XML_NAMESPACE_DRAW;
 
     sal_Int32 i, j, k, l;
 
@@ -413,6 +414,8 @@ void ImpExportEnhancedPath( SvXMLExport& rExport,
                 aStrBuffer.append( (sal_Unicode)'Y' ); nParameter = 1; break;
             case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::QUADRATICCURVETO :
                 aStrBuffer.append( (sal_Unicode)'Q' ); nParameter = 2; break;
+            case com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCANGLETO :
+                aStrBuffer.append( (sal_Unicode)'G' ); nParameter = 2; aNamespace = XML_NAMESPACE_DRAW_EXT; break;
 
             default : // ups, seems to be something wrong
             {
@@ -442,7 +445,7 @@ void ImpExportEnhancedPath( SvXMLExport& rExport,
         }
     }
     aStr = aStrBuffer.makeStringAndClear();
-    rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_ENHANCED_PATH, aStr );
+    rExport.AddAttribute( aNamespace, XML_ENHANCED_PATH, aStr );
 }
 
 void ImpExportEnhancedGeometry( SvXMLExport& rExport, const uno::Reference< beans::XPropertySet >& xPropSet )
diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx
index 0736fe3..f8966a1 100644
--- a/xmloff/source/draw/ximpcustomshape.cxx
+++ b/xmloff/source/draw/ximpcustomshape.cxx
@@ -667,6 +667,13 @@ void GetEnhancedPath( std::vector< com::sun::star::beans::PropertyValue >& rDest
                 nIndex++;
             }
             break;
+            case 'G' :
+            {
+                nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::ARCANGLETO;
+                nParametersNeeded = 2;
+                nIndex++;
+            }
+            break;
             case 'W' :
             {
                 nLatestSegmentCommand = com::sun::star::drawing::EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
commit cf08e8a2ee18c3d1b26647489d16443b8cf617ad
Author: Radek Doulik <rodo at novell.com>
Date:   Tue Jul 17 16:15:50 2012 +0200

    emf+: added implementation of DrawImage record
    
    Change-Id: I6c86c2eaca1586d915b648292373da4378c755ba

diff --git a/cppcanvas/source/inc/implrenderer.hxx b/cppcanvas/source/inc/implrenderer.hxx
index 9b737d8..a0f59f4 100644
--- a/cppcanvas/source/inc/implrenderer.hxx
+++ b/cppcanvas/source/inc/implrenderer.hxx
@@ -211,7 +211,7 @@ static float GetSwapFloat( SvStream& rSt )
             typedef ::std::vector< MtfAction >      ActionVector;
 
             /* EMF+ */
-            void ReadRectangle (SvStream& s, float& x, float& y, float &width, float& height, sal_uInt32 flags = 0);
+            void ReadRectangle (SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed = false);
             void ReadPoint (SvStream& s, float& x, float& y, sal_uInt32 flags);
             void MapToDevice (double &x, double &y);
             ::basegfx::B2DPoint Map (double ix, double iy);
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 8ce563b..5b9651a 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -63,6 +63,7 @@
 #define EmfPlusRecordTypeDrawLines 16397
 #define EmfPlusRecordTypeFillPath 16404
 #define EmfPlusRecordTypeDrawPath 16405
+#define EmfPlusRecordTypeDrawImage 16410
 #define EmfPlusRecordTypeDrawImagePoints 16411
 #define EmfPlusRecordTypeDrawString 16412
 #define EmfPlusRecordTypeSetRenderingOrigin 16413
@@ -800,9 +801,9 @@ namespace cppcanvas
             }
         };
 
-        void ImplRenderer::ReadRectangle (SvStream& s, float& x, float& y, float &width, float& height, sal_uInt32 flags)
+        void ImplRenderer::ReadRectangle (SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed)
         {
-            if (flags & 0x4000) {
+            if (bCompressed) {
                 sal_Int16 ix, iy, iw, ih;
 
                 s >> ix >> iy >> iw >> ih;
@@ -1405,6 +1406,7 @@ namespace cppcanvas
                         }
                         break;
                     }
+                case EmfPlusRecordTypeDrawImage:
                 case EmfPlusRecordTypeDrawImagePoints:
                     {
                         sal_uInt32 attrIndex;
@@ -1412,27 +1414,49 @@ namespace cppcanvas
 
                         rMF >> attrIndex >> sourceUnit;
 
-                        EMFP_DEBUG (printf ("EMF+ DrawImagePoints attributes index: %d source unit: %d\n", (int)attrIndex, (int)sourceUnit));
+                        EMFP_DEBUG (printf ("EMF+ %s attributes index: %d source unit: %d\n", type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage", (int)attrIndex, (int)sourceUnit));
                         EMFP_DEBUG (printf ("EMF+\tTODO: use image attributes\n"));
 
                         if (sourceUnit == 2 && aObjects [flags & 0xff]) { // we handle only GraphicsUnit.Pixel now
                             EMFPImage& image = *(EMFPImage *) aObjects [flags & 0xff];
                             float sx, sy, sw, sh;
-                            sal_Int32 unknown;
+                            sal_Int32 aCount;
 
                             ReadRectangle (rMF, sx, sy, sw, sh);
 
-                            rMF >> unknown;
+                            EMFP_DEBUG (printf ("EMF+ %s source rectangle: %f,%f %fx%f\n", type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage", sx, sy, sw, sh));
+
+                            ::basegfx::B2DPoint aDstPoint;
+                            ::basegfx::B2DSize aDstSize;
+                            bool bValid = false;
+
+                            if (type == EmfPlusRecordTypeDrawImagePoints) {
+                                rMF >> aCount;
 
-                            EMFP_DEBUG (printf ("EMF+ DrawImagePoints source rectangle: %f,%f %fx%f unknown: 0x%08x\n", sx, sy, sw, sh, (unsigned int)unknown));
+                                if( aCount == 3) { // TODO: now that we now that this value is count we should support it better
+                                    float x1, y1, x2, y2, x3, y3;
 
-                            if (unknown == 3) { // it probably means number of points defining destination rectangle
-                                float x1, y1, x2, y2, x3, y3;
+                                    ReadPoint (rMF, x1, y1, flags);
+                                    ReadPoint (rMF, x2, y2, flags);
+                                    ReadPoint (rMF, x3, y3, flags);
 
-                                ReadPoint (rMF, x1, y1, flags);
-                                ReadPoint (rMF, x2, y2, flags);
-                                ReadPoint (rMF, x3, y3, flags);
+                                    aDstPoint = Map (x1, y1);
+                                    aDstSize = MapSize(x2 - x1, y3 - y1);
+
+                                    bValid = true;
+                                }
+                            } else if (type == EmfPlusRecordTypeDrawImage) {
+                                float dx, dy, dw, dh;
+
+                                ReadRectangle (rMF, dx, dy, dw, dh, flags & 0x4000);
+
+                                aDstPoint = Map (dx, dy);
+                                aDstSize = MapSize(dw, dh);
+
+                                bValid = true;
+                            }
 
+                            if (bValid) {
                                 BitmapEx aBmp( image.graphic.GetBitmapEx () );
                                 const Rectangle aCropRect (::vcl::unotools::pointFromB2DPoint (basegfx::B2DPoint (sx, sy)),
                                                            ::vcl::unotools::sizeFromB2DSize (basegfx::B2DSize(sw, sh)));
@@ -1444,8 +1468,8 @@ namespace cppcanvas
                                     ActionSharedPtr pBmpAction (
                                         internal::BitmapActionFactory::createBitmapAction (
                                             aBmp,
-                                            rState.mapModeTransform * Map (x1, y1),
-                                            rState.mapModeTransform * MapSize(x2 - x1, y3 - y1),
+                                            rState.mapModeTransform * aDstPoint,
+                                            rState.mapModeTransform * aDstSize,
                                             rCanvas,
                                             rState));
 
@@ -1459,10 +1483,10 @@ namespace cppcanvas
                                     EMFP_DEBUG (printf ("EMF+ warning: empty bitmap\n"));
                                 }
                             } else {
-                                EMFP_DEBUG (printf ("EMF+ DrawImagePoints TODO (fixme)\n"));
+                                EMFP_DEBUG (printf ("EMF+ DrawImage(Points) TODO (fixme)\n"));
                             }
                         } else {
-                            EMFP_DEBUG (printf ("EMF+ DrawImagePoints TODO (fixme) - possibly unsupported source units for crop rectangle\n"));
+                            EMFP_DEBUG (printf ("EMF+ DrawImage(Points) TODO (fixme) - possibly unsupported source units for crop rectangle\n"));
                         }
                         break;
                     }


More information about the Libreoffice-commits mailing list