[Libreoffice-commits] .: Branch 'libreoffice-3-3' - sfx2/source

Petr Mladek pmladek at kemper.freedesktop.org
Mon Feb 7 12:00:29 PST 2011


 sfx2/source/appl/newhelp.cxx |   10 ++++------
 sfx2/source/appl/newhelp.hxx |    3 +++
 sfx2/source/appl/sfxhelp.cxx |   33 ++++++++++++++++++++-------------
 3 files changed, 27 insertions(+), 19 deletions(-)

New commits:
commit 73474b4bae74c3f6f6aac146db198ca958cef70c
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Mon Feb 7 19:56:28 2011 +0100

    wikihelp: Improve the check for existence of the localized help, fdo#33258.
    
    This fixes commit 44eaa36c4ce25a7c861455e9dbe6c2c959adecb4 that introduced an
    infinite recursion.
    
    Signed-off-by: Petr Mladek <pmladek at suse.cz>

diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 8d8ca17..e55b8f7 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -132,8 +132,6 @@ using namespace ::com::sun::star::ui;
 
 using namespace ::comphelper;
 
-extern void AppendConfigToken_Impl( String& rURL, sal_Bool bQuestionMark ); // sfxhelp.cxx
-
 // defines ---------------------------------------------------------------
 
 #define SPLITSET_ID			0
@@ -652,7 +650,7 @@ void IndexTabPage_Impl::InitializeIndex()
         aURL += ::rtl::OUString( sFactory );
 
         String aTemp = aURL;
-        AppendConfigToken_Impl( aTemp, sal_True );
+        AppendConfigToken( aTemp, sal_True );
         aURL = aTemp;
 
         Content aCnt( aURL, Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
@@ -1097,7 +1095,7 @@ IMPL_LINK( SearchTabPage_Impl, SearchHdl, PushButton*, EMPTYARG )
         if ( !aFullWordsCB.IsChecked() )
             aSearchText = sfx2::PrepareSearchString( aSearchText, xBreakIterator, true );
         aSearchURL += aSearchText;
-        AppendConfigToken_Impl( aSearchURL, sal_False );
+        AppendConfigToken( aSearchURL, sal_False );
         if ( aScopeCB.IsChecked() )
             aSearchURL += DEFINE_CONST_UNICODE("&Scope=Heading");
         Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aSearchURL );
@@ -1522,7 +1520,7 @@ sal_Bool SfxHelpWindow_Impl::splitHelpURL(const ::rtl::OUString& sHelpURL,
     sHelpURL.append(sFactory);
     sHelpURL.append(sContent);
     String sURL = String(sHelpURL.makeStringAndClear());
-    AppendConfigToken_Impl(sURL, bUseQuestionMark);
+    AppendConfigToken(sURL, bUseQuestionMark);
     if (sAnchor.getLength())
         sURL += String(sAnchor);
     return ::rtl::OUString(sURL);
@@ -1643,7 +1641,7 @@ SfxHelpIndexWindow_Impl::~SfxHelpIndexWindow_Impl()
 void SfxHelpIndexWindow_Impl::Initialize()
 {
     String aHelpURL = HELP_URL;
-    AppendConfigToken_Impl( aHelpURL, sal_True );
+    AppendConfigToken( aHelpURL, sal_True );
     Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aHelpURL );
     const ::rtl::OUString* pFacs  = aFactories.getConstArray();
     UINT32 i, nCount = aFactories.getLength();
diff --git a/sfx2/source/appl/newhelp.hxx b/sfx2/source/appl/newhelp.hxx
index 268ca39..cb3e942 100644
--- a/sfx2/source/appl/newhelp.hxx
+++ b/sfx2/source/appl/newhelp.hxx
@@ -611,6 +611,9 @@ public:
     inline String	GetTitle() const { return aTitleED.GetText(); }
 };
 
+/// Appends ?Language=xy&System=abc to the help URL in rURL
+void AppendConfigToken( String& rURL, sal_Bool bQuestionMark, const rtl::OUString &rLang = rtl::OUString() );
+
 #endif // #ifndef INCLUDED_SFX_NEWHELP_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 586515c..d425107 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -113,7 +113,7 @@ void NoHelpErrorBox::RequestHelp( const HelpEvent& )
 
 #define STARTERLIST 0
 
-static bool impl_hasHelpInstalled();
+static bool impl_hasHelpInstalled( const rtl::OUString &rLang );
 
 /// Return the locale we prefer for displaying help
 static rtl::OUString HelpLocaleString()
@@ -121,13 +121,16 @@ static rtl::OUString HelpLocaleString()
     static rtl::OUString aLocaleStr;
     if (!aLocaleStr.getLength())
     {
+        const rtl::OUString aEnglish( RTL_CONSTASCII_USTRINGPARAM( "en" ) );
         // detect installed locale
         Any aLocale =
             ::utl::ConfigManager::GetConfigManager().GetDirectConfigProperty(
                ::utl::ConfigManager::LOCALE );
         aLocale >>= aLocaleStr;
         bool bOk = aLocaleStr.getLength() != 0;
-        if ( impl_hasHelpInstalled() && bOk )
+        if ( !bOk )
+            aLocaleStr = aEnglish;
+        else
         {
             rtl::OUString aBaseInstallPath;
             // utl::Bootstrap::PathStatus aBaseLocateResult =
@@ -154,15 +157,19 @@ static rtl::OUString HelpLocaleString()
                 }
             }
         }
-        if (!bOk)
-            aLocaleStr = rtl::OUString( DEFINE_CONST_UNICODE("en") );
+        // if not OK, and not even English installed, we use online help, and
+        // have to preserve the full locale name
+        if ( !bOk && impl_hasHelpInstalled( aEnglish ) )
+            aLocaleStr = aEnglish;
     }
     return aLocaleStr;
 }
 
-void AppendConfigToken_Impl( String& rURL, sal_Bool bQuestionMark )
+void AppendConfigToken( String& rURL, sal_Bool bQuestionMark, const rtl::OUString &rLang )
 {
-    ::rtl::OUString aLocaleStr(HelpLocaleString());
+    ::rtl::OUString aLocaleStr( rLang );
+    if ( !aLocaleStr.getLength() )
+        aLocaleStr = HelpLocaleString();
 
     // query part exists?
     if ( bQuestionMark )
@@ -338,7 +345,7 @@ void SfxHelp_Impl::Load()
     // fill modules list
     // create the help url (empty, without module and helpid)
     String sHelpURL( DEFINE_CONST_UNICODE("vnd.sun.star.help://") );
-    AppendConfigToken_Impl( sHelpURL, sal_True );
+    AppendConfigToken( sHelpURL, sal_True );
 
     // open ucb content and get the list of the help modules
     // the list contains strings with three tokens "ui title \t type \t url"
@@ -621,11 +628,11 @@ String SfxHelp::CreateHelpURL_Impl( ULONG nHelpId, const String& rModuleName )
             aHelpURL += String::CreateFromInt64( nHelpId );
 
             String aTempURL = aHelpURL;
-            AppendConfigToken_Impl( aTempURL, sal_True );
+            AppendConfigToken( aTempURL, sal_True );
             bHasAnchor = GetHelpAnchor_Impl( aTempURL, aAnchor );
         }
 
-        AppendConfigToken_Impl( aHelpURL, sal_True );
+        AppendConfigToken( aHelpURL, sal_True );
 
         if ( bHasAnchor )
         {
@@ -683,11 +690,11 @@ String	SfxHelp::CreateHelpURL_Impl( const String& aCommandURL, const String& rMo
                                               RTL_TEXTENCODING_ASCII_US ));
 
         String aTempURL = aHelpURL;
-        AppendConfigToken_Impl( aTempURL, sal_True );
+        AppendConfigToken( aTempURL, sal_True );
         bHasAnchor = GetHelpAnchor_Impl( aTempURL, aAnchor );
     }
 
-    AppendConfigToken_Impl( aHelpURL, sal_True );
+    AppendConfigToken( aHelpURL, sal_True );
 
     if ( bHasAnchor )
     {
@@ -749,10 +756,10 @@ SfxHelpWindow_Impl* impl_createHelp(Reference< XFrame >& rHelpTask   ,
 }
 
 /// Check for built-in help
-static bool impl_hasHelpInstalled()
+static bool impl_hasHelpInstalled( const rtl::OUString &rLang = rtl::OUString() )
 {
     String aHelpRootURL( DEFINE_CONST_OUSTRING("vnd.sun.star.help://") );
-    AppendConfigToken_Impl( aHelpRootURL, sal_True );
+    AppendConfigToken( aHelpRootURL, sal_True, rLang );
     Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet( aHelpRootURL );
 
     return ( aFactories.getLength() != 0 );


More information about the Libreoffice-commits mailing list