summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2020-09-18 13:26:41 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2020-11-12 08:06:09 +0100
commit1a1b0c91715b3fe3ec2988afab4e5bc40ada67c0 (patch)
tree70426e359e864c4eba5b64616b35edf14f5168d4 /svx
parent1397a1c8e4995b0dd336478e564880fe8ad91d1d (diff)
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@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105592 Tested-by: Jenkins
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx27
1 files changed, 19 insertions, 8 deletions
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;
}