xref: /aoo42x/main/svx/source/table/cellcursor.hxx (revision 3334a7e6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVX_CELLCURSOR_HXX_
25 #define _SVX_CELLCURSOR_HXX_
26 
27 #include <com/sun/star/table/XMergeableCellRange.hpp>
28 #include <com/sun/star/table/XCellCursor.hpp>
29 #include <cppuhelper/implbase2.hxx>
30 #include "cellrange.hxx"
31 
32 // -----------------------------------------------------------------------------
33 
34 namespace sdr { namespace table {
35 
36 struct CellPos;
37 
38 // -----------------------------------------------------------------------------
39 // CellCursor
40 // -----------------------------------------------------------------------------
41 
42 typedef ::cppu::ImplInheritanceHelper2< CellRange, ::com::sun::star::table::XCellCursor, ::com::sun::star::table::XMergeableCellRange > CellCursorBase;
43 
44 class CellCursor : public CellCursorBase
45 {
46 public:
47 	CellCursor( const TableModelRef& xTableModel, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom );
48 	virtual ~CellCursor();
49 
50 	// XCellRange
51 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
52     virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
53 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByName( const ::rtl::OUString& aRange ) throw (::com::sun::star::uno::RuntimeException);
54 
55 	// XCellCursor
56     virtual void SAL_CALL gotoStart(  ) throw (::com::sun::star::uno::RuntimeException);
57     virtual void SAL_CALL gotoEnd(  ) throw (::com::sun::star::uno::RuntimeException);
58     virtual void SAL_CALL gotoNext(  ) throw (::com::sun::star::uno::RuntimeException);
59     virtual void SAL_CALL gotoPrevious(  ) throw (::com::sun::star::uno::RuntimeException);
60     virtual void SAL_CALL gotoOffset( ::sal_Int32 nColumnOffset, ::sal_Int32 nRowOffset ) throw (::com::sun::star::uno::RuntimeException);
61 
62     // XMergeableCellRange
63     virtual void SAL_CALL merge(  ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
64     virtual void SAL_CALL split( ::sal_Int32 Columns, ::sal_Int32 Rows ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
65     virtual ::sal_Bool SAL_CALL isMergeable(  ) throw (::com::sun::star::uno::RuntimeException);
66     virtual ::sal_Bool SAL_CALL isUnmergeable(  ) throw (::com::sun::star::uno::RuntimeException);
67 
68 protected:
69 	bool GetMergedSelection( CellPos& rStart, CellPos& rEnd );
70 
71 	void split_column( sal_Int32 nCol, sal_Int32 nColumns, std::vector< sal_Int32 >& rLeftOvers );
72 	void split_horizontal( sal_Int32 nColumns );
73 	void split_row( sal_Int32 nRow, sal_Int32 nRows, std::vector< sal_Int32 >& rLeftOvers );
74 	void split_vertical( sal_Int32 nRows );
75 };
76 
77 } }
78 
79 #endif
80