summaryrefslogtreecommitdiff
path: root/scaddins/source/datefunc
diff options
context:
space:
mode:
Diffstat (limited to 'scaddins/source/datefunc')
-rw-r--r--scaddins/source/datefunc/datefunc.cxx37
-rw-r--r--scaddins/source/datefunc/datefunc.hrc49
-rw-r--r--scaddins/source/datefunc/datefunc.hxx28
-rw-r--r--scaddins/source/datefunc/datefunc.src154
4 files changed, 22 insertions, 246 deletions
diff --git a/scaddins/source/datefunc/datefunc.cxx b/scaddins/source/datefunc/datefunc.cxx
index d2a33ccf5398..ef73390c854b 100644
--- a/scaddins/source/datefunc/datefunc.cxx
+++ b/scaddins/source/datefunc/datefunc.cxx
@@ -19,11 +19,11 @@
#include "datefunc.hxx"
#include "datefunc.hrc"
+#include "strings.hrc"
#include <com/sun/star/util/Date.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ustrbuf.hxx>
-#include <tools/rcid.h>
#include <tools/resmgr.hxx>
#include <algorithm>
#include "deffuncname.hxx"
@@ -34,11 +34,6 @@ using namespace ::com::sun::star;
#define MY_SERVICE "com.sun.star.sheet.addin.DateFunctions"
#define MY_IMPLNAME "com.sun.star.sheet.addin.DateFunctionsImpl"
-ScaResId::ScaResId( sal_uInt16 nId, ResMgr& rResMgr ) :
- ResId( nId, rResMgr )
-{
-}
-
#define UNIQUE false // function name does not exist in Calc
#define STDPAR false // all parameters are described
@@ -63,8 +58,8 @@ const ScaFuncDataBase pFuncDataArr[] =
ScaFuncData::ScaFuncData(const ScaFuncDataBase& rBaseData) :
aIntName( OUString::createFromAscii( rBaseData.pIntName ) ),
- nUINameID( rBaseData.nUINameID ),
- nDescrID( rBaseData.nDescrID ),
+ pUINameID( rBaseData.pUINameID ),
+ pDescrID( rBaseData.pDescrID ),
nParamCount( rBaseData.nParamCount ),
eCat( rBaseData.eCat ),
bDouble( rBaseData.bDouble ),
@@ -129,7 +124,6 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL date_component_getFactory(
// "normal" service implementation
ScaDateAddIn::ScaDateAddIn() :
pDefLocales( nullptr ),
- pResMgr( nullptr ),
pFuncDataList( nullptr )
{
}
@@ -157,20 +151,9 @@ const lang::Locale& ScaDateAddIn::GetLocale( sal_uInt32 nIndex )
return (nIndex < sizeof( pLang )) ? pDefLocales[ nIndex ] : aFuncLoc;
}
-ResMgr& ScaDateAddIn::GetResMgr()
-{
- if( !pResMgr )
- {
- InitData(); // try to get resource manager
- if( !pResMgr )
- throw uno::RuntimeException();
- }
- return *pResMgr;
-}
-
void ScaDateAddIn::InitData()
{
- pResMgr.reset(ResMgr::CreateResMgr("date", LanguageTag(aFuncLoc)));
+ aResLocale = Translate::Create("sca", LanguageTag(aFuncLoc));
pFuncDataList.reset();
pFuncDataList.reset(new ScaFuncDataList);
@@ -182,10 +165,9 @@ void ScaDateAddIn::InitData()
}
}
-OUString ScaDateAddIn::GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex )
+OUString ScaDateAddIn::GetFuncDescrStr(const char** pResId, sal_uInt16 nStrIndex)
{
- ResStringArray aArr(ScaResId(nResId, GetResMgr()));
- return aArr.GetString(nStrIndex - 1);
+ return ScaResId(pResId[nStrIndex - 1]);
}
OUString ScaDateAddIn::getImplementationName_Static()
@@ -252,7 +234,7 @@ OUString SAL_CALL ScaDateAddIn::getDisplayFunctionName( const OUString& aProgram
FindScaFuncData( aProgrammaticName ) );
if( fDataIt != pFuncDataList->end() )
{
- aRet = ScaResId(fDataIt->GetUINameID(), GetResMgr());
+ aRet = ScaResId(fDataIt->GetUINameID());
if( fDataIt->IsDouble() )
aRet += "_ADD";
}
@@ -770,4 +752,9 @@ OUString SAL_CALL ScaDateAddIn::getRot13( const OUString& aSrcString )
return aBuffer.makeStringAndClear();
}
+OUString ScaDateAddIn::ScaResId(const char* pId)
+{
+ return Translate::get(pId, aResLocale);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/scaddins/source/datefunc/datefunc.hrc b/scaddins/source/datefunc/datefunc.hrc
deleted file mode 100644
index 44653ef848a2..000000000000
--- a/scaddins/source/datefunc/datefunc.hrc
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_SCADDINS_SOURCE_DATEFUNC_DATEFUNC_HRC
-#define INCLUDED_SCADDINS_SOURCE_DATEFUNC_DATEFUNC_HRC
-
-#define DATE_RESOURCE_START 1000
-
-#define DATE_FUNCDESC_START DATE_RESOURCE_START
-
-#define DATE_FUNCDESC_DiffWeeks (DATE_FUNCDESC_START)
-#define DATE_FUNCDESC_DiffMonths (DATE_FUNCDESC_START+1)
-#define DATE_FUNCDESC_DiffYears (DATE_FUNCDESC_START+2)
-#define DATE_FUNCDESC_IsLeapYear (DATE_FUNCDESC_START+3)
-#define DATE_FUNCDESC_DaysInMonth (DATE_FUNCDESC_START+4)
-#define DATE_FUNCDESC_DaysInYear (DATE_FUNCDESC_START+5)
-#define DATE_FUNCDESC_WeeksInYear (DATE_FUNCDESC_START+6)
-#define DATE_FUNCDESC_Rot13 (DATE_FUNCDESC_START+7)
-
-#define DATE_FUNCNAME_START (DATE_RESOURCE_START+1000)
-
-#define DATE_FUNCNAME_DiffWeeks (DATE_FUNCNAME_START)
-#define DATE_FUNCNAME_DiffMonths (DATE_FUNCNAME_START+1)
-#define DATE_FUNCNAME_DiffYears (DATE_FUNCNAME_START+2)
-#define DATE_FUNCNAME_IsLeapYear (DATE_FUNCNAME_START+3)
-#define DATE_FUNCNAME_DaysInMonth (DATE_FUNCNAME_START+4)
-#define DATE_FUNCNAME_DaysInYear (DATE_FUNCNAME_START+5)
-#define DATE_FUNCNAME_WeeksInYear (DATE_FUNCNAME_START+6)
-#define DATE_FUNCNAME_Rot13 (DATE_FUNCNAME_START+7)
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/scaddins/source/datefunc/datefunc.hxx b/scaddins/source/datefunc/datefunc.hxx
index 816aaffd6c19..51b2899daeef 100644
--- a/scaddins/source/datefunc/datefunc.hxx
+++ b/scaddins/source/datefunc/datefunc.hxx
@@ -33,14 +33,6 @@
#include <com/sun/star/sheet/addin/XDateFunctions.hpp>
#include <com/sun/star/sheet/addin/XMiscFunctions.hpp>
#include <cppuhelper/implbase.hxx>
-#include <tools/resid.hxx>
-#include <tools/resary.hxx>
-
-class ScaResId : public ResId
-{
-public:
- ScaResId(sal_uInt16 nResId, ResMgr& rResMgr);
-};
enum class ScaCategory
{
@@ -55,8 +47,8 @@ enum class ScaCategory
struct ScaFuncDataBase
{
const sal_Char* pIntName; // internal name (get***)
- sal_uInt16 nUINameID; // resource ID to UI name
- sal_uInt16 nDescrID; // resource ID to description, parameter names and ~ description
+ const char* pUINameID; // resource ID to UI name
+ const char** pDescrID; // resource ID to description, parameter names and ~ description
const char** pCompListID; // list of valid names
sal_uInt16 nParamCount; // number of named / described parameters
ScaCategory eCat; // function category
@@ -68,8 +60,8 @@ class ScaFuncData final
{
private:
OUString aIntName; // internal name (get***)
- sal_uInt16 nUINameID; // resource ID to UI name
- sal_uInt16 nDescrID; // leads also to parameter descriptions!
+ const char* pUINameID; // resource ID to UI name
+ const char** pDescrID; // leads also to parameter descriptions!
sal_uInt16 nParamCount; // num of parameters
std::vector<OUString> aCompList; // list of all valid names
ScaCategory eCat; // function category
@@ -80,8 +72,8 @@ public:
ScaFuncData(const ScaFuncDataBase& rBaseData);
~ScaFuncData();
- sal_uInt16 GetUINameID() const { return nUINameID; }
- sal_uInt16 GetDescrID() const { return nDescrID; }
+ const char* GetUINameID() const { return pUINameID; }
+ const char** GetDescrID() const { return pDescrID; }
ScaCategory GetCategory() const { return eCat; }
bool IsDouble() const { return bDouble; }
@@ -120,22 +112,22 @@ class ScaDateAddIn : public ::cppu::WeakImplHelper<
private:
css::lang::Locale aFuncLoc;
std::unique_ptr< css::lang::Locale[] > pDefLocales;
- std::unique_ptr< ResMgr > pResMgr;
+ std::locale aResLocale;
std::unique_ptr< ScaFuncDataList > pFuncDataList;
void InitDefLocales();
const css::lang::Locale& GetLocale( sal_uInt32 nIndex );
- /// @throws css::uno::RuntimeException
- ResMgr& GetResMgr();
void InitData();
/// @throws css::uno::RuntimeException
- OUString GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex );
+ OUString GetFuncDescrStr(const char** pResId, sal_uInt16 nStrIndex);
public:
ScaDateAddIn();
+ OUString ScaResId(const char* pId);
+
static OUString getImplementationName_Static();
static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
diff --git a/scaddins/source/datefunc/datefunc.src b/scaddins/source/datefunc/datefunc.src
deleted file mode 100644
index 9e8632995a37..000000000000
--- a/scaddins/source/datefunc/datefunc.src
+++ /dev/null
@@ -1,154 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "datefunc.hrc"
-
-StringArray DATE_FUNCDESC_DiffWeeks
-{
- ItemList [ en-US ] =
- {
- < "Calculates the number of weeks in a specific period"; > ;
- < "Start date"; > ;
- < "First day of the period"; > ;
- < "End date"; > ;
- < "Last day of the period"; > ;
- < "Type"; > ;
- < "Type of calculation: Type=0 means the time interval, Type=1 means calendar weeks."; > ;
- };
-};
-
-StringArray DATE_FUNCDESC_DiffMonths
-{
- ItemList [ en-US ] =
- {
- < "Determines the number of months in a specific period."; > ;
- < "Start date"; > ;
- < "First day of the period."; > ;
- < "End date"; > ;
- < "Last day of the period."; > ;
- < "Type"; > ;
- < "Type of calculation: Type=0 means the time interval, Type=1 means calendar months."; > ;
- };
-};
-
-StringArray DATE_FUNCDESC_DiffYears
-{
- ItemList [ en-US ] =
- {
- < "Calculates the number of years in a specific period."; > ;
- < "Start date"; > ;
- < "First day of the period"; > ;
- < "End date"; > ;
- < "Last day of the period"; > ;
- < "Type"; > ;
- < "Type of calculation: Type=0 means the time interval, Type=1 means calendar years."; > ;
- };
-};
-
-StringArray DATE_FUNCDESC_IsLeapYear
-{
- ItemList [ en-US ] =
- {
- < "Returns 1 (TRUE) if the date is a day of a leap year, otherwise 0 (FALSE)."; > ;
- < "Date"; > ;
- < "Any day in the desired year"; > ;
- };
-};
-
-StringArray DATE_FUNCDESC_DaysInMonth
-{
- ItemList [ en-US ] =
- {
- < "Returns the number of days of the month in which the date entered occurs"; > ;
- < "Date"; > ;
- < "Any day in the desired month"; > ;
- };
-};
-
-StringArray DATE_FUNCDESC_DaysInYear
-{
- ItemList [ en-US ] =
- {
- < "Returns the number of days of the year in which the date entered occurs."; > ;
- < "Date"; > ;
- < "Any day in the desired year"; > ;
- };
-};
-
-StringArray DATE_FUNCDESC_WeeksInYear
-{
- ItemList [ en-US ] =
- {
- < "Returns the number of weeks of the year in which the date entered occurs"; > ;
- < "Date"; > ;
- < "Any day in the desired year"; > ;
- };
-};
-
-StringArray DATE_FUNCDESC_Rot13
-{
- ItemList [ en-US ] =
- {
- < "Encrypts or decrypts a text using the ROT13 algorithm"; > ;
- < "Text"; > ;
- < "Text to be encrypted or text already encrypted"; > ;
- };
-};
-
-String DATE_FUNCNAME_DiffWeeks
-{
- Text [ en-US ] = "WEEKS";
-};
-
-String DATE_FUNCNAME_DiffMonths
-{
- Text [ en-US ] = "MONTHS";
-};
-
-String DATE_FUNCNAME_DiffYears
-{
- Text [ en-US ] = "YEARS";
-};
-
-String DATE_FUNCNAME_IsLeapYear
-{
- Text [ en-US ] = "ISLEAPYEAR";
-};
-
-String DATE_FUNCNAME_DaysInMonth
-{
- Text [ en-US ] = "DAYSINMONTH";
-};
-
-String DATE_FUNCNAME_DaysInYear
-{
- Text [ en-US ] = "DAYSINYEAR";
-};
-
-String DATE_FUNCNAME_WeeksInYear
-{
- Text [ en-US ] = "WEEKSINYEAR";
-};
-
-String DATE_FUNCNAME_Rot13
-{
- Text [ en-US ] = "ROT13";
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */