1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: vbapane.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include<com/sun/star/table/CellRangeAddress.hpp>
33 using namespace com::sun::star
;
34 using namespace ooo::vba
;
37 ScVbaPane::ScVbaPane( uno::Reference< uno::XComponentContext > xContext, uno::Refrence< sheet::XViewPane > xViewPane )
38 : m_xContext( xContext ), m_xViewPane( xViewPane )
44 ScVbaPane::getScrollColumn() throw (uno::RuntimeException
)
46 return ( m_xViewPane
->getFirstVisibleColumn() + 1 );
50 ScVbaPane::setScrollColumn( sal_Int32 _scrollcolumn
) throw (uno::RuntimeException
)
52 if( _scrollcolumn
< 1 )
54 throw uno::RuntimeException( rtl::OUString::createFromAscii( "Column number should not less than 1" ),
55 uno::Reference
< uno::XInterface
>() );
57 m_xViewPane
->setFirstVisibleColumn( _scrollcolumn
- 1 );
61 ScVbaPane::getScrollRow() throw (uno::RuntimeException
)
63 return ( m_xViewPane
->getFirstVisibleRow() + 1 );
67 ScVbaPane::setScrollRow( sal_Int32 _scrollrow
) throw (uno::RuntimeException
)
71 throw uno::RuntimeException( rtl::OUString::createFromAscii( "Row number should not less than 1" ),
72 uno::Reference
< uno::XInterface
>() );
74 m_xViewPane
->setFirstVisibleRow( _scrollrow
- 1 );
79 ScVbaPane::SmallScroll( const uno::Any
& Down
, const uno::Any
& Up
, const uno::Any
& ToRight
, const uno::Any
& ToLeft
) throw (uno::RuntimeException
)
81 rtl::OUString messageBuffer
;
82 sal_Int32 downRows
= 0;
83 sal_Int32 rightCols
= 0;
84 table::CellRangeAddress visibleRange
= m_xViewPane
->getVisibleRange();
94 catch ( uno::Exception
)
96 messageBuffer
+= rtl::OUString::createFromAscii( "Error getting parameter: Down\n" );
107 catch ( uno::Exception
)
109 messageBuffer
+= rtl::OUString::createFromAscii( "Error getting parameter: Up\n" );
112 if( ToRight
.hasValue() )
120 catch ( uno::Exception
)
122 messageBuffer
+= rtl::OUString::createFromAscii( "Error getting parameter: ToRight\n" );
125 if( ToLeft
.hasValue() )
133 catch ( uno::Exception
)
135 messageBuffer
+= rtl::OUString::createFromAscii( "Error getting parameter: ToLeft\n" );
138 if( messageBuffer
.getLength() > 0 )
139 throw(uno::RuntimeException( messageBuffer
, uno::Reference
< uno::XInterface
>() ) );
141 sal_Int32 newStartRow
= visibleRange
.StartRow
+ downRows
;
142 if( newStartRow
< 0 )
144 sal_Int32 newStartCol
= visibleRange
.StartColumn
+ rightCols
;
145 if( newStartCol
< 0 )
147 m_xViewPane
->setFirstVisibleRow( newStartRow
);
148 m_xViewPane
->setFirstVisibleColumn( newStartCol
);
152 ScVbaPane::LargeScroll( const uno::Any
& Down
, const uno::Any
& Up
, const uno::Any
& ToRight
, const uno::Any
& ToLeft
) throw (uno::RuntimeException
)
154 rtl::OUString messageBuffer
;
155 table::CellRangeAddress visibleRange
= m_xViewPane
->getVisibleRange();
157 sal_Int32 vertPageSize
= 1 + visibleRange
.EndRow
- visibleRange
.StartRow
;
158 sal_Int32 horizPageSize
= 1 + visibleRange
.EndColumn
- visibleRange
.StartColumn
;
159 sal_Int32 downPages
= 0;
160 sal_Int32 acrossPages
= 0;
161 if( Down
.hasValue() )
169 catch ( uno::Exception
)
171 messageBuffer
+= rtl::OUString::createFromAscii( "Error getting parameter: Down\n" );
182 catch ( uno::Exception
)
184 messageBuffer
+= rtl::OUString::createFromAscii( "Error getting parameter: Up\n" );
187 if( ToRight
.hasValue() )
193 acrossPages
+= right
;
195 catch ( uno::Exception
)
197 messageBuffer
+= rtl::OUString::createFromAscii( "Error getting parameter: ToRight\n" );
200 if( ToLeft
.hasValue() )
208 catch ( uno::Exception
)
210 messageBuffer
+= rtl::OUString::createFromAscii( "Error getting parameter: ToLeft\n" );
214 if( messageBuffer
.getLength() > 0 )
215 throw(uno::RuntimeException( messageBuffer
, uno::Reference
< uno::XInterface
>() ) );
217 sal_Int32 newStartRow
= visibleRange
.StartRow
+ (downPages
* vertPageSize
);
218 if( newStartRow
< 0 )
220 sal_Int32 newStartCol
= visibleRange
.StartColumn
+ (acrossPages
* horizPageSize
);
221 if( newStartCol
< 0 )
223 m_xViewPane
->setFirstVisibleRow( newStartRow
);
224 m_xViewPane
->setFirstVisibleColumn( newStartCol
);