Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <osl/diagnose.h>
30 : : #include <vcl/svapp.hxx>
31 : : #include <tools/resmgr.hxx>
32 : : #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
33 : : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
34 : :
35 : : #include "svids.hrc"
36 : : #include "svdata.hxx"
37 : : #include "gtk/fpicker/SalGtkPicker.hxx"
38 : :
39 : : using namespace ::com::sun::star::ui::dialogs::ExtendedFilePickerElementIds;
40 : : using namespace ::com::sun::star::ui::dialogs::CommonFilePickerElementIds;
41 : :
42 : : //---------------------------------------
43 : : // translate control ids to resource ids
44 : : //---------------------------------------
45 : : static const struct
46 : : {
47 : : sal_Int32 ctrlId;
48 : : sal_Int16 resId;
49 : : } CtrlIdToResIdTable[] = {
50 : : { CHECKBOX_AUTOEXTENSION, STR_FPICKER_AUTO_EXTENSION },
51 : : { CHECKBOX_PASSWORD, STR_FPICKER_PASSWORD },
52 : : { CHECKBOX_FILTEROPTIONS, STR_FPICKER_FILTER_OPTIONS },
53 : : { CHECKBOX_READONLY, STR_FPICKER_READONLY },
54 : : { CHECKBOX_LINK, STR_FPICKER_INSERT_AS_LINK },
55 : : { CHECKBOX_PREVIEW, STR_FPICKER_SHOW_PREVIEW },
56 : : { PUSHBUTTON_PLAY, STR_FPICKER_PLAY },
57 : : { LISTBOX_VERSION_LABEL, STR_FPICKER_VERSION },
58 : : { LISTBOX_TEMPLATE_LABEL, STR_FPICKER_TEMPLATES },
59 : : { LISTBOX_IMAGE_TEMPLATE_LABEL, STR_FPICKER_IMAGE_TEMPLATE },
60 : : { CHECKBOX_SELECTION, STR_FPICKER_SELECTION },
61 : : { FOLDERPICKER_TITLE, STR_FPICKER_FOLDER_DEFAULT_TITLE },
62 : : { FOLDER_PICKER_DEF_DESCRIPTION, STR_FPICKER_FOLDER_DEFAULT_DESCRIPTION },
63 : : { FILE_PICKER_OVERWRITE, STR_FPICKER_ALREADYEXISTOVERWRITE },
64 : : { FILE_PICKER_ALLFORMATS, STR_FPICKER_ALLFORMATS },
65 : : { FILE_PICKER_TITLE_OPEN, STR_FPICKER_OPEN },
66 : : { FILE_PICKER_TITLE_SAVE, STR_FPICKER_SAVE },
67 : : { FILE_PICKER_FILE_TYPE, STR_FPICKER_TYPE }
68 : : };
69 : :
70 : 0 : static sal_Int16 CtrlIdToResId( sal_Int32 aControlId )
71 : : {
72 : 0 : for ( size_t i = 0; i < SAL_N_ELEMENTS( CtrlIdToResIdTable ); i++ )
73 : : {
74 : 0 : if ( CtrlIdToResIdTable[i].ctrlId == aControlId )
75 : 0 : return CtrlIdToResIdTable[i].resId;
76 : : }
77 : 0 : return -1;
78 : : }
79 : :
80 : 0 : rtl::OUString SalGtkPicker::getResString( sal_Int32 aId )
81 : : {
82 : 0 : rtl::OUString aResString;
83 : : try
84 : : {
85 : : // translate the control id to a resource id
86 : 0 : sal_Int16 aResId = CtrlIdToResId( aId );
87 : 0 : if ( aResId > -1 )
88 : 0 : aResString = ResId(aResId, *ImplGetResMgr()).toString();
89 : : }
90 : 0 : catch(...)
91 : : {
92 : : }
93 : :
94 : 0 : return aResString.replace('~', '_');
95 : : }
96 : :
97 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|