Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / fpicker / source / aqua / resourceprovider.mm
blobb5ec09532ea2c5906d5d14fbc5895600dd71e2c3
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  */
20 #include <sal/config.h>
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>
31 #include "NSString_OOoAdditions.hxx"
32 #include <fpsofficeResMgr.hxx>
33 #include "resourceprovider.hxx"
35 using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds;
36 using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds;
38 // we have to translate control ids to resource ids
40 struct Entry
42     sal_Int32 ctrlId;
43     const char* resId;
46 struct OldEntry
48     sal_Int32 ctrlId;
49     sal_Int16 resId;
52 Entry const CtrlIdToResIdTable[] = {
53     { CHECKBOX_AUTOEXTENSION,                   STR_SVT_FILEPICKER_AUTO_EXTENSION },
54     { CHECKBOX_PASSWORD,                        STR_SVT_FILEPICKER_PASSWORD },
55     { CHECKBOX_FILTEROPTIONS,                   STR_SVT_FILEPICKER_FILTER_OPTIONS },
56     { CHECKBOX_READONLY,                        STR_SVT_FILEPICKER_READONLY },
57     { CHECKBOX_LINK,                            STR_SVT_FILEPICKER_INSERT_AS_LINK },
58     { CHECKBOX_PREVIEW,                         STR_SVT_FILEPICKER_SHOW_PREVIEW },
59     { PUSHBUTTON_PLAY,                          STR_SVT_FILEPICKER_PLAY },
60     { LISTBOX_VERSION_LABEL,                    STR_SVT_FILEPICKER_VERSION },
61     { LISTBOX_TEMPLATE_LABEL,                   STR_SVT_FILEPICKER_TEMPLATES },
62     { LISTBOX_IMAGE_TEMPLATE_LABEL,             STR_SVT_FILEPICKER_IMAGE_TEMPLATE },
63     { LISTBOX_IMAGE_ANCHOR_LABEL,               STR_SVT_FILEPICKER_IMAGE_ANCHOR },
64     { CHECKBOX_SELECTION,                       STR_SVT_FILEPICKER_SELECTION },
65     { FOLDERPICKER_TITLE,                       STR_SVT_FOLDERPICKER_DEFAULT_TITLE },
66     { FOLDER_PICKER_DEF_DESCRIPTION,            STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION },
67     { FILE_PICKER_OVERWRITE,                    STR_SVT_ALREADYEXISTOVERWRITE },
68     { LISTBOX_FILTER_LABEL,                     STR_SVT_FILEPICKER_FILTER_TITLE},
69     { FILE_PICKER_TITLE_OPEN,                   STR_FILEDLG_OPEN },
70     { FILE_PICKER_TITLE_SAVE,                   STR_FILEDLG_SAVE },
71     { FILE_PICKER_FILE_TYPE,                    STR_FILEDLG_TYPE }
74 const sal_Int32 SIZE_TABLE = SAL_N_ELEMENTS( CtrlIdToResIdTable );
76 static const char* CtrlIdToResId(sal_Int32 aControlId)
78     const char *pResId = nullptr;
80     for ( sal_Int32 i = 0; i < SIZE_TABLE; i++ )
81     {
82         if ( CtrlIdToResIdTable[i].ctrlId == aControlId )
83         {
84             pResId = CtrlIdToResIdTable[i].resId;
85             break;
86         }
87     }
89     return pResId;
92 namespace CResourceProvider_Impl
94     static NSString* getResString(sal_Int16 aId)
95     {
96         OUString aResString;
98         // translate the control id to a resource id
99         const char* pResId = CtrlIdToResId(aId);
100         if (pResId)
101             aResString = FpsResId(pResId);
103         return [NSString stringWithOUString:aResString];
104     }
107 NSString* CResourceProvider::getResString( sal_Int32 aId )
109     NSString* sImmutable = CResourceProvider_Impl::getResString(aId);
110     NSMutableString *sMutableString = [NSMutableString stringWithString:sImmutable];
111     [sMutableString replaceOccurrencesOfString:@"~" withString:@"" options:0 range:NSMakeRange(0, [sMutableString length])];
113     NSString *result = [NSString stringWithString:sMutableString];
115     return result;
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */