From 7b34b13b71cbf7172d3373ed19c697db060938e1 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sun, 11 Jul 2010 21:30:47 +0000 Subject: [PATCH] avoid LYX_PLATFORM_DARWIN10 macro git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34861 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/LyX-Mac-binary-release.sh | 46 ++++++++++----------------- src/LyX.cpp | 2 +- src/LyXRC.cpp | 2 +- src/frontends/qt4/GuiPrefs.cpp | 2 +- src/support/AppleSpeller.m | 44 +++++++++++++++---------- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/development/LyX-Mac-binary-release.sh b/development/LyX-Mac-binary-release.sh index f41d33d791..a184b36cf0 100644 --- a/development/LyX-Mac-binary-release.sh +++ b/development/LyX-Mac-binary-release.sh @@ -5,7 +5,7 @@ # This script automates creating universal binaries of LyX on Mac. # Author: Bennett Helm (and extended by Konrad Hofbauer) # modified by Stephan Witt -# Last modified: 6 June 2010 +# Last modified: 9 July 2010 #Qt4SourceVersion="qt-everywhere-opensource-src-4.7.0-beta1" #Qt4Build="qt4.7-beta" @@ -18,7 +18,7 @@ # the aspell sources placed in a sibling directory (variable ASpellSourceVersion) # * for hunspell support: # the hunspell sources placed in a sibling directory (variable HunSpellSourceVersion) -# * for dictionary deployment: +# * for dictionary deployment (per default thesauri only): # - aspell: the dictionary files of macports (in /opt/local/share/aspell and /opt/local/lib/aspell-0.60) # - hunspell: the dictionary files in the sibling directory Dictionaries/dict # - mythes: the data and idx files in the sibling directory Dictionaries/thes @@ -30,10 +30,15 @@ Qt4ConfigureOptions="-opensource -silent -shared -release -fast -no-exceptions" Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus" Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools" +aspell_dictionaries="no" +hunspell_dictionaries="no" + aspell_deployment="yes" hunspell_deployment="yes" thesaurus_deployment="yes" + qt4_deployment="yes" + MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default usage() { @@ -208,38 +213,21 @@ case "$SDKs" in *10.6*) MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET case "${MACOSX_DEPLOYMENT_TARGET}" in - 10.5) + 10.5|10.4) SDKROOT="/Developer/SDKs/MacOSX10.5.sdk"; export SDKROOT ;; - 10.4) - SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk"; export SDKROOT - CC=gcc-4.0 ; export CC - CXX=g++-4.0 ; export CXX - OBJC=gcc-4.0 ; export OBJC - ;; esac ;; *10.5*) - MACOSX_DEPLOYMENT_TARGET="10.4"; export MACOSX_DEPLOYMENT_TARGET - SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk"; export SDKROOT + MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET + SDKROOT="/Developer/SDKs/MacOSX10.5.sdk"; export SDKROOT ;; *) echo Unknown or missing SDK for Mac OS X. exit 1 ;; esac -case "${MACOSX_DEPLOYMENT_TARGET}" in -10.4) - MYCFLAGS="-DLYX_PLATFORM_DARWIN10=4" - ;; -10.5) - MYCFLAGS="-DLYX_PLATFORM_DARWIN10=5" - ;; -10.6) - MYCFLAGS="-DLYX_PLATFORM_DARWIN10=6" - ;; -esac -MYCFLAGS="$MYCFLAGS -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" +MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" updateDictionaries() { TMP_DIR="/tmp/lyx-build-$$" @@ -363,8 +351,8 @@ if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then for arch in ${ARCH_LIST} ; do make distclean - CPPFLAGS=" -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS - LDFLAGS=" -arch ${arch}"; export LDFLAGS + CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS + LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch}"; export LDFLAGS HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"` "${HunSpellSourceDir}/configure"\ --prefix="${HunSpellInstallDir}"\ @@ -428,8 +416,8 @@ if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_ for arch in ${ARCH_LIST} ; do make distclean - CPPFLAGS=" -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS - LDFLAGS=" -arch ${arch}"; export LDFLAGS + CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS + LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch}"; export LDFLAGS HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"` CXXFLAGS=-g "${ASpellSourceDir}/configure"\ --prefix="${ASpellInstallDir}"\ @@ -651,7 +639,7 @@ convert_universal() { } copy_dictionaries() { - if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then + if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then ASpellResources="${LyxAppPrefix}/Contents/Resources" # try to reuse macports dictionaries for now if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi @@ -661,7 +649,7 @@ copy_dictionaries() { cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dict fi - if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then + if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then HunSpellResources="${LyxAppPrefix}/Contents/Resources" if [ -d "${DictionarySourceDir}" ]; then updateDictionaries "${DictionarySourceDir}" diff --git a/src/LyX.cpp b/src/LyX.cpp index 801dff7ab3..fda6fc3602 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -1328,7 +1328,7 @@ SpellChecker * theSpellChecker() void setSpellChecker() { -#if defined(USE_MACOSX_PACKAGING) || defined(LYX_PLATFORM_DARWIN10) +#if defined(USE_MACOSX_PACKAGING) if (lyxrc.spellchecker == "native") { if (!singleton_->pimpl_->apple_spell_checker_) singleton_->pimpl_->apple_spell_checker_ = new AppleSpellChecker(); diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index f1a37e99c0..90d51cb587 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -286,7 +286,7 @@ void LyXRC::setDefaults() display_graphics = true; // Spellchecker settings: // FIXME: this check should test the target platform (darwin) -#if defined(USE_MACOSX_PACKAGING) || defined(LYX_PLATFORM_DARWIN10) +#if defined(USE_MACOSX_PACKAGING) spellchecker = "native"; #elif defined(USE_ASPELL) spellchecker = "aspell"; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 38c5d314a3..0b37b037b4 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1336,7 +1336,7 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form) setupUi(this); // FIXME: this check should test the target platform (darwin) -#if defined(USE_MACOSX_PACKAGING) || defined(LYX_PLATFORM_DARWIN10) +#if defined(USE_MACOSX_PACKAGING) spellcheckerCB->addItem(qt_("native"), QString("native")); #define CONNECT_APPLESPELL #else diff --git a/src/support/AppleSpeller.m b/src/support/AppleSpeller.m index 6530e53dd4..d550fa6860 100644 --- a/src/support/AppleSpeller.m +++ b/src/support/AppleSpeller.m @@ -8,14 +8,16 @@ * Full author contact details are available in file CREDITS. */ -#include -#include +#import +#import + +#import #include "support/AppleSpeller.h" typedef struct AppleSpellerRec { NSSpellChecker * checker; -#if defined(LYX_PLATFORM_DARWIN10) && (LYX_PLATFORM_DARWIN10 >= 5) +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1050) NSInteger doctag; #else int doctag; @@ -72,7 +74,7 @@ int checkAppleSpeller(AppleSpeller speller, const char * word, const char * lang return 0; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; -#if defined(LYX_PLATFORM_DARWIN10) && (LYX_PLATFORM_DARWIN10 >= 5) +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1050) NSInteger wordcount; #else int wordcount; @@ -117,14 +119,21 @@ size_t makeSuggestionAppleSpeller(AppleSpeller speller, const char * word, const NSString * word_ = toString(speller, word); NSString * lang_ = toString(speller, lang); -#if defined(LYX_PLATFORM_DARWIN10) && (LYX_PLATFORM_DARWIN10 >= 6) +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1060) // Mac OS X 10.6 only NSInteger slen = [word_ length]; NSRange range = { 0, slen }; - NSArray * result = [speller->checker guessesForWordRange:range - inString:word_ - language:lang_ - inSpellDocumentWithTag:speller->doctag]; + NSArray * result ; + + if ([NSSpellChecker instancesRespondToSelector:@selector(guessesForWordRange:)]) { + result = [speller->checker guessesForWordRange:range + inString:word_ + language:lang_ + inSpellDocumentWithTag:speller->doctag]; + } else { + [speller->checker setLanguage:lang_]; + NSArray * result = [speller->checker guessesForWord:word_]; + } #else [speller->checker setLanguage:lang_]; NSArray * result = [speller->checker guessesForWord:word_]; @@ -164,11 +173,12 @@ const char * getSuggestionAppleSpeller(AppleSpeller speller, size_t pos) void learnAppleSpeller(AppleSpeller speller, const char * word, const char * lang) { -#if defined(LYX_PLATFORM_DARWIN10) && (LYX_PLATFORM_DARWIN10 >= 5) +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1050) NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString * word_ = toString(speller, word); - [speller->checker learnWord:word_]; + if ([NSSpellChecker instancesRespondToSelector:@selector(learnWord)]) + [speller->checker learnWord:word_]; [word_ release]; [pool release]; @@ -179,14 +189,16 @@ void learnAppleSpeller(AppleSpeller speller, const char * word, const char * lan int hasLanguageAppleSpeller(AppleSpeller speller, const char * lang) { BOOL result = NO; -#if defined(LYX_PLATFORM_DARWIN10) && (LYX_PLATFORM_DARWIN10 >= 5) +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1050) NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString * lang_ = toString(speller, lang); - NSArray * languages = [speller->checker availableLanguages]; + if ([NSSpellChecker instancesRespondToSelector:@selector(availableLanguages)]) { + NSArray * languages = [speller->checker availableLanguages]; - for (NSString *element in languages) { - result = [element isEqualToString:lang_] || [lang_ hasPrefix:element]; - if (result) break; + for (NSString *element in languages) { + result = [element isEqualToString:lang_] || [lang_ hasPrefix:element]; + if (result) break; + } } [lang_ release]; -- 2.39.5