diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-02-15 14:28:55 +0000 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-02-16 21:37:05 +0000 |
commit | 7b6bf8348f36e5b98c5a6d5ddc4815df07f4fbbc (patch) | |
tree | 3617a5c0c91cf685828118c317e9be9201ed218c | |
parent | 3b24499324a149626a6b57ea8ec32bf2a5f84152 (diff) |
Resolves: tdf#101000 ensure unique image names in .docscp-5.3-branch-point
(cherry picked from commit 432f605e3287269d1a20383f4eeebf012ee3679d)
Change-Id: Id4f93638ad366b66968e6946a835239beee16942
Reviewed-on: https://gerrit.libreoffice.org/34302
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | sw/source/filter/ww8/ww8graf2.cxx | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx index 90e60214fd84..dbcfdc32aedd 100644 --- a/sw/source/filter/ww8/ww8graf2.cxx +++ b/sw/source/filter/ww8/ww8graf2.cxx @@ -30,8 +30,9 @@ #include <sfx2/docfile.hxx> #include <sfx2/fcontnr.hxx> #include <grfatr.hxx> -#include <fmtflcnt.hxx> #include <fmtanchr.hxx> +#include <fmtcntnt.hxx> +#include <fmtflcnt.hxx> #include <frmfmt.hxx> #include <fltshell.hxx> #include <pam.hxx> @@ -454,6 +455,19 @@ void SwWW8ImplReader::PicRead(SvStream *pDataStream, WW8_PIC *pPic, pDataStream->SeekRel(2); //cProps } +namespace +{ + sal_uInt8 GetNodeType(SwFrameFormat &rSource) + { + const SwNodeIndex* pNodeIndex = rSource.GetContent().GetContentIdx(); + if (!pNodeIndex) + return 0; + const SwNode& rCSttNd = pNodeIndex->GetNode(); + SwNodeRange aRg(rCSttNd, 1, *rCSttNd.EndOfSectionNode()); + return aRg.aStart.GetNode().GetNodeType(); + } +} + SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj, SwFrameFormat* pOldFlyFormat) { @@ -670,12 +684,11 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj, if (pRecord) SetAttributesAtGrfNode(pRecord, pRet, nullptr); - // #i68101# - // removed pObject->HasSetName() usage since always returned - // true, also removed else-part and wrote an informing mail - // to Henning Brinkmann about this to clarify. - pRet->SetName(pObject->GetName()); - + OUString aObjectName(pObject->GetName()); + if (aObjectName.isEmpty() || !m_rDoc.FindFlyByName(aObjectName, GetNodeType(*pRet))) + pRet->SetName(aObjectName); + else + m_aGrfNameGenerator.SetUniqueGraphName(pRet, aObjectName); // determine the pointer to the new object and update // Z-order-list accordingly (or delete entry) |