[Libreoffice-commits] .: cppcanvas/inc cppcanvas/source

August Sodora augsod at kemper.freedesktop.org
Wed Dec 21 03:47:15 PST 2011


 cppcanvas/inc/cppcanvas/basegfxfactory.hxx    |    6 +++
 cppcanvas/source/inc/implrenderer.hxx         |    5 ++
 cppcanvas/source/mtfrenderer/emfplus.cxx      |   28 ++++++++++++++
 cppcanvas/source/mtfrenderer/implrenderer.cxx |   48 ++++++++++++++++++++++++
 cppcanvas/source/wrapper/basegfxfactory.cxx   |   50 ++++++++++++++++++++++++++
 5 files changed, 137 insertions(+)

New commits:
commit 3b8bf60a040d51d2d228127693f0b9c3292b151d
Author: August Sodora <augsod at gmail.com>
Date:   Wed Dec 21 06:46:40 2011 -0500

    Revert "callcatcher: Remove unused code"
    
    This reverts commit 070eff8cf1ad7763b8b730336f11032893b77049.

diff --git a/cppcanvas/inc/cppcanvas/basegfxfactory.hxx b/cppcanvas/inc/cppcanvas/basegfxfactory.hxx
index dbb8d12..5cb87aa 100644
--- a/cppcanvas/inc/cppcanvas/basegfxfactory.hxx
+++ b/cppcanvas/inc/cppcanvas/basegfxfactory.hxx
@@ -75,6 +75,7 @@ namespace cppcanvas
             coordinate space as the source polygon
          */
         PolyPolygonSharedPtr    createPolyPolygon( const CanvasSharedPtr&, const ::basegfx::B2DPolygon& rPoly ) const;
+        PolyPolygonSharedPtr    createPolyPolygon( const CanvasSharedPtr&, const ::basegfx::B2DPolyPolygon& rPoly ) const;
 
         /** Create an uninitialized bitmap with the given size
          */
@@ -84,6 +85,10 @@ namespace cppcanvas
          */
         BitmapSharedPtr         createAlphaBitmap( const CanvasSharedPtr&, const ::basegfx::B2ISize& rSize ) const;
 
+        /** Create a text portion with the given content string
+         */
+        TextSharedPtr           createText( const CanvasSharedPtr&, const ::rtl::OUString& ) const;
+
     private:
         friend struct InitInstance2;
 
@@ -95,6 +100,7 @@ namespace cppcanvas
         BaseGfxFactory(const BaseGfxFactory&);
         BaseGfxFactory& operator=( const BaseGfxFactory& );
     };
+
 }
 
 #endif /* _CPPCANVAS_BASEGFXFACTORY_HXX */
diff --git a/cppcanvas/source/inc/implrenderer.hxx b/cppcanvas/source/inc/implrenderer.hxx
index edf69be..3c1ec6d 100644
--- a/cppcanvas/source/inc/implrenderer.hxx
+++ b/cppcanvas/source/inc/implrenderer.hxx
@@ -174,6 +174,9 @@ static float GetSwapFloat( SvStream& rSt )
             ImplRenderer( const CanvasSharedPtr&    rCanvas,
                           const GDIMetaFile&        rMtf,
                           const Parameters&         rParms );
+            ImplRenderer( const CanvasSharedPtr&    rCanvas,
+                          const BitmapEx&           rBmpEx,
+                          const Parameters&         rParms );
 
             virtual ~ImplRenderer();
 
@@ -207,8 +210,10 @@ static float GetSwapFloat( SvStream& rSt )
             void ReadRectangle (SvStream& s, float& x, float& y, float &width, float& height, sal_uInt32 flags = 0);
             void ReadPoint (SvStream& s, float& x, float& y, sal_uInt32 flags = 0);
             void MapToDevice (double &x, double &y);
+            ::basegfx::B2DPoint Map (::basegfx::B2DPoint& p);
             ::basegfx::B2DPoint Map (double ix, double iy);
             ::basegfx::B2DSize MapSize (double iwidth, double iheight);
+            ::basegfx::B2DRange MapRectangle (double ix, double iy, double iwidth, double iheight);
 
         private:
             // default: disabled copy/assignment
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 8ccb75b..91c9560 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -825,6 +825,11 @@ namespace cppcanvas
             y = 100*nMmY*y/nPixY;
         }
 
+        ::basegfx::B2DPoint ImplRenderer::Map (::basegfx::B2DPoint& p)
+        {
+            return Map (p.getX (), p.getY ());
+        }
+
         ::basegfx::B2DPoint ImplRenderer::Map (double ix, double iy)
         {
             double x, y;
@@ -858,6 +863,29 @@ namespace cppcanvas
             return ::basegfx::B2DSize (w, h);
         }
 
+        ::basegfx::B2DRange ImplRenderer::MapRectangle (double ix, double iy, double iwidth, double iheight)
+        {
+            double x, y, w, h;
+
+            x = ix*aWorldTransform.eM11 + iy*aWorldTransform.eM21 + aWorldTransform.eDx;
+            y = ix*aWorldTransform.eM12 + iy*aWorldTransform.eM22 + aWorldTransform.eDy;
+            w = iwidth*aWorldTransform.eM11 + iheight*aWorldTransform.eM21;
+            h = iwidth*aWorldTransform.eM12 + iheight*aWorldTransform.eM22;
+
+            MapToDevice (x, y);
+            MapToDevice (w, h);
+
+            x -= nFrameLeft;
+            y -= nFrameTop;
+
+            x *= aBaseTransform.eM11;
+            y *= aBaseTransform.eM22;
+            w *= aBaseTransform.eM11;
+            h *= aBaseTransform.eM22;
+
+            return ::basegfx::B2DRange (x, y, x + w, y + h);
+        }
+
 #define COLOR(x) \
     ::vcl::unotools::colorToDoubleSequence( ::Color (0xff - (x >> 24), \
                              (x >> 16) & 0xff, \
diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx
index 8dde2f0..65b9d21 100644
--- a/cppcanvas/source/mtfrenderer/implrenderer.cxx
+++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx
@@ -3074,6 +3074,54 @@ namespace cppcanvas
                             );
         }
 
+        ImplRenderer::ImplRenderer( const CanvasSharedPtr&  rCanvas,
+                                    const BitmapEx&         rBmpEx,
+                                    const Parameters&       rParams ) :
+            CanvasGraphicHelper( rCanvas ),
+            maActions()
+        {
+            // TODO(F3): property modification parameters are
+            // currently ignored for Bitmaps
+            (void)rParams;
+
+            RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::ImplRenderer::ImplRenderer(bitmap)" );
+
+            OSL_ENSURE( rCanvas.get() != NULL && rCanvas->getUNOCanvas().is(),
+                        "ImplRenderer::ImplRenderer(): Invalid canvas" );
+            OSL_ENSURE( rCanvas->getUNOCanvas()->getDevice().is(),
+                        "ImplRenderer::ImplRenderer(): Invalid graphic device" );
+
+            // make sure canvas and graphic device are valid; action
+            // creation don't check that every time
+            if( rCanvas.get() == NULL ||
+                !rCanvas->getUNOCanvas().is() ||
+                !rCanvas->getUNOCanvas()->getDevice().is() )
+            {
+                // leave actions empty
+                return;
+            }
+
+            OutDevState aState;
+
+            const Size aBmpSize( rBmpEx.GetSizePixel() );
+
+            // Setup local state, such that the bitmap renders itself
+            // into a one-by-one square for identity view and render
+            // transformations
+            aState.transform.scale( 1.0 / aBmpSize.Width(),
+                                    1.0 / aBmpSize.Height() );
+
+            // create a single action for the provided BitmapEx
+            maActions.push_back(
+                MtfAction(
+                    BitmapActionFactory::createBitmapAction(
+                        rBmpEx,
+                        ::basegfx::B2DPoint(),
+                        rCanvas,
+                        aState),
+                    0 ) );
+        }
+
         ImplRenderer::~ImplRenderer()
         {
         }
diff --git a/cppcanvas/source/wrapper/basegfxfactory.cxx b/cppcanvas/source/wrapper/basegfxfactory.cxx
index d8dedb3..bac25aa 100644
--- a/cppcanvas/source/wrapper/basegfxfactory.cxx
+++ b/cppcanvas/source/wrapper/basegfxfactory.cxx
@@ -43,6 +43,7 @@
 #include "implbitmap.hxx"
 #include "impltext.hxx"
 
+
 using namespace ::com::sun::star;
 
 namespace cppcanvas
@@ -71,6 +72,48 @@ namespace cppcanvas
     {
     }
 
+    PolyPolygonSharedPtr BaseGfxFactory::createPolyPolygon( const CanvasSharedPtr&          rCanvas,
+                                                            const ::basegfx::B2DPolygon&    rPoly ) const
+    {
+        OSL_ENSURE( rCanvas.get() != NULL &&
+                    rCanvas->getUNOCanvas().is(),
+                    "BaseGfxFactory::createPolyPolygon(): Invalid canvas" );
+
+        if( rCanvas.get() == NULL )
+            return PolyPolygonSharedPtr();
+
+        uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
+        if( !xCanvas.is() )
+            return PolyPolygonSharedPtr();
+
+        return PolyPolygonSharedPtr(
+            new internal::ImplPolyPolygon( rCanvas,
+                                           ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
+                                               xCanvas->getDevice(),
+                                               rPoly) ) );
+    }
+
+    PolyPolygonSharedPtr BaseGfxFactory::createPolyPolygon( const CanvasSharedPtr&              rCanvas,
+                                                            const ::basegfx::B2DPolyPolygon&    rPolyPoly ) const
+    {
+        OSL_ENSURE( rCanvas.get() != NULL &&
+                    rCanvas->getUNOCanvas().is(),
+                    "BaseGfxFactory::createPolyPolygon(): Invalid canvas" );
+
+        if( rCanvas.get() == NULL )
+            return PolyPolygonSharedPtr();
+
+        uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
+        if( !xCanvas.is() )
+            return PolyPolygonSharedPtr();
+
+        return PolyPolygonSharedPtr(
+            new internal::ImplPolyPolygon( rCanvas,
+                                           ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
+                                               xCanvas->getDevice(),
+                                               rPolyPoly) ) );
+    }
+
     BitmapSharedPtr BaseGfxFactory::createBitmap( const CanvasSharedPtr&    rCanvas,
                                                   const ::basegfx::B2ISize& rSize ) const
     {
@@ -110,6 +153,13 @@ namespace cppcanvas
                                       xCanvas->getDevice()->createCompatibleAlphaBitmap(
                                           ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
     }
+
+    TextSharedPtr BaseGfxFactory::createText( const CanvasSharedPtr& rCanvas, const ::rtl::OUString& rText ) const
+    {
+        return TextSharedPtr( new internal::ImplText( rCanvas,
+                                                      rText ) );
+    }
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list