sd/source/filter/eppt/eppt.cxx | 35 ------------------------------- sd/source/filter/eppt/epptbase.hxx | 1 sd/source/filter/eppt/pptx-epptbase.cxx | 21 ++++++++++++++++++ sd/source/filter/eppt/pptx-epptooxml.cxx | 22 ------------------- 4 files changed, 24 insertions(+), 55 deletions(-)
New commits: commit a063a8bc391ae3017a114a9a5edd8073067168dc Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Thu Jun 13 19:31:48 2024 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> CommitDate: Mon Jun 17 11:57:17 2024 +0200 Move duplicate code into shared method Change-Id: I3859c3a491abbe74d12f08d86948196dddb462ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168822 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> diff --git a/sd/source/filter/eppt/eppt.cxx b/sd/source/filter/eppt/eppt.cxx index bb0544c5d068..1d0f242c20b1 100644 --- a/sd/source/filter/eppt/eppt.cxx +++ b/sd/source/filter/eppt/eppt.cxx @@ -1024,39 +1024,6 @@ bool PPTWriter::ImplCreateMainNotes() return true; } -static OUString getInitials( const OUString& rName ) -{ - OUStringBuffer sInitials; - - const sal_Unicode * pStr = rName.getStr(); - sal_Int32 nLength = rName.getLength(); - - while( nLength ) - { - // skip whitespace - while( nLength && (*pStr <= ' ') ) - { - nLength--; pStr++; - } - - // take letter - if( nLength ) - { - sInitials.append( *pStr ); - nLength--; pStr++; - } - - // skip letters until whitespace - while( nLength && (*pStr > ' ') ) - { - nLength--; pStr++; - } - } - - return sInitials.makeStringAndClear(); -} - - void PPTWriter::ImplExportComments( const uno::Reference< drawing::XDrawPage >& xPage, SvMemoryStream& rBinaryTagData10Atom ) { try @@ -1087,7 +1054,7 @@ void PPTWriter::ImplExportComments( const uno::Reference< drawing::XDrawPage >& : xAnnotation->getAuthor() ); uno::Reference< text::XText > xText( xAnnotation->getTextRange() ); OUString sText( xText->getString() ); - OUString sInitials( getInitials( sAuthor ) ); + OUString sInitials( GetInitials( sAuthor ) ); util::DateTime aEmptyDateTime; util::DateTime aDateTime(bRemoveCommentAuthorDates ? aEmptyDateTime : xAnnotation->getDateTime()); diff --git a/sd/source/filter/eppt/epptbase.hxx b/sd/source/filter/eppt/epptbase.hxx index 70bcd3a4b6ce..18199210cc6b 100644 --- a/sd/source/filter/eppt/epptbase.hxx +++ b/sd/source/filter/eppt/epptbase.hxx @@ -379,6 +379,7 @@ protected: ::tools::Rectangle MapRectangle( const css::awt::Rectangle& ); bool ContainsOtherShapeThanPlaceholders(); + static OUString GetInitials(std::u16string_view sName); public: PPTWriterBase(); diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx index 1e2137cb8057..fe9444865797 100644 --- a/sd/source/filter/eppt/pptx-epptbase.cxx +++ b/sd/source/filter/eppt/pptx-epptbase.cxx @@ -25,6 +25,7 @@ #include <vcl/outdev.hxx> #include <rtl/ustring.hxx> #include <rtl/strbuf.hxx> +#include <rtl/ustrbuf.hxx> #include <sal/log.hxx> #include <tools/UnitConversion.hxx> #include <com/sun/star/awt/Rectangle.hpp> @@ -997,4 +998,24 @@ bool PPTWriterBase::ContainsOtherShapeThanPlaceholders() return bOtherThanPlaceHolders; } +OUString PPTWriterBase::GetInitials(std::u16string_view sName) +{ + OUStringBuffer sRet; + + if (!sName.empty()) + { + sRet.append(sName[0]); + size_t nStart = 0, nOffset; + + while ((nOffset = sName.find(' ', nStart)) != std::u16string_view::npos) + { + if (nOffset + 1 < sName.size()) + sRet.append(sName[ nOffset + 1 ]); + nStart = nOffset + 1; + } + } + + return sRet.makeStringAndClear(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx index 728682f955d6..f7379a3cd68e 100644 --- a/sd/source/filter/eppt/pptx-epptooxml.cxx +++ b/sd/source/filter/eppt/pptx-epptooxml.cxx @@ -1017,26 +1017,6 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS) } } -static OUString lcl_GetInitials(std::u16string_view sName) -{ - OUStringBuffer sRet; - - if (!sName.empty()) - { - sRet.append(sName[0]); - size_t nStart = 0, nOffset; - - while ((nOffset = sName.find(' ', nStart)) != std::u16string_view::npos) - { - if (nOffset + 1 < sName.size()) - sRet.append(sName[ nOffset + 1 ]); - nStart = nOffset + 1; - } - } - - return sRet.makeStringAndClear(); -} - void PowerPointExport::WriteAuthors() { if (maAuthors.empty()) @@ -1056,7 +1036,7 @@ void PowerPointExport::WriteAuthors() pFS->singleElementNS(XML_p, XML_cmAuthor, XML_id, OString::number(i.second.nId), XML_name, i.first, - XML_initials, lcl_GetInitials(i.first), + XML_initials, GetInitials(i.first), XML_lastIdx, OString::number(i.second.nLastIndex), XML_clrIdx, OString::number(i.second.nId)); }