summaryrefslogtreecommitdiffstats
path: root/fpicker/source/aqua
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-06-11 20:56:30 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-07-21 08:20:50 +0100
commit00657aef09d854c74fb426a935a3e8b1fc390bb0 (patch)
treefd1a9bb264fe15dcc129498e62060ecd256b1ee7 /fpicker/source/aqua
parentosl: Unix pipe converted from OSL_ASSERT to assert/SAL_WARNs (diff)
downloadcore-00657aef09d854c74fb426a935a3e8b1fc390bb0.tar.gz
core-00657aef09d854c74fb426a935a3e8b1fc390bb0.zip
migrate to boost::gettext
* all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
Diffstat (limited to 'fpicker/source/aqua')
-rw-r--r--fpicker/source/aqua/resourceprovider.hxx8
-rw-r--r--fpicker/source/aqua/resourceprovider.mm100
2 files changed, 20 insertions, 88 deletions
diff --git a/fpicker/source/aqua/resourceprovider.hxx b/fpicker/source/aqua/resourceprovider.hxx
index 63fb47e8ad5f..44454c8e0954 100644
--- a/fpicker/source/aqua/resourceprovider.hxx
+++ b/fpicker/source/aqua/resourceprovider.hxx
@@ -38,18 +38,10 @@
#define FILE_PICKER_FILE_TYPE 504
#define FILE_PICKER_OVERWRITE 505
-class CResourceProvider_Impl;
-
class CResourceProvider
{
public:
- CResourceProvider( );
- ~CResourceProvider( );
-
NSString* getResString( sal_Int32 aId );
-
-private:
- std::unique_ptr<CResourceProvider_Impl> m_pImpl;
};
#endif
diff --git a/fpicker/source/aqua/resourceprovider.mm b/fpicker/source/aqua/resourceprovider.mm
index f1c9023a1cfd..6942d0fe9fda 100644
--- a/fpicker/source/aqua/resourceprovider.mm
+++ b/fpicker/source/aqua/resourceprovider.mm
@@ -23,29 +23,31 @@
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
#include <osl/mutex.hxx>
-#include <vcl/fpicker.hrc>
+#include <fpicker/fpicker.hrc>
#include <vcl/svapp.hxx>
#include <tools/resmgr.hxx>
#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
-#include <svtools/filedlg2.hrc>
#include "NSString_OOoAdditions.hxx"
-
+#include "fpsofficeResMgr.hxx"
#include "resourceprovider.hxx"
using rtl::OUString;
using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds;
using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds;
-static const char* const RES_NAME = "fps_office";
-static const char* const OTHER_RES_NAME = "svt";
-
// we have to translate control ids to resource ids
struct Entry
{
sal_Int32 ctrlId;
+ const char* resId;
+};
+
+struct OldEntry
+{
+ sal_Int32 ctrlId;
sal_Int16 resId;
};
@@ -64,110 +66,48 @@ Entry const CtrlIdToResIdTable[] = {
{ FOLDERPICKER_TITLE, STR_SVT_FOLDERPICKER_DEFAULT_TITLE },
{ FOLDER_PICKER_DEF_DESCRIPTION, STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION },
{ FILE_PICKER_OVERWRITE, STR_SVT_ALREADYEXISTOVERWRITE },
- { LISTBOX_FILTER_LABEL, STR_SVT_FILEPICKER_FILTER_TITLE}
-};
-
-Entry const OtherCtrlIdToResIdTable[] = {
+ { LISTBOX_FILTER_LABEL, STR_SVT_FILEPICKER_FILTER_TITLE},
{ FILE_PICKER_TITLE_OPEN, STR_FILEDLG_OPEN },
{ FILE_PICKER_TITLE_SAVE, STR_FILEDLG_SAVE },
{ FILE_PICKER_FILE_TYPE, STR_FILEDLG_TYPE }
};
const sal_Int32 SIZE_TABLE = SAL_N_ELEMENTS( CtrlIdToResIdTable );
-const sal_Int32 OTHER_SIZE_TABLE = SAL_N_ELEMENTS( OtherCtrlIdToResIdTable );
-sal_Int16 CtrlIdToResId( sal_Int32 aControlId )
+const char* CtrlIdToResId(sal_Int32 aControlId)
{
- sal_Int16 aResId = -1;
+ const char *pResId = nullptr;
for ( sal_Int32 i = 0; i < SIZE_TABLE; i++ )
{
if ( CtrlIdToResIdTable[i].ctrlId == aControlId )
{
- aResId = CtrlIdToResIdTable[i].resId;
- break;
- }
- }
-
- return aResId;
-}
-
-sal_Int16 OtherCtrlIdToResId( sal_Int32 aControlId )
-{
- sal_Int16 aResId = -1;
-
- for ( sal_Int32 i = 0; i < OTHER_SIZE_TABLE; i++ )
- {
- if ( OtherCtrlIdToResIdTable[i].ctrlId == aControlId )
- {
- aResId = OtherCtrlIdToResIdTable[i].resId;
+ pResId = CtrlIdToResIdTable[i].resId;
break;
}
}
- return aResId;
+ return pResId;
}
-class CResourceProvider_Impl
+namespace CResourceProvider_Impl
{
-public:
- CResourceProvider_Impl( )
- {
- m_ResMgr = ResMgr::CreateResMgr( RES_NAME );
- m_OtherResMgr = ResMgr::CreateResMgr( OTHER_RES_NAME );
- }
-
- ~CResourceProvider_Impl( )
- {
- delete m_ResMgr;
- delete m_OtherResMgr;
- }
-
- NSString* getResString( sal_Int16 aId )
+ NSString* getResString(sal_Int16 aId)
{
OUString aResString;
- const SolarMutexGuard aGuard;
-
- try
- {
- OSL_ASSERT( m_ResMgr && m_OtherResMgr );
-
- // translate the control id to a resource id
- sal_Int16 aResId = CtrlIdToResId( aId );
- if ( aResId > -1 )
- aResString = ResId( aResId, *m_ResMgr );
- else
- {
- aResId = OtherCtrlIdToResId( aId );
- if ( aResId > -1 ) {
- aResString = ResId( aResId, *m_OtherResMgr );
- }
- }
- }
- catch(...)
- {
- }
+ // translate the control id to a resource id
+ const char* pResId = CtrlIdToResId(aId);
+ if (pResId)
+ aResString = FpsResId(pResId);
return [NSString stringWithOUString:aResString];
}
-
-public:
- ResMgr* m_ResMgr;
- ResMgr* m_OtherResMgr;
};
-CResourceProvider::CResourceProvider( ) :
- m_pImpl( o3tl::make_unique<CResourceProvider_Impl>() )
-{
-}
-
-CResourceProvider::~CResourceProvider( )
-{}
-
NSString* CResourceProvider::getResString( sal_Int32 aId )
{
- NSString* sImmutable = m_pImpl->getResString( aId );
+ NSString* sImmutable = CResourceProvider_Impl::getResString(aId);
NSMutableString *sMutableString = [NSMutableString stringWithString:sImmutable];
[sMutableString replaceOccurrencesOfString:@"~" withString:@"" options:0 range:NSMakeRange(0, [sMutableString length])];