Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "selectionstate.hxx"
30 : :
31 : : #include <editeng/editview.hxx>
32 : : #include "viewdata.hxx"
33 : : #include "markdata.hxx"
34 : :
35 : : // ============================================================================
36 : :
37 : 0 : ScSelectionState::ScSelectionState( ScViewData& rViewData ) :
38 : 0 : meType( SC_SELECTTYPE_NONE )
39 : : {
40 : 0 : maCursor.SetTab( rViewData.GetTabNo() );
41 : 0 : ScSplitPos eWhich = rViewData.GetActivePart();
42 : :
43 [ # # ]: 0 : if( rViewData.HasEditView( eWhich ) )
44 : : {
45 : 0 : meType = SC_SELECTTYPE_EDITCELL;
46 : 0 : maCursor.SetCol( rViewData.GetEditViewCol() );
47 : 0 : maCursor.SetRow( rViewData.GetEditViewRow() );
48 [ # # ]: 0 : maEditSel = rViewData.GetEditView( eWhich )->GetSelection();
49 : : }
50 : : else
51 : : {
52 : 0 : maCursor.SetCol( rViewData.GetCurX() );
53 : 0 : maCursor.SetRow( rViewData.GetCurY() );
54 : :
55 [ # # ]: 0 : ScMarkData& rMarkData = rViewData.GetMarkData();
56 [ # # ]: 0 : rMarkData.MarkToMulti();
57 [ # # ]: 0 : if( rMarkData.IsMultiMarked() )
58 : : {
59 : 0 : meType = SC_SELECTTYPE_SHEET;
60 [ # # ]: 0 : rMarkData.FillRangeListWithMarks( &maSheetSel, false );
61 : : }
62 : : // else type is SC_SELECTTYPE_NONE - already initialized
63 : : }
64 : 0 : }
65 : :
66 : 0 : bool operator==( const ScSelectionState& rL, const ScSelectionState& rR )
67 : : {
68 : 0 : bool bEqual = rL.GetSelectionType() == rR.GetSelectionType();
69 [ # # # # ]: 0 : if( bEqual ) switch( rL.GetSelectionType() )
[ # # ]
70 : : {
71 : : case SC_SELECTTYPE_EDITCELL:
72 : 0 : bEqual &= ( rL.GetEditSelection().IsEqual( rR.GetEditSelection() ) != false );
73 : : // run through!
74 : : case SC_SELECTTYPE_SHEET:
75 : 0 : bEqual &= (rL.GetSheetSelection() == rR.GetSheetSelection()) == sal_True;
76 : : // run through!
77 : : case SC_SELECTTYPE_NONE:
78 : 0 : bEqual &= rL.GetCellCursor() == rR.GetCellCursor();
79 : 0 : break;
80 : : default:
81 : : {
82 : : // added to avoid warnings
83 : : }
84 : : }
85 : 0 : return bEqual;
86 : : }
87 : :
88 : : // ============================================================================
89 : :
90 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|