21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/style/TabAlign.hpp>
23 #include <com/sun/star/style/TabStop.hpp>
24 #include <ooo/vba/word/WdTabLeader.hpp>
25 #include <ooo/vba/word/WdTabAlignment.hpp>
33 static uno::Sequence< style::TabStop >
lcl_getTabStops(
const uno::Reference< beans::XPropertySet >& xParaProps )
35 uno::Sequence< style::TabStop >
aSeq;
36 xParaProps->getPropertyValue(
"ParaTabStops") >>= aSeq;
41 static void lcl_setTabStops(
const uno::Reference< beans::XPropertySet >& xParaProps,
const uno::Sequence< style::TabStop >& aSeq )
43 xParaProps->setPropertyValue(
"ParaTabStops", uno::makeAny( aSeq ) );
50 uno::Reference< container::XIndexAccess > mxIndexAccess;
54 explicit TabStopsEnumWrapper(
const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxIndexAccess( xIndexAccess ), nIndex( 0 )
57 virtual sal_Bool SAL_CALL hasMoreElements( )
override
59 return ( nIndex < mxIndexAccess->getCount() );
62 virtual uno::Any SAL_CALL nextElement( )
override
64 if( nIndex < mxIndexAccess->getCount() )
66 return mxIndexAccess->getByIndex( nIndex++ );
68 throw container::NoSuchElementException();
72 class TabStopCollectionHelper :
public ::cppu::WeakImplHelper< container::XIndexAccess,
73 container::XEnumerationAccess >
76 uno::Reference< XHelperInterface >
mxParent;
77 uno::Reference< uno::XComponentContext >
mxContext;
82 TabStopCollectionHelper(
const css::uno::Reference< ov::XHelperInterface >& xParent,
const css::uno::Reference< css::uno::XComponentContext > & xContext,
const css::uno::Reference< css::beans::XPropertySet >& xParaProps ): mxParent( xParent ), mxContext( xContext ), mnTabStops(
lcl_getTabStops( xParaProps ).
getLength())
86 virtual sal_Int32 SAL_CALL getCount( )
override
90 virtual uno::Any SAL_CALL getByIndex( sal_Int32
Index )
override
93 throw css::lang::IndexOutOfBoundsException();
95 return uno::makeAny( uno::Reference< word::XTabStop >(
new SwVbaTabStop( mxParent, mxContext ) ) );
97 virtual uno::Type SAL_CALL getElementType( )
override
101 virtual sal_Bool SAL_CALL hasElements( )
override
106 virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( )
override
108 return new TabStopsEnumWrapper(
this );
114 SwVbaTabStops::SwVbaTabStops(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext,
const uno::Reference< beans::XPropertySet >& xParaProps ) :
SwVbaTabStops_BASE( xParent, xContext,
uno::
Reference< container::XIndexAccess >( new TabStopCollectionHelper( xParent, xContext, xParaProps ) ) ), mxParaProps( xParaProps )
120 sal_Int32 nPosition = Millimeter::getInHundredthsOfOneMillimeter( Position );
122 style::TabAlign nAlign = style::TabAlign_LEFT;
125 sal_Int32 wdAlign = word::WdTabAlignment::wdAlignTabLeft;
126 Alignment >>= wdAlign;
129 case word::WdTabAlignment::wdAlignTabLeft:
131 nAlign = style::TabAlign_LEFT;
134 case word::WdTabAlignment::wdAlignTabRight:
136 nAlign = style::TabAlign_RIGHT;
139 case word::WdTabAlignment::wdAlignTabCenter:
141 nAlign = style::TabAlign_CENTER;
144 case word::WdTabAlignment::wdAlignTabDecimal:
146 nAlign = style::TabAlign_DECIMAL;
149 case word::WdTabAlignment::wdAlignTabBar:
150 case word::WdTabAlignment::wdAlignTabList:
165 sal_Int32 wdLeader = word::WdTabLeader::wdTabLeaderSpaces;
169 case word::WdTabLeader::wdTabLeaderSpaces:
174 case word::WdTabLeader::wdTabLeaderMiddleDot:
179 case word::WdTabLeader::wdTabLeaderDots:
184 case word::WdTabLeader::wdTabLeaderDashes:
185 case word::WdTabLeader::wdTabLeaderHeavy:
186 case word::WdTabLeader::wdTabLeaderLines:
199 aTab.Position = nPosition;
200 aTab.Alignment = nAlign;
201 aTab.DecimalChar =
'.';
202 aTab.FillChar = cLeader;
206 style::TabStop* pOldTab = std::find_if(aOldTabs.begin(), aOldTabs.end(),
207 [nPosition](
const style::TabStop& rTab) {
return rTab.Position == nPosition; });
208 bool bOverWriter = pOldTab != aOldTabs.end();
216 sal_Int32 nTabs = aOldTabs.getLength();
217 uno::Sequence< style::TabStop > aNewTabs( nTabs + 1 );
220 std::copy(aOldTabs.begin(), aOldTabs.end(), std::next(aNewTabs.begin()));
224 return uno::Reference< word::XTabStop >(
new SwVbaTabStop(
this, mxContext ) );
229 uno::Sequence< style::TabStop >
aSeq;
239 uno::Reference< container::XEnumeration >
254 return "SwVbaTabStops";
257 css::uno::Sequence<OUString>
260 static uno::Sequence< OUString >
const sNames
262 "ooo.vba.word.TabStops"
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
WeakReference< XInterface > mxParent
#define ERRCODE_BASIC_NOT_IMPLEMENTED
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual css::uno::Type SAL_CALL getElementType() override
SwVbaTabStops(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::beans::XPropertySet > &xParaProps)
virtual css::uno::Reference< ::ooo::vba::word::XTabStop > SAL_CALL Add(float Position, const css::uno::Any &Alignment, const css::uno::Any &Leader) override
virtual OUString getServiceImplName() override
css::uno::Type const & get()
Sequence< sal_Int8 > aSeq
double getLength(const B2DPolygon &rCandidate)
css::uno::Reference< css::beans::XPropertySet > mxParaProps
static void lcl_setTabStops(const uno::Reference< beans::XPropertySet > &xParaProps, const uno::Sequence< style::TabStop > &aSeq)
virtual void SAL_CALL ClearAll() override
Reference< XComponentContext > mxContext
static uno::Sequence< style::TabStop > lcl_getTabStops(const uno::Reference< beans::XPropertySet > &xParaProps)