Kaydet (Commit) 0af2e9fa authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: manual memory management -> boost::optional in PropertyMap

Change-Id: Ie8f7ce11ab03d47835cfe224c775324dd79a5e7a
üst 780dd8c1
...@@ -432,7 +432,6 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) : ...@@ -432,7 +432,6 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) :
{ {
static sal_Int32 nNumber = 0; static sal_Int32 nNumber = 0;
nSectionNumber = nNumber++; nSectionNumber = nNumber++;
memset(&m_pBorderLines, 0x00, sizeof(m_pBorderLines));
for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder ) for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder )
{ {
m_nBorderDistances[ nBorder ] = -1; m_nBorderDistances[ nBorder ] = -1;
...@@ -471,8 +470,6 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) : ...@@ -471,8 +470,6 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) :
SectionPropertyMap::~SectionPropertyMap() SectionPropertyMap::~SectionPropertyMap()
{ {
for( sal_Int16 ePos = BORDER_LEFT; ePos <= BORDER_BOTTOM; ++ePos)
delete m_pBorderLines[ePos];
} }
...@@ -564,8 +561,7 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle( ...@@ -564,8 +561,7 @@ uno::Reference< beans::XPropertySet > SectionPropertyMap::GetPageStyle(
void SectionPropertyMap::SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const table::BorderLine2& rBorderLine, bool bShadow ) void SectionPropertyMap::SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const table::BorderLine2& rBorderLine, bool bShadow )
{ {
delete m_pBorderLines[ePos]; m_oBorderLines[ePos] = rBorderLine;
m_pBorderLines[ePos] = new table::BorderLine2( rBorderLine );
m_nBorderDistances[ePos] = nLineDistance; m_nBorderDistances[ePos] = nLineDistance;
m_bBorderShadows[ePos] = bShadow; m_bBorderShadows[ePos] = bShadow;
} }
...@@ -639,19 +635,19 @@ void SectionPropertyMap::ApplyBorderToPageStyles( ...@@ -639,19 +635,19 @@ void SectionPropertyMap::ApplyBorderToPageStyles(
for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder) for( sal_Int32 nBorder = 0; nBorder < 4; ++nBorder)
{ {
if( m_pBorderLines[nBorder] ) if( m_oBorderLines[nBorder] )
{ {
const OUString sBorderName = getPropertyName( aBorderIds[nBorder] ); const OUString sBorderName = getPropertyName( aBorderIds[nBorder] );
if (xFirst.is()) if (xFirst.is())
xFirst->setPropertyValue( sBorderName, uno::makeAny( *m_pBorderLines[nBorder] )); xFirst->setPropertyValue( sBorderName, uno::makeAny( *m_oBorderLines[nBorder] ));
if(xSecond.is()) if(xSecond.is())
xSecond->setPropertyValue( sBorderName, uno::makeAny( *m_pBorderLines[nBorder] )); xSecond->setPropertyValue( sBorderName, uno::makeAny( *m_oBorderLines[nBorder] ));
} }
if( m_nBorderDistances[nBorder] >= 0 ) if( m_nBorderDistances[nBorder] >= 0 )
{ {
sal_uInt32 nLineWidth = 0; sal_uInt32 nLineWidth = 0;
if (m_pBorderLines[nBorder]) if (m_oBorderLines[nBorder])
nLineWidth = m_pBorderLines[nBorder]->LineWidth; nLineWidth = m_oBorderLines[nBorder]->LineWidth;
if(xFirst.is()) if(xFirst.is())
SetBorderDistance( xFirst, aMarginIds[nBorder], aBorderDistanceIds[nBorder], SetBorderDistance( xFirst, aMarginIds[nBorder], aBorderDistanceIds[nBorder],
m_nBorderDistances[nBorder], nOffsetFrom, nLineWidth ); m_nBorderDistances[nBorder], nOffsetFrom, nLineWidth );
...@@ -663,7 +659,7 @@ void SectionPropertyMap::ApplyBorderToPageStyles( ...@@ -663,7 +659,7 @@ void SectionPropertyMap::ApplyBorderToPageStyles(
if (m_bBorderShadows[BORDER_RIGHT]) if (m_bBorderShadows[BORDER_RIGHT])
{ {
table::ShadowFormat aFormat = getShadowFromBorder(*m_pBorderLines[BORDER_RIGHT]); table::ShadowFormat aFormat = getShadowFromBorder(*m_oBorderLines[BORDER_RIGHT]);
if (xFirst.is()) if (xFirst.is())
xFirst->setPropertyValue(getPropertyName(PROP_SHADOW_FORMAT), uno::makeAny(aFormat)); xFirst->setPropertyValue(getPropertyName(PROP_SHADOW_FORMAT), uno::makeAny(aFormat));
if (xSecond.is()) if (xSecond.is())
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/uno/Any.h> #include <com/sun/star/uno/Any.h>
#include "PropertyIds.hxx" #include "PropertyIds.hxx"
#include <memory> #include <memory>
...@@ -190,7 +191,7 @@ class SectionPropertyMap : public PropertyMap ...@@ -190,7 +191,7 @@ class SectionPropertyMap : public PropertyMap
css::uno::Reference<css::beans::XPropertySet> m_aFirstPageStyle; css::uno::Reference<css::beans::XPropertySet> m_aFirstPageStyle;
css::uno::Reference<css::beans::XPropertySet> m_aFollowPageStyle; css::uno::Reference<css::beans::XPropertySet> m_aFollowPageStyle;
css::table::BorderLine2* m_pBorderLines[4]; boost::optional<css::table::BorderLine2> m_oBorderLines[4];
sal_Int32 m_nBorderDistances[4]; sal_Int32 m_nBorderDistances[4];
sal_Int32 m_nBorderParams; sal_Int32 m_nBorderParams;
bool m_bBorderShadows[4]; bool m_bBorderShadows[4];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment