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 <rtl/ustring.hxx>
22 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
24 #include <svl/pickerhistoryaccess.hxx>
25 #include <officecfg/Office/Common.hxx>
27 #include <vcl/svapp.hxx>
29 #include "fpicker.hxx"
31 using css::uno::Reference
;
32 using css::uno::Sequence
;
35 * FilePicker implementation.
37 static OUString
FilePicker_getSystemPickerServiceName()
40 OUString
aDesktopEnvironment (Application::GetDesktopEnvironment());
41 if (aDesktopEnvironment
.equalsIgnoreAsciiCase("macosx"))
42 return "com.sun.star.ui.dialogs.AquaFilePicker";
44 return "com.sun.star.ui.dialogs.SystemFilePicker";
47 return "com.sun.star.ui.dialogs.Win32FilePicker";
51 Reference
< css::uno::XInterface
> FilePicker_CreateInstance (
52 Reference
< css::uno::XComponentContext
> const & context
)
54 Reference
< css::uno::XInterface
> xResult
;
59 Reference
< css::lang::XMultiComponentFactory
> xFactory (context
->getServiceManager());
60 if (xFactory
.is() && officecfg::Office::Common::Misc::UseSystemFileDialog::get())
62 xResult
.set( Application::createFilePicker( context
) );
68 xResult
= xFactory
->createInstanceWithContext (
69 FilePicker_getSystemPickerServiceName(),
72 catch (css::uno::Exception
const &)
74 // Handled below (see @ fallback).
80 if (!xResult
.is() && xFactory
.is())
82 // Always fall back to OfficeFilePicker.
83 xResult
= xFactory
->createInstanceWithContext (
84 "com.sun.star.ui.dialogs.OfficeFilePicker",
89 // Add to FilePicker history.
90 svt::addFilePicker (xResult
);
95 OUString
FilePicker_getImplementationName()
97 return "com.sun.star.comp.svt.FilePicker";
100 Sequence
< OUString
> FilePicker_getSupportedServiceNames()
102 Sequence
< OUString
> aServiceNames
{ "com.sun.star.ui.dialogs.FilePicker" };
103 return aServiceNames
;
107 * FolderPicker implementation.
109 static OUString
FolderPicker_getSystemPickerServiceName()
112 OUString
aDesktopEnvironment (Application::GetDesktopEnvironment());
113 if (aDesktopEnvironment
.equalsIgnoreAsciiCase("macosx"))
114 return "com.sun.star.ui.dialogs.AquaFolderPicker";
116 return "com.sun.star.ui.dialogs.SystemFolderPicker";
119 Reference
< css::uno::XInterface
> FolderPicker_CreateInstance (
120 Reference
< css::uno::XComponentContext
> const & context
)
122 Reference
< css::uno::XInterface
> xResult
;
127 Reference
< css::lang::XMultiComponentFactory
> xFactory (context
->getServiceManager());
128 if (xFactory
.is() && officecfg::Office::Common::Misc::UseSystemFileDialog::get())
130 xResult
.set( Application::createFolderPicker( context
) );
135 xResult
= xFactory
->createInstanceWithContext (
136 FolderPicker_getSystemPickerServiceName(),
139 catch (css::uno::Exception
const &)
141 // Handled below (see @ fallback).
145 if (!xResult
.is() && xFactory
.is() )
147 // Always fall back to OfficeFolderPicker.
148 xResult
= xFactory
->createInstanceWithContext (
149 "com.sun.star.ui.dialogs.OfficeFolderPicker",
154 // Add to FolderPicker history.
155 svt::addFolderPicker (xResult
);
160 OUString
FolderPicker_getImplementationName()
162 return "com.sun.star.comp.svt.FolderPicker";
165 Sequence
< OUString
> FolderPicker_getSupportedServiceNames()
167 Sequence
< OUString
> aServiceNames
{ "com.sun.star.ui.dialogs.FolderPicker" };
168 return aServiceNames
;
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */