summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-15 14:28:55 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-15 15:03:41 +0000
commit432f605e3287269d1a20383f4eeebf012ee3679d (patch)
treedf33691f969a07fe31a9d0504e0f1d10b5bb630d
parentd2b014edc0f466370023a35eb46548390ceb7fb2 (diff)
Resolves: tdf#101000 ensure unique image names in .docs
Change-Id: Id4f93638ad366b66968e6946a835239beee16942
-rw-r--r--sw/source/filter/ww8/ww8graf2.cxx27
1 files changed, 20 insertions, 7 deletions
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 08099375f463..c4fabfa88735 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>
@@ -455,6 +456,19 @@ void SwWW8ImplReader::PicRead(SvStream *pDataStream, WW8_PIC *pPic,
pDataStream->SeekRel(2); //cProps
}
+namespace
+{
+ SwNodeType GetNodeType(SwFrameFormat &rSource)
+ {
+ const SwNodeIndex* pNodeIndex = rSource.GetContent().GetContentIdx();
+ if (!pNodeIndex)
+ return SwNodeType::NONE;
+ const SwNode& rCSttNd = pNodeIndex->GetNode();
+ SwNodeRange aRg(rCSttNd, 1, *rCSttNd.EndOfSectionNode());
+ return aRg.aStart.GetNode().GetNodeType();
+ }
+}
+
SwFrameFormat* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
SwFrameFormat* pOldFlyFormat)
{
@@ -671,12 +685,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)