helper.cxx (466d5a0b) | helper.cxx (b8c015e0) |
---|---|
1/************************************************************** | 1/************************************************************** |
2 * | 2 * |
3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at | 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at |
10 * | 10 * |
11 * http://www.apache.org/licenses/LICENSE-2.0 | 11 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * | 12 * |
13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. | 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. |
19 * | 19 * |
20 *************************************************************/ 21 22 23 24#include <unistd.h> 25#include <helper.hxx> 26#ifndef _PAD_PADIALOG_HRC_ 27#include <padialog.hrc> --- 28 unchanged lines hidden (view full) --- 56 * PaResId 57 */ 58 59ResId padmin::PaResId( sal_uInt32 nId ) 60{ 61 static ResMgr* pPaResMgr = NULL; 62 if( ! pPaResMgr ) 63 { | 20 *************************************************************/ 21 22 23 24#include <unistd.h> 25#include <helper.hxx> 26#ifndef _PAD_PADIALOG_HRC_ 27#include <padialog.hrc> --- 28 unchanged lines hidden (view full) --- 56 * PaResId 57 */ 58 59ResId padmin::PaResId( sal_uInt32 nId ) 60{ 61 static ResMgr* pPaResMgr = NULL; 62 if( ! pPaResMgr ) 63 { |
64 ::com::sun::star::lang::Locale aLocale; | 64 ::com::sun::star::lang::Locale aLocale; |
65// LanguageType nLang = LANGUAGE_SYSTEM; | 65// LanguageType nLang = LANGUAGE_SYSTEM; |
66 67 utl::OConfigurationNode aNode = 68 utl::OConfigurationTreeRoot::tryCreateWithServiceFactory( 69 vcl::unohelper::GetMultiServiceFactory(), 70 OUString::createFromAscii( "org.openoffice.Setup/L10N" ) ); 71 if ( aNode.isValid() ) 72 { 73 rtl::OUString aLoc; 74 Any aValue = aNode.getNodeValue( OUString::createFromAscii( "ooLocale" ) ); 75 if( aValue >>= aLoc ) 76 { 77// LanguageType nTmpLang = MsLangId::convertIsoStringToLanguage( aLoc ); 78// if( nTmpLang != LANGUAGE_DONTKNOW ) 79// nLang = nTmpLang; 80 sal_Int32 nIndex = 0; 81 aLocale.Language = aLoc.getToken( 0, '-', nIndex ); 82 aLocale.Country = aLoc.getToken( 0, '-', nIndex ); 83 aLocale.Variant = aLoc.getToken( 0, '-', nIndex ); 84 } 85 } | 66 67 utl::OConfigurationNode aNode = 68 utl::OConfigurationTreeRoot::tryCreateWithServiceFactory( 69 vcl::unohelper::GetMultiServiceFactory(), 70 OUString::createFromAscii( "org.openoffice.Setup/L10N" ) ); 71 if ( aNode.isValid() ) 72 { 73 rtl::OUString aLoc; 74 Any aValue = aNode.getNodeValue( OUString::createFromAscii( "ooLocale" ) ); 75 if( aValue >>= aLoc ) 76 { 77// LanguageType nTmpLang = MsLangId::convertIsoStringToLanguage( aLoc ); 78// if( nTmpLang != LANGUAGE_DONTKNOW ) 79// nLang = nTmpLang; 80 sal_Int32 nIndex = 0; 81 aLocale.Language = aLoc.getToken( 0, '-', nIndex ); 82 aLocale.Country = aLoc.getToken( 0, '-', nIndex ); 83 aLocale.Variant = aLoc.getToken( 0, '-', nIndex ); 84 } 85 } |
86 pPaResMgr = ResMgr::SearchCreateResMgr( "spa", aLocale ); 87 AllSettings aSettings = Application::GetSettings(); | 86 pPaResMgr = ResMgr::SearchCreateResMgr( "spa", aLocale ); 87 AllSettings aSettings = Application::GetSettings(); |
88// aSettings.SetUILanguage( nLang ); 89 aSettings.SetUILocale( aLocale ); 90 Application::SetSettings( aSettings ); | 88// aSettings.SetUILanguage( nLang ); 89 aSettings.SetUILocale( aLocale ); 90 Application::SetSettings( aSettings ); |
91 } 92 return ResId( nId, *pPaResMgr ); 93} 94 95/* 96 * FindFiles 97 */ 98 99void padmin::FindFiles( const String& rDirectory, ::std::list< String >& rResult, const String& rSuffixes, bool bRecursive ) 100{ | 91 } 92 return ResId( nId, *pPaResMgr ); 93} 94 95/* 96 * FindFiles 97 */ 98 99void padmin::FindFiles( const String& rDirectory, ::std::list< String >& rResult, const String& rSuffixes, bool bRecursive ) 100{ |
101 rResult.clear(); | 101 rResult.clear(); |
102 103 OUString aDirPath; 104 ::osl::FileBase::getFileURLFromSystemPath( rDirectory, aDirPath ); 105 Directory aDir( aDirPath ); 106 if( aDir.open() != FileBase::E_None ) | 102 103 OUString aDirPath; 104 ::osl::FileBase::getFileURLFromSystemPath( rDirectory, aDirPath ); 105 Directory aDir( aDirPath ); 106 if( aDir.open() != FileBase::E_None ) |
107 return; | 107 return; |
108 DirectoryItem aItem; 109 while( aDir.getNextItem( aItem ) == FileBase::E_None ) 110 { 111 FileStatus aStatus( FileStatusMask_FileName | 112 FileStatusMask_Type 113 ); 114 if( aItem.getFileStatus( aStatus ) == FileBase::E_None ) | 108 DirectoryItem aItem; 109 while( aDir.getNextItem( aItem ) == FileBase::E_None ) 110 { 111 FileStatus aStatus( FileStatusMask_FileName | 112 FileStatusMask_Type 113 ); 114 if( aItem.getFileStatus( aStatus ) == FileBase::E_None ) |
115 { 116 if( aStatus.getFileType() == FileStatus::Regular || 117 aStatus.getFileType() == FileStatus::Link ) 118 { 119 String aFileName = aStatus.getFileName(); 120 int nToken = rSuffixes.GetTokenCount( ';' ); 121 while( nToken-- ) 122 { 123 String aSuffix = rSuffixes.GetToken( nToken, ';' ); 124 if( aFileName.Len() > aSuffix.Len()+1 ) 125 { 126 String aExtension = aFileName.Copy( aFileName.Len()-aSuffix.Len() ); 127 if( aFileName.GetChar( aFileName.Len()-aSuffix.Len()-1 ) == '.' && 128 aExtension.EqualsIgnoreCaseAscii( aSuffix ) ) 129 { 130 rResult.push_back( aFileName ); 131 break; 132 } 133 } 134 } 135 } 136 else if( bRecursive && aStatus.getFileType() == FileStatus::Directory ) 137 { 138 OUStringBuffer aSubDir( rDirectory ); 139 aSubDir.appendAscii( "/", 1 ); 140 aSubDir.append( aStatus.getFileName() ); 141 std::list< String > subfiles; 142 FindFiles( aSubDir.makeStringAndClear(), subfiles, rSuffixes, bRecursive ); 143 for( std::list< String >::const_iterator it = subfiles.begin(); it != subfiles.end(); ++it ) 144 { 145 OUStringBuffer aSubFile( aStatus.getFileName() ); 146 aSubFile.appendAscii( "/", 1 ); 147 aSubFile.append( *it ); 148 rResult.push_back( aSubFile.makeStringAndClear() ); 149 } 150 } 151 } | 115 { 116 if( aStatus.getFileType() == FileStatus::Regular || 117 aStatus.getFileType() == FileStatus::Link ) 118 { 119 String aFileName = aStatus.getFileName(); 120 int nToken = rSuffixes.GetTokenCount( ';' ); 121 while( nToken-- ) 122 { 123 String aSuffix = rSuffixes.GetToken( nToken, ';' ); 124 if( aFileName.Len() > aSuffix.Len()+1 ) 125 { 126 String aExtension = aFileName.Copy( aFileName.Len()-aSuffix.Len() ); 127 if( aFileName.GetChar( aFileName.Len()-aSuffix.Len()-1 ) == '.' && 128 aExtension.EqualsIgnoreCaseAscii( aSuffix ) ) 129 { 130 rResult.push_back( aFileName ); 131 break; 132 } 133 } 134 } 135 } 136 else if( bRecursive && aStatus.getFileType() == FileStatus::Directory ) 137 { 138 OUStringBuffer aSubDir( rDirectory ); 139 aSubDir.appendAscii( "/", 1 ); 140 aSubDir.append( aStatus.getFileName() ); 141 std::list< String > subfiles; 142 FindFiles( aSubDir.makeStringAndClear(), subfiles, rSuffixes, bRecursive ); 143 for( std::list< String >::const_iterator it = subfiles.begin(); it != subfiles.end(); ++it ) 144 { 145 OUStringBuffer aSubFile( aStatus.getFileName() ); 146 aSubFile.appendAscii( "/", 1 ); 147 aSubFile.append( *it ); 148 rResult.push_back( aSubFile.makeStringAndClear() ); 149 } 150 } 151 } |
152 } 153 aDir.close(); 154} 155 156/* 157 * DelMultiListBox 158 */ 159 160long DelMultiListBox::Notify( NotifyEvent& rEvent ) 161{ 162 long nRet = 0; 163 164 if( rEvent.GetType() == EVENT_KEYINPUT && 165 rEvent.GetKeyEvent()->GetKeyCode().GetCode() == KEY_DELETE ) 166 { 167 m_aDelPressedLink.Call( this ); 168 nRet = 1; 169 } | 152 } 153 aDir.close(); 154} 155 156/* 157 * DelMultiListBox 158 */ 159 160long DelMultiListBox::Notify( NotifyEvent& rEvent ) 161{ 162 long nRet = 0; 163 164 if( rEvent.GetType() == EVENT_KEYINPUT && 165 rEvent.GetKeyEvent()->GetKeyCode().GetCode() == KEY_DELETE ) 166 { 167 m_aDelPressedLink.Call( this ); 168 nRet = 1; 169 } |
170 else 171 nRet = MultiListBox::Notify( rEvent ); | 170 else 171 nRet = MultiListBox::Notify( rEvent ); |
172 173 return nRet; 174} 175 176/* 177 * DelListBox 178 */ 179 180long DelListBox::Notify( NotifyEvent& rEvent ) 181{ 182 long nRet = 0; 183 184 if( rEvent.GetType() == EVENT_KEYINPUT && 185 rEvent.GetKeyEvent()->GetKeyCode().GetCode() == KEY_DELETE ) 186 { 187 m_aDelPressedLink.Call( this ); 188 nRet = 1; 189 } | 172 173 return nRet; 174} 175 176/* 177 * DelListBox 178 */ 179 180long DelListBox::Notify( NotifyEvent& rEvent ) 181{ 182 long nRet = 0; 183 184 if( rEvent.GetType() == EVENT_KEYINPUT && 185 rEvent.GetKeyEvent()->GetKeyCode().GetCode() == KEY_DELETE ) 186 { 187 m_aDelPressedLink.Call( this ); 188 nRet = 1; 189 } |
190 else 191 nRet = ListBox::Notify( rEvent ); | 190 else 191 nRet = ListBox::Notify( rEvent ); |
192 193 return nRet; 194} 195 196/* 197 * QueryString 198 */ 199 200QueryString::QueryString( Window* pParent, String& rQuery, String& rRet, const ::std::list< String >& rChoices ) : 201 ModalDialog( pParent, PaResId( RID_STRINGQUERYDLG ) ), 202 m_aOKButton( this, PaResId( RID_STRQRY_BTN_OK ) ), 203 m_aCancelButton( this, PaResId( RID_STRQRY_BTN_CANCEL ) ), 204 m_aFixedText( this, PaResId( RID_STRQRY_TXT_RENAME ) ), 205 m_aEdit( this, PaResId( RID_STRQRY_EDT_NEWNAME ) ), | 192 193 return nRet; 194} 195 196/* 197 * QueryString 198 */ 199 200QueryString::QueryString( Window* pParent, String& rQuery, String& rRet, const ::std::list< String >& rChoices ) : 201 ModalDialog( pParent, PaResId( RID_STRINGQUERYDLG ) ), 202 m_aOKButton( this, PaResId( RID_STRQRY_BTN_OK ) ), 203 m_aCancelButton( this, PaResId( RID_STRQRY_BTN_CANCEL ) ), 204 m_aFixedText( this, PaResId( RID_STRQRY_TXT_RENAME ) ), 205 m_aEdit( this, PaResId( RID_STRQRY_EDT_NEWNAME ) ), |
206 m_aComboBox( this, PaResId( RID_STRQRY_BOX_NEWNAME ) ), | 206 m_aComboBox( this, PaResId( RID_STRQRY_BOX_NEWNAME ) ), |
207 m_rReturnValue( rRet ) 208{ 209 FreeResource(); 210 m_aOKButton.SetClickHdl( LINK( this, QueryString, ClickBtnHdl ) ); 211 m_aFixedText.SetText( rQuery ); | 207 m_rReturnValue( rRet ) 208{ 209 FreeResource(); 210 m_aOKButton.SetClickHdl( LINK( this, QueryString, ClickBtnHdl ) ); 211 m_aFixedText.SetText( rQuery ); |
212 if( rChoices.begin() != rChoices.end() ) 213 { 214 m_aComboBox.SetText( m_rReturnValue ); 215 m_aComboBox.InsertEntry( m_rReturnValue ); 216 for( ::std::list<String>::const_iterator it = rChoices.begin(); it != rChoices.end(); ++it ) 217 m_aComboBox.InsertEntry( *it ); 218 m_aEdit.Show( sal_False ); 219 m_bUseEdit = false; 220 } 221 else 222 { 223 m_aEdit.SetText( m_rReturnValue ); 224 m_aComboBox.Show( sal_False ); 225 m_bUseEdit = true; 226 } | 212 if( rChoices.begin() != rChoices.end() ) 213 { 214 m_aComboBox.SetText( m_rReturnValue ); 215 m_aComboBox.InsertEntry( m_rReturnValue ); 216 for( ::std::list<String>::const_iterator it = rChoices.begin(); it != rChoices.end(); ++it ) 217 m_aComboBox.InsertEntry( *it ); 218 m_aEdit.Show( sal_False ); 219 m_bUseEdit = false; 220 } 221 else 222 { 223 m_aEdit.SetText( m_rReturnValue ); 224 m_aComboBox.Show( sal_False ); 225 m_bUseEdit = true; 226 } |
227 SetText( Application::GetDisplayName() ); 228} 229 230QueryString::~QueryString() 231{ 232} 233 234IMPL_LINK( QueryString, ClickBtnHdl, Button*, pButton ) --- 42 unchanged lines hidden (view full) --- 277void padmin::freePadminRC() 278{ 279 if( pRC ) 280 delete pRC, pRC = NULL; 281} 282 283bool padmin::chooseDirectory( String& rInOutPath ) 284{ | 227 SetText( Application::GetDisplayName() ); 228} 229 230QueryString::~QueryString() 231{ 232} 233 234IMPL_LINK( QueryString, ClickBtnHdl, Button*, pButton ) --- 42 unchanged lines hidden (view full) --- 277void padmin::freePadminRC() 278{ 279 if( pRC ) 280 delete pRC, pRC = NULL; 281} 282 283bool padmin::chooseDirectory( String& rInOutPath ) 284{ |
285 bool bRet = false; 286 Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 287 if( xFactory.is() ) 288 { 289 Reference< XFolderPicker > xFolderPicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FolderPicker" ) ) ), UNO_QUERY ); 290 if( xFolderPicker.is() ) 291 { 292 Reference< XControlAccess > xCA( xFolderPicker, UNO_QUERY ); 293 if( xCA.is() ) 294 { 295 try 296 { 297 Any aState; 298 aState <<= sal_False; 299 xCA->setControlProperty( OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpButton" ) ), 300 OUString( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ), 301 aState ); | 285 bool bRet = false; 286 Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); 287 if( xFactory.is() ) 288 { 289 Reference< XFolderPicker > xFolderPicker( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FolderPicker" ) ) ), UNO_QUERY ); 290 if( xFolderPicker.is() ) 291 { 292 Reference< XControlAccess > xCA( xFolderPicker, UNO_QUERY ); 293 if( xCA.is() ) 294 { 295 try 296 { 297 Any aState; 298 aState <<= sal_False; 299 xCA->setControlProperty( OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpButton" ) ), 300 OUString( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ), 301 aState ); |
302 | 302 |
303 } 304 catch( ... ) 305 { 306 } 307 } 308 INetURLObject aObj( rInOutPath, INET_PROT_FILE, INetURLObject::ENCODE_ALL ); 309 xFolderPicker->setDisplayDirectory( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) ); 310 if( xFolderPicker->execute() == ExecutableDialogResults::OK ) 311 { 312 aObj = INetURLObject( xFolderPicker->getDirectory() ); 313 rInOutPath = aObj.PathToFileName(); 314 bRet = true; 315 } 316 } | 303 } 304 catch( ... ) 305 { 306 } 307 } 308 INetURLObject aObj( rInOutPath, INET_PROT_FILE, INetURLObject::ENCODE_ALL ); 309 xFolderPicker->setDisplayDirectory( aObj.GetMainURL(INetURLObject::DECODE_TO_IURI) ); 310 if( xFolderPicker->execute() == ExecutableDialogResults::OK ) 311 { 312 aObj = INetURLObject( xFolderPicker->getDirectory() ); 313 rInOutPath = aObj.PathToFileName(); 314 bRet = true; 315 } 316 } |
317#if OSL_DEBUG_LEVEL > 1 | 317#if OSL_DEBUG_LEVEL > 1 |
318 else 319 fprintf( stderr, "could not get FolderPicker service\n" ); | 318 else 319 fprintf( stderr, "could not get FolderPicker service\n" ); |
320#endif | 320#endif |
321 } 322 return bRet; | 321 } 322 return bRet; |
323} | 323} |
324 325/* vim: set noet sw=4 ts=4: */ |
|