GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / svtools / source / uno / fpicker.cxx
blob397f661840b5f30bff45fdb168420114ae72dbed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "sal/types.h"
21 #include "rtl/ustring.hxx"
23 #include "com/sun/star/lang/XMultiComponentFactory.hpp"
25 #include "svtools/miscopt.hxx"
26 #include "svl/pickerhistoryaccess.hxx"
28 #include "vcl/svapp.hxx"
30 using css::uno::Reference;
31 using css::uno::Sequence;
34 * FilePicker implementation.
36 static OUString FilePicker_getSystemPickerServiceName()
38 #ifdef UNX
39 OUString aDesktopEnvironment (Application::GetDesktopEnvironment());
40 if (aDesktopEnvironment.equalsIgnoreAsciiCase("tde"))
41 return OUString ("com.sun.star.ui.dialogs.TDEFilePicker");
42 else if (aDesktopEnvironment.equalsIgnoreAsciiCase("kde"))
43 return OUString ("com.sun.star.ui.dialogs.KDEFilePicker");
44 else if (aDesktopEnvironment.equalsIgnoreAsciiCase("kde4"))
45 return OUString ("com.sun.star.ui.dialogs.KDE4FilePicker");
46 else if (aDesktopEnvironment.equalsIgnoreAsciiCase("macosx"))
47 return OUString ("com.sun.star.ui.dialogs.AquaFilePicker");
48 else
49 return OUString ("com.sun.star.ui.dialogs.SystemFilePicker");
50 #endif
51 #ifdef WNT
52 return OUString ("com.sun.star.ui.dialogs.Win32FilePicker");
53 #endif
56 Reference< css::uno::XInterface > FilePicker_CreateInstance (
57 Reference< css::uno::XComponentContext > const & rxContext)
59 Reference< css::uno::XInterface > xResult;
61 if (!rxContext.is())
62 return xResult;
64 Reference< css::lang::XMultiComponentFactory > xFactory (rxContext->getServiceManager());
65 if (xFactory.is() && SvtMiscOptions().UseSystemFileDialog())
67 xResult = Reference< css::uno::XInterface >( Application::createFilePicker( rxContext ) );
69 if (!xResult.is())
71 try
73 xResult = xFactory->createInstanceWithContext (
74 FilePicker_getSystemPickerServiceName(),
75 rxContext);
77 catch (css::uno::Exception const &)
79 // Handled below (see @ fallback).
85 if (!xResult.is() && xFactory.is())
87 // Always fall back to OfficeFilePicker.
88 xResult = xFactory->createInstanceWithContext (
89 OUString( "com.sun.star.ui.dialogs.OfficeFilePicker"),
90 rxContext);
92 if (xResult.is())
94 // Add to FilePicker history.
95 svt::addFilePicker (xResult);
97 return xResult;
100 OUString SAL_CALL FilePicker_getImplementationName()
102 return OUString("com.sun.star.comp.svt.FilePicker");
105 Sequence< OUString > FilePicker_getSupportedServiceNames()
107 Sequence< OUString > aServiceNames(1);
108 aServiceNames.getArray()[0] =
109 OUString( "com.sun.star.ui.dialogs.FilePicker");
110 return aServiceNames;
114 * FolderPicker implementation.
116 static OUString FolderPicker_getSystemPickerServiceName()
118 OUString aDesktopEnvironment (Application::GetDesktopEnvironment());
119 #ifdef UNX
120 if (aDesktopEnvironment.equalsIgnoreAsciiCase("tde"))
121 return OUString("com.sun.star.ui.dialogs.TDEFolderPicker");
122 else if (aDesktopEnvironment.equalsIgnoreAsciiCase("kde"))
123 return OUString("com.sun.star.ui.dialogs.KDEFolderPicker");
124 else if (aDesktopEnvironment.equalsIgnoreAsciiCase("macosx"))
125 return OUString("com.sun.star.ui.dialogs.AquaFolderPicker");
126 #endif
127 return OUString("com.sun.star.ui.dialogs.SystemFolderPicker");
130 Reference< css::uno::XInterface > FolderPicker_CreateInstance (
131 Reference< css::uno::XComponentContext > const & rxContext)
133 Reference< css::uno::XInterface > xResult;
135 if (!rxContext.is())
136 return xResult;
138 Reference< css::lang::XMultiComponentFactory > xFactory (rxContext->getServiceManager());
139 if (xFactory.is() && SvtMiscOptions().UseSystemFileDialog())
141 xResult = Reference< css::uno::XInterface >( Application::createFolderPicker( rxContext ) );
142 if (!xResult.is())
146 xResult = xFactory->createInstanceWithContext (
147 FolderPicker_getSystemPickerServiceName(),
148 rxContext);
150 catch (css::uno::Exception const &)
152 // Handled below (see @ fallback).
156 if (!xResult.is() && xFactory.is() )
158 // Always fall back to OfficeFolderPicker.
159 xResult = xFactory->createInstanceWithContext (
160 OUString( "com.sun.star.ui.dialogs.OfficeFolderPicker"),
161 rxContext);
163 if (xResult.is())
165 // Add to FolderPicker history.
166 svt::addFolderPicker (xResult);
168 return xResult;
171 OUString SAL_CALL FolderPicker_getImplementationName()
173 return OUString("com.sun.star.comp.svt.FolderPicker");
176 Sequence< OUString > FolderPicker_getSupportedServiceNames()
178 Sequence< OUString > aServiceNames(1);
179 aServiceNames.getArray()[0] =
180 OUString( "com.sun.star.ui.dialogs.FolderPicker");
181 return aServiceNames;
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */