[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Jun 13 11:07:43 PDT 2014


 sw/inc/textboxhelper.hxx             |    2 ++
 sw/inc/unomid.h                      |    1 +
 sw/inc/unoprnms.hxx                  |    1 +
 sw/source/core/doc/textboxhelper.cxx |   30 ++++++++++++++++++++++++++++++
 sw/source/core/unocore/unodraw.cxx   |   10 ++++++++++
 sw/source/core/unocore/unomap.cxx    |    3 +++
 6 files changed, 47 insertions(+)

New commits:
commit db6f15ab21c7292c895a0042dc13072649dbfc9c
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jun 13 19:37:37 2014 +0200

    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

diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index 50024e1..665f82a 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 11d14c9..9d514a2 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 bed1254..9f0267e 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 accd912..5ddfbe0 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 ed62fd7..afbf447 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 d213286..9464e49 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;
commit 599643ec944dd3cad37a65e99d443e2010c8a36f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jun 13 18:52:38 2014 +0200

    SwXShape: add ChainNext/PrevName UNO property
    
    At the moment it's only possible to set this property, and it only sets
    the same property of the underlying textbox, if there is any.
    
    Change-Id: I9f168f69a8e92a1b26f21e653a05c97e2e32297c

diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 06bc0e0..accd912 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -351,6 +351,17 @@ void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, sal_uInt16 nWID, sal_uInt8
                 }
             }
             break;
+        case RES_CHAIN:
+            switch (nMemberId)
+            {
+            case MID_CHAIN_PREVNAME:
+                aPropertyName = UNO_NAME_CHAIN_PREV_NAME;
+                break;
+            case MID_CHAIN_NEXTNAME:
+                aPropertyName = UNO_NAME_CHAIN_NEXT_NAME;
+                break;
+            }
+            break;
         }
 
         if (!aPropertyName.isEmpty())
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 19d24f5..ed62fd7 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1201,6 +1201,11 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a
                         SwTextBoxHelper::destroy(pFmt);
 
                 }
+                else if (pEntry->nWID == RES_CHAIN)
+                {
+                    if (pEntry->nMemberId == MID_CHAIN_NEXTNAME || pEntry->nMemberId == MID_CHAIN_PREVNAME)
+                        SwTextBoxHelper::syncProperty(pFmt, pEntry->nWID, pEntry->nMemberId, aValue);
+                }
                 // #i28749#
                 else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
                 {
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 6a26b9d..d213286 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1396,6 +1396,8 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                     { OUString(UNO_NAME_RELATIVE_WIDTH), RES_FRM_SIZE,      cppu::UnoType<sal_Int16>::get()  ,         PROPERTY_NONE, MID_FRMSIZE_REL_WIDTH  },
                     { OUString(UNO_NAME_RELATIVE_WIDTH_RELATION), RES_FRM_SIZE, cppu::UnoType<sal_Int16>::get(),       PROPERTY_NONE, MID_FRMSIZE_REL_WIDTH_RELATION },
                     { 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(), 0, css::uno::Type(), 0, 0 }
                 };
                 aMapEntriesArr[nPropertyId] = aShapeMap_Impl;


More information about the Libreoffice-commits mailing list