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 GetSystemDateStyle(bool bLongFormat); + static std::unique_ptr 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 #include #include +#include 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 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 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 pDateStyle(new XFDateStyle); for (int32_t i=0;i='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 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 pTimeStyle(new XFTimeStyle); for (int32_t i=0;i='A' && cSymbol<='Z') || (cSymbol>='a' && cSymbol<='z') ) { - delete pTimeStyle; return nullptr; } else//TEXT