1 #include "vbatable.hxx"
2 #include "vbarange.hxx"
3 #include <com/sun/star/frame/XModel.hpp>
4 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
5 #include <com/sun/star/view/XSelectionSupplier.hpp>
6 #include <com/sun/star/text/XTextTable.hpp>
7 #include <com/sun/star/text/XTextTablesSupplier.hpp>
8 #include <com/sun/star/table/XTableRows.hpp>
9 #include <com/sun/star/container/XNamed.hpp>
10 #include "vbaborders.hxx"
11 #include "vbapalette.hxx"
13 using namespace ::ooo::vba
;
14 using namespace ::com::sun::star
;
16 SwVbaTable::SwVbaTable( const uno::Reference
< ooo::vba::XHelperInterface
>& rParent
, const uno::Reference
< uno::XComponentContext
>& rContext
, const css::uno::Reference
< css::text::XTextDocument
>& rDocument
, const uno::Reference
< css::text::XTextTable
>& xTextTable
) throw ( uno::RuntimeException
) : SwVbaTable_BASE( rParent
, rContext
), mxTextDocument( rDocument
)
18 mxTextTable
.set( xTextTable
, uno::UNO_QUERY_THROW
);
21 uno::Reference
< word::XRange
> SAL_CALL
22 SwVbaTable::Range( ) throw (script::BasicErrorException
, uno::RuntimeException
)
24 return new SwVbaRange( mxParent
, mxContext
, mxTextDocument
, mxTextTable
->getAnchor() );
28 SwVbaTable::Select( ) throw (script::BasicErrorException
, uno::RuntimeException
)
30 uno::Reference
< frame::XModel
> xModel( mxTextDocument
, uno::UNO_QUERY_THROW
);
31 uno::Reference
< frame::XController
> xController
= xModel
->getCurrentController();
33 uno::Reference
< text::XTextViewCursorSupplier
> xViewCursorSupplier( xController
, uno::UNO_QUERY_THROW
);
34 uno::Reference
< view::XSelectionSupplier
> xSelectionSupplier( xController
, uno::UNO_QUERY_THROW
);
36 // set the view cursor to the start of the table.
37 xSelectionSupplier
->select( uno::makeAny( mxTextTable
) );
39 // go to the end of the table and span the view
40 uno::Reference
< text::XTextViewCursor
> xCursor
= xViewCursorSupplier
->getViewCursor();
41 xCursor
->gotoEnd(sal_True
);
46 SwVbaTable::Delete( ) throw (script::BasicErrorException
, uno::RuntimeException
)
48 uno::Reference
< table::XTableRows
> xRows( mxTextTable
->getRows() );
49 xRows
->removeByIndex( 0, xRows
->getCount() );
52 uno::Reference
< word::XRange
> SAL_CALL
53 SwVbaTable::ConvertToText( const uno::Any
& /*Separator*/, const uno::Any
& /*NestedTables*/ ) throw (script::BasicErrorException
, uno::RuntimeException
)
55 // #FIXME the helper api uses the dreaded dispatch mechanism, holding off
56 // implementation while I look for alternative solution
57 throw uno::RuntimeException();
60 rtl::OUString SAL_CALL
61 SwVbaTable::getName() throw (uno::RuntimeException
)
63 uno::Reference
< container::XNamed
> xNamed( mxTextTable
, uno::UNO_QUERY_THROW
);
64 return xNamed
->getName();
68 SwVbaTable::Borders( const uno::Any
& index
) throw (uno::RuntimeException
)
70 uno::Reference
< table::XCellRange
> aCellRange( mxTextTable
, uno::UNO_QUERY_THROW
);
72 uno::Reference
< XCollection
> xCol( new SwVbaBorders( this, mxContext
, aCellRange
, aPalette
) );
73 if ( index
.hasValue() )
74 return xCol
->Item( index
, uno::Any() );
75 return uno::makeAny( xCol
);
80 SwVbaTable::getServiceImplName()
82 static rtl::OUString
sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTable") );
86 uno::Sequence
<rtl::OUString
>
87 SwVbaTable::getServiceNames()
89 static uno::Sequence
< rtl::OUString
> aServiceNames
;
90 if ( aServiceNames
.getLength() == 0 )
92 aServiceNames
.realloc( 1 );
93 aServiceNames
[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Table" ) );