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: selectionstate.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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
33 #include "selectionstate.hxx"
35 #include <svx/editview.hxx>
36 #include "viewdata.hxx"
38 // ============================================================================
40 ScSelectionState::ScSelectionState( ScViewData
& rViewData
) :
41 meType( SC_SELECTTYPE_NONE
)
43 maCursor
.SetTab( rViewData
.GetTabNo() );
44 ScSplitPos eWhich
= rViewData
.GetActivePart();
46 if( rViewData
.HasEditView( eWhich
) )
48 meType
= SC_SELECTTYPE_EDITCELL
;
49 maCursor
.SetCol( rViewData
.GetEditViewCol() );
50 maCursor
.SetRow( rViewData
.GetEditViewRow() );
51 maEditSel
= rViewData
.GetEditView( eWhich
)->GetSelection();
55 maCursor
.SetCol( rViewData
.GetCurX() );
56 maCursor
.SetRow( rViewData
.GetCurY() );
58 ScMarkData
& rMarkData
= rViewData
.GetMarkData();
59 rMarkData
.MarkToMulti();
60 if( rMarkData
.IsMultiMarked() )
62 meType
= SC_SELECTTYPE_SHEET
;
63 rMarkData
.FillRangeListWithMarks( &maSheetSel
, FALSE
);
65 // else type is SC_SELECTTYPE_NONE - already initialized
69 bool operator==( const ScSelectionState
& rL
, const ScSelectionState
& rR
)
71 bool bEqual
= rL
.GetSelectionType() == rR
.GetSelectionType();
72 if( bEqual
) switch( rL
.GetSelectionType() )
74 case SC_SELECTTYPE_EDITCELL
:
75 bEqual
&= ( rL
.GetEditSelection().IsEqual( rR
.GetEditSelection() ) != FALSE
);
77 case SC_SELECTTYPE_SHEET
:
78 bEqual
&= (rL
.GetSheetSelection() == rR
.GetSheetSelection()) == TRUE
;
80 case SC_SELECTTYPE_NONE
:
81 bEqual
&= rL
.GetCellCursor() == rR
.GetCellCursor();
85 // added to avoid warnings
91 // ============================================================================