[Libreoffice-commits] core.git: 4 commits - filter/source include/oox include/vcl officecfg/registry sd/inc sd/sdi sd/source sfx2/inc sfx2/source vcl/source

Caolán McNamara caolanm at redhat.com
Wed Sep 30 05:36:07 PDT 2015


 filter/source/svg/svgwriter.cxx                                          |    3 
 include/oox/helper/binaryoutputstream.hxx                                |   13 -
 include/vcl/svgdata.hxx                                                  |    8 
 officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu |    7 
 sd/inc/app.hrc                                                           |    1 
 sd/inc/sdcommands.h                                                      |    1 
 sd/sdi/_drvwsh.sdi                                                       |    5 
 sd/sdi/sdraw.sdi                                                         |   24 ++
 sd/source/ui/app/menuids_tmpl.src                                        |   11 +
 sd/source/ui/func/fupage.cxx                                             |   85 ++++++----
 sd/source/ui/inc/DrawViewShell.hxx                                       |    4 
 sd/source/ui/view/drviews2.cxx                                           |    1 
 sd/source/ui/view/drviews7.cxx                                           |   25 ++
 sfx2/inc/pch/precompiled_sfx.hxx                                         |    1 
 sfx2/source/doc/DocumentMetadataAccess.cxx                               |    1 
 vcl/source/filter/graphicfilter.cxx                                      |   16 -
 vcl/source/gdi/impgraph.cxx                                              |   16 -
 vcl/source/gdi/pdfwriter_impl.cxx                                        |   30 +--
 vcl/source/gdi/svgdata.cxx                                               |   20 --
 19 files changed, 173 insertions(+), 99 deletions(-)

New commits:
commit ed25a000ab67324075e68d9a7f3ca657b4e6a573
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Sep 30 13:30:36 2015 +0100

    implement save slide background for impress
    
    to go along with the existing "set background",
    same sort of thing as the competitor's effort
    
    Change-Id: I2a1106771ead2cd926f3d631850447499340697c

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu
index 9e61182..d80b94d 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/DrawImpressCommands.xcu
@@ -1409,7 +1409,12 @@
       </node>
       <node oor:name=".uno:SelectBackground" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">
-          <value xml:lang="en-US">Background Image...</value>
+          <value xml:lang="en-US">Set Background Image...</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:SaveBackground" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Save Background Image...</value>
         </prop>
       </node>
       <node oor:name=".uno:DisplayMasterBackground" oor:op="replace">
diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc
index 4e1306c..0b21cd0 100644
--- a/sd/inc/app.hrc
+++ b/sd/inc/app.hrc
@@ -449,6 +449,7 @@
 #define SID_SLIDE_SORTER_MULTI_PANE_GUI     (SID_SD_START+421)
 
 #define SID_SELECT_BACKGROUND               (SID_SD_START+422)
+#define SID_SAVE_BACKGROUND                 (SID_SD_START+423)
         // FREE
 // Slots for the tool pane popup
 #define SID_TP_APPLY_TO_ALL_SLIDES          (SID_SD_START+425)
diff --git a/sd/inc/sdcommands.h b/sd/inc/sdcommands.h
index 2f4bf56..1d3502f 100644
--- a/sd/inc/sdcommands.h
+++ b/sd/inc/sdcommands.h
@@ -90,6 +90,7 @@
 #define CMD_SID_DELETE_MASTER_PAGE                  ".uno:DeleteMasterPage"
 #define CMD_SID_RENAME_MASTER_PAGE                  ".uno:RenameMasterPage"
 #define CMD_SID_SELECT_BACKGROUND                   ".uno:SelectBackground"
+#define CMD_SID_SAVE_BACKGROUND                     ".uno:SaveBackground"
 #define CMD_SID_DISPLAY_MASTER_BACKGROUND           ".uno:DisplayMasterBackground"
 #define CMD_SID_DISPLAY_MASTER_OBJECTS              ".uno:DisplayMasterObjects"
 #define CMD_SID_TABLE_DISTRIBUTE_COLUMNS            ".uno:DistributeColumns"
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
index 2f7769b..c25285d 100644
--- a/sd/sdi/_drvwsh.sdi
+++ b/sd/sdi/_drvwsh.sdi
@@ -2695,6 +2695,11 @@ interface DrawView
         ExecMethod = FuTemporary ;
         StateMethod = GetMenuState ;
     ]
+    SID_SAVE_BACKGROUND
+    [
+        ExecMethod = FuTemporary ;
+        StateMethod = GetMenuState ;
+    ]
     SID_DISPLAY_MASTER_BACKGROUND
     [
         ExecMethod = FuTemporary ;
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
index 5fd19ad..cda8bf8 100644
--- a/sd/sdi/sdraw.sdi
+++ b/sd/sdi/sdraw.sdi
@@ -6439,6 +6439,30 @@ SfxVoidItem SelectBackground SID_SELECT_BACKGROUND
     GroupId = GID_OPTIONS;
 ]
 
+SfxVoidItem SaveBackground SID_SAVE_BACKGROUND
+()
+[
+    /* flags: */
+    AutoUpdate = FALSE,
+    Cachable = Cachable,
+    FastCall = FALSE,
+    HasCoreId = FALSE,
+    HasDialog = TRUE,
+    ReadOnlyDoc = TRUE,
+    Toggle = FALSE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = FALSE,
+    MenuConfig = FALSE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = FALSE,
+    GroupId = GID_OPTIONS;
+]
+
 SfxBoolItem DisplayMasterBackground SID_DISPLAY_MASTER_BACKGROUND
 [
     /* flags: */
diff --git a/sd/source/ui/app/menuids_tmpl.src b/sd/source/ui/app/menuids_tmpl.src
index 5221ff1..c32cd2d 100644
--- a/sd/source/ui/app/menuids_tmpl.src
+++ b/sd/source/ui/app/menuids_tmpl.src
@@ -130,6 +130,13 @@
         HelpId = CMD_SID_SELECT_BACKGROUND ; \
         Text [ en-US ] = "Set Background Image..." ; \
     };
+#define MN_SAVE_BACKGROUND \
+    MenuItem\
+    {\
+        Identifier = SID_SAVE_BACKGROUND ; \
+        HelpId = CMD_SID_SAVE_BACKGROUND ; \
+        Text [ en-US ] = "Save Background Image..." ; \
+    };
 #define MN_DISPLAY_MASTER_BACKGROUND \
     MenuItem\
     {\
@@ -161,6 +168,7 @@
                 MN_SELECT_BACKGROUND\
                 MN_PAGE_DESIGN\
                 MN_RENAME_PAGE\
+                MN_SAVE_BACKGROUND\
             };\
         };\
         Text [ en-US ] = "Pag~e" ; \
@@ -192,7 +200,8 @@
                 MN_DISPLAY_MASTER_OBJECTS\
             };\
         };\
-    };
+    }; \
+    MN_SAVE_BACKGROUND
 
  // Layer
 #define MN_RENAME_LAYER \
diff --git a/sd/source/ui/func/fupage.cxx b/sd/source/ui/func/fupage.cxx
index f652f82..2fcf881 100644
--- a/sd/source/ui/func/fupage.cxx
+++ b/sd/source/ui/func/fupage.cxx
@@ -36,6 +36,7 @@
 #include <svx/svdundo.hxx>
 #include <editeng/eeitem.hxx>
 #include <editeng/frmdiritem.hxx>
+#include <svx/graphichelper.hxx>
 #include <svx/xbtmpit.hxx>
 #include <svx/xsetit.hxx>
 #include <editeng/ulspitem.hxx>
@@ -164,6 +165,41 @@ void FuPage::Deactivate()
 {
 }
 
+void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr)
+{
+    if (bMasterPage)
+    {
+        if (pStyleSheet)
+            mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet());
+    }
+    else
+    {
+        // Only this page, get attributes for background fill
+        const SfxItemSet& rBackgroundAttributes = pPage->getSdrPageProperties().GetItemSet();
+
+        if(drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(rBackgroundAttributes.Get(XATTR_FILLSTYLE)).GetValue())
+        {
+            // page attributes are used, take them
+            rMergedAttr.Put(rBackgroundAttributes);
+        }
+        else
+        {
+            if(pStyleSheet
+                && drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
+            {
+                // if the page has no fill style, use the settings from the
+                // background stylesheet (if used)
+                mergeItemSetsImpl(rMergedAttr, pStyleSheet->GetItemSet());
+            }
+            else
+            {
+                // no fill style from page, start with no fill style
+                rMergedAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
+            }
+        }
+    }
+}
+
 const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent )
 {
     if (!mpDrawViewShell)
@@ -247,44 +283,27 @@ const SfxItemSet* FuPage::ExecuteDialog( vcl::Window* pParent )
     // merge page background filling to the dialogs input set
     if( mbDisplayBackgroundTabPage )
     {
-        if( mbMasterPage )
-        {
-            if(pStyleSheet)
-                mergeItemSetsImpl( aMergedAttr, pStyleSheet->GetItemSet() );
-        }
-        else
-        {
-            // Only this page, get attributes for background fill
-            const SfxItemSet& rBackgroundAttributes = mpPage->getSdrPageProperties().GetItemSet();
-
-            if(drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(rBackgroundAttributes.Get(XATTR_FILLSTYLE)).GetValue())
-            {
-                // page attributes are used, take them
-                aMergedAttr.Put(rBackgroundAttributes);
-            }
-            else
-            {
-                if(pStyleSheet
-                    && drawing::FillStyle_NONE != static_cast<const XFillStyleItem&>(pStyleSheet->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
-                {
-                    // if the page has no fill style, use the settings from the
-                    // background stylesheet (if used)
-                    mergeItemSetsImpl(aMergedAttr, pStyleSheet->GetItemSet());
-                }
-                else
-                {
-                    // no fill style from page, start with no fill style
-                    aMergedAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
-                }
-            }
-        }
+        MergePageBackgroundFilling(mpPage, pStyleSheet, mbMasterPage, aMergedAttr);
     }
 
     std::unique_ptr< SfxItemSet > pTempSet;
 
-    if( GetSlotID() == SID_SELECT_BACKGROUND )
+    const sal_uInt16 nId = GetSlotID();
+    if (nId == SID_SAVE_BACKGROUND)
+    {
+        const XFillStyleItem& rStyleItem =
+            static_cast<const XFillStyleItem&>(aMergedAttr.Get(XATTR_FILLSTYLE));
+        if (drawing::FillStyle_BITMAP == (drawing::FillStyle)rStyleItem.GetValue())
+        {
+            const XFillBitmapItem& rBitmap =
+                static_cast<const XFillBitmapItem&>(aMergedAttr.Get(XATTR_FILLBITMAP));
+            const GraphicObject& rGraphicObj = rBitmap.GetGraphicObject();
+            GraphicHelper::ExportGraphic(rGraphicObj.GetGraphic(), "");
+        }
+    }
+    else if (nId == SID_SELECT_BACKGROUND)
     {
-        SvxOpenGraphicDialog    aDlg(SdResId(STR_SET_BACKGROUND_PICTURE));
+        SvxOpenGraphicDialog aDlg(SdResId(STR_SET_BACKGROUND_PICTURE));
 
         if( aDlg.Execute() == GRFILTER_OK )
         {
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
index 6205ef3..e6d24e7 100644
--- a/sd/source/ui/inc/DrawViewShell.hxx
+++ b/sd/source/ui/inc/DrawViewShell.hxx
@@ -33,6 +33,7 @@
 
 class Outliner;
 class SdPage;
+class SdStyleSheet;
 class SdrExternalToolEdit;
 class DrawDocShell;
 class TabBar;
@@ -515,6 +516,9 @@ private:
     Color mnAppBackgroundColor;
 };
 
+    /// Merge the background properties together and deposit the result in rMergeAttr
+    void MergePageBackgroundFilling(SdPage *pPage, SdStyleSheet *pStyleSheet, bool bMasterPage, SfxItemSet& rMergedAttr);
+
 } // end of namespace sd
 
 #endif
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index 358d3ce..2a8c7bf 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -1184,6 +1184,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
         break;
 
         case SID_SELECT_BACKGROUND:
+        case SID_SAVE_BACKGROUND:
         case SID_PAGESETUP:  // BASIC ??
         {
             SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index 2f3484e..480b433 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -84,6 +84,7 @@
 #include "fubullet.hxx"
 #include "fuconcs.hxx"
 #include "fuformatpaintbrush.hxx"
+#include "stlsheet.hxx"
 
 #include <config_features.h>
 
@@ -678,6 +679,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
     {
         rSet.DisableItem(SID_PRESENTATION_LAYOUT);
         rSet.DisableItem(SID_SELECT_BACKGROUND);
+        rSet.DisableItem(SID_SAVE_BACKGROUND);
     }
 
     if (mePageKind == PK_NOTES)
@@ -694,6 +696,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
             rSet.DisableItem(SID_MODIFYPAGE);
 
         rSet.DisableItem(SID_SELECT_BACKGROUND);
+        rSet.DisableItem(SID_SAVE_BACKGROUND);
         rSet.DisableItem(SID_INSERTLAYER);
         rSet.DisableItem(SID_LAYERMODE);
         rSet.DisableItem(SID_INSERTFILE);
@@ -714,6 +717,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
         rSet.DisableItem(SID_INSERTFILE);
         rSet.DisableItem(SID_PAGEMODE);
         rSet.DisableItem(SID_SELECT_BACKGROUND);
+        rSet.DisableItem(SID_SAVE_BACKGROUND);
     }
     else
     {
@@ -1593,8 +1597,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
         || rSet.GetItemState(SID_DISPLAY_MASTER_OBJECTS) == SfxItemState::DEFAULT)
     {
         SdPage* pPage = GetActualPage();
-        if (pPage != NULL
-            && GetDoc() != NULL)
+        if (pPage != NULL && GetDoc() != NULL)
         {
             SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
             SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
@@ -1615,6 +1618,24 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
     }
 #endif
 
+    if (rSet.GetItemState(SID_SAVE_BACKGROUND) == SfxItemState::DEFAULT)
+    {
+        bool bDisableSaveBackground = true;
+        SdPage* pPage = GetActualPage();
+        if (pPage != NULL && GetDoc() != NULL)
+        {
+            SfxItemSet aMergedAttr(GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0);
+            SdStyleSheet* pStyleSheet = pPage->getPresentationStyle(HID_PSEUDOSHEET_BACKGROUND);
+            MergePageBackgroundFilling(pPage, pStyleSheet, meEditMode == EM_MASTERPAGE, aMergedAttr);
+            if (drawing::FillStyle_BITMAP == static_cast<const XFillStyleItem&>(aMergedAttr.Get(XATTR_FILLSTYLE)).GetValue())
+            {
+                bDisableSaveBackground = false;
+            }
+        }
+        if (bDisableSaveBackground)
+            rSet.DisableItem(SID_SAVE_BACKGROUND);
+    }
+
     GetModeSwitchingMenuState (rSet);
 }
 
commit 739094745eb051e9a733ef16f59aba4cb74ea93e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Sep 30 10:32:38 2015 +0100

    drop unused headers
    
    Change-Id: If28362f97b36e378c426c3747beaddce6933b771

diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx
index ccaa0bd..8d93542 100644
--- a/sfx2/inc/pch/precompiled_sfx.hxx
+++ b/sfx2/inc/pch/precompiled_sfx.hxx
@@ -47,7 +47,6 @@
 #include <boost/ptr_container/ptr_map.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <memory>
-#include <boost/shared_array.hpp>
 #include <boost/tuple/tuple.hpp>
 #include <cassert>
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx
index ef64bee..ad6156c 100644
--- a/sfx2/source/doc/DocumentMetadataAccess.cxx
+++ b/sfx2/source/doc/DocumentMetadataAccess.cxx
@@ -49,7 +49,6 @@
 #include <libxml/tree.h>
 
 #include <boost/bind.hpp>
-#include <boost/shared_array.hpp>
 #include <boost/tuple/tuple.hpp>
 
 #include <vector>
commit 66343a8aeb4328a61766e4df41515130290e8a93
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Sep 30 10:17:20 2015 +0100

    shared_array->unique_ptr<[]>
    
    where we don't need to share the data
    
    Change-Id: I0edc9d62186d96095ee67e3c93f5cf186dffcb71

diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx
index 37b84fd..db8d1ce 100644
--- a/filter/source/svg/svgwriter.cxx
+++ b/filter/source/svg/svgwriter.cxx
@@ -30,7 +30,6 @@
 #include <sax/tools/converter.hxx>
 
 #include <memory>
-#include <boost/shared_array.hpp>
 
 
 static const char   aXMLElemG[] = "g";
@@ -2422,7 +2421,7 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const OUString& rText,
     else
         aPos = rPos;
 
-    boost::shared_array<long> xTmpArray(new long[nLen]);
+    std::unique_ptr<long[]> xTmpArray(new long[nLen]);
     // get text sizes
     if( pDXArray )
     {
diff --git a/include/oox/helper/binaryoutputstream.hxx b/include/oox/helper/binaryoutputstream.hxx
index 49eb7e7..bcceec3 100644
--- a/include/oox/helper/binaryoutputstream.hxx
+++ b/include/oox/helper/binaryoutputstream.hxx
@@ -20,10 +20,8 @@
 #ifndef INCLUDED_OOX_HELPER_BINARYOUTPUTSTREAM_HXX
 #define INCLUDED_OOX_HELPER_BINARYOUTPUTSTREAM_HXX
 
-#include <memory>
-#include <boost/shared_array.hpp>
-
 #include <oox/helper/binarystreambase.hxx>
+#include <memory>
 
 namespace com { namespace sun { namespace star {
     namespace io { class XOutputStream; }
@@ -103,14 +101,11 @@ void BinaryOutputStream::writeArray( Type* opnArray, sal_Int32 nElemCount )
 template< typename Type >
 void BinaryOutputStream::writeArray( const Type* opnArray, sal_Int32 nElemCount )
 {
-    boost::shared_array<Type> pArray(new Type[nElemCount]);
-    std::uninitialized_copy(opnArray, opnArray + nElemCount, pArray.get());
-    writeArray(pArray.get(), nElemCount);
+    std::unique_ptr<Type[]> xArray(new Type[nElemCount]);
+    std::uninitialized_copy(opnArray, opnArray + nElemCount, xArray.get());
+    writeArray(xArray.get(), nElemCount);
 }
 
-
-
-
 template< typename Type >
 void BinaryOutputStream::writeValue( Type nValue )
 {
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 0911269..dfdbae3 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3465,8 +3465,8 @@ std::map< sal_Int32, sal_Int32 > PDFWriterImpl::emitEmbeddedFont( const Physical
                     }
                     else
                     {
-                        boost::shared_array<unsigned char> pWriteBuffer( new unsigned char[ nLength2 ] );
-                        memset( pWriteBuffer.get(), 0, nLength2 );
+                        std::unique_ptr<unsigned char[]> xWriteBuffer(new unsigned char[nLength2]);
+                        memset(xWriteBuffer.get(), 0, nLength2);
                         int nWriteIndex = 0;
 
                         int nNextSectionIndex = 0;
@@ -3493,11 +3493,11 @@ std::map< sal_Int32, sal_Int32 > PDFWriterImpl::emitEmbeddedFont( const Physical
                             {
                                 if( !(nWriteIndex & 1 ) )
                                     cNibble <<= 4;
-                                pWriteBuffer.get()[ nWriteIndex/2 ] |= cNibble;
+                                xWriteBuffer.get()[ nWriteIndex/2 ] |= cNibble;
                                 nWriteIndex++;
                             }
                         }
-                        if( ! writeBuffer( pWriteBuffer.get(), nLength2 ) )
+                        if (!writeBuffer(xWriteBuffer.get(), nLength2))
                             throw FontException();
                         if( aSections.empty() )
                         {
@@ -4039,15 +4039,15 @@ bool PDFWriterImpl::emitFonts()
                 }
                 else if( (aSubsetInfo.m_nFontType & FontSubsetInfo::TYPE1_PFB) != 0 ) // TODO: also support PFA?
                 {
-                    boost::shared_array<unsigned char> pBuffer( new unsigned char[ nLength1 ] );
+                    std::unique_ptr<unsigned char[]> xBuffer(new unsigned char[nLength1]);
 
                     sal_uInt64 nBytesRead = 0;
-                    if ( osl::File::E_None != aFontFile.read(pBuffer.get(), nLength1, nBytesRead) ) return false;
+                    if ( osl::File::E_None != aFontFile.read(xBuffer.get(), nLength1, nBytesRead) ) return false;
                     DBG_ASSERT( nBytesRead==nLength1, "PDF-FontSubset read incomplete!" );
                     if ( osl::File::E_None != aFontFile.setPos(osl_Pos_Absolut, 0) ) return false;
                     // get the PFB-segment lengths
                     ThreeInts aSegmentLengths = {0,0,0};
-                    getPfbSegmentLengths( pBuffer.get(), (int)nBytesRead, aSegmentLengths );
+                    getPfbSegmentLengths(xBuffer.get(), (int)nBytesRead, aSegmentLengths);
                     // the lengths below are mandatory for PDF-exported Type1 fonts
                     // because the PFB segment headers get stripped! WhyOhWhy.
                     aLine.append( (sal_Int32)aSegmentLengths[0] );
@@ -4064,9 +4064,9 @@ bool PDFWriterImpl::emitFonts()
                     // emit PFB-sections without section headers
                     beginCompression();
                     checkAndEnableStreamEncryption( nFontStream );
-                    if ( !writeBuffer( &pBuffer[6], aSegmentLengths[0] ) ) return false;
-                    if ( !writeBuffer( &pBuffer[12] + aSegmentLengths[0], aSegmentLengths[1] ) ) return false;
-                    if ( !writeBuffer( &pBuffer[18] + aSegmentLengths[0] + aSegmentLengths[1], aSegmentLengths[2] ) ) return false;
+                    if ( !writeBuffer( &xBuffer[6], aSegmentLengths[0] ) ) return false;
+                    if ( !writeBuffer( &xBuffer[12] + aSegmentLengths[0], aSegmentLengths[1] ) ) return false;
+                    if ( !writeBuffer( &xBuffer[18] + aSegmentLengths[0] + aSegmentLengths[1], aSegmentLengths[2] ) ) return false;
                 }
                 else
                 {
@@ -11440,17 +11440,17 @@ bool PDFWriterImpl::writeBitmapObject( BitmapEmit& rObject, bool bMask )
         else
         {
             const int nScanLineBytes = pAccess->Width()*3;
-            boost::shared_array<sal_uInt8> pCol( new sal_uInt8[ nScanLineBytes ] );
+            std::unique_ptr<sal_uInt8[]> xCol(new sal_uInt8[nScanLineBytes]);
             for( long y = 0; y < pAccess->Height(); y++ )
             {
                 for( long x = 0; x < pAccess->Width(); x++ )
                 {
                     BitmapColor aColor = pAccess->GetColor( y, x );
-                    pCol[3*x+0] = aColor.GetRed();
-                    pCol[3*x+1] = aColor.GetGreen();
-                    pCol[3*x+2] = aColor.GetBlue();
+                    xCol[3*x+0] = aColor.GetRed();
+                    xCol[3*x+1] = aColor.GetGreen();
+                    xCol[3*x+2] = aColor.GetBlue();
                 }
-                CHECK_RETURN( writeBuffer( pCol.get(), nScanLineBytes ) );
+                CHECK_RETURN(writeBuffer(xCol.get(), nScanLineBytes));
             }
         }
         endCompression();
commit 78c83032b266fbb6fc20ddca86df80affaff7c24
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Sep 30 09:40:16 2015 +0100

    maSvgDataArray only populates a uno::Sequence, so use that instead
    
    Change-Id: I335d5ee70e95e1a3b204d34f6df4cb62f3fb3cad

diff --git a/include/vcl/svgdata.hxx b/include/vcl/svgdata.hxx
index c8ee186..b234c10 100644
--- a/include/vcl/svgdata.hxx
+++ b/include/vcl/svgdata.hxx
@@ -21,13 +21,12 @@
 #define INCLUDED_VCL_SVGDATA_HXX
 
 #include <basegfx/range/b2drange.hxx>
-#include <boost/shared_array.hpp>
 #include <com/sun/star/graphic/XPrimitive2D.hpp>
 #include <vcl/bitmapex.hxx>
 #include <rtl/ustring.hxx>
 
 
-typedef boost::shared_array< sal_uInt8 > SvgDataArray;
+typedef css::uno::Sequence<sal_Int8> SvgDataArray;
 
 
 // helper to convert any Primitive2DSequence to a good quality BitmapEx,
@@ -44,7 +43,6 @@ class VCL_DLLPUBLIC SvgData
 private:
     // the file and length
     SvgDataArray            maSvgDataArray;
-    sal_uInt32              mnSvgDataArrayLength;
 
     // The absolute Path if available
     OUString           maPath;
@@ -63,12 +61,12 @@ private:
     SvgData& operator=(const SvgData&) SAL_DELETED_FUNCTION;
 
 public:
-    SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const OUString& rPath);
+    SvgData(const SvgDataArray& rSvgDataArray, const OUString& rPath);
     SvgData(const OUString& rPath);
 
     /// data read
     const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
-    sal_uInt32 getSvgDataArrayLength() const { return mnSvgDataArrayLength; }
+    sal_uInt32 getSvgDataArrayLength() const { return maSvgDataArray.getLength(); }
     const OUString& getPath() const { return maPath; }
 
     /// data read and evtl. on demand creation
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 7d79078..49f3b65 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1533,18 +1533,18 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat
 
                     if (!rIStream.GetError() && nMemoryLength >= 0)
                     {
-                        SvgDataArray aNewData(new sal_uInt8[nMemoryLength]);
+                        SvgDataArray aNewData(nMemoryLength);
                         aMemStream.Seek(STREAM_SEEK_TO_BEGIN);
-                        aMemStream.Read(aNewData.get(), nMemoryLength);
+                        aMemStream.Read(aNewData.begin(), nMemoryLength);
 
                         // Make a uncompressed copy for GfxLink
                         nGraphicContentSize = nMemoryLength;
                         pGraphicContent = new sal_uInt8[nGraphicContentSize];
-                        std::copy(aNewData.get(), aNewData.get() + nMemoryLength, pGraphicContent);
+                        std::copy(aNewData.begin(), aNewData.end(), pGraphicContent);
 
                         if(!aMemStream.GetError() )
                         {
-                            SvgDataPtr aSvgDataPtr(new SvgData(aNewData, nMemoryLength, rPath));
+                            SvgDataPtr aSvgDataPtr(new SvgData(aNewData, rPath));
                             rGraphic = Graphic(aSvgDataPtr);
                             bOkay = true;
                         }
@@ -1552,20 +1552,20 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat
                 }
                 else
                 {
-                    SvgDataArray aNewData(new sal_uInt8[nStreamLength]);
+                    SvgDataArray aNewData(nStreamLength);
                     rIStream.Seek(nStreamPosition);
-                    rIStream.Read(aNewData.get(), nStreamLength);
+                    rIStream.Read(aNewData.begin(), nStreamLength);
 
                     if(!rIStream.GetError())
                     {
-                        SvgDataPtr aSvgDataPtr(new SvgData(aNewData, nStreamLength, rPath));
+                        SvgDataPtr aSvgDataPtr(new SvgData(aNewData, rPath));
                         rGraphic = Graphic(aSvgDataPtr);
                         bOkay = true;
                     }
                 }
             }
 
-            if(bOkay)
+            if (bOkay)
             {
                 eLinkType = GFX_LINK_TYPE_NATIVE_SVG;
             }
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 4050efe..735eab1 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1542,23 +1542,21 @@ SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
                         }
                         else
                         {
-                            sal_uInt32 mnSvgDataArrayLength(0);
-                            rIStm.ReadUInt32( mnSvgDataArrayLength );
+                            sal_uInt32 nSvgDataArrayLength(0);
+                            rIStm.ReadUInt32(nSvgDataArrayLength);
 
-                            if(mnSvgDataArrayLength)
+                            if (nSvgDataArrayLength)
                             {
-                                SvgDataArray aNewData(new sal_uInt8[mnSvgDataArrayLength]);
-                                OUString aPath;
+                                SvgDataArray aNewData(nSvgDataArrayLength);
 
-                                rIStm.Read(aNewData.get(), mnSvgDataArrayLength);
-                                aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
+                                rIStm.Read(aNewData.begin(), nSvgDataArrayLength);
+                                OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
 
-                                if(!rIStm.GetError())
+                                if (!rIStm.GetError())
                                 {
                                     SvgDataPtr aSvgDataPtr(
                                         new SvgData(
                                             aNewData,
-                                            mnSvgDataArrayLength,
                                             OUString(aPath)));
 
                                     rImpGraphic = aSvgDataPtr;
diff --git a/vcl/source/gdi/svgdata.cxx b/vcl/source/gdi/svgdata.cxx
index d86fc8d..cd1614e 100644
--- a/vcl/source/gdi/svgdata.cxx
+++ b/vcl/source/gdi/svgdata.cxx
@@ -99,14 +99,13 @@ void SvgData::ensureReplacement()
 
 void SvgData::ensureSequenceAndRange()
 {
-    if(!maSequence.hasElements() && mnSvgDataArrayLength)
+    if(!maSequence.hasElements() && maSvgDataArray.hasElements())
     {
         // import SVG to maSequence, also set maRange
         maRange.reset();
 
         // create stream
-        const uno::Sequence< sal_Int8 > aPostData(reinterpret_cast<sal_Int8*>(maSvgDataArray.get()), mnSvgDataArrayLength);
-        const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(aPostData));
+        const uno::Reference< io::XInputStream > myInputStream(new comphelper::SequenceInputStream(maSvgDataArray));
 
         if(myInputStream.is())
         {
@@ -152,9 +151,8 @@ void SvgData::ensureSequenceAndRange()
     }
 }
 
-SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const OUString& rPath)
+SvgData::SvgData(const SvgDataArray& rSvgDataArray, const OUString& rPath)
 :   maSvgDataArray(rSvgDataArray),
-    mnSvgDataArrayLength(nSvgDataArrayLength),
     maPath(rPath),
     maRange(),
     maSequence(),
@@ -164,7 +162,6 @@ SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLeng
 
 SvgData::SvgData(const OUString& rPath):
     maSvgDataArray(),
-    mnSvgDataArrayLength(0),
     maPath(rPath),
     maRange(),
     maSequence(),
@@ -174,15 +171,14 @@ SvgData::SvgData(const OUString& rPath):
     if(rIStm.GetError())
         return;
     const sal_uInt32 nStmLen(rIStm.remainingSize());
-    if(nStmLen)
+    if (nStmLen)
     {
-        SvgDataArray aNewData(new sal_uInt8[nStmLen]);
-        rIStm.Read(aNewData.get(), nStmLen);
+        maSvgDataArray.realloc(nStmLen);
+        rIStm.Read(maSvgDataArray.begin(), nStmLen);
 
-        if(!rIStm.GetError())
+        if (rIStm.GetError())
         {
-            maSvgDataArray = aNewData;
-            mnSvgDataArrayLength = nStmLen;
+            maSvgDataArray = SvgDataArray();
         }
     }
 }


More information about the Libreoffice-commits mailing list