[Libreoffice-commits] core.git: include/oox oox/source

Stephan Bergmann sbergman at redhat.com
Thu Jan 5 14:42:31 UTC 2017


 include/oox/export/vmlexport.hxx |    2 -
 oox/source/export/vmlexport.cxx  |   56 ++++++++++++++++++---------------------
 2 files changed, 28 insertions(+), 30 deletions(-)

New commits:
commit cdff2caffabf97cb87a22548e0d1a55f4e1daf42
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jan 5 15:41:59 2017 +0100

    No need for heap-allocated OUStringBuffer
    
    Change-Id: Id2dbe3ecce9eba2eefab90f43b9a2a6894839cfb

diff --git a/include/oox/export/vmlexport.hxx b/include/oox/export/vmlexport.hxx
index e9971e0..c8f06c2 100644
--- a/include/oox/export/vmlexport.hxx
+++ b/include/oox/export/vmlexport.hxx
@@ -99,7 +99,7 @@ class OOX_DLLPUBLIC VMLExport : public EscherEx
     sal_uInt32 m_nShapeFlags;
 
     /// Remember style, the most important shape attribute ;-)
-    OStringBuffer *m_pShapeStyle;
+    OStringBuffer m_pShapeStyle;
 
     /// Remember which shape types we had already written.
     bool *m_pShapeTypeWritten;
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index c284b55..59c1f20 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -64,7 +64,7 @@ VMLExport::VMLExport( ::sax_fastparser::FSHelperPtr const & pSerializer, VMLText
     , m_pShapeAttrList( nullptr )
     , m_nShapeType( ESCHER_ShpInst_Nil )
     , m_nShapeFlags(0)
-    , m_pShapeStyle( new OStringBuffer( 200 ) )
+    , m_pShapeStyle( 200 )
     , m_pShapeTypeWritten( new bool[ ESCHER_ShpInst_COUNT ] )
 {
     mnGroupLevel = 1;
@@ -80,8 +80,6 @@ VMLExport::~VMLExport()
 {
     delete mpOutStrm;
     mpOutStrm = nullptr;
-    delete m_pShapeStyle;
-    m_pShapeStyle = nullptr;
     delete[] m_pShapeTypeWritten;
     m_pShapeTypeWritten = nullptr;
 }
@@ -100,10 +98,10 @@ void VMLExport::OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance )
         m_nShapeType = ESCHER_ShpInst_Nil;
         m_pShapeAttrList = FastSerializerHelper::createAttrList();
 
-        if ( !m_pShapeStyle->isEmpty() )
-            m_pShapeStyle->setLength(0);
+        if ( !m_pShapeStyle.isEmpty() )
+            m_pShapeStyle.setLength(0);
 
-        m_pShapeStyle->ensureCapacity( 200 );
+        m_pShapeStyle.ensureCapacity( 200 );
 
         // postpone the output so that we are able to write even the elements
         // that we learn inside Commit()
@@ -372,7 +370,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect
     if ( m_nShapeType == ESCHER_ShpInst_Line )
         AddLineDimensions( rRect );
     else
-        AddRectangleDimensions( *m_pShapeStyle, rRect );
+        AddRectangleDimensions( m_pShapeStyle, rRect );
 
     // properties
     bool bAlreadyWritten[ 0xFFF ];
@@ -763,7 +761,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect
 
             case ESCHER_Prop_fHidden:
                 if ( !it->nPropValue )
-                    m_pShapeStyle->append( ";visibility:hidden" );
+                    m_pShapeStyle.append( ";visibility:hidden" );
                 break;
             case ESCHER_Prop_shadowColor:
             case ESCHER_Prop_fshadowObscured:
@@ -832,7 +830,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect
             case ESCHER_Prop_Rotation:
                 {
                     // The higher half of the variable contains the angle.
-                    m_pShapeStyle->append(";rotation:").append(double(it->nPropValue >> 16));
+                    m_pShapeStyle.append(";rotation:").append(double(it->nPropValue >> 16));
                     bAlreadyWritten[ESCHER_Prop_Rotation] = true;
                 }
                 break;
@@ -889,19 +887,19 @@ void VMLExport::AddFlipXY( )
     const sal_uInt32 nFlipHandV = SHAPEFLAG_FLIPH + SHAPEFLAG_FLIPV;
     switch ( m_nShapeFlags & nFlipHandV )
     {
-        case SHAPEFLAG_FLIPH:   m_pShapeStyle->append( ";flip:x" );  break;
-        case SHAPEFLAG_FLIPV:   m_pShapeStyle->append( ";flip:y" );  break;
-        case nFlipHandV:        m_pShapeStyle->append( ";flip:xy" ); break;
+        case SHAPEFLAG_FLIPH:   m_pShapeStyle.append( ";flip:x" );  break;
+        case SHAPEFLAG_FLIPV:   m_pShapeStyle.append( ";flip:y" );  break;
+        case nFlipHandV:        m_pShapeStyle.append( ";flip:xy" ); break;
     }
 }
 
 void VMLExport::AddLineDimensions( const Rectangle& rRectangle )
 {
     // style
-    if ( !m_pShapeStyle->isEmpty() )
-        m_pShapeStyle->append( ";" );
+    if ( !m_pShapeStyle.isEmpty() )
+        m_pShapeStyle.append( ";" );
 
-    m_pShapeStyle->append( "position:absolute" );
+    m_pShapeStyle.append( "position:absolute" );
 
     AddFlipXY();
 
@@ -1062,19 +1060,19 @@ sal_Int32 VMLExport::StartShape()
     switch (m_eHOri)
     {
         case text::HoriOrientation::LEFT:
-            m_pShapeStyle->append(";mso-position-horizontal:left");
+            m_pShapeStyle.append(";mso-position-horizontal:left");
             break;
         case text::HoriOrientation::CENTER:
-            m_pShapeStyle->append(";mso-position-horizontal:center");
+            m_pShapeStyle.append(";mso-position-horizontal:center");
             break;
         case text::HoriOrientation::RIGHT:
-            m_pShapeStyle->append(";mso-position-horizontal:right");
+            m_pShapeStyle.append(";mso-position-horizontal:right");
             break;
         case text::HoriOrientation::INSIDE:
-            m_pShapeStyle->append(";mso-position-horizontal:inside");
+            m_pShapeStyle.append(";mso-position-horizontal:inside");
             break;
         case text::HoriOrientation::OUTSIDE:
-            m_pShapeStyle->append(";mso-position-horizontal:outside");
+            m_pShapeStyle.append(";mso-position-horizontal:outside");
             break;
         default:
         case text::HoriOrientation::NONE:
@@ -1083,15 +1081,15 @@ sal_Int32 VMLExport::StartShape()
     switch (m_eHRel)
     {
         case text::RelOrientation::PAGE_PRINT_AREA:
-            m_pShapeStyle->append(";mso-position-horizontal-relative:margin");
+            m_pShapeStyle.append(";mso-position-horizontal-relative:margin");
             break;
         case text::RelOrientation::PAGE_FRAME:
         case text::RelOrientation::PAGE_LEFT:
         case text::RelOrientation::PAGE_RIGHT:
-            m_pShapeStyle->append(";mso-position-horizontal-relative:page");
+            m_pShapeStyle.append(";mso-position-horizontal-relative:page");
             break;
         case text::RelOrientation::CHAR:
-            m_pShapeStyle->append(";mso-position-horizontal-relative:char");
+            m_pShapeStyle.append(";mso-position-horizontal-relative:char");
             break;
         default:
             break;
@@ -1102,16 +1100,16 @@ sal_Int32 VMLExport::StartShape()
         case text::VertOrientation::TOP:
         case text::VertOrientation::LINE_TOP:
         case text::VertOrientation::CHAR_TOP:
-            m_pShapeStyle->append(";mso-position-vertical:top");
+            m_pShapeStyle.append(";mso-position-vertical:top");
             break;
         case text::VertOrientation::CENTER:
         case text::VertOrientation::LINE_CENTER:
-            m_pShapeStyle->append(";mso-position-vertical:center");
+            m_pShapeStyle.append(";mso-position-vertical:center");
             break;
         case text::VertOrientation::BOTTOM:
         case text::VertOrientation::LINE_BOTTOM:
         case text::VertOrientation::CHAR_BOTTOM:
-            m_pShapeStyle->append(";mso-position-vertical:bottom");
+            m_pShapeStyle.append(";mso-position-vertical:bottom");
             break;
         default:
         case text::VertOrientation::NONE:
@@ -1120,17 +1118,17 @@ sal_Int32 VMLExport::StartShape()
     switch (m_eVRel)
     {
         case text::RelOrientation::PAGE_PRINT_AREA:
-            m_pShapeStyle->append(";mso-position-vertical-relative:margin");
+            m_pShapeStyle.append(";mso-position-vertical-relative:margin");
             break;
         case text::RelOrientation::PAGE_FRAME:
-            m_pShapeStyle->append(";mso-position-vertical-relative:page");
+            m_pShapeStyle.append(";mso-position-vertical-relative:page");
             break;
         default:
             break;
     }
 
     // add style
-    m_pShapeAttrList->add( XML_style, m_pShapeStyle->makeStringAndClear() );
+    m_pShapeAttrList->add( XML_style, m_pShapeStyle.makeStringAndClear() );
 
     OUString sAnchorId = lcl_getAnchorIdFromGrabBag(m_pSdrObject);
     if (!sAnchorId.isEmpty())


More information about the Libreoffice-commits mailing list