pptx export: Respect user defined initials

instead of generating new ones.

Change-Id: I8979eaa694642cebd552534eeddcff5483831e6e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169846
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
This commit is contained in:
Samuel Mehrbrodt
2024-07-04 07:33:21 +02:00
parent 2dfcc67fbc
commit 9b72524722
4 changed files with 11 additions and 25 deletions
-1
View File
@@ -379,7 +379,6 @@ protected:
::tools::Rectangle MapRectangle( const css::awt::Rectangle& );
bool ContainsOtherShapeThanPlaceholders();
static OUString GetInitials(std::u16string_view sName);
public:
PPTWriterBase();
+2 -1
View File
@@ -109,7 +109,7 @@ private:
sal_uInt32 GetNewSlideId() { return mnSlideIdMax ++; }
sal_uInt32 GetNewSlideMasterId() { return mnSlideMasterIdMax ++; }
sal_Int32 GetAuthorIdAndLastIndex( const OUString& sAuthor, sal_Int32& nLastIndex );
sal_Int32 GetAuthorIdAndLastIndex( const OUString& sAuthor, const OUString& sInitials, sal_Int32& nLastIndex );
// Write docProps/core.xml and docprops/custom.xml and docprops/app.xml
void writeDocumentProperties();
@@ -165,6 +165,7 @@ private:
struct AuthorComments {
sal_Int32 nId;
sal_Int32 nLastIndex;
OUString sInitials;
};
typedef std::unordered_map< OUString, struct AuthorComments > AuthorsMap;
AuthorsMap maAuthors;
-20
View File
@@ -998,24 +998,4 @@ 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: */
+9 -3
View File
@@ -1036,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, GetInitials(i.first),
XML_initials, i.second.sInitials,
XML_lastIdx, OString::number(i.second.nLastIndex),
XML_clrIdx, OString::number(i.second.nId));
}
@@ -1046,7 +1046,9 @@ void PowerPointExport::WriteAuthors()
pFS->endDocument();
}
sal_Int32 PowerPointExport::GetAuthorIdAndLastIndex(const OUString& sAuthor, sal_Int32& nLastIndex)
sal_Int32 PowerPointExport::GetAuthorIdAndLastIndex(const OUString& sAuthor,
const OUString& sInitials,
sal_Int32& nLastIndex)
{
if (maAuthors.count(sAuthor) <= 0)
{
@@ -1054,6 +1056,7 @@ sal_Int32 PowerPointExport::GetAuthorIdAndLastIndex(const OUString& sAuthor, sal
aAuthorComments.nId = maAuthors.size();
aAuthorComments.nLastIndex = 0;
aAuthorComments.sInitials = sInitials;
maAuthors[ sAuthor ] = aAuthorComments;
}
@@ -1172,7 +1175,10 @@ bool PowerPointExport::WriteComments(sal_uInt32 nPageNum)
? "Author"
+ OUString::number(GetInfoID(xAnnotation->getAuthor()))
: xAnnotation->getAuthor());
sal_Int32 nId = GetAuthorIdAndLastIndex(sAuthor, nLastIndex);
OUString sInitials(bRemoveCommentAuthorDates
? "A" + OUString::number(GetInfoID(xAnnotation->getAuthor()))
: xAnnotation->getInitials());
sal_Int32 nId = GetAuthorIdAndLastIndex(sAuthor, sInitials, nLastIndex);
char cDateTime[sizeof("-32768-65535-65535T65535:65535:65535.4294967295")];
// reserve enough space for hypothetical max length