fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / docshell / editable.cxx
blobaab817d0d04ed55b69e259dcba9e1201246929e1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "editable.hxx"
21 #include "document.hxx"
22 #include "viewfunc.hxx"
23 #include "globstr.hrc"
24 #include "markdata.hxx"
26 ScEditableTester::ScEditableTester() :
27 mbIsEditable(true),
28 mbOnlyMatrix(true)
32 ScEditableTester::ScEditableTester( ScDocument* pDoc, SCTAB nTab,
33 SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) :
34 mbIsEditable(true),
35 mbOnlyMatrix(true)
37 TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow );
40 ScEditableTester::ScEditableTester( ScDocument* pDoc,
41 SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
42 const ScMarkData& rMark ) :
43 mbIsEditable(true),
44 mbOnlyMatrix(true)
46 TestSelectedBlock( pDoc, nStartCol, nStartRow, nEndCol, nEndRow, rMark );
49 ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScRange& rRange ) :
50 mbIsEditable(true),
51 mbOnlyMatrix(true)
53 TestRange( pDoc, rRange );
56 ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScMarkData& rMark ) :
57 mbIsEditable(true),
58 mbOnlyMatrix(true)
60 TestSelection( pDoc, rMark );
63 ScEditableTester::ScEditableTester( ScViewFunc* pView ) :
64 mbIsEditable(true),
65 mbOnlyMatrix(true)
67 TestView( pView );
70 void ScEditableTester::TestBlock( ScDocument* pDoc, SCTAB nTab,
71 SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
73 if (mbIsEditable || mbOnlyMatrix)
75 bool bThisMatrix;
76 if ( !pDoc->IsBlockEditable( nTab, nStartCol, nStartRow, nEndCol, nEndRow, &bThisMatrix ) )
78 mbIsEditable = false;
79 if ( !bThisMatrix )
80 mbOnlyMatrix = false;
85 void ScEditableTester::TestSelectedBlock( ScDocument* pDoc,
86 SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
87 const ScMarkData& rMark )
89 SCTAB nTabCount = pDoc->GetTableCount();
90 ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
91 for (; itr != itrEnd && *itr < nTabCount; ++itr)
92 TestBlock( pDoc, *itr, nStartCol, nStartRow, nEndCol, nEndRow );
95 void ScEditableTester::TestRange( ScDocument* pDoc, const ScRange& rRange )
97 SCCOL nStartCol = rRange.aStart.Col();
98 SCROW nStartRow = rRange.aStart.Row();
99 SCTAB nStartTab = rRange.aStart.Tab();
100 SCCOL nEndCol = rRange.aEnd.Col();
101 SCROW nEndRow = rRange.aEnd.Row();
102 SCTAB nEndTab = rRange.aEnd.Tab();
103 for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
104 TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow );
107 void ScEditableTester::TestSelection( ScDocument* pDoc, const ScMarkData& rMark )
109 if (mbIsEditable || mbOnlyMatrix)
111 bool bThisMatrix;
112 if ( !pDoc->IsSelectionEditable( rMark, &bThisMatrix ) )
114 mbIsEditable = false;
115 if ( !bThisMatrix )
116 mbOnlyMatrix = false;
121 void ScEditableTester::TestView( ScViewFunc* pView )
123 if (mbIsEditable || mbOnlyMatrix)
125 bool bThisMatrix;
126 if ( !pView->SelectionEditable( &bThisMatrix ) )
128 mbIsEditable = false;
129 if ( !bThisMatrix )
130 mbOnlyMatrix = false;
135 sal_uInt16 ScEditableTester::GetMessageId() const
137 if (mbIsEditable)
138 return 0;
139 else if (mbOnlyMatrix)
140 return STR_MATRIXFRAGMENTERR;
141 else
142 return STR_PROTECTIONERR;
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */