[Libreoffice-commits] core.git: 5 commits - canvas/source editeng/inc filter/source framework/inc sw/inc sw/source vcl/source

Michael Stahl mstahl at redhat.com
Wed May 25 21:54:53 UTC 2016


 canvas/source/directx/dx_canvasbitmap.cxx    |   28 +++++++++---------------
 editeng/inc/pch/precompiled_editeng.hxx      |    1 
 filter/source/svg/js2hxx.py                  |    4 +++
 filter/source/svg/svgexport.cxx              |   10 +++-----
 framework/inc/pch/precompiled_fwk.hxx        |    1 
 sw/inc/pch/precompiled_sw.hxx                |    1 
 sw/source/core/tox/ToxWhitespaceStripper.cxx |    8 +++---
 sw/source/filter/ww8/WW8Sttbf.cxx            |   11 +++++----
 sw/source/filter/ww8/WW8Sttbf.hxx            |    4 +--
 vcl/source/gdi/pdfwriter_impl.hxx            |   31 +++++----------------------
 10 files changed, 37 insertions(+), 62 deletions(-)

New commits:
commit 1029b6cb067eb8cb8c2c00663f4403f9e13fde05
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 25 23:19:05 2016 +0200

    sw: replace boost::shared_array with std::shared_ptr
    
    Change-Id: I99eec60db7f6d586b3b424661e03a7891422ab2e

diff --git a/editeng/inc/pch/precompiled_editeng.hxx b/editeng/inc/pch/precompiled_editeng.hxx
index bd2786b..1d1ab23 100644
--- a/editeng/inc/pch/precompiled_editeng.hxx
+++ b/editeng/inc/pch/precompiled_editeng.hxx
@@ -50,7 +50,6 @@
 #include <utility>
 #include <vector>
 #include <boost/intrusive_ptr.hpp>
-#include <boost/shared_array.hpp>
 #include <osl/diagnose.h>
 #include <osl/doublecheckedlocking.h>
 #include <osl/endian.h>
diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx
index 11b6477..c27cb3d 100644
--- a/framework/inc/pch/precompiled_fwk.hxx
+++ b/framework/inc/pch/precompiled_fwk.hxx
@@ -54,7 +54,6 @@
 #include <vector>
 #include <boost/intrusive_ptr.hpp>
 #include <boost/optional.hpp>
-#include <boost/shared_array.hpp>
 #include <osl/conditn.h>
 #include <osl/conditn.hxx>
 #include <osl/diagnose.h>
diff --git a/sw/source/filter/ww8/WW8Sttbf.cxx b/sw/source/filter/ww8/WW8Sttbf.cxx
index 8d985cc..d5b24b2 100644
--- a/sw/source/filter/ww8/WW8Sttbf.cxx
+++ b/sw/source/filter/ww8/WW8Sttbf.cxx
@@ -24,6 +24,7 @@
 #include <cstdio>
 #include <osl/endian.h>
 #include <rtl/ustrbuf.hxx>
+#include <o3tl/make_shared.hxx>
 #include <tools/stream.hxx>
 
 namespace ww8
@@ -35,14 +36,14 @@ namespace ww8
         {
             sal_Size nRemainingSize = rSt.remainingSize();
             nSize = std::min<sal_uInt32>(nRemainingSize, nSize);
-            mp_data.reset(new sal_uInt8[nSize]);
-            mn_size = rSt.Read(mp_data.get(), nSize);
+            m_pData = o3tl::make_shared_array<sal_uInt8>(nSize);
+            mn_size = rSt.Read(m_pData.get(), nSize);
         }
         OSL_ENSURE(mn_size == nSize, "short read in WW8Struct::WW8Struct");
     }
 
     WW8Struct::WW8Struct(WW8Struct * pStruct, sal_uInt32 nPos, sal_uInt32 nSize)
-        : mp_data(pStruct->mp_data), mn_offset(pStruct->mn_offset + nPos)
+        : m_pData(pStruct->m_pData), mn_offset(pStruct->mn_offset + nPos)
         , mn_size(nSize)
     {
     }
@@ -57,7 +58,7 @@ namespace ww8
 
         if (nOffset < mn_size)
         {
-            nResult = mp_data[mn_offset + nOffset];
+            nResult = m_pData.get()[mn_offset + nOffset];
         }
 
         return nResult;
@@ -79,7 +80,7 @@ namespace ww8
                 nCount = nAvailable;
 #if defined OSL_LITENDIAN
             aResult = OUString(reinterpret_cast<const sal_Unicode *>(
-                mp_data.get() + nStartOff), nCount);
+                m_pData.get() + nStartOff), nCount);
 #else
             OUStringBuffer aBuf;
             for (sal_uInt32 i = 0; i < nCount; ++i)
diff --git a/sw/source/filter/ww8/WW8Sttbf.hxx b/sw/source/filter/ww8/WW8Sttbf.hxx
index 744e4d9..e6f4cf2 100644
--- a/sw/source/filter/ww8/WW8Sttbf.hxx
+++ b/sw/source/filter/ww8/WW8Sttbf.hxx
@@ -22,7 +22,7 @@
 
 #include <memory>
 #include <vector>
-#include <boost/shared_array.hpp>
+
 #include <tools/solar.h>
 #include <rtl/ustring.hxx>
 #include <IDocumentExternalData.hxx>
@@ -34,7 +34,7 @@ namespace ww8
 
     class WW8Struct : public ::sw::ExternalData
     {
-        boost::shared_array<sal_uInt8> mp_data;
+        std::shared_ptr<sal_uInt8> m_pData;
         sal_uInt32 mn_offset;
         sal_uInt32 mn_size;
 
commit 66e798dda73b66471940ee99298ba4069345630a
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 25 22:45:58 2016 +0200

    vcl: replace prematurely optimized GlyphEmit with a std::vector
    
    Change-Id: Ie0cdc224c1b224ea549c011f1d07beb38261516f

diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 4cc5e0bf..c8ebcac 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -24,7 +24,6 @@
 #include <unordered_map>
 #include <vector>
 
-#include <boost/shared_array.hpp>
 #include <com/sun/star/lang/Locale.hpp>
 #include <com/sun/star/util/XURLTransformer.hpp>
 #include <osl/file.hxx>
@@ -272,17 +271,12 @@ public:
     class GlyphEmit
     {
         // performance: actually this should probably a vector;
-        sal_Ucs                         m_aBufferedUnicodes[3];
-        sal_Int32                       m_nUnicodes;
-        sal_Int32                       m_nMaxUnicodes;
-        boost::shared_array<sal_Ucs>    m_pUnicodes;
+        std::vector<sal_Ucs>            m_Unicodes;
         sal_uInt8                       m_nSubsetGlyphID;
 
     public:
-        GlyphEmit() : m_nUnicodes(0), m_nSubsetGlyphID(0)
+        GlyphEmit() : m_nSubsetGlyphID(0)
         {
-            memset( m_aBufferedUnicodes, 0, sizeof( m_aBufferedUnicodes ) );
-            m_nMaxUnicodes = SAL_N_ELEMENTS(m_aBufferedUnicodes);
         }
         ~GlyphEmit()
         {
@@ -293,27 +287,14 @@ public:
 
         void addCode( sal_Ucs i_cCode )
         {
-            if( m_nUnicodes == m_nMaxUnicodes )
-            {
-                sal_Ucs* pNew = new sal_Ucs[ 2 * m_nMaxUnicodes];
-                if( m_pUnicodes.get() )
-                    memcpy( pNew, m_pUnicodes.get(), m_nMaxUnicodes * sizeof(sal_Ucs) );
-                else
-                    memcpy( pNew, m_aBufferedUnicodes, m_nMaxUnicodes * sizeof(sal_Ucs) );
-                m_pUnicodes.reset( pNew );
-                m_nMaxUnicodes *= 2;
-            }
-            if( m_pUnicodes.get() )
-                m_pUnicodes[ m_nUnicodes++ ] = i_cCode;
-            else
-                m_aBufferedUnicodes[ m_nUnicodes++ ] = i_cCode;
+            m_Unicodes.push_back(i_cCode);
         }
-        sal_Int32 countCodes() const { return m_nUnicodes; }
+        sal_Int32 countCodes() const { return m_Unicodes.size(); }
         sal_Ucs getCode( sal_Int32 i_nIndex ) const
         {
             sal_Ucs nRet = 0;
-            if( i_nIndex < m_nUnicodes )
-                nRet = m_pUnicodes.get() ? m_pUnicodes[ i_nIndex ] : m_aBufferedUnicodes[ i_nIndex ];
+            if (static_cast<size_t>(i_nIndex) < m_Unicodes.size())
+                nRet = m_Unicodes[i_nIndex];
             return nRet;
         }
     };
commit 03ddce193b3a031d9156775a8ee94206ba5b39ce
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 25 22:16:50 2016 +0200

    canvas: replace BOOST_PP usage
    
    Change-Id: I46bb4aba6c08fb753b22242069ef0b00d4c77f12

diff --git a/canvas/source/directx/dx_canvasbitmap.cxx b/canvas/source/directx/dx_canvasbitmap.cxx
index 2af84a5..e2e249a 100644
--- a/canvas/source/directx/dx_canvasbitmap.cxx
+++ b/canvas/source/directx/dx_canvasbitmap.cxx
@@ -22,9 +22,6 @@
 #include <cctype>
 #include <memory>
 
-#include <boost/preprocessor/repetition.hpp>
-#include <boost/preprocessor/iteration/local.hpp>
-
 #include <cppuhelper/supportsservice.hxx>
 #include <tools/diagnose_ex.h>
 #include <vcl/bitmapex.hxx>
@@ -64,6 +61,16 @@ namespace dxcanvas
     {
         BITMAPINFOHEADER bmiHeader;
         RGBQUAD          bmiColors[256];
+        AlphaDIB()
+            : bmiHeader({0,0,0,1,8,BI_RGB,0,0,0,0,0})
+        {
+            for (size_t i = 0; i < 256; ++i)
+            {
+                // this here fills palette with grey level colors, starting
+                // from 0,0,0 up to 255,255,255
+                bmiColors[i] = { i,i,i,i };
+            }
+        }
     };
 
     uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle )  throw (uno::RuntimeException)
@@ -158,20 +165,7 @@ namespace dxcanvas
                 }
                 else
                 {
-                    static AlphaDIB aDIB=
-                        {
-                            {0,0,0,1,8,BI_RGB,0,0,0,0,0},
-                            {
-                                // this here fills palette with grey
-                                // level colors, starting from 0,0,0
-                                // up to 255,255,255
-#define BOOST_PP_LOCAL_MACRO(n_) \
-                    BOOST_PP_COMMA_IF(n_) \
-                    {n_,n_,n_,n_}
-#define BOOST_PP_LOCAL_LIMITS     (0, 255)
-#include BOOST_PP_LOCAL_ITERATE()
-                            }
-                        };
+                    static AlphaDIB aDIB;
 
                     // need to copy&convert the bitmap, since dx
                     // canvas uses inline alpha channel
commit aa7772a80bca16df21b24c3632fce8244d6055bf
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 25 18:27:23 2016 +0200

    filter: generate that with the python script, not BOOST_PP
    
    Change-Id: I9ab4cf721dd135aaae021fa05b8b6df54389a9b7

diff --git a/filter/source/svg/js2hxx.py b/filter/source/svg/js2hxx.py
index 5d6ddd51..1c76762 100755
--- a/filter/source/svg/js2hxx.py
+++ b/filter/source/svg/js2hxx.py
@@ -127,6 +127,10 @@ for line in valid_lines:
 out_lines.append( ']]>";' )
 out_lines.append( '' )
 
+out_lines.append('static const char * g_SVGScripts[N_SVGSCRIPT_FRAGMENTS] = {')
+for j in range(0, fragment+1):
+    out_lines.append("    %s%d," % (VARIABLE_NAME, j))
+out_lines.append('};')
 
 outfile = open( outfile_name, 'w' )
 if( not os.path.isfile( outfile_name ) ):
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index acc0912..96cb1fb 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -49,7 +49,6 @@
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/animationexport.hxx>
 
-#include <boost/preprocessor/repetition/repeat.hpp>
 #include <memory>
 
 using namespace ::com::sun::star::graphic;
@@ -1347,10 +1346,6 @@ void SVGFilter::implExportTextEmbeddedBitmaps()
     }
 }
 
-
-#define SVGFILTER_EXPORT_SVGSCRIPT( z, n, aFragment ) \
-        xExtDocHandler->unknown( aFragment ## n );
-
 void SVGFilter::implGenerateScript()
 {
     mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "type", "text/ecmascript" );
@@ -1361,7 +1356,10 @@ void SVGFilter::implGenerateScript()
 
         if( xExtDocHandler.is() )
         {
-            BOOST_PP_REPEAT( N_SVGSCRIPT_FRAGMENTS, SVGFILTER_EXPORT_SVGSCRIPT, aSVGScript )
+            for (size_t i = 0; i < N_SVGSCRIPT_FRAGMENTS; ++i)
+            {
+                xExtDocHandler->unknown(OUString::createFromAscii(g_SVGScripts[i]));
+            }
         }
     }
 }
commit 6b54253d4ff0c550a116fee87629ab5c32123af5
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 25 17:35:57 2016 +0200

    sw: boost::numeric_cast not really ideal in core code
    
    ... since that can't handle exceptions particularly well anyway.
    Negative position would be a bug anyway, so assert() is appropriate.
    
    Change-Id: Ib246200b3c64ec049fa39835d922092d5a660f55

diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx
index e085bba..bcad79a 100644
--- a/sw/inc/pch/precompiled_sw.hxx
+++ b/sw/inc/pch/precompiled_sw.hxx
@@ -52,7 +52,6 @@
 #include <unordered_map>
 #include <utility>
 #include <vector>
-#include <boost/numeric/conversion/cast.hpp>
 #include <boost/optional.hpp>
 #include <boost/optional/optional.hpp>
 #include <boost/property_tree/json_parser.hpp>
diff --git a/sw/source/core/tox/ToxWhitespaceStripper.cxx b/sw/source/core/tox/ToxWhitespaceStripper.cxx
index c38079c..9ea87c4 100644
--- a/sw/source/core/tox/ToxWhitespaceStripper.cxx
+++ b/sw/source/core/tox/ToxWhitespaceStripper.cxx
@@ -12,7 +12,6 @@
 #include "rtl/ustrbuf.hxx"
 #include "sal/log.hxx"
 
-#include <boost/numeric/conversion/cast.hpp>
 
 namespace sw {
 
@@ -51,13 +50,14 @@ ToxWhitespaceStripper::ToxWhitespaceStripper(const OUString& inputString)
 sal_Int32
 ToxWhitespaceStripper::GetPositionInStrippedString(sal_Int32 pos) const
 {
-    size_t upos = boost::numeric_cast<size_t>(pos);
-    if (upos >= mNewPositions.size()) {
+    assert(0 <= pos);
+    if (static_cast<size_t>(pos) >= mNewPositions.size()) {
+        // TODO probably this should assert, not just warn?
         SAL_WARN("sw.core", "Requested position of TOX entry text which does not exist. "
                             "Maybe the formatting hint is corrupt?");
         return mNewPositions.back();
     }
-    return mNewPositions.at(upos);
+    return mNewPositions.at(pos);
 }
 
 


More information about the Libreoffice-commits mailing list