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 "vbacolumns.hxx"
29 : : #include "vbacolumn.hxx"
30 : : #include <com/sun/star/text/HoriOrientation.hpp>
31 : : #include <com/sun/star/table/XCellRange.hpp>
32 : : #include <ooo/vba/word/WdConstants.hpp>
33 : : #include <ooo/vba/word/WdRulerStyle.hpp>
34 : : #include "wordvbahelper.hxx"
35 : : #include "vbatablehelper.hxx"
36 : :
37 : : using namespace ::ooo::vba;
38 : : using namespace ::com::sun::star;
39 : :
40 [ # # ][ # # ]: 0 : class ColumnsEnumWrapper : public EnumerationHelper_BASE
41 : : {
42 : : uno::WeakReference< XHelperInterface > mxParent;
43 : : uno::Reference< uno::XComponentContext > mxContext;
44 : : uno::Reference< text::XTextTable > mxTextTable;
45 : : uno::Reference< container::XIndexAccess > mxIndexAccess;
46 : : sal_Int32 nIndex;
47 : :
48 : : public:
49 [ # # ]: 0 : ColumnsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< text::XTextTable >& xTextTable ) : mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), nIndex( 0 )
50 : : {
51 [ # # ][ # # ]: 0 : mxIndexAccess.set( mxTextTable->getColumns(), uno::UNO_QUERY );
[ # # ]
52 : 0 : }
53 : 0 : virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
54 : : {
55 : 0 : return ( nIndex < mxIndexAccess->getCount() );
56 : : }
57 : :
58 : 0 : virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
59 : : {
60 [ # # ]: 0 : if( nIndex < mxIndexAccess->getCount() )
61 : : {
62 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XColumn > ( new SwVbaColumn( mxParent, mxContext, mxTextTable, nIndex++ ) ) );
[ # # ][ # # ]
63 : : }
64 [ # # ]: 0 : throw container::NoSuchElementException();
65 : : }
66 : : };
67 : :
68 [ # # ]: 0 : SwVbaColumns::SwVbaColumns( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableColumns >& xTableColumns ) throw (uno::RuntimeException) : SwVbaColumns_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableColumns, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableColumns( xTableColumns )
69 : : {
70 : 0 : mnStartColumnIndex = 0;
71 [ # # ]: 0 : SwVbaTableHelper aTableHelper( mxTextTable );
72 [ # # ][ # # ]: 0 : mnEndColumnIndex = aTableHelper.getTabColumnsMaxCount( ) - 1;
73 : 0 : }
74 : :
75 [ # # ]: 0 : SwVbaColumns::SwVbaColumns( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableColumns >& xTableColumns, sal_Int32 nStartCol, sal_Int32 nEndCol ) throw (uno::RuntimeException) : SwVbaColumns_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableColumns, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableColumns( xTableColumns ), mnStartColumnIndex( nStartCol ), mnEndColumnIndex( nEndCol )
76 : : {
77 [ # # ]: 0 : if( mnEndColumnIndex < mnStartColumnIndex )
78 [ # # ]: 0 : throw uno::RuntimeException();
79 : 0 : }
80 : :
81 : 0 : uno::Reference< word::XColumn > SwVbaColumns::getColumnAtIndex( sal_Int32 index ) throw (uno::RuntimeException)
82 : : {
83 [ # # ][ # # ]: 0 : return uno::Reference< word::XColumn >( new SwVbaColumn( this, mxContext, mxTextTable, index ) );
[ # # ]
84 : : }
85 : :
86 : 0 : ::sal_Int32 SAL_CALL SwVbaColumns::getWidth() throw (uno::RuntimeException)
87 : : {
88 [ # # ][ # # ]: 0 : return getColumnAtIndex( mnStartColumnIndex )->getWidth();
89 : : }
90 : :
91 : 0 : void SAL_CALL SwVbaColumns::setWidth( ::sal_Int32 _width ) throw (uno::RuntimeException)
92 : : {
93 [ # # ]: 0 : for( sal_Int32 index = mnStartColumnIndex; index <= mnEndColumnIndex; index++ )
94 : : {
95 [ # # ][ # # ]: 0 : getColumnAtIndex( index )->setWidth( _width );
96 : : }
97 : 0 : }
98 : :
99 : 0 : void SAL_CALL SwVbaColumns::Select( ) throw (uno::RuntimeException)
100 : : {
101 [ # # ]: 0 : SwVbaColumn::SelectColumn( getCurrentWordDoc(mxContext), mxTextTable, mnStartColumnIndex, mnEndColumnIndex );
102 : 0 : }
103 : :
104 : 0 : ::sal_Int32 SAL_CALL SwVbaColumns::getCount() throw (uno::RuntimeException)
105 : : {
106 : 0 : return ( mnEndColumnIndex - mnStartColumnIndex + 1 );
107 : : }
108 : :
109 : 0 : uno::Any SAL_CALL SwVbaColumns::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
110 : : {
111 : 0 : sal_Int32 nIndex = 0;
112 [ # # ]: 0 : if( ( Index1 >>= nIndex ) == sal_True )
113 : : {
114 [ # # ][ # # ]: 0 : if( nIndex <= 0 || nIndex > getCount() )
[ # # ][ # # ]
115 : : {
116 [ # # ][ # # ]: 0 : throw lang::IndexOutOfBoundsException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
117 : : }
118 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XColumn >( new SwVbaColumn( this, mxContext, mxTextTable, nIndex - 1 ) ) );
[ # # ][ # # ]
[ # # ]
119 : : }
120 [ # # ][ # # ]: 0 : throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
121 : : }
122 : :
123 : : // XEnumerationAccess
124 : : uno::Type
125 : 0 : SwVbaColumns::getElementType() throw (uno::RuntimeException)
126 : : {
127 : 0 : return word::XColumn::static_type(0);
128 : : }
129 : : uno::Reference< container::XEnumeration >
130 : 0 : SwVbaColumns::createEnumeration() throw (uno::RuntimeException)
131 : : {
132 [ # # ][ # # ]: 0 : return new ColumnsEnumWrapper( this, mxContext, mxTextTable );
[ # # ]
133 : : }
134 : :
135 : : uno::Any
136 : 0 : SwVbaColumns::createCollectionObject( const uno::Any& aSource )
137 : : {
138 : 0 : return aSource;
139 : : }
140 : :
141 : : rtl::OUString
142 : 0 : SwVbaColumns::getServiceImplName()
143 : : {
144 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaColumns"));
145 : : }
146 : :
147 : : uno::Sequence<rtl::OUString>
148 : 0 : SwVbaColumns::getServiceNames()
149 : : {
150 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > sNames;
[ # # ][ # # ]
151 [ # # ]: 0 : if ( sNames.getLength() == 0 )
152 : : {
153 : 0 : sNames.realloc( 1 );
154 [ # # ]: 0 : sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Columns") );
155 : : }
156 : 0 : return sNames;
157 : : }
158 : :
159 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|