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: editable.cxx,v $
10 * $Revision: 1.5.32.1 $
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"
36 #include "editable.hxx"
37 #include "document.hxx"
38 #include "viewfunc.hxx"
39 #include "globstr.hrc"
41 //------------------------------------------------------------------
43 ScEditableTester::ScEditableTester() :
49 ScEditableTester::ScEditableTester( ScDocument
* pDoc
, SCTAB nTab
,
50 SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
) :
54 TestBlock( pDoc
, nTab
, nStartCol
, nStartRow
, nEndCol
, nEndRow
);
57 ScEditableTester::ScEditableTester( ScDocument
* pDoc
,
58 SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
59 const ScMarkData
& rMark
) :
63 TestSelectedBlock( pDoc
, nStartCol
, nStartRow
, nEndCol
, nEndRow
, rMark
);
66 ScEditableTester::ScEditableTester( ScDocument
* pDoc
, const ScRange
& rRange
) :
70 TestRange( pDoc
, rRange
);
73 ScEditableTester::ScEditableTester( ScDocument
* pDoc
, const ScMarkData
& rMark
) :
77 TestSelection( pDoc
, rMark
);
80 ScEditableTester::ScEditableTester( ScViewFunc
* pView
) :
87 //------------------------------------------------------------------
89 void ScEditableTester::TestBlock( ScDocument
* pDoc
, SCTAB nTab
,
90 SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
)
92 if ( bIsEditable
|| bOnlyMatrix
)
95 if ( !pDoc
->IsBlockEditable( nTab
, nStartCol
, nStartRow
, nEndCol
, nEndRow
, &bThisMatrix
) )
104 void ScEditableTester::TestSelectedBlock( ScDocument
* pDoc
,
105 SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
106 const ScMarkData
& rMark
)
108 SCTAB nTabCount
= pDoc
->GetTableCount();
109 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
110 if (rMark
.GetTableSelect(nTab
))
111 TestBlock( pDoc
, nTab
, nStartCol
, nStartRow
, nEndCol
, nEndRow
);
114 void ScEditableTester::TestRange( ScDocument
* pDoc
, const ScRange
& rRange
)
116 SCCOL nStartCol
= rRange
.aStart
.Col();
117 SCROW nStartRow
= rRange
.aStart
.Row();
118 SCTAB nStartTab
= rRange
.aStart
.Tab();
119 SCCOL nEndCol
= rRange
.aEnd
.Col();
120 SCROW nEndRow
= rRange
.aEnd
.Row();
121 SCTAB nEndTab
= rRange
.aEnd
.Tab();
122 for (SCTAB nTab
=nStartTab
; nTab
<=nEndTab
; nTab
++)
123 TestBlock( pDoc
, nTab
, nStartCol
, nStartRow
, nEndCol
, nEndRow
);
126 void ScEditableTester::TestSelection( ScDocument
* pDoc
, const ScMarkData
& rMark
)
128 if ( bIsEditable
|| bOnlyMatrix
)
131 if ( !pDoc
->IsSelectionEditable( rMark
, &bThisMatrix
) )
140 void ScEditableTester::TestView( ScViewFunc
* pView
)
142 if ( bIsEditable
|| bOnlyMatrix
)
145 if ( !pView
->SelectionEditable( &bThisMatrix
) )
154 //------------------------------------------------------------------
156 USHORT
ScEditableTester::GetMessageId() const
160 else if (bOnlyMatrix
)
161 return STR_MATRIXFRAGMENTERR
;
163 return STR_PROTECTIONERR
;