[Libreoffice-commits] .: 4 commits - avmedia/Library_avmediaQuickTime.mk avmedia/source lingucomponent/Library_MacOSXSpell.mk lingucomponent/source solenv/gbuild
Michael Stahl
mst at kemper.freedesktop.org
Fri Dec 16 02:43:55 PST 2011
avmedia/Library_avmediaQuickTime.mk | 6
avmedia/source/quicktime/framegrabber.cxx | 155 --
avmedia/source/quicktime/framegrabber.mm | 155 ++
avmedia/source/quicktime/manager.cxx | 99 -
avmedia/source/quicktime/manager.mm | 99 +
avmedia/source/quicktime/player.cxx | 471 --------
avmedia/source/quicktime/player.mm | 471 ++++++++
avmedia/source/quicktime/quicktimeuno.cxx | 67 -
avmedia/source/quicktime/quicktimeuno.mm | 67 +
avmedia/source/quicktime/window.cxx | 354 ------
avmedia/source/quicktime/window.mm | 354 ++++++
lingucomponent/Library_MacOSXSpell.mk | 6
lingucomponent/source/spellcheck/macosxspell/macreg.cxx | 71 -
lingucomponent/source/spellcheck/macosxspell/macreg.mm | 71 +
lingucomponent/source/spellcheck/macosxspell/macspellimp.cxx | 623 -----------
lingucomponent/source/spellcheck/macosxspell/macspellimp.mm | 623 +++++++++++
solenv/gbuild/Library.mk | 12
solenv/gbuild/platform/macosx.mk | 2
solenv/gbuild/platform/solaris.mk | 6
solenv/gbuild/platform/unxgcc.mk | 2
20 files changed, 1861 insertions(+), 1853 deletions(-)
New commits:
commit b8fc450949f90981edf9e1dec82b0aaddd98426e
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Dec 16 11:29:53 2011 +0100
lingucomponent: MacOSX: use gb_Library_add_objcxxobjects
diff --git a/lingucomponent/Library_MacOSXSpell.mk b/lingucomponent/Library_MacOSXSpell.mk
index ee35fda..57c0640 100644
--- a/lingucomponent/Library_MacOSXSpell.mk
+++ b/lingucomponent/Library_MacOSXSpell.mk
@@ -56,13 +56,9 @@ $(eval $(call gb_Library_use_externals,MacOSXSpell,\
hunspell \
))
-$(eval $(call gb_Library_add_exception_objects,MacOSXSpell,\
+$(eval $(call gb_Library_add_objcxxobjects,MacOSXSpell,\
lingucomponent/source/spellcheck/macosxspell/macreg \
lingucomponent/source/spellcheck/macosxspell/macspellimp \
))
-$(eval $(call gb_Library_add_cxxflags,MacOSXSpell,\
- $(gb_LinkTarget_OBJCXXFLAGS) \
-))
-
# vim: set noet sw=4 ts=4:
diff --git a/lingucomponent/source/spellcheck/macosxspell/macreg.cxx b/lingucomponent/source/spellcheck/macosxspell/macreg.cxx
deleted file mode 100644
index 9020ace..0000000
--- a/lingucomponent/source/spellcheck/macosxspell/macreg.cxx
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * 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 <cppuhelper/factory.hxx> // helper for factories
-#include <rtl/string.hxx>
-
-#include <com/sun/star/registry/XRegistryKey.hpp>
-
-using namespace com::sun::star::lang;
-using namespace com::sun::star::registry;
-
-////////////////////////////////////////
-// declaration of external RegEntry-functions defined by the service objects
-//
-
-extern void * SAL_CALL MacSpellChecker_getFactory(
- const sal_Char * pImplName,
- XMultiServiceFactory * pServiceManager,
- void * /*pRegistryKey*/ );
-
-////////////////////////////////////////
-// definition of the two functions that are used to provide the services
-//
-
-extern "C"
-{
-
-SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
- const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
-{
- void * pRet = NULL;
- pRet = MacSpellChecker_getFactory(
- pImplName,
- reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
- pRegistryKey );
-
- return pRet;
-}
-
-}
-
-///////////////////////////////////////////////////////////////////////////
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lingucomponent/source/spellcheck/macosxspell/macreg.mm b/lingucomponent/source/spellcheck/macosxspell/macreg.mm
new file mode 100644
index 0000000..9020ace
--- /dev/null
+++ b/lingucomponent/source/spellcheck/macosxspell/macreg.mm
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 <cppuhelper/factory.hxx> // helper for factories
+#include <rtl/string.hxx>
+
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+////////////////////////////////////////
+// declaration of external RegEntry-functions defined by the service objects
+//
+
+extern void * SAL_CALL MacSpellChecker_getFactory(
+ const sal_Char * pImplName,
+ XMultiServiceFactory * pServiceManager,
+ void * /*pRegistryKey*/ );
+
+////////////////////////////////////////
+// definition of the two functions that are used to provide the services
+//
+
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = NULL;
+ pRet = MacSpellChecker_getFactory(
+ pImplName,
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ pRegistryKey );
+
+ return pRet;
+}
+
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.cxx b/lingucomponent/source/spellcheck/macosxspell/macspellimp.cxx
deleted file mode 100644
index 5baf4d4..0000000
--- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.cxx
+++ /dev/null
@@ -1,623 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * 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/uno/Reference.h>
-#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
-
-#include <com/sun/star/linguistic2/SpellFailure.hpp>
-#include <cppuhelper/factory.hxx> // helper for factories
-#include <com/sun/star/registry/XRegistryKey.hpp>
-#include <tools/debug.hxx>
-#include <osl/mutex.hxx>
-
-#include <dictmgr.hxx>
-#include <macspellimp.hxx>
-
-#include <linguistic/spelldta.hxx>
-#include <unotools/pathoptions.hxx>
-#include <unotools/useroptions.hxx>
-#include <osl/file.hxx>
-#include <rtl/ustrbuf.hxx>
-
-using namespace utl;
-using namespace osl;
-using namespace com::sun::star;
-using namespace com::sun::star::beans;
-using namespace com::sun::star::lang;
-using namespace com::sun::star::uno;
-using namespace com::sun::star::linguistic2;
-using namespace linguistic;
-
-using ::rtl::OUString;
-using ::rtl::OString;
-using ::rtl::OUStringBuffer;
-using ::rtl::OUStringToOString;
-
-///////////////////////////////////////////////////////////////////////////
-
-MacSpellChecker::MacSpellChecker() :
- aEvtListeners ( GetLinguMutex() )
-{
- aDEncs = NULL;
- aDLocs = NULL;
- aDNames = NULL;
- bDisposing = sal_False;
- pPropHelper = NULL;
- numdict = 0;
- NSApplicationLoad();
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- macSpell = [NSSpellChecker sharedSpellChecker];
- macTag = [NSSpellChecker uniqueSpellDocumentTag];
- [pool release];
-}
-
-
-MacSpellChecker::~MacSpellChecker()
-{
- numdict = 0;
- if (aDEncs) delete[] aDEncs;
- aDEncs = NULL;
- if (aDLocs) delete[] aDLocs;
- aDLocs = NULL;
- if (aDNames) delete[] aDNames;
- aDNames = NULL;
- if (pPropHelper)
- pPropHelper->RemoveAsPropListener();
-}
-
-
-PropertyHelper_Spell & MacSpellChecker::GetPropHelper_Impl()
-{
- if (!pPropHelper)
- {
- Reference< XPropertySet > xPropSet( GetLinguProperties(), UNO_QUERY );
-
- pPropHelper = new PropertyHelper_Spell( (XSpellChecker *) this, xPropSet );
- xPropHelper = pPropHelper;
- pPropHelper->AddAsPropListener(); //! after a reference is established
- }
- return *pPropHelper;
-}
-
-
-Sequence< Locale > SAL_CALL MacSpellChecker::getLocales()
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- // this routine should return the locales supported by the installed
- // dictionaries. So here we need to parse both the user edited
- // dictionary list and the shared dictionary list
- // to see what dictionaries the admin/user has installed
-
- int numusr; // number of user dictionary entries
- int numshr; // number of shared dictionary entries
- dictentry * spdict; // shared dict entry pointer
- dictentry * updict; // user dict entry pointer
- SvtPathOptions aPathOpt;
- rtl_TextEncoding aEnc = RTL_TEXTENCODING_UTF8;
-
- std::vector<NSString *> postspdict;
- std::vector<dictentry *> postupdict;
-
-
- if (!numdict) {
-
- // invoke a dictionary manager to get the user dictionary list
- // TODO How on Mac OS X?
-
- // invoke a second dictionary manager to get the shared dictionary list
- NSArray *aLocales = [NSLocale availableLocaleIdentifiers];
-
- //Test for existence of the dictionaries
- for (unsigned int i = 0; i < [aLocales count]; i++)
- {
- if( [macSpell setLanguage:[aLocales objectAtIndex:i] ] )
- {
- postspdict.push_back( [ aLocales objectAtIndex:i ] );
- }
- }
-
- numusr = postupdict.size();
- numshr = postspdict.size();
-
- // we really should merge these and remove duplicates but since
- // users can name their dictionaries anything they want it would
- // be impossible to know if a real duplication exists unless we
- // add some unique key to each myspell dictionary
- numdict = numshr + numusr;
-
- if (numdict) {
- aDLocs = new Locale [numdict];
- aDEncs = new rtl_TextEncoding [numdict];
- aDNames = new OUString [numdict];
- aSuppLocales.realloc(numdict);
- Locale * pLocale = aSuppLocales.getArray();
- int numlocs = 0;
- int newloc;
- int i,j;
- int k = 0;
-
- //first add the user dictionaries
- //TODO for MAC?
-
- // now add the shared dictionaries
- for (i = 0; i < numshr; i++) {
- NSDictionary *aLocDict = [ NSLocale componentsFromLocaleIdentifier:postspdict[i] ];
- NSString* aLang = [ aLocDict objectForKey:NSLocaleLanguageCode ];
- NSString* aCountry = [ aLocDict objectForKey:NSLocaleCountryCode ];
- OUString lang([aLang cStringUsingEncoding: NSUTF8StringEncoding], [aLang length], aEnc);
- OUString country([ aCountry cStringUsingEncoding: NSUTF8StringEncoding], [aCountry length], aEnc);
- Locale nLoc( lang, country, OUString() );
- newloc = 1;
- //eliminate duplicates (is this needed for MacOS?)
- for (j = 0; j < numlocs; j++) {
- if (nLoc == pLocale[j]) newloc = 0;
- }
- if (newloc) {
- pLocale[numlocs] = nLoc;
- numlocs++;
- }
- aDLocs[k] = nLoc;
- aDEncs[k] = 0;
- k++;
- }
-
- aSuppLocales.realloc(numlocs);
-
- } else {
- /* no dictionary.lst found so register no dictionaries */
- numdict = 0;
- aDEncs = NULL;
- aDLocs = NULL;
- aDNames = NULL;
- aSuppLocales.realloc(0);
- }
-
- /* de-allocation of memory is handled inside the DictMgr */
- updict = NULL;
- spdict = NULL;
-
- }
-
- return aSuppLocales;
-}
-
-
-
-sal_Bool SAL_CALL MacSpellChecker::hasLocale(const Locale& rLocale)
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- sal_Bool bRes = sal_False;
- if (!aSuppLocales.getLength())
- getLocales();
-
- sal_Int32 nLen = aSuppLocales.getLength();
- for (sal_Int32 i = 0; i < nLen; ++i)
- {
- const Locale *pLocale = aSuppLocales.getConstArray();
- if (rLocale == pLocale[i])
- {
- bRes = sal_True;
- break;
- }
- }
- return bRes;
-}
-
-
-sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocale )
-{
- rtl_TextEncoding aEnc;
-
- // initialize a myspell object for each dictionary once
- // (note: mutex is held higher up in isValid)
-
-
- sal_Int16 nRes = -1;
-
- // first handle smart quotes both single and double
- OUStringBuffer rBuf(rWord);
- sal_Int32 n = rBuf.getLength();
- sal_Unicode c;
- for (sal_Int32 ix=0; ix < n; ix++) {
- c = rBuf[ix];
- if ((c == 0x201C) || (c == 0x201D)) rBuf[ix] = (sal_Unicode)0x0022;
- if ((c == 0x2018) || (c == 0x2019)) rBuf[ix] = (sal_Unicode)0x0027;
- }
- OUString nWord(rBuf.makeStringAndClear());
-
- if (n)
- {
- aEnc = 0;
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSString* aNSStr = [[NSString alloc] initWithCharacters: nWord.getStr() length: nWord.getLength()];
- NSString* aLang = [[NSString alloc] initWithCharacters: rLocale.Language.getStr() length: rLocale.Language.getLength()];
- if(rLocale.Country.getLength()>0)
- {
- NSString* aCountry = [[NSString alloc] initWithCharacters: rLocale.Country.getStr() length: rLocale.Country.getLength()];
- NSString* aTag = @"_";
- NSString* aTaggedCountry = [aTag stringByAppendingString:aCountry];
- [aLang autorelease];
- aLang = [aLang stringByAppendingString:aTaggedCountry];
- }
-
- int aCount;
- NSRange range = [macSpell checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:sal_False inSpellDocumentWithTag:macTag wordCount:&aCount];
- int rVal = 0;
- if(range.length>0)
- {
- rVal = -1;
- }
- else
- {
- rVal = 1;
- }
- [pool release];
- if (rVal != 1)
- {
- nRes = SpellFailure::SPELLING_ERROR;
- } else {
- return -1;
- }
- }
- return nRes;
-}
-
-
-
-sal_Bool SAL_CALL
- MacSpellChecker::isValid( const OUString& rWord, const Locale& rLocale,
- const PropertyValues& rProperties )
- throw(IllegalArgumentException, RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- if (rLocale == Locale() || !rWord.getLength())
- return sal_True;
-
- if (!hasLocale( rLocale ))
-#ifdef LINGU_EXCEPTIONS
- throw( IllegalArgumentException() );
-#else
- return sal_True;
-#endif
-
- // Get property values to be used.
- // These are be the default values set in the SN_LINGU_PROPERTIES
- // PropertySet which are overridden by the supplied ones from the
- // last argument.
- // You'll probably like to use a simplier solution than the provided
- // one using the PropertyHelper_Spell.
-
- PropertyHelper_Spell &rHelper = GetPropHelper();
- rHelper.SetTmpPropVals( rProperties );
-
- sal_Int16 nFailure = GetSpellFailure( rWord, rLocale );
- if (nFailure != -1)
- {
- sal_Int16 nLang = LocaleToLanguage( rLocale );
- // postprocess result for errors that should be ignored
- if ( (!rHelper.IsSpellUpperCase() && IsUpper( rWord, nLang ))
- || (!rHelper.IsSpellWithDigits() && HasDigits( rWord ))
- || (!rHelper.IsSpellCapitalization()
- && nFailure == SpellFailure::CAPTION_ERROR)
- )
- nFailure = -1;
- }
-
- return (nFailure == -1);
-}
-
-
-Reference< XSpellAlternatives >
- MacSpellChecker::GetProposals( const OUString &rWord, const Locale &rLocale )
-{
- // Retrieves the return values for the 'spell' function call in case
- // of a misspelled word.
- // Especially it may give a list of suggested (correct) words:
-
- Reference< XSpellAlternatives > xRes;
- // note: mutex is held by higher up by spell which covers both
-
- sal_Int16 nLang = LocaleToLanguage( rLocale );
- int count;
- Sequence< OUString > aStr( 0 );
-
- // first handle smart quotes (single and double)
- OUStringBuffer rBuf(rWord);
- sal_Int32 n = rBuf.getLength();
- sal_Unicode c;
- for (sal_Int32 ix=0; ix < n; ix++) {
- c = rBuf[ix];
- if ((c == 0x201C) || (c == 0x201D)) rBuf[ix] = (sal_Unicode)0x0022;
- if ((c == 0x2018) || (c == 0x2019)) rBuf[ix] = (sal_Unicode)0x0027;
- }
- OUString nWord(rBuf.makeStringAndClear());
-
- if (n)
- {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSString* aNSStr = [[NSString alloc] initWithCharacters: nWord.getStr() length: nWord.getLength()];
- NSString* aLang = [[NSString alloc] initWithCharacters: rLocale.Language.getStr() length: rLocale.Language.getLength() ];
- if(rLocale.Country.getLength()>0)
- {
- NSString* aCountry = [[NSString alloc] initWithCharacters: rLocale.Country.getStr() length: rLocale.Country.getLength() ];
- NSString* aTag = @"_";
- NSString* aTaggedCountry = [aTag stringByAppendingString:aCountry];
- [aLang autorelease];
- aLang = [aLang stringByAppendingString:aTaggedCountry];
- }
- [macSpell setLanguage:aLang];
- NSArray *guesses = [macSpell guessesForWord:aNSStr];
- count = [guesses count];
- if (count)
- {
- aStr.realloc( count );
- OUString *pStr = aStr.getArray();
- for (int ii=0; ii < count; ii++)
- {
- // if needed add: if (suglst[ii] == NULL) continue;
- NSString* guess = [guesses objectAtIndex:ii];
- OUString cvtwrd((const sal_Unicode*)[guess cStringUsingEncoding:NSUnicodeStringEncoding], (sal_Int32)[guess length]);
- pStr[ii] = cvtwrd;
- }
- }
- [pool release];
- }
-
- // now return an empty alternative for no suggestions or the list of alternatives if some found
- SpellAlternatives *pAlt = new SpellAlternatives;
- String aTmp(rWord);
- pAlt->SetWordLanguage( aTmp, nLang );
- pAlt->SetFailureType( SpellFailure::SPELLING_ERROR );
- pAlt->SetAlternatives( aStr );
- xRes = pAlt;
- return xRes;
-
-}
-
-
-
-
-Reference< XSpellAlternatives > SAL_CALL
- MacSpellChecker::spell( const OUString& rWord, const Locale& rLocale,
- const PropertyValues& rProperties )
- throw(IllegalArgumentException, RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- if (rLocale == Locale() || !rWord.getLength())
- return NULL;
-
- if (!hasLocale( rLocale ))
-#ifdef LINGU_EXCEPTIONS
- throw( IllegalArgumentException() );
-#else
- return NULL;
-#endif
-
- Reference< XSpellAlternatives > xAlt;
- if (!isValid( rWord, rLocale, rProperties ))
- {
- xAlt = GetProposals( rWord, rLocale );
- }
- return xAlt;
-}
-
-
-Reference< XInterface > SAL_CALL MacSpellChecker_CreateInstance(
- const Reference< XMultiServiceFactory > & /*rSMgr*/ )
- throw(Exception)
-{
-
- Reference< XInterface > xService = (cppu::OWeakObject*) new MacSpellChecker;
- return xService;
-}
-
-
-sal_Bool SAL_CALL
- MacSpellChecker::addLinguServiceEventListener(
- const Reference< XLinguServiceEventListener >& rxLstnr )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- sal_Bool bRes = sal_False;
- if (!bDisposing && rxLstnr.is())
- {
- bRes = GetPropHelper().addLinguServiceEventListener( rxLstnr );
- }
- return bRes;
-}
-
-
-sal_Bool SAL_CALL
- MacSpellChecker::removeLinguServiceEventListener(
- const Reference< XLinguServiceEventListener >& rxLstnr )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- sal_Bool bRes = sal_False;
- if (!bDisposing && rxLstnr.is())
- {
- DBG_ASSERT( xPropHelper.is(), "xPropHelper non existent" );
- bRes = GetPropHelper().removeLinguServiceEventListener( rxLstnr );
- }
- return bRes;
-}
-
-
-OUString SAL_CALL
- MacSpellChecker::getServiceDisplayName( const Locale& /*rLocale*/ )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
- return A2OU( "Mac OS X Spell Checker" );
-}
-
-
-void SAL_CALL
- MacSpellChecker::initialize( const Sequence< Any >& rArguments )
- throw(Exception, RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- if (!pPropHelper)
- {
- sal_Int32 nLen = rArguments.getLength();
- if (2 == nLen)
- {
- Reference< XPropertySet > xPropSet;
- rArguments.getConstArray()[0] >>= xPropSet;
- //rArguments.getConstArray()[1] >>= xDicList;
-
- //! Pointer allows for access of the non-UNO functions.
- //! And the reference to the UNO-functions while increasing
- //! the ref-count and will implicitly free the memory
- //! when the object is not longer used.
- pPropHelper = new PropertyHelper_Spell( (XSpellChecker *) this, xPropSet );
- xPropHelper = pPropHelper;
- pPropHelper->AddAsPropListener(); //! after a reference is established
- }
- else
- OSL_FAIL( "wrong number of arguments in sequence" );
-
- }
-}
-
-
-void SAL_CALL
- MacSpellChecker::dispose()
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- if (!bDisposing)
- {
- bDisposing = sal_True;
- EventObject aEvtObj( (XSpellChecker *) this );
- aEvtListeners.disposeAndClear( aEvtObj );
- }
-}
-
-
-void SAL_CALL
- MacSpellChecker::addEventListener( const Reference< XEventListener >& rxListener )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- if (!bDisposing && rxListener.is())
- aEvtListeners.addInterface( rxListener );
-}
-
-
-void SAL_CALL
- MacSpellChecker::removeEventListener( const Reference< XEventListener >& rxListener )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- if (!bDisposing && rxListener.is())
- aEvtListeners.removeInterface( rxListener );
-}
-
-
-///////////////////////////////////////////////////////////////////////////
-// Service specific part
-//
-
-OUString SAL_CALL MacSpellChecker::getImplementationName()
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- return getImplementationName_Static();
-}
-
-
-sal_Bool SAL_CALL MacSpellChecker::supportsService( const OUString& ServiceName )
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- Sequence< OUString > aSNL = getSupportedServiceNames();
- const OUString * pArray = aSNL.getConstArray();
- for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
- if( pArray[i] == ServiceName )
- return sal_True;
- return sal_False;
-}
-
-
-Sequence< OUString > SAL_CALL MacSpellChecker::getSupportedServiceNames()
- throw(RuntimeException)
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- return getSupportedServiceNames_Static();
-}
-
-
-Sequence< OUString > MacSpellChecker::getSupportedServiceNames_Static()
- throw()
-{
- MutexGuard aGuard( GetLinguMutex() );
-
- Sequence< OUString > aSNS( 1 ); // auch mehr als 1 Service moeglich
- aSNS.getArray()[0] = A2OU( SN_SPELLCHECKER );
- return aSNS;
-}
-
-void * SAL_CALL MacSpellChecker_getFactory( const sal_Char * pImplName,
- XMultiServiceFactory * pServiceManager, void * )
-{
- void * pRet = 0;
- if ( !MacSpellChecker::getImplementationName_Static().compareToAscii( pImplName ) )
- {
- Reference< XSingleServiceFactory > xFactory =
- cppu::createOneInstanceFactory(
- pServiceManager,
- MacSpellChecker::getImplementationName_Static(),
- MacSpellChecker_CreateInstance,
- MacSpellChecker::getSupportedServiceNames_Static());
- // acquire, because we return an interface pointer instead of a reference
- xFactory->acquire();
- pRet = xFactory.get();
- }
- return pRet;
-}
-
-
-///////////////////////////////////////////////////////////////////////////
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm
new file mode 100644
index 0000000..5baf4d4
--- /dev/null
+++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm
@@ -0,0 +1,623 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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/uno/Reference.h>
+#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
+
+#include <com/sun/star/linguistic2/SpellFailure.hpp>
+#include <cppuhelper/factory.hxx> // helper for factories
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <tools/debug.hxx>
+#include <osl/mutex.hxx>
+
+#include <dictmgr.hxx>
+#include <macspellimp.hxx>
+
+#include <linguistic/spelldta.hxx>
+#include <unotools/pathoptions.hxx>
+#include <unotools/useroptions.hxx>
+#include <osl/file.hxx>
+#include <rtl/ustrbuf.hxx>
+
+using namespace utl;
+using namespace osl;
+using namespace com::sun::star;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::linguistic2;
+using namespace linguistic;
+
+using ::rtl::OUString;
+using ::rtl::OString;
+using ::rtl::OUStringBuffer;
+using ::rtl::OUStringToOString;
+
+///////////////////////////////////////////////////////////////////////////
+
+MacSpellChecker::MacSpellChecker() :
+ aEvtListeners ( GetLinguMutex() )
+{
+ aDEncs = NULL;
+ aDLocs = NULL;
+ aDNames = NULL;
+ bDisposing = sal_False;
+ pPropHelper = NULL;
+ numdict = 0;
+ NSApplicationLoad();
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ macSpell = [NSSpellChecker sharedSpellChecker];
+ macTag = [NSSpellChecker uniqueSpellDocumentTag];
+ [pool release];
+}
+
+
+MacSpellChecker::~MacSpellChecker()
+{
+ numdict = 0;
+ if (aDEncs) delete[] aDEncs;
+ aDEncs = NULL;
+ if (aDLocs) delete[] aDLocs;
+ aDLocs = NULL;
+ if (aDNames) delete[] aDNames;
+ aDNames = NULL;
+ if (pPropHelper)
+ pPropHelper->RemoveAsPropListener();
+}
+
+
+PropertyHelper_Spell & MacSpellChecker::GetPropHelper_Impl()
+{
+ if (!pPropHelper)
+ {
+ Reference< XPropertySet > xPropSet( GetLinguProperties(), UNO_QUERY );
+
+ pPropHelper = new PropertyHelper_Spell( (XSpellChecker *) this, xPropSet );
+ xPropHelper = pPropHelper;
+ pPropHelper->AddAsPropListener(); //! after a reference is established
+ }
+ return *pPropHelper;
+}
+
+
+Sequence< Locale > SAL_CALL MacSpellChecker::getLocales()
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ // this routine should return the locales supported by the installed
+ // dictionaries. So here we need to parse both the user edited
+ // dictionary list and the shared dictionary list
+ // to see what dictionaries the admin/user has installed
+
+ int numusr; // number of user dictionary entries
+ int numshr; // number of shared dictionary entries
+ dictentry * spdict; // shared dict entry pointer
+ dictentry * updict; // user dict entry pointer
+ SvtPathOptions aPathOpt;
+ rtl_TextEncoding aEnc = RTL_TEXTENCODING_UTF8;
+
+ std::vector<NSString *> postspdict;
+ std::vector<dictentry *> postupdict;
+
+
+ if (!numdict) {
+
+ // invoke a dictionary manager to get the user dictionary list
+ // TODO How on Mac OS X?
+
+ // invoke a second dictionary manager to get the shared dictionary list
+ NSArray *aLocales = [NSLocale availableLocaleIdentifiers];
+
+ //Test for existence of the dictionaries
+ for (unsigned int i = 0; i < [aLocales count]; i++)
+ {
+ if( [macSpell setLanguage:[aLocales objectAtIndex:i] ] )
+ {
+ postspdict.push_back( [ aLocales objectAtIndex:i ] );
+ }
+ }
+
+ numusr = postupdict.size();
+ numshr = postspdict.size();
+
+ // we really should merge these and remove duplicates but since
+ // users can name their dictionaries anything they want it would
+ // be impossible to know if a real duplication exists unless we
+ // add some unique key to each myspell dictionary
+ numdict = numshr + numusr;
+
+ if (numdict) {
+ aDLocs = new Locale [numdict];
+ aDEncs = new rtl_TextEncoding [numdict];
+ aDNames = new OUString [numdict];
+ aSuppLocales.realloc(numdict);
+ Locale * pLocale = aSuppLocales.getArray();
+ int numlocs = 0;
+ int newloc;
+ int i,j;
+ int k = 0;
+
+ //first add the user dictionaries
+ //TODO for MAC?
+
+ // now add the shared dictionaries
+ for (i = 0; i < numshr; i++) {
+ NSDictionary *aLocDict = [ NSLocale componentsFromLocaleIdentifier:postspdict[i] ];
+ NSString* aLang = [ aLocDict objectForKey:NSLocaleLanguageCode ];
+ NSString* aCountry = [ aLocDict objectForKey:NSLocaleCountryCode ];
+ OUString lang([aLang cStringUsingEncoding: NSUTF8StringEncoding], [aLang length], aEnc);
+ OUString country([ aCountry cStringUsingEncoding: NSUTF8StringEncoding], [aCountry length], aEnc);
+ Locale nLoc( lang, country, OUString() );
+ newloc = 1;
+ //eliminate duplicates (is this needed for MacOS?)
+ for (j = 0; j < numlocs; j++) {
+ if (nLoc == pLocale[j]) newloc = 0;
+ }
+ if (newloc) {
+ pLocale[numlocs] = nLoc;
+ numlocs++;
+ }
+ aDLocs[k] = nLoc;
+ aDEncs[k] = 0;
+ k++;
+ }
+
+ aSuppLocales.realloc(numlocs);
+
+ } else {
+ /* no dictionary.lst found so register no dictionaries */
+ numdict = 0;
+ aDEncs = NULL;
+ aDLocs = NULL;
+ aDNames = NULL;
+ aSuppLocales.realloc(0);
+ }
+
+ /* de-allocation of memory is handled inside the DictMgr */
+ updict = NULL;
+ spdict = NULL;
+
+ }
+
+ return aSuppLocales;
+}
+
+
+
+sal_Bool SAL_CALL MacSpellChecker::hasLocale(const Locale& rLocale)
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ sal_Bool bRes = sal_False;
+ if (!aSuppLocales.getLength())
+ getLocales();
+
+ sal_Int32 nLen = aSuppLocales.getLength();
+ for (sal_Int32 i = 0; i < nLen; ++i)
+ {
+ const Locale *pLocale = aSuppLocales.getConstArray();
+ if (rLocale == pLocale[i])
+ {
+ bRes = sal_True;
+ break;
+ }
+ }
+ return bRes;
+}
+
+
+sal_Int16 MacSpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocale )
+{
+ rtl_TextEncoding aEnc;
+
+ // initialize a myspell object for each dictionary once
+ // (note: mutex is held higher up in isValid)
+
+
+ sal_Int16 nRes = -1;
+
+ // first handle smart quotes both single and double
+ OUStringBuffer rBuf(rWord);
+ sal_Int32 n = rBuf.getLength();
+ sal_Unicode c;
+ for (sal_Int32 ix=0; ix < n; ix++) {
+ c = rBuf[ix];
+ if ((c == 0x201C) || (c == 0x201D)) rBuf[ix] = (sal_Unicode)0x0022;
+ if ((c == 0x2018) || (c == 0x2019)) rBuf[ix] = (sal_Unicode)0x0027;
+ }
+ OUString nWord(rBuf.makeStringAndClear());
+
+ if (n)
+ {
+ aEnc = 0;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NSString* aNSStr = [[NSString alloc] initWithCharacters: nWord.getStr() length: nWord.getLength()];
+ NSString* aLang = [[NSString alloc] initWithCharacters: rLocale.Language.getStr() length: rLocale.Language.getLength()];
+ if(rLocale.Country.getLength()>0)
+ {
+ NSString* aCountry = [[NSString alloc] initWithCharacters: rLocale.Country.getStr() length: rLocale.Country.getLength()];
+ NSString* aTag = @"_";
+ NSString* aTaggedCountry = [aTag stringByAppendingString:aCountry];
+ [aLang autorelease];
+ aLang = [aLang stringByAppendingString:aTaggedCountry];
+ }
+
+ int aCount;
+ NSRange range = [macSpell checkSpellingOfString:aNSStr startingAt:0 language:aLang wrap:sal_False inSpellDocumentWithTag:macTag wordCount:&aCount];
+ int rVal = 0;
+ if(range.length>0)
+ {
+ rVal = -1;
+ }
+ else
+ {
+ rVal = 1;
+ }
+ [pool release];
+ if (rVal != 1)
+ {
+ nRes = SpellFailure::SPELLING_ERROR;
+ } else {
+ return -1;
+ }
+ }
+ return nRes;
+}
+
+
+
+sal_Bool SAL_CALL
+ MacSpellChecker::isValid( const OUString& rWord, const Locale& rLocale,
+ const PropertyValues& rProperties )
+ throw(IllegalArgumentException, RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ if (rLocale == Locale() || !rWord.getLength())
+ return sal_True;
+
+ if (!hasLocale( rLocale ))
+#ifdef LINGU_EXCEPTIONS
+ throw( IllegalArgumentException() );
+#else
+ return sal_True;
+#endif
+
+ // Get property values to be used.
+ // These are be the default values set in the SN_LINGU_PROPERTIES
+ // PropertySet which are overridden by the supplied ones from the
+ // last argument.
+ // You'll probably like to use a simplier solution than the provided
+ // one using the PropertyHelper_Spell.
+
+ PropertyHelper_Spell &rHelper = GetPropHelper();
+ rHelper.SetTmpPropVals( rProperties );
+
+ sal_Int16 nFailure = GetSpellFailure( rWord, rLocale );
+ if (nFailure != -1)
+ {
+ sal_Int16 nLang = LocaleToLanguage( rLocale );
+ // postprocess result for errors that should be ignored
+ if ( (!rHelper.IsSpellUpperCase() && IsUpper( rWord, nLang ))
+ || (!rHelper.IsSpellWithDigits() && HasDigits( rWord ))
+ || (!rHelper.IsSpellCapitalization()
+ && nFailure == SpellFailure::CAPTION_ERROR)
+ )
+ nFailure = -1;
+ }
+
+ return (nFailure == -1);
+}
+
+
+Reference< XSpellAlternatives >
+ MacSpellChecker::GetProposals( const OUString &rWord, const Locale &rLocale )
+{
+ // Retrieves the return values for the 'spell' function call in case
+ // of a misspelled word.
+ // Especially it may give a list of suggested (correct) words:
+
+ Reference< XSpellAlternatives > xRes;
+ // note: mutex is held by higher up by spell which covers both
+
+ sal_Int16 nLang = LocaleToLanguage( rLocale );
+ int count;
+ Sequence< OUString > aStr( 0 );
+
+ // first handle smart quotes (single and double)
+ OUStringBuffer rBuf(rWord);
+ sal_Int32 n = rBuf.getLength();
+ sal_Unicode c;
+ for (sal_Int32 ix=0; ix < n; ix++) {
+ c = rBuf[ix];
+ if ((c == 0x201C) || (c == 0x201D)) rBuf[ix] = (sal_Unicode)0x0022;
+ if ((c == 0x2018) || (c == 0x2019)) rBuf[ix] = (sal_Unicode)0x0027;
+ }
+ OUString nWord(rBuf.makeStringAndClear());
+
+ if (n)
+ {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NSString* aNSStr = [[NSString alloc] initWithCharacters: nWord.getStr() length: nWord.getLength()];
+ NSString* aLang = [[NSString alloc] initWithCharacters: rLocale.Language.getStr() length: rLocale.Language.getLength() ];
+ if(rLocale.Country.getLength()>0)
+ {
+ NSString* aCountry = [[NSString alloc] initWithCharacters: rLocale.Country.getStr() length: rLocale.Country.getLength() ];
+ NSString* aTag = @"_";
+ NSString* aTaggedCountry = [aTag stringByAppendingString:aCountry];
+ [aLang autorelease];
+ aLang = [aLang stringByAppendingString:aTaggedCountry];
+ }
+ [macSpell setLanguage:aLang];
+ NSArray *guesses = [macSpell guessesForWord:aNSStr];
+ count = [guesses count];
+ if (count)
+ {
+ aStr.realloc( count );
+ OUString *pStr = aStr.getArray();
+ for (int ii=0; ii < count; ii++)
+ {
+ // if needed add: if (suglst[ii] == NULL) continue;
+ NSString* guess = [guesses objectAtIndex:ii];
+ OUString cvtwrd((const sal_Unicode*)[guess cStringUsingEncoding:NSUnicodeStringEncoding], (sal_Int32)[guess length]);
+ pStr[ii] = cvtwrd;
+ }
+ }
+ [pool release];
+ }
+
+ // now return an empty alternative for no suggestions or the list of alternatives if some found
+ SpellAlternatives *pAlt = new SpellAlternatives;
+ String aTmp(rWord);
+ pAlt->SetWordLanguage( aTmp, nLang );
+ pAlt->SetFailureType( SpellFailure::SPELLING_ERROR );
+ pAlt->SetAlternatives( aStr );
+ xRes = pAlt;
+ return xRes;
+
+}
+
+
+
+
+Reference< XSpellAlternatives > SAL_CALL
+ MacSpellChecker::spell( const OUString& rWord, const Locale& rLocale,
+ const PropertyValues& rProperties )
+ throw(IllegalArgumentException, RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ if (rLocale == Locale() || !rWord.getLength())
+ return NULL;
+
+ if (!hasLocale( rLocale ))
+#ifdef LINGU_EXCEPTIONS
+ throw( IllegalArgumentException() );
+#else
+ return NULL;
+#endif
+
+ Reference< XSpellAlternatives > xAlt;
+ if (!isValid( rWord, rLocale, rProperties ))
+ {
+ xAlt = GetProposals( rWord, rLocale );
+ }
+ return xAlt;
+}
+
+
+Reference< XInterface > SAL_CALL MacSpellChecker_CreateInstance(
+ const Reference< XMultiServiceFactory > & /*rSMgr*/ )
+ throw(Exception)
+{
+
+ Reference< XInterface > xService = (cppu::OWeakObject*) new MacSpellChecker;
+ return xService;
+}
+
+
+sal_Bool SAL_CALL
+ MacSpellChecker::addLinguServiceEventListener(
+ const Reference< XLinguServiceEventListener >& rxLstnr )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ sal_Bool bRes = sal_False;
+ if (!bDisposing && rxLstnr.is())
+ {
+ bRes = GetPropHelper().addLinguServiceEventListener( rxLstnr );
+ }
+ return bRes;
+}
+
+
+sal_Bool SAL_CALL
+ MacSpellChecker::removeLinguServiceEventListener(
+ const Reference< XLinguServiceEventListener >& rxLstnr )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ sal_Bool bRes = sal_False;
+ if (!bDisposing && rxLstnr.is())
+ {
+ DBG_ASSERT( xPropHelper.is(), "xPropHelper non existent" );
+ bRes = GetPropHelper().removeLinguServiceEventListener( rxLstnr );
+ }
+ return bRes;
+}
+
+
+OUString SAL_CALL
+ MacSpellChecker::getServiceDisplayName( const Locale& /*rLocale*/ )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+ return A2OU( "Mac OS X Spell Checker" );
+}
+
+
+void SAL_CALL
+ MacSpellChecker::initialize( const Sequence< Any >& rArguments )
+ throw(Exception, RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ if (!pPropHelper)
+ {
+ sal_Int32 nLen = rArguments.getLength();
+ if (2 == nLen)
+ {
+ Reference< XPropertySet > xPropSet;
+ rArguments.getConstArray()[0] >>= xPropSet;
+ //rArguments.getConstArray()[1] >>= xDicList;
+
+ //! Pointer allows for access of the non-UNO functions.
+ //! And the reference to the UNO-functions while increasing
+ //! the ref-count and will implicitly free the memory
+ //! when the object is not longer used.
+ pPropHelper = new PropertyHelper_Spell( (XSpellChecker *) this, xPropSet );
+ xPropHelper = pPropHelper;
+ pPropHelper->AddAsPropListener(); //! after a reference is established
+ }
+ else
+ OSL_FAIL( "wrong number of arguments in sequence" );
+
+ }
+}
+
+
+void SAL_CALL
+ MacSpellChecker::dispose()
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ if (!bDisposing)
+ {
+ bDisposing = sal_True;
+ EventObject aEvtObj( (XSpellChecker *) this );
+ aEvtListeners.disposeAndClear( aEvtObj );
+ }
+}
+
+
+void SAL_CALL
+ MacSpellChecker::addEventListener( const Reference< XEventListener >& rxListener )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ if (!bDisposing && rxListener.is())
+ aEvtListeners.addInterface( rxListener );
+}
+
+
+void SAL_CALL
+ MacSpellChecker::removeEventListener( const Reference< XEventListener >& rxListener )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ if (!bDisposing && rxListener.is())
+ aEvtListeners.removeInterface( rxListener );
+}
+
+
+///////////////////////////////////////////////////////////////////////////
+// Service specific part
+//
+
+OUString SAL_CALL MacSpellChecker::getImplementationName()
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ return getImplementationName_Static();
+}
+
+
+sal_Bool SAL_CALL MacSpellChecker::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+
+Sequence< OUString > SAL_CALL MacSpellChecker::getSupportedServiceNames()
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ return getSupportedServiceNames_Static();
+}
+
+
+Sequence< OUString > MacSpellChecker::getSupportedServiceNames_Static()
+ throw()
+{
+ MutexGuard aGuard( GetLinguMutex() );
+
+ Sequence< OUString > aSNS( 1 ); // auch mehr als 1 Service moeglich
+ aSNS.getArray()[0] = A2OU( SN_SPELLCHECKER );
+ return aSNS;
+}
+
+void * SAL_CALL MacSpellChecker_getFactory( const sal_Char * pImplName,
+ XMultiServiceFactory * pServiceManager, void * )
+{
+ void * pRet = 0;
+ if ( !MacSpellChecker::getImplementationName_Static().compareToAscii( pImplName ) )
+ {
+ Reference< XSingleServiceFactory > xFactory =
+ cppu::createOneInstanceFactory(
+ pServiceManager,
+ MacSpellChecker::getImplementationName_Static(),
+ MacSpellChecker_CreateInstance,
+ MacSpellChecker::getSupportedServiceNames_Static());
+ // acquire, because we return an interface pointer instead of a reference
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ return pRet;
+}
+
+
+///////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit c68574888434ae5e5ac3010593cf6939c4bbba6c
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Dec 16 11:25:53 2011 +0100
avmedia: QuickTime: use gb_Library_add_objcxxobjects
diff --git a/avmedia/Library_avmediaQuickTime.mk b/avmedia/Library_avmediaQuickTime.mk
index 6c25594..a652596 100644
--- a/avmedia/Library_avmediaQuickTime.mk
+++ b/avmedia/Library_avmediaQuickTime.mk
@@ -56,7 +56,7 @@ $(eval $(call gb_Library_use_externals,avmediaQuickTime,\
quicktime \
))
-$(eval $(call gb_Library_add_exception_objects,avmediaQuickTime,\
+$(eval $(call gb_Library_add_objcxxobjects,avmediaQuickTime,\
avmedia/source/quicktime/framegrabber \
avmedia/source/quicktime/manager \
avmedia/source/quicktime/player \
@@ -64,8 +64,4 @@ $(eval $(call gb_Library_add_exception_objects,avmediaQuickTime,\
avmedia/source/quicktime/window \
))
-$(eval $(call gb_Library_add_cxxflags,avmediaQuickTime,\
- $(gb_LinkTarget_OBJCXXFLAGS) \
-))
-
# vim: set noet sw=4 ts=4:
diff --git a/avmedia/source/quicktime/framegrabber.cxx b/avmedia/source/quicktime/framegrabber.cxx
deleted file mode 100644
index 5da2aa2..0000000
--- a/avmedia/source/quicktime/framegrabber.cxx
+++ /dev/null
@@ -1,155 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * 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 "framegrabber.hxx"
-#include "player.hxx"
-
-#include <tools/stream.hxx>
-#include <vcl/graph.hxx>
-#include <vcl/cvtgrf.hxx>
-#include <unotools/localfilehelper.hxx>
-
-#define AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_Quicktime"
-#define AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_Quicktime"
-
-using namespace ::com::sun::star;
-
-namespace avmedia { namespace quicktime {
-
-// ----------------
-// - FrameGrabber -
-// ----------------
-
-FrameGrabber::FrameGrabber( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
- mxMgr( rxMgr )
-{
- OSErr result;
-
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- // check the version of QuickTime installed
- result = Gestalt(gestaltQuickTime,&mnVersion);
- if ((result == noErr) && (mnVersion >= QT701))
- {
- // we have version 7.01 or later, initialize
- mpMovie = [QTMovie movie];
- [mpMovie retain];
- mbInitialized = true;
- }
- [pool release];
-}
-
-// ------------------------------------------------------------------------------
-
-FrameGrabber::~FrameGrabber()
-{
- if( mbInitialized )
- {
- if( mpMovie )
- {
- [mpMovie release];
- mpMovie = nil;
- }
- }
-}
-
-// ------------------------------------------------------------------------------
-
-bool FrameGrabber::create( const ::rtl::OUString& rURL )
-{
- bool bRet = false;
- maURL = rURL;
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
- NSURL* aURL = [NSURL URLWithString:aNSStr ];
-
- // create the Movie
-
- mpMovie = [mpMovie initWithURL:aURL error:nil];
- if(mpMovie)
- {
- [mpMovie retain];
- bRet = true;
- }
-
- [pool release];
-
- return( bRet );
-}
-
-// ------------------------------------------------------------------------------
-
-uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMediaTime )
- throw (uno::RuntimeException)
-{
- uno::Reference< graphic::XGraphic > xRet;
-
- NSImage* pImage = [mpMovie frameImageAtTime: QTMakeTimeWithTimeInterval(fMediaTime)];
- NSData *pBitmap = [pImage TIFFRepresentation];
- long nSize = [pBitmap length];
- const void* pBitmapData = [pBitmap bytes];
- SvMemoryStream aMemStm( (char *)pBitmapData, nSize, STREAM_READ | STREAM_WRITE );
- Graphic aGraphic;
- if ( GraphicConverter::Import( aMemStm, aGraphic, CVT_TIF ) == ERRCODE_NONE )
- {
- xRet = aGraphic.GetXGraphic();
- }
-
- return xRet;
-}
-
-// ------------------------------------------------------------------------------
-
-::rtl::OUString SAL_CALL FrameGrabber::getImplementationName( )
- throw (uno::RuntimeException)
-{
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME ) );
-}
-
-// ------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL FrameGrabber::supportsService( const ::rtl::OUString& ServiceName )
- throw (uno::RuntimeException)
-{
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME ) );
-}
-
-// ------------------------------------------------------------------------------
-
-uno::Sequence< ::rtl::OUString > SAL_CALL FrameGrabber::getSupportedServiceNames( )
- throw (uno::RuntimeException)
-{
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME ) );
-
- return aRet;
-}
-
-} // namespace quicktime
-} // namespace avmedia
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/framegrabber.mm b/avmedia/source/quicktime/framegrabber.mm
new file mode 100644
index 0000000..5da2aa2
--- /dev/null
+++ b/avmedia/source/quicktime/framegrabber.mm
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 "framegrabber.hxx"
+#include "player.hxx"
+
+#include <tools/stream.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <unotools/localfilehelper.hxx>
+
+#define AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_Quicktime"
+#define AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_Quicktime"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace quicktime {
+
+// ----------------
+// - FrameGrabber -
+// ----------------
+
+FrameGrabber::FrameGrabber( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr )
+{
+ OSErr result;
+
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ // check the version of QuickTime installed
+ result = Gestalt(gestaltQuickTime,&mnVersion);
+ if ((result == noErr) && (mnVersion >= QT701))
+ {
+ // we have version 7.01 or later, initialize
+ mpMovie = [QTMovie movie];
+ [mpMovie retain];
+ mbInitialized = true;
+ }
+ [pool release];
+}
+
+// ------------------------------------------------------------------------------
+
+FrameGrabber::~FrameGrabber()
+{
+ if( mbInitialized )
+ {
+ if( mpMovie )
+ {
+ [mpMovie release];
+ mpMovie = nil;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+bool FrameGrabber::create( const ::rtl::OUString& rURL )
+{
+ bool bRet = false;
+ maURL = rURL;
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
+ NSURL* aURL = [NSURL URLWithString:aNSStr ];
+
+ // create the Movie
+
+ mpMovie = [mpMovie initWithURL:aURL error:nil];
+ if(mpMovie)
+ {
+ [mpMovie retain];
+ bRet = true;
+ }
+
+ [pool release];
+
+ return( bRet );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMediaTime )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< graphic::XGraphic > xRet;
+
+ NSImage* pImage = [mpMovie frameImageAtTime: QTMakeTimeWithTimeInterval(fMediaTime)];
+ NSData *pBitmap = [pImage TIFFRepresentation];
+ long nSize = [pBitmap length];
+ const void* pBitmapData = [pBitmap bytes];
+ SvMemoryStream aMemStm( (char *)pBitmapData, nSize, STREAM_READ | STREAM_WRITE );
+ Graphic aGraphic;
+ if ( GraphicConverter::Import( aMemStm, aGraphic, CVT_TIF ) == ERRCODE_NONE )
+ {
+ xRet = aGraphic.GetXGraphic();
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL FrameGrabber::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL FrameGrabber::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL FrameGrabber::getSupportedServiceNames( )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace quicktime
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/manager.cxx b/avmedia/source/quicktime/manager.cxx
deleted file mode 100644
index ca8da8e..0000000
--- a/avmedia/source/quicktime/manager.cxx
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * 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 "manager.hxx"
-#include "player.hxx"
-#include <tools/urlobj.hxx>
-
-using namespace ::com::sun::star;
-
-namespace avmedia { namespace quicktime {
-// ----------------
-// - Manager -
-// ----------------
-
-Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
- mxMgr( rxMgr )
-{
- OSL_TRACE( "avmediaquicktime: Manager::Manager" );
-}
-
-// ------------------------------------------------------------------------------
-
-Manager::~Manager()
-{
-}
-
-// ------------------------------------------------------------------------------
-
-uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const ::rtl::OUString& rURL )
- throw (uno::RuntimeException)
-{
- Player* pPlayer( new Player( mxMgr ) );
- uno::Reference< media::XPlayer > xRet( pPlayer );
- INetURLObject aURL( rURL );
-
- OSL_TRACE( "avmediaquicktime: Manager::createPlayer" );
-
- if( !pPlayer->create( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
- xRet = uno::Reference< media::XPlayer >();
-
- return xRet;
-}
-
-// ------------------------------------------------------------------------------
-
-::rtl::OUString SAL_CALL Manager::getImplementationName( )
- throw (uno::RuntimeException)
-{
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME ) );
-}
-
-// ------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL Manager::supportsService( const ::rtl::OUString& ServiceName )
- throw (uno::RuntimeException)
-{
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_MANAGER_SERVICENAME ) );
-}
-
-// ------------------------------------------------------------------------------
-
-uno::Sequence< ::rtl::OUString > SAL_CALL Manager::getSupportedServiceNames( )
- throw (uno::RuntimeException)
-{
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_QUICKTIME_MANAGER_SERVICENAME ) );
-
- return aRet;
-}
-
-} // namespace quicktime
-} // namespace avmedia
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/manager.mm b/avmedia/source/quicktime/manager.mm
new file mode 100644
index 0000000..ca8da8e
--- /dev/null
+++ b/avmedia/source/quicktime/manager.mm
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 "manager.hxx"
+#include "player.hxx"
+#include <tools/urlobj.hxx>
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace quicktime {
+// ----------------
+// - Manager -
+// ----------------
+
+Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr )
+{
+ OSL_TRACE( "avmediaquicktime: Manager::Manager" );
+}
+
+// ------------------------------------------------------------------------------
+
+Manager::~Manager()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const ::rtl::OUString& rURL )
+ throw (uno::RuntimeException)
+{
+ Player* pPlayer( new Player( mxMgr ) );
+ uno::Reference< media::XPlayer > xRet( pPlayer );
+ INetURLObject aURL( rURL );
+
+ OSL_TRACE( "avmediaquicktime: Manager::createPlayer" );
+
+ if( !pPlayer->create( aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
+ xRet = uno::Reference< media::XPlayer >();
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL Manager::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Manager::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_MANAGER_SERVICENAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL Manager::getSupportedServiceNames( )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_QUICKTIME_MANAGER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace quicktime
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/player.cxx b/avmedia/source/quicktime/player.cxx
deleted file mode 100644
index e4550a0..0000000
--- a/avmedia/source/quicktime/player.cxx
+++ /dev/null
@@ -1,471 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * 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 <math.h>
-
-#include "player.hxx"
-#include "framegrabber.hxx"
-#include "window.hxx"
-
-using namespace ::com::sun::star;
-
-namespace avmedia { namespace quicktime {
-
-// ----------------
-// - Player -
-// ----------------
-
-Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
- mxMgr( rxMgr ),
- mpMovie( nil ),
- /* GST
- mbFakeVideo (sal_False ),
- */
- mnUnmutedVolume( 0 ),
- mnStopTime( DBL_MAX ), //max double
- mbMuted( false ),
- mbLooping( false ),
- mbInitialized( false ),
- mnWindowID( 0 ),
- mnDuration( 0 ),
- mnWidth( 0 ),
- mnHeight( 0 ),
- mnVersion( 0 ),
- maSizeCondition( osl_createCondition() )
-{
- OSErr result;
-
- NSApplicationLoad();
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- // check the version of QuickTime installed
- result = Gestalt(gestaltQuickTime,&mnVersion);
- if ((result == noErr) && (mnVersion >= QT701))
- {
- // we have version 7.01 or later, initialize
- mbInitialized = true;
- }
- [pool release];
-}
-
-// ------------------------------------------------------------------------------
-
-Player::~Player()
-{
- if( mpMovie )
- {
- [mpMovie release];
- mpMovie = nil;
- }
-}
-// ------------------------------------------------------------------------------
-
-QTMovie* Player::getMovie()
-{
- OSL_ASSERT( mpMovie );
- return mpMovie;
-}
-
-// ------------------------------------------------------------------------------
-
-bool Player::create( const ::rtl::OUString& rURL )
-{
- bool bRet = false;
- // create the Movie
- if( mbInitialized )
- {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
-
- if( mpMovie )
- {
- [mpMovie release];
- mpMovie = nil;
- }
-
- NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
- NSURL* aURL = [NSURL URLWithString:aNSStr ];
-
- NSError* pErr = nil;
- mpMovie = [QTMovie movieWithURL:aURL error:&pErr];
- if(mpMovie)
- {
- [mpMovie retain];
- maURL = rURL;
- bRet = true;
- }
- if( pErr )
- {
- OSL_TRACE( "NSMovie create failed with error %ld (%s)",
- (long)[pErr code],
- [[pErr localizedDescription] UTF8String]
- );
- }
- [pool release];
- }
-
- return bRet;
-}
-
-// ------------------------------------------------------------------------------
-
-void SAL_CALL Player::start( )
- throw (uno::RuntimeException)
-{
- OSL_TRACE ("Player::start");
-
- if( mpMovie )
- {
- [mpMovie play];
- }
-}
-
-// ------------------------------------------------------------------------------
-
-void SAL_CALL Player::stop( )
- throw (uno::RuntimeException)
-{
- OSL_TRACE ("Player::stop");
- if( mpMovie )
- {
- [mpMovie stop];
- }
-}
-
-// ------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL Player::isPlaying()
- throw (uno::RuntimeException)
-{
- bool bRet = false;
-
- if ( mpMovie )
- {
- if ([mpMovie rate] != 0)
- {
- bRet = true;
- }
- }
-
- return bRet;
-}
-
-// ------------------------------------------------------------------------------
-
-double SAL_CALL Player::getDuration( )
- throw (uno::RuntimeException)
-{
- // slideshow checks for non-zero duration, so cheat here
- double duration = 0.01;
-
- if ( mpMovie ) // && mnDuration > 0 ) {
- {
- QTTime structDuration = [mpMovie duration] ;
- duration = (double)structDuration.timeValue / (double)structDuration.timeScale;
- }
-
- return duration;
-}
-
-// ------------------------------------------------------------------------------
-
-void SAL_CALL Player::setMediaTime( double fTime )
- throw (uno::RuntimeException)
-{
- OSL_TRACE ("Player::setMediaTime");
-
- if ( mpMovie )
- {
- [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)];
- }
-}
-
-// ------------------------------------------------------------------------------
-
-double SAL_CALL Player::getMediaTime( )
- throw (uno::RuntimeException)
-{
- double position = 0.0;
-
- if ( mpMovie )
- {
- QTTime structDuration = [mpMovie currentTime] ;
- position = (double)structDuration.timeValue / (double)structDuration.timeScale;
- }
-
- if(isPlaying() && position>mnStopTime)
- {
- stop();
- }
-
- return position;
-}
-
-// ------------------------------------------------------------------------------
-
-void SAL_CALL Player::setStopTime( double fTime )
- throw (uno::RuntimeException)
-{
- OSL_TRACE ("Player::setStopTime %f", fTime);
-
- mnStopTime = fTime;
-}
-
-// ------------------------------------------------------------------------------
-
-double SAL_CALL Player::getStopTime( )
- throw (uno::RuntimeException)
-{
- double fRet = mnStopTime;
-
- return fRet;
-}
-
-// ------------------------------------------------------------------------------
-
-void SAL_CALL Player::setRate( double fRate )
- throw (uno::RuntimeException)
-{
- OSL_TRACE ("Player::setRate");
-
- // Quicktime: 0 = stop, 1 = normal speed, 2 = double speed, -1 = normal speed backwards
- if ( mpMovie )
- {
- [mpMovie setRate: fRate];
- }
-}
-
-// ------------------------------------------------------------------------------
-
-double SAL_CALL Player::getRate( )
- throw (uno::RuntimeException)
-{
- // Quicktime: 0 = stop, 1 = normal speed, 2 = double speed, -1 = normal speed backwards
- double rate = 1.0;
-
- OSL_TRACE ("Player::getRate");
-
- if ( mpMovie )
- {
- rate = (double) [mpMovie rate];
- }
-
- return rate;
-}
-
-// ------------------------------------------------------------------------------
-
-void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet )
- throw (uno::RuntimeException)
-{
- OSL_TRACE ("Player::setPlaybackLoop? %s", bSet?"True":"False" );
-
- if(bSet)
- {
- [mpMovie setAttribute:[NSNumber numberWithBool:YES] forKey: QTMovieLoopsAttribute] ;
- }
- else
- {
- [mpMovie setAttribute:[NSNumber numberWithBool:NO] forKey: QTMovieLoopsAttribute] ;
- }
-}
-
-// ------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL Player::isPlaybackLoop( )
- throw (uno::RuntimeException)
-{
- bool bRet = [[mpMovie attributeForKey:QTMovieLoopsAttribute] boolValue];
-
- OSL_TRACE ("Player::isPlaybackLoop ? %s", bRet?"True":"False" );
-
- return bRet;
-}
-
-// ------------------------------------------------------------------------------
-
-void SAL_CALL Player::setMute( sal_Bool bSet )
- throw (uno::RuntimeException)
-{
- OSL_TRACE( "set mute: %d muted: %d unmuted volume: %lf", bSet, mbMuted, mnUnmutedVolume );
-
- // change the volume to 0 or the unmuted volume
- if( mpMovie && mbMuted != bSet )
- {
- [mpMovie setMuted: bSet ];
- mbMuted = bSet;
- }
-
-}
-
-// ------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL Player::isMute( )
- throw (uno::RuntimeException)
-{
- OSL_TRACE ("Player::isMuted");
-
- return mbMuted;
-}
-
-// ------------------------------------------------------------------------------
-
-void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
- throw (uno::RuntimeException)
-{
- // OOo db volume -40 = QTVolume 0
- // OOo db volume 0 = QTvolume 1
- if(nVolumeDB==-40)
- {
- mnUnmutedVolume = 0;
- }
- else
- {
- mnUnmutedVolume = pow( 10.0, nVolumeDB / 20.0 );
- }
-
- OSL_TRACE( "set volume: %d gst volume: %f", nVolumeDB, mnUnmutedVolume );
-
- // change volume
- if( !mbMuted && mpMovie )
- {
- [mpMovie setVolume: mnUnmutedVolume ];
- }
-}
-
-// ------------------------------------------------------------------------------
-
-sal_Int16 SAL_CALL Player::getVolumeDB( )
- throw (uno::RuntimeException)
-{
- sal_Int16 nVolumeDB = 0.0;
-
- if( mpMovie )
- {
- float volume = 0.0;
-
- volume = [mpMovie volume];
- if(volume>0) //protect from log10(0)
- {
- nVolumeDB = (sal_Int16) ( 20.0*log10 ( volume ) );
- }
- else
- {
- nVolumeDB = -40 ; // QT zero volume is no volume, -40db
- }
- }
-
- return nVolumeDB;
-}
-
-// ------------------------------------------------------------------------------
-
-awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( )
- throw (uno::RuntimeException)
-{
- NSSize nsSize = [[mpMovie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
- awt::Size aSize( nsSize.width, nsSize.height );
- return aSize;
-}
-
-// ------------------------------------------------------------------------------
-
-uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& aArguments )
- throw (uno::RuntimeException)
-{
- uno::Reference< ::media::XPlayerWindow > xRet;
- awt::Size aSize( getPreferredPlayerWindowSize() );
- NSSize nsSize( NSMakeSize(aSize.Width, aSize.Height) );
-
- OSL_TRACE( "Player::createPlayerWindow %d %d length: %d", aSize.Width, aSize.Height, aArguments.getLength() );
-
- if( aSize.Width > 0 && aSize.Height > 0 )
- {
- sal_IntPtr nPtr = NULL;
- aArguments[0] >>= nPtr;
- NSView* pParentView = reinterpret_cast< NSView * >(nPtr);
-
- ::avmedia::quicktime::Window* pWindow = new ::avmedia::quicktime::Window( mxMgr, *this, pParentView );
- xRet = pWindow;
- }
-
- return xRet;
-}
-
-// ------------------------------------------------------------------------------
-
-uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber( )
- throw (::com::sun::star::uno::RuntimeException)
-{
- uno::Reference< media::XFrameGrabber > xRet;
- OSL_TRACE ("Player::createFrameGrabber");
-
- if( maURL.getLength() > 0 )
- {
- FrameGrabber* pGrabber = new FrameGrabber( mxMgr );
-
- xRet = pGrabber;
-
- if( !pGrabber->create( maURL ) )
- {
- xRet.clear();
- }
- }
-
- return xRet;
-}
-
-// ------------------------------------------------------------------------------
-
-::rtl::OUString SAL_CALL Player::getImplementationName( )
- throw (uno::RuntimeException)
-{
- return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_PLAYER_IMPLEMENTATIONNAME ) );
-}
-
-// ------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName )
- throw (uno::RuntimeException)
-{
- return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_PLAYER_SERVICENAME ) );
-}
-
-// ------------------------------------------------------------------------------
-
-uno::Sequence< ::rtl::OUString > SAL_CALL Player::getSupportedServiceNames( )
- throw (uno::RuntimeException)
-{
- uno::Sequence< ::rtl::OUString > aRet(1);
- aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_QUICKTIME_PLAYER_SERVICENAME ) );
-
- return aRet;
-}
-
-} // namespace quicktime
-} // namespace avmedia
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/player.mm b/avmedia/source/quicktime/player.mm
new file mode 100644
index 0000000..e4550a0
--- /dev/null
+++ b/avmedia/source/quicktime/player.mm
@@ -0,0 +1,471 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 <math.h>
+
+#include "player.hxx"
+#include "framegrabber.hxx"
+#include "window.hxx"
+
+using namespace ::com::sun::star;
+
+namespace avmedia { namespace quicktime {
+
+// ----------------
+// - Player -
+// ----------------
+
+Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
+ mxMgr( rxMgr ),
+ mpMovie( nil ),
+ /* GST
+ mbFakeVideo (sal_False ),
+ */
+ mnUnmutedVolume( 0 ),
+ mnStopTime( DBL_MAX ), //max double
+ mbMuted( false ),
+ mbLooping( false ),
+ mbInitialized( false ),
+ mnWindowID( 0 ),
+ mnDuration( 0 ),
+ mnWidth( 0 ),
+ mnHeight( 0 ),
+ mnVersion( 0 ),
+ maSizeCondition( osl_createCondition() )
+{
+ OSErr result;
+
+ NSApplicationLoad();
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ // check the version of QuickTime installed
+ result = Gestalt(gestaltQuickTime,&mnVersion);
+ if ((result == noErr) && (mnVersion >= QT701))
+ {
+ // we have version 7.01 or later, initialize
+ mbInitialized = true;
+ }
+ [pool release];
+}
+
+// ------------------------------------------------------------------------------
+
+Player::~Player()
+{
+ if( mpMovie )
+ {
+ [mpMovie release];
+ mpMovie = nil;
+ }
+}
+// ------------------------------------------------------------------------------
+
+QTMovie* Player::getMovie()
+{
+ OSL_ASSERT( mpMovie );
+ return mpMovie;
+}
+
+// ------------------------------------------------------------------------------
+
+bool Player::create( const ::rtl::OUString& rURL )
+{
+ bool bRet = false;
+ // create the Movie
+ if( mbInitialized )
+ {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ if( mpMovie )
+ {
+ [mpMovie release];
+ mpMovie = nil;
+ }
+
+ NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
+ NSURL* aURL = [NSURL URLWithString:aNSStr ];
+
+ NSError* pErr = nil;
+ mpMovie = [QTMovie movieWithURL:aURL error:&pErr];
+ if(mpMovie)
+ {
+ [mpMovie retain];
+ maURL = rURL;
+ bRet = true;
+ }
+ if( pErr )
+ {
+ OSL_TRACE( "NSMovie create failed with error %ld (%s)",
+ (long)[pErr code],
+ [[pErr localizedDescription] UTF8String]
+ );
+ }
+ [pool release];
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::start( )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::start");
+
+ if( mpMovie )
+ {
+ [mpMovie play];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::stop( )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::stop");
+ if( mpMovie )
+ {
+ [mpMovie stop];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isPlaying()
+ throw (uno::RuntimeException)
+{
+ bool bRet = false;
+
+ if ( mpMovie )
+ {
+ if ([mpMovie rate] != 0)
+ {
+ bRet = true;
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getDuration( )
+ throw (uno::RuntimeException)
+{
+ // slideshow checks for non-zero duration, so cheat here
+ double duration = 0.01;
+
+ if ( mpMovie ) // && mnDuration > 0 ) {
+ {
+ QTTime structDuration = [mpMovie duration] ;
+ duration = (double)structDuration.timeValue / (double)structDuration.timeScale;
+ }
+
+ return duration;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setMediaTime( double fTime )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::setMediaTime");
+
+ if ( mpMovie )
+ {
+ [mpMovie setCurrentTime: QTMakeTimeWithTimeInterval(fTime)];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getMediaTime( )
+ throw (uno::RuntimeException)
+{
+ double position = 0.0;
+
+ if ( mpMovie )
+ {
+ QTTime structDuration = [mpMovie currentTime] ;
+ position = (double)structDuration.timeValue / (double)structDuration.timeScale;
+ }
+
+ if(isPlaying() && position>mnStopTime)
+ {
+ stop();
+ }
+
+ return position;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setStopTime( double fTime )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::setStopTime %f", fTime);
+
+ mnStopTime = fTime;
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getStopTime( )
+ throw (uno::RuntimeException)
+{
+ double fRet = mnStopTime;
+
+ return fRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setRate( double fRate )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::setRate");
+
+ // Quicktime: 0 = stop, 1 = normal speed, 2 = double speed, -1 = normal speed backwards
+ if ( mpMovie )
+ {
+ [mpMovie setRate: fRate];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+double SAL_CALL Player::getRate( )
+ throw (uno::RuntimeException)
+{
+ // Quicktime: 0 = stop, 1 = normal speed, 2 = double speed, -1 = normal speed backwards
+ double rate = 1.0;
+
+ OSL_TRACE ("Player::getRate");
+
+ if ( mpMovie )
+ {
+ rate = (double) [mpMovie rate];
+ }
+
+ return rate;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::setPlaybackLoop? %s", bSet?"True":"False" );
+
+ if(bSet)
+ {
+ [mpMovie setAttribute:[NSNumber numberWithBool:YES] forKey: QTMovieLoopsAttribute] ;
+ }
+ else
+ {
+ [mpMovie setAttribute:[NSNumber numberWithBool:NO] forKey: QTMovieLoopsAttribute] ;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isPlaybackLoop( )
+ throw (uno::RuntimeException)
+{
+ bool bRet = [[mpMovie attributeForKey:QTMovieLoopsAttribute] boolValue];
+
+ OSL_TRACE ("Player::isPlaybackLoop ? %s", bRet?"True":"False" );
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setMute( sal_Bool bSet )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE( "set mute: %d muted: %d unmuted volume: %lf", bSet, mbMuted, mnUnmutedVolume );
+
+ // change the volume to 0 or the unmuted volume
+ if( mpMovie && mbMuted != bSet )
+ {
+ [mpMovie setMuted: bSet ];
+ mbMuted = bSet;
+ }
+
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::isMute( )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE ("Player::isMuted");
+
+ return mbMuted;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
+ throw (uno::RuntimeException)
+{
+ // OOo db volume -40 = QTVolume 0
+ // OOo db volume 0 = QTvolume 1
+ if(nVolumeDB==-40)
+ {
+ mnUnmutedVolume = 0;
+ }
+ else
+ {
+ mnUnmutedVolume = pow( 10.0, nVolumeDB / 20.0 );
+ }
+
+ OSL_TRACE( "set volume: %d gst volume: %f", nVolumeDB, mnUnmutedVolume );
+
+ // change volume
+ if( !mbMuted && mpMovie )
+ {
+ [mpMovie setVolume: mnUnmutedVolume ];
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL Player::getVolumeDB( )
+ throw (uno::RuntimeException)
+{
+ sal_Int16 nVolumeDB = 0.0;
+
+ if( mpMovie )
+ {
+ float volume = 0.0;
+
+ volume = [mpMovie volume];
+ if(volume>0) //protect from log10(0)
+ {
+ nVolumeDB = (sal_Int16) ( 20.0*log10 ( volume ) );
+ }
+ else
+ {
+ nVolumeDB = -40 ; // QT zero volume is no volume, -40db
+ }
+ }
+
+ return nVolumeDB;
+}
+
+// ------------------------------------------------------------------------------
+
+awt::Size SAL_CALL Player::getPreferredPlayerWindowSize( )
+ throw (uno::RuntimeException)
+{
+ NSSize nsSize = [[mpMovie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
+ awt::Size aSize( nsSize.width, nsSize.height );
+ return aSize;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& aArguments )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< ::media::XPlayerWindow > xRet;
+ awt::Size aSize( getPreferredPlayerWindowSize() );
+ NSSize nsSize( NSMakeSize(aSize.Width, aSize.Height) );
+
+ OSL_TRACE( "Player::createPlayerWindow %d %d length: %d", aSize.Width, aSize.Height, aArguments.getLength() );
+
+ if( aSize.Width > 0 && aSize.Height > 0 )
+ {
+ sal_IntPtr nPtr = NULL;
+ aArguments[0] >>= nPtr;
+ NSView* pParentView = reinterpret_cast< NSView * >(nPtr);
+
+ ::avmedia::quicktime::Window* pWindow = new ::avmedia::quicktime::Window( mxMgr, *this, pParentView );
+ xRet = pWindow;
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Reference< media::XFrameGrabber > xRet;
+ OSL_TRACE ("Player::createFrameGrabber");
+
+ if( maURL.getLength() > 0 )
+ {
+ FrameGrabber* pGrabber = new FrameGrabber( mxMgr );
+
+ xRet = pGrabber;
+
+ if( !pGrabber->create( maURL ) )
+ {
+ xRet.clear();
+ }
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL Player::getImplementationName( )
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_PLAYER_IMPLEMENTATIONNAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_QUICKTIME_PLAYER_SERVICENAME ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL Player::getSupportedServiceNames( )
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aRet(1);
+ aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_QUICKTIME_PLAYER_SERVICENAME ) );
+
+ return aRet;
+}
+
+} // namespace quicktime
+} // namespace avmedia
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/quicktimeuno.cxx b/avmedia/source/quicktime/quicktimeuno.cxx
deleted file mode 100644
index 0a927d6..0000000
--- a/avmedia/source/quicktime/quicktimeuno.cxx
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * 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 "quicktimecommon.hxx"
-#include "manager.hxx"
-
-using namespace ::com::sun::star;
-
-// -------------------
-// - factory methods -
-// -------------------
-
-static uno::Reference< uno::XInterface > SAL_CALL create_MediaPlayer( const uno::Reference< lang::XMultiServiceFactory >& rxFact )
-{
- return uno::Reference< uno::XInterface >( *new ::avmedia::quicktime::Manager( rxFact ) );
-}
-
-extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
-{
- uno::Reference< lang::XSingleServiceFactory > xFactory;
- void* pRet = 0;
-
- if( rtl_str_compare( pImplName, AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME ) == 0 )
- {
- const ::rtl::OUString aServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_MANAGER_SERVICENAME )) );
-
- xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
- reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME )),
- create_MediaPlayer, uno::Sequence< ::rtl::OUString >( &aServiceName, 1 ) ) );
- }
-
- if( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
-
- return pRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/quicktimeuno.mm b/avmedia/source/quicktime/quicktimeuno.mm
new file mode 100644
index 0000000..0a927d6
--- /dev/null
+++ b/avmedia/source/quicktime/quicktimeuno.mm
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * 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 "quicktimecommon.hxx"
+#include "manager.hxx"
+
+using namespace ::com::sun::star;
+
+// -------------------
+// - factory methods -
+// -------------------
+
+static uno::Reference< uno::XInterface > SAL_CALL create_MediaPlayer( const uno::Reference< lang::XMultiServiceFactory >& rxFact )
+{
+ return uno::Reference< uno::XInterface >( *new ::avmedia::quicktime::Manager( rxFact ) );
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
+{
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
+ void* pRet = 0;
+
+ if( rtl_str_compare( pImplName, AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME ) == 0 )
+ {
+ const ::rtl::OUString aServiceName( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_MANAGER_SERVICENAME )) );
+
+ xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
+ reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_QUICKTIME_MANAGER_IMPLEMENTATIONNAME )),
+ create_MediaPlayer, uno::Sequence< ::rtl::OUString >( &aServiceName, 1 ) ) );
+ }
+
+ if( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/quicktime/window.cxx b/avmedia/source/quicktime/window.cxx
deleted file mode 100644
index ca7c6d1..0000000
--- a/avmedia/source/quicktime/window.cxx
+++ /dev/null
@@ -1,354 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * 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>
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list