[Libreoffice-commits] core.git: 2 commits - svx/source sw/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 18 11:30:54 UTC 2020
svx/source/inc/StylesPreviewToolBoxControl.hxx | 2 -
svx/source/inc/StylesPreviewWindow.hxx | 18 +++++----
svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx | 10 ++++-
svx/source/tbxctrls/StylesPreviewWindow.cxx | 39 +++++++++++---------
sw/source/core/doc/DocumentStylePoolManager.cxx | 11 +++++
sw/source/core/edit/edfcol.cxx | 13 ++++++
6 files changed, 65 insertions(+), 28 deletions(-)
New commits:
commit 10aac52bafc8a0430d1da3fe8f45832c64d6bf34
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Aug 31 13:05:31 2020 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Sep 18 13:30:17 2020 +0200
Styles preview widget language independent
Use both english / universal and translated names
to identify a style.
Change-Id: Ibd8b23e678e8bea5773d1da97adf5201377b4453
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101832
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Tested-by: Szymon Kłos <szymon.klos at collabora.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102963
Tested-by: Jenkins
diff --git a/svx/source/inc/StylesPreviewToolBoxControl.hxx b/svx/source/inc/StylesPreviewToolBoxControl.hxx
index 7e2bd85da67e..c7ac3f9953b6 100644
--- a/svx/source/inc/StylesPreviewToolBoxControl.hxx
+++ b/svx/source/inc/StylesPreviewToolBoxControl.hxx
@@ -35,7 +35,7 @@ class StylesPreviewToolBoxControl final
css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
- std::vector<OUString> m_aDefaultStyles;
+ std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
public:
StylesPreviewToolBoxControl();
diff --git a/svx/source/inc/StylesPreviewWindow.hxx b/svx/source/inc/StylesPreviewWindow.hxx
index 5ae857210c6f..26ba93d7be79 100644
--- a/svx/source/inc/StylesPreviewWindow.hxx
+++ b/svx/source/inc/StylesPreviewWindow.hxx
@@ -44,19 +44,19 @@ class StyleItemController : public weld::CustomWidgetController
static constexpr unsigned LEFT_MARGIN = 8;
SfxStyleFamily m_eStyleFamily;
- OUString m_aStyleName;
+ std::pair<OUString, OUString> m_aStyleName;
bool m_bSelected;
css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
public:
- StyleItemController(const OUString& aStyleName,
+ StyleItemController(const std::pair<OUString, OUString>& aStyleName,
css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
bool MouseButtonDown(const MouseEvent&) override;
- void SetStyle(const OUString& sStyleName);
+ void SetStyle(const std::pair<OUString, OUString>& sStyleName);
void Select(bool bSelect);
@@ -83,8 +83,8 @@ protected:
std::unique_ptr<weld::Toolbar> m_xUp;
std::unique_ptr<weld::Toolbar> m_xDown;
- std::vector<OUString> m_aDefaultStyles;
- std::vector<OUString> m_aAllStyles;
+ std::vector<std::pair<OUString, OUString>> m_aDefaultStyles;
+ std::vector<std::pair<OUString, OUString>> m_aAllStyles;
unsigned m_nStyleIterator;
OUString m_sSelectedStyle;
@@ -93,7 +93,8 @@ protected:
DECL_LINK(GoDown, const OString&, void);
public:
- StylesPreviewWindow_Base(weld::Builder& xBuilder, std::vector<OUString>& aDefaultStyles,
+ StylesPreviewWindow_Base(weld::Builder& xBuilder,
+ std::vector<std::pair<OUString, OUString>>& aDefaultStyles,
css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
~StylesPreviewWindow_Base();
@@ -103,13 +104,14 @@ private:
void Update();
void UpdateStylesList();
void MakeCurrentStyleVisible();
- OUString GetVisibleStyle(unsigned nPosition);
+ std::pair<OUString, OUString> GetVisibleStyle(unsigned nPosition);
};
class StylesPreviewWindow_Impl : public InterimItemWindow, public StylesPreviewWindow_Base
{
public:
- StylesPreviewWindow_Impl(vcl::Window* pParent, std::vector<OUString>& aDefaultStyles,
+ StylesPreviewWindow_Impl(vcl::Window* pParent,
+ std::vector<std::pair<OUString, OUString>>& aDefaultStyles,
css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider);
~StylesPreviewWindow_Impl();
diff --git a/svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx b/svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx
index 7e4a0167b908..9b78a0e7aaf0 100644
--- a/svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx
+++ b/svx/source/tbxctrls/StylesPreviewToolBoxControl.cxx
@@ -79,7 +79,10 @@ void StylesPreviewToolBoxControl::InitializeStyles(
OUString sName;
xStyle->getPropertyValue("DisplayName") >>= sName;
if (!sName.isEmpty())
- m_aDefaultStyles.push_back(sName);
+ m_aDefaultStyles.push_back(std::pair<OUString, OUString>(aStyle, sName));
+ }
+ catch (const css::container::NoSuchElementException&)
+ {
}
catch (const css::uno::Exception&)
{
@@ -103,7 +106,10 @@ void StylesPreviewToolBoxControl::InitializeStyles(
OUString sName;
xStyle->getPropertyValue("DisplayName") >>= sName;
if (!sName.isEmpty())
- m_aDefaultStyles.push_back(sName);
+ {
+ m_aDefaultStyles.push_back(
+ std::pair<OUString, OUString>(sStyleName, sName));
+ }
}
}
catch (const css::uno::Exception&)
diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx
index 992c601601a4..6bd4f54ecba8 100644
--- a/svx/source/tbxctrls/StylesPreviewWindow.cxx
+++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx
@@ -71,7 +71,7 @@ void StyleStatusListener::StateChanged(SfxItemState /*eState*/, const SfxPoolIte
}
StyleItemController::StyleItemController(
- const OUString& aStyleName,
+ const std::pair<OUString, OUString>& aStyleName,
css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
: m_eStyleFamily(SfxStyleFamily::Para)
, m_aStyleName(aStyleName)
@@ -90,7 +90,7 @@ void StyleItemController::Paint(vcl::RenderContext& rRenderContext,
rRenderContext.Pop();
}
-void StyleItemController::SetStyle(const OUString& sStyleName)
+void StyleItemController::SetStyle(const std::pair<OUString, OUString>& sStyleName)
{
m_aStyleName = sStyleName;
Invalidate();
@@ -105,7 +105,7 @@ void StyleItemController::Select(bool bSelect)
bool StyleItemController::MouseButtonDown(const MouseEvent&)
{
css::uno::Sequence<css::beans::PropertyValue> aArgs(2);
- aArgs[0].Value <<= m_aStyleName;
+ aArgs[0].Value <<= m_aStyleName.second;
aArgs[1].Name = "Family";
aArgs[1].Value <<= sal_Int16(m_eStyleFamily);
@@ -217,7 +217,8 @@ void StyleItemController::DrawEntry(vcl::RenderContext& rRenderContext)
return;
pStyle = pPool->First(m_eStyleFamily);
- while (pStyle && pStyle->GetName() != m_aStyleName)
+ while (pStyle && pStyle->GetName() != m_aStyleName.first
+ && pStyle->GetName() != m_aStyleName.second)
pStyle = pPool->Next();
if (!pStyle)
@@ -319,7 +320,7 @@ void StyleItemController::DrawSelection(vcl::RenderContext& rRenderContext)
void StyleItemController::DrawHighlight(vcl::RenderContext& rRenderContext, Color aFontBack)
{
tools::Rectangle aTextRect;
- rRenderContext.GetTextBoundRect(aTextRect, m_aStyleName);
+ rRenderContext.GetTextBoundRect(aTextRect, m_aStyleName.second);
Size aSize = aTextRect.GetSize();
aSize.AdjustHeight(aSize.getHeight());
@@ -339,17 +340,17 @@ void StyleItemController::DrawHighlight(vcl::RenderContext& rRenderContext, Colo
void StyleItemController::DrawText(vcl::RenderContext& rRenderContext)
{
tools::Rectangle aTextRect;
- rRenderContext.GetTextBoundRect(aTextRect, m_aStyleName);
+ rRenderContext.GetTextBoundRect(aTextRect, m_aStyleName.second);
Point aPos(0, 0);
aPos.AdjustX(LEFT_MARGIN);
aPos.AdjustY((rRenderContext.GetOutputHeightPixel() - aTextRect.Bottom()) / 2);
- rRenderContext.DrawText(aPos, m_aStyleName);
+ rRenderContext.DrawText(aPos, m_aStyleName.second);
}
StylesPreviewWindow_Base::StylesPreviewWindow_Base(
- weld::Builder& xBuilder, std::vector<OUString>& aDefaultStyles,
+ weld::Builder& xBuilder, std::vector<std::pair<OUString, OUString>>& aDefaultStyles,
css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
: m_xUp(xBuilder.weld_toolbar("uptoolbar"))
, m_xDown(xBuilder.weld_toolbar("downtoolbar"))
@@ -358,7 +359,9 @@ StylesPreviewWindow_Base::StylesPreviewWindow_Base(
{
for (unsigned int i = 0; i < STYLES_COUNT; i++)
{
- m_xStyleControllers[i].reset(new StyleItemController(aDefaultStyles[i], xDispatchProvider));
+ auto aStyle
+ = i < aDefaultStyles.size() ? aDefaultStyles[i] : std::pair<OUString, OUString>("", "");
+ m_xStyleControllers[i].reset(new StyleItemController(aStyle, xDispatchProvider));
OUString sIdOUString = "style" + OUString::number(i + 1);
OString sId = OUStringToOString(sIdOUString, RTL_TEXTENCODING_ASCII_US);
@@ -390,10 +393,10 @@ StylesPreviewWindow_Base::~StylesPreviewWindow_Base()
m_pStatusListener = nullptr;
}
-OUString StylesPreviewWindow_Base::GetVisibleStyle(unsigned nPosition)
+std::pair<OUString, OUString> StylesPreviewWindow_Base::GetVisibleStyle(unsigned nPosition)
{
if (nPosition >= STYLES_COUNT || !m_aAllStyles.size())
- return "";
+ return std::make_pair<OUString, OUString>("", "");
return m_aAllStyles[(m_nStyleIterator + nPosition) % m_aAllStyles.size()];
}
@@ -413,7 +416,9 @@ void StylesPreviewWindow_Base::MakeCurrentStyleVisible()
return;
unsigned nNewIterator = m_nStyleIterator;
- auto aFound = std::find(m_aAllStyles.begin(), m_aAllStyles.end(), m_sSelectedStyle);
+ auto aFound = std::find_if(m_aAllStyles.begin(), m_aAllStyles.end(), [this](auto it) {
+ return it.first == m_sSelectedStyle || it.second == m_sSelectedStyle;
+ });
if (aFound != m_aAllStyles.end())
nNewIterator = aFound - m_aAllStyles.begin();
@@ -430,11 +435,11 @@ void StylesPreviewWindow_Base::Update()
for (unsigned int i = 0; i < STYLES_COUNT; i++)
{
- OUString sStyleName = GetVisibleStyle(i);
+ std::pair<OUString, OUString> sStyleName = GetVisibleStyle(i);
m_xStyleControllers[i]->SetStyle(sStyleName);
- m_xStyleControllersWeld[i]->set_tooltip_text(sStyleName);
+ m_xStyleControllersWeld[i]->set_tooltip_text(sStyleName.second);
- if (sStyleName == m_sSelectedStyle)
+ if (sStyleName.first == m_sSelectedStyle || sStyleName.second == m_sSelectedStyle)
m_xStyleControllers[i]->Select(true);
else
m_xStyleControllers[i]->Select(false);
@@ -460,7 +465,7 @@ void StylesPreviewWindow_Base::UpdateStylesList()
while (pStyle)
{
- m_aAllStyles.push_back(pStyle->GetName());
+ m_aAllStyles.push_back(std::pair<OUString, OUString>("", pStyle->GetName()));
pStyle = xIter->Next();
}
}
@@ -483,7 +488,7 @@ IMPL_LINK(StylesPreviewWindow_Base, GoDown, const OString&, /*rItem*/, void)
}
StylesPreviewWindow_Impl::StylesPreviewWindow_Impl(
- vcl::Window* pParent, std::vector<OUString>& aDefaultStyles,
+ vcl::Window* pParent, std::vector<std::pair<OUString, OUString>>& aDefaultStyles,
css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider)
: InterimItemWindow(pParent, "svx/ui/stylespreview.ui", "ApplyStyleBox",
reinterpret_cast<sal_uInt64>(SfxViewShell::Current()))
commit e046042865cd269b901fdf95c861f66b31fb4b0a
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Aug 31 12:49:46 2020 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Sep 18 13:30:10 2020 +0200
writer: handle styles in multiple languages for online
Use translated name when style is applied and broadcasted.
Avoid using style names created by the first view.
Change-Id: I18abf3388e69f76ec99eda94e0b67782a52ab23f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101831
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/+/102962
Tested-by: Jenkins
Tested-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx
index a6ff35a87200..de8303491c6c 100644
--- a/sw/source/core/doc/DocumentStylePoolManager.cxx
+++ b/sw/source/core/doc/DocumentStylePoolManager.cxx
@@ -70,6 +70,7 @@
#include <com/sun/star/text/HoriOrientation.hpp>
#include <unotools/syslocale.hxx>
#include <i18nlangtag/languagetag.hxx>
+#include <comphelper/lok.hxx>
using namespace ::editeng;
using namespace ::com::sun::star;
@@ -585,11 +586,21 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId,
SwTextFormatColl* pNewColl;
sal_uInt16 nOutLvlBits = 0;
+
for (size_t n = 0, nSize = m_rDoc.GetTextFormatColls()->size(); n < nSize; ++n)
{
pNewColl = (*m_rDoc.GetTextFormatColls())[ n ];
if( nId == pNewColl->GetPoolFormatId() )
{
+ // in online we can have multiple languages, use translated name
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ OUString aName;
+ SwStyleNameMapper::GetUIName(nId, aName);
+ if (!aName.isEmpty())
+ pNewColl->SetName(aName);
+ }
+
return pNewColl;
}
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index d23a345a06ef..23988e1c4e12 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -91,6 +91,8 @@
#include <tools/diagnose_ex.h>
#include <IDocumentRedlineAccess.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <comphelper/lok.hxx>
#define WATERMARK_NAME "PowerPlusWaterMarkObject"
#define WATERMARK_AUTO_SIZE sal_uInt32(1)
@@ -2186,6 +2188,17 @@ void SwEditShell::SetTextFormatColl(SwTextFormatColl *pFormat,
RedlineFlags eRedlMode = GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags(), eOldMode = eRedlMode;
SwRewriter aRewriter;
+
+ // in online we can have multiple languages, use universal name then
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ OUString aName;
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(pLocal->GetName(), SwGetPoolIdFromName::TxtColl);
+ SwStyleNameMapper::FillProgName(nId, aName);
+ if (!aName.isEmpty())
+ pLocal->SetName(aName);
+ }
+
aRewriter.AddRule(UndoArg1, pLocal->GetName());
GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::SETFMTCOLL, &aRewriter);
More information about the Libreoffice-commits
mailing list