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>
34static uno::Sequence< style::TabStop >
lcl_getTabStops(
const uno::Reference< beans::XPropertySet >& xParaProps )
36 uno::Sequence< style::TabStop >
aSeq;
37 xParaProps->getPropertyValue(
"ParaTabStops") >>=
aSeq;
42static void lcl_setTabStops(
const uno::Reference< beans::XPropertySet >& xParaProps,
const uno::Sequence< style::TabStop >& aSeq )
44 xParaProps->setPropertyValue(
"ParaTabStops",
uno::Any(
aSeq ) );
51 uno::Reference< container::XIndexAccess > mxIndexAccess;
55 explicit TabStopsEnumWrapper( uno::Reference< container::XIndexAccess > xIndexAccess ) : mxIndexAccess(
std::move( xIndexAccess )), m_nIndex( 0 )
58 virtual sal_Bool SAL_CALL hasMoreElements( )
override
60 return ( m_nIndex < mxIndexAccess->getCount() );
63 virtual uno::Any SAL_CALL nextElement( )
override
65 if( m_nIndex < mxIndexAccess->getCount() )
67 return mxIndexAccess->getByIndex( m_nIndex++ );
69 throw container::NoSuchElementException();
73class TabStopCollectionHelper :
public ::cppu::WeakImplHelper< container::XIndexAccess,
74 container::XEnumerationAccess >
77 uno::Reference< XHelperInterface >
mxParent;
78 uno::Reference< uno::XComponentContext >
mxContext;
83 TabStopCollectionHelper( css::uno::Reference< ov::XHelperInterface > xParent, css::uno::Reference< css::uno::XComponentContext > xContext,
const css::uno::Reference< css::beans::XPropertySet >& xParaProps ):
mxParent(
std::move( xParent )),
mxContext(
std::move( xContext )), mnTabStops(
lcl_getTabStops( xParaProps ).
getLength())
87 virtual sal_Int32 SAL_CALL getCount( )
override
91 virtual uno::Any SAL_CALL getByIndex( sal_Int32
Index )
override
94 throw css::lang::IndexOutOfBoundsException();
98 virtual uno::Type SAL_CALL getElementType( )
override
102 virtual sal_Bool SAL_CALL hasElements( )
override
107 virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( )
override
109 return new TabStopsEnumWrapper(
this );
115SwVbaTabStops::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 )
121 sal_Int32 nPosition = Millimeter::getInHundredthsOfOneMillimeter(
Position );
123 style::TabAlign nAlign = style::TabAlign_LEFT;
126 sal_Int32 wdAlign = word::WdTabAlignment::wdAlignTabLeft;
127 Alignment >>= wdAlign;
130 case word::WdTabAlignment::wdAlignTabLeft:
132 nAlign = style::TabAlign_LEFT;
135 case word::WdTabAlignment::wdAlignTabRight:
137 nAlign = style::TabAlign_RIGHT;
140 case word::WdTabAlignment::wdAlignTabCenter:
142 nAlign = style::TabAlign_CENTER;
145 case word::WdTabAlignment::wdAlignTabDecimal:
147 nAlign = style::TabAlign_DECIMAL;
150 case word::WdTabAlignment::wdAlignTabBar:
151 case word::WdTabAlignment::wdAlignTabList:
166 sal_Int32 wdLeader = word::WdTabLeader::wdTabLeaderSpaces;
170 case word::WdTabLeader::wdTabLeaderSpaces:
175 case word::WdTabLeader::wdTabLeaderMiddleDot:
180 case word::WdTabLeader::wdTabLeaderDots:
185 case word::WdTabLeader::wdTabLeaderDashes:
186 case word::WdTabLeader::wdTabLeaderHeavy:
187 case word::WdTabLeader::wdTabLeaderLines:
200 aTab.Position = nPosition;
201 aTab.Alignment = nAlign;
202 aTab.DecimalChar =
'.';
203 aTab.FillChar = cLeader;
206 auto [
begin,
end] = asNonConstRange(aOldTabs);
208 style::TabStop* pOldTab = std::find_if(
begin,
end,
209 [nPosition](
const style::TabStop& rTab) {
return rTab.Position == nPosition; });
210 bool bOverWriter = pOldTab !=
end;
218 sal_Int32 nTabs = aOldTabs.getLength();
219 uno::Sequence< style::TabStop > aNewTabs( nTabs + 1 );
221 auto it = aNewTabs.getArray();
223 std::copy(
begin,
end, std::next(it));
232 uno::Sequence< style::TabStop >
aSeq;
242uno::Reference< container::XEnumeration >
257 return "SwVbaTabStops";
260css::uno::Sequence<OUString>
263 static uno::Sequence< OUString >
const sNames
265 "ooo.vba.word.TabStops"
unotools::WeakReference< AnimationNode > mxParent
css::uno::Reference< css::uno::XComponentContext > mxContext
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
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< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL ClearAll() override
virtual css::uno::Sequence< OUString > getServiceNames() override
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::Reference< css::beans::XPropertySet > mxParaProps
css::uno::Type const & get()
Sequence< sal_Int8 > aSeq
double getLength(const B2DPolygon &rCandidate)
enumrange< T >::Iterator begin(enumrange< T >)
#define ERRCODE_BASIC_NOT_IMPLEMENTED
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE
static void lcl_setTabStops(const uno::Reference< beans::XPropertySet > &xParaProps, const uno::Sequence< style::TabStop > &aSeq)
static uno::Sequence< style::TabStop > lcl_getTabStops(const uno::Reference< beans::XPropertySet > &xParaProps)