Kaydet (Commit) 05327339 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Bool cleanup with ScEditableTester.

Change-Id: If4ae85bec451897f5c22397f4301200d1d3c77ac
üst 80f5a837
...@@ -23,18 +23,16 @@ ...@@ -23,18 +23,16 @@
#include "globstr.hrc" #include "globstr.hrc"
#include "markdata.hxx" #include "markdata.hxx"
//------------------------------------------------------------------
ScEditableTester::ScEditableTester() : ScEditableTester::ScEditableTester() :
bIsEditable( sal_True ), mbIsEditable(true),
bOnlyMatrix( sal_True ) mbOnlyMatrix(true)
{ {
} }
ScEditableTester::ScEditableTester( ScDocument* pDoc, SCTAB nTab, ScEditableTester::ScEditableTester( ScDocument* pDoc, SCTAB nTab,
SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) : SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) :
bIsEditable( sal_True ), mbIsEditable(true),
bOnlyMatrix( sal_True ) mbOnlyMatrix(true)
{ {
TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow ); TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow );
} }
...@@ -42,29 +40,29 @@ ScEditableTester::ScEditableTester( ScDocument* pDoc, SCTAB nTab, ...@@ -42,29 +40,29 @@ ScEditableTester::ScEditableTester( ScDocument* pDoc, SCTAB nTab,
ScEditableTester::ScEditableTester( ScDocument* pDoc, ScEditableTester::ScEditableTester( ScDocument* pDoc,
SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
const ScMarkData& rMark ) : const ScMarkData& rMark ) :
bIsEditable( sal_True ), mbIsEditable(true),
bOnlyMatrix( sal_True ) mbOnlyMatrix(true)
{ {
TestSelectedBlock( pDoc, nStartCol, nStartRow, nEndCol, nEndRow, rMark ); TestSelectedBlock( pDoc, nStartCol, nStartRow, nEndCol, nEndRow, rMark );
} }
ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScRange& rRange ) : ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScRange& rRange ) :
bIsEditable( sal_True ), mbIsEditable(true),
bOnlyMatrix( sal_True ) mbOnlyMatrix(true)
{ {
TestRange( pDoc, rRange ); TestRange( pDoc, rRange );
} }
ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScMarkData& rMark ) : ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScMarkData& rMark ) :
bIsEditable( sal_True ), mbIsEditable(true),
bOnlyMatrix( sal_True ) mbOnlyMatrix(true)
{ {
TestSelection( pDoc, rMark ); TestSelection( pDoc, rMark );
} }
ScEditableTester::ScEditableTester( ScViewFunc* pView ) : ScEditableTester::ScEditableTester( ScViewFunc* pView ) :
bIsEditable( sal_True ), mbIsEditable(true),
bOnlyMatrix( sal_True ) mbOnlyMatrix(true)
{ {
TestView( pView ); TestView( pView );
} }
...@@ -74,14 +72,14 @@ ScEditableTester::ScEditableTester( ScViewFunc* pView ) : ...@@ -74,14 +72,14 @@ ScEditableTester::ScEditableTester( ScViewFunc* pView ) :
void ScEditableTester::TestBlock( ScDocument* pDoc, SCTAB nTab, void ScEditableTester::TestBlock( ScDocument* pDoc, SCTAB nTab,
SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
{ {
if ( bIsEditable || bOnlyMatrix ) if (mbIsEditable || mbOnlyMatrix)
{ {
bool bThisMatrix; bool bThisMatrix;
if ( !pDoc->IsBlockEditable( nTab, nStartCol, nStartRow, nEndCol, nEndRow, &bThisMatrix ) ) if ( !pDoc->IsBlockEditable( nTab, nStartCol, nStartRow, nEndCol, nEndRow, &bThisMatrix ) )
{ {
bIsEditable = false; mbIsEditable = false;
if ( !bThisMatrix ) if ( !bThisMatrix )
bOnlyMatrix = false; mbOnlyMatrix = false;
} }
} }
} }
...@@ -110,28 +108,28 @@ void ScEditableTester::TestRange( ScDocument* pDoc, const ScRange& rRange ) ...@@ -110,28 +108,28 @@ void ScEditableTester::TestRange( ScDocument* pDoc, const ScRange& rRange )
void ScEditableTester::TestSelection( ScDocument* pDoc, const ScMarkData& rMark ) void ScEditableTester::TestSelection( ScDocument* pDoc, const ScMarkData& rMark )
{ {
if ( bIsEditable || bOnlyMatrix ) if (mbIsEditable || mbOnlyMatrix)
{ {
bool bThisMatrix; bool bThisMatrix;
if ( !pDoc->IsSelectionEditable( rMark, &bThisMatrix ) ) if ( !pDoc->IsSelectionEditable( rMark, &bThisMatrix ) )
{ {
bIsEditable = false; mbIsEditable = false;
if ( !bThisMatrix ) if ( !bThisMatrix )
bOnlyMatrix = false; mbOnlyMatrix = false;
} }
} }
} }
void ScEditableTester::TestView( ScViewFunc* pView ) void ScEditableTester::TestView( ScViewFunc* pView )
{ {
if ( bIsEditable || bOnlyMatrix ) if (mbIsEditable || mbOnlyMatrix)
{ {
bool bThisMatrix; bool bThisMatrix;
if ( !pView->SelectionEditable( &bThisMatrix ) ) if ( !pView->SelectionEditable( &bThisMatrix ) )
{ {
bIsEditable = false; mbIsEditable = false;
if ( !bThisMatrix ) if ( !bThisMatrix )
bOnlyMatrix = false; mbOnlyMatrix = false;
} }
} }
} }
...@@ -140,9 +138,9 @@ void ScEditableTester::TestView( ScViewFunc* pView ) ...@@ -140,9 +138,9 @@ void ScEditableTester::TestView( ScViewFunc* pView )
sal_uInt16 ScEditableTester::GetMessageId() const sal_uInt16 ScEditableTester::GetMessageId() const
{ {
if (bIsEditable) if (mbIsEditable)
return 0; return 0;
else if (bOnlyMatrix) else if (mbOnlyMatrix)
return STR_MATRIXFRAGMENTERR; return STR_MATRIXFRAGMENTERR;
else else
return STR_PROTECTIONERR; return STR_PROTECTIONERR;
......
...@@ -31,11 +31,10 @@ class ScRange; ...@@ -31,11 +31,10 @@ class ScRange;
class ScEditableTester class ScEditableTester
{ {
sal_Bool bIsEditable; bool mbIsEditable;
sal_Bool bOnlyMatrix; bool mbOnlyMatrix;
public: public:
// no test in ctor
ScEditableTester(); ScEditableTester();
// calls TestBlock // calls TestBlock
...@@ -56,8 +55,6 @@ public: ...@@ -56,8 +55,6 @@ public:
// calls TestView // calls TestView
ScEditableTester( ScViewFunc* pView ); ScEditableTester( ScViewFunc* pView );
~ScEditableTester() {}
// Several calls to the Test... methods check if *all* of the ranges // Several calls to the Test... methods check if *all* of the ranges
// are editable. For several independent checks, Reset() has to be used. // are editable. For several independent checks, Reset() has to be used.
void TestBlock( ScDocument* pDoc, SCTAB nTab, void TestBlock( ScDocument* pDoc, SCTAB nTab,
...@@ -69,8 +66,8 @@ public: ...@@ -69,8 +66,8 @@ public:
void TestSelection( ScDocument* pDoc, const ScMarkData& rMark ); void TestSelection( ScDocument* pDoc, const ScMarkData& rMark );
void TestView( ScViewFunc* pView ); void TestView( ScViewFunc* pView );
sal_Bool IsEditable() const { return bIsEditable; } bool IsEditable() const { return mbIsEditable; }
sal_Bool IsFormatEditable() const { return bIsEditable || bOnlyMatrix; } bool IsFormatEditable() const { return mbIsEditable || mbOnlyMatrix; }
sal_uInt16 GetMessageId() const; sal_uInt16 GetMessageId() const;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment