Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : #include "vbatable.hxx"
3 : : #include "vbarange.hxx"
4 : : #include <com/sun/star/frame/XModel.hpp>
5 : : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
6 : : #include <com/sun/star/view/XSelectionSupplier.hpp>
7 : : #include <com/sun/star/text/XTextTable.hpp>
8 : : #include <com/sun/star/text/XTextTablesSupplier.hpp>
9 : : #include <com/sun/star/table/XTableRows.hpp>
10 : : #include <com/sun/star/container/XNamed.hpp>
11 : : #include "vbaborders.hxx"
12 : : #include "vbapalette.hxx"
13 : : #include "vbarows.hxx"
14 : : #include "vbacolumns.hxx"
15 : :
16 : : using namespace ::ooo::vba;
17 : : using namespace ::com::sun::star;
18 : :
19 : 0 : SwVbaTable::SwVbaTable( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rDocument, const uno::Reference< text::XTextTable >& xTextTable) throw ( uno::RuntimeException ) : SwVbaTable_BASE( rParent, rContext ), mxTextDocument( rDocument )
20 : : {
21 [ # # ]: 0 : mxTextTable.set( xTextTable, uno::UNO_QUERY_THROW );
22 : 0 : }
23 : :
24 : : uno::Reference< word::XRange > SAL_CALL
25 : 0 : SwVbaTable::Range( ) throw (script::BasicErrorException, uno::RuntimeException)
26 : : {
27 [ # # ][ # # ]: 0 : return new SwVbaRange( mxParent, mxContext, mxTextDocument, mxTextTable->getAnchor() );
[ # # ][ # # ]
[ # # ]
28 : : }
29 : :
30 : : void SAL_CALL
31 : 0 : SwVbaTable::Select( ) throw (script::BasicErrorException, uno::RuntimeException)
32 : : {
33 [ # # ]: 0 : uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
34 [ # # ][ # # ]: 0 : uno::Reference< frame::XController > xController = xModel->getCurrentController();
35 : :
36 [ # # ]: 0 : uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( xController, uno::UNO_QUERY_THROW );
37 [ # # ]: 0 : uno::Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY_THROW );
38 : :
39 : : // set the view cursor to the start of the table.
40 [ # # ][ # # ]: 0 : xSelectionSupplier->select( uno::makeAny( mxTextTable ) );
[ # # ]
41 : :
42 : : // go to the end of the table and span the view
43 [ # # ][ # # ]: 0 : uno::Reference< text::XTextViewCursor > xCursor = xViewCursorSupplier->getViewCursor();
44 [ # # ][ # # ]: 0 : xCursor->gotoEnd(sal_True);
45 : :
46 : 0 : }
47 : :
48 : : void SAL_CALL
49 : 0 : SwVbaTable::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
50 : : {
51 [ # # ][ # # ]: 0 : uno::Reference< table::XTableRows > xRows( mxTextTable->getRows() );
52 [ # # ][ # # ]: 0 : xRows->removeByIndex( 0, xRows->getCount() );
[ # # ][ # # ]
53 : 0 : }
54 : :
55 : : uno::Reference< word::XRange > SAL_CALL
56 : 0 : SwVbaTable::ConvertToText( const uno::Any& /*Separator*/, const uno::Any& /*NestedTables*/ ) throw (script::BasicErrorException, uno::RuntimeException)
57 : : {
58 : : // #FIXME the helper api uses the dreaded dispatch mechanism, holding off
59 : : // implementation while I look for alternative solution
60 [ # # ]: 0 : throw uno::RuntimeException();
61 : : }
62 : :
63 : : rtl::OUString SAL_CALL
64 : 0 : SwVbaTable::getName() throw (uno::RuntimeException)
65 : : {
66 [ # # ]: 0 : uno::Reference< container::XNamed > xNamed( mxTextTable, uno::UNO_QUERY_THROW );
67 [ # # ][ # # ]: 0 : return xNamed->getName();
68 : : }
69 : :
70 : : uno::Any SAL_CALL
71 : 0 : SwVbaTable::Borders( const uno::Any& index ) throw (uno::RuntimeException)
72 : : {
73 [ # # ]: 0 : uno::Reference< table::XCellRange > aCellRange( mxTextTable, uno::UNO_QUERY_THROW );
74 [ # # ]: 0 : VbaPalette aPalette;
75 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xCol( new SwVbaBorders( this, mxContext, aCellRange, aPalette ) );
[ # # ][ # # ]
76 [ # # ]: 0 : if ( index.hasValue() )
77 [ # # ][ # # ]: 0 : return xCol->Item( index, uno::Any() );
78 [ # # ][ # # ]: 0 : return uno::makeAny( xCol );
79 : : }
80 : :
81 : : uno::Any SAL_CALL
82 : 0 : SwVbaTable::Rows( const uno::Any& index ) throw (uno::RuntimeException)
83 : : {
84 [ # # ][ # # ]: 0 : uno::Reference< table::XTableRows > xTableRows( mxTextTable->getRows(), uno::UNO_QUERY_THROW );
[ # # ]
85 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xCol( new SwVbaRows( this, mxContext, mxTextTable, xTableRows ) );
[ # # ][ # # ]
86 [ # # ]: 0 : if ( index.hasValue() )
87 [ # # ][ # # ]: 0 : return xCol->Item( index, uno::Any() );
88 [ # # ]: 0 : return uno::makeAny( xCol );
89 : : }
90 : :
91 : : uno::Any SAL_CALL
92 : 0 : SwVbaTable::Columns( const uno::Any& index ) throw (uno::RuntimeException)
93 : : {
94 [ # # ][ # # ]: 0 : uno::Reference< table::XTableColumns > xTableColumns( mxTextTable->getColumns(), uno::UNO_QUERY_THROW );
[ # # ]
95 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xCol( new SwVbaColumns( this, mxContext, mxTextTable, xTableColumns ) );
[ # # ][ # # ]
96 [ # # ]: 0 : if ( index.hasValue() )
97 [ # # ][ # # ]: 0 : return xCol->Item( index, uno::Any() );
98 [ # # ]: 0 : return uno::makeAny( xCol );
99 : : }
100 : :
101 : : // XHelperInterface
102 : : rtl::OUString
103 : 0 : SwVbaTable::getServiceImplName()
104 : : {
105 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaTable"));
106 : : }
107 : :
108 : : uno::Sequence<rtl::OUString>
109 : 0 : SwVbaTable::getServiceNames()
110 : : {
111 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
112 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
113 : : {
114 : 0 : aServiceNames.realloc( 1 );
115 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Table" ) );
116 : : }
117 : 0 : return aServiceNames;
118 : : }
119 : :
120 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|