Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi Petr,

Jan Holesovsky píše v St 02. 02. 2011 v 09:36 +0100:

Can you please review the patch in the following bug, and push to
libreoffice-3-3?

https://bugs.freedesktop.org/show_bug.cgi?id=33258

It fixes a 3.3.1 blocker.

And the attached patch fixes the problem this patch introduced - sorry
for that :-(  Can you please check?

I renamed AppendConfigToken_Impl() to AppendConfigToken(), because it is
used in more .cxx files, so it should be declared in a header, instead
of being extern.

Regards,
Kendy
From a038bd21e136f33ccd3bba465327f16b5803f1a0 Mon Sep 17 00:00:00 2001
From: Jan Holesovsky <kendy@suse.cz>
Date: Mon, 7 Feb 2011 19:56:28 +0100
Subject: [PATCH] wikihelp: Improve the check for existence of the localized help, fdo#33258.

This fixes commit 44eaa36c4ce25a7c861455e9dbe6c2c959adecb4 that introduced an
infinite recursion.
---
 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(-)

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 );
-- 
1.7.3.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.