summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-07 08:25:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-07 11:40:09 +0100
commitc4331c0b6a12b541a5adee6374f9acf70c3dd6fd (patch)
tree6f67c4720e7db2667625c54a9446510631c14112 /lotuswordpro
parent05f12ce00f03be685df9a392001c2ae5f3258edf (diff)
use unique_ptr in LwpTools::GetSystemDateStyle
Change-Id: I6ea90be5736982422aaa45c7147beec1cfd5430b Reviewed-on: https://gerrit.libreoffice.org/65918 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/inc/lwptools.hxx4
-rw-r--r--lotuswordpro/source/filter/localtime.cxx5
-rw-r--r--lotuswordpro/source/filter/lwpfribmark.cxx8
-rw-r--r--lotuswordpro/source/filter/lwptools.cxx10
4 files changed, 13 insertions, 14 deletions
diff --git a/lotuswordpro/inc/lwptools.hxx b/lotuswordpro/inc/lwptools.hxx
index a0ec4bae29cc..3013c20435da 100644
--- a/lotuswordpro/inc/lwptools.hxx
+++ b/lotuswordpro/inc/lwptools.hxx
@@ -101,8 +101,8 @@ public:
static OUString convertToFileUrl(const OString& fileName);
static OUString DateTimeToOUString(const LtTm& dt);
- static XFDateStyle* GetSystemDateStyle(bool bLongFormat);
- static XFTimeStyle* GetSystemTimeStyle();
+ static std::unique_ptr<XFDateStyle> GetSystemDateStyle(bool bLongFormat);
+ static std::unique_ptr<XFTimeStyle> GetSystemTimeStyle();
};
inline double LwpTools::ConvertFromUnits(sal_Int32 nUnits)
diff --git a/lotuswordpro/source/filter/localtime.cxx b/lotuswordpro/source/filter/localtime.cxx
index 39b6e0212058..9532cbbdcba8 100644
--- a/lotuswordpro/source/filter/localtime.cxx
+++ b/lotuswordpro/source/filter/localtime.cxx
@@ -56,6 +56,7 @@
#include <localtime.hxx>
#include <limits.h>
#include <unicode/timezone.h>
+#include <memory>
const long DAY_SEC =24 * 60 * 60;
const long YEAR_SEC = 365 * DAY_SEC;
@@ -174,9 +175,9 @@ bool LtgLocalTime(long rtime,LtTm& rtm)
if ((rtime > 3 * DAY_SEC)&&(rtime < LONG_MAX - 3 * DAY_SEC))
{
- icu::TimeZone* pLocalZone = icu::TimeZone::createDefault();
+ std::unique_ptr<icu::TimeZone> pLocalZone(icu::TimeZone::createDefault());
long offset = (pLocalZone->getRawOffset())/1000;
- delete pLocalZone;
+ pLocalZone.reset();
long ltime = rtime + offset;
return LtgGmTime(ltime,rtm);
}
diff --git a/lotuswordpro/source/filter/lwpfribmark.cxx b/lotuswordpro/source/filter/lwpfribmark.cxx
index 307b3e6f0df9..878b37d3d28e 100644
--- a/lotuswordpro/source/filter/lwpfribmark.cxx
+++ b/lotuswordpro/source/filter/lwpfribmark.cxx
@@ -398,11 +398,11 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
{
if (sFormula == "%FLSystemShortDate")
{
- pDateStyle.reset( LwpTools::GetSystemDateStyle(false) );
+ pDateStyle = LwpTools::GetSystemDateStyle(false);
}
else if (sFormula == "%FLSystemLongDate")
{
- pDateStyle.reset( LwpTools::GetSystemDateStyle(true) );
+ pDateStyle = LwpTools::GetSystemDateStyle(true);
}
else if (sFormula == "%FLISODate1" || sFormula == "%FLYYYY/MM/DD" )
{
@@ -868,7 +868,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
//TIME
else if (sFormula == "%FLSystemTime")
{
- pTimeStyle.reset(LwpTools::GetSystemTimeStyle());
+ pTimeStyle = LwpTools::GetSystemTimeStyle();
}
else if (sFormula == "%FLISOTime1" || sFormula == "%FLH:mm:SS")
{
@@ -1018,7 +1018,7 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula)
{
if (sFormula == "%Da")
{
- pDateStyle.reset(LwpTools::GetSystemDateStyle(false));
+ pDateStyle = LwpTools::GetSystemDateStyle(false);
}
else if (sFormula == "%DB" || sFormula == "%Db")
{
diff --git a/lotuswordpro/source/filter/lwptools.cxx b/lotuswordpro/source/filter/lwptools.cxx
index 0f5ae98e7496..bd8ad0e067ba 100644
--- a/lotuswordpro/source/filter/lwptools.cxx
+++ b/lotuswordpro/source/filter/lwptools.cxx
@@ -233,7 +233,7 @@ OUString LwpTools::DateTimeToOUString(const LtTm &dt)
/**
* @descr get the system date format
*/
-XFDateStyle* LwpTools::GetSystemDateStyle(bool bLongFormat)
+std::unique_ptr<XFDateStyle> LwpTools::GetSystemDateStyle(bool bLongFormat)
{
icu::DateFormat::EStyle style;
if (bLongFormat)
@@ -268,7 +268,7 @@ XFDateStyle* LwpTools::GetSystemDateStyle(bool bLongFormat)
// we parse pattern string letter by letter and get the time format.
UChar cSymbol;
UChar cTmp;
- XFDateStyle* pDateStyle = new XFDateStyle;
+ std::unique_ptr<XFDateStyle> pDateStyle(new XFDateStyle);
for (int32_t i=0;i<nLengthNeed;)
{
@@ -594,7 +594,6 @@ XFDateStyle* LwpTools::GetSystemDateStyle(bool bLongFormat)
{
if ((cSymbol>='A' && cSymbol<='Z') || (cSymbol>='a' && cSymbol<='z') )
{
- delete pDateStyle;
return nullptr;
}
else//TEXT
@@ -628,7 +627,7 @@ XFDateStyle* LwpTools::GetSystemDateStyle(bool bLongFormat)
/**
* @descr get the system time format
*/
-XFTimeStyle* LwpTools::GetSystemTimeStyle()
+std::unique_ptr<XFTimeStyle> LwpTools::GetSystemTimeStyle()
{
//1 get locale for system
icu::Locale aLocale( LanguageTagIcu::getIcuLocale( Application::GetSettings().GetLanguageTag()));
@@ -658,7 +657,7 @@ XFTimeStyle* LwpTools::GetSystemTimeStyle()
// for time format ,for there is not date info,we can only parse the letter representing time.
UChar cSymbol;
UChar cTmp;
- XFTimeStyle* pTimeStyle = new XFTimeStyle;
+ std::unique_ptr<XFTimeStyle> pTimeStyle(new XFTimeStyle);
for (int32_t i=0;i<nLengthNeed;)
{
@@ -817,7 +816,6 @@ XFTimeStyle* LwpTools::GetSystemTimeStyle()
{
if ((cSymbol>='A' && cSymbol<='Z') || (cSymbol>='a' && cSymbol<='z') )
{
- delete pTimeStyle;
return nullptr;
}
else//TEXT