1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <osl/diagnose.h>
21 #include <rtl/ustrbuf.hxx>
22 #include "resourceprovider.hxx"
23 #include <osl/mutex.hxx>
24 #include <vcl/fpicker.hrc>
25 #include <vcl/svapp.hxx>
27 #include <tools/simplerm.hxx>
28 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
29 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
31 //------------------------------------------------------------
32 // namespace directives
33 //------------------------------------------------------------
35 using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds
;
36 using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds
;
38 //------------------------------------------------------------
40 //------------------------------------------------------------
42 #define FOLDERPICKER_TITLE 500
43 #define FOLDER_PICKER_DEF_DESCRIPTION 501
45 //------------------------------------------------------------
46 // we have to translate control ids to resource ids
47 //------------------------------------------------------------
55 _Entry CtrlIdToResIdTable
[] = {
56 { CHECKBOX_AUTOEXTENSION
, STR_SVT_FILEPICKER_AUTO_EXTENSION
},
57 { CHECKBOX_PASSWORD
, STR_SVT_FILEPICKER_PASSWORD
},
58 { CHECKBOX_FILTEROPTIONS
, STR_SVT_FILEPICKER_FILTER_OPTIONS
},
59 { CHECKBOX_READONLY
, STR_SVT_FILEPICKER_READONLY
},
60 { CHECKBOX_LINK
, STR_SVT_FILEPICKER_INSERT_AS_LINK
},
61 { CHECKBOX_PREVIEW
, STR_SVT_FILEPICKER_SHOW_PREVIEW
},
62 { PUSHBUTTON_PLAY
, STR_SVT_FILEPICKER_PLAY
},
63 { LISTBOX_VERSION_LABEL
, STR_SVT_FILEPICKER_VERSION
},
64 { LISTBOX_TEMPLATE_LABEL
, STR_SVT_FILEPICKER_TEMPLATES
},
65 { LISTBOX_IMAGE_TEMPLATE_LABEL
, STR_SVT_FILEPICKER_IMAGE_TEMPLATE
},
66 { CHECKBOX_SELECTION
, STR_SVT_FILEPICKER_SELECTION
},
67 { FOLDERPICKER_TITLE
, STR_SVT_FOLDERPICKER_DEFAULT_TITLE
},
68 { FOLDER_PICKER_DEF_DESCRIPTION
, STR_SVT_FOLDERPICKER_DEFAULT_DESCRIPTION
}
71 const sal_Int32 SIZE_TABLE
= SAL_N_ELEMENTS( CtrlIdToResIdTable
);
73 //------------------------------------------------------------
75 //------------------------------------------------------------
77 sal_Int16
CtrlIdToResId( sal_Int32 aControlId
)
79 sal_Int16 aResId
= -1;
81 for ( sal_Int32 i
= 0; i
< SIZE_TABLE
; i
++ )
83 if ( CtrlIdToResIdTable
[i
].ctrlId
== aControlId
)
85 aResId
= CtrlIdToResIdTable
[i
].resId
;
93 //------------------------------------------------------------
95 //------------------------------------------------------------
97 class CResourceProvider_Impl
101 //-------------------------------------
103 //-------------------------------------
105 CResourceProvider_Impl( )
107 const SolarMutexGuard aGuard
;
108 m_ResMgr
= new SimpleResMgr(
109 "fps_office", Application::GetSettings().GetUILanguageTag());
112 //-------------------------------------
114 //-------------------------------------
116 ~CResourceProvider_Impl( )
121 //-------------------------------------
123 //-------------------------------------
125 OUString
getResString( sal_Int16 aId
)
127 OUString aResOUString
;
131 OSL_ASSERT( m_ResMgr
);
133 // translate the control id to a resource id
134 sal_Int16 aResId
= CtrlIdToResId( aId
);
137 aResOUString
= m_ResMgr
->ReadString( aResId
);
147 SimpleResMgr
* m_ResMgr
;
150 //------------------------------------------------------------
152 //------------------------------------------------------------
154 CResourceProvider::CResourceProvider( ) :
155 m_pImpl( new CResourceProvider_Impl() )
159 //------------------------------------------------------------
161 //------------------------------------------------------------
163 CResourceProvider::~CResourceProvider( )
168 //------------------------------------------------------------
170 //------------------------------------------------------------
172 OUString
CResourceProvider::getResString( sal_Int16 aId
)
174 return m_pImpl
->getResString( aId
);
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */