[Libreoffice-commits] core.git: 2 commits - cui/source filter/source include/svx svx/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 19 06:13:06 UTC 2018


 cui/source/tabpages/tppattern.cxx |    6 +++---
 filter/source/flash/swfwriter.cxx |   22 ++++++++--------------
 filter/source/flash/swfwriter.hxx |    4 ++--
 include/svx/xbtmpit.hxx           |    2 +-
 svx/source/xoutdev/xattrbmp.cxx   |   34 ++++++++++++----------------------
 svx/source/xoutdev/xtabptrn.cxx   |    2 +-
 6 files changed, 27 insertions(+), 43 deletions(-)

New commits:
commit ccd316d1cb310734848bd20244f509024b549b8c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Feb 16 14:26:14 2018 +0200

    use VirtualDevice in createHistorical8x8FromArray
    
    part of making BitmapWriteAccess an internal detail of vcl/
    
    Change-Id: I8b3aa2fdd3c26db0e48b228640cd31b0bd31543c
    Reviewed-on: https://gerrit.libreoffice.org/49937
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx
index 141bd052cc66..443f5d95f7f0 100644
--- a/cui/source/tabpages/tppattern.cxx
+++ b/cui/source/tabpages/tppattern.cxx
@@ -72,9 +72,9 @@ public:
     // BitmapCtl: Returns the Bitmap
     BitmapEx GetBitmapEx()
     {
-        const Bitmap aRetval(createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor));
-
-        return (pBmpArray != nullptr) ? BitmapEx(aRetval) : BitmapEx();
+        if (!pBmpArray)
+            return BitmapEx();
+        return createHistorical8x8FromArray(pBmpArray, aPixelColor, aBackgroundColor);
     }
 
     void SetBmpArray( const sal_uInt16* pPixel ) { pBmpArray = pPixel; }
diff --git a/include/svx/xbtmpit.hxx b/include/svx/xbtmpit.hxx
index 7f34b0c1be71..b9ced7c42fb0 100644
--- a/include/svx/xbtmpit.hxx
+++ b/include/svx/xbtmpit.hxx
@@ -30,7 +30,7 @@ class BitmapColor;
 
 // helper to construct historical 8x8 bitmaps with two colors
 
-Bitmap SVX_DLLPUBLIC createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, Color aColorBack);
+BitmapEx SVX_DLLPUBLIC createHistorical8x8FromArray(sal_uInt16 const * pArray, Color aColorPix, Color aColorBack);
 bool SVX_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront);
 
 
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 8e6e5afb18a8..336f84d9c2a8 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <vcl/salbtype.hxx>
 #include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapTools.hxx>
 #include <vcl/dibtools.hxx>
 
 #include <libxml/xmlwriter.h>
@@ -143,37 +144,26 @@ XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
 {
 }
 
-Bitmap createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, Color aColorBack)
+BitmapEx createHistorical8x8FromArray(sal_uInt16 const *pArray, Color aColorPix, Color aColorBack)
 {
-    BitmapPalette aPalette(2);
+    vcl::bitmap::RawBitmap aBitmap(Size(8, 8));
 
-    aPalette[0] = BitmapColor(aColorBack);
-    aPalette[1] = BitmapColor(aColorPix);
-
-    Bitmap aBitmap(Size(8, 8), 1, &aPalette);
-    Bitmap::ScopedWriteAccess pContent(aBitmap);
-
-    if(pContent)
+    for(sal_uInt16 a(0); a < 8; a++)
     {
-        for(sal_uInt16 a(0); a < 8; a++)
+        for(sal_uInt16 b(0); b < 8; b++)
         {
-            for(sal_uInt16 b(0); b < 8; b++)
+            if(pArray[(a * 8) + b])
             {
-                if(pArray[(a * 8) + b])
-                {
-                    pContent->SetPixelIndex(a, b, 1);
-                }
-                else
-                {
-                    pContent->SetPixelIndex(a, b, 0);
-                }
+                aBitmap.SetPixel(a, b, aColorBack);
+            }
+            else
+            {
+                aBitmap.SetPixel(a, b, aColorPix);
             }
         }
-
-        pContent.reset();
     }
 
-    return aBitmap;
+    return vcl::bitmap::CreateFromData(std::move(aBitmap));
 }
 
 bool isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront)
diff --git a/svx/source/xoutdev/xtabptrn.cxx b/svx/source/xoutdev/xtabptrn.cxx
index 9dd126dd3126..40e38cb3e331 100644
--- a/svx/source/xoutdev/xtabptrn.cxx
+++ b/svx/source/xoutdev/xtabptrn.cxx
@@ -49,7 +49,7 @@ bool XPatternList::Create()
 {
     OUStringBuffer aStr(SvxResId(RID_SVXSTR_PATTERN));
     sal_uInt16 aArray[64];
-    Bitmap aBitmap;
+    BitmapEx aBitmap;
     const sal_Int32 nLen(aStr.getLength() - 1);
 
     memset(aArray, 0, sizeof(aArray));
commit add367bfec9d12502e64d2994f0f39e2e436442a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Feb 6 15:13:35 2018 +0200

    loplugin:useuniqueptr in swf::Writer
    
    Change-Id: Ia337bffa45a1949567f70586db480d92bb55b238
    Reviewed-on: https://gerrit.libreoffice.org/49936
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/flash/swfwriter.cxx b/filter/source/flash/swfwriter.cxx
index d32c417d4362..071f567073e5 100644
--- a/filter/source/flash/swfwriter.cxx
+++ b/filter/source/flash/swfwriter.cxx
@@ -93,8 +93,6 @@ Writer::Writer( sal_Int32 nTWIPWidthOutput, sal_Int32 nTWIPHeightOutput, sal_Int
 Writer::~Writer()
 {
     mpVDev.disposeAndClear();
-    delete mpSprite;
-    delete mpTag;
 }
 
 
@@ -175,8 +173,8 @@ void Writer::storeTo( Reference< XOutputStream > const &xOutStream )
 sal_uInt16 Writer::startSprite()
 {
     sal_uInt16 nShapeId = createID();
-    mvSpriteStack.push(mpSprite);
-    mpSprite = new Sprite( nShapeId );
+    mvSpriteStack.push(mpSprite.release());
+    mpSprite.reset(new Sprite( nShapeId ));
     return nShapeId;
 }
 
@@ -189,15 +187,13 @@ void Writer::endSprite()
         endTag();
 
         mpSprite->write( *mpMovieStream );
-        delete mpSprite;
+        mpSprite.reset();
 
         if (!mvSpriteStack.empty())
         {
-            mpSprite = mvSpriteStack.top();
+            mpSprite.reset( mvSpriteStack.top() );
             mvSpriteStack.pop();
         }
-        else
-            mpSprite = nullptr;
     }
 }
 
@@ -243,7 +239,7 @@ void Writer::startTag( sal_uInt8 nTagId )
 {
     DBG_ASSERT( mpTag == nullptr, "Last tag was not ended");
 
-    mpTag = new Tag( nTagId );
+    mpTag.reset( new Tag( nTagId ) );
 }
 
 
@@ -253,14 +249,12 @@ void Writer::endTag()
 
     if( mpSprite && ( (nTag == TAG_END) || (nTag == TAG_SHOWFRAME) || (nTag == TAG_DOACTION) || (nTag == TAG_STARTSOUND) || (nTag == TAG_PLACEOBJECT) || (nTag == TAG_PLACEOBJECT2) || (nTag == TAG_REMOVEOBJECT2) || (nTag == TAG_FRAMELABEL) ) )
     {
-        mpSprite->addTag( mpTag );
-        mpTag = nullptr;
+        mpSprite->addTag( mpTag.release() );
     }
     else
     {
         mpTag->write( *mpMovieStream );
-        delete mpTag;
-        mpTag = nullptr;
+        mpTag.reset();
     }
 }
 
@@ -329,7 +323,7 @@ sal_uInt16 Writer::defineShape( const tools::PolyPolygon& rPolyPoly, const FillS
     mpTag->addUI8( 1 );         // FillStyleCount
 
     // FILLSTYLE
-    rFillStyle.addTo( mpTag );
+    rFillStyle.addTo( mpTag.get() );
 
     // LINESTYLEARRAY
     mpTag->addUI8( 0 );         // LineStyleCount
diff --git a/filter/source/flash/swfwriter.hxx b/filter/source/flash/swfwriter.hxx
index 7bb9d33b65cd..34982a1c588a 100644
--- a/filter/source/flash/swfwriter.hxx
+++ b/filter/source/flash/swfwriter.hxx
@@ -385,8 +385,8 @@ private:
     typedef std::vector<sal_uInt16> CharacterIdVector;
     CharacterIdVector       maShapeIds;
 
-    Tag* mpTag;
-    Sprite* mpSprite;
+    std::unique_ptr<Tag> mpTag;
+    std::unique_ptr<Sprite> mpSprite;
     std::stack<Sprite*> mvSpriteStack;
     ChecksumCache mBitmapCache;
 


More information about the Libreoffice-commits mailing list