20#include <ooo/vba/word/XBorder.hpp>
21#include <ooo/vba/word/WdBorderType.hpp>
22#include <ooo/vba/word/WdLineStyle.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
26#include <com/sun/star/table/TableBorder.hpp>
38const sal_Int16
supportedIndexTable[] = { word::WdBorderType::wdBorderBottom, word::WdBorderType::wdBorderDiagonalDown, word::WdBorderType::wdBorderDiagonalUp, word::WdBorderType::wdBorderHorizontal, word::WdBorderType::wdBorderLeft, word::WdBorderType::wdBorderRight, word::WdBorderType::wdBorderTop, word::WdBorderType::wdBorderVertical };
48 uno::Reference< beans::XPropertySet >
m_xProps;
50 void setBorderLine( table::BorderLine
const & rBorderLine )
52 table::TableBorder aTableBorder;
53 m_xProps->getPropertyValue(
"TableBorder" ) >>= aTableBorder;
57 case word::WdBorderType::wdBorderLeft:
58 aTableBorder.IsLeftLineValid =
true;
59 aTableBorder.LeftLine= rBorderLine;
61 case word::WdBorderType::wdBorderTop:
62 aTableBorder.IsTopLineValid =
true;
63 aTableBorder.TopLine = rBorderLine;
66 case word::WdBorderType::wdBorderBottom:
67 aTableBorder.IsBottomLineValid =
true;
68 aTableBorder.BottomLine = rBorderLine;
70 case word::WdBorderType::wdBorderRight:
71 aTableBorder.IsRightLineValid =
true;
72 aTableBorder.RightLine = rBorderLine;
74 case word::WdBorderType::wdBorderVertical:
75 aTableBorder.IsVerticalLineValid =
true;
76 aTableBorder.VerticalLine = rBorderLine;
78 case word::WdBorderType::wdBorderHorizontal:
79 aTableBorder.IsHorizontalLineValid =
true;
80 aTableBorder.HorizontalLine = rBorderLine;
82 case word::WdBorderType::wdBorderDiagonalDown:
83 case word::WdBorderType::wdBorderDiagonalUp:
93 bool getBorderLine( table::BorderLine& rBorderLine )
95 table::TableBorder aTableBorder;
96 m_xProps->getPropertyValue(
"TableBorder" ) >>= aTableBorder;
99 case word::WdBorderType::wdBorderLeft:
100 if ( aTableBorder.IsLeftLineValid )
101 rBorderLine = aTableBorder.LeftLine;
103 case word::WdBorderType::wdBorderTop:
104 if ( aTableBorder.IsTopLineValid )
105 rBorderLine = aTableBorder.TopLine;
107 case word::WdBorderType::wdBorderBottom:
108 if ( aTableBorder.IsBottomLineValid )
109 rBorderLine = aTableBorder.BottomLine;
111 case word::WdBorderType::wdBorderRight:
112 if ( aTableBorder.IsRightLineValid )
113 rBorderLine = aTableBorder.RightLine;
115 case word::WdBorderType::wdBorderVertical:
116 if ( aTableBorder.IsVerticalLineValid )
117 rBorderLine = aTableBorder.VerticalLine;
119 case word::WdBorderType::wdBorderHorizontal:
120 if ( aTableBorder.IsHorizontalLineValid )
121 rBorderLine = aTableBorder.HorizontalLine;
124 case word::WdBorderType::wdBorderDiagonalDown:
125 case word::WdBorderType::wdBorderDiagonalUp:
138 return "SwVbaBorder";
145 "ooo.vba.word.Border"
150 SwVbaBorder(
const uno::Reference< beans::XPropertySet > & xProps,
const uno::Reference< uno::XComponentContext >& xContext, sal_Int32 lineType ) :
SwVbaBorder_Base( uno::Reference< XHelperInterface >( xProps, uno::UNO_QUERY ), xContext ),
m_xProps( xProps ), m_LineType( lineType ) {}
152 uno::Any SAL_CALL getLineStyle()
override
154 sal_Int32 nLineStyle = word::WdLineStyle::wdLineStyleNone;
155 table::BorderLine aBorderLine;
156 if ( getBorderLine( aBorderLine ) )
158 if( aBorderLine.InnerLineWidth !=0 && aBorderLine.OuterLineWidth !=0 )
160 nLineStyle = word::WdLineStyle::wdLineStyleDouble;
162 else if( aBorderLine.InnerLineWidth !=0 || aBorderLine.OuterLineWidth !=0 )
164 nLineStyle = word::WdLineStyle::wdLineStyleSingle;
168 nLineStyle = word::WdLineStyle::wdLineStyleNone;
173 void SAL_CALL setLineStyle(
const uno::Any& _linestyle )
override
177 sal_Int32 nLineStyle = 0;
178 _linestyle >>= nLineStyle;
179 table::BorderLine aBorderLine;
180 if ( !getBorderLine( aBorderLine ) )
181 throw uno::RuntimeException(
"Method failed" );
183 switch ( nLineStyle )
185 case word::WdLineStyle::wdLineStyleNone:
187 aBorderLine.InnerLineWidth = 0;
188 aBorderLine.OuterLineWidth = 0;
191 case word::WdLineStyle::wdLineStyleDashDot:
192 case word::WdLineStyle::wdLineStyleDashDotDot:
193 case word::WdLineStyle::wdLineStyleDashDotStroked:
194 case word::WdLineStyle::wdLineStyleDashLargeGap:
195 case word::WdLineStyle::wdLineStyleDashSmallGap:
196 case word::WdLineStyle::wdLineStyleDot:
197 case word::WdLineStyle::wdLineStyleDouble:
198 case word::WdLineStyle::wdLineStyleDoubleWavy:
199 case word::WdLineStyle::wdLineStyleEmboss3D:
200 case word::WdLineStyle::wdLineStyleEngrave3D:
201 case word::WdLineStyle::wdLineStyleInset:
202 case word::WdLineStyle::wdLineStyleOutset:
203 case word::WdLineStyle::wdLineStyleSingle:
204 case word::WdLineStyle::wdLineStyleSingleWavy:
205 case word::WdLineStyle::wdLineStyleThickThinLargeGap:
206 case word::WdLineStyle::wdLineStyleThickThinMedGap:
207 case word::WdLineStyle::wdLineStyleThickThinSmallGap:
208 case word::WdLineStyle::wdLineStyleThinThickLargeGap:
209 case word::WdLineStyle::wdLineStyleThinThickMedGap:
210 case word::WdLineStyle::wdLineStyleThinThickSmallGap:
211 case word::WdLineStyle::wdLineStyleThinThickThinLargeGap:
212 case word::WdLineStyle::wdLineStyleThinThickThinMedGap:
213 case word::WdLineStyle::wdLineStyleThinThickThinSmallGap:
214 case word::WdLineStyle::wdLineStyleTriple:
216 aBorderLine.InnerLineWidth = 0;
221 throw uno::RuntimeException(
"Bad param" );
223 setBorderLine( aBorderLine );
231 uno::Reference< table::XCellRange > m_xRange;
232 uno::Reference< uno::XComponentContext >
m_xContext;
234 sal_Int32 getTableIndex( sal_Int32 nConst )
237 sal_Int32 nIndexes = getCount();
238 sal_Int32 realIndex = 0;
240 for ( ; realIndex < nIndexes; ++realIndex, ++pTableEntry )
242 if ( *pTableEntry == nConst )
248 RangeBorders( uno::Reference< table::XCellRange > xRange, uno::Reference< uno::XComponentContext > xContext,
VbaPalette aPalette ) : m_xRange(std::move( xRange )),
m_xContext(std::move( xContext )), m_Palette(std::move( aPalette ))
252 virtual ::sal_Int32 SAL_CALL getCount( )
override
256 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32
Index )
override
262 uno::Reference< beans::XPropertySet > xProps( m_xRange, uno::UNO_QUERY_THROW );
265 throw lang::IndexOutOfBoundsException();
267 virtual uno::Type SAL_CALL getElementType( )
override
271 virtual sal_Bool SAL_CALL hasElements( )
override
279static uno::Reference< container::XIndexAccess >
282 return new RangeBorders( xRange, xContext, rPalette );
289 uno::Reference<container::XIndexAccess > m_xIndexAccess;
292 explicit RangeBorderEnumWrapper( uno::Reference< container::XIndexAccess > xIndexAccess ) : m_xIndexAccess(
std::move( xIndexAccess )), m_nIndex( 0 ) {}
293 virtual sal_Bool SAL_CALL hasMoreElements( )
override
295 return ( m_nIndex < m_xIndexAccess->getCount() );
298 virtual uno::Any SAL_CALL nextElement( )
override
300 if ( m_nIndex < m_xIndexAccess->getCount() )
301 return m_xIndexAccess->getByIndex( m_nIndex++ );
302 throw container::NoSuchElementException();
311 m_xProps.set( xRange, uno::UNO_QUERY_THROW );
314uno::Reference< container::XEnumeration >
353 return "SwVbaBorders";
356uno::Sequence< OUString >
361 "ooo.vba.word.Borders"
Reference< XComponentContext > m_xContext
virtual OUString getServiceImplName()=0
virtual css::uno::Sequence< OUString > getServiceNames()=0
css::uno::Reference< css::container::XIndexAccess > m_xIndexAccess
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Any getItemByIntIndex(const sal_Int32 nIndex) override
virtual OUString getServiceImplName() override
SwVbaBorders(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::table::XCellRange > &xRange, VbaPalette const &rPalette)
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual void SAL_CALL setShadow(sal_Bool _shadow) override
css::uno::Reference< css::beans::XPropertySet > m_xProps
virtual sal_Bool SAL_CALL getShadow() override
css::uno::Type const & get()
Sequence< OUString > aServiceNames
#define SAL_N_ELEMENTS(arr)
static uno::Reference< container::XIndexAccess > rangeToBorderIndexAccess(const uno::Reference< table::XCellRange > &xRange, const uno::Reference< uno::XComponentContext > &xContext, VbaPalette const &rPalette)
::cppu::WeakImplHelper< container::XIndexAccess > RangeBorders_Base
const sal_Int32 OOLineHairline
InheritedHelperInterfaceWeakImpl< word::XBorder > SwVbaBorder_Base
const sal_Int16 supportedIndexTable[]
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE