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

Jakub Trzebiatowski ubap.dev at gmail.com
Tue May 31 07:22:55 UTC 2016


 sw/inc/tblafmt.hxx                  |    1 
 sw/inc/unocoll.hxx                  |    2 
 sw/inc/unomap.hxx                   |    3 
 sw/inc/unostyle.hxx                 |   69 +++++++++++-
 sw/qa/python/check_styles.py        |    9 +
 sw/source/core/doc/tblafmt.cxx      |   15 ++
 sw/source/core/unocore/unocoll.cxx  |    7 +
 sw/source/core/unocore/unomap.cxx   |   10 +
 sw/source/core/unocore/unomap1.cxx  |    6 +
 sw/source/core/unocore/unostyle.cxx |  206 ++++++++++++++++++++++++++++++++++--
 10 files changed, 312 insertions(+), 16 deletions(-)

New commits:
commit be0c898587f9464cd7a11be5e6b1d4e8dbd078d8
Author: Jakub Trzebiatowski <ubap.dev at gmail.com>
Date:   Fri May 27 17:55:44 2016 +0200

    Sw UNO API SwXTextCellStyle; TableStyles createInstance, XNameAccess
    
    Making createInstance("com.sun.star.style.TableStyle") possible
    Making SwXTextTableStyle a XNameAccess container of SwXTextCellStyles
    
    Implementing basic SwXTextCellStyle
    
    CellStyleMap based on svx/source/table/tabledesign.cxx
    
    Change-Id: I5afff1f514582a63a6eb9f9fb44667665749855a
    Reviewed-on: https://gerrit.libreoffice.org/25558
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index 73c1f5a..5490dce 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -266,6 +266,7 @@ public:
 
     void SetBoxFormat( const SwBoxAutoFormat& rNew, sal_uInt8 nPos );
     const SwBoxAutoFormat& GetBoxFormat( sal_uInt8 nPos ) const;
+    SwBoxAutoFormat& GetBoxFormat( sal_uInt8 nPos );
 
     void SetName( const OUString& rNew ) { m_aName = rNew; nStrResId = USHRT_MAX; }
     const OUString& GetName() const { return m_aName; }
diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx
index f4cc3c8..32979a9 100644
--- a/sw/inc/unocoll.hxx
+++ b/sw/inc/unocoll.hxx
@@ -182,7 +182,7 @@ class SwUnoCollection
 #define SW_SERVICE_VBACODENAMEPROVIDER                  111
 #define SW_SERVICE_VBAPROJECTNAMEPROVIDER               112
 #define SW_SERVICE_VBAGLOBALS                           113
-
+#define SW_SERVICE_STYLE_TABLE_STYLE                    114
 
 #define SW_SERVICE_INVALID          USHRT_MAX
 
diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx
index 80439cb..cf5b068 100644
--- a/sw/inc/unomap.hxx
+++ b/sw/inc/unomap.hxx
@@ -123,7 +123,8 @@
 #define PROPERTY_MAP_METAFIELD                          98
 #define PROPERTY_MAP_ACCESSIBILITY_TEXT_ATTRIBUTE       99
 #define PROPERTY_MAP_TABLE_STYLE                        100
-#define PROPERTY_MAP_END                                101
+#define PROPERTY_MAP_CELL_STYLE                         101
+#define PROPERTY_MAP_END                                102
 
 //S&E
 #define WID_WORDS                0
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index 9a56b5c..9b59091 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -248,16 +248,39 @@ protected:
 };
 
 class SwTableAutoFormat;
+typedef std::map<OUString, sal_Int32> CellStyleNameMap;
 
 /// A text table style is a uno api wrapper for a SwTableAutoFormat
-class SwXTextTableStyle : public cppu::WeakImplHelper<css::style::XStyle, css::lang::XServiceInfo>
+class SwXTextTableStyle : public cppu::WeakImplHelper
+<
+    css::style::XStyle,
+    css::container::XNameAccess,
+    css::lang::XServiceInfo
+>
 {
-    OUString m_sTableAutoFormatName;
     SwDocShell* m_pDocShell;
+    OUString m_sTableAutoFormatName;
+
+    enum {
+        FIRST_ROW_STYLE = 0,
+        LAST_ROW_STYLE,
+        FIRST_COLUMN_STYLE,
+        LAST_COLUMN_STYLE,
+        EVEN_ROWS_STYLE,
+        ODD_ROWS_STYLE,
+        EVEN_COLUMNS_STYLE,
+        ODD_COLUMNS_STYLE,
+        BODY_STYLE,
+        BACKGROUND_STYLE,
+        STYLE_COUNT
+    };
 
     SwTableAutoFormat* GetTableAutoFormat();
+    static const CellStyleNameMap& GetCellStyleNameMap();
+    css::uno::Reference<css::style::XStyle> m_aCellStyles[STYLE_COUNT];
 public:
     SwXTextTableStyle(SwDocShell* pDocShell, const OUString& rTableAutoFormatName);
+
     //XStyle
     virtual sal_Bool SAL_CALL isUserDefined() throw (css::uno::RuntimeException, std::exception) override;
     virtual sal_Bool SAL_CALL isInUse() throw (css::uno::RuntimeException, std::exception) override;
@@ -268,6 +291,15 @@ public:
     virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
     virtual void SAL_CALL setName(const OUString& rName) throw(css::uno::RuntimeException, std::exception) override;
 
+    //XNameAccess
+    virtual css::uno::Any SAL_CALL getByName(const OUString& rName) throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
+    virtual css::uno::Sequence<OUString> SAL_CALL getElementNames() throw(css::uno::RuntimeException, std::exception) override;
+    virtual sal_Bool SAL_CALL hasByName(const OUString& rName) throw(css::uno::RuntimeException, std::exception) override;
+
+    //XElementAccess
+    virtual css::uno::Type SAL_CALL getElementType() throw(css::uno::RuntimeException, std::exception) override;
+    virtual sal_Bool SAL_CALL hasElements() throw(css::uno::RuntimeException, std::exception) override;
+
     //XServiceInfo
     virtual OUString SAL_CALL getImplementationName() throw(css::uno::RuntimeException, std::exception) override;
     virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) throw(css::uno::RuntimeException, std::exception) override;
@@ -275,6 +307,39 @@ public:
 
     static css::uno::Reference<css::style::XStyle> CreateXTextTableStyle(SwDocShell* pDocShell, const OUString& rTableAutoFormatName);
 };
+
+class SwBoxAutoFormat;
+/// A text cell style is a uno api wrapper for a SwBoxAutoFormat core class
+class SwXTextCellStyle : public cppu::WeakImplHelper
+<
+    css::style::XStyle,
+    css::beans::XPropertySet
+>
+{
+    SwBoxAutoFormat& m_rBoxAutoFormat;
+public:
+    SwXTextCellStyle(SwBoxAutoFormat& rBoxAutoFormat);
+
+    //XStyle
+    virtual sal_Bool SAL_CALL isUserDefined() throw (css::uno::RuntimeException, std::exception) override;
+    virtual sal_Bool SAL_CALL isInUse() throw (css::uno::RuntimeException, std::exception) override;
+    virtual OUString SAL_CALL getParentStyle() throw (css::uno::RuntimeException, std::exception) override;
+    virtual void SAL_CALL setParentStyle(const OUString& aParentStyle ) throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception) override;
+
+    //XNamed
+    virtual OUString SAL_CALL getName() throw(css::uno::RuntimeException, std::exception) override;
+    virtual void SAL_CALL setName(const OUString& rName) throw(css::uno::RuntimeException, std::exception) override;
+
+    //XPropertySet
+    virtual css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(css::uno::RuntimeException, std::exception) override;
+    virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, const css::uno::Any& aValue) throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
+    virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
+    virtual void SAL_CALL addPropertyChangeListener(const OUString& aPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener>& xListener) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
+    virtual void SAL_CALL removePropertyChangeListener(const OUString& aPropertyName, const css::uno::Reference<css::beans::XPropertyChangeListener>& aListener) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
+    virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
+    virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName, const css::uno::Reference<css::beans::XVetoableChangeListener>& aListener) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
+
+};
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/python/check_styles.py b/sw/qa/python/check_styles.py
index 79972ef..31d8b5c 100644
--- a/sw/qa/python/check_styles.py
+++ b/sw/qa/python/check_styles.py
@@ -11,6 +11,7 @@ import math
 import unittest
 from org.libreoffice.unotest import UnoInProcess
 from com.sun.star.container import NoSuchElementException
+from com.sun.star.beans import UnknownPropertyException
 from com.sun.star.lang import IndexOutOfBoundsException
 from com.sun.star.lang import IllegalArgumentException
 
@@ -172,6 +173,14 @@ class CheckStyle(unittest.TestCase):
         self.__test_StyleFamilyIndex(xTableStyles, vEmptyDocStyles, "SwXTextTableStyle")
         for sStyleName in vEmptyDocStyles:
             self.assertIsNotNone(xTableStyles.getByName(sStyleName))
+        #check SwXTextCellStyles
+        vCellStyles = ["first-row", "last-row", "first-column", "last-column", "body", "even-rows", "odd-rows", "even-columns", "odd-columns", "background"]
+        xDefaultTableStyle = xTableStyles.getByIndex(0)
+        for sCellStyle in vCellStyles:
+            xCellStyle = xDefaultTableStyle.getByName(sCellStyle)
+            self.assertIsNotNone(xCellStyle.getPropertyValue("BackColor"))
+            with self.assertRaises(UnknownPropertyException):
+                xCellStyle.getPropertyValue("foobarbaz")
         xDoc.dispose()
 
 if __name__ == '__main__':
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index ebad1b0..229e9c95 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -690,6 +690,21 @@ const SwBoxAutoFormat& SwTableAutoFormat::GetBoxFormat( sal_uInt8 nPos ) const
     }
 }
 
+SwBoxAutoFormat& SwTableAutoFormat::GetBoxFormat( sal_uInt8 nPos )
+{
+    SAL_WARN_IF(!(nPos < 16), "sw.core", "GetBoxFormat wrong area");
+
+    SwBoxAutoFormat* pFormat = aBoxAutoFormat[ nPos ];
+    if( !pFormat )
+    {
+        // If default doesn't exist yet:
+        if( !pDfltBoxAutoFormat )
+            pDfltBoxAutoFormat = new SwBoxAutoFormat();
+        *pFormat = *pDfltBoxAutoFormat;
+    }
+    return *pFormat;
+}
+
 void SwTableAutoFormat::UpdateFromSet( sal_uInt8 nPos,
                                     const SfxItemSet& rSet,
                                     UpdateFlags eFlags,
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 4a6adb3..50a4ec6 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -454,7 +454,8 @@ const ProvNamesId_Type aProvNamesId[] =
     { CSS_TEXT_FIELDMASTER_DDE,                       SW_SERVICE_FIELDMASTER_DDE },
     { CSS_TEXT_FIELDMASTER_SET_EXPRESSION,            SW_SERVICE_FIELDMASTER_SET_EXP },
     { CSS_TEXT_FIELDMASTER_DATABASE,                  SW_SERVICE_FIELDMASTER_DATABASE },
-    { CSS_TEXT_FIELDMASTER_BIBLIOGRAPHY,              SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY }
+    { CSS_TEXT_FIELDMASTER_BIBLIOGRAPHY,              SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY },
+    { "com.sun.star.style.TableStyle",                SW_SERVICE_STYLE_TABLE_STYLE }
 };
 
 const SvEventDescription* sw_GetSupportedMacroItems()
@@ -669,6 +670,7 @@ SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc & rDoc)
         case SW_SERVICE_STYLE_FRAME_STYLE:
         case SW_SERVICE_STYLE_PAGE_STYLE:
         case SW_SERVICE_STYLE_NUMBERING_STYLE:
+        case SW_SERVICE_STYLE_TABLE_STYLE:
         {
             SfxStyleFamily eFamily = SfxStyleFamily::Char;
             switch(nObjectType)
@@ -689,6 +691,9 @@ SwXServiceProvider::MakeInstance(sal_uInt16 nObjectType, SwDoc & rDoc)
                 case SW_SERVICE_STYLE_NUMBERING_STYLE:
                     eFamily = SfxStyleFamily::Pseudo;
                 break;
+                case SW_SERVICE_STYLE_TABLE_STYLE:
+                    eFamily = SfxStyleFamily::Table;
+                break;
             }
             if(!xRet.is())
                 xRet = SwXStyleFamilies::CreateStyle(eFamily, rDoc);
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 669c535..e120b7f 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -1497,6 +1497,16 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                 m_aMapEntriesArr[nPropertyId] = aTableStyleMap;
             }
             break;
+            case PROPERTY_MAP_CELL_STYLE:
+            {
+                static SfxItemPropertyMapEntry const aCellStyleMap[] =
+                {
+                    { OUString(UNO_NAME_BACK_COLOR), RES_BACKGROUND, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE , 0 },
+                    { OUString(), 0, css::uno::Type(), 0, 0 }
+                };
+                m_aMapEntriesArr[nPropertyId] = aCellStyleMap;
+            }
+            break;
 
             default:
                 OSL_FAIL( "unexpected property map ID" );
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index bdf5820..069a15f 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -1647,6 +1647,12 @@ const SfxItemPropertySet*  SwUnoPropertyMapProvider::GetPropertySet( sal_uInt16
                 m_aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TABLE_STYLE;
             }
             break;
+            case PROPERTY_MAP_CELL_STYLE:
+            {
+                static SfxItemPropertySet aPROPERTY_MAP_CELL_STYLE(pEntries);
+                m_aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_CELL_STYLE;
+            }
+            break;
         }
     }
     return m_aPropertySetArr[nPropertyId];
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index ae6d428..5a11ce5 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -4238,15 +4238,31 @@ uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() throw (uno::
     return aRet;
 }
 
-SwXTextTableStyle::SwXTextTableStyle(SwDocShell* pDocShell, const OUString& rTableAutoFormatName)
+SwXTextTableStyle::SwXTextTableStyle(SwDocShell* pDocShell, const OUString& rTableAutoFormatName) :
+    m_pDocShell(pDocShell), m_sTableAutoFormatName(rTableAutoFormatName)
 {
-    m_pDocShell = pDocShell;
-    m_sTableAutoFormatName = rTableAutoFormatName;
+    SwTableAutoFormat *pAutoFormat = GetTableAutoFormat();
+
+    if (pAutoFormat)
+    {
+        // TODO fix styles mapping
+        m_aCellStyles[ FIRST_ROW_STYLE    ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 0 ));  // 0
+        m_aCellStyles[ LAST_ROW_STYLE     ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 12 )); // 1
+        m_aCellStyles[ FIRST_COLUMN_STYLE ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 4 ));  // 2
+        m_aCellStyles[ LAST_COLUMN_STYLE  ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 7 ));  // 3
+        m_aCellStyles[ EVEN_ROWS_STYLE    ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 13 )); // 4
+        m_aCellStyles[ ODD_ROWS_STYLE     ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 13 )); // 5
+        m_aCellStyles[ EVEN_COLUMNS_STYLE ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 13 )); // 6
+        m_aCellStyles[ ODD_COLUMNS_STYLE  ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 13 )); // 7
+        m_aCellStyles[ BODY_STYLE         ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 13 )); // 8
+        m_aCellStyles[ BACKGROUND_STYLE   ] = new SwXTextCellStyle(pAutoFormat->GetBoxFormat( 13 )); // 9
+    }
 }
 
-uno::Reference<css::style::XStyle> SwXTextTableStyle::CreateXTextTableStyle(SwDocShell* pDocShell, const OUString& rTableAutoFormatName)
+uno::Reference<style::XStyle> SwXTextTableStyle::CreateXTextTableStyle(SwDocShell* pDocShell, const OUString& rTableAutoFormatName)
 {
-    uno::Reference<css::style::XStyle> xTextTableStyle;
+    SolarMutexGuard aGuard;
+    uno::Reference<style::XStyle> xTextTableStyle;
     const size_t nStyles = pDocShell->GetDoc()->GetTableStyles().size();
     for(size_t i=0; i < nStyles; ++i)
     {
@@ -4286,33 +4302,55 @@ SwTableAutoFormat* SwXTextTableStyle::GetTableAutoFormat()
     return nullptr;
 }
 
+const CellStyleNameMap& SwXTextTableStyle::GetCellStyleNameMap()
+{
+    static CellStyleNameMap aMap;
+    if(aMap.empty())
+    {
+        CellStyleNameMap aNewMap;
+        aNewMap[ "first-row"    ] = FIRST_ROW_STYLE;
+        aNewMap[ "last-row"     ] = LAST_ROW_STYLE;
+        aNewMap[ "first-column" ] = FIRST_COLUMN_STYLE;
+        aNewMap[ "last-column"  ] = LAST_COLUMN_STYLE;
+        aNewMap[ "body"         ] = BODY_STYLE;
+        aNewMap[ "even-rows"    ] = EVEN_ROWS_STYLE;
+        aNewMap[ "odd-rows"     ] = ODD_ROWS_STYLE;
+        aNewMap[ "even-columns" ] = EVEN_COLUMNS_STYLE;
+        aNewMap[ "odd-columns"  ] = ODD_COLUMNS_STYLE;
+        aNewMap[ "background"   ] = BACKGROUND_STYLE;
+        aMap.swap(aNewMap);
+    }
+    return aMap;
+}
+
 // XStyle
-sal_Bool SAL_CALL SwXTextTableStyle::isUserDefined() throw (css::uno::RuntimeException, std::exception)
+sal_Bool SAL_CALL SwXTextTableStyle::isUserDefined() throw (uno::RuntimeException, std::exception)
 {
     return false;
 }
 
-sal_Bool SAL_CALL SwXTextTableStyle::isInUse() throw (css::uno::RuntimeException, std::exception)
+sal_Bool SAL_CALL SwXTextTableStyle::isInUse() throw (uno::RuntimeException, std::exception)
 {
     return false;
 }
 
-OUString SAL_CALL SwXTextTableStyle::getParentStyle() throw (css::uno::RuntimeException, std::exception)
+OUString SAL_CALL SwXTextTableStyle::getParentStyle() throw (uno::RuntimeException, std::exception)
 {
     return OUString();
 }
 
-void SAL_CALL SwXTextTableStyle::setParentStyle( const OUString& /*aParentStyle*/ ) throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
+void SAL_CALL SwXTextTableStyle::setParentStyle(const OUString& /*aParentStyle*/) throw (container::NoSuchElementException, uno::RuntimeException, std::exception)
 { }
 
 //XNamed
-OUString SAL_CALL SwXTextTableStyle::getName() throw(css::uno::RuntimeException, std::exception)
+OUString SAL_CALL SwXTextTableStyle::getName() throw(uno::RuntimeException, std::exception)
 {
     return m_sTableAutoFormatName;
 }
 
-void SAL_CALL SwXTextTableStyle::setName(const OUString& rName) throw(css::uno::RuntimeException, std::exception)
+void SAL_CALL SwXTextTableStyle::setName(const OUString& rName) throw(uno::RuntimeException, std::exception)
 {
+    SolarMutexGuard aGuard;
     const size_t nStyles = m_pDocShell->GetDoc()->GetTableStyles().size();
     for(size_t i=0; i < nStyles; ++i)
     {
@@ -4331,6 +4369,43 @@ void SAL_CALL SwXTextTableStyle::setName(const OUString& rName) throw(css::uno::
     m_sTableAutoFormatName = rName;
 }
 
+//XNameAccess
+uno::Any SAL_CALL SwXTextTableStyle::getByName(const OUString& rName) throw(container::NoSuchElementException, lang::WrappedTargetException, css::uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    const CellStyleNameMap& rMap = GetCellStyleNameMap();
+    CellStyleNameMap::const_iterator iter = rMap.find(rName);
+    if(iter == rMap.end())
+        throw css::container::NoSuchElementException();
+
+    return css::uno::Any(m_aCellStyles[(*iter).second]);
+}
+
+css::uno::Sequence<OUString> SAL_CALL SwXTextTableStyle::getElementNames() throw(css::uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    return comphelper::mapKeysToSequence(GetCellStyleNameMap());
+}
+
+sal_Bool SAL_CALL SwXTextTableStyle::hasByName(const OUString& rName) throw(css::uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    const CellStyleNameMap& rMap = GetCellStyleNameMap();
+    CellStyleNameMap::const_iterator iter = rMap.find(rName);
+    return iter != rMap.end();
+}
+
+//XElementAccess
+uno::Type SAL_CALL SAL_CALL SwXTextTableStyle::getElementType() throw(uno::RuntimeException, std::exception)
+{
+    return cppu::UnoType<style::XStyle>::get();
+}
+
+sal_Bool SAL_CALL SAL_CALL SwXTextTableStyle::hasElements() throw(uno::RuntimeException, std::exception)
+{
+    return true;
+}
+
 //XServiceInfo
 OUString SAL_CALL SwXTextTableStyle::getImplementationName() throw(css::uno::RuntimeException, std::exception)
 {
@@ -4346,4 +4421,113 @@ css::uno::Sequence<OUString> SAL_CALL SwXTextTableStyle::getSupportedServiceName
 {
     return {"com.sun.star.style.Style"};
 }
+
+// SwXTextCellStyle
+SwXTextCellStyle::SwXTextCellStyle(SwBoxAutoFormat& rBoxAutoFormat) :
+    m_rBoxAutoFormat(rBoxAutoFormat)
+{ }
+
+// XStyle
+sal_Bool SAL_CALL SwXTextCellStyle::isUserDefined() throw (css::uno::RuntimeException, std::exception)
+{
+    return false;
+}
+
+sal_Bool SAL_CALL SwXTextCellStyle::isInUse() throw (css::uno::RuntimeException, std::exception)
+{
+    return false;
+}
+
+OUString SAL_CALL SwXTextCellStyle::getParentStyle() throw (css::uno::RuntimeException, std::exception)
+{
+    return OUString();
+}
+
+void SAL_CALL SwXTextCellStyle::setParentStyle( const OUString& /*aParentStyle*/ ) throw (css::container::NoSuchElementException, css::uno::RuntimeException, std::exception)
+{ }
+
+//XNamed
+OUString SAL_CALL SwXTextCellStyle::getName() throw(css::uno::RuntimeException, std::exception)
+{
+    return OUString();
+}
+
+void SAL_CALL SwXTextCellStyle::setName(const OUString& /*rName*/) throw(css::uno::RuntimeException, std::exception)
+{ }
+
+//XPropertySet
+css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL SwXTextCellStyle::getPropertySetInfo() throw(css::uno::RuntimeException, std::exception)
+{
+    static uno::Reference<beans::XPropertySetInfo> xRef(aSwMapProvider.GetPropertySet(PROPERTY_MAP_CELL_STYLE)->getPropertySetInfo());
+    return xRef;
+}
+
+void SAL_CALL SwXTextCellStyle::setPropertyValue(const OUString& rPropertyName, const css::uno::Any& aValue) throw(css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    const SfxItemPropertySimpleEntry *const pEntry = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CELL_STYLE)->getPropertyMap().getByName(rPropertyName);
+    if(pEntry)
+    {
+        switch(pEntry->nWID)
+        {
+            case RES_BACKGROUND:
+            {
+                SvxBrushItem rBrush( m_rBoxAutoFormat.GetBackground() );
+                rBrush.PutValue(aValue, 0);
+                m_rBoxAutoFormat.SetBackground(rBrush);
+                return;
+            }
+            default:
+                SAL_WARN("sw.uno", "SwXTextCellStyle unknown nWID");
+                throw css::uno::RuntimeException();
+        }
+    }
+
+    throw css::beans::UnknownPropertyException();
+}
+
+css::uno::Any SAL_CALL SwXTextCellStyle::getPropertyValue(const OUString& rPropertyName) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aGuard;
+    uno::Any aRet;
+    const SfxItemPropertySimpleEntry *const pEntry = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CELL_STYLE)->getPropertyMap().getByName(rPropertyName);
+    if(pEntry)
+    {
+        switch(pEntry->nWID)
+        {
+            case RES_BACKGROUND:
+            {
+                const SvxBrushItem& rBrush = m_rBoxAutoFormat.GetBackground();
+                rBrush.QueryValue(aRet);
+                return aRet;
+            }
+            default:
+                SAL_WARN("sw.uno", "SwXTextCellStyle unknown nWID");
+                throw css::uno::RuntimeException();
+        }
+    }
+
+    throw css::beans::UnknownPropertyException();
+}
+
+void SAL_CALL SwXTextCellStyle::addPropertyChangeListener( const OUString& /*aPropertyName*/, const css::uno::Reference< css::beans::XPropertyChangeListener >& /*xListener*/ ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception)
+{
+    SAL_WARN("sw.uno", "not implemented");
+}
+
+void SAL_CALL SwXTextCellStyle::removePropertyChangeListener( const OUString& /*aPropertyName*/, const css::uno::Reference< css::beans::XPropertyChangeListener >& /*aListener*/ ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception)
+{
+    SAL_WARN("sw.uno", "not implemented");
+}
+
+void SAL_CALL SwXTextCellStyle::addVetoableChangeListener( const OUString& /*PropertyName*/, const css::uno::Reference< css::beans::XVetoableChangeListener >& /*aListener*/ ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception)
+{
+    SAL_WARN("sw.uno", "not implemented");
+}
+
+void SAL_CALL SwXTextCellStyle::removeVetoableChangeListener( const OUString& /*PropertyName*/, const css::uno::Reference< css::beans::XVetoableChangeListener >& /*aListener*/ ) throw(css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception)
+{
+    SAL_WARN("sw.uno", "not implemented");
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list