summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-04-22 19:10:58 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-04-22 21:11:49 +0200
commit193996728c842a4a36f678d5bf34a775e3c30636 (patch)
tree73494f81b7a15bb1034c09886fc76e25bc2eab7c
parentcd4d6187a24119cb4954ec10539902c2aa120c0f (diff)
Resolves: tdf#122487 take groups into account
interate and recurse through their contents for name collision check Change-Id: Ide7d1d051f6b9420b7ef7b3f6bed669dbde5697a Reviewed-on: https://gerrit.libreoffice.org/71077 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/core/doc/doclay.cxx44
1 files changed, 34 insertions, 10 deletions
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 30bd3d0e7225..286064fddab8 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -23,6 +23,7 @@
#include <sot/exchange.hxx>
#include <sfx2/progress.hxx>
#include <svx/svdmodel.hxx>
+#include <svx/svdogrp.hxx>
#include <svx/svdpage.hxx>
#include <editeng/keepitem.hxx>
#include <editeng/ulspitem.hxx>
@@ -1286,6 +1287,36 @@ SwFlyFrameFormat* SwDoc::InsertDrawLabel(
return pNewFormat;
}
+static void lcl_SetNumUsedBit(std::vector<sal_uInt8>& rSetFlags, size_t nFormatSize, sal_Int32 nNmLen, const OUString& rName, const OUString& rCmpName)
+{
+ if (rName.startsWith(rCmpName))
+ {
+ // Only get and set the Flag
+ const sal_Int32 nNum = rName.copy(nNmLen).toInt32()-1;
+ if (nNum >= 0 && static_cast<SwFrameFormats::size_type>(nNum) < nFormatSize)
+ rSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
+ }
+}
+
+static void lcl_SetNumUsedBit(std::vector<sal_uInt8>& rSetFlags, size_t nFormatSize, sal_Int32 nNmLen, const SdrObject& rObj, const OUString& rCmpName)
+{
+ OUString sName = rObj.GetName();
+ lcl_SetNumUsedBit(rSetFlags, nFormatSize, nNmLen, sName, rCmpName);
+ // tdf#122487 take groups into account, interate and recurse through their
+ // contents for name collision check
+ if (rObj.IsGroupObject())
+ {
+ const SdrObjGroup &rGroupObj = static_cast<const SdrObjGroup&>(rObj);
+ for (size_t i = 0, nCount = rGroupObj.GetObjCount(); i < nCount; ++i)
+ {
+ SdrObject* pObj = rGroupObj.GetObj(i);
+ if (!pObj)
+ continue;
+ lcl_SetNumUsedBit(rSetFlags, nFormatSize, nNmLen, *pObj, rCmpName);
+ }
+ }
+}
+
static OUString lcl_GetUniqueFlyName(const SwDoc* pDoc, const char* pDefStrId, sal_uInt16 eType)
{
assert(eType >= RES_FMT_BEGIN && eType < RES_FMT_END);
@@ -1309,23 +1340,16 @@ static OUString lcl_GetUniqueFlyName(const SwDoc* pDoc, const char* pDefStrId, s
const SwFrameFormat* pFlyFormat = rFormats[ n ];
if (eType != pFlyFormat->Which())
continue;
- OUString sName;
if (eType == RES_DRAWFRMFMT)
{
const SdrObject *pObj = pFlyFormat->FindSdrObject();
if (pObj)
- sName = pObj->GetName();
+ lcl_SetNumUsedBit(aSetFlags, rFormats.size(), nNmLen, *pObj, aName);
}
else
{
- sName = pFlyFormat->GetName();
- }
- if (sName.startsWith(aName))
- {
- // Only get and set the Flag
- const sal_Int32 nNum = sName.copy(nNmLen).toInt32()-1;
- if( nNum >= 0 && static_cast<SwFrameFormats::size_type>(nNum) < rFormats.size() )
- aSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
+ OUString sName = pFlyFormat->GetName();
+ lcl_SetNumUsedBit(aSetFlags, rFormats.size(), nNmLen, sName, aName);
}
}