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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sc.hxx" 26 #include "selectionstate.hxx" 27 28 #include <editeng/editview.hxx> 29 #include "viewdata.hxx" 30 31 // ============================================================================ 32 ScSelectionState(ScViewData & rViewData)33ScSelectionState::ScSelectionState( ScViewData& rViewData ) : 34 meType( SC_SELECTTYPE_NONE ) 35 { 36 maCursor.SetTab( rViewData.GetTabNo() ); 37 ScSplitPos eWhich = rViewData.GetActivePart(); 38 39 if( rViewData.HasEditView( eWhich ) ) 40 { 41 meType = SC_SELECTTYPE_EDITCELL; 42 maCursor.SetCol( rViewData.GetEditViewCol() ); 43 maCursor.SetRow( rViewData.GetEditViewRow() ); 44 maEditSel = rViewData.GetEditView( eWhich )->GetSelection(); 45 } 46 else 47 { 48 maCursor.SetCol( rViewData.GetCurX() ); 49 maCursor.SetRow( rViewData.GetCurY() ); 50 51 ScMarkData& rMarkData = rViewData.GetMarkData(); 52 rMarkData.MarkToMulti(); 53 if( rMarkData.IsMultiMarked() ) 54 { 55 meType = SC_SELECTTYPE_SHEET; 56 rMarkData.FillRangeListWithMarks( &maSheetSel, sal_False ); 57 } 58 // else type is SC_SELECTTYPE_NONE - already initialized 59 } 60 } 61 operator ==(const ScSelectionState & rL,const ScSelectionState & rR)62bool operator==( const ScSelectionState& rL, const ScSelectionState& rR ) 63 { 64 bool bEqual = rL.GetSelectionType() == rR.GetSelectionType(); 65 if( bEqual ) switch( rL.GetSelectionType() ) 66 { 67 case SC_SELECTTYPE_EDITCELL: 68 bEqual &= ( rL.GetEditSelection().IsEqual( rR.GetEditSelection() ) != sal_False ); 69 // run through! 70 case SC_SELECTTYPE_SHEET: 71 bEqual &= (rL.GetSheetSelection() == rR.GetSheetSelection()) == sal_True; 72 // run through! 73 case SC_SELECTTYPE_NONE: 74 bEqual &= rL.GetCellCursor() == rR.GetCellCursor(); 75 break; 76 default: 77 { 78 // added to avoid warnings 79 } 80 } 81 return bEqual; 82 } 83 84 // ============================================================================ 85 86