Kaydet (Commit) db6f15ab authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 599643ec
......@@ -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);
......
......@@ -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
......
......@@ -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"
......
......@@ -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().
......
......@@ -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 )
{
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment