update emoji autocorrect entries from po-files
[LibreOffice.git] / fpicker / source / office / OfficeFolderPicker.cxx
blob8f524856884c38a84043d5fd200e57e37ee1f125
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 "OfficeFolderPicker.hxx"
22 #include "iodlg.hxx"
24 #include <list>
25 #include <tools/urlobj.hxx>
26 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
27 #include <com/sun/star/container/XSet.hpp>
28 #include <com/sun/star/uno/Any.hxx>
29 #include <cppuhelper/factory.hxx>
30 #include <cppuhelper/supportsservice.hxx>
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <unotools/pathoptions.hxx>
34 using namespace ::com::sun::star::container;
35 using namespace ::com::sun::star::lang;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::beans;
39 SvtFolderPicker::SvtFolderPicker( const Reference < XMultiServiceFactory >& _rxFactory )
40 :SvtFolderPicker_Base( _rxFactory )
44 SvtFolderPicker::~SvtFolderPicker()
48 void SAL_CALL SvtFolderPicker::setTitle( const OUString& _rTitle ) throw (RuntimeException, std::exception)
50 OCommonPicker::setTitle( _rTitle );
53 sal_Int16 SAL_CALL SvtFolderPicker::execute( ) throw (RuntimeException, std::exception)
55 return OCommonPicker::execute();
58 void SAL_CALL SvtFolderPicker::setDialogTitle( const OUString& _rTitle) throw (RuntimeException, std::exception)
60 setTitle( _rTitle );
63 void SAL_CALL SvtFolderPicker::startExecuteModal( const Reference< ::com::sun::star::ui::dialogs::XDialogClosedListener >& xListener ) throw (RuntimeException, std::exception)
65 m_xListener = xListener;
66 prepareDialog();
67 prepareExecute();
68 getDialog()->EnableAutocompletion( true );
69 getDialog()->StartExecuteModal( LINK( this, SvtFolderPicker, DialogClosedHdl ) );
72 VclPtr<SvtFileDialog> SvtFolderPicker::implCreateDialog( vcl::Window* _pParent )
74 return VclPtr<SvtFileDialog>::Create( _pParent, SFXWB_PATHDIALOG );
77 sal_Int16 SvtFolderPicker::implExecutePicker( )
79 prepareExecute();
81 // now we are ready to execute the dialog
82 getDialog()->EnableAutocompletion( false );
83 sal_Int16 nRet = getDialog()->Execute();
85 return nRet;
88 void SvtFolderPicker::prepareExecute()
90 // set the default directory
91 if ( !m_aDisplayDirectory.isEmpty() )
92 getDialog()->SetPath( m_aDisplayDirectory );
93 else
95 // Default-Standard-Dir setzen
96 INetURLObject aStdDirObj( SvtPathOptions().GetWorkPath() );
97 getDialog()->SetPath( aStdDirObj.GetMainURL( INetURLObject::NO_DECODE) );
101 IMPL_LINK( SvtFolderPicker, DialogClosedHdl, Dialog*, pDlg )
103 if ( m_xListener.is() )
105 sal_Int16 nRet = static_cast< sal_Int16 >( pDlg->GetResult() );
106 ::com::sun::star::ui::dialogs::DialogClosedEvent aEvent( *this, nRet );
107 m_xListener->dialogClosed( aEvent );
108 m_xListener.clear();
110 return 0;
113 void SAL_CALL SvtFolderPicker::setDisplayDirectory( const OUString& aDirectory )
114 throw( IllegalArgumentException, RuntimeException, std::exception )
116 m_aDisplayDirectory = aDirectory;
119 OUString SAL_CALL SvtFolderPicker::getDisplayDirectory() throw( RuntimeException, std::exception )
121 if ( ! getDialog() )
122 return m_aDisplayDirectory;
124 std::vector<OUString> aPathList(getDialog()->GetPathList());
126 if(!aPathList.empty())
127 return aPathList[0];
129 return OUString();
132 OUString SAL_CALL SvtFolderPicker::getDirectory() throw( RuntimeException, std::exception )
134 if ( ! getDialog() )
135 return m_aDisplayDirectory;
137 std::vector<OUString> aPathList(getDialog()->GetPathList());
139 if(!aPathList.empty())
140 return aPathList[0];
142 return OUString();
145 void SAL_CALL SvtFolderPicker::setDescription( const OUString& aDescription )
146 throw( RuntimeException, std::exception )
148 m_aDescription = aDescription;
151 void SvtFolderPicker::cancel() throw (RuntimeException, std::exception)
153 OCommonPicker::cancel();
156 /* XServiceInfo */
157 OUString SAL_CALL SvtFolderPicker::getImplementationName() throw( RuntimeException, std::exception )
159 return impl_getStaticImplementationName();
162 /* XServiceInfo */
163 sal_Bool SAL_CALL SvtFolderPicker::supportsService( const OUString& sServiceName ) throw( RuntimeException, std::exception )
165 return cppu::supportsService(this, sServiceName);
168 /* XServiceInfo */
169 Sequence< OUString > SAL_CALL SvtFolderPicker::getSupportedServiceNames() throw( RuntimeException, std::exception )
171 return impl_getStaticSupportedServiceNames();
174 /* Helper for XServiceInfo */
175 Sequence< OUString > SvtFolderPicker::impl_getStaticSupportedServiceNames()
177 Sequence< OUString > seqServiceNames(1);
178 seqServiceNames[0] = "com.sun.star.ui.dialogs.OfficeFolderPicker";
179 return seqServiceNames ;
182 /* Helper for XServiceInfo */
183 OUString SvtFolderPicker::impl_getStaticImplementationName()
185 return OUString( "com.sun.star.svtools.OfficeFolderPicker" );
188 /* Helper for registry */
189 Reference< XInterface > SAL_CALL SvtFolderPicker::impl_createInstance( const Reference< XComponentContext >& rxContext )
190 throw( Exception )
192 Reference< XMultiServiceFactory > xServiceManager (rxContext->getServiceManager(), UNO_QUERY_THROW);
193 return Reference< XInterface >( *new SvtFolderPicker( xServiceManager ) );
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */