LCOV - code coverage report
Current view: top level - sc/source/ui/docshell - editable.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 67 0.0 %
Date: 2014-04-14 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "editable.hxx"
      21             : #include "document.hxx"
      22             : #include "viewfunc.hxx"
      23             : #include "globstr.hrc"
      24             : #include "markdata.hxx"
      25             : 
      26           0 : ScEditableTester::ScEditableTester() :
      27             :     mbIsEditable(true),
      28           0 :     mbOnlyMatrix(true)
      29             : {
      30           0 : }
      31             : 
      32           0 : ScEditableTester::ScEditableTester( ScDocument* pDoc, SCTAB nTab,
      33             :                         SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) :
      34             :     mbIsEditable(true),
      35           0 :     mbOnlyMatrix(true)
      36             : {
      37           0 :     TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow );
      38           0 : }
      39             : 
      40           0 : ScEditableTester::ScEditableTester( ScDocument* pDoc,
      41             :                         SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
      42             :                         const ScMarkData& rMark ) :
      43             :     mbIsEditable(true),
      44           0 :     mbOnlyMatrix(true)
      45             : {
      46           0 :     TestSelectedBlock( pDoc, nStartCol, nStartRow, nEndCol, nEndRow, rMark );
      47           0 : }
      48             : 
      49           0 : ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScRange& rRange ) :
      50             :     mbIsEditable(true),
      51           0 :     mbOnlyMatrix(true)
      52             : {
      53           0 :     TestRange( pDoc, rRange );
      54           0 : }
      55             : 
      56           0 : ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScMarkData& rMark ) :
      57             :     mbIsEditable(true),
      58           0 :     mbOnlyMatrix(true)
      59             : {
      60           0 :     TestSelection( pDoc, rMark );
      61           0 : }
      62             : 
      63           0 : ScEditableTester::ScEditableTester( ScViewFunc* pView ) :
      64             :     mbIsEditable(true),
      65           0 :     mbOnlyMatrix(true)
      66             : {
      67           0 :     TestView( pView );
      68           0 : }
      69             : 
      70           0 : void ScEditableTester::TestBlock( ScDocument* pDoc, SCTAB nTab,
      71             :                         SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
      72             : {
      73           0 :     if (mbIsEditable || mbOnlyMatrix)
      74             :     {
      75             :         bool bThisMatrix;
      76           0 :         if ( !pDoc->IsBlockEditable( nTab, nStartCol, nStartRow, nEndCol, nEndRow, &bThisMatrix ) )
      77             :         {
      78           0 :             mbIsEditable = false;
      79           0 :             if ( !bThisMatrix )
      80           0 :                 mbOnlyMatrix = false;
      81             :         }
      82             :     }
      83           0 : }
      84             : 
      85           0 : void ScEditableTester::TestSelectedBlock( ScDocument* pDoc,
      86             :                         SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
      87             :                         const ScMarkData& rMark )
      88             : {
      89           0 :     SCTAB nTabCount = pDoc->GetTableCount();
      90           0 :     ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
      91           0 :     for (; itr != itrEnd && *itr < nTabCount; ++itr)
      92           0 :         TestBlock( pDoc, *itr, nStartCol, nStartRow, nEndCol, nEndRow );
      93           0 : }
      94             : 
      95           0 : void ScEditableTester::TestRange( ScDocument* pDoc, const ScRange& rRange )
      96             : {
      97           0 :     SCCOL nStartCol = rRange.aStart.Col();
      98           0 :     SCROW nStartRow = rRange.aStart.Row();
      99           0 :     SCTAB nStartTab = rRange.aStart.Tab();
     100           0 :     SCCOL nEndCol = rRange.aEnd.Col();
     101           0 :     SCROW nEndRow = rRange.aEnd.Row();
     102           0 :     SCTAB nEndTab = rRange.aEnd.Tab();
     103           0 :     for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
     104           0 :         TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow );
     105           0 : }
     106             : 
     107           0 : void ScEditableTester::TestSelection( ScDocument* pDoc, const ScMarkData& rMark )
     108             : {
     109           0 :     if (mbIsEditable || mbOnlyMatrix)
     110             :     {
     111             :         bool bThisMatrix;
     112           0 :         if ( !pDoc->IsSelectionEditable( rMark, &bThisMatrix ) )
     113             :         {
     114           0 :             mbIsEditable = false;
     115           0 :             if ( !bThisMatrix )
     116           0 :                 mbOnlyMatrix = false;
     117             :         }
     118             :     }
     119           0 : }
     120             : 
     121           0 : void ScEditableTester::TestView( ScViewFunc* pView )
     122             : {
     123           0 :     if (mbIsEditable || mbOnlyMatrix)
     124             :     {
     125             :         bool bThisMatrix;
     126           0 :         if ( !pView->SelectionEditable( &bThisMatrix ) )
     127             :         {
     128           0 :             mbIsEditable = false;
     129           0 :             if ( !bThisMatrix )
     130           0 :                 mbOnlyMatrix = false;
     131             :         }
     132             :     }
     133           0 : }
     134             : 
     135           0 : sal_uInt16 ScEditableTester::GetMessageId() const
     136             : {
     137           0 :     if (mbIsEditable)
     138           0 :         return 0;
     139           0 :     else if (mbOnlyMatrix)
     140           0 :         return STR_MATRIXFRAGMENTERR;
     141             :     else
     142           0 :         return STR_PROTECTIONERR;
     143           0 : }
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10