diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-03-05 15:35:55 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-03-05 15:35:55 +0000 |
commit | 1bcf4b5cab91f86f782a9242730441530b912d7b (patch) | |
tree | 517dd480bb3732182c50510363348014dda453f8 /fpicker/source | |
parent | 0789c3d9ece3862b50cda8de945d376375b13d77 (diff) |
INTEGRATION: CWS aquafilepicker02_DEV300 (1.2.40); FILE MERGED
2008/01/14 08:23:24 fheckl 1.2.40.2: Code cleanup and some implementation details
2008/01/02 18:25:58 fheckl 1.2.40.1: issue #80399 more Cocoa
Diffstat (limited to 'fpicker/source')
-rw-r--r-- | fpicker/source/aqua/FPentry.cxx | 23 | ||||
-rw-r--r-- | fpicker/source/aqua/FilterHelper.cxx | 71 | ||||
-rw-r--r-- | fpicker/source/aqua/FilterHelper.hxx | 46 |
3 files changed, 67 insertions, 73 deletions
diff --git a/fpicker/source/aqua/FPentry.cxx b/fpicker/source/aqua/FPentry.cxx index e5239533e74c..853adbb07ffd 100644 --- a/fpicker/source/aqua/FPentry.cxx +++ b/fpicker/source/aqua/FPentry.cxx @@ -4,9 +4,9 @@ * * $RCSfile: FPentry.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: ihi $ $Date: 2007-07-11 10:58:21 $ + * last change: $Author: kz $ $Date: 2008-03-05 16:35:24 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -45,20 +45,21 @@ #include <com/sun/star/container/XSet.hpp> #endif -#ifndef _OSL_DIAGNOSE_H_ -#include <osl/diagnose.h> -#endif +// #ifndef _OSL_DIAGNOSE_H_ +// #include <osl/diagnose.h> +// #endif #ifndef _SALAQUAFILEPICKER_HXX_ #include "SalAquaFilePicker.hxx" #endif + #ifndef _SALAQUAFOLDERPICKER_HXX_ #include "SalAquaFolderPicker.hxx" #endif -#ifndef _SV_SVAPP_HXX -#include <vcl/svapp.hxx> -#endif +// #ifndef _SV_SVAPP_HXX +// #include <vcl/svapp.hxx> +// #endif #ifndef _FPSERVICEINFO_HXX_ #include "FPServiceInfo.hxx" @@ -85,16 +86,14 @@ static Reference< XInterface > SAL_CALL createFileInstance( const Reference< XMultiServiceFactory >& rServiceManager ) { return Reference< XInterface >( - static_cast< XFilePicker* >( - new SalAquaFilePicker( rServiceManager ) ) ); + *new SalAquaFilePicker( rServiceManager ) ); } static Reference< XInterface > SAL_CALL createFolderInstance( const Reference< XMultiServiceFactory >& rServiceManager ) { return Reference< XInterface >( - static_cast< XFolderPicker* >( - new SalAquaFolderPicker( rServiceManager ) ) ); + *new SalAquaFolderPicker( rServiceManager ) ); } //------------------------------------------------ diff --git a/fpicker/source/aqua/FilterHelper.cxx b/fpicker/source/aqua/FilterHelper.cxx index 3a0e7dc84eb1..7a2a5d883f02 100644 --- a/fpicker/source/aqua/FilterHelper.cxx +++ b/fpicker/source/aqua/FilterHelper.cxx @@ -4,9 +4,9 @@ * * $RCSfile: FilterHelper.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: ihi $ $Date: 2008-01-14 17:42:52 $ + * last change: $Author: kz $ $Date: 2008-03-05 16:35:39 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -39,19 +39,25 @@ #ifndef _VOS_MUTEX_HXX_ #include <vos/mutex.hxx> #endif + #ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> #endif -#ifndef _OSL_DIAGNOSE_H_ -#include <osl/diagnose.h> -#endif -#ifndef _FILTERHELPER_HXX_ -#include "FilterHelper.hxx" -#endif + +// #ifndef _OSL_DIAGNOSE_H_ +// #include <osl/diagnose.h> +// #endif + #ifndef _CFSTRINGUTILITIES_HXX_ #include "CFStringUtilities.hxx" #endif +#ifndef _NSSTRING_OOOADDITIONS_HXX_ +#include "NSString_OOoAdditions.hxx" +#endif + +#include "FilterHelper.hxx" + #pragma mark DEFINES #define CLASS_NAME "FilterEntry" @@ -209,14 +215,22 @@ FilterHelper::~FilterHelper() { DBG_PRINT_ENTRY(CLASS_NAME, __func__); + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + if (NULL != m_pFilterList) { delete m_pFilterList; } if (NULL != m_pFilterNames) { + //we called retain when we added the strings to the list, so we should release them now + for (NSStringList::iterator iter = m_pFilterNames->begin(); iter != m_pFilterNames->end(); iter++) { + [*iter release]; + } delete m_pFilterNames; } + [pool release]; + DBG_PRINT_EXIT(CLASS_NAME, __func__); } @@ -393,16 +407,10 @@ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno:: DBG_PRINT_EXIT(CLASS_NAME, __func__); } -sal_Bool FilterHelper::implFilterHandler(AEDesc *theItem, void *info, - void *callBackUD, - NavFilterModes filterMode) +sal_Bool FilterHelper::filenameMatchesFilter(NSString* sFilename) { DBG_PRINT_ENTRY(CLASS_NAME, __func__); - OSStatus status; - NavFileOrFolderInfo *theInfo = (NavFileOrFolderInfo*)info; - FSRef ref; - // OSL_TRACE("filter event handler called"); if (m_aCurrentFilter == NULL) { @@ -410,7 +418,9 @@ sal_Bool FilterHelper::implFilterHandler(AEDesc *theItem, void *info, return sal_True; } - if (theInfo->isFolder == true) { + NSFileManager *manager = [NSFileManager defaultManager]; + MacOSBOOL bDir = NO; + if ([manager fileExistsAtPath:sFilename isDirectory:&bDir] && bDir == YES) { // OSL_TRACE(" folder"); return sal_True; } @@ -424,26 +434,13 @@ sal_Bool FilterHelper::implFilterHandler(AEDesc *theItem, void *info, OUStringList suffixList = filter->getFilterSuffixList(); - AECoerceDesc (theItem, typeFSRef, theItem); - - char fileName[1024]; - if ( (status = AEGetDescData (theItem, &ref, sizeof (FSRef))) == noErr ) { // OSL_TRACE(" starting to work"); - status = FSRefMakePath(&ref, (UInt8*)fileName, 1023); - OSL_TRACE("filter file name: %s", fileName); - if (status == noErr) { - int nameLength = strlen(fileName); - if (nameLength < 4) { - return sal_False; - } else { - rtl::OUString aName = rtl::OUString::createFromAscii(fileName); - rtl::OUString allMatcher = rtl::OUString::createFromAscii(".*"); - for(OUStringList::iterator iter = suffixList.begin(); iter != suffixList.end(); iter++) { - if (aName.matchIgnoreAsciiCase(*iter, aName.getLength() - (*iter).getLength()) || ((*iter).equals(allMatcher))) { - return sal_True; - } - } + rtl::OUString aName = [sFilename OUString]; + rtl::OUString allMatcher = rtl::OUString::createFromAscii(".*"); + for(OUStringList::iterator iter = suffixList.begin(); iter != suffixList.end(); iter++) { + if (aName.matchIgnoreAsciiCase(*iter, aName.getLength() - (*iter).getLength()) || ((*iter).equals(allMatcher))) { + return sal_True; } } } @@ -460,16 +457,16 @@ FilterList* FilterHelper::getFilterList() { return m_pFilterList; } -CFStringList* FilterHelper::getFilterNames() { +NSStringList* FilterHelper::getFilterNames() { DBG_PRINT_ENTRY(CLASS_NAME, __func__); if (NULL == m_pFilterList) return NULL; if (NULL == m_pFilterNames) { //build filter names list - m_pFilterNames = new CFStringList; + m_pFilterNames = new NSStringList; for (FilterList::iterator iter = m_pFilterList->begin(); iter != m_pFilterList->end(); iter++) { - m_pFilterNames->push_back(CFStringCreateWithOUString(iter->getTitle())); + m_pFilterNames->push_back([[NSString stringWithOUString:iter->getTitle()] retain]); } } diff --git a/fpicker/source/aqua/FilterHelper.hxx b/fpicker/source/aqua/FilterHelper.hxx index 499773a863c6..6c55453c7c9b 100644 --- a/fpicker/source/aqua/FilterHelper.hxx +++ b/fpicker/source/aqua/FilterHelper.hxx @@ -4,9 +4,9 @@ * * $RCSfile: FilterHelper.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: ihi $ $Date: 2007-07-11 10:58:41 $ + * last change: $Author: kz $ $Date: 2008-03-05 16:35:55 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -36,21 +36,21 @@ #ifndef _FILTERHELPER_HXX_ #define _FILTERHELPER_HXX_ -#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_ -#include <com/sun/star/uno/Type.hxx> -#endif +// #ifndef _COM_SUN_STAR_UNO_TYPE_HXX_ +// #include <com/sun/star/uno/Type.hxx> +// #endif -#ifndef INCLUDED_CPPU_UNOTYPE_HXX -#include <cppu/unotype.hxx> -#endif +// #ifndef INCLUDED_CPPU_UNOTYPE_HXX +// #include <cppu/unotype.hxx> +// #endif -#ifndef _TYPELIB_TYPECLASS_H_ -#include "typelib/typeclass.h" -#endif +// #ifndef _TYPELIB_TYPECLASS_H_ +// #include "typelib/typeclass.h" +// #endif -#ifndef _TYPELIB_TYPEDESCRIPTION_H_ -#include "typelib/typedescription.h" -#endif +// #ifndef _TYPELIB_TYPEDESCRIPTION_H_ +// #include "typelib/typedescription.h" +// #endif #ifndef _COM_SUN_STAR_BEANS_STRINGPAIR_HPP_ #include <com/sun/star/beans/StringPair.hpp> @@ -68,20 +68,20 @@ #include <com/sun/star/uno/RuntimeException.hpp> #endif -#ifndef _RTL_USTRING_H_ -#include <rtl/ustring.hxx> -#endif +// #ifndef _RTL_USTRING_H_ +// #include <rtl/ustring.hxx> +// #endif #include <list> #include <vector> #include <premac.h> -#include <Carbon/Carbon.h> +#include <Cocoa/Cocoa.h> #include <postmac.h> typedef ::com::sun::star::beans::StringPair UnoFilterEntry; typedef ::com::sun::star::uno::Sequence< UnoFilterEntry > UnoFilterList; // can be transported more effectively -typedef ::std::list<CFStringRef> CFStringList; +typedef ::std::list<NSString *> NSStringList; typedef ::std::list<rtl::OUString> OUStringList; struct FilterEntry @@ -142,7 +142,7 @@ public: //accessor FilterList* getFilterList(); - CFStringList* getFilterNames(); + NSStringList* getFilterNames(); //misc void SetCurFilter( const rtl::OUString& rFilter ); @@ -150,14 +150,12 @@ public: OUStringList getCurrentFilterSuffixList(); int getCurrentFilterIndex(); void SetFilters(); - sal_Bool SAL_CALL implFilterHandler(AEDesc *theItem, void *info, - void *callBackUD, - NavFilterModes filterMode); + sal_Bool filenameMatchesFilter(NSString * sFilename); private: FilterList *m_pFilterList; rtl::OUString m_aCurrentFilter; - CFStringList *m_pFilterNames; + NSStringList *m_pFilterNames; int implAddFilter( const rtl::OUString rFilter, const OUStringList rSuffixList); int implAddFilterGroup( const rtl::OUString rFilter, |