[Libreoffice-commits] core.git: lotuswordpro/inc lotuswordpro/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Apr 3 10:39:13 UTC 2018


 lotuswordpro/inc/lwpfoundry.hxx                        |    2 
 lotuswordpro/inc/xfilter/xfdatestyle.hxx               |   40 +--
 lotuswordpro/inc/xfilter/xfstylecont.hxx               |    5 
 lotuswordpro/inc/xfilter/xfstylemanager.hxx            |    2 
 lotuswordpro/source/filter/lwparrowstyles.hxx          |   16 -
 lotuswordpro/source/filter/lwpbulletstylemgr.cxx       |    9 
 lotuswordpro/source/filter/lwpcelllayout.cxx           |    6 
 lotuswordpro/source/filter/lwpcharacterstyle.cxx       |    4 
 lotuswordpro/source/filter/lwpdrawobj.cxx              |   69 +++---
 lotuswordpro/source/filter/lwpfoundry.cxx              |    6 
 lotuswordpro/source/filter/lwpframelayout.cxx          |    4 
 lotuswordpro/source/filter/lwpfrib.cxx                 |   26 +-
 lotuswordpro/source/filter/lwpfribbreaks.cxx           |    8 
 lotuswordpro/source/filter/lwpfribframe.cxx            |    4 
 lotuswordpro/source/filter/lwpfribmark.cxx             |  190 ++++++++---------
 lotuswordpro/source/filter/lwpfribsection.cxx          |   10 
 lotuswordpro/source/filter/lwpfribtable.cxx            |    2 
 lotuswordpro/source/filter/lwpfribtext.cxx             |    8 
 lotuswordpro/source/filter/lwpgrfobj.cxx               |    6 
 lotuswordpro/source/filter/lwppagelayout.cxx           |    8 
 lotuswordpro/source/filter/lwppara.cxx                 |   18 -
 lotuswordpro/source/filter/lwppara1.cxx                |   16 -
 lotuswordpro/source/filter/lwpparastyle.cxx            |    2 
 lotuswordpro/source/filter/lwprowlayout.cxx            |    9 
 lotuswordpro/source/filter/lwpsilverbullet.cxx         |    2 
 lotuswordpro/source/filter/lwpstory.cxx                |    4 
 lotuswordpro/source/filter/lwptablelayout.cxx          |   12 -
 lotuswordpro/source/filter/lwptoc.cxx                  |    4 
 lotuswordpro/source/filter/lwpverdocument.cxx          |    4 
 lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx |    6 
 lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx     |    4 
 lotuswordpro/source/filter/xfilter/xfparastyle.cxx     |   12 -
 lotuswordpro/source/filter/xfilter/xfstylecont.cxx     |   31 --
 lotuswordpro/source/filter/xfilter/xfstylemanager.cxx  |   50 ++--
 34 files changed, 293 insertions(+), 306 deletions(-)

New commits:
commit 86e54f2d757fe300ba634cdcbf0ee8a589dbc2ae
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Apr 3 11:36:57 2018 +0200

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

diff --git a/lotuswordpro/inc/lwpfoundry.hxx b/lotuswordpro/inc/lwpfoundry.hxx
index 30b604b295fa..96c487c35c98 100644
--- a/lotuswordpro/inc/lwpfoundry.hxx
+++ b/lotuswordpro/inc/lwpfoundry.hxx
@@ -300,7 +300,7 @@ private:
     LwpStyleMap m_StyleList;
 public:
     void SetFoundry(LwpFoundry* pFoundry){m_pFoundry = pFoundry;}
-    void AddStyle(LwpObjectID styleObjID, IXFStyle* pStyle);
+    void AddStyle(LwpObjectID styleObjID, std::unique_ptr<IXFStyle> pStyle);
     IXFStyle* GetStyle(const LwpObjectID &styleObjID);
 };
 #endif
diff --git a/lotuswordpro/inc/xfilter/xfdatestyle.hxx b/lotuswordpro/inc/xfilter/xfdatestyle.hxx
index 6b1b2aa0223b..a292a8fdd5fc 100644
--- a/lotuswordpro/inc/xfilter/xfdatestyle.hxx
+++ b/lotuswordpro/inc/xfilter/xfdatestyle.hxx
@@ -122,83 +122,83 @@ inline void XFDatePart::SetTexture(bool bTexture)
 
 inline void XFDateStyle::AddYear( bool bLongFmt )
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateYear);
     part->SetLongFmt(bLongFmt);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddMonth( bool bLongFmt, bool bTexture  )
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateMonth);
     part->SetLongFmt(bLongFmt);
     part->SetTexture(bTexture);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddMonthDay( bool bLongFmt )
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateMonthDay);
     part->SetLongFmt(bLongFmt);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddWeekDay( bool bLongFmt )
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateWeekDay);
     part->SetLongFmt(bLongFmt);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddEra()
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateEra);
     part->SetLongFmt(false);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddText( const OUString& text )
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateText);
     part->SetText(text);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddHour( bool bLongFmt )
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateHour);
     part->SetLongFmt(bLongFmt);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddMinute( bool bLongFmt )
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateMinute);
     part->SetLongFmt(bLongFmt);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddSecond( bool bLongFmt )
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateSecond);
     part->SetLongFmt(bLongFmt);
     part->SetDecimalPos(0);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 inline void XFDateStyle::AddAmPm()
 {
-    XFDatePart  *part = new XFDatePart();
+    std::unique_ptr<XFDatePart> part(new XFDatePart());
     part->SetPartType(enumXFDateAmPm);
-    m_aParts.AddStyle(part);
+    m_aParts.AddStyle(std::move(part));
 }
 
 #endif
diff --git a/lotuswordpro/inc/xfilter/xfstylecont.hxx b/lotuswordpro/inc/xfilter/xfstylecont.hxx
index 12b6c751d3aa..15783b5d65fa 100644
--- a/lotuswordpro/inc/xfilter/xfstylecont.hxx
+++ b/lotuswordpro/inc/xfilter/xfstylecont.hxx
@@ -62,6 +62,7 @@
 
 #include <xfilter/xfglobal.hxx>
 #include <vector>
+#include <memory>
 
 class IXFStyle;
 
@@ -98,7 +99,7 @@ public:
      * @descr   Add style to container.
      *          If the same style has exist, then pStyle will be deleted, and the same style will be return.
      */
-    IXFStyleRet     AddStyle(IXFStyle *pStyle);
+    IXFStyleRet     AddStyle(std::unique_ptr<IXFStyle> pStyle);
 
     /**
      * @descr   Find the same style.
@@ -135,7 +136,7 @@ public:
 private:
     static void     ManageStyleFont(IXFStyle *pStyle);
 private:
-    std::vector<IXFStyle*>  m_aStyles;
+    std::vector<std::unique_ptr<IXFStyle>>  m_aStyles;
     OUString   m_strStyleNamePrefix;
 };
 
diff --git a/lotuswordpro/inc/xfilter/xfstylemanager.hxx b/lotuswordpro/inc/xfilter/xfstylemanager.hxx
index fa5649b6492f..f9e9d9411055 100644
--- a/lotuswordpro/inc/xfilter/xfstylemanager.hxx
+++ b/lotuswordpro/inc/xfilter/xfstylemanager.hxx
@@ -95,7 +95,7 @@ public:
 
     void        AddFontDecl(XFFontDecl const & aFontDecl);
 
-    IXFStyleRet AddStyle(IXFStyle *pStyle);
+    IXFStyleRet AddStyle(std::unique_ptr<IXFStyle> pStyle);
 
     IXFStyle*   FindStyle(const OUString& name);
 
diff --git a/lotuswordpro/source/filter/lwparrowstyles.hxx b/lotuswordpro/source/filter/lwparrowstyles.hxx
index c6057e9a982a..16d4c9714ed7 100644
--- a/lotuswordpro/source/filter/lwparrowstyles.hxx
+++ b/lotuswordpro/source/filter/lwparrowstyles.hxx
@@ -71,32 +71,32 @@ void    RegisteArrowStyles()
     if (!pXFStyleManager)
         return;
     //reversed arrow:
-    XFArrowStyle *pArrowStyle100 = new XFArrowStyle();
+    std::unique_ptr<XFArrowStyle> pArrowStyle100(new XFArrowStyle());
     pArrowStyle100->SetArrowName( "arrow100" );
     pArrowStyle100->SetViewbox("0 0 140 200");
     pArrowStyle100->SetSVGPath("M0 180 L70 0 L140 180 L120 180 L70 30 L20 180 L0 180");
-    pXFStyleManager->AddStyle(pArrowStyle100);
+    pXFStyleManager->AddStyle(std::move(pArrowStyle100));
 
     //reversed arrow:
-    XFArrowStyle *pArrowStyle1 = new XFArrowStyle();
+    std::unique_ptr<XFArrowStyle> pArrowStyle1(new XFArrowStyle());
     pArrowStyle1->SetArrowName( "reverse arrow" );
     pArrowStyle1->SetViewbox("0 0 140 200");
     pArrowStyle1->SetSVGPath("M0 0 L70 200 L140 0");
-    pXFStyleManager->AddStyle(pArrowStyle1);
+    pXFStyleManager->AddStyle(std::move(pArrowStyle1));
 
     //reversed concave arrow
-    XFArrowStyle *pArrowStyle2 = new XFArrowStyle();
+    std::unique_ptr<XFArrowStyle> pArrowStyle2(new XFArrowStyle());
     pArrowStyle2->SetArrowName( "reverse concave arrow" );
     pArrowStyle2->SetViewbox("0 0 140 200");
     pArrowStyle2->SetSVGPath("M0 0 L80 200 L160 0 L80 100");
-    pXFStyleManager->AddStyle(pArrowStyle2);
+    pXFStyleManager->AddStyle(std::move(pArrowStyle2));
 
     //reversed line arrow
-    XFArrowStyle *pArrowStyle3 = new XFArrowStyle();
+    std::unique_ptr<XFArrowStyle> pArrowStyle3(new XFArrowStyle());
     pArrowStyle3->SetArrowName( "reverse line arrow" );
     pArrowStyle3->SetViewbox("0 0 140 200");
     pArrowStyle3->SetSVGPath("M0 0 L70 200 L140 0L110 0 L70 160 L20 0 L0 0");
-    pXFStyleManager->AddStyle(pArrowStyle3);
+    pXFStyleManager->AddStyle(std::move(pArrowStyle3));
 }
 
 #endif
diff --git a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
index 40aef7d0618b..325114cdb8ee 100644
--- a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
+++ b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx
@@ -152,7 +152,7 @@ OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverrid
         eAlign = enumXFAlignEnd;
     }
 
-    XFListStyle* pListStyle = new XFListStyle();
+    std::unique_ptr<XFListStyle> pListStyle(new XFListStyle());
     XFStyleManager* pXFStyleMgr = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
 
     if (!bIsNumbering)
@@ -174,7 +174,7 @@ OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverrid
             }
         }
 
-        aStyleName = pXFStyleMgr->AddStyle(pListStyle).m_pStyle->GetStyleName();
+        aStyleName = pXFStyleMgr->AddStyle(std::move(pListStyle)).m_pStyle->GetStyleName();
     }
     else
     {
@@ -230,11 +230,8 @@ OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverrid
 
                 pListStyle->SetListPosition(nPos, 0.0, 0.635, 0.0);
             }
-            aStyleName = pXFStyleMgr->AddStyle(pListStyle).m_pStyle->GetStyleName();
+            aStyleName = pXFStyleMgr->AddStyle(std::move(pListStyle)).m_pStyle->GetStyleName();
         }
-        else
-            delete pListStyle;
-
     }
 
     m_vStyleNameList.push_back(aStyleName);
diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index db9279df6aa0..ad80d4aa4048 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -285,7 +285,7 @@ void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle)
         if (pStyle)
         {
             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-            m_NumfmtName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+            m_NumfmtName = pXFStyleManager->AddStyle(std::unique_ptr<XFStyle>(pStyle)).m_pStyle->GetStyleName();
             pCellStyle->SetDataStyle(m_NumfmtName);
         }
     }
@@ -555,7 +555,7 @@ void LwpCellLayout::RegisterDefaultCell()
             }
             xCellStyle->SetBorders(xBorders.release());
         }
-        m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(xCellStyle.release()).m_pStyle->GetStyleName();
+        m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(std::move(xCellStyle)).m_pStyle->GetStyleName();
     }
 }
 /**
@@ -587,7 +587,7 @@ void LwpCellLayout::RegisterStyle()
     xCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(xCellStyle.release()).m_pStyle->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(std::move(xCellStyle)).m_pStyle->GetStyleName();
 
     // content object register styles
     rtl::Reference<LwpObject> pObj = m_Content.obj();
diff --git a/lotuswordpro/source/filter/lwpcharacterstyle.cxx b/lotuswordpro/source/filter/lwpcharacterstyle.cxx
index febc7585f7c4..5e3c7cdba25b 100644
--- a/lotuswordpro/source/filter/lwpcharacterstyle.cxx
+++ b/lotuswordpro/source/filter/lwpcharacterstyle.cxx
@@ -145,7 +145,7 @@ void LwpTextStyle::RegisterStyle()
         return;
     }
 
-    XFTextStyle* pStyle = new XFTextStyle();
+    std::unique_ptr<XFTextStyle> pStyle(new XFTextStyle());
 
     //Set name
     OUString styleName = GetName().str();
@@ -160,7 +160,7 @@ void LwpTextStyle::RegisterStyle()
 
     //Add style
     LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
-    pStyleMgr->AddStyle(GetObjectID(), pStyle);
+    pStyleMgr->AddStyle(GetObjectID(), std::move(pStyle));
 
 }
 
diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx
index 1fa5233a4ed0..f2c226a7d767 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -437,17 +437,16 @@ void LwpDrawLine::Read()
 
 OUString LwpDrawLine::RegisterStyle()
 {
-    XFDrawStyle* pStyle = new XFDrawStyle();
+    std::unique_ptr<XFDrawStyle> pStyle( new XFDrawStyle() );
 
     // set line style
-    SetLineStyle(pStyle, m_aLineRec.nLineWidth, m_aLineRec.nLineStyle, m_aLineRec.aPenColor);
+    SetLineStyle(pStyle.get(), m_aLineRec.nLineWidth, m_aLineRec.nLineStyle, m_aLineRec.aPenColor);
 
     // set arrow head
-    SetArrowHead(pStyle, m_aLineRec.nLineEnd, m_aLineRec.nLineWidth);
+    SetArrowHead(pStyle.get(), m_aLineRec.nLineEnd, m_aLineRec.nLineWidth);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
-
+    return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawLine::CreateDrawObj(const OUString& rStyleName )
@@ -514,17 +513,17 @@ void LwpDrawPolyLine::Read()
 
 OUString LwpDrawPolyLine::RegisterStyle()
 {
-    XFDrawStyle* pStyle = new XFDrawStyle();
+    std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
 
     // set line style
-    SetLineStyle(pStyle, m_aPolyLineRec.nLineWidth, m_aPolyLineRec.nLineStyle,
+    SetLineStyle(pStyle.get(), m_aPolyLineRec.nLineWidth, m_aPolyLineRec.nLineStyle,
         m_aPolyLineRec.aPenColor);
 
     // set arrow head
-    SetArrowHead(pStyle, m_aPolyLineRec.nLineEnd, m_aPolyLineRec.nLineWidth);
+    SetArrowHead(pStyle.get(), m_aPolyLineRec.nLineEnd, m_aPolyLineRec.nLineWidth);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawPolyLine::CreateDrawObj(const OUString& rStyleName )
@@ -594,17 +593,17 @@ void LwpDrawPolygon::Read()
 
 OUString LwpDrawPolygon::RegisterStyle()
 {
-    XFDrawStyle* pStyle = new XFDrawStyle();
+    std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
 
     // set line style
-    SetLineStyle(pStyle, m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
+    SetLineStyle(pStyle.get(), m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
         m_aClosedObjStyleRec.aPenColor);
 
     // set fill style
-    SetFillStyle(pStyle);
+    SetFillStyle(pStyle.get());
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawPolygon::CreateDrawObj(const OUString& rStyleName)
@@ -674,17 +673,17 @@ void LwpDrawRectangle::Read()
 
 OUString LwpDrawRectangle::RegisterStyle()
 {
-    XFDrawStyle* pStyle = new XFDrawStyle();
+    std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
 
     // set line style
-    SetLineStyle(pStyle, m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
+    SetLineStyle(pStyle.get(), m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
         m_aClosedObjStyleRec.aPenColor);
 
     // set fill style
-    SetFillStyle(pStyle);
+    SetFillStyle(pStyle.get());
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawRectangle::CreateDrawObj(const OUString& rStyleName)
@@ -833,17 +832,17 @@ void LwpDrawEllipse::Read()
 
 OUString LwpDrawEllipse::RegisterStyle()
 {
-    XFDrawStyle* pStyle = new XFDrawStyle();
+    std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
 
     // set line style
-    SetLineStyle(pStyle, m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
+    SetLineStyle(pStyle.get(), m_aClosedObjStyleRec.nLineWidth, m_aClosedObjStyleRec.nLineStyle,
         m_aClosedObjStyleRec.aPenColor);
 
     // set fill style
-    SetFillStyle(pStyle);
+    SetFillStyle(pStyle.get());
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawEllipse::CreateDrawObj(const OUString& rStyleName )
@@ -912,17 +911,17 @@ void LwpDrawArc::Read()
 
 OUString LwpDrawArc::RegisterStyle()
 {
-    XFDrawStyle* pStyle = new XFDrawStyle();
+    std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
 
     // set line style
-    SetLineStyle(pStyle, m_aArcRec.nLineWidth, m_aArcRec.nLineStyle,
+    SetLineStyle(pStyle.get(), m_aArcRec.nLineWidth, m_aArcRec.nLineStyle,
         m_aArcRec.aPenColor);
 
     // set arrow head
-    SetArrowHead(pStyle, m_aArcRec.nLineEnd, m_aArcRec.nLineWidth);
+    SetArrowHead(pStyle.get(), m_aArcRec.nLineEnd, m_aArcRec.nLineWidth);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawArc::CreateDrawObj(const OUString& rStyleName )
@@ -1056,7 +1055,7 @@ void LwpDrawTextBox::Read()
 
 OUString LwpDrawTextBox::RegisterStyle()
 {
-    XFParaStyle* pStyle = new XFParaStyle();
+    std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
 
     // font style
     // the pFont need to be deleted myself?
@@ -1071,7 +1070,7 @@ OUString LwpDrawTextBox::RegisterStyle()
     pStyle->SetFont(pFont);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawTextBox::CreateDrawObj(const OUString& rStyleName )
@@ -1097,10 +1096,10 @@ XFFrame* LwpDrawTextBox::CreateDrawObj(const OUString& rStyleName )
     pTextBox->Add(pXFPara);
     SetPosition(pTextBox);
 
-    XFTextBoxStyle* pBoxStyle = new XFTextBoxStyle();
+    std::unique_ptr<XFTextBoxStyle> pBoxStyle(new XFTextBoxStyle());
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    OUString sName = pXFStyleManager->AddStyle(pBoxStyle).m_pStyle->GetStyleName();
+    OUString sName = pXFStyleManager->AddStyle(std::move(pBoxStyle)).m_pStyle->GetStyleName();
     pTextBox->SetStyleName(sName);
 
     //todo: add the interface for rotating textbox
@@ -1260,7 +1259,7 @@ void LwpDrawTextArt::Read()
 
 OUString LwpDrawTextArt::RegisterStyle()
 {
-    XFParaStyle* pStyle = new XFParaStyle();
+    std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
 
     // font style
     // the pFont need to be deleted myself?
@@ -1275,13 +1274,13 @@ OUString LwpDrawTextArt::RegisterStyle()
     pStyle->SetFont(pFont);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawTextArt::CreateDrawObj(const OUString& rStyleName)
 {
     XFFrame* pRetObj = nullptr;
-    XFDrawStyle* pStyle = new XFDrawStyle();
+    std::unique_ptr<XFDrawStyle> pStyle(new XFDrawStyle());
 
     pRetObj = new XFDrawPath();
     XFDrawPath* pFWPath = static_cast<XFDrawPath*>(pRetObj);
@@ -1307,7 +1306,7 @@ XFFrame* LwpDrawTextArt::CreateDrawObj(const OUString& rStyleName)
     pRetObj->Add(pXFPara);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pRetObj->SetStyleName(pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName());
+    pRetObj->SetStyleName(pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName());
 
     return pRetObj;
 }
@@ -1463,12 +1462,12 @@ void LwpDrawBitmap::Read()
 
 OUString LwpDrawBitmap::RegisterStyle()
 {
-    XFImageStyle* pBmpStyle = new XFImageStyle();
+    std::unique_ptr<XFImageStyle> pBmpStyle(new XFImageStyle());
     pBmpStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelFrame);
     pBmpStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    return pXFStyleManager->AddStyle(pBmpStyle).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(pBmpStyle)).m_pStyle->GetStyleName();
 }
 
 XFFrame* LwpDrawBitmap::CreateDrawObj(const OUString& rStyleName)
diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx
index 5f19f8269e51..2f56998ee4b7 100644
--- a/lotuswordpro/source/filter/lwpfoundry.cxx
+++ b/lotuswordpro/source/filter/lwpfoundry.cxx
@@ -506,12 +506,12 @@ VO_PARASTYLE/VO_CHARACTERSTYLE call this method to add its created style to XFSt
 Prerequisite: pStyle has been created and all properties has been set to it.
 Return the XFStyle* added by XFStyleManager
 */
-void LwpStyleManager::AddStyle(LwpObjectID styleObjID, IXFStyle* pStyle)
+void LwpStyleManager::AddStyle(LwpObjectID styleObjID, std::unique_ptr<IXFStyle> pNewStyle)
 {
-    assert(pStyle);
+    assert(pNewStyle);
     //pStyle may change if same style is found in XFStyleManager
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pStyle = pXFStyleManager->AddStyle(pStyle).m_pStyle;
+    auto pStyle = pXFStyleManager->AddStyle(std::move(pNewStyle)).m_pStyle;
     m_StyleList.emplace(styleObjID, pStyle);
 }
 
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index 419e790cb462..0d4119824041 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -100,7 +100,7 @@ void LwpFrame::RegisterStyle(std::unique_ptr<XFFrameStyle>& rFrameStyle)
 
     rFrameStyle->SetStyleName(m_pLayout->GetName().str());
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(rFrameStyle.release()).m_pStyle->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(std::move(rFrameStyle)).m_pStyle->GetStyleName();
     m_pLayout->SetStyleName(m_StyleName);
 }
 
@@ -1271,7 +1271,7 @@ void LwpRubyLayout::RegisterStyle()
     xRubyStyle->SetPosition(eType);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    OUString rubyStyle = pXFStyleManager->AddStyle(xRubyStyle.release()).m_pStyle->GetStyleName();
+    OUString rubyStyle = pXFStyleManager->AddStyle(std::move(xRubyStyle)).m_pStyle->GetStyleName();
     pMarker->SetRubyStyleName(rubyStyle);
 
     LwpStory* pStory = GetContentStory();
diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx
index f1f74a25420c..0da28697af3e 100644
--- a/lotuswordpro/source/filter/lwpfrib.cxx
+++ b/lotuswordpro/source/filter/lwpfrib.cxx
@@ -261,13 +261,13 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
             pCharStyle = dynamic_cast<LwpCharacterStyle*>(m_pModifiers->CharStyleID.obj().get());
         if (pCharStyle)
         {
-            pStyle = new XFTextStyle();
-            *pStyle = *pNamedStyle;
+            std::unique_ptr<XFTextStyle> pNewStyle(new XFTextStyle());
+            *pNewStyle = *pNamedStyle;
 
-            pStyle->SetStyleName("");
+            pNewStyle->SetStyleName("");
             pFont = pFoundry->GetFontManger().CreateOverrideFont(pCharStyle->GetFinalFontID(),m_pModifiers->FontID);
-            pStyle->SetFont(pFont);
-            IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(pStyle);
+            pNewStyle->SetFont(pFont);
+            IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(std::move(pNewStyle));
             m_StyleName = aNewStyle.m_pStyle->GetStyleName();
             pStyle = dynamic_cast<XFTextStyle*>(aNewStyle.m_pStyle);
             if (aNewStyle.m_bOrigDeleted)
@@ -280,10 +280,10 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
     {
         if (m_pModifiers->FontID && pFoundry)
         {
-            pStyle = new XFTextStyle();
+            std::unique_ptr<XFTextStyle> pNewStyle(new XFTextStyle());
             pFont = pFoundry->GetFontManger().CreateFont(m_pModifiers->FontID);
-            pStyle->SetFont(pFont);
-            IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(pStyle);
+            pNewStyle->SetFont(pFont);
+            IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(std::move(pNewStyle));
             m_StyleName = aNewStyle.m_pStyle->GetStyleName();
             pStyle = dynamic_cast<XFTextStyle*>(aNewStyle.m_pStyle);
             if (aNewStyle.m_bOrigDeleted)
@@ -298,21 +298,21 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
             pStyle->GetFont()->SetBackColor(aColor);
         else //register a new style
         {
-            pStyle = new XFTextStyle();
+            std::unique_ptr<XFTextStyle> pNewStyle(new XFTextStyle());
 
             if (!m_StyleName.isEmpty())
             {
                 XFTextStyle* pOldStyle = pXFStyleManager->FindTextStyle(m_StyleName);
-                *pStyle = *pOldStyle;
-                pStyle->GetFont()->SetBackColor(aColor);
+                *pNewStyle = *pOldStyle;
+                pNewStyle->GetFont()->SetBackColor(aColor);
             }
             else
             {
                 pFont = new XFFont;
                 pFont->SetBackColor(aColor);
-                pStyle->SetFont(pFont);
+                pNewStyle->SetFont(pFont);
             }
-            m_StyleName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+            m_StyleName = pXFStyleManager->AddStyle(std::move(pNewStyle)).m_pStyle->GetStyleName();
         }
     }
 }
diff --git a/lotuswordpro/source/filter/lwpfribbreaks.cxx b/lotuswordpro/source/filter/lwpfribbreaks.cxx
index 540bf2f78fa0..6f4e9b4f6beb 100644
--- a/lotuswordpro/source/filter/lwpfribbreaks.cxx
+++ b/lotuswordpro/source/filter/lwpfribbreaks.cxx
@@ -73,7 +73,7 @@ void LwpFribColumnBreak::RegisterBreakStyle(LwpPara * pPara)
     if (pBaseStyle == nullptr) return;
 //    m_StyleName = pBaseStyle->GetStyleName();
 
-    XFParaStyle* pOverStyle = new XFParaStyle;
+    std::unique_ptr<XFParaStyle> pOverStyle( new XFParaStyle );
     *pOverStyle = *pBaseStyle;
     pOverStyle->SetStyleName("");
 
@@ -96,7 +96,7 @@ void LwpFribColumnBreak::RegisterBreakStyle(LwpPara * pPara)
             pOverStyle->SetBreaks(enumXFBreakBefColumn);
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(std::move(pOverStyle)).m_pStyle->GetStyleName();
 }
 
 LwpFribPageBreak::LwpFribPageBreak( LwpPara* pPara )
@@ -126,7 +126,7 @@ void LwpFribPageBreak::RegisterBreakStyle(LwpPara* pPara)
         return;
     }
 
-    XFParaStyle* pOverStyle = new XFParaStyle;
+    std::unique_ptr<XFParaStyle> pOverStyle(new XFParaStyle);
     *pOverStyle = *pBaseStyle;
     pOverStyle->SetStyleName("");
     pOverStyle->SetMasterPage(pBaseStyle->GetMasterPage());
@@ -142,7 +142,7 @@ void LwpFribPageBreak::RegisterBreakStyle(LwpPara* pPara)
         pOverStyle->SetBreaks(enumXFBreakBefPage);
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(std::move(pOverStyle)).m_pStyle->GetStyleName();
 }
 
 void LwpFribPageBreak::ParseLayout()
diff --git a/lotuswordpro/source/filter/lwpfribframe.cxx b/lotuswordpro/source/filter/lwpfribframe.cxx
index 5b44dbd5aefd..1eb167766a1d 100644
--- a/lotuswordpro/source/filter/lwpfribframe.cxx
+++ b/lotuswordpro/source/filter/lwpfribframe.cxx
@@ -114,10 +114,10 @@ void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry)
                 m_StyleName = pOldStyle->GetStyleName();
             else
             {
-                XFParaStyle* pParaStyle = new XFParaStyle;
+                std::unique_ptr<XFParaStyle> pParaStyle(new XFParaStyle);
                 *pParaStyle = *pOldStyle;
                 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-                m_StyleName = pXFStyleManager->AddStyle(pParaStyle).m_pStyle->GetStyleName();
+                m_StyleName = pXFStyleManager->AddStyle(std::move(pParaStyle)).m_pStyle->GetStyleName();
             }
         }
         //remember the current paragraph font size which will be used in parsing frame
diff --git a/lotuswordpro/source/filter/lwpfribmark.cxx b/lotuswordpro/source/filter/lwpfribmark.cxx
index fb5fe1e3fcac..307b3e6f0df9 100644
--- a/lotuswordpro/source/filter/lwpfribmark.cxx
+++ b/lotuswordpro/source/filter/lwpfribmark.cxx
@@ -380,17 +380,17 @@ void LwpFribField::RegisterTimeField(LwpFieldMark* pFieldMark)
 
 void LwpFribField::RegisterTotalTimeStyle()
 {
-    XFTimeStyle* pTimeStyle = new XFTimeStyle;//use the default format
+    std::unique_ptr<XFTimeStyle> pTimeStyle(new XFTimeStyle);//use the default format
     pTimeStyle->SetTruncate(false);
     pTimeStyle->AddMinute();
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName();
+    m_TimeStyle = pXFStyleManager->AddStyle(std::move(pTimeStyle)).m_pStyle->GetStyleName();
 }
 
 void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
 {
-    XFDateStyle* pDateStyle = nullptr;
-    XFTimeStyle* pTimeStyle = nullptr;
+    std::unique_ptr<XFDateStyle> pDateStyle;
+    std::unique_ptr<XFTimeStyle> pTimeStyle;
 //DATE
     if (sFormula.getLength()<2)
         return;
@@ -398,15 +398,15 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
     {
         if (sFormula == "%FLSystemShortDate")
         {
-            pDateStyle = LwpTools::GetSystemDateStyle(false);
+            pDateStyle.reset( LwpTools::GetSystemDateStyle(false) );
         }
         else if (sFormula == "%FLSystemLongDate")
         {
-            pDateStyle = LwpTools::GetSystemDateStyle(true);
+            pDateStyle.reset( LwpTools::GetSystemDateStyle(true) );
         }
         else if (sFormula == "%FLISODate1" || sFormula == "%FLYYYY/MM/DD" )
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear();
             pDateStyle->AddText("/");
             pDateStyle->AddMonth();
@@ -415,7 +415,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLISODate2" || sFormula == "%FLYYYY/MM/DD HH:mm:SS" )
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear();
             pDateStyle->AddText("/");
             pDateStyle->AddMonth();
@@ -430,7 +430,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLM/D/YY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false);
             pDateStyle->AddText("/");
             pDateStyle->AddMonthDay(false);
@@ -439,7 +439,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLMonth D, YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(true,true);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonthDay(false);
@@ -448,7 +448,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLWeekday, Month D, YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonth(true,true);
@@ -459,7 +459,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLMn D, YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false,true);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonthDay(false);
@@ -468,7 +468,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLWday, Mn D, YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay(false);
             pDateStyle->AddText(", ");
             pDateStyle->AddMonth(false,true);
@@ -479,14 +479,14 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLMn D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false,true);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonthDay(false);
         }
         else if (sFormula == "%FLWeekday, Mn D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonth(false,true);
@@ -495,7 +495,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLMn D, YY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false,true);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonthDay(false);
@@ -504,69 +504,69 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLM/D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false);
             pDateStyle->AddText("/");
             pDateStyle->AddMonthDay(false);
         }
         else if (sFormula == "%FLM/YY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false);
             pDateStyle->AddText("/");
             pDateStyle->AddYear(false);
         }
         else if (sFormula == "%FLMn YY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false,true);
             pDateStyle->AddText(" ");
             pDateStyle->AddYear(false);
         }
         else if (sFormula == "%FLWeekday")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
         }
         else if (sFormula == "%FLWday")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay(false);
         }
         else if (sFormula == "%FLMonth")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(true,true);
         }
         else if (sFormula == "%FLMn")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false,true);
         }
         else if (sFormula == "%FLD")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
         }
         else if (sFormula == "%FLM")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false);
         }
         else if (sFormula == "%FLYYYY" )
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear();
         }
         else if (sFormula == "%FLYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear(false);
         }
         //chinese version begin
         else if (sFormula == "%FLYY/M/D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear(false);
             pDateStyle->AddText("-");
             pDateStyle->AddMonth(false);
@@ -575,7 +575,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if(sFormula == "%FLYYYY Month D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear();
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(true,true);
@@ -584,7 +584,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if(sFormula == "%FLWeekday, YYYY Month D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(",");
             pDateStyle->AddYear();
@@ -595,7 +595,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if(sFormula == "%FLYYYY Mn D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear();
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(false,true);
@@ -604,7 +604,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if(sFormula == "%FLWday, YYYY Mn D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay(false);
             pDateStyle->AddText(",");
             pDateStyle->AddYear();
@@ -616,7 +616,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         //next 2 are the same with english version
         else if (sFormula == "%FLYY Mn D")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear(false);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(false,true);
@@ -625,21 +625,21 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLYY/M")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false);
             pDateStyle->AddText("-");
             pDateStyle->AddMonth(false);
         }
         else if (sFormula == "%FLYY Mn")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(false,true);
         }
         else if (sFormula == "%FLeeeeoa" || sFormula == "%FLffffooaa" || sFormula == "%FLEEEEOA")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             OUString sText;
             pDateStyle->AddYear();
             sText = OUString(u'\x5e74');
@@ -653,7 +653,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLoa" || sFormula == "%FLooaa" || sFormula == "%FLOA" )
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             OUString sText;
             pDateStyle->AddMonth(false);
             sText = OUString(u'\x6708');
@@ -664,7 +664,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLYYYY/M/D" || sFormula == "%FLGGGG/od/ad")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear();
             pDateStyle->AddText("-");
             pDateStyle->AddMonth(false);
@@ -673,7 +673,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLYY.M.D" )
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear(false);
             pDateStyle->AddText(".");
             pDateStyle->AddMonth(false);
@@ -684,7 +684,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         //other version begin
         else if (sFormula == "%FLWeekday, Month DD, YYYY" )
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonth(true,true);
@@ -695,7 +695,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLYYYY/MM/DD" )
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonth(true,true);
@@ -706,7 +706,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLD/M/YY" )
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText("/");
             pDateStyle->AddMonth(false);
@@ -715,7 +715,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLD Month YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(true,true);
@@ -724,7 +724,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLDD Month YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay();
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(true,true);
@@ -733,7 +733,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLWeekday, D Month YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonthDay(false);
@@ -744,7 +744,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLWeekday, DD Month YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonthDay();
@@ -755,7 +755,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLD Mn YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(false,true);
@@ -764,7 +764,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLWday, D Mn YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay(false);
             pDateStyle->AddText(", ");
             pDateStyle->AddMonthDay(false);
@@ -775,7 +775,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLWday, DD Mn YYYY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay(false);
             pDateStyle->AddText(", ");
             pDateStyle->AddMonthDay();
@@ -786,21 +786,21 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLD Mn")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(false,true);
         }
         else if (sFormula == "%FLDD Mn")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay();
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(false,true);
         }
         else if (sFormula == "%FLWeekday, D Mn")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonthDay(false);
@@ -809,7 +809,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLWeekday, DD Mn")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonthDay();
@@ -818,7 +818,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLD Mn YY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(false,true);
@@ -827,7 +827,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLDD Mn YY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay();
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(false,true);
@@ -836,21 +836,21 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLD/M")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText("/");
             pDateStyle->AddMonth(false);
         }
         else if (sFormula == "%FLDD/MM")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay();
             pDateStyle->AddText("/");
             pDateStyle->AddMonth();
         }
         else if(sFormula == "%FLDD/MM/YY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay();
             pDateStyle->AddText("/");
             pDateStyle->AddMonth();
@@ -859,7 +859,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLMM/YY")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth();
             pDateStyle->AddText("/");
             pDateStyle->AddYear(false);
@@ -868,11 +868,11 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
     //TIME
         else if (sFormula == "%FLSystemTime")
         {
-            pTimeStyle = LwpTools::GetSystemTimeStyle();
+            pTimeStyle.reset(LwpTools::GetSystemTimeStyle());
         }
         else if (sFormula == "%FLISOTime1" || sFormula == "%FLH:mm:SS")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour();
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -881,7 +881,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLH:mm ampm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour(false);
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -890,14 +890,14 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLH:mm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour(false);
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
         }
         else if (sFormula == "%FLH:mm:SS ampm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour(false);
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -908,7 +908,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLH:mm:SS")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour(false);
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -917,36 +917,36 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLH ampm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour(false);
             pTimeStyle->AddText(" ");
             pTimeStyle->SetAmPm(true);
         }
         else if (sFormula == "%FLH")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour(false);
         }
         else if (sFormula == "%FLmm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddMinute();
         }
         else if (sFormula == "%FLSS")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddSecond();
         }
         else if (sFormula == "%FLampm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->SetAmPm(true);
         }
         //chinese version begin
         else     if (sFormula == "%FLjF" || sFormula == "%FLJFF"
             || sFormula == "%FLjjF" || sFormula == "%FLJJFF " )
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour(false);
             OUString sText;
             sText = OUString(u'\x70b9');
@@ -957,7 +957,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLjjjF" || sFormula == "%FLJJJFF" )
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->SetAmPm(true);
             pTimeStyle->AddHour(false);
             OUString sText;
@@ -971,7 +971,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         //other version begin
         else if (sFormula == "%FLHH:mm ampm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour();
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -980,14 +980,14 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLHH ampm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour();
             pTimeStyle->AddText(" ");
             pTimeStyle->SetAmPm(true);
         }
         else if (sFormula == "%FLHH:mm:SS ampm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour();
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -998,14 +998,14 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%FLHH:mm")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour();
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
         }
         else if (sFormula == "%FLHH:mm:SS")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour();
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -1018,11 +1018,11 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
     {
         if (sFormula == "%Da")
         {
-            pDateStyle = LwpTools::GetSystemDateStyle(false);
+            pDateStyle.reset(LwpTools::GetSystemDateStyle(false));
         }
         else if (sFormula == "%DB" || sFormula == "%Db")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(true,true);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonthDay(false);
@@ -1031,7 +1031,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%Dc" || sFormula == "%DC")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(true,true);
@@ -1040,7 +1040,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%Dd" || sFormula == "%DD")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(", ");
             pDateStyle->AddMonth(true,true);
@@ -1051,14 +1051,14 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%DE" || sFormula == "%De")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(true,true);
             pDateStyle->AddText(" ");
             pDateStyle->AddMonthDay(false);
         }
         else if (sFormula == "%Df" || sFormula == "%DF")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddWeekDay();
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(true,true);
@@ -1067,14 +1067,14 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%Dg")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false);
             pDateStyle->AddText("/");
             pDateStyle->AddMonthDay(false);
         }
         else if (sFormula == "%Dh")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(false);
             pDateStyle->AddText("/");
             pDateStyle->AddMonthDay(false);
@@ -1083,14 +1083,14 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%Di" || sFormula == "%DI")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText(".");
             pDateStyle->AddMonth(true,true);
         }
         else if (sFormula == "%Dj" || sFormula == "%DJ")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay(false);
             pDateStyle->AddText(".");
             pDateStyle->AddMonth(true,true);
@@ -1099,7 +1099,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%Dk" || sFormula == "%DK")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddYear();
             pDateStyle->AddText(" ");
             pDateStyle->AddMonth(true,true);
@@ -1108,14 +1108,14 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         }
         else if (sFormula == "%DL" || sFormula == "%Dl")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonth(true,true);
             pDateStyle->AddText(",");
             pDateStyle->AddYear();
         }
         else if (sFormula == "%Dm")
         {
-            pDateStyle = new XFDateStyle;
+            pDateStyle.reset(new XFDateStyle);
             pDateStyle->AddMonthDay();
             pDateStyle->AddText("/");
             pDateStyle->AddMonth();
@@ -1127,7 +1127,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
     {
         if (sFormula == "%T1")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour();
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -1135,7 +1135,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         else if (sFormula == "%T2" || sFormula == "%T6"
          || sFormula == "%T4" || sFormula == "%T8" )
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour(false);
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -1145,7 +1145,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
         else if (sFormula == "%T3" || sFormula == "%T7"
          || sFormula == "%T5" || sFormula == "%T9")
         {
-            pTimeStyle = new XFTimeStyle;
+            pTimeStyle.reset(new XFTimeStyle);
             pTimeStyle->AddHour();
             pTimeStyle->AddText(":");
             pTimeStyle->AddMinute();
@@ -1155,9 +1155,9 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
     if (pDateStyle)
-        m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle).m_pStyle->GetStyleName();
+        m_TimeStyle = pXFStyleManager->AddStyle(std::move(pDateStyle)).m_pStyle->GetStyleName();
     if (pTimeStyle)
-        m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName();
+        m_TimeStyle = pXFStyleManager->AddStyle(std::move(pTimeStyle)).m_pStyle->GetStyleName();
 }
 
 void LwpFribField::CheckFieldType(LwpFieldMark* pFieldMark)
diff --git a/lotuswordpro/source/filter/lwpfribsection.cxx b/lotuswordpro/source/filter/lwpfribsection.cxx
index 153e5cf373ee..95bd07ca1644 100644
--- a/lotuswordpro/source/filter/lwpfribsection.cxx
+++ b/lotuswordpro/source/filter/lwpfribsection.cxx
@@ -302,11 +302,11 @@ void LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
     m_pPara->RegisterTabStyle(xOverStyle.get());
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(xOverStyle.release()).m_pStyle->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
     //register section style here
     if(m_bNewSection)
     {
-        XFSectionStyle* pSectStyle= new XFSectionStyle();
+        std::unique_ptr<XFSectionStyle> pSectStyle(new XFSectionStyle());
         //set margin
         pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
         LwpPageLayout* pCurrentLayout = pStory ? pStory->GetCurrentLayout() : nullptr;
@@ -327,7 +327,7 @@ void LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
                 pSectStyle->SetColumns(pColumns);
             }
         //}
-        m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle).m_pStyle->GetStyleName();
+        m_SectionStyleName = pXFStyleManager->AddStyle(std::move(pSectStyle)).m_pStyle->GetStyleName();
     }
 }
 
@@ -433,12 +433,12 @@ void LwpMasterPage::RegisterFillerPageStyle()
     {
         if(m_pLayout->HasFillerPageText(m_pPara->GetFoundry()))
         {
-            XFParaStyle* pPagebreakStyle = new XFParaStyle;
+            std::unique_ptr<XFParaStyle> pPagebreakStyle(new XFParaStyle);
             *pPagebreakStyle = *(m_pPara->GetXFParaStyle());
             pPagebreakStyle->SetStyleName("");
             pPagebreakStyle->SetBreaks(enumXFBreakAftPage);
             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-            m_FillerPageStyleName= pXFStyleManager->AddStyle(pPagebreakStyle).m_pStyle->GetStyleName();
+            m_FillerPageStyleName= pXFStyleManager->AddStyle(std::move(pPagebreakStyle)).m_pStyle->GetStyleName();
         }
     }
 }
diff --git a/lotuswordpro/source/filter/lwpfribtable.cxx b/lotuswordpro/source/filter/lwpfribtable.cxx
index 0bfa7d6b7485..a6c50b86f9ee 100644
--- a/lotuswordpro/source/filter/lwpfribtable.cxx
+++ b/lotuswordpro/source/filter/lwpfribtable.cxx
@@ -90,7 +90,7 @@ void LwpFribTable::RegisterNewStyle()
             std::unique_ptr<XFParaStyle> xParaStyle(new XFParaStyle);
             *xParaStyle = *pOldStyle;
             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-            m_StyleName = pXFStyleManager->AddStyle(xParaStyle.release()).m_pStyle->GetStyleName();
+            m_StyleName = pXFStyleManager->AddStyle(std::move(xParaStyle)).m_pStyle->GetStyleName();
         }
     }
 }
diff --git a/lotuswordpro/source/filter/lwpfribtext.cxx b/lotuswordpro/source/filter/lwpfribtext.cxx
index 3aae5d61d9fc..0ae66e675b19 100644
--- a/lotuswordpro/source/filter/lwpfribtext.cxx
+++ b/lotuswordpro/source/filter/lwpfribtext.cxx
@@ -177,7 +177,7 @@ void LwpFribDocVar::RegisterStyle(LwpFoundry* pFoundry)
  */
 void LwpFribDocVar::RegisterDefaultTimeStyle()
 {
-    XFDateStyle* pDateStyle = new XFDateStyle;//use the default format
+    std::unique_ptr<XFDateStyle> pDateStyle(new XFDateStyle);//use the default format
 
     pDateStyle->AddMonth();
     pDateStyle->AddText("/");
@@ -192,15 +192,15 @@ void LwpFribDocVar::RegisterDefaultTimeStyle()
     pDateStyle->AddSecond();
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle).m_pStyle->GetStyleName();
+    m_TimeStyle = pXFStyleManager->AddStyle(std::move(pDateStyle)).m_pStyle->GetStyleName();
 }
 void LwpFribDocVar::RegisterTotalTimeStyle()
 {
-    XFTimeStyle* pTimeStyle = new XFTimeStyle;//use the default format
+    std::unique_ptr<XFTimeStyle> pTimeStyle(new XFTimeStyle);//use the default format
     pTimeStyle->SetTruncate(false);
     pTimeStyle->AddMinute();
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName();
+    m_TimeStyle = pXFStyleManager->AddStyle(std::move(pTimeStyle)).m_pStyle->GetStyleName();
 }
 
 /**
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
index 6947bc064b20..10945a7ff982 100644
--- a/lotuswordpro/source/filter/lwpgrfobj.cxx
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -272,11 +272,11 @@ void LwpGraphicObject::RegisterStyle()
         rtl::Reference<LwpVirtualLayout> xMyLayout(GetLayout(nullptr));
         if (xMyLayout.is() && xMyLayout->IsFrame())
         {
-            XFFrameStyle* pXFFrameStyle = new XFFrameStyle();
+            std::unique_ptr<XFFrameStyle> pXFFrameStyle(new XFFrameStyle());
             pXFFrameStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame);
             pXFFrameStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelPara);
             XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-            m_strStyleName = pXFStyleManager->AddStyle(pXFFrameStyle).m_pStyle->GetStyleName();
+            m_strStyleName = pXFStyleManager->AddStyle(std::move(pXFFrameStyle)).m_pStyle->GetStyleName();
         }
     }
 
@@ -628,7 +628,7 @@ void LwpGraphicObject::CreateGrafObject()
 
     // set style for the image
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pImage->SetStyleName(pXFStyleManager->AddStyle(xImageStyle.release()).m_pStyle->GetStyleName());
+    pImage->SetStyleName(pXFStyleManager->AddStyle(std::move(xImageStyle)).m_pStyle->GetStyleName());
 
     // set anchor to frame
     pImage->SetAnchorType(enumXFAnchorFrame);
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index efa9de8fc2d8..5a00d5368778 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -333,7 +333,7 @@ void LwpPageLayout::RegisterStyle()
 
     //Add the page master to stylemanager
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    XFPageMaster* pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(xpm1.release()).m_pStyle);
+    XFPageMaster* pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(std::move(xpm1)).m_pStyle);
     m_pXFPageMaster = pm1;
     OUString pmname = pm1->GetStyleName();
 
@@ -341,7 +341,7 @@ void LwpPageLayout::RegisterStyle()
     std::unique_ptr<XFMasterPage> p1(new XFMasterPage);
     p1->SetStyleName(GetName().str());
     p1->SetPageMaster(pmname);
-    XFMasterPage* p1_added = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(p1.release()).m_pStyle);
+    XFMasterPage* p1_added = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(std::move(p1)).m_pStyle);
     m_StyleName = p1_added->GetStyleName();
 
     //Set footer style
@@ -390,7 +390,7 @@ OUString LwpPageLayout::RegisterEndnoteStyle()
 
     //Add the page master to stylemanager
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_pXFPageMaster = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1.release()).m_pStyle);
+    m_pXFPageMaster = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(std::move(pm1)).m_pStyle);
     OUString pmname = m_pXFPageMaster->GetStyleName();
 
     //Add master page
@@ -416,7 +416,7 @@ OUString LwpPageLayout::RegisterEndnoteStyle()
         pLayoutHeader->RegisterStyle(p1.get());
     }
 
-    return pXFStyleManager->AddStyle(p1.release()).m_pStyle->GetStyleName();
+    return pXFStyleManager->AddStyle(std::move(p1)).m_pStyle->GetStyleName();
 }
 /**
 * @descr:   Whether current page layout has columns
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index b0b16f5f48e3..6a635d439709 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -283,7 +283,7 @@ void LwpPara::RegisterMasterPage(XFParaStyle const * pBaseStyle)
         if (!m_ParentStyleName.isEmpty())
             xOverStyle->SetParentStyleName(m_ParentStyleName);
         XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-        m_StyleName = pXFStyleManager->AddStyle(xOverStyle.release()).m_pStyle->GetStyleName();
+        m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
     }
 }
 /**
@@ -439,7 +439,7 @@ void LwpPara::RegisterStyle()
         }
         if (!m_ParentStyleName.isEmpty())
             xOverStyle->SetParentStyleName(m_ParentStyleName);
-        m_StyleName = pXFStyleManager->AddStyle(xOverStyle.release()).m_pStyle->GetStyleName();
+        m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
 
     }
     else //use named style
@@ -453,7 +453,7 @@ void LwpPara::RegisterStyle()
                     OverrideIndent(nullptr,m_pIndentOverride.get(),xOverStyle.get());
                     if (!m_ParentStyleName.isEmpty())
                         xOverStyle->SetParentStyleName(m_ParentStyleName);
-                    m_StyleName = pXFStyleManager->AddStyle(xOverStyle.release()).m_pStyle->GetStyleName();
+                    m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
                 }
             }
     }
@@ -468,7 +468,7 @@ void LwpPara::RegisterStyle()
             xOverStyle->SetAlignType(enumXFAlignStart);
             if (!m_ParentStyleName.isEmpty())
                 xOverStyle->SetParentStyleName(m_ParentStyleName);
-            m_StyleName = pXFStyleManager->AddStyle(xOverStyle.release()).m_pStyle->GetStyleName();
+            m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
         }
     }
 
@@ -625,7 +625,7 @@ void LwpPara::RegisterStyle()
                             if (pOldStyle)
                             {
                                 std::unique_ptr<XFListStyle> xNewStyle(new XFListStyle(*pOldStyle));
-                                m_aBulletStyleName = pXFStyleManager->AddStyle(xNewStyle.release()).m_pStyle->GetStyleName();
+                                m_aBulletStyleName = pXFStyleManager->AddStyle(std::move(xNewStyle)).m_pStyle->GetStyleName();
                             }
                         }
                     }
@@ -660,7 +660,7 @@ void LwpPara::RegisterStyle()
             pMargin->SetTop(pMargin->GetTop()+pPrePara->GetBelowSpacing());
             if (!m_ParentStyleName.isEmpty())
                     xOverStyle->SetParentStyleName(m_ParentStyleName);
-            m_StyleName = pXFStyleManager->AddStyle(xOverStyle.release()).m_pStyle->GetStyleName();
+            m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
         }
     }
 
@@ -673,7 +673,7 @@ void LwpPara::RegisterStyle()
         RegisterTabStyle(xNewParaStyle.get());
         if (!m_ParentStyleName.isEmpty())
             xNewParaStyle->SetParentStyleName(m_ParentStyleName);
-        m_StyleName = pXFStyleManager->AddStyle(xNewParaStyle.release()).m_pStyle->GetStyleName();
+        m_StyleName = pXFStyleManager->AddStyle(std::move(xNewParaStyle)).m_pStyle->GetStyleName();
     }
 
     //register master page;
@@ -691,7 +691,7 @@ void LwpPara::RegisterStyle()
         xStyle->SetDropCap(m_nChars-1,m_nLines);
         if (!m_ParentStyleName.isEmpty())
             xStyle->SetParentStyleName(m_ParentStyleName);
-        m_StyleName = pXFStyleManager->AddStyle(xStyle.release()).m_pStyle->GetStyleName();
+        m_StyleName = pXFStyleManager->AddStyle(std::move(xStyle)).m_pStyle->GetStyleName();
     }
     // maybe useful for further version
     // deleted because Leader of Table is not supported in this version
@@ -710,7 +710,7 @@ void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout)
         xSectStyle->SetColumns(pColumns);
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_SectionStyleName = pXFStyleManager->AddStyle(xSectStyle.release()).m_pStyle->GetStyleName();
+    m_SectionStyleName = pXFStyleManager->AddStyle(std::move(xSectStyle)).m_pStyle->GetStyleName();
 }
 
 rtl::Reference<XFSection> LwpPara::CreateXFSection()
diff --git a/lotuswordpro/source/filter/lwppara1.cxx b/lotuswordpro/source/filter/lwppara1.cxx
index d31decf5df73..8909346a9fba 100644
--- a/lotuswordpro/source/filter/lwppara1.cxx
+++ b/lotuswordpro/source/filter/lwppara1.cxx
@@ -409,27 +409,27 @@ void LwpPara::OverrideParaBreaks(LwpParaProperty* pProps, XFParaStyle* pOverStyl
     }
     if (m_pBreaks->IsPageBreakBefore())
     {
-        XFParaStyle* pStyle = new XFParaStyle();
+        std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
         pStyle->SetBreaks(enumXFBreakAftPage);
-        m_BefPageBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+        m_BefPageBreakName = pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
     }
     if (m_pBreaks->IsPageBreakAfter())
     {
-        XFParaStyle* pStyle = new XFParaStyle();
+        std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
         pStyle->SetBreaks(enumXFBreakAftPage);
-        m_AftPageBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+        m_AftPageBreakName = pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
     }
     if (m_pBreaks->IsColumnBreakBefore())
     {
-        XFParaStyle* pStyle = new XFParaStyle();
+        std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
         pStyle->SetBreaks(enumXFBreakAftColumn);//tmp after, should change when layout read
-        m_BefColumnBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+        m_BefColumnBreakName = pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
     }
     if (m_pBreaks->IsColumnBreakAfter())
     {
-        XFParaStyle* pStyle = new XFParaStyle();
+        std::unique_ptr<XFParaStyle> pStyle(new XFParaStyle());
         pStyle->SetBreaks(enumXFBreakAftColumn);
-        m_AftColumnBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName();
+        m_AftColumnBreakName = pXFStyleManager->AddStyle(std::move(pStyle)).m_pStyle->GetStyleName();
     }
 
 //  pParaStyle->ApplyBreaks(pOverStyle, &aFinalBreaks);
diff --git a/lotuswordpro/source/filter/lwpparastyle.cxx b/lotuswordpro/source/filter/lwpparastyle.cxx
index ea8ff180c0b8..157dc041adc1 100644
--- a/lotuswordpro/source/filter/lwpparastyle.cxx
+++ b/lotuswordpro/source/filter/lwpparastyle.cxx
@@ -673,7 +673,7 @@ void LwpParaStyle::RegisterStyle()
     Apply(xStyle.get());
     //Add style
     LwpStyleManager* pStyleMgr = m_pFoundry->GetStyleManager();
-    pStyleMgr->AddStyle(GetObjectID(), xStyle.release());
+    pStyleMgr->AddStyle(GetObjectID(), std::move(xStyle));
 }
 
 LwpAlignmentOverride* LwpParaStyle::GetAlignment()
diff --git a/lotuswordpro/source/filter/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx
index ca1f43979e09..e4d1fdf6c29b 100644
--- a/lotuswordpro/source/filter/lwprowlayout.cxx
+++ b/lotuswordpro/source/filter/lwprowlayout.cxx
@@ -118,7 +118,7 @@ void LwpRowLayout::SetRowMap()
 void LwpRowLayout::RegisterStyle()
 {
     // register row style
-    XFRowStyle *pRowStyle = new XFRowStyle();
+    std::unique_ptr<XFRowStyle> pRowStyle(new XFRowStyle());
 
     if (m_nDirection & 0x0030)
     {
@@ -129,7 +129,7 @@ void LwpRowLayout::RegisterStyle()
         pRowStyle->SetRowHeight(static_cast<float>(LwpTools::ConvertFromUnitsToMetric(cheight)));
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(pRowStyle).m_pStyle->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(std::move(pRowStyle)).m_pStyle->GetStyleName();
 
     LwpTableLayout* pTableLayout = GetParentTableLayout();
     if (pTableLayout)
@@ -265,12 +265,11 @@ void LwpRowLayout::RegisterCurRowStyle(XFRow* pXFRow,sal_uInt16 nRowMark)
         return;
     double fHeight = pRowStyle->GetRowHeight();
 
-    XFRowStyle* pNewStyle = new XFRowStyle;
+    std::unique_ptr<XFRowStyle> pNewStyle(new XFRowStyle);
     *pNewStyle = *pRowStyle;
     LwpTableLayout* pTableLayout = GetParentTableLayout();
     if (!pTableLayout)
     {
-        delete pNewStyle;
         return;
     }
     std::map<sal_uInt16,LwpRowLayout*> RowsMap = pTableLayout->GetRowsMap();
@@ -301,7 +300,7 @@ void LwpRowLayout::RegisterCurRowStyle(XFRow* pXFRow,sal_uInt16 nRowMark)
         pNewStyle->SetRowHeight(static_cast<float>(fHeight));
     }
 
-    pXFRow->SetStyleName(pXFStyleManager->AddStyle(pNewStyle).m_pStyle->GetStyleName());
+    pXFRow->SetStyleName(pXFStyleManager->AddStyle(std::move(pNewStyle)).m_pStyle->GetStyleName());
 }
 
 /**
diff --git a/lotuswordpro/source/filter/lwpsilverbullet.cxx b/lotuswordpro/source/filter/lwpsilverbullet.cxx
index e5a762c0d0fb..78aa35c94f98 100644
--- a/lotuswordpro/source/filter/lwpsilverbullet.cxx
+++ b/lotuswordpro/source/filter/lwpsilverbullet.cxx
@@ -178,7 +178,7 @@ void LwpSilverBullet::RegisterStyle()
     }
 
     //add style-list to style manager.
-    m_strStyleName = pXFStyleManager->AddStyle(xListStyle.release()).m_pStyle->GetStyleName();
+    m_strStyleName = pXFStyleManager->AddStyle(std::move(xListStyle)).m_pStyle->GetStyleName();
 }
 
 /**
diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx
index 1911229f3192..320400ea01e5 100644
--- a/lotuswordpro/source/filter/lwpstory.cxx
+++ b/lotuswordpro/source/filter/lwpstory.cxx
@@ -466,11 +466,11 @@ OUString LwpStory::RegisterFirstFribStyle()
     XFTextStyle* pBaseStyle = pXFStyleManager->FindTextStyle(pFirstFrib->GetStyleName());
     if (pBaseStyle == nullptr)
         return OUString();
-    XFTextStyle* pStyle = new XFTextStyle;
+    std::unique_ptr<XFTextStyle> pStyle(new XFTextStyle);
     *pStyle = *pBaseStyle;
     OUString sName = "Ruby" + pFirstFrib->GetStyleName();
     pStyle->SetStyleName(sName);
-    pXFStyleManager->AddStyle(pStyle);
+    pXFStyleManager->AddStyle(std::move(pStyle));
     return sName;
 }
 
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 4f1bf06cd724..379c44b34c13 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -618,7 +618,7 @@ void LwpTableLayout::RegisterColumns()
     xColStyle->SetWidth(static_cast<float>(dDefaultColumn));
 
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_DefaultColumnStyleName =  pXFStyleManager->AddStyle(xColStyle.release()).m_pStyle->GetStyleName();
+    m_DefaultColumnStyleName =  pXFStyleManager->AddStyle(std::move(xColStyle)).m_pStyle->GetStyleName();
 
     // register existed column style
     sal_uInt16 i=0;
@@ -664,7 +664,7 @@ void LwpTableLayout::RegisterRows()
         xRowStyle->SetRowHeight(static_cast<float>(pTable->GetHeight()));
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_DefaultRowStyleName =  pXFStyleManager->AddStyle(xRowStyle.release()).m_pStyle->GetStyleName();
+    m_DefaultRowStyleName =  pXFStyleManager->AddStyle(std::move(xRowStyle)).m_pStyle->GetStyleName();
 
     // register style of rows
     LwpObjectID& rRowID = GetChildHead();
@@ -739,7 +739,7 @@ void LwpTableLayout::RegisterStyle()
         xTableStyle->SetWidth(pSuper->GetTableWidth());
     }
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(xTableStyle.release()).m_pStyle->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(std::move(xTableStyle)).m_pStyle->GetStyleName();
 
     //convert to OO table now and register row style traverse
     TraverseTable();
@@ -917,7 +917,7 @@ void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable, rtl::Reference<XFTable>
     {
         xRowStyle->SetRowHeight(static_cast<float>(fHeight));
     }
-    xXFRow->SetStyleName(pXFStyleManager->AddStyle(xRowStyle.release()).m_pStyle->GetStyleName());
+    xXFRow->SetStyleName(pXFStyleManager->AddStyle(std::move(xRowStyle)).m_pStyle->GetStyleName());
 
     //construct heading row
     rtl::Reference<XFCell> xXFCell1(new XFCell);
@@ -1245,7 +1245,7 @@ void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_
                 }
 
                 xOverStyle->SetStyleName("");
-                OUString StyleName = pXFStyleManager->AddStyle(xOverStyle.release()).m_pStyle->GetStyleName();
+                OUString StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
 
                 pXFPara->SetStyleName(StyleName);
             }
@@ -1453,7 +1453,7 @@ void LwpColumnLayout::RegisterStyle(double dCalculatedWidth)
     std::unique_ptr<XFColStyle> xColStyle(new XFColStyle);
     xColStyle->SetWidth(static_cast<float>(dCalculatedWidth));
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_StyleName = pXFStyleManager->AddStyle(xColStyle.release()).m_pStyle->GetStyleName();
+    m_StyleName = pXFStyleManager->AddStyle(std::move(xColStyle)).m_pStyle->GetStyleName();
 }
 
 LwpTableHeadingLayout::LwpTableHeadingLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
diff --git a/lotuswordpro/source/filter/lwptoc.cxx b/lotuswordpro/source/filter/lwptoc.cxx
index 3f2add0b96a2..037ecd72ef1f 100644
--- a/lotuswordpro/source/filter/lwptoc.cxx
+++ b/lotuswordpro/source/filter/lwptoc.cxx
@@ -132,11 +132,11 @@ void LwpTocSuperLayout::RegisterStyle()
     // Get font info of default text style and set into tab style
     const LwpObjectID *pDefaultTextStyle = m_pFoundry ? m_pFoundry->GetDefaultTextStyle() : nullptr;
     XFParaStyle* pBaseStyle = pDefaultTextStyle ? dynamic_cast<XFParaStyle*>(m_pFoundry->GetStyleManager()->GetStyle(*pDefaultTextStyle)) : nullptr;
-    XFTextStyle*pTextStyle = new XFTextStyle;
+    std::unique_ptr<XFTextStyle> pTextStyle(new XFTextStyle);
     if (pBaseStyle)
         pTextStyle->SetFont(pBaseStyle->GetFont()); // who delete this font?????
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    m_TabStyleName = pXFStyleManager->AddStyle(pTextStyle).m_pStyle->GetStyleName();
+    m_TabStyleName = pXFStyleManager->AddStyle(std::move(pTextStyle)).m_pStyle->GetStyleName();
 
 }
 /**
diff --git a/lotuswordpro/source/filter/lwpverdocument.cxx b/lotuswordpro/source/filter/lwpverdocument.cxx
index a19d9a6c8263..894a9008d97f 100644
--- a/lotuswordpro/source/filter/lwpverdocument.cxx
+++ b/lotuswordpro/source/filter/lwpverdocument.cxx
@@ -91,7 +91,7 @@ void LwpVerDocument::Read()
 
 void LwpVerDocument::RegisterStyle()
 {
-    XFDefaultParaStyle* pDefault = new XFDefaultParaStyle;
+    std::unique_ptr<XFDefaultParaStyle> pDefault(new XFDefaultParaStyle);
     double len =static_cast<double>(m_nTabSpacing)/UNITS_PER_INCH*CM_PER_INCH;
     if(len < 0.001)
     {
@@ -99,7 +99,7 @@ void LwpVerDocument::RegisterStyle()
     }
     pDefault->SetTabDistance(len);
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pXFStyleManager->AddStyle(pDefault);
+    pXFStyleManager->AddStyle(std::move(pDefault));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx b/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx
index 8592a0604723..8b0e5bd4440b 100644
--- a/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfconfigmanager.cxx
@@ -89,11 +89,11 @@ void    XFConfigManager::SetEndnoteConfig(XFEndnoteConfig *pENConfig)
 void    XFConfigManager::ToXml(IXFStream *pStrm)
 {
     if( m_pLineNumberConfig )
-        AddStyle(m_pLineNumberConfig.release());
+        AddStyle(std::move(m_pLineNumberConfig));
     if( m_pFootnoteConfig )
-        AddStyle(m_pFootnoteConfig.release());
+        AddStyle(std::move(m_pFootnoteConfig));
     if( m_pEndnoteConfig )
-        AddStyle(m_pEndnoteConfig.release());
+        AddStyle(std::move(m_pEndnoteConfig));
 
     XFStyleContainer::ToXml(pStrm);
     XFStyleContainer::Reset();
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx b/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx
index bb5c76013625..b4c7b6729892 100644
--- a/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx
@@ -104,7 +104,7 @@ void    XFDrawStyle::SetLineDashStyle(enumXFLineStyle style, double len1, double
     m_pLineStyle->SetDot2Length(len2);
     m_pLineStyle->SetSpace(space);
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pXFStyleManager->AddStyle(m_pLineStyle);
+    pXFStyleManager->AddStyle(std::unique_ptr<IXFStyle>(m_pLineStyle));
 }
 
 void XFDrawStyle::SetFontWorkStyle(enumXFFWStyle eStyle, enumXFFWAdjust eAdjust)
@@ -143,7 +143,7 @@ void    XFDrawStyle::SetAreaLineStyle(enumXFAreaLineStyle style, sal_Int32 angle
     m_pAreaStyle->SetLineSpace(space);
     m_pAreaStyle->SetLineColor(lineColor);
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
-    pXFStyleManager->AddStyle(m_pAreaStyle);
+    pXFStyleManager->AddStyle(std::unique_ptr<IXFStyle>(m_pAreaStyle));
 }
 
 enumXFStyle XFDrawStyle::GetStyleFamily()
diff --git a/lotuswordpro/source/filter/xfilter/xfparastyle.cxx b/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
index 0f8369d629d5..bbb686b986cc 100644
--- a/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
@@ -117,8 +117,8 @@ XFParaStyle::XFParaStyle(const XFParaStyle& other)
             const XFTabStyle* pTabStyle = dynamic_cast<const XFTabStyle*>(pStyle);
             if( pTabStyle )
             {
-                XFTabStyle *pCopyStyle = new XFTabStyle(*pTabStyle);
-                m_aTabs.AddStyle(pCopyStyle);
+                std::unique_ptr<XFTabStyle> pCopyStyle(new XFTabStyle(*pTabStyle));
+                m_aTabs.AddStyle(std::move(pCopyStyle));
             }
         }
     }
@@ -171,8 +171,8 @@ XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other)
                 const XFTabStyle *pTabStyle = dynamic_cast<const XFTabStyle*>(pStyle);
                 if( pTabStyle )
                 {
-                    XFTabStyle *pCopyStyle = new XFTabStyle(*pTabStyle);
-                    m_aTabs.AddStyle(pCopyStyle);
+                    std::unique_ptr<XFTabStyle> pCopyStyle(new XFTabStyle(*pTabStyle));
+                    m_aTabs.AddStyle(std::move(pCopyStyle));
                 }
             }
         }
@@ -275,12 +275,12 @@ void    XFParaStyle::SetLineHeight(enumLHType type, double value)
 
 void    XFParaStyle::AddTabStyle(enumXFTab type, double len, sal_Unicode leader, sal_Unicode delimiter)
 {
-    XFTabStyle  *tab = new XFTabStyle();
+    std::unique_ptr<XFTabStyle> tab(new XFTabStyle());
     tab->SetTabType(type);
     tab->SetLength(len);
     tab->SetLeaderChar(leader);
     tab->SetDelimiter(delimiter);
-    m_aTabs.AddStyle(tab);
+    m_aTabs.AddStyle(std::move(tab));
 }
 
 /**
diff --git a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
index 811c1b9c2e52..8e2a675a3281 100644
--- a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
@@ -72,22 +72,14 @@ XFStyleContainer::XFStyleContainer(const OUString& strStyleNamePrefix)
 
 XFStyleContainer::~XFStyleContainer()
 {
-    for (auto const& style : m_aStyles)
-    {
-        delete style;
-    }
 }
 
-void    XFStyleContainer::Reset()
+void XFStyleContainer::Reset()
 {
-    for (auto const& style : m_aStyles)
-    {
-        delete style;
-    }
     m_aStyles.clear();
 }
 
-IXFStyleRet XFStyleContainer::AddStyle(IXFStyle *pStyle)
+IXFStyleRet XFStyleContainer::AddStyle(std::unique_ptr<IXFStyle> pStyle)
 {
     IXFStyleRet aRet;
 
@@ -97,14 +89,13 @@ IXFStyleRet XFStyleContainer::AddStyle(IXFStyle *pStyle)
     if( !pStyle )
         return aRet;
     //no matter we want to delete the style or not,XFFont object should be saved first.
-    ManageStyleFont(pStyle);
+    ManageStyleFont(pStyle.get());
 
     if( pStyle->GetStyleName().isEmpty() )
-        pConStyle = FindSameStyle(pStyle);
+        pConStyle = FindSameStyle(pStyle.get());
 
     if( pConStyle )//such a style has exist:
     {
-        delete pStyle;
         aRet.m_pStyle = pConStyle;
         aRet.m_bOrigDeleted = true;
         return aRet;
@@ -127,9 +118,9 @@ IXFStyleRet XFStyleContainer::AddStyle(IXFStyle *pStyle)
             }
         }
 
-        m_aStyles.push_back(pStyle);
         //transform the font object to XFFontFactory
-        aRet.m_pStyle = pStyle;
+        aRet.m_pStyle = pStyle.get();
+        m_aStyles.push_back(std::move(pStyle));
         return aRet;
     }
 }
@@ -140,7 +131,7 @@ IXFStyle*   XFStyleContainer::FindSameStyle(IXFStyle *pStyle)
     {
         assert(style);
         if( style->Equal(pStyle) )
-            return style;
+            return style.get();
     }
 
     return nullptr;
@@ -152,7 +143,7 @@ IXFStyle*   XFStyleContainer::FindStyle(const OUString& name)
     {
         assert(style);
         if( style->GetStyleName() == name )
-            return style;
+            return style.get();
     }
 
     return nullptr;
@@ -163,7 +154,7 @@ const IXFStyle* XFStyleContainer::Item(size_t index) const
     assert(index<m_aStyles.size());
     if (index < m_aStyles.size())
     {
-        return m_aStyles[index];
+        return m_aStyles[index].get();
     }
     return nullptr;
 }
@@ -233,8 +224,8 @@ bool operator==(XFStyleContainer& b1, XFStyleContainer& b2)
         return false;
     for( size_t i=0; i<b1.m_aStyles.size(); ++i )
     {
-        IXFStyle *pS1 = b1.m_aStyles[i];
-        IXFStyle *pS2 = b2.m_aStyles[i];
+        IXFStyle *pS1 = b1.m_aStyles[i].get();
+        IXFStyle *pS2 = b2.m_aStyles[i].get();
 
         if( pS1 )
         {
diff --git a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx
index bff7a1b3354b..74a05f265a9b 100644
--- a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx
@@ -109,7 +109,7 @@ void    XFStyleManager::AddFontDecl(XFFontDecl const & aFontDecl)
     s_aFontDecls.push_back(aFontDecl);
 }
 
-IXFStyleRet XFStyleManager::AddStyle(IXFStyle *pStyle)
+IXFStyleRet XFStyleManager::AddStyle(std::unique_ptr<IXFStyle> pStyle)
 {
     IXFStyleRet aRet;
 
@@ -122,105 +122,105 @@ IXFStyleRet XFStyleManager::AddStyle(IXFStyle *pStyle)
     {
         if( !name.isEmpty() )
         {
-            aRet = s_aStdTextStyles.AddStyle(pStyle);
+            aRet = s_aStdTextStyles.AddStyle(std::move(pStyle));
         }
         else
         {
-            aRet = s_aTextStyles.AddStyle(pStyle);
+            aRet = s_aTextStyles.AddStyle(std::move(pStyle));
         }
     }
     else if( pStyle->GetStyleFamily() == enumXFStylePara )
     {
         if( !name.isEmpty() )
         {
-            aRet = s_aStdParaStyles.AddStyle(pStyle);
+            aRet = s_aStdParaStyles.AddStyle(std::move(pStyle));
         }
         else
         {
-            aRet = s_aParaStyles.AddStyle(pStyle);
+            aRet = s_aParaStyles.AddStyle(std::move(pStyle));
         }
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleDefaultPara )
     {
-        aRet = s_aStdParaStyles.AddStyle(pStyle);
+        aRet = s_aStdParaStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleList )
     {
-        aRet = s_aListStyles.AddStyle(pStyle);
+        aRet = s_aListStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleSection )
     {
-        aRet = s_aSectionStyles.AddStyle(pStyle);
+        aRet = s_aSectionStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStylePageMaster )
     {
-        aRet = s_aPageMasters.AddStyle(pStyle);
+        aRet = s_aPageMasters.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleMasterPage )
     {
         //Master page don't need name.
-        aRet = s_aMasterpages.AddStyle(pStyle);
+        aRet = s_aMasterpages.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleDate )
     {
-        aRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTime )
     {
-        aRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleNumber )
     {
-        aRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStylePercent )
     {
-        aRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleCurrency )
     {
-        aRet = s_aDateStyles.AddStyle(pStyle);
+        aRet = s_aDateStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleGraphics )
     {
-        aRet = s_aGraphicsStyles.AddStyle(pStyle);
+        aRet = s_aGraphicsStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTable )
     {
-        aRet = s_aTableStyles.AddStyle(pStyle);
+        aRet = s_aTableStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTableCell )
     {
-        aRet = s_aTableCellStyles.AddStyle(pStyle);
+        aRet = s_aTableCellStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTableRow )
     {
-        aRet = s_aTableRowStyles.AddStyle(pStyle);
+        aRet = s_aTableRowStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleTableCol )
     {
-        aRet = s_aTableColStyles.AddStyle(pStyle);
+        aRet = s_aTableColStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleOutline )
     {
         delete s_pOutlineStyle;
-        s_pOutlineStyle = pStyle;
+        s_pOutlineStyle = pStyle.release();
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleStrokeDash )
     {
-        aRet = s_aStdStrokeDashStyles.AddStyle(pStyle);
+        aRet = s_aStdStrokeDashStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleArea )
     {
-        aRet = s_aStdAreaStyles.AddStyle(pStyle);
+        aRet = s_aStdAreaStyles.AddStyle(std::move(pStyle));
     }
     else if( pStyle->GetStyleFamily() == enumXFStyleArrow )
     {
-        aRet = s_aStdArrowStyles.AddStyle(pStyle);
+        aRet = s_aStdArrowStyles.AddStyle(std::move(pStyle));
     }
     else if (pStyle->GetStyleFamily() == enumXFStyleRuby)
     {
-        aRet = s_aRubyStyles.AddStyle(pStyle);
+        aRet = s_aRubyStyles.AddStyle(std::move(pStyle));
     }
 
     return aRet;


More information about the Libreoffice-commits mailing list