xref: /AOO41X/main/sw/source/ui/vba/vbaborders.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir #include "vbaborders.hxx"
24cdf0e10cSrcweir #include <ooo/vba/word/XBorder.hpp>
25cdf0e10cSrcweir #include <ooo/vba/word/WdBorderType.hpp>
26cdf0e10cSrcweir #include <ooo/vba/word/WdLineStyle.hpp>
27cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
28cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
29cdf0e10cSrcweir #include <com/sun/star/table/TableBorder.hpp>
30cdf0e10cSrcweir #include <com/sun/star/table/ShadowFormat.hpp>
31cdf0e10cSrcweir #include <com/sun/star/table/ShadowLocation.hpp>
32cdf0e10cSrcweir #include "vbapalette.hxx"
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using namespace ::com::sun::star;
35cdf0e10cSrcweir using namespace ::ooo::vba;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1<container::XIndexAccess > RangeBorders_Base;
39cdf0e10cSrcweir typedef InheritedHelperInterfaceImpl1<word::XBorder > SwVbaBorder_Base;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // #TODO sort these indexes to match the order in which Word iterates over the
42cdf0e10cSrcweir // borders, the enumeration will match the order in this list
43cdf0e10cSrcweir static 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 };
44cdf0e10cSrcweir 
45cdf0e10cSrcweir const static rtl::OUString sTableBorder( RTL_CONSTASCII_USTRINGPARAM("TableBorder") );
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //  Equiv widths in in 1/100 mm
48cdf0e10cSrcweir const static sal_Int32 OOLineThin = 35;
49cdf0e10cSrcweir const static sal_Int32 OOLineMedium = 88;
50cdf0e10cSrcweir const static sal_Int32 OOLineThick = 141;
51cdf0e10cSrcweir const static sal_Int32 OOLineHairline = 2;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir class SwVbaBorder : public SwVbaBorder_Base
54cdf0e10cSrcweir {
55cdf0e10cSrcweir private:
56cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > m_xProps;
57cdf0e10cSrcweir 	sal_Int32 m_LineType;
58cdf0e10cSrcweir 	VbaPalette m_Palette;
setBorderLine(table::BorderLine & rBorderLine)59cdf0e10cSrcweir 	bool setBorderLine( table::BorderLine& rBorderLine )
60cdf0e10cSrcweir 	{
61cdf0e10cSrcweir 		table::TableBorder aTableBorder;
62cdf0e10cSrcweir 		m_xProps->getPropertyValue( sTableBorder ) >>= aTableBorder;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 		switch ( m_LineType )
65cdf0e10cSrcweir 		{
66cdf0e10cSrcweir 			case word::WdBorderType::wdBorderLeft:
67cdf0e10cSrcweir 				aTableBorder.IsLeftLineValid = sal_True;
68cdf0e10cSrcweir 				aTableBorder.LeftLine= rBorderLine;
69cdf0e10cSrcweir 				break;
70cdf0e10cSrcweir 			case word::WdBorderType::wdBorderTop:
71cdf0e10cSrcweir 				aTableBorder.IsTopLineValid = sal_True;
72cdf0e10cSrcweir 				aTableBorder.TopLine = rBorderLine;
73cdf0e10cSrcweir 				break;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 			case word::WdBorderType::wdBorderBottom:
76cdf0e10cSrcweir 				aTableBorder.IsBottomLineValid = sal_True;
77cdf0e10cSrcweir 				aTableBorder.BottomLine = rBorderLine;
78cdf0e10cSrcweir 				break;
79cdf0e10cSrcweir 			case word::WdBorderType::wdBorderRight:
80cdf0e10cSrcweir 				aTableBorder.IsRightLineValid = sal_True;
81cdf0e10cSrcweir 				aTableBorder.RightLine = rBorderLine;
82cdf0e10cSrcweir 				break;
83cdf0e10cSrcweir 			case word::WdBorderType::wdBorderVertical:
84cdf0e10cSrcweir 				aTableBorder.IsVerticalLineValid = sal_True;
85cdf0e10cSrcweir 				aTableBorder.VerticalLine = rBorderLine;
86cdf0e10cSrcweir 				break;
87cdf0e10cSrcweir 			case word::WdBorderType::wdBorderHorizontal:
88cdf0e10cSrcweir 				aTableBorder.IsHorizontalLineValid = sal_True;
89cdf0e10cSrcweir 				aTableBorder.HorizontalLine = rBorderLine;
90cdf0e10cSrcweir 				break;
91cdf0e10cSrcweir 			case word::WdBorderType::wdBorderDiagonalDown:
92cdf0e10cSrcweir 			case word::WdBorderType::wdBorderDiagonalUp:
93cdf0e10cSrcweir 				// #TODO have to ignore at the momement, would be
94cdf0e10cSrcweir 				// nice to investigate what we can do here
95cdf0e10cSrcweir 				break;
96cdf0e10cSrcweir 			default:
97cdf0e10cSrcweir 					return false;
98cdf0e10cSrcweir 		}
99cdf0e10cSrcweir 		m_xProps->setPropertyValue( sTableBorder, uno::makeAny(aTableBorder) );
100cdf0e10cSrcweir 		return true;
101cdf0e10cSrcweir 	}
102cdf0e10cSrcweir 
getBorderLine(table::BorderLine & rBorderLine)103cdf0e10cSrcweir 	bool getBorderLine( table::BorderLine& rBorderLine )
104cdf0e10cSrcweir 	{
105cdf0e10cSrcweir 		table::TableBorder aTableBorder;
106cdf0e10cSrcweir 		m_xProps->getPropertyValue( sTableBorder ) >>= aTableBorder;
107cdf0e10cSrcweir 		switch ( m_LineType )
108cdf0e10cSrcweir 		{
109cdf0e10cSrcweir 			case word::WdBorderType::wdBorderLeft:
110cdf0e10cSrcweir 				if ( aTableBorder.IsLeftLineValid )
111cdf0e10cSrcweir 					rBorderLine = aTableBorder.LeftLine;
112cdf0e10cSrcweir 				break;
113cdf0e10cSrcweir 			case word::WdBorderType::wdBorderTop:
114cdf0e10cSrcweir 				if ( aTableBorder.IsTopLineValid )
115cdf0e10cSrcweir 					rBorderLine = aTableBorder.TopLine;
116cdf0e10cSrcweir 				break;
117cdf0e10cSrcweir 			case word::WdBorderType::wdBorderBottom:
118cdf0e10cSrcweir 				if ( aTableBorder.IsBottomLineValid )
119cdf0e10cSrcweir 					rBorderLine = aTableBorder.BottomLine;
120cdf0e10cSrcweir 				break;
121cdf0e10cSrcweir 			case word::WdBorderType::wdBorderRight:
122cdf0e10cSrcweir 				if ( aTableBorder.IsRightLineValid )
123cdf0e10cSrcweir 					rBorderLine = aTableBorder.RightLine;
124cdf0e10cSrcweir 				break;
125cdf0e10cSrcweir 			case word::WdBorderType::wdBorderVertical:
126cdf0e10cSrcweir                 if ( aTableBorder.IsVerticalLineValid )
127cdf0e10cSrcweir                     rBorderLine = aTableBorder.VerticalLine;
128cdf0e10cSrcweir 				break;
129cdf0e10cSrcweir 			case word::WdBorderType::wdBorderHorizontal:
130cdf0e10cSrcweir                 if ( aTableBorder.IsHorizontalLineValid )
131cdf0e10cSrcweir                     rBorderLine = aTableBorder.HorizontalLine;
132cdf0e10cSrcweir 				break;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 			case word::WdBorderType::wdBorderDiagonalDown:
135cdf0e10cSrcweir 			case word::WdBorderType::wdBorderDiagonalUp:
136cdf0e10cSrcweir 				// #TODO have to ignore at the momement, would be
137cdf0e10cSrcweir 				// nice to investigate what we can do here
138cdf0e10cSrcweir 				break;
139cdf0e10cSrcweir 			default:
140cdf0e10cSrcweir 					return false;
141cdf0e10cSrcweir 		}
142cdf0e10cSrcweir 		return true;
143cdf0e10cSrcweir 	}
144cdf0e10cSrcweir 	SwVbaBorder(); // no impl
145cdf0e10cSrcweir protected:
getServiceImplName()146cdf0e10cSrcweir 	virtual rtl::OUString& getServiceImplName()
147cdf0e10cSrcweir 	{
148cdf0e10cSrcweir 		static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBorder") );
149cdf0e10cSrcweir 	return sImplName;
150cdf0e10cSrcweir 	}
getServiceNames()151cdf0e10cSrcweir 	virtual css::uno::Sequence<rtl::OUString> getServiceNames()
152cdf0e10cSrcweir 	{
153cdf0e10cSrcweir 		static uno::Sequence< rtl::OUString > aServiceNames;
154cdf0e10cSrcweir 		if ( aServiceNames.getLength() == 0 )
155cdf0e10cSrcweir 		{
156cdf0e10cSrcweir 			aServiceNames.realloc( 1 );
157cdf0e10cSrcweir 			aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Border" ) );
158cdf0e10cSrcweir 		}
159cdf0e10cSrcweir 		return aServiceNames;
160cdf0e10cSrcweir 	}
161cdf0e10cSrcweir public:
SwVbaBorder(const uno::Reference<beans::XPropertySet> & xProps,const uno::Reference<uno::XComponentContext> & xContext,sal_Int32 lineType,VbaPalette & rPalette)162cdf0e10cSrcweir 	SwVbaBorder( const uno::Reference< beans::XPropertySet > & xProps, const uno::Reference< uno::XComponentContext >& xContext, sal_Int32 lineType, VbaPalette& rPalette) : SwVbaBorder_Base( uno::Reference< XHelperInterface >( xProps, uno::UNO_QUERY ), xContext ), m_xProps( xProps ), m_LineType( lineType ), m_Palette( rPalette ) {}
163cdf0e10cSrcweir 
getLineStyle()164cdf0e10cSrcweir 	uno::Any SAL_CALL getLineStyle() throw (uno::RuntimeException)
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir         sal_Int32 nLineStyle = word::WdLineStyle::wdLineStyleNone;
167cdf0e10cSrcweir         table::BorderLine aBorderLine;
168cdf0e10cSrcweir         if ( getBorderLine( aBorderLine ) )
169cdf0e10cSrcweir         {
170cdf0e10cSrcweir             if( aBorderLine.InnerLineWidth !=0 && aBorderLine.OuterLineWidth !=0 )
171cdf0e10cSrcweir             {
172cdf0e10cSrcweir                 nLineStyle = word::WdLineStyle::wdLineStyleDouble;
173cdf0e10cSrcweir             }
174cdf0e10cSrcweir             else if( aBorderLine.InnerLineWidth !=0 || aBorderLine.OuterLineWidth !=0 )
175cdf0e10cSrcweir             {
176cdf0e10cSrcweir                 nLineStyle = word::WdLineStyle::wdLineStyleSingle;
177cdf0e10cSrcweir             }
178cdf0e10cSrcweir             else
179cdf0e10cSrcweir             {
180cdf0e10cSrcweir                 nLineStyle = word::WdLineStyle::wdLineStyleNone;
181cdf0e10cSrcweir             }
182cdf0e10cSrcweir         }
183cdf0e10cSrcweir 		return uno::makeAny( nLineStyle );
184cdf0e10cSrcweir 	}
setLineStyle(const uno::Any & _linestyle)185cdf0e10cSrcweir 	void SAL_CALL setLineStyle( const uno::Any& _linestyle ) throw (uno::RuntimeException)
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		// Urk no choice but to silently ignore we don't support this attribute
188cdf0e10cSrcweir 		// #TODO would be nice to support the word line styles
189cdf0e10cSrcweir         sal_Int32 nLineStyle = 0;
190cdf0e10cSrcweir         _linestyle >>= nLineStyle;
191cdf0e10cSrcweir         table::BorderLine aBorderLine;
192cdf0e10cSrcweir 		if ( getBorderLine( aBorderLine ) )
193cdf0e10cSrcweir 		{
194cdf0e10cSrcweir 			switch ( nLineStyle )
195cdf0e10cSrcweir 			{
196cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleNone:
197cdf0e10cSrcweir                 {
198cdf0e10cSrcweir                     aBorderLine.InnerLineWidth = 0;
199cdf0e10cSrcweir                     aBorderLine.OuterLineWidth = 0;
200cdf0e10cSrcweir                     break;
201cdf0e10cSrcweir                 }
202cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleDashDot:
203cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleDashDotDot:
204cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleDashDotStroked:
205cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleDashLargeGap:
206cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleDashSmallGap:
207cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleDot:
208cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleDouble:
209cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleDoubleWavy:
210cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleEmboss3D:
211cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleEngrave3D:
212cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleInset:
213cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleOutset:
214cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleSingle:
215cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleSingleWavy:
216cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThickThinLargeGap:
217cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThickThinMedGap:
218cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThickThinSmallGap:
219cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThinThickLargeGap:
220cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThinThickMedGap:
221cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThinThickSmallGap:
222cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThinThickThinLargeGap:
223cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThinThickThinMedGap:
224cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleThinThickThinSmallGap:
225cdf0e10cSrcweir                 case word::WdLineStyle::wdLineStyleTriple:
226cdf0e10cSrcweir                 {
227cdf0e10cSrcweir                     aBorderLine.InnerLineWidth = 0;
228cdf0e10cSrcweir                     aBorderLine.OuterLineWidth = OOLineHairline;
229cdf0e10cSrcweir                     break;
230cdf0e10cSrcweir                 }
231cdf0e10cSrcweir                 default:
232cdf0e10cSrcweir                     throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Bad param" ) ), uno::Reference< uno::XInterface >() );
233cdf0e10cSrcweir             }
234cdf0e10cSrcweir 			setBorderLine( aBorderLine );
235cdf0e10cSrcweir         }
236cdf0e10cSrcweir 		else
237cdf0e10cSrcweir             throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Method failed" ) ), uno::Reference< uno::XInterface >() );
238cdf0e10cSrcweir 	}
239cdf0e10cSrcweir };
240cdf0e10cSrcweir 
241cdf0e10cSrcweir class RangeBorders : public RangeBorders_Base
242cdf0e10cSrcweir {
243cdf0e10cSrcweir private:
244cdf0e10cSrcweir 	uno::Reference< table::XCellRange > m_xRange;
245cdf0e10cSrcweir 	uno::Reference< uno::XComponentContext > m_xContext;
246cdf0e10cSrcweir 	VbaPalette m_Palette;
getTableIndex(sal_Int32 nConst)247cdf0e10cSrcweir 	sal_Int32 getTableIndex( sal_Int32 nConst )
248cdf0e10cSrcweir 	{
249cdf0e10cSrcweir 		// hokay return position of the index in the table
250cdf0e10cSrcweir 		sal_Int32 nIndexes = getCount();
251cdf0e10cSrcweir 		sal_Int32 realIndex = 0;
252cdf0e10cSrcweir 		const sal_Int16* pTableEntry = supportedIndexTable;
253cdf0e10cSrcweir 		for ( ; realIndex < nIndexes; ++realIndex, ++pTableEntry )
254cdf0e10cSrcweir 		{
255cdf0e10cSrcweir 			if ( *pTableEntry == nConst )
256cdf0e10cSrcweir 				return realIndex;
257cdf0e10cSrcweir 		}
258cdf0e10cSrcweir 		return getCount(); // error condition
259cdf0e10cSrcweir 	}
260cdf0e10cSrcweir public:
RangeBorders(const uno::Reference<table::XCellRange> & xRange,const uno::Reference<uno::XComponentContext> & xContext,VbaPalette & rPalette)261cdf0e10cSrcweir 	RangeBorders(  const uno::Reference< table::XCellRange >& xRange,  const uno::Reference< uno::XComponentContext > & xContext, VbaPalette& rPalette ) : m_xRange( xRange ), m_xContext( xContext ), m_Palette( rPalette )
262cdf0e10cSrcweir 	{
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir 	// XIndexAccess
getCount()265cdf0e10cSrcweir 	virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException)
266cdf0e10cSrcweir 	{
267cdf0e10cSrcweir 		return sizeof( supportedIndexTable ) / sizeof( supportedIndexTable[0] );
268cdf0e10cSrcweir 	}
getByIndex(::sal_Int32 Index)269cdf0e10cSrcweir 	virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 		sal_Int32 nIndex = getTableIndex( Index );
273cdf0e10cSrcweir 		if ( nIndex >= 0 && nIndex < getCount() )
274cdf0e10cSrcweir 		{
275cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xProps( m_xRange, uno::UNO_QUERY_THROW );
276cdf0e10cSrcweir 			return uno::makeAny( uno::Reference< word::XBorder >( new SwVbaBorder( xProps, m_xContext, supportedIndexTable[ nIndex ], m_Palette )) );
277cdf0e10cSrcweir 		}
278cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
279cdf0e10cSrcweir 	}
getElementType()280cdf0e10cSrcweir 	virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException)
281cdf0e10cSrcweir 	{
282cdf0e10cSrcweir 		return  word::XBorder::static_type(0);
283cdf0e10cSrcweir 	}
hasElements()284cdf0e10cSrcweir 	virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException)
285cdf0e10cSrcweir 	{
286cdf0e10cSrcweir 		return sal_True;
287cdf0e10cSrcweir 	}
288cdf0e10cSrcweir };
289cdf0e10cSrcweir 
290cdf0e10cSrcweir uno::Reference< container::XIndexAccess >
rangeToBorderIndexAccess(const uno::Reference<table::XCellRange> & xRange,const uno::Reference<uno::XComponentContext> & xContext,VbaPalette & rPalette)291cdf0e10cSrcweir rangeToBorderIndexAccess( const uno::Reference< table::XCellRange >& xRange,  const uno::Reference< uno::XComponentContext > & xContext, VbaPalette& rPalette )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir 	return new RangeBorders( xRange, xContext, rPalette );
294cdf0e10cSrcweir }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir class RangeBorderEnumWrapper : public EnumerationHelper_BASE
297cdf0e10cSrcweir {
298cdf0e10cSrcweir 	uno::Reference<container::XIndexAccess > m_xIndexAccess;
299cdf0e10cSrcweir 	sal_Int32 nIndex;
300cdf0e10cSrcweir public:
RangeBorderEnumWrapper(const uno::Reference<container::XIndexAccess> & xIndexAccess)301cdf0e10cSrcweir 	RangeBorderEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
hasMoreElements()302cdf0e10cSrcweir 	virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
303cdf0e10cSrcweir 	{
304cdf0e10cSrcweir 		return ( nIndex < m_xIndexAccess->getCount() );
305cdf0e10cSrcweir 	}
306cdf0e10cSrcweir 
nextElement()307cdf0e10cSrcweir 	virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
308cdf0e10cSrcweir 	{
309cdf0e10cSrcweir 		if ( nIndex < m_xIndexAccess->getCount() )
310cdf0e10cSrcweir 			return m_xIndexAccess->getByIndex( nIndex++ );
311cdf0e10cSrcweir 		throw container::NoSuchElementException();
312cdf0e10cSrcweir 	}
313cdf0e10cSrcweir };
314cdf0e10cSrcweir 
315cdf0e10cSrcweir // for Table borders
SwVbaBorders(const uno::Reference<XHelperInterface> & xParent,const uno::Reference<uno::XComponentContext> & xContext,const uno::Reference<table::XCellRange> & xRange,VbaPalette & rPalette)316cdf0e10cSrcweir SwVbaBorders::SwVbaBorders( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< table::XCellRange >& xRange, VbaPalette& rPalette  ):  SwVbaBorders_BASE( xParent, xContext, rangeToBorderIndexAccess( xRange ,xContext, rPalette ) )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir 	m_xProps.set( xRange, uno::UNO_QUERY_THROW );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir uno::Reference< container::XEnumeration >
createEnumeration()322cdf0e10cSrcweir SwVbaBorders::createEnumeration() throw (uno::RuntimeException)
323cdf0e10cSrcweir {
324cdf0e10cSrcweir 	return new RangeBorderEnumWrapper( m_xIndexAccess );
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir uno::Any
createCollectionObject(const css::uno::Any & aSource)328cdf0e10cSrcweir SwVbaBorders::createCollectionObject( const css::uno::Any& aSource )
329cdf0e10cSrcweir {
330cdf0e10cSrcweir 	return aSource; // its already a Border object
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir uno::Type
getElementType()334cdf0e10cSrcweir SwVbaBorders::getElementType() throw (uno::RuntimeException)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir 	return word::XBorders::static_type(0);
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir uno::Any
getItemByIntIndex(const sal_Int32 nIndex)340cdf0e10cSrcweir SwVbaBorders::getItemByIntIndex( const sal_Int32 nIndex )  throw (uno::RuntimeException)
341cdf0e10cSrcweir {
342cdf0e10cSrcweir 	return createCollectionObject( m_xIndexAccess->getByIndex( nIndex ) );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir 
getShadow()345cdf0e10cSrcweir sal_Bool SAL_CALL SwVbaBorders::getShadow() throw (uno::RuntimeException)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir     table::ShadowFormat aShadowFormat;
348cdf0e10cSrcweir     m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShadowFormat") ) ) >>= aShadowFormat;
349cdf0e10cSrcweir     return ( aShadowFormat.Location != table::ShadowLocation_NONE );
350cdf0e10cSrcweir }
351cdf0e10cSrcweir 
setShadow(sal_Bool)352cdf0e10cSrcweir void SAL_CALL SwVbaBorders::setShadow( sal_Bool /*_shadow*/ ) throw (uno::RuntimeException)
353cdf0e10cSrcweir {
354cdf0e10cSrcweir     throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir rtl::OUString&
getServiceImplName()358cdf0e10cSrcweir SwVbaBorders::getServiceImplName()
359cdf0e10cSrcweir {
360cdf0e10cSrcweir 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBorders") );
361cdf0e10cSrcweir 	return sImplName;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir 
364cdf0e10cSrcweir uno::Sequence< rtl::OUString >
getServiceNames()365cdf0e10cSrcweir SwVbaBorders::getServiceNames()
366cdf0e10cSrcweir {
367cdf0e10cSrcweir 	static uno::Sequence< rtl::OUString > aServiceNames;
368cdf0e10cSrcweir 	if ( aServiceNames.getLength() == 0 )
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir 		aServiceNames.realloc( 1 );
371cdf0e10cSrcweir 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Borders" ) );
372cdf0e10cSrcweir 	}
373cdf0e10cSrcweir 	return aServiceNames;
374cdf0e10cSrcweir }
375