22#include <com/sun/star/beans/XPropertySetInfo.hpp>
23#include <com/sun/star/awt/TextAlign.hpp>
24#include <com/sun/star/style/ParagraphAdjust.hpp>
25#include <osl/diagnose.h>
42 OUString getParaAlignProperty()
47 OUString getAlignProperty()
52 sal_Int32 findStringElement(
const Sequence< OUString >& _rNames,
const OUString& _rName )
54 const OUString* pPos = ::std::find( _rNames.begin(), _rNames.end(), _rName );
55 if ( pPos != _rNames.end() )
56 return pPos - _rNames.begin();
60 struct AlignmentTranslationEntry
65 const AlignmentTranslations[] =
70 { ParagraphAdjust_LEFT, awt::TextAlign::LEFT },
71 { ParagraphAdjust_CENTER, awt::TextAlign::CENTER },
72 { ParagraphAdjust_RIGHT, awt::TextAlign::RIGHT },
73 { ParagraphAdjust_BLOCK, awt::TextAlign::RIGHT },
74 { ParagraphAdjust_STRETCH, awt::TextAlign::LEFT },
75 { ParagraphAdjust::ParagraphAdjust_MAKE_FIXED_SIZE, awt::TextAlign::LEFT },
76 { ParagraphAdjust::ParagraphAdjust_MAKE_FIXED_SIZE, -1 }
79 void valueAlignToParaAdjust(Any& rValue)
83 const AlignmentTranslationEntry* pTranslation = AlignmentTranslations;
84 while (-1 != pTranslation->nControlValue)
86 if ( nValue == pTranslation->nControlValue )
88 rValue <<= pTranslation->nParagraphValue;
93 OSL_FAIL(
"valueAlignToParaAdjust: unreachable!" );
96 void valueParaAdjustToAlign(Any& rValue)
100 const AlignmentTranslationEntry* pTranslation = AlignmentTranslations;
101 while ( ParagraphAdjust::ParagraphAdjust_MAKE_FIXED_SIZE != pTranslation->nParagraphValue)
103 if (
static_cast<ParagraphAdjust
>(nValue) == pTranslation->nParagraphValue)
105 rValue <<= pTranslation->nControlValue;
110 OSL_FAIL(
"valueParaAdjustToAlign: unreachable!" );
115 > OMergedPropertySetInfo_Base;
116 class OMergedPropertySetInfo :
public OMergedPropertySetInfo_Base
122 explicit OMergedPropertySetInfo(
const Reference< XPropertySetInfo >& _rxMasterInfo );
125 virtual ~OMergedPropertySetInfo()
override;
128 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties( )
override;
129 virtual css::beans::Property SAL_CALL getPropertyByName(
const OUString& aName )
override;
130 virtual sal_Bool SAL_CALL hasPropertyByName(
const OUString& Name )
override;
133 OMergedPropertySetInfo::OMergedPropertySetInfo(
const Reference< XPropertySetInfo >& _rxMasterInfo )
136 OSL_ENSURE(
m_xMasterInfo.is(),
"OMergedPropertySetInfo::OMergedPropertySetInfo: hmm?" );
139 OMergedPropertySetInfo::~OMergedPropertySetInfo()
143 Sequence< Property > SAL_CALL OMergedPropertySetInfo::getProperties( )
152 aProperties.getArray()[ nOldLength ] = getPropertyByName( getParaAlignProperty() );
157 Property SAL_CALL OMergedPropertySetInfo::getPropertyByName(
const OUString& aName )
159 if ( aName == getParaAlignProperty() )
160 return Property( getParaAlignProperty(), -1,
169 sal_Bool SAL_CALL OMergedPropertySetInfo::hasPropertyByName(
const OUString& Name )
171 if ( Name == getParaAlignProperty() )
182 OGridColumnPropertyTranslator::OGridColumnPropertyTranslator(
const Reference< XMultiPropertySet >& _rxGridColumn )
183 :m_xGridColumn( _rxGridColumn )
185 OSL_ENSURE(
m_xGridColumn.is(),
"OGridColumnPropertyTranslator: invalid grid column!" );
194 Reference< XPropertySetInfo > xColumnPropInfo;
197 return new OMergedPropertySetInfo( xColumnPropInfo );
206 throw UnknownPropertyException( _rPropertyName, *
this );
208 Sequence< OUString > aNames( &_rPropertyName, 1 );
209 Sequence< Any > aValues( &aValue, 1 );
215 Sequence< OUString > aNames( &PropertyName, 1 );
217 OSL_ENSURE( aValues.getLength() == 1,
"OGridColumnPropertyTranslator::getPropertyValue: nonsense!" );
218 if ( aValues.getLength() == 1 )
225 OSL_FAIL(
"OGridColumnPropertyTranslator::addPropertyChangeListener: not implemented - this should not be needed!" );
230 OSL_FAIL(
"OGridColumnPropertyTranslator::removePropertyChangeListener: not implemented - this should not be needed!" );
235 OSL_FAIL(
"OGridColumnPropertyTranslator::addVetoableChangeListener: not implemented - this should not be needed!" );
240 OSL_FAIL(
"OGridColumnPropertyTranslator::removeVetoableChangeListener: not implemented - this should not be needed!" );
251 Sequence< OUString > aTranslatedNames( aPropertyNames );
252 Sequence< Any > aTranslatedValues( aValues );
254 sal_Int32 nParaAlignPos = findStringElement( aTranslatedNames, getParaAlignProperty() );
255 if ( nParaAlignPos != -1 )
257 if (aTranslatedNames.getLength() != aTranslatedValues.getLength())
258 throw css::lang::IllegalArgumentException(
259 "lengths do not match", getXWeak(), -1);
260 aTranslatedNames.getArray()[ nParaAlignPos ] = getAlignProperty();
261 valueParaAdjustToAlign( aTranslatedValues.getArray()[ nParaAlignPos ] );
264 m_xGridColumn->setPropertyValues( aTranslatedNames, aTranslatedValues );
269 Sequence< Any > aValues( aPropertyNames.getLength() );
273 Sequence< OUString > aTranslatedNames( aPropertyNames );
274 sal_Int32 nAlignPos = findStringElement( aTranslatedNames, getParaAlignProperty() );
275 if ( nAlignPos != -1 )
276 aTranslatedNames.getArray()[ nAlignPos ] = getAlignProperty();
278 aValues =
m_xGridColumn->getPropertyValues( aPropertyNames );
279 if ( nAlignPos != -1 )
280 valueAlignToParaAdjust( aValues.getArray()[ nAlignPos ] );
287 OSL_FAIL(
"OGridColumnPropertyTranslator::addPropertiesChangeListener: not implemented - this should not be needed!" );
292 OSL_FAIL(
"OGridColumnPropertyTranslator::removePropertiesChangeListener: not implemented - this should not be needed!" );
297 OSL_FAIL(
"OGridColumnPropertyTranslator::firePropertiesChangeEvent: not implemented - this should not be needed!" );
PropertiesInfo aProperties
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
css::uno::Reference< css::beans::XMultiPropertySet > m_xGridColumn
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual ~OGridColumnPropertyTranslator() override
ParagraphAdjust nParagraphValue
Reference< XPropertySetInfo > m_xMasterInfo