1 diff --git fpicker/source/unx/kde4/KDE4FPEntry.cxx fpicker/source/unx/kde4/KDE4FPEntry.cxx
2 index 9a75688..805e6cf 100644
3 --- fpicker/source/unx/kde4/KDE4FPEntry.cxx
4 +++ fpicker/source/unx/kde4/KDE4FPEntry.cxx
5 @@ -84,12 +84,12 @@ static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiS
6 // the three uno functions that will be exported
9 - void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
10 + void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** )
12 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
15 - sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey )
16 + sal_Bool SAL_CALL component_writeInfo( void*, void* pRegistryKey )
18 sal_Bool bRetVal = sal_True;
20 @@ -110,7 +110,7 @@ extern "C"
24 - void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey )
25 + void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* )
29 diff --git fpicker/source/unx/kde4/KDE4FilePicker.cxx fpicker/source/unx/kde4/KDE4FilePicker.cxx
30 index b5cd83d..6c6db9e 100644
31 --- fpicker/source/unx/kde4/KDE4FilePicker.cxx
32 +++ fpicker/source/unx/kde4/KDE4FilePicker.cxx
33 @@ -118,6 +118,8 @@ using namespace ::com::sun::star::uno;
35 //////////////////////////////////////////////////////////////////////////
41 // controling event notifications
42 @@ -166,7 +168,7 @@ KDE4FilePicker::KDE4FilePicker( const uno::Reference<lang::XMultiServiceFactory>
44 _layout = new QGridLayout(_extraControls);
46 - _dialog = new KFileDialog(KUrl(""), QString(""), 0, _extraControls);
47 + _dialog = new KFileDialog(KUrl("~"), QString(""), 0, _extraControls);
48 _dialog->setMode(KFile::File | KFile::LocalOnly);
51 @@ -213,21 +215,19 @@ sal_Int16 SAL_CALL KDE4FilePicker::execute()
55 + _dialog->clearFilter();
56 _dialog->setFilter(_filter);
60 //nasty hack to get a local qt event loop going to process the dialog
61 //otherwise the dialog returns immediately
62 while (_dialog->isVisible())
64 kapp->processEvents(QEventLoop::WaitForMoreEvents);
67 //block and wait for user input
68 if (_dialog->result() == KFileDialog::Accepted)
70 return ExecutableDialogResults::OK;
73 return ExecutableDialogResults::CANCEL;
75 @@ -236,13 +236,9 @@ void SAL_CALL KDE4FilePicker::setMultiSelectionMode( sal_Bool multiSelect )
76 throw( uno::RuntimeException )
80 _dialog->setMode(KFile::Files | KFile::LocalOnly);
84 _dialog->setMode(KFile::File | KFile::LocalOnly);
88 void SAL_CALL KDE4FilePicker::setDefaultName( const ::rtl::OUString &name )
89 @@ -256,7 +252,7 @@ void SAL_CALL KDE4FilePicker::setDisplayDirectory( const rtl::OUString &dir )
90 throw( uno::RuntimeException )
92 const QString url = toQString(dir);
93 - _dialog->setStartDir(KUrl(url));
94 + _dialog->setUrl(KUrl(url));
97 rtl::OUString SAL_CALL KDE4FilePicker::getDisplayDirectory()
98 @@ -269,16 +265,54 @@ rtl::OUString SAL_CALL KDE4FilePicker::getDisplayDirectory()
99 uno::Sequence< ::rtl::OUString > SAL_CALL KDE4FilePicker::getFiles()
100 throw( uno::RuntimeException )
102 - QStringList files = _dialog->selectedFiles();
103 + QStringList rawFiles = _dialog->selectedFiles();
106 - uno::Sequence< ::rtl::OUString > seq(files.size());
107 + // check if we need to add an extension
108 + QString extension = "";
109 + if ( _dialog->operationMode() == KFileDialog::Saving )
111 + QCheckBox *cb = dynamic_cast<QCheckBox*> (
112 + _customWidgets[ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION ]);
114 + if (cb->isChecked())
116 + extension = _dialog->currentFilter(); // assuming filter value is like this *.ext
117 + extension.replace("*","");
121 + // Workaround for the double click selection KDE4 bug
122 + // kde file picker returns the file and directories for selectedFiles()
123 + // when a file is double clicked
124 + // make a true list of files
125 + const QString dir = "file://" + KUrl(rawFiles[0]).directory();
127 - for (int i=0 ; i<files.size() ; ++i)
128 + // by appending the dir, we make OO treat all opens like multifile opens
129 + // this makes the code for adding the the OO sequence simpler
132 + for (USHORT i = 0; i < rawFiles.size(); ++i)
134 - const QString fileName = "file:" + files[i];
135 - seq[i] = toOUString(fileName);
136 + // if the raw file is not the base directory (see above kde bug)
137 + // we add the file to list of avail files
138 + if ((dir + "/") != ("file://" + rawFiles[i]))
140 + const QString filename = KUrl(rawFiles[i]).fileName();
142 + //prevent extension append if we already have one
143 + if (filename.endsWith(extension))
144 + files.append(filename);
146 + files.append(filename + extension);
150 + // add all files and leading directory to outgoing OO sequence
151 + uno::Sequence< ::rtl::OUString > seq(files.size());
152 + for (int i = 0; i < files.size(); ++i)
153 + seq[i] = toOUString(files[i]);
158 @@ -289,9 +323,7 @@ void SAL_CALL KDE4FilePicker::appendFilter( const ::rtl::OUString &title, const
159 QString f = toQString(filter);
161 if (!_filter.isNull())
163 _filter.append("\n");
166 //add to hash map for reverse lookup in getCurrentFilter
167 _filters.insert(f, t);
168 @@ -318,17 +350,31 @@ rtl::OUString SAL_CALL KDE4FilePicker::getCurrentFilter()
170 //default if not found
173 filter = "ODF Text Document (.odt)";
176 return toOUString(filter);
179 -void SAL_CALL KDE4FilePicker::appendFilterGroup( const rtl::OUString&, const uno::Sequence<beans::StringPair>& )
180 +void SAL_CALL KDE4FilePicker::appendFilterGroup( const rtl::OUString&, const uno::Sequence<beans::StringPair>&)
181 throw( lang::IllegalArgumentException, uno::RuntimeException )
185 + //TODO ... don't really like this behavior... Shtylman
187 + if (!_filter.isNull())
188 + _filter.append(QString("\n"));
190 + for (USHORT i = 0; i < filters.getLength(); ++i)
192 + beans::StringPair aPair = filters[i];
194 + _filter.append(QString("%1|%2").arg(
195 + toQString(aPair.Second).replace(";", " ")).arg(
196 + toQString(aPair.First).replace("/","\\/") + "\n" ));
199 + if (filters.getLength() > 0)
200 + _filter.append(QString("*.*|*.*"));
204 void SAL_CALL KDE4FilePicker::setValue( sal_Int16 controlId, sal_Int16, const uno::Any &value )