summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-06-13 19:37:37 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-06-13 20:07:16 +0200
commitdb6f15ab21c7292c895a0042dc13072649dbfc9c (patch)
treedbb2957ae985302cafe854b0d72ddfb4b7ee21c4
parentSwXShape: add ChainNext/PrevName UNO property (diff)
downloadcore-db6f15ab21c7292c895a0042dc13072649dbfc9c.tar.gz
core-db6f15ab21c7292c895a0042dc13072649dbfc9c.zip
SwXShape: add ChainName UNO property
Shapes may not have a unique name, but TextFrames always have. So in order to be able to link shapes with textboxes, provide a ChainName property that's the name of the underlying TextFrame. This kills two birds with one stone: - we can have a unique name for each shape - the names can be used for TextFrame linking, as they are valid TextFrame names Change-Id: Ie96f267d392d9fe5388c5eacff9b873f1639054c
-rw-r--r--sw/inc/textboxhelper.hxx2
-rw-r--r--sw/inc/unomid.h1
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/source/core/doc/textboxhelper.cxx19
-rw-r--r--sw/source/core/unocore/unodraw.cxx5
-rw-r--r--sw/source/core/unocore/unomap.cxx1
6 files changed, 29 insertions, 0 deletions
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 50024e14c086..665f82abdc00 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -54,6 +54,8 @@ public:
static void syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const css::uno::Any& rValue);
/// Does the same, but works on properties which lack an sw-specific WID / MemberID.
static void syncProperty(SwFrmFmt* pShape, const OUString& rPropertyName, const css::uno::Any& rValue);
+ /// Get a property of the underlying TextFrame.
+ static void getProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, css::uno::Any& rValue);
/// If we have an associated TextFrame, then return that.
static SwFrmFmt* findTextBox(SwFrmFmt* pShape);
diff --git a/sw/inc/unomid.h b/sw/inc/unomid.h
index 11d14c96664f..9d514a2350b1 100644
--- a/sw/inc/unomid.h
+++ b/sw/inc/unomid.h
@@ -56,6 +56,7 @@
#define MID_CHAIN_PREVNAME 0
#define MID_CHAIN_NEXTNAME 1
+#define MID_CHAIN_NAME 2
#define MID_LINENUMBER_COUNT 0
#define MID_LINENUMBER_STARTVALUE 1
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index bed1254b4a5e..9f0267e872e2 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -266,6 +266,7 @@
#define UNO_NAME_BREAK_TYPE "BreakType"
#define UNO_NAME_CHAIN_NEXT_NAME "ChainNextName"
#define UNO_NAME_CHAIN_PREV_NAME "ChainPrevName"
+#define UNO_NAME_CHAIN_NAME "ChainName"
#define UNO_NAME_CHAPTER_FORMAT "ChapterFormat"
#define UNO_NAME_CLIENT_MAP "ClientMap"
#define UNO_NAME_CONDITION "Condition"
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index accd9122b90e..5ddfbe01ab0f 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -63,6 +63,9 @@ void SwTextBoxHelper::create(SwFrmFmt* pShape)
xPropertySet->setPropertyValue(UNO_NAME_SIZE_TYPE, uno::makeAny(text::SizeType::FIX));
+ uno::Reference<container::XNamed> xNamed(xTextFrame, uno::UNO_QUERY);
+ xNamed->setName(pShape->GetDoc()->GetUniqueFrameName());
+
// Link its text range to the original shape.
uno::Reference<text::XTextRange> xTextBox(xTextFrame, uno::UNO_QUERY_THROW);
SwUnoInternalPaM aInternalPaM(*pShape->GetDoc());
@@ -274,6 +277,22 @@ void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, const OUString& rPropertyNa
}
}
+void SwTextBoxHelper::getProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberId, css::uno::Any& rValue)
+{
+ if (!pShape)
+ return;
+
+ nMemberId &= ~CONVERT_TWIPS;
+
+ if (SwFrmFmt* pFmt = findTextBox(pShape))
+ {
+ if (nWID == RES_CHAIN && nMemberId == MID_CHAIN_NAME)
+ {
+ rValue = uno::makeAny(pFmt->GetName());
+ }
+ }
+}
+
void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8 nMemberId, const css::uno::Any& rValue)
{
// No shape yet? Then nothing to do, initial properties are set by create().
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index ed62fd7901a2..afbf447b8551 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1540,6 +1540,11 @@ uno::Any SwXShape::getPropertyValue(const OUString& rPropertyName)
bool bValue = SwTextBoxHelper::findTextBox(pFmt);
aRet <<= bValue;
}
+ else if (pEntry->nWID == RES_CHAIN)
+ {
+ if (pEntry->nMemberId == MID_CHAIN_NAME)
+ SwTextBoxHelper::getProperty(pFmt, pEntry->nWID, pEntry->nMemberId, aRet);
+ }
// #i28749#
else if ( FN_SHAPE_TRANSFORMATION_IN_HORI_L2R == pEntry->nWID )
{
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index d2132860bba4..9464e49a9be0 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1398,6 +1398,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
{ OUString(UNO_NAME_TEXT_BOX), FN_TEXT_BOX, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0},
{ OUString(UNO_NAME_CHAIN_NEXT_NAME), RES_CHAIN, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID ,MID_CHAIN_NEXTNAME},
{ OUString(UNO_NAME_CHAIN_PREV_NAME), RES_CHAIN, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID ,MID_CHAIN_PREVNAME},
+ { OUString(UNO_NAME_CHAIN_NAME), RES_CHAIN, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID ,MID_CHAIN_NAME },
{ OUString(), 0, css::uno::Type(), 0, 0 }
};
aMapEntriesArr[nPropertyId] = aShapeMap_Impl;