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 2000, 2010 Oracle and/or its affiliates.
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 : :
29 : : #include "vbapane.hxx"
30 : : #include <com/sun/star/sheet/XSpreadsheet.hpp>
31 : : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
32 : : #include <com/sun/star/table/CellRangeAddress.hpp>
33 : : #include "vbarange.hxx"
34 : :
35 : : using namespace com::sun::star;
36 : : using namespace ooo::vba;
37 : :
38 : 0 : ScVbaPane::ScVbaPane(
39 : : const css::uno::Reference< ov::XHelperInterface >& xParent,
40 : : const uno::Reference< uno::XComponentContext >& xContext,
41 : : const uno::Reference< frame::XModel >& xModel,
42 : : const uno::Reference< sheet::XViewPane > xViewPane ) throw (uno::RuntimeException) :
43 : : ScVbaPane_BASE( xParent, xContext ),
44 : : m_xModel( xModel, uno::UNO_SET_THROW ),
45 [ # # ][ # # ]: 0 : m_xViewPane( xViewPane, uno::UNO_SET_THROW )
46 : : {
47 : 0 : }
48 : :
49 : : sal_Int32 SAL_CALL
50 : 0 : ScVbaPane::getScrollColumn() throw (uno::RuntimeException)
51 : : {
52 : 0 : return ( m_xViewPane->getFirstVisibleColumn() + 1 );
53 : : }
54 : :
55 : : void SAL_CALL
56 : 0 : ScVbaPane::setScrollColumn( sal_Int32 _scrollcolumn ) throw (uno::RuntimeException)
57 : : {
58 [ # # ]: 0 : if( _scrollcolumn < 1 )
59 : : {
60 : : throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Column number should not less than 1" )),
61 [ # # ][ # # ]: 0 : uno::Reference< uno::XInterface >() );
62 : : }
63 : 0 : m_xViewPane->setFirstVisibleColumn( _scrollcolumn - 1 );
64 : 0 : }
65 : :
66 : : sal_Int32 SAL_CALL
67 : 0 : ScVbaPane::getScrollRow() throw (uno::RuntimeException)
68 : : {
69 : 0 : return ( m_xViewPane->getFirstVisibleRow() + 1 );
70 : : }
71 : :
72 : : void SAL_CALL
73 : 0 : ScVbaPane::setScrollRow( sal_Int32 _scrollrow ) throw (uno::RuntimeException)
74 : : {
75 [ # # ]: 0 : if( _scrollrow < 1 )
76 : : {
77 : : throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Row number should not less than 1" )),
78 [ # # ][ # # ]: 0 : uno::Reference< uno::XInterface >() );
79 : : }
80 : 0 : m_xViewPane->setFirstVisibleRow( _scrollrow - 1 );
81 : 0 : }
82 : :
83 : : uno::Reference< excel::XRange > SAL_CALL
84 : 0 : ScVbaPane::getVisibleRange() throw (uno::RuntimeException)
85 : : {
86 : : // TODO: Excel includes partly visible rows/columns, Calc does not
87 [ # # ][ # # ]: 0 : table::CellRangeAddress aRangeAddr = m_xViewPane->getVisibleRange();
88 [ # # ]: 0 : uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xModel, uno::UNO_QUERY_THROW );
89 [ # # ][ # # ]: 0 : uno::Reference< container::XIndexAccess > xSheetsIA( xDoc->getSheets(), uno::UNO_QUERY_THROW );
[ # # ]
90 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xSheet( xSheetsIA->getByIndex( aRangeAddr.Sheet ), uno::UNO_QUERY_THROW );
[ # # ]
91 [ # # ][ # # ]: 0 : uno::Reference< table::XCellRange > xRange( xSheet->getCellRangeByPosition( aRangeAddr.StartColumn, aRangeAddr.StartRow, aRangeAddr.EndColumn, aRangeAddr.EndRow ), uno::UNO_SET_THROW );
[ # # ]
92 : : // TODO: getParent() returns the window, Range needs the worksheet
93 [ # # ][ # # ]: 0 : return new ScVbaRange( getParent(), mxContext, xRange );
[ # # ][ # # ]
94 : : }
95 : :
96 : : //Method
97 : : void SAL_CALL
98 : 0 : ScVbaPane::SmallScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
99 : : {
100 : 0 : rtl::OUString messageBuffer;
101 : 0 : sal_Int32 downRows = 0;
102 : 0 : sal_Int32 rightCols = 0;
103 [ # # ][ # # ]: 0 : table::CellRangeAddress visibleRange = m_xViewPane->getVisibleRange();
104 : :
105 [ # # ]: 0 : if( Down.hasValue() )
106 : : {
107 : 0 : sal_Int32 down = 0;
108 [ # # ]: 0 : if( Down >>= down )
109 : 0 : downRows += down;
110 : : else
111 [ # # ]: 0 : messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: Down\n" ));
112 : : }
113 [ # # ]: 0 : if( Up.hasValue() )
114 : : {
115 : 0 : sal_Int32 up = 0;
116 [ # # ]: 0 : if( Up >>= up )
117 : 0 : downRows -= up;
118 : : else
119 [ # # ]: 0 : messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: Up\n" ));
120 : : }
121 [ # # ]: 0 : if( ToRight.hasValue() )
122 : : {
123 : 0 : sal_Int32 right = 0;
124 [ # # ]: 0 : if( ToRight >>= right )
125 : 0 : rightCols += right;
126 : : else
127 [ # # ]: 0 : messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: ToRight\n" ));
128 : : }
129 [ # # ]: 0 : if( ToLeft.hasValue() )
130 : : {
131 : 0 : sal_Int32 left = 0;
132 [ # # ]: 0 : if( ToLeft >>= left )
133 : 0 : rightCols -= left;
134 : : else
135 [ # # ]: 0 : messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: ToLeft\n" ));
136 : : }
137 [ # # ]: 0 : if( !messageBuffer.isEmpty() )
138 [ # # ]: 0 : throw(uno::RuntimeException( messageBuffer, uno::Reference< uno::XInterface >() ) );
139 : :
140 : 0 : sal_Int32 newStartRow = visibleRange.StartRow + downRows;
141 [ # # ]: 0 : if( newStartRow < 0 )
142 : 0 : newStartRow = 0;
143 : 0 : sal_Int32 newStartCol = visibleRange.StartColumn + rightCols;
144 [ # # ]: 0 : if( newStartCol < 0 )
145 : 0 : newStartCol = 0;
146 [ # # ][ # # ]: 0 : m_xViewPane->setFirstVisibleRow( newStartRow );
147 [ # # ][ # # ]: 0 : m_xViewPane->setFirstVisibleColumn( newStartCol );
148 : 0 : }
149 : :
150 : : void SAL_CALL
151 : 0 : ScVbaPane::LargeScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
152 : : {
153 : 0 : rtl::OUString messageBuffer;
154 [ # # ][ # # ]: 0 : table::CellRangeAddress visibleRange = m_xViewPane->getVisibleRange();
155 : :
156 : 0 : sal_Int32 vertPageSize = 1 + visibleRange.EndRow - visibleRange.StartRow;
157 : 0 : sal_Int32 horizPageSize = 1 + visibleRange.EndColumn - visibleRange.StartColumn;
158 : 0 : sal_Int32 downPages = 0;
159 : 0 : sal_Int32 acrossPages = 0;
160 [ # # ]: 0 : if( Down.hasValue() )
161 : : {
162 : 0 : sal_Int32 down = 0;
163 [ # # ]: 0 : if( Down >>= down )
164 : 0 : downPages += down;
165 : : else
166 [ # # ]: 0 : messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: Down\n" ));
167 : : }
168 [ # # ]: 0 : if( Up.hasValue() )
169 : : {
170 : 0 : sal_Int32 up = 0;
171 [ # # ]: 0 : if( Up >>= up )
172 : 0 : downPages -= up;
173 : : else
174 [ # # ]: 0 : messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: Up\n" ));
175 : : }
176 [ # # ]: 0 : if( ToRight.hasValue() )
177 : : {
178 : 0 : sal_Int32 right = 0;
179 [ # # ]: 0 : if( ToRight >>= right )
180 : 0 : acrossPages += right;
181 : : else
182 [ # # ]: 0 : messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: ToRight\n" ));
183 : : }
184 [ # # ]: 0 : if( ToLeft.hasValue() )
185 : : {
186 : 0 : sal_Int32 left = 0;
187 [ # # ]: 0 : if( ToLeft >>= left )
188 : 0 : acrossPages -= left;
189 : : else
190 [ # # ]: 0 : messageBuffer += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Error getting parameter: ToLeft\n" ));
191 : : }
192 [ # # ]: 0 : if( !messageBuffer.isEmpty() )
193 [ # # ]: 0 : throw(uno::RuntimeException( messageBuffer, uno::Reference< uno::XInterface >() ) );
194 : :
195 : 0 : sal_Int32 newStartRow = visibleRange.StartRow + (downPages * vertPageSize );
196 [ # # ]: 0 : if( newStartRow < 0 )
197 : 0 : newStartRow = 0;
198 : 0 : sal_Int32 newStartCol = visibleRange.StartColumn + (acrossPages * horizPageSize );
199 [ # # ]: 0 : if( newStartCol < 0 )
200 : 0 : newStartCol = 0;
201 [ # # ][ # # ]: 0 : m_xViewPane->setFirstVisibleRow( newStartRow );
202 [ # # ][ # # ]: 0 : m_xViewPane->setFirstVisibleColumn( newStartCol );
203 : 0 : }
204 : :
205 : : // XHelperInterface
206 : :
207 [ # # ][ # # ]: 0 : VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaPane, "ooo.vba.excel.Pane" )
[ # # ][ # # ]
[ # # ][ # # ]
208 : :
209 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|