Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "vbacolumn.hxx"
29 : : #include <vbahelper/vbahelper.hxx>
30 : : #include <tools/diagnose_ex.h>
31 : : #include "vbatable.hxx"
32 : : #include <com/sun/star/table/XCellRange.hpp>
33 : : #include <com/sun/star/view/XSelectionSupplier.hpp>
34 : : #include <rtl/ustrbuf.hxx>
35 : : #include "wordvbahelper.hxx"
36 : : #include "vbatablehelper.hxx"
37 : :
38 : : using namespace ::ooo::vba;
39 : : using namespace ::com::sun::star;
40 : :
41 : 0 : SwVbaColumn::SwVbaColumn( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( uno::RuntimeException ) :
42 : 0 : SwVbaColumn_BASE( rParent, rContext ), mxTextTable( xTextTable ), mnIndex( nIndex )
43 : : {
44 [ # # ][ # # ]: 0 : mxTableColumns = mxTextTable->getColumns();
[ # # ]
45 : 0 : }
46 : :
47 : 0 : SwVbaColumn::~SwVbaColumn()
48 : : {
49 [ # # ]: 0 : }
50 : :
51 : : sal_Int32 SAL_CALL
52 : 0 : SwVbaColumn::getWidth( ) throw ( css::uno::RuntimeException )
53 : : {
54 [ # # ]: 0 : SwVbaTableHelper aTableHelper( mxTextTable );
55 [ # # ][ # # ]: 0 : return aTableHelper.GetColWidth( mnIndex );
56 : : }
57 : :
58 : : void SAL_CALL
59 : 0 : SwVbaColumn::setWidth( sal_Int32 _width ) throw ( css::uno::RuntimeException )
60 : : {
61 : :
62 [ # # ]: 0 : SwVbaTableHelper aTableHelper( mxTextTable );
63 [ # # ][ # # ]: 0 : aTableHelper.SetColWidth( _width, mnIndex );
64 : 0 : }
65 : :
66 : : void SAL_CALL
67 : 0 : SwVbaColumn::Select( ) throw ( uno::RuntimeException )
68 : : {
69 [ # # ]: 0 : SelectColumn( getCurrentWordDoc(mxContext), mxTextTable, mnIndex, mnIndex );
70 : 0 : }
71 : :
72 : 0 : void SwVbaColumn::SelectColumn( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn ) throw ( uno::RuntimeException )
73 : : {
74 : 0 : rtl::OUStringBuffer aRangeName;
75 [ # # ]: 0 : rtl::OUString sStartCol = SwVbaTableHelper::getColumnStr( nStartColumn );
76 [ # # ][ # # ]: 0 : aRangeName.append(sStartCol).append(sal_Int32( 1 ) );
77 [ # # ]: 0 : rtl::OUString sEndCol = SwVbaTableHelper::getColumnStr( nEndColumn );
78 [ # # ][ # # ]: 0 : sal_Int32 nRowCount = xTextTable->getRows()->getCount();
[ # # ][ # # ]
79 [ # # ][ # # ]: 0 : aRangeName.append(':').append( sEndCol ).append( sal_Int32( nRowCount ) );
[ # # ]
80 : :
81 [ # # ]: 0 : uno::Reference< table::XCellRange > xCellRange( xTextTable, uno::UNO_QUERY_THROW );
82 [ # # ]: 0 : rtl::OUString sSelRange = aRangeName.makeStringAndClear();
83 [ # # ][ # # ]: 0 : uno::Reference< table::XCellRange > xSelRange = xCellRange->getCellRangeByName( sSelRange );
84 : :
85 [ # # ][ # # ]: 0 : uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
[ # # ]
86 [ # # ][ # # ]: 0 : xSelection->select( uno::makeAny( xSelRange ) );
[ # # ]
87 : 0 : }
88 : :
89 : : rtl::OUString
90 : 0 : SwVbaColumn::getServiceImplName()
91 : : {
92 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaColumn"));
93 : : }
94 : :
95 : : uno::Sequence< rtl::OUString >
96 : 0 : SwVbaColumn::getServiceNames()
97 : : {
98 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
99 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
100 : : {
101 : 0 : aServiceNames.realloc( 1 );
102 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Column" ) );
103 : : }
104 : 0 : return aServiceNames;
105 : : }
106 : :
107 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|