1*cdf0e10cSrcweir #include "vbatable.hxx" 2*cdf0e10cSrcweir #include "vbarange.hxx" 3*cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 4*cdf0e10cSrcweir #include <com/sun/star/text/XTextViewCursorSupplier.hpp> 5*cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp> 6*cdf0e10cSrcweir #include <com/sun/star/text/XTextTable.hpp> 7*cdf0e10cSrcweir #include <com/sun/star/text/XTextTablesSupplier.hpp> 8*cdf0e10cSrcweir #include <com/sun/star/table/XTableRows.hpp> 9*cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp> 10*cdf0e10cSrcweir #include "vbaborders.hxx" 11*cdf0e10cSrcweir #include "vbapalette.hxx" 12*cdf0e10cSrcweir 13*cdf0e10cSrcweir using namespace ::ooo::vba; 14*cdf0e10cSrcweir using namespace ::com::sun::star; 15*cdf0e10cSrcweir 16*cdf0e10cSrcweir 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 ) 17*cdf0e10cSrcweir { 18*cdf0e10cSrcweir mxTextTable.set( xTextTable, uno::UNO_QUERY_THROW ); 19*cdf0e10cSrcweir } 20*cdf0e10cSrcweir 21*cdf0e10cSrcweir uno::Reference< word::XRange > SAL_CALL 22*cdf0e10cSrcweir SwVbaTable::Range( ) throw (script::BasicErrorException, uno::RuntimeException) 23*cdf0e10cSrcweir { 24*cdf0e10cSrcweir return new SwVbaRange( mxParent, mxContext, mxTextDocument, mxTextTable->getAnchor() ); 25*cdf0e10cSrcweir } 26*cdf0e10cSrcweir 27*cdf0e10cSrcweir void SAL_CALL 28*cdf0e10cSrcweir SwVbaTable::Select( ) throw (script::BasicErrorException, uno::RuntimeException) 29*cdf0e10cSrcweir { 30*cdf0e10cSrcweir uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW ); 31*cdf0e10cSrcweir uno::Reference< frame::XController > xController = xModel->getCurrentController(); 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( xController, uno::UNO_QUERY_THROW ); 34*cdf0e10cSrcweir uno::Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY_THROW ); 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir // set the view cursor to the start of the table. 37*cdf0e10cSrcweir xSelectionSupplier->select( uno::makeAny( mxTextTable ) ); 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir // go to the end of the table and span the view 40*cdf0e10cSrcweir uno::Reference< text::XTextViewCursor > xCursor = xViewCursorSupplier->getViewCursor(); 41*cdf0e10cSrcweir xCursor->gotoEnd(sal_True); 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir } 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir void SAL_CALL 46*cdf0e10cSrcweir SwVbaTable::Delete( ) throw (script::BasicErrorException, uno::RuntimeException) 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir uno::Reference< table::XTableRows > xRows( mxTextTable->getRows() ); 49*cdf0e10cSrcweir xRows->removeByIndex( 0, xRows->getCount() ); 50*cdf0e10cSrcweir } 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir uno::Reference< word::XRange > SAL_CALL 53*cdf0e10cSrcweir SwVbaTable::ConvertToText( const uno::Any& /*Separator*/, const uno::Any& /*NestedTables*/ ) throw (script::BasicErrorException, uno::RuntimeException) 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir // #FIXME the helper api uses the dreaded dispatch mechanism, holding off 56*cdf0e10cSrcweir // implementation while I look for alternative solution 57*cdf0e10cSrcweir throw uno::RuntimeException(); 58*cdf0e10cSrcweir } 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir rtl::OUString SAL_CALL 61*cdf0e10cSrcweir SwVbaTable::getName() throw (uno::RuntimeException) 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir uno::Reference< container::XNamed > xNamed( mxTextTable, uno::UNO_QUERY_THROW ); 64*cdf0e10cSrcweir return xNamed->getName(); 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir uno::Any SAL_CALL 68*cdf0e10cSrcweir SwVbaTable::Borders( const uno::Any& index ) throw (uno::RuntimeException) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir uno::Reference< table::XCellRange > aCellRange( mxTextTable, uno::UNO_QUERY_THROW ); 71*cdf0e10cSrcweir VbaPalette aPalette; 72*cdf0e10cSrcweir uno::Reference< XCollection > xCol( new SwVbaBorders( this, mxContext, aCellRange, aPalette ) ); 73*cdf0e10cSrcweir if ( index.hasValue() ) 74*cdf0e10cSrcweir return xCol->Item( index, uno::Any() ); 75*cdf0e10cSrcweir return uno::makeAny( xCol ); 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // XHelperInterface 79*cdf0e10cSrcweir rtl::OUString& 80*cdf0e10cSrcweir SwVbaTable::getServiceImplName() 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTable") ); 83*cdf0e10cSrcweir return sImplName; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir uno::Sequence<rtl::OUString> 87*cdf0e10cSrcweir SwVbaTable::getServiceNames() 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir static uno::Sequence< rtl::OUString > aServiceNames; 90*cdf0e10cSrcweir if ( aServiceNames.getLength() == 0 ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir aServiceNames.realloc( 1 ); 93*cdf0e10cSrcweir aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Table" ) ); 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir return aServiceNames; 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir 98