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>
37 const 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 };
47 uno::Reference< beans::XPropertySet >
m_xProps;
49 void setBorderLine( table::BorderLine
const & rBorderLine )
51 table::TableBorder aTableBorder;
52 m_xProps->getPropertyValue(
"TableBorder" ) >>= aTableBorder;
56 case word::WdBorderType::wdBorderLeft:
57 aTableBorder.IsLeftLineValid =
true;
58 aTableBorder.LeftLine= rBorderLine;
60 case word::WdBorderType::wdBorderTop:
61 aTableBorder.IsTopLineValid =
true;
62 aTableBorder.TopLine = rBorderLine;
65 case word::WdBorderType::wdBorderBottom:
66 aTableBorder.IsBottomLineValid =
true;
67 aTableBorder.BottomLine = rBorderLine;
69 case word::WdBorderType::wdBorderRight:
70 aTableBorder.IsRightLineValid =
true;
71 aTableBorder.RightLine = rBorderLine;
73 case word::WdBorderType::wdBorderVertical:
74 aTableBorder.IsVerticalLineValid =
true;
75 aTableBorder.VerticalLine = rBorderLine;
77 case word::WdBorderType::wdBorderHorizontal:
78 aTableBorder.IsHorizontalLineValid =
true;
79 aTableBorder.HorizontalLine = rBorderLine;
81 case word::WdBorderType::wdBorderDiagonalDown:
82 case word::WdBorderType::wdBorderDiagonalUp:
89 m_xProps->setPropertyValue(
"TableBorder",
uno::Any(aTableBorder) );
92 bool getBorderLine( table::BorderLine& rBorderLine )
94 table::TableBorder aTableBorder;
95 m_xProps->getPropertyValue(
"TableBorder" ) >>= aTableBorder;
98 case word::WdBorderType::wdBorderLeft:
99 if ( aTableBorder.IsLeftLineValid )
100 rBorderLine = aTableBorder.LeftLine;
102 case word::WdBorderType::wdBorderTop:
103 if ( aTableBorder.IsTopLineValid )
104 rBorderLine = aTableBorder.TopLine;
106 case word::WdBorderType::wdBorderBottom:
107 if ( aTableBorder.IsBottomLineValid )
108 rBorderLine = aTableBorder.BottomLine;
110 case word::WdBorderType::wdBorderRight:
111 if ( aTableBorder.IsRightLineValid )
112 rBorderLine = aTableBorder.RightLine;
114 case word::WdBorderType::wdBorderVertical:
115 if ( aTableBorder.IsVerticalLineValid )
116 rBorderLine = aTableBorder.VerticalLine;
118 case word::WdBorderType::wdBorderHorizontal:
119 if ( aTableBorder.IsHorizontalLineValid )
120 rBorderLine = aTableBorder.HorizontalLine;
123 case word::WdBorderType::wdBorderDiagonalDown:
124 case word::WdBorderType::wdBorderDiagonalUp:
137 return "SwVbaBorder";
144 "ooo.vba.word.Border"
149 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 ) {}
151 uno::Any SAL_CALL getLineStyle()
override
153 sal_Int32 nLineStyle = word::WdLineStyle::wdLineStyleNone;
154 table::BorderLine aBorderLine;
155 if ( getBorderLine( aBorderLine ) )
157 if( aBorderLine.InnerLineWidth !=0 && aBorderLine.OuterLineWidth !=0 )
159 nLineStyle = word::WdLineStyle::wdLineStyleDouble;
161 else if( aBorderLine.InnerLineWidth !=0 || aBorderLine.OuterLineWidth !=0 )
163 nLineStyle = word::WdLineStyle::wdLineStyleSingle;
167 nLineStyle = word::WdLineStyle::wdLineStyleNone;
172 void SAL_CALL setLineStyle(
const uno::Any& _linestyle )
override
176 sal_Int32 nLineStyle = 0;
177 _linestyle >>= nLineStyle;
178 table::BorderLine aBorderLine;
179 if ( !getBorderLine( aBorderLine ) )
180 throw uno::RuntimeException(
"Method failed" );
182 switch ( nLineStyle )
184 case word::WdLineStyle::wdLineStyleNone:
186 aBorderLine.InnerLineWidth = 0;
187 aBorderLine.OuterLineWidth = 0;
190 case word::WdLineStyle::wdLineStyleDashDot:
191 case word::WdLineStyle::wdLineStyleDashDotDot:
192 case word::WdLineStyle::wdLineStyleDashDotStroked:
193 case word::WdLineStyle::wdLineStyleDashLargeGap:
194 case word::WdLineStyle::wdLineStyleDashSmallGap:
195 case word::WdLineStyle::wdLineStyleDot:
196 case word::WdLineStyle::wdLineStyleDouble:
197 case word::WdLineStyle::wdLineStyleDoubleWavy:
198 case word::WdLineStyle::wdLineStyleEmboss3D:
199 case word::WdLineStyle::wdLineStyleEngrave3D:
200 case word::WdLineStyle::wdLineStyleInset:
201 case word::WdLineStyle::wdLineStyleOutset:
202 case word::WdLineStyle::wdLineStyleSingle:
203 case word::WdLineStyle::wdLineStyleSingleWavy:
204 case word::WdLineStyle::wdLineStyleThickThinLargeGap:
205 case word::WdLineStyle::wdLineStyleThickThinMedGap:
206 case word::WdLineStyle::wdLineStyleThickThinSmallGap:
207 case word::WdLineStyle::wdLineStyleThinThickLargeGap:
208 case word::WdLineStyle::wdLineStyleThinThickMedGap:
209 case word::WdLineStyle::wdLineStyleThinThickSmallGap:
210 case word::WdLineStyle::wdLineStyleThinThickThinLargeGap:
211 case word::WdLineStyle::wdLineStyleThinThickThinMedGap:
212 case word::WdLineStyle::wdLineStyleThinThickThinSmallGap:
213 case word::WdLineStyle::wdLineStyleTriple:
215 aBorderLine.InnerLineWidth = 0;
220 throw uno::RuntimeException(
"Bad param" );
222 setBorderLine( aBorderLine );
230 uno::Reference< table::XCellRange > m_xRange;
231 uno::Reference< uno::XComponentContext >
m_xContext;
233 sal_Int32 getTableIndex( sal_Int32 nConst )
236 sal_Int32 nIndexes = getCount();
237 sal_Int32 realIndex = 0;
239 for ( ; realIndex < nIndexes; ++realIndex, ++pTableEntry )
241 if ( *pTableEntry == nConst )
247 RangeBorders(
const uno::Reference< table::XCellRange >& xRange,
const uno::Reference< uno::XComponentContext > & xContext,
VbaPalette const & rPalette ) : m_xRange( xRange ), m_xContext( xContext ), m_Palette( rPalette )
251 virtual ::sal_Int32 SAL_CALL getCount( )
override
255 virtual uno::Any SAL_CALL getByIndex( ::sal_Int32
Index )
override
258 sal_Int32
nIndex = getTableIndex( Index );
259 if ( nIndex >= 0 && nIndex < getCount() )
261 uno::Reference< beans::XPropertySet > xProps( m_xRange, uno::UNO_QUERY_THROW );
264 throw lang::IndexOutOfBoundsException();
266 virtual uno::Type SAL_CALL getElementType( )
override
270 virtual sal_Bool SAL_CALL hasElements( )
override
278 static uno::Reference< container::XIndexAccess >
281 return new RangeBorders( xRange, xContext, rPalette );
288 uno::Reference<container::XIndexAccess > m_xIndexAccess;
291 explicit RangeBorderEnumWrapper(
const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
292 virtual sal_Bool SAL_CALL hasMoreElements( )
override
294 return ( nIndex < m_xIndexAccess->getCount() );
297 virtual uno::Any SAL_CALL nextElement( )
override
299 if ( nIndex < m_xIndexAccess->getCount() )
300 return m_xIndexAccess->getByIndex( nIndex++ );
301 throw container::NoSuchElementException();
310 m_xProps.set( xRange, uno::UNO_QUERY_THROW );
313 uno::Reference< container::XEnumeration >
316 return new RangeBorderEnumWrapper( m_xIndexAccess );
352 return "SwVbaBorders";
355 uno::Sequence< OUString >
360 "ooo.vba.word.Borders"
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual OUString getServiceImplName() override
css::uno::Reference< css::beans::XPropertySet > m_xProps
Sequence< OUString > aServiceNames
virtual OUString getServiceImplName()=0
const sal_Int32 OOLineHairline
InheritedHelperInterfaceWeakImpl< word::XBorder > SwVbaBorder_Base
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE
virtual css::uno::Sequence< OUString > getServiceNames()=0
#define SAL_N_ELEMENTS(arr)
virtual void SAL_CALL setShadow(sal_Bool _shadow) override
virtual sal_Bool SAL_CALL getShadow() override
css::uno::Type const & get()
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual css::uno::Any getItemByIntIndex(const sal_Int32 nIndex) override
const sal_Int16 supportedIndexTable[]
static uno::Reference< container::XIndexAccess > rangeToBorderIndexAccess(const uno::Reference< table::XCellRange > &xRange, const uno::Reference< uno::XComponentContext > &xContext, VbaPalette const &rPalette)
Reference< XComponentContext > m_xContext
::cppu::WeakImplHelper< container::XIndexAccess > RangeBorders_Base
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)