diff options
author | Michael Meeks <michael.meeks@suse.com> | 2013-03-21 21:44:14 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-03-22 16:40:15 +0000 |
commit | 1d0c1d4b8298c52b226e5c39b4dd98f9ec38a222 (patch) | |
tree | 6e8fa988c31d675b7aee30348cef61d1a94f7f2e /sw | |
parent | 7e9010735b62397c7eae87444aca3677a79f1223 (diff) |
implement part of XMultiPropertySet on SwXTextCursor.
Change-Id: I903f049a3bdba96a8e1ac613ca8b9443a062fe8f
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unotextcursor.hxx | 21 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 62 | ||||
-rw-r--r-- | sw/source/core/unocore/unoparagraph.cxx | 3 |
3 files changed, 84 insertions, 2 deletions
diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx index 485a4df58ee9..d0b0dde75dd9 100644 --- a/sw/inc/unotextcursor.hxx +++ b/sw/inc/unotextcursor.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XMultiPropertyStates.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> @@ -34,7 +35,7 @@ #include <com/sun/star/text/XParagraphCursor.hpp> #include <com/sun/star/text/XRedline.hpp> -#include <cppuhelper/implbase12.hxx> +#include <cppuhelper/implbase13.hxx> #include <comphelper/uno3.hxx> @@ -47,10 +48,11 @@ struct SwPosition; class SwUnoCrsr; -typedef ::cppu::WeakImplHelper12 +typedef ::cppu::WeakImplHelper13 < ::com::sun::star::lang::XServiceInfo , ::com::sun::star::beans::XPropertySet , ::com::sun::star::beans::XPropertyState +, ::com::sun::star::beans::XMultiPropertySet , ::com::sun::star::beans::XMultiPropertyStates , ::com::sun::star::container::XEnumerationAccess , ::com::sun::star::container::XContentEnumerationAccess @@ -191,6 +193,21 @@ public: ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL + getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ); + virtual void SAL_CALL addPropertiesChangeListener( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, + const ::com::sun::star::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ); + virtual void SAL_CALL removePropertiesChangeListener( + const ::com::sun::star::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ); + virtual void SAL_CALL firePropertiesChangeEvent( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, + const ::com::sun::star::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ); + // XMultiPropertyStates virtual void SAL_CALL setAllPropertiesToDefault() throw (::com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 75b7f0b7c206..91b30f5cc629 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -2332,6 +2332,68 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, return getPropertyDefaults ( aSequence ).getConstArray()[0]; } +void SAL_CALL SwXTextCursor::setPropertyValues( + const uno::Sequence< ::rtl::OUString >& aPropertyNames, + const uno::Sequence< uno::Any >& aValues ) +{ + if( aValues.getLength() != aPropertyNames.getLength() ) + { + OSL_FAIL( "mis-matched property value sequences" ); + throw lang::IllegalArgumentException(); + } + + SolarMutexGuard aGuard; + + SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() ); + + // a little lame to have to copy into this. + uno::Sequence< beans::PropertyValue > aPropertyValues( aValues.getLength() ); + for ( sal_Int32 i = 0; i < aPropertyNames.getLength(); i++ ) + { + if ( aPropertyNames[ i ].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_HIDDEN_TEXT)) || + aPropertyNames[ i ].equalsAsciiL( + SW_PROP_NAME(UNO_NAME_IS_SKIP_PROTECTED_TEXT)) ) + { + // the behaviour of these is hard to model in a group + OSL_ASSERT("invalid property name for batch setting"); + throw lang::IllegalArgumentException(); + } + aPropertyValues[ i ].Name = aPropertyNames[ i ]; + aPropertyValues[ i ].Value = aValues[ i ]; + } + SwUnoCursorHelper::SetPropertyValues( rUnoCursor, m_pImpl->m_rPropSet, aPropertyValues ); +} + +uno::Sequence< uno::Any > SAL_CALL +SwXTextCursor::getPropertyValues( const uno::Sequence< ::rtl::OUString >& aPropertyNames ) +{ + // a banal implementation for now + uno::Sequence< uno::Any > aValues( aPropertyNames.getLength() ); + for (sal_Int32 i = 0; i < aPropertyNames.getLength(); i++) + aValues[i] = getPropertyValue( aPropertyNames[ i ] ); + return aValues; +} + +void SAL_CALL SwXTextCursor::addPropertiesChangeListener( + const uno::Sequence< ::rtl::OUString >& /* aPropertyNames */, + const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ ) +{ + OSL_FAIL("SwXTextCursor::addPropertiesChangeListener(): not implemented"); +} +void SAL_CALL SwXTextCursor::removePropertiesChangeListener( + const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ ) +{ + OSL_FAIL("SwXTextCursor::removePropertiesChangeListener(): not implemented"); +} + +void SAL_CALL SwXTextCursor::firePropertiesChangeEvent( + const uno::Sequence< ::rtl::OUString >& /* aPropertyNames */, + const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ ) +{ + OSL_FAIL("SwXTextCursor::firePropertiesChangeEvent(): not implemented"); +} + // para specific attribut ranges static sal_uInt16 g_ParaResetableSetRange[] = { RES_FRMATR_BEGIN, RES_FRMATR_END-1, diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 550b7b7d8959..5382e1b58a80 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -390,6 +390,9 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException, const uno::Any* pValues = rValues.getConstArray(); const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap(); SwParaSelection aParaSel( aCursor ); + + // FIXME: this should be replaced with the significantly faster + // SwUnoCursorHelper::SetPropertyValues... for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++) { SfxItemPropertySimpleEntry const*const pEntry = |