diff options
author | Jan Holesovsky <kendy@suse.cz> | 2010-08-25 17:44:01 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2010-08-26 12:54:36 +0200 |
commit | 98b7a3b0b8da3e9ff2d79decd3f5bb98b82cbef2 (patch) | |
tree | 15df735bf82747be989f68203a3408b72f2a73ce /fpicker/source/unx | |
parent | 6c75d3fc11fbed2132d797456479501193c637f0 (diff) |
fpicker-kde-service.diff: Out-of-process implementation of KDE3 fpicker.
Diffstat (limited to 'fpicker/source/unx')
-rw-r--r-- | fpicker/source/unx/kde_unx/FPServiceInfo.hxx | 44 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxCommandThread.cxx | 311 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxCommandThread.hxx | 92 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxFPentry.cxx | 124 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxFilePicker.cxx | 895 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxFilePicker.hxx | 171 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxNotifyThread.cxx | 112 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/UnxNotifyThread.hxx | 86 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/fps-kde-ucd.txt | 6 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/fps_kde.xml | 51 | ||||
-rw-r--r-- | fpicker/source/unx/kde_unx/makefile.mk | 78 |
11 files changed, 1970 insertions, 0 deletions
diff --git a/fpicker/source/unx/kde_unx/FPServiceInfo.hxx b/fpicker/source/unx/kde_unx/FPServiceInfo.hxx new file mode 100644 index 000000000000..e4ea5663e85b --- /dev/null +++ b/fpicker/source/unx/kde_unx/FPServiceInfo.hxx @@ -0,0 +1,44 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2010 Novell, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _FPSERVICEINFO_HXX_ +#define _FPSERVICEINFO_HXX_ + +// the service names +#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.KDEFilePicker" + +// the implementation names +#define FILE_PICKER_IMPL_NAME "com.sun.star.ui.dialogs.UnxFilePicker" + +// the registry key names +// a key under which this service will be registered, +// Format: -> "/ImplName/UNO/SERVICES/ServiceName" +// <Implementation-Name></UNO/SERVICES/><Service-Name> +#define FILE_PICKER_REGKEY_NAME "/com.sun.star.ui.dialogs.UnxFilePicker/UNO/SERVICES/com.sun.star.ui.dialogs.KDEFilePicker" + +#endif diff --git a/fpicker/source/unx/kde_unx/UnxCommandThread.cxx b/fpicker/source/unx/kde_unx/UnxCommandThread.cxx new file mode 100644 index 000000000000..9f577d824ac5 --- /dev/null +++ b/fpicker/source/unx/kde_unx/UnxCommandThread.cxx @@ -0,0 +1,311 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2010 Novell, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <UnxCommandThread.hxx> +#include <UnxNotifyThread.hxx> + +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> + +#include <unistd.h> +#include <string.h> +#include <iostream> + +using namespace ::com::sun::star; + +////////////////////////////////////////////////////////////////////////// +// UnxFilePickerCommandThread +////////////////////////////////////////////////////////////////////////// + +UnxFilePickerCommandThread::UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD ) + : m_pNotifyThread( pNotifyThread ), + m_nReadFD( nReadFD ) +{ +} + +UnxFilePickerCommandThread::~UnxFilePickerCommandThread() +{ +} + +sal_Bool SAL_CALL UnxFilePickerCommandThread::result() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_aResult; +} + +::rtl::OUString SAL_CALL UnxFilePickerCommandThread::getCurrentFilter() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_aGetCurrentFilter; +} + +::rtl::OUString SAL_CALL UnxFilePickerCommandThread::getDirectory() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_aGetDirectory; +} + +uno::Sequence< ::rtl::OUString > SAL_CALL UnxFilePickerCommandThread::getFiles() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + sal_Int32 nSize = m_aGetFiles.size(); + uno::Sequence< ::rtl::OUString > aFiles( ( nSize > 1 )? nSize + 1: nSize ); + + if ( nSize == 1 ) + aFiles[0] = m_aGetFiles.front(); + else if ( nSize > 1 ) + { + // First entry in the sequence must be the dirname, the others are the + // filenames, so we have to rearrange the list... + + ::rtl::OUString aFront = m_aGetFiles.front(); + sal_Int32 nLastSlash = aFront.lastIndexOf( '/' ); + + aFiles[0] = ( nLastSlash >= 0 )? aFront.copy( 0, nLastSlash ): ::rtl::OUString(); + ++nLastSlash; + + sal_Int32 nIdx = 1; + for ( ::std::list< ::rtl::OUString >::const_iterator it = m_aGetFiles.begin(); + it != m_aGetFiles.end(); ++it, ++nIdx ) + { + sal_Int32 nLength = (*it).getLength() - nLastSlash; + aFiles[nIdx] = ( nLength >= 0 )? (*it).copy( nLastSlash, nLength ): ::rtl::OUString(); + } + } + + return aFiles; +} + +uno::Any SAL_CALL UnxFilePickerCommandThread::getValue() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_aGetValue; +} + +void SAL_CALL UnxFilePickerCommandThread::run() +{ + if ( m_nReadFD < 0 ) + return; + + sal_Int32 nBufferSize = 1024; // 1 is for testing, 1024 for real use + sal_Char *pBuffer = new sal_Char[nBufferSize]; + sal_Char *pBufferEnd = pBuffer + nBufferSize; + + sal_Char *pWhereToRead = pBuffer; + sal_Char *pEntryBegin = pBuffer; + sal_Int32 nBytesRead = 0; + sal_Bool bShouldExit = sal_False; + while ( !bShouldExit && ( nBytesRead = read( m_nReadFD, pWhereToRead, pBufferEnd - pWhereToRead ) ) > 0 ) + { + sal_Bool bFoundNL = sal_False; + sal_Char *pWhereToReadEnd = pWhereToRead + nBytesRead; + sal_Char *pEntryEnd = pWhereToRead; + do { + for ( ; pEntryEnd < pWhereToReadEnd && *pEntryEnd != '\n'; ++pEntryEnd ) + ; + + if ( pEntryEnd < pWhereToReadEnd ) + { + bFoundNL = sal_True; + *pEntryEnd = 0; + + if ( strcmp( pEntryBegin, "exited" ) == 0 ) + bShouldExit = sal_True; + else + handleCommand( ::rtl::OUString( pEntryBegin, pEntryEnd - pEntryBegin, RTL_TEXTENCODING_UTF8 )/*, bQuit*/ ); + + pEntryBegin = pEntryEnd + 1; + } + } while ( pEntryEnd < pWhereToReadEnd ); + + if ( bFoundNL ) + { + if ( pEntryBegin < pBufferEnd ) + memmove( pBuffer, pEntryBegin, pWhereToReadEnd - pEntryBegin ); + } + else + { + // enlarge the buffer size + nBufferSize *= 2; + sal_Char *pNewBuffer = new sal_Char[nBufferSize]; + if ( pEntryBegin < pBufferEnd ) + memmove( pNewBuffer, pEntryBegin, pWhereToReadEnd - pEntryBegin ); + + delete[] pBuffer; + pBuffer = pNewBuffer; + pBufferEnd = pBuffer + nBufferSize; + } + + pWhereToRead = pBuffer + ( pWhereToReadEnd - pEntryBegin ); + pEntryBegin = pBuffer; + } +} + +void SAL_CALL UnxFilePickerCommandThread::handleCommand( const ::rtl::OUString &rCommand ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + +#if OSL_DEBUG_LEVEL > 0 + ::std::cerr << "UnxFilePicker received: \"" << + OUStringToOString( rCommand, RTL_TEXTENCODING_ASCII_US ).getStr() << "\"" << ::std::endl; +#endif + + ::std::list< ::rtl::OUString > aList = tokenize( rCommand ); + + if ( aList.size() == 0 ) + return; + + ::rtl::OUString aCommandName = aList.front(); + aList.pop_front(); + + if ( aCommandName.equalsAscii( "accept" ) ) + { + m_aResult = sal_True; + m_aExecCondition.set(); + } + else if ( aCommandName.equalsAscii( "reject" ) ) + { + m_aResult = sal_False; + m_aExecCondition.set(); + } + else if ( aCommandName.equalsAscii( "fileSelectionChanged" ) ) + { + if ( m_pNotifyThread ) + m_pNotifyThread->fileSelectionChanged(); + } + else if ( aCommandName.equalsAscii( "files" ) ) + { + m_aGetFiles = aList; + m_aGetFilesCondition.set(); + } + else if ( aCommandName.equalsAscii( "value" ) ) + { + ::rtl::OUString aType; + if ( !aList.empty() ) + { + aType = aList.front(); + aList.pop_front(); + } + + if ( aType.equalsAscii( "bool" ) ) + { + sal_Bool bValue = !aList.empty() && aList.front().equalsIgnoreAsciiCaseAscii( "true" ); + + m_aGetValue <<= bValue; + m_aGetValueCondition.set(); + } + else if ( aType.equalsAscii( "int" ) ) + { + sal_Int32 nValue = 0; + if ( !aList.empty() ) + nValue = aList.front().toInt32(); + + m_aGetValue <<= nValue; + m_aGetValueCondition.set(); + } + else if ( aType.equalsAscii( "string" ) ) + { + ::rtl::OUString aValue; + if ( !aList.empty() ) + aValue = aList.front(); + + m_aGetValue <<= aValue; + m_aGetValueCondition.set(); + } + else if ( aType.equalsAscii( "stringList" ) ) + { + uno::Sequence< ::rtl::OUString > aSequence( aList.size() ); + sal_Int32 nIdx = 0; + for ( ::std::list< ::rtl::OUString >::const_iterator it = aList.begin(); it != aList.end(); ++it, ++nIdx ) + aSequence[nIdx] = (*it); + + m_aGetValue <<= aSequence; + m_aGetValueCondition.set(); + } + else + { + m_aGetValue = uno::Any(); + m_aGetValueCondition.set(); + } + } + else if ( aCommandName.equalsAscii( "currentFilter" ) ) + { + m_aGetCurrentFilter = aList.empty()? ::rtl::OUString(): aList.front(); + m_aGetCurrentFilterCondition.set(); + } + else if ( aCommandName.equalsAscii( "currentDirectory" ) ) + { + m_aGetDirectory = aList.empty()? ::rtl::OUString(): aList.front(); + m_aGetDirectoryCondition.set(); + } + else + { +#if OSL_DEBUG_LEVEL > 0 + ::std::cerr << "Unrecognized command: " + << OUStringToOString( aCommandName, RTL_TEXTENCODING_ASCII_US ).getStr() << "\"" << ::std::endl; +#endif + } +} + +::std::list< ::rtl::OUString > SAL_CALL UnxFilePickerCommandThread::tokenize( const ::rtl::OUString &rCommand ) +{ + ::std::list< ::rtl::OUString > aList; + ::rtl::OUStringBuffer aBuffer( 1024 ); + + const sal_Unicode *pUnicode = rCommand.getStr(); + const sal_Unicode *pEnd = pUnicode + rCommand.getLength(); + sal_Bool bQuoted = sal_False; + + for ( ; pUnicode != pEnd; ++pUnicode ) + { + if ( *pUnicode == '\\' ) + { + ++pUnicode; + if ( pUnicode != pEnd ) + { + if ( *pUnicode == 'n' ) + aBuffer.appendAscii( "\n", 1 ); + else + aBuffer.append( *pUnicode ); + } + } + else if ( *pUnicode == '"' ) + bQuoted = !bQuoted; + else if ( *pUnicode == ' ' && !bQuoted ) + aList.push_back( aBuffer.makeStringAndClear() ); + else + aBuffer.append( *pUnicode ); + } + aList.push_back( aBuffer.makeStringAndClear() ); + + return aList; +} diff --git a/fpicker/source/unx/kde_unx/UnxCommandThread.hxx b/fpicker/source/unx/kde_unx/UnxCommandThread.hxx new file mode 100644 index 000000000000..14e8d3ab9629 --- /dev/null +++ b/fpicker/source/unx/kde_unx/UnxCommandThread.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2010 Novell, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNXCOMMANDTHREAD_HXX_ +#define _UNXCOMMANDTHREAD_HXX_ + +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#include <osl/conditn.hxx> +#include <osl/mutex.hxx> +#include <osl/thread.hxx> +#include <rtl/ustring.hxx> + +#include <list> + +class UnxFilePickerNotifyThread; + +class UnxFilePickerCommandThread : public ::osl::Thread +{ +protected: + UnxFilePickerNotifyThread *m_pNotifyThread; + int m_nReadFD; + + ::osl::Mutex m_aMutex; + + ::osl::Condition m_aExecCondition; + sal_Bool m_aResult; + + ::osl::Condition m_aGetCurrentFilterCondition; + ::rtl::OUString m_aGetCurrentFilter; + + ::osl::Condition m_aGetDirectoryCondition; + ::rtl::OUString m_aGetDirectory; + + ::osl::Condition m_aGetFilesCondition; + ::std::list< ::rtl::OUString > m_aGetFiles; + + ::osl::Condition m_aGetValueCondition; + ::com::sun::star::uno::Any m_aGetValue; + +public: + UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD ); + ~UnxFilePickerCommandThread(); + + ::osl::Condition& SAL_CALL execCondition() { return m_aExecCondition; } + sal_Bool SAL_CALL result(); + + ::osl::Condition& SAL_CALL getCurrentFilterCondition() { return m_aGetCurrentFilterCondition; } + ::rtl::OUString SAL_CALL getCurrentFilter(); + + ::osl::Condition& SAL_CALL getDirectoryCondition() { return m_aGetDirectoryCondition; } + ::rtl::OUString SAL_CALL getDirectory(); + + ::osl::Condition& SAL_CALL getFilesCondition() { return m_aGetFilesCondition; } + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles(); + + ::osl::Condition& SAL_CALL getValueCondition() { return m_aGetValueCondition; } + ::com::sun::star::uno::Any SAL_CALL getValue(); + +protected: + virtual void SAL_CALL run(); + + virtual void SAL_CALL handleCommand( const ::rtl::OUString &rCommand/*, sal_Bool &rQuit*/ ); + ::std::list< ::rtl::OUString > SAL_CALL tokenize( const ::rtl::OUString &rCommand ); +}; + +#endif // _UNXCOMMANDTHREAD_HXX_ diff --git a/fpicker/source/unx/kde_unx/UnxFPentry.cxx b/fpicker/source/unx/kde_unx/UnxFPentry.cxx new file mode 100644 index 000000000000..24ecd5456daa --- /dev/null +++ b/fpicker/source/unx/kde_unx/UnxFPentry.cxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2010 Novell, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <com/sun/star/container/XSet.hpp> + +#include <cppuhelper/factory.hxx> +#include <osl/diagnose.h> + +#include "UnxFilePicker.hxx" +#include "FPServiceInfo.hxx" + +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; +using namespace ::cppu; +using ::com::sun::star::ui::dialogs::XFilePicker; + +////////////////////////////////////////////////////////////////////////// +// +////////////////////////////////////////////////////////////////////////// + +static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) +{ + return Reference< XInterface >( + static_cast< XFilePicker* >( new UnxFilePicker( rServiceManager ) ) ); +} + +////////////////////////////////////////////////////////////////////////// +// the three uno functions that will be exported +////////////////////////////////////////////////////////////////////////// + +extern "C" +{ + +////////////////////////////////////////////////////////////////////////// +// component_getImplementationEnvironment +////////////////////////////////////////////////////////////////////////// + +void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +////////////////////////////////////////////////////////////////////////// +// +////////////////////////////////////////////////////////////////////////// + +sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) +{ + sal_Bool bRetVal = sal_True; + + if ( pRegistryKey ) + { + try + { + Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) ); + pXNewKey->createKey( OUString::createFromAscii( FILE_PICKER_REGKEY_NAME ) ); + } + catch( InvalidRegistryException& ) + { + OSL_ENSURE( sal_False, "InvalidRegistryException caught" ); + bRetVal = sal_False; + } + } + + return bRetVal; +} + +////////////////////////////////////////////////////////////////////////// +// +////////////////////////////////////////////////////////////////////////// + +void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey ) +{ + void* pRet = 0; + + if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, FILE_PICKER_IMPL_NAME ) ) ) + { + Sequence< OUString > aSNS( 1 ); + aSNS.getArray( )[0] = OUString::createFromAscii( FILE_PICKER_SERVICE_NAME ); + + Reference< XSingleServiceFactory > xFactory ( createSingleFactory( + reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), + OUString::createFromAscii( pImplName ), + createInstance, + aSNS ) ); + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} // extern "C" diff --git a/fpicker/source/unx/kde_unx/UnxFilePicker.cxx b/fpicker/source/unx/kde_unx/UnxFilePicker.cxx new file mode 100644 index 000000000000..1ee8942829fc --- /dev/null +++ b/fpicker/source/unx/kde_unx/UnxFilePicker.cxx @@ -0,0 +1,895 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2010 Novell, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> +#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> +#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> +#include <com/sun/star/ui/dialogs/ControlActions.hpp> + +#include <FPServiceInfo.hxx> + +#include <cppuhelper/interfacecontainer.h> +#include <osl/diagnose.h> +#include <rtl/ustring.hxx> +#include <rtl/ustrbuf.hxx> +#include <svtools/svtdata.hxx> +#include <svtools/svtools.hrc> +#include <UnxFilePicker.hxx> +#include <UnxCommandThread.hxx> +#include <UnxNotifyThread.hxx> + +#include <sys/wait.h> +#include <unistd.h> +#include <fcntl.h> + +#include <iostream> + +using namespace ::com::sun::star; + +using namespace ::com::sun::star::ui::dialogs; +using namespace ::com::sun::star::ui::dialogs::TemplateDescription; + +////////////////////////////////////////////////////////////////////////// +// helper functions +////////////////////////////////////////////////////////////////////////// + +namespace +{ + // controling event notifications + const bool STARTUP_SUSPENDED = true; + const bool STARTUP_ALIVE = false; + + uno::Sequence<rtl::OUString> SAL_CALL FilePicker_getSupportedServiceNames() + { + uno::Sequence<rtl::OUString> aRet(3); + aRet[0] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.FilePicker"); + aRet[1] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.SystemFilePicker"); + aRet[2] = rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.KDEFilePicker"); + return aRet; + } +} + +////////////////////////////////////////////////////////////////////////// +// UnxFilePicker +////////////////////////////////////////////////////////////////////////// + +UnxFilePicker::UnxFilePicker( const uno::Reference<lang::XMultiServiceFactory>& xServiceMgr ) + : cppu::WeakComponentImplHelper8< + XFilterManager, + XFilterGroupManager, + XFilePickerControlAccess, + XFilePickerNotifier, +// TODO XFilePreview, + lang::XInitialization, + util::XCancellable, + lang::XEventListener, + lang::XServiceInfo>( m_rbHelperMtx ), + m_xServiceMgr( xServiceMgr ), + m_nFilePickerPid( -1 ), + m_nFilePickerWrite( -1 ), + m_nFilePickerRead( -1 ), + m_pNotifyThread( NULL ), + m_pCommandThread( NULL ) +{ +} + +UnxFilePicker::~UnxFilePicker() +{ + if ( m_nFilePickerPid > 0 ) + { + sendCommand( ::rtl::OUString::createFromAscii( "exit" ) ); + waitpid( m_nFilePickerPid, NULL, 0 ); + } + + if ( m_pCommandThread ) + { + m_pCommandThread->join(); + + delete m_pCommandThread, m_pCommandThread = NULL; + } + + if ( m_pNotifyThread ) + { + m_pNotifyThread->exit(); + + m_pNotifyThread->join(); + + delete m_pNotifyThread, m_pNotifyThread = NULL; + } + + if ( m_nFilePickerWrite >= 0 ) + close( m_nFilePickerWrite ); + + if ( m_nFilePickerRead >= 0 ) + close( m_nFilePickerRead ); +} + +void SAL_CALL UnxFilePicker::addFilePickerListener( const uno::Reference<XFilePickerListener>& xListener ) + throw( uno::RuntimeException ) +{ + OSL_ASSERT( m_pNotifyThread ); + osl::MutexGuard aGuard( m_aMutex ); + + m_pNotifyThread->addFilePickerListener( xListener ); +} + +void SAL_CALL UnxFilePicker::removeFilePickerListener( const uno::Reference<XFilePickerListener>& xListener ) + throw( uno::RuntimeException ) +{ + OSL_ASSERT( m_pNotifyThread ); + osl::MutexGuard aGuard( m_aMutex ); + + m_pNotifyThread->removeFilePickerListener( xListener ); +} + +void SAL_CALL UnxFilePicker::setTitle( const rtl::OUString &rTitle ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "setTitle " ); + appendEscaped( aBuffer, rTitle ); + + sendCommand( aBuffer.makeStringAndClear() ); +} + +sal_Int16 SAL_CALL UnxFilePicker::execute() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + + sendCommand( ::rtl::OUString::createFromAscii( "exec" ), + m_pCommandThread->execCondition() ); + + return m_pCommandThread->result(); +} + +void SAL_CALL UnxFilePicker::setMultiSelectionMode( sal_Bool bMode ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUString aString = bMode? + ::rtl::OUString::createFromAscii( "setMultiSelection true" ): + ::rtl::OUString::createFromAscii( "setMultiSelection false" ); + + sendCommand( aString ); +} + +void SAL_CALL UnxFilePicker::setDefaultName( const ::rtl::OUString &rName ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "setDefaultName " ); + appendEscaped( aBuffer, rName ); + + sendCommand( aBuffer.makeStringAndClear() ); +} + +void SAL_CALL UnxFilePicker::setDisplayDirectory( const rtl::OUString &rDirectory ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "setDirectory " ); + appendEscaped( aBuffer, rDirectory ); + + sendCommand( aBuffer.makeStringAndClear() ); +} + +rtl::OUString SAL_CALL UnxFilePicker::getDisplayDirectory() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + sendCommand( ::rtl::OUString::createFromAscii( "getDirectory" ), + m_pCommandThread->getDirectoryCondition() ); + + return m_pCommandThread->getDirectory(); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL UnxFilePicker::getFiles() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + sendCommand( ::rtl::OUString::createFromAscii( "getFiles" ), + m_pCommandThread->getFilesCondition() ); + + return m_pCommandThread->getFiles(); +} + +void SAL_CALL UnxFilePicker::appendFilter( const ::rtl::OUString &rTitle, const ::rtl::OUString &rFilter ) + throw( lang::IllegalArgumentException, uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "appendFilter " ); + appendEscaped( aBuffer, rTitle ); + aBuffer.appendAscii( " ", 1 ); + appendEscaped( aBuffer, rFilter ); + + sendCommand( aBuffer.makeStringAndClear() ); +} + +void SAL_CALL UnxFilePicker::setCurrentFilter( const rtl::OUString &rTitle ) + throw( lang::IllegalArgumentException, uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "setCurrentFilter " ); + appendEscaped( aBuffer, rTitle ); + + sendCommand( aBuffer.makeStringAndClear() ); +} + +rtl::OUString SAL_CALL UnxFilePicker::getCurrentFilter() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + sendCommand( ::rtl::OUString::createFromAscii( "getCurrentFilter" ), + m_pCommandThread->getCurrentFilterCondition() ); + + return m_pCommandThread->getCurrentFilter(); +} + +void SAL_CALL UnxFilePicker::appendFilterGroup( const rtl::OUString &rGroupTitle, const uno::Sequence<beans::StringPair> &rFilters ) + throw( lang::IllegalArgumentException, uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "appendFilterGroup " ); + appendEscaped( aBuffer, rGroupTitle ); + + for ( sal_Int32 i = 0; i < rFilters.getLength(); ++i ) + { + beans::StringPair aPair = rFilters[i]; + + aBuffer.appendAscii( " ", 1 ); + appendEscaped( aBuffer, aPair.First ); + aBuffer.appendAscii( " ", 1 ); + appendEscaped( aBuffer, aPair.Second ); + } + + sendCommand( aBuffer.makeStringAndClear() ); +} + +void SAL_CALL UnxFilePicker::setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const uno::Any &rValue ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUString aType; + ::rtl::OUString aAction; + sal_Int32 nTitleId; + + if ( controlIdInfo( nControlId, aType, nTitleId ) && controlActionInfo( nControlAction, aAction ) ) + { + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "setValue " ); + aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); + aBuffer.appendAscii( " ", 1 ); + aBuffer.append( aAction ); + + if ( aType.equalsAscii( "checkbox" ) ) + { + sal_Bool bControlValue; + if ( ( rValue >>= bControlValue ) && bControlValue ) + aBuffer.appendAscii( " true" ); + else + aBuffer.appendAscii( " false" ); + } + else if ( aType.equalsAscii( "listbox" ) ) + { + switch ( nControlAction ) + { + case ControlActions::ADD_ITEM: + case ControlActions::SET_HELP_URL: + { + ::rtl::OUString aString; + if ( rValue >>= aString ) + { + aBuffer.appendAscii( " ", 1 ); + appendEscaped( aBuffer, aString ); + } + } + break; + + case ControlActions::ADD_ITEMS: + { + uno::Sequence< ::rtl::OUString > aSequence; + if ( rValue >>= aSequence ) + { + for ( sal_Int32 nIdx = 0; nIdx < aSequence.getLength(); ++nIdx ) + { + aBuffer.appendAscii( " ", 1 ); + appendEscaped( aBuffer, aSequence[nIdx] ); + } + + } + } + break; + + case ControlActions::DELETE_ITEM: + case ControlActions::SET_SELECT_ITEM: + { + sal_Int32 nInt; + if ( rValue >>= nInt ) + { + aBuffer.appendAscii( " ", 1 ); + aBuffer.append( nInt ); + } + } + break; + + default: + // nothing + break; + } + } + // TODO else if push button... + + sendCommand( aBuffer.makeStringAndClear() ); + } +} + +uno::Any SAL_CALL UnxFilePicker::getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUString aAction; + + if ( controlActionInfo( nControlAction, aAction ) ) + { + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "getValue " ); + aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); + aBuffer.appendAscii( " ", 1 ); + aBuffer.append( aAction ); + + sendCommand( aBuffer.makeStringAndClear(), + m_pCommandThread->getValueCondition() ); + + return m_pCommandThread->getValue(); + } + + return uno::Any(); +} + +void SAL_CALL UnxFilePicker::enableControl( sal_Int16 nControlId, sal_Bool bEnable ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "enableControl " ); + aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); + aBuffer.appendAscii( bEnable? " true": " false" ); + + sendCommand( aBuffer.makeStringAndClear() ); +} + +void SAL_CALL UnxFilePicker::setLabel( sal_Int16 nControlId, const ::rtl::OUString &rLabel ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "setLabel " ); + aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); + aBuffer.appendAscii( " ", 1 ); + appendEscaped( aBuffer, rLabel ); + + sendCommand( aBuffer.makeStringAndClear() ); +} + +rtl::OUString SAL_CALL UnxFilePicker::getLabel(sal_Int16 nControlId) + throw ( uno::RuntimeException ) +{ + // FIXME getLabel() is not yet implemented + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + // TODO return m_pImpl->getLabel(nControlId); + return ::rtl::OUString(); +} + +/* TODO +uno::Sequence<sal_Int16> SAL_CALL UnxFilePicker::getSupportedImageFormats() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_pImpl->getSupportedImageFormats(); +} + +sal_Int32 SAL_CALL UnxFilePicker::getTargetColorDepth() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_pImpl->getTargetColorDepth(); +} + +sal_Int32 SAL_CALL UnxFilePicker::getAvailableWidth() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_pImpl->getAvailableWidth(); +} + +sal_Int32 SAL_CALL UnxFilePicker::getAvailableHeight() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_pImpl->getAvailableHeight(); +} + +void SAL_CALL UnxFilePicker::setImage( sal_Int16 aImageFormat, const uno::Any &rImage ) + throw( lang::IllegalArgumentException, uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + m_pImpl->setImage( aImageFormat, aImage ); +} + +sal_Bool SAL_CALL UnxFilePicker::setShowState( sal_Bool bShowState ) + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_pImpl->setShowState( bShowState ); +} + +sal_Bool SAL_CALL UnxFilePicker::getShowState() + throw( uno::RuntimeException ) +{ + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + return m_pImpl->getShowState(); +} +*/ + +void SAL_CALL UnxFilePicker::initialize( const uno::Sequence<uno::Any> &rArguments ) + throw( uno::Exception, uno::RuntimeException ) +{ + initFilePicker(); + + // parameter checking + uno::Any aAny; + if ( 0 == rArguments.getLength( ) ) + throw lang::IllegalArgumentException( + rtl::OUString::createFromAscii( "no arguments" ), + static_cast< XFilePicker* >( this ), 1 ); + + aAny = rArguments[0]; + + if ( ( aAny.getValueType() != ::getCppuType( (sal_Int16*)0 ) ) && ( aAny.getValueType() != ::getCppuType( (sal_Int8*)0 ) ) ) + throw lang::IllegalArgumentException( + rtl::OUString::createFromAscii( "invalid argument type" ), + static_cast< XFilePicker* >( this ), 1 ); + + sal_Int16 templateId = -1; + aAny >>= templateId; + + ::rtl::OUString aTypeOpen = ::rtl::OUString::createFromAscii( "setType \"open\"" ); + ::rtl::OUString aTypeSaveAs = ::rtl::OUString::createFromAscii( "setType \"save\"" ); + + switch ( templateId ) + { + case FILEOPEN_SIMPLE: + sendCommand( aTypeOpen ); + break; + + case FILESAVE_SIMPLE: + sendCommand( aTypeSaveAs ); + break; + + case FILESAVE_AUTOEXTENSION_PASSWORD: + sendCommand( aTypeSaveAs ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD ); + break; + + case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS: + sendCommand( aTypeSaveAs ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD ); + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS ); + break; + + case FILESAVE_AUTOEXTENSION_SELECTION: + sendCommand( aTypeSaveAs ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_SELECTION ); + break; + + case FILESAVE_AUTOEXTENSION_TEMPLATE: + sendCommand( aTypeSaveAs ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE ); + break; + + case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE: + sendCommand( aTypeOpen ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_LINK ); + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW ); + sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE ); + break; + + case FILEOPEN_PLAY: + sendCommand( aTypeOpen ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY ); + break; + + case FILEOPEN_READONLY_VERSION: + sendCommand( aTypeOpen ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_READONLY ); + sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_VERSION ); + break; + + case FILEOPEN_LINK_PREVIEW: + sendCommand( aTypeOpen ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_LINK ); + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW ); + break; + + case FILESAVE_AUTOEXTENSION: + sendCommand( aTypeSaveAs ); + + sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ); + break; + + default: + throw lang::IllegalArgumentException( + rtl::OUString::createFromAscii( "Unknown template" ), + static_cast< XFilePicker* >( this ), + 1 ); + } +} + +void SAL_CALL UnxFilePicker::cancel() + throw ( uno::RuntimeException ) +{ + // FIXME cancel() is not implemented + checkFilePicker(); + ::osl::MutexGuard aGuard( m_aMutex ); + + // TODO m_pImpl->cancel(); +} + +void SAL_CALL UnxFilePicker::disposing( const lang::EventObject &rEvent ) + throw( uno::RuntimeException ) +{ + uno::Reference<XFilePickerListener> xFilePickerListener( rEvent.Source, uno::UNO_QUERY ); + + if ( xFilePickerListener.is() ) + removeFilePickerListener( xFilePickerListener ); +} + +rtl::OUString SAL_CALL UnxFilePicker::getImplementationName() + throw( uno::RuntimeException ) +{ + return rtl::OUString::createFromAscii( FILE_PICKER_IMPL_NAME ); +} + +sal_Bool SAL_CALL UnxFilePicker::supportsService( const rtl::OUString& ServiceName ) + throw( uno::RuntimeException ) +{ + uno::Sequence< ::rtl::OUString > SupportedServicesNames = FilePicker_getSupportedServiceNames(); + + for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; ) + { + if ( SupportedServicesNames[n].compareTo( ServiceName ) == 0 ) + return sal_True; + } + + return sal_False; +} + +uno::Sequence< ::rtl::OUString > SAL_CALL UnxFilePicker::getSupportedServiceNames() + throw( uno::RuntimeException ) +{ + return FilePicker_getSupportedServiceNames(); +} + +void UnxFilePicker::initFilePicker() +{ + int aFiledesStdin[2], aFiledesStdout[2]; + if ( pipe( aFiledesStdin ) < 0 || pipe( aFiledesStdout ) < 0 ) + return; + + m_nFilePickerPid = fork(); + if ( m_nFilePickerPid < 0 ) + return; + + if ( m_nFilePickerPid == 0 ) + { + // Child... + close( aFiledesStdin[1] ); // write end of the pipe + dup2( aFiledesStdin[0], 0 ); + close( aFiledesStdin[0] ); + + close( aFiledesStdout[0] ); // read end of the pipe + dup2( aFiledesStdout[1], 1 ); + close( aFiledesStdout[1] ); + +#if OSL_DEBUG_LEVEL == 0 + int nRedirect = open( "/dev/null", O_WRONLY ); + if( nRedirect != -1 ) + { + dup2( nRedirect, 2 ); + } +#endif + + // FIXME: window id, etc. + const char *pFname = "kdefilepicker"; + + execlp( pFname, pFname, NULL ); + + // Error, finish the child + exit( -1 ); + } + + // Parent continues + close( aFiledesStdin[0] ); + m_nFilePickerWrite = aFiledesStdin[1]; + + close( aFiledesStdout[1] ); + m_nFilePickerRead = aFiledesStdout[0]; + + // Create the notify thread + if ( !m_pNotifyThread ) + m_pNotifyThread = new UnxFilePickerNotifyThread( this ); + + // Create the command thread + if ( !m_pCommandThread ) + m_pCommandThread = new UnxFilePickerCommandThread( m_pNotifyThread, m_nFilePickerRead ); + + // Start the threads + m_pNotifyThread->create(); + m_pCommandThread->create(); + + return; +} + +void UnxFilePicker::checkFilePicker() throw( ::com::sun::star::uno::RuntimeException ) +{ + if ( m_nFilePickerPid > 0 ) + { + // TODO check if external file picker is runnning + } + else + { + throw uno::RuntimeException( + ::rtl::OUString::createFromAscii( "the external file picker does not run" ), + *this ); + } +} + +void UnxFilePicker::sendCommand( const ::rtl::OUString &rCommand ) +{ + if ( m_nFilePickerWrite < 0 ) + return; + + ::rtl::OString aUtfString = OUStringToOString( rCommand + ::rtl::OUString::createFromAscii( "\n" ), RTL_TEXTENCODING_UTF8 ); + +#if OSL_DEBUG_LEVEL > 0 + ::std::cerr << "UnxFilePicker sent: \"" << aUtfString.getStr() << "\"" << ::std::endl; +#endif + + write( m_nFilePickerWrite, aUtfString.getStr(), aUtfString.getLength() ); +} + +void UnxFilePicker::sendCommand( const ::rtl::OUString &rCommand, ::osl::Condition &rCondition ) +{ + rCondition.reset(); + + sendCommand( rCommand ); + + rCondition.wait(); +} + +void UnxFilePicker::appendEscaped( ::rtl::OUStringBuffer &rBuffer, const ::rtl::OUString &rString ) +{ + const sal_Unicode *pUnicode = rString.getStr(); + const sal_Unicode *pEnd = pUnicode + rString.getLength(); + + rBuffer.appendAscii( "\"" , 1 ); + + for ( ; pUnicode != pEnd; ++pUnicode ) + { + if ( *pUnicode == '\\' ) + rBuffer.appendAscii( "\\\\", 2 ); + else if ( *pUnicode == '"' ) + rBuffer.appendAscii( "\\\"", 2 ); + else if ( *pUnicode == '\n' ) + rBuffer.appendAscii( "\\n", 2 ); + else + rBuffer.append( *pUnicode ); + } + + rBuffer.appendAscii( "\"", 1 ); +} + +sal_Bool UnxFilePicker::controlIdInfo( sal_Int16 nControlId, ::rtl::OUString &rType, sal_Int32 &rTitleId ) +{ + typedef struct { + sal_Int16 nId; + const ::rtl::OUString *pType; + sal_Int32 nTitle; + } ElementToName; + + const ::rtl::OUString aCheckBox( RTL_CONSTASCII_USTRINGPARAM( "checkbox" ) ); + const ::rtl::OUString aControl( RTL_CONSTASCII_USTRINGPARAM( "control" ) ); + const ::rtl::OUString aEdit( RTL_CONSTASCII_USTRINGPARAM( "edit" ) ); + const ::rtl::OUString aLabel( RTL_CONSTASCII_USTRINGPARAM( "label" ) ); + const ::rtl::OUString aListBox( RTL_CONSTASCII_USTRINGPARAM( "listbox" ) ); + const ::rtl::OUString aPushButton( RTL_CONSTASCII_USTRINGPARAM( "pushbutton" ) ); + + const ElementToName *pPtr; + const ElementToName pArray[] = + { + { CommonFilePickerElementIds::PUSHBUTTON_OK, &aPushButton, 0/*FIXME?*/ }, + { CommonFilePickerElementIds::PUSHBUTTON_CANCEL, &aPushButton, 0/*FIXME?*/ }, + { CommonFilePickerElementIds::LISTBOX_FILTER, &aListBox, 0/*FIXME?*/ }, + { CommonFilePickerElementIds::CONTROL_FILEVIEW, &aControl, 0/*FIXME?*/ }, + { CommonFilePickerElementIds::EDIT_FILEURL, &aEdit, 0/*FIXME?*/ }, + { CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, &aLabel, 0/*FIXME?*/ }, + { CommonFilePickerElementIds::EDIT_FILEURL_LABEL, &aLabel, 0/*FIXME?*/ }, + + { ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, &aCheckBox, STR_SVT_FILEPICKER_AUTO_EXTENSION }, + { ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, &aCheckBox, STR_SVT_FILEPICKER_PASSWORD }, + { ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, &aCheckBox, STR_SVT_FILEPICKER_FILTER_OPTIONS }, + { ExtendedFilePickerElementIds::CHECKBOX_READONLY, &aCheckBox, STR_SVT_FILEPICKER_READONLY }, + { ExtendedFilePickerElementIds::CHECKBOX_LINK, &aCheckBox, STR_SVT_FILEPICKER_INSERT_AS_LINK }, + { ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, &aCheckBox, STR_SVT_FILEPICKER_SHOW_PREVIEW }, + { ExtendedFilePickerElementIds::PUSHBUTTON_PLAY, &aPushButton, STR_SVT_FILEPICKER_PLAY }, + { ExtendedFilePickerElementIds::LISTBOX_VERSION, &aListBox, STR_SVT_FILEPICKER_VERSION }, + { ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, &aListBox, STR_SVT_FILEPICKER_TEMPLATES }, + { ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, &aListBox, STR_SVT_FILEPICKER_IMAGE_TEMPLATE }, + { ExtendedFilePickerElementIds::CHECKBOX_SELECTION, &aCheckBox, STR_SVT_FILEPICKER_SELECTION }, + { 0, 0, 0 } + }; + + for ( pPtr = pArray; pPtr->nId && ( pPtr->nId != nControlId ); ++pPtr ) + ; + + if ( pPtr->nId == nControlId ) + { + rType = *(pPtr->pType); + rTitleId = pPtr->nTitle; + + return sal_True; + } + + return sal_False; +} + +sal_Bool UnxFilePicker::controlActionInfo( sal_Int16 nControlAction, ::rtl::OUString &rType ) +{ + typedef struct { + sal_Int16 nId; + const ::rtl::OUString pType; + } ElementToName; + + const ElementToName *pPtr; + const ElementToName pArray[] = + { + { ControlActions::ADD_ITEM, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "addItem" ) ) }, + { ControlActions::ADD_ITEMS, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "addItems" ) ) }, + { ControlActions::DELETE_ITEM, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "deleteItem" ) ) }, + { ControlActions::DELETE_ITEMS, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "deleteItems" ) ) }, + { ControlActions::SET_SELECT_ITEM, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "setSelectedItem" ) ) }, + { ControlActions::GET_ITEMS, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getItems" ) ) }, + { ControlActions::GET_SELECTED_ITEM, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getSelectedItem" ) ) }, + { ControlActions::GET_SELECTED_ITEM_INDEX, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getSelectedItemIndex" ) ) }, + { ControlActions::SET_HELP_URL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "setHelpURL" ) ) }, + { ControlActions::GET_HELP_URL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getHelpURL" ) ) }, + { 0, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "noAction" ) ) } + }; + + for ( pPtr = pArray; pPtr->nId && ( pPtr->nId != nControlAction ); ++pPtr ) + ; + + rType = pPtr->pType; + + return sal_True; +} + +void UnxFilePicker::sendAppendControlCommand( sal_Int16 nControlId ) +{ + ::rtl::OUString aType; + sal_Int32 nTitleId; + + if ( controlIdInfo( nControlId, aType, nTitleId ) ) + { + ::rtl::OUStringBuffer aBuffer( 1024 ); + + aBuffer.appendAscii( "appendControl " ); + aBuffer.append( static_cast< sal_Int32 >( nControlId ) ); + aBuffer.appendAscii( " ", 1 ); + appendEscaped( aBuffer, aType ); + aBuffer.appendAscii( " ", 1 ); + appendEscaped( aBuffer, String( SvtResId( nTitleId ) ) ); + + sendCommand( aBuffer.makeStringAndClear() ); + } +} diff --git a/fpicker/source/unx/kde_unx/UnxFilePicker.hxx b/fpicker/source/unx/kde_unx/UnxFilePicker.hxx new file mode 100644 index 000000000000..9e6b07e8a2ad --- /dev/null +++ b/fpicker/source/unx/kde_unx/UnxFilePicker.hxx @@ -0,0 +1,171 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2010 Novell, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNXFILEPICKER_HXX_ +#define _UNXFILEPICKER_HXX_ + +#include <cppuhelper/compbase8.hxx> +#include <osl/conditn.hxx> +#include <osl/mutex.hxx> +#include <rtl/ustrbuf.hxx> + +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/ui/dialogs/XFilePickerNotifier.hpp> +#include <com/sun/star/ui/dialogs/XFilterManager.hpp> +#include <com/sun/star/ui/dialogs/XFilterGroupManager.hpp> +#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> +#include <com/sun/star/ui/dialogs/XFilePreview.hpp> +#include <com/sun/star/util/XCancellable.hpp> + +#include <list> + +class UnxFilePickerCommandThread; +class UnxFilePickerNotifyThread; + +class UnxFilePickerDummy +{ +protected: + osl::Mutex m_aMutex; + osl::Mutex m_rbHelperMtx; +}; + +class UnxFilePicker : + public UnxFilePickerDummy, + public cppu::WeakComponentImplHelper8< + ::com::sun::star::ui::dialogs::XFilterManager, + ::com::sun::star::ui::dialogs::XFilterGroupManager, + ::com::sun::star::ui::dialogs::XFilePickerControlAccess, + ::com::sun::star::ui::dialogs::XFilePickerNotifier, +// TODO ::com::sun::star::ui::dialogs::XFilePreview, + ::com::sun::star::lang::XInitialization, + ::com::sun::star::util::XCancellable, + ::com::sun::star::lang::XEventListener, + ::com::sun::star::lang::XServiceInfo > +{ +protected: + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceMgr; // to instanciate own services + + pid_t m_nFilePickerPid; + int m_nFilePickerWrite; // (kde|...)filepicker gets it as stdin + int m_nFilePickerRead; // (kde|...)filepicker gets it as stdout + + UnxFilePickerNotifyThread *m_pNotifyThread; + UnxFilePickerCommandThread *m_pCommandThread; + +public: + UnxFilePicker( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceMgr ); + virtual ~UnxFilePicker(); + + // XFilePickerNotifier + + virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) throw( ::com::sun::star::uno::RuntimeException ); + + // XExecutableDialog functions + + virtual void SAL_CALL setTitle( const ::rtl::OUString &rTitle ) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Int16 SAL_CALL execute() throw( ::com::sun::star::uno::RuntimeException ); + + // XFilePicker functions + + virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setDefaultName( const ::rtl::OUString &rName ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setDisplayDirectory( const ::rtl::OUString &rDirectory ) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getDisplayDirectory() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFiles() throw( ::com::sun::star::uno::RuntimeException ); + + // XFilterManager functions + + virtual void SAL_CALL appendFilter( const ::rtl::OUString &rTitle, const ::rtl::OUString &rFilter ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setCurrentFilter( const ::rtl::OUString &rTitle ) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getCurrentFilter() throw( ::com::sun::star::uno::RuntimeException ); + + // XFilterGroupManager functions + + virtual void SAL_CALL appendFilterGroup( const ::rtl::OUString &rGroupTitle, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > &rFilters ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + // XFilePickerControlAccess functions + + virtual void SAL_CALL setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const ::com::sun::star::uno::Any &rValue ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL enableControl( sal_Int16 nControlId, sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setLabel( sal_Int16 nControlId, const ::rtl::OUString &rLabel ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getLabel( sal_Int16 nControlId ) throw (::com::sun::star::uno::RuntimeException); + + /* TODO XFilePreview + + virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const ::com::sun::star::uno::Any &rImage ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL getShowState( ) throw (::com::sun::star::uno::RuntimeException); + */ + + // XInitialization + + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > &rArguments ) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException ); + + // XCancellable + + virtual void SAL_CALL cancel( ) throw( ::com::sun::star::uno::RuntimeException ); + + // XEventListener + + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject &rEvent ) throw( ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo + + virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString &rServiceName ) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); + +private: + // prevent copy and assignment + UnxFilePicker( const UnxFilePicker& ); + UnxFilePicker& operator=( const UnxFilePicker& ); + +protected: + void initFilePicker(); + void checkFilePicker() throw( ::com::sun::star::uno::RuntimeException ); + + // Async sendCommand + void sendCommand( const ::rtl::OUString &rCommand ); + // Synchronized sendCommand + void sendCommand( const ::rtl::OUString &rCommand, ::osl::Condition &rCondition ); + void appendEscaped( ::rtl::OUStringBuffer &rBuffer, const ::rtl::OUString &rString ); + +private: + sal_Bool controlIdInfo( sal_Int16 nControlId, ::rtl::OUString &rType, sal_Int32 &rTitleId ); + sal_Bool controlActionInfo( sal_Int16 nControlId, ::rtl::OUString &rType ); + void sendAppendControlCommand( sal_Int16 nControlId ); +}; + +#endif // _UNXFILEPICKER_HXX_ diff --git a/fpicker/source/unx/kde_unx/UnxNotifyThread.cxx b/fpicker/source/unx/kde_unx/UnxNotifyThread.cxx new file mode 100644 index 000000000000..6aedf3dc01a8 --- /dev/null +++ b/fpicker/source/unx/kde_unx/UnxNotifyThread.cxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2010 Novell, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <UnxNotifyThread.hxx> +#include <UnxFilePicker.hxx> + +using namespace ::com::sun::star; + +////////////////////////////////////////////////////////////////////////// +// UnxFilePickerNotifyThread +////////////////////////////////////////////////////////////////////////// + +UnxFilePickerNotifyThread::UnxFilePickerNotifyThread( UnxFilePicker *pUnxFilePicker ) + : m_pUnxFilePicker( pUnxFilePicker ), + m_bExit( sal_False ), + m_eNotifyType( Nothing ), + m_nControlId( 0 ) +{ +} + +void SAL_CALL UnxFilePickerNotifyThread::addFilePickerListener( const uno::Reference< ui::dialogs::XFilePickerListener >& xListener ) + throw( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + m_xListener = xListener; +} + +void SAL_CALL UnxFilePickerNotifyThread::removeFilePickerListener( const uno::Reference< ui::dialogs::XFilePickerListener >& xListener ) + throw( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + m_xListener.clear(); +} + +void SAL_CALL UnxFilePickerNotifyThread::exit() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + m_bExit = sal_True; + + m_aExitCondition.reset(); + m_aNotifyCondition.set(); + + m_aExitCondition.wait(); +} + +void SAL_CALL UnxFilePickerNotifyThread::fileSelectionChanged() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + + m_eNotifyType = FileSelectionChanged; + m_nControlId = 0; + + m_aNotifyCondition.set(); +} + +void SAL_CALL UnxFilePickerNotifyThread::run() +{ + do { + m_aNotifyCondition.reset(); + m_aNotifyCondition.wait(); + + if ( m_xListener.is() && m_pUnxFilePicker ) + { + ::osl::MutexGuard aGuard( m_aMutex ); + + ui::dialogs::FilePickerEvent aEvent( *m_pUnxFilePicker, m_nControlId ); + + switch ( m_eNotifyType ) + { + case FileSelectionChanged: + m_xListener->fileSelectionChanged( aEvent ); + break; + + // TODO More to come... + + default: + // nothing + break; + } + } + } while ( !m_bExit ); + + m_aExitCondition.set(); +} diff --git a/fpicker/source/unx/kde_unx/UnxNotifyThread.hxx b/fpicker/source/unx/kde_unx/UnxNotifyThread.hxx new file mode 100644 index 000000000000..206721b02074 --- /dev/null +++ b/fpicker/source/unx/kde_unx/UnxNotifyThread.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2010 Novell, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _UNXNOTIFYTHREAD_HXX_ +#define _UNXNOTIFYTHREAD_HXX_ + +#include <com/sun/star/ui/dialogs/XFilePickerListener.hpp> +#include <com/sun/star/uno/Reference.hxx> + +#include <osl/conditn.hxx> +#include <osl/mutex.hxx> +#include <osl/thread.hxx> + +class UnxFilePicker; + +class UnxFilePickerNotifyThread : public ::osl::Thread +{ +protected: + enum NotifyType + { + Nothing = 0, + FileSelectionChanged + // TODO More to come... + }; + + UnxFilePicker *m_pUnxFilePicker; + + ::osl::Mutex m_aMutex; + + ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener > m_xListener; + + sal_Bool m_bExit; + ::osl::Condition m_aExitCondition; + + NotifyType m_eNotifyType; + ::osl::Condition m_aNotifyCondition; + sal_Int16 m_nControlId; + +public: + UnxFilePickerNotifyThread( UnxFilePicker *pUnxFilePicker ); + + virtual void SAL_CALL addFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeFilePickerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::dialogs::XFilePickerListener >& xListener ) + throw( ::com::sun::star::uno::RuntimeException ); + + void SAL_CALL exit(); + + void SAL_CALL fileSelectionChanged(); + /* TODO + void SAL_CALL directoryChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ); + rtl::OUString SAL_CALL helpRequested( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ) const; + void SAL_CALL controlStateChanged( ::com::sun::star::ui::dialogs::FilePickerEvent aEvent ); + void SAL_CALL dialogSizeChanged( ); + */ + +protected: + virtual void SAL_CALL run(); +}; + +#endif // _UNXNOTIFYTHREAD_HXX_ diff --git a/fpicker/source/unx/kde_unx/fps-kde-ucd.txt b/fpicker/source/unx/kde_unx/fps-kde-ucd.txt new file mode 100644 index 000000000000..28aa49d97bea --- /dev/null +++ b/fpicker/source/unx/kde_unx/fps-kde-ucd.txt @@ -0,0 +1,6 @@ +[ComponentDescriptor] +ImplementationName=com.sun.star.ui.dialogs.UnxFilePicker +ComponentName=fps_kde.uno.so +LoaderName=com.sun.star.loader.SharedLibrary +[SupportedServices] +com.sun.star.ui.dialogs.KDEFilePicker diff --git a/fpicker/source/unx/kde_unx/fps_kde.xml b/fpicker/source/unx/kde_unx/fps_kde.xml new file mode 100644 index 000000000000..99683bfecacf --- /dev/null +++ b/fpicker/source/unx/kde_unx/fps_kde.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name>fps_kde</module-name> + <component-description> + <author> Jan Holesovsky </author> + <name> com.sun.star.comp.ui.dialogs.FilePicker </name> + <description> + The KDE implementation of the FilePicker service. + </description> + <loader-name>com.sun.star.loader.SharedLibrary</loader-name> + <language> c++ </language> + <status value="beta"/> + <supported-service> com.sun.star.ui.dialogs.FilePicker </supported-service> + <service-dependency>...</service-dependency> + <type> com.sun.star.ui.dialogs.XExecutableDialog </type> + <type> com.sun.star.ui.dialogs.XFilePicker </type> + <type> com.sun.star.ui.dialogs.XFilterManager </type> + <type> com.sun.star.ui.dialogs.XFilterGroupManager </type> + <type> com.sun.star.ui.dialogs.XFilePickerListener </type> + <type> com.sun.star.ui.dialogs.ExecutableDialogException </type> + <type> com.sun.star.ui.dialogs.XFilePickerNotifier </type> + <type> com.sun.star.ui.dialogs.XFilePickerControlAccess </type> + <type> com.sun.star.ui.dialogs.XFilePreview </type> + <type> com.sun.star.ui.dialogs.ExtendedFilePickerElementIds </type> + <type> com.sun.star.ui.dialogs.ExecutableDialogResults </type> + <type> com.sun.star.ui.dialogs.FilePickerEvent </type> + <type> com.sun.star.ui.dialogs.CommonFilePickerElementIds </type> + <type> com.sun.star.ui.dialogs.ListboxControlActions </type> + <type> com.sun.star.ui.dialogs.TemplateDescription </type> + <type> com.sun.star.ui.dialogs.FilePreviewImageFormats </type> + <type> com.sun.star.util.XCancellable </type> + <type> com.sun.star.lang.XComponent </type> + <type> com.sun.star.lang.XMultiServiceFactory </type> + <type> com.sun.star.lang.XSingleServiceFactory </type> + <type> com.sun.star.lang.XServiceInfo </type> + <type> com.sun.star.lang.XTypeProvider </type> + <type> com.sun.star.lang.IllegalArgumentException </type> + <type> com.sun.star.uno.TypeClass </type> + <type> com.sun.star.uno.XWeak </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.registry.XRegistryKey </type> + <type> com.sun.star.container.XSet </type> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper </runtime-module-dependency> + <runtime-module-dependency> cppu2 </runtime-module-dependency> + <runtime-module-dependency> sal2 </runtime-module-dependency> +</module-description> diff --git a/fpicker/source/unx/kde_unx/makefile.mk b/fpicker/source/unx/kde_unx/makefile.mk new file mode 100644 index 000000000000..8101aa1aa226 --- /dev/null +++ b/fpicker/source/unx/kde_unx/makefile.mk @@ -0,0 +1,78 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# Copyright 2010 Novell, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=fpicker +TARGET=fps_kde.uno +LIBTARGET=NO +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +DLLPRE= + +# ------------------------------------------------------------------ + +# Currently just KDE is supported... +.IF "$(GUIBASE)" != "unx" || "$(ENABLE_KDE)" != "TRUE" + +dummy: + @echo "Nothing to build. GUIBASE == $(GUIBASE), ENABLE_KDE is not set" + +.ELSE # we build for KDE + +# --- Files -------------------------------------------------------- + +SLOFILES =\ + $(SLO)$/UnxCommandThread.obj \ + $(SLO)$/UnxFilePicker.obj \ + $(SLO)$/UnxNotifyThread.obj \ + $(SLO)$/UnxFPentry.obj + +SHL1NOCHECK=TRUE +SHL1TARGET=fps_kde.uno +SHL1STDLIBS=$(CPPULIB)\ + $(CPPUHELPERLIB)\ + $(SALLIB)\ + $(VCLLIB)\ + $(TOOLSLIB)\ + $(SVTOOLLIB) + +SHL1OBJS=$(SLOFILES) +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +DEF1VERSIONMAP=$(SOLARENV)/src/component.map + +.ENDIF # "$(GUIBASE)" != "unx" || "$(ENABLE_KDE)" != "TRUE" + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk |