LibreOffice Module fpicker (master) 1
resourceprovider.mm
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <osl/diagnose.h>
23#include <rtl/ustrbuf.hxx>
24#include <osl/mutex.hxx>
25#include <fpicker/strings.hrc>
26#include <vcl/svapp.hxx>
27#include <unotools/resmgr.hxx>
28#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
29#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
30
33#include "resourceprovider.hxx"
34
35using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds;
36using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds;
37
38// we have to translate control ids to resource ids
39
40namespace {
41
42struct Entry
43{
44 sal_Int32 ctrlId;
45 TranslateId resId;
46};
47
48}
49
51 { CHECKBOX_AUTOEXTENSION, STR_SVT_FILEPICKER_AUTO_EXTENSION },
52 { CHECKBOX_PASSWORD, STR_SVT_FILEPICKER_PASSWORD },
53 { CHECKBOX_GPGENCRYPTION, STR_SVT_FILEPICKER_GPGENCRYPT },
54 { CHECKBOX_FILTEROPTIONS, STR_SVT_FILEPICKER_FILTER_OPTIONS },
55 { CHECKBOX_READONLY, STR_SVT_FILEPICKER_READONLY },
56 { CHECKBOX_LINK, STR_SVT_FILEPICKER_INSERT_AS_LINK },
57 { CHECKBOX_PREVIEW, STR_SVT_FILEPICKER_SHOW_PREVIEW },
58 { PUSHBUTTON_PLAY, STR_SVT_FILEPICKER_PLAY },
59 { LISTBOX_VERSION_LABEL, STR_SVT_FILEPICKER_VERSION },
60 { LISTBOX_TEMPLATE_LABEL, STR_SVT_FILEPICKER_TEMPLATES },
61 { LISTBOX_IMAGE_TEMPLATE_LABEL, STR_SVT_FILEPICKER_IMAGE_TEMPLATE },
62 { LISTBOX_IMAGE_ANCHOR_LABEL, STR_SVT_FILEPICKER_IMAGE_ANCHOR },
63 { CHECKBOX_SELECTION, STR_SVT_FILEPICKER_SELECTION },
64 { FOLDERPICKER_TITLE, STR_SVT_FOLDERPICKER_DEFAULT_TITLE },
65 { FOLDER_PICKER_DEF_DESCRIPTION, STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION },
66 { FILE_PICKER_OVERWRITE, STR_SVT_ALREADYEXISTOVERWRITE },
67 { LISTBOX_FILTER_LABEL, STR_SVT_FILEPICKER_FILTER_TITLE},
68 { FILE_PICKER_TITLE_OPEN, STR_FILEDLG_OPEN },
69 { FILE_PICKER_TITLE_SAVE, STR_FILEDLG_SAVE },
70 { FILE_PICKER_FILE_TYPE, STR_FILEDLG_TYPE }
71};
72
74
75static TranslateId CtrlIdToResId(sal_Int32 aControlId)
76{
77 TranslateId pResId;
78
79 for ( sal_Int32 i = 0; i < SIZE_TABLE; i++ )
80 {
81 if ( CtrlIdToResIdTable[i].ctrlId == aControlId )
82 {
83 pResId = CtrlIdToResIdTable[i].resId;
84 break;
85 }
86 }
87
88 return pResId;
89}
90
92{
93 static NSString* getResString(sal_Int16 aId)
94 {
95 OUString aResString;
96
97 // translate the control id to a resource id
98 TranslateId pResId = CtrlIdToResId(aId);
99 if (pResId)
100 aResString = FpsResId(pResId);
101
102 return [NSString stringWithOUString:aResString];
103 }
104};
105
106NSString* CResourceProvider::getResString( sal_Int32 aId )
107{
108 NSString* sImmutable = CResourceProvider_Impl::getResString(aId);
109 NSMutableString *sMutableString = [NSMutableString stringWithString:sImmutable];
110 [sMutableString replaceOccurrencesOfString:@"~" withString:@"" options:0 range:NSMakeRange(0, [sMutableString length])];
111
112 NSString *result = [NSString stringWithString:sMutableString];
113
114 return result;
115}
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define FILE_PICKER_TITLE_OPEN
#define FILE_PICKER_OVERWRITE
#define FILE_PICKER_FILE_TYPE
#define FILE_PICKER_TITLE_SAVE
#define FOLDER_PICKER_DEF_DESCRIPTION
#define FOLDERPICKER_TITLE
OUString FpsResId(TranslateId aId)
#define SAL_N_ELEMENTS(arr)
static NSString * getResString(sal_Int16 aId)
NSString * getResString(sal_Int32 aId)
int i
static TranslateId CtrlIdToResId(sal_Int32 aControlId)
const sal_Int32 SIZE_TABLE
Entry const CtrlIdToResIdTable[]
Any result