[Libreoffice-commits] core.git: svx/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 12 07:06:47 UTC 2020


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

New commits:
commit 1a1b0c91715b3fe3ec2988afab4e5bc40ada67c0
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Sep 18 13:26:41 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Nov 12 08:06:09 2020 +0100

    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 <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105592
    Tested-by: Jenkins

diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 9dcd11998461..ac4c2339b872 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -2517,7 +2517,7 @@ struct SvxStyleToolBoxControl::Impl
 {
     OUString                     aClearForm;
     OUString                     aMore;
-    ::std::vector< OUString >    aDefaultStyles;
+    ::std::vector< std::pair< OUString, OUString > >    aDefaultStyles;
     bool                     bSpecModeWriter;
     bool                     bSpecModeCalc;
 
@@ -2572,7 +2572,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& )
                     {}
@@ -2603,7 +2604,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& )
@@ -2811,7 +2813,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;
@@ -2840,7 +2842,7 @@ void SvxStyleToolBoxControl::FillStyleBox()
 
         // insert default styles
         for (const auto &rStyle : pImpl->aDefaultStyles)
-            pBox->append_text(rStyle);
+            pBox->append_text(rStyle.second);
     }
 
     std::sort(aStyles.begin(), aStyles.end());
@@ -2868,8 +2870,17 @@ void SvxStyleToolBoxControl::SelectStyle( const OUString& rStyleName )
 
     if ( !rStyleName.isEmpty() )
     {
-        if ( rStyleName != aStrSel )
-            pBox->set_active_or_entry_text( 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->set_active_or_entry_text( aNewStyle );
     }
     else
         pBox->set_active(-1);
@@ -2989,7 +3000,7 @@ css::uno::Reference<css::awt::XWindow> SvxStyleToolBoxControl::createItemWindow(
     }
 
     if (pImpl->m_pBox && !pImpl->aDefaultStyles.empty())
-        pImpl->m_pBox->SetDefaultStyle(pImpl->aDefaultStyles[0]);
+        pImpl->m_pBox->SetDefaultStyle(pImpl->aDefaultStyles[0].second);
 
     return xItemWindow;
 }


More information about the Libreoffice-commits mailing list