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 SC_SELECTIONSTATE_HXX
25 #define SC_SELECTIONSTATE_HXX
26
27 #include <editeng/editdata.hxx>
28 #include "rangelst.hxx"
29
30 // ============================================================================
31
32 /** Enumerates all possible types of selections in a Calc document. */
33 enum ScSelectionType
34 {
35 SC_SELECTTYPE_NONE, /// No selection, simple cell cursor.
36 SC_SELECTTYPE_SHEET, /// Single cell, cell range, or multi range selection.
37 SC_SELECTTYPE_EDITCELL, /// Cell in edit mode (with or without selection).
38 SC_SELECTTYPE_DRAWING, /// One or more drawing objects.
39 SC_SELECTTYPE_EDITDRAW /// Edit mode in drawing object (with or without selection).
40 };
41
42 // ----------------------------------------------------------------------------
43
44 class ScViewData;
45
46 /** Contains all available data about any possible selection in a Calc document. */
47 class ScSelectionState
48 {
49 public:
50 explicit ScSelectionState( ScViewData& rViewData );
51
52 /** Returns the type of the selection this object contains. */
GetSelectionType() const53 inline ScSelectionType GetSelectionType() const { return meType; }
54
55 /** Returns the position of the cell cursor. */
GetCellCursor() const56 inline const ScAddress& GetCellCursor() const { return maCursor; }
57 /** Returns a range list containing all selected cell ranges. */
GetSheetSelection() const58 inline const ScRangeList& GetSheetSelection() const { return maSheetSel; }
59 /** Returns the edit engine selection. */
GetEditSelection() const60 inline const ESelection& GetEditSelection() const { return maEditSel; }
61
62 private:
63 ScSelectionType meType; /// Type of the selection.
64 ScAddress maCursor; /// Cell cursor position.
65 ScRangeList maSheetSel; /// Sheet selection.
66 ESelection maEditSel; /// Selection in edit mode.
67 };
68
69 bool operator==( const ScSelectionState& rL, const ScSelectionState& rR );
operator !=(const ScSelectionState & rL,const ScSelectionState & rR)70 inline bool operator!=( const ScSelectionState& rL, const ScSelectionState& rR ) { return !(rL == rR); }
71
72 // ============================================================================
73
74 #endif
75
76