svx/source/tbxctrls/tbcontrl.cxx |   27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

New commits:
commit 5d8390a36e45c14a38c02cafd935512ea58fbfe6
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Fri Sep 18 13:26:41 2020 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Tue Sep 22 08:33:05 2020 +0200

    Use translated standard styles for styles listbox
    
    In online we can have users with multiple languages.
    Select style in sidebar depending on translated name
    and also universal/English.
    
    Change-Id: Ia33df29526e5fd8de5c7e0f7f6f74e0b0f559477
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103000
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index e49ac60442a8..50e3f6760867 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2847,7 +2847,7 @@ struct SvxStyleToolBoxControl::Impl
 {
     OUString                     aClearForm;
     OUString                     aMore;
-    ::std::vector< OUString >    aDefaultStyles;
+    ::std::vector< std::pair< OUString, OUString > >    aDefaultStyles;
     bool                     bSpecModeWriter;
     bool                     bSpecModeCalc;
 
@@ -2893,7 +2893,8 @@ struct SvxStyleToolBoxControl::Impl
                         OUString sName;
                         xStyle->getPropertyValue("DisplayName") >>= sName;
                         if( !sName.isEmpty() )
-                            aDefaultStyles.push_back(sName);
+                            aDefaultStyles.push_back(
+                                std::pair<OUString, OUString>(aStyle, sName) );
                     }
                     catch( const uno::Exception& )
                     {}
@@ -2924,7 +2925,8 @@ struct SvxStyleToolBoxControl::Impl
                             OUString sName;
                             xStyle->getPropertyValue("DisplayName") >>= sName;
                             if( !sName.isEmpty() )
-                                aDefaultStyles.push_back(sName);
+                                aDefaultStyles.push_back(
+                                    std::pair<OUString, OUString>(sStyleName, 
sName) );
                         }
                     }
                     catch( const uno::Exception& )
@@ -3100,7 +3102,7 @@ void SvxStyleToolBoxControl::FillStyleBox()
                         OUString aName( pStyle->GetName() );
                         for( auto const & _i: pImpl->aDefaultStyles )
                         {
-                            if( _i == aName )
+                            if( _i.first == aName || _i.second == aName )
                             {
                                 bInsert = false;
                                 break;
@@ -3133,7 +3135,7 @@ void SvxStyleToolBoxControl::FillStyleBox()
                 sal_uInt16 nPos = 1;
                 for( auto const & _i: pImpl->aDefaultStyles )
                 {
-                    pBox->InsertEntry( _i, nPos );
+                    pBox->InsertEntry( _i.second, nPos );
                     ++nPos;
                 }
 
@@ -3169,8 +3171,17 @@ void SvxStyleToolBoxControl::SelectStyle( const 
OUString& rStyleName )
 
         if ( !rStyleName.isEmpty() )
         {
-            if ( rStyleName != aStrSel )
-                pBox->SetText( rStyleName );
+            OUString aNewStyle = rStyleName;
+
+            auto aFound = std::find_if(pImpl->aDefaultStyles.begin(), 
pImpl->aDefaultStyles.end(),
+                [rStyleName] (auto it) { return it.first == rStyleName || 
it.second == rStyleName; }
+            );
+
+            if (aFound != pImpl->aDefaultStyles.end())
+                aNewStyle = aFound->second;
+
+            if ( aNewStyle != aStrSel )
+                pBox->SetText( aNewStyle );
         }
         else
             pBox->SetNoSelection();
@@ -3304,7 +3315,7 @@ VclPtr<vcl::Window> 
SvxStyleToolBoxControl::CreateItemWindow( vcl::Window *pPare
                                            pImpl->aMore,
                                            pImpl->bSpecModeWriter || 
pImpl->bSpecModeCalc );
     if( !pImpl->aDefaultStyles.empty())
-        pBox->SetDefaultStyle( pImpl->aDefaultStyles[0] );
+        pBox->SetDefaultStyle( pImpl->aDefaultStyles[0].second );
     // Set visibility listener to bind/unbind controller
     pBox->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl, 
VisibilityNotification ));
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to