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:
@@ -379,7 +379,6 @@ protected:
|
||||
::tools::Rectangle MapRectangle( const css::awt::Rectangle& );
|
||||
|
||||
bool ContainsOtherShapeThanPlaceholders();
|
||||
static OUString GetInitials(std::u16string_view sName);
|
||||
|
||||
public:
|
||||
PPTWriterBase();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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: */
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user