LCOV - code coverage report
Current view: top level - sc/source/ui/view - viewfun2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 52 1573 3.3 %
Date: 2012-08-25 Functions: 4 57 7.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 38 2791 1.4 %

           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 "scitems.hxx"
      30                 :            : #include <comphelper/string.hxx>
      31                 :            : #include <editeng/eeitem.hxx>
      32                 :            : 
      33                 :            : #include <sfx2/app.hxx>
      34                 :            : #include <editeng/boxitem.hxx>
      35                 :            : #include <editeng/fontitem.hxx>
      36                 :            : #include <editeng/scripttypeitem.hxx>
      37                 :            : #include <svl/srchitem.hxx>
      38                 :            : #include <sfx2/linkmgr.hxx>
      39                 :            : #include <sfx2/dispatch.hxx>
      40                 :            : #include <sfx2/docfilt.hxx>
      41                 :            : #include <sfx2/docfile.hxx>
      42                 :            : #include <sfx2/objitem.hxx>
      43                 :            : #include <sfx2/viewfrm.hxx>
      44                 :            : #include <svl/stritem.hxx>
      45                 :            : #include <svl/zforlist.hxx>
      46                 :            : #include <svx/svdview.hxx>
      47                 :            : #include <vcl/msgbox.hxx>
      48                 :            : #include <vcl/waitobj.hxx>
      49                 :            : 
      50                 :            : #include <basic/sbstar.hxx>
      51                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      52                 :            : #include <com/sun/star/script/XLibraryContainer.hpp>
      53                 :            : 
      54                 :            : #include "viewfunc.hxx"
      55                 :            : 
      56                 :            : #include "sc.hrc"
      57                 :            : #include "globstr.hrc"
      58                 :            : 
      59                 :            : #include "attrib.hxx"
      60                 :            : #include "autoform.hxx"
      61                 :            : #include "cell.hxx"                 // EnterAutoSum
      62                 :            : #include "cellmergeoption.hxx"
      63                 :            : #include "compiler.hxx"
      64                 :            : #include "docfunc.hxx"
      65                 :            : #include "docpool.hxx"
      66                 :            : #include "docsh.hxx"
      67                 :            : #include "global.hxx"
      68                 :            : #include "patattr.hxx"
      69                 :            : #include "printfun.hxx"
      70                 :            : #include "rangenam.hxx"
      71                 :            : #include "rangeutl.hxx"
      72                 :            : #include "refundo.hxx"
      73                 :            : #include "tablink.hxx"
      74                 :            : #include "tabvwsh.hxx"
      75                 :            : #include "uiitems.hxx"
      76                 :            : #include "undoblk.hxx"
      77                 :            : #include "undocell.hxx"
      78                 :            : #include "undotab.hxx"
      79                 :            : #include "sizedev.hxx"
      80                 :            : #include "editable.hxx"
      81                 :            : #include "scmod.hxx"
      82                 :            : #include "inputhdl.hxx"
      83                 :            : #include "inputwin.hxx"
      84                 :            : #include "funcdesc.hxx"
      85                 :            : #include "docuno.hxx"
      86                 :            : #include "charthelper.hxx"
      87                 :            : #include "tabbgcolor.hxx"
      88                 :            : #include "clipparam.hxx"
      89                 :            : 
      90                 :            : #include <boost/scoped_ptr.hpp>
      91                 :            : #include <vector>
      92                 :            : #include <memory>
      93                 :            : 
      94                 :            : using namespace com::sun::star;
      95                 :            : using ::rtl::OUStringBuffer;
      96                 :            : using ::rtl::OUString;
      97                 :            : using ::editeng::SvxBorderLine;
      98                 :            : 
      99                 :            : using ::std::vector;
     100                 :            : using ::std::auto_ptr;
     101                 :            : 
     102                 :            : // helper func defined in docfunc.cxx
     103                 :            : void VBA_DeleteModule( ScDocShell& rDocSh, const rtl::OUString& sModuleName );
     104                 :            : 
     105                 :            : // STATIC DATA ---------------------------------------------------------------
     106                 :            : 
     107                 :            : 
     108                 :            : //----------------------------------------------------------------------------
     109                 :            : 
     110                 :         16 : sal_Bool ScViewFunc::AdjustBlockHeight( sal_Bool bPaint, ScMarkData* pMarkData )
     111                 :            : {
     112                 :         16 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     113         [ +  - ]:         16 :     if (!pMarkData)
     114         [ +  - ]:         16 :         pMarkData = &GetViewData()->GetMarkData();
     115                 :            : 
     116                 :         16 :     ScDocument* pDoc = pDocSh->GetDocument();
     117         [ +  - ]:         16 :     SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT];
     118         [ +  - ]:         16 :     SCCOLROW nRangeCnt = pMarkData->GetMarkRowRanges( pRanges );
     119         [ -  + ]:         16 :     if (nRangeCnt == 0)
     120                 :            :     {
     121                 :          0 :         pRanges[0] = pRanges[1] = GetViewData()->GetCurY();
     122                 :          0 :         nRangeCnt = 1;
     123                 :            :     }
     124                 :            : 
     125                 :         16 :     double nPPTX = GetViewData()->GetPPTX();
     126                 :         16 :     double nPPTY = GetViewData()->GetPPTY();
     127         [ +  - ]:         16 :     Fraction aZoomX = GetViewData()->GetZoomX();
     128         [ +  - ]:         16 :     Fraction aZoomY = GetViewData()->GetZoomY();
     129                 :            : 
     130         [ +  - ]:         16 :     ScSizeDeviceProvider aProv(pDocSh);
     131         [ -  + ]:         16 :     if (aProv.IsPrinter())
     132                 :            :     {
     133                 :          0 :         nPPTX = aProv.GetPPTX();
     134                 :          0 :         nPPTY = aProv.GetPPTY();
     135 [ #  # ][ #  # ]:          0 :         aZoomX = aZoomY = Fraction( 1, 1 );
                 [ #  # ]
     136                 :            :     }
     137                 :            : 
     138                 :         16 :     sal_Bool bAnyChanged = false;
     139 [ +  - ][ +  - ]:         16 :     ScMarkData::iterator itr = pMarkData->begin(), itrEnd = pMarkData->end();
     140 [ +  - ][ +  - ]:         32 :     for (; itr != itrEnd; ++itr)
                 [ +  + ]
     141                 :            :     {
     142         [ +  - ]:         16 :         SCTAB nTab = *itr;
     143                 :         16 :         SCCOLROW* pOneRange = pRanges;
     144                 :         16 :         sal_Bool bChanged = false;
     145                 :         16 :         SCROW nPaintY = 0;
     146         [ +  + ]:         32 :         for (SCROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
     147                 :            :         {
     148                 :         16 :             SCROW nStartNo = *(pOneRange++);
     149                 :         16 :             SCROW nEndNo = *(pOneRange++);
     150 [ +  - ][ +  - ]:         16 :             if (pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(),
     151                 :         16 :                                         nPPTX, nPPTY, aZoomX, aZoomY, false ))
     152                 :            :             {
     153         [ +  - ]:         16 :                 if (!bChanged)
     154                 :         16 :                     nPaintY = nStartNo;
     155                 :         16 :                 bAnyChanged = bChanged = sal_True;
     156                 :            :             }
     157                 :            :         }
     158 [ +  - ][ +  - ]:         16 :         if ( bPaint && bChanged )
     159                 :            :             pDocSh->PostPaint( 0, nPaintY, nTab, MAXCOL, MAXROW, nTab,
     160         [ +  - ]:         16 :                                                 PAINT_GRID | PAINT_LEFT );
     161                 :            :     }
     162         [ +  - ]:         16 :     delete[] pRanges;
     163                 :            : 
     164 [ +  - ][ +  - ]:         16 :     if ( bPaint && bAnyChanged )
     165         [ +  - ]:         16 :         pDocSh->UpdateOle(GetViewData());
     166                 :            : 
     167         [ +  - ]:         16 :     return bAnyChanged;
     168                 :            : }
     169                 :            : 
     170                 :            : 
     171                 :            : //----------------------------------------------------------------------------
     172                 :            : 
     173                 :          0 : sal_Bool ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, sal_Bool bPaint )
     174                 :            : {
     175                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     176                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
     177                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
     178                 :          0 :     double nPPTX = GetViewData()->GetPPTX();
     179                 :          0 :     double nPPTY = GetViewData()->GetPPTY();
     180         [ #  # ]:          0 :     Fraction aZoomX = GetViewData()->GetZoomX();
     181         [ #  # ]:          0 :     Fraction aZoomY = GetViewData()->GetZoomY();
     182                 :          0 :     sal_uInt16 nOldPixel = 0;
     183         [ #  # ]:          0 :     if (nStartRow == nEndRow)
     184         [ #  # ]:          0 :         nOldPixel = (sal_uInt16) (pDoc->GetRowHeight(nStartRow,nTab) * nPPTY);
     185                 :            : 
     186         [ #  # ]:          0 :     ScSizeDeviceProvider aProv(pDocSh);
     187         [ #  # ]:          0 :     if (aProv.IsPrinter())
     188                 :            :     {
     189                 :          0 :         nPPTX = aProv.GetPPTX();
     190                 :          0 :         nPPTY = aProv.GetPPTY();
     191 [ #  # ][ #  # ]:          0 :         aZoomX = aZoomY = Fraction( 1, 1 );
                 [ #  # ]
     192                 :            :     }
     193                 :            :     sal_Bool bChanged = pDoc->SetOptimalHeight( nStartRow, nEndRow, nTab, 0, aProv.GetDevice(),
     194         [ #  # ]:          0 :                                             nPPTX, nPPTY, aZoomX, aZoomY, false );
     195                 :            : 
     196 [ #  # ][ #  # ]:          0 :     if (bChanged && ( nStartRow == nEndRow ))
     197                 :            :     {
     198         [ #  # ]:          0 :         sal_uInt16 nNewPixel = (sal_uInt16) (pDoc->GetRowHeight(nStartRow,nTab) * nPPTY);
     199         [ #  # ]:          0 :         if ( nNewPixel == nOldPixel )
     200                 :          0 :             bChanged = false;
     201                 :            :     }
     202                 :            : 
     203 [ #  # ][ #  # ]:          0 :     if ( bPaint && bChanged )
     204                 :            :         pDocSh->PostPaint( 0, nStartRow, nTab, MAXCOL, MAXROW, nTab,
     205         [ #  # ]:          0 :                                             PAINT_GRID | PAINT_LEFT );
     206                 :            : 
     207         [ #  # ]:          0 :     return bChanged;
     208                 :            : }
     209                 :            : 
     210                 :            : 
     211                 :            : //----------------------------------------------------------------------------
     212                 :            : 
     213                 :            : enum ScAutoSum
     214                 :            : {
     215                 :            :     ScAutoSumNone = 0,
     216                 :            :     ScAutoSumData,
     217                 :            :     ScAutoSumSum
     218                 :            : };
     219                 :            : 
     220                 :            : 
     221                 :          0 : ScAutoSum lcl_IsAutoSumData( ScDocument* pDoc, SCCOL nCol, SCROW nRow,
     222                 :            :         SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
     223                 :            : {
     224                 :            :     ScBaseCell* pCell;
     225         [ #  # ]:          0 :     pDoc->GetCell( nCol, nRow, nTab, pCell );
     226 [ #  # ][ #  # ]:          0 :     if ( pCell && pCell->HasValueData() )
         [ #  # ][ #  # ]
     227                 :            :     {
     228         [ #  # ]:          0 :         if ( pCell->GetCellType() == CELLTYPE_FORMULA )
     229                 :            :         {
     230         [ #  # ]:          0 :             ScTokenArray* pCode = ((ScFormulaCell*)pCell)->GetCode();
     231 [ #  # ][ #  # ]:          0 :             if ( pCode && pCode->GetOuterFuncOpCode() == ocSum )
                 [ #  # ]
     232                 :            :             {
     233 [ #  # ][ #  # ]:          0 :                 if ( pCode->GetAdjacentExtendOfOuterFuncRefs( nExtend,
     234                 :          0 :                         ScAddress( nCol, nRow, nTab ), eDir ) )
     235                 :          0 :                     return ScAutoSumSum;
     236                 :            :             }
     237                 :            :         }
     238                 :          0 :         return ScAutoSumData;
     239                 :            :     }
     240                 :          0 :     return ScAutoSumNone;
     241                 :            : }
     242                 :            : 
     243                 :            : 
     244                 :            : //----------------------------------------------------------------------------
     245                 :            : 
     246                 :            : #define SC_AUTOSUM_MAXCOUNT     20
     247                 :            : 
     248                 :          0 : ScAutoSum lcl_SeekAutoSumData( ScDocument* pDoc, SCCOL& nCol, SCROW& nRow,
     249                 :            :         SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
     250                 :            : {
     251                 :          0 :     sal_uInt16 nCount = 0;
     252         [ #  # ]:          0 :     while (nCount < SC_AUTOSUM_MAXCOUNT)
     253                 :            :     {
     254         [ #  # ]:          0 :         if ( eDir == DIR_TOP )
     255                 :            :         {
     256         [ #  # ]:          0 :             if (nRow > 0)
     257                 :          0 :                 --nRow;
     258                 :            :             else
     259                 :          0 :                 return ScAutoSumNone;
     260                 :            :         }
     261                 :            :         else
     262                 :            :         {
     263         [ #  # ]:          0 :             if (nCol > 0)
     264                 :          0 :                 --nCol;
     265                 :            :             else
     266                 :          0 :                 return ScAutoSumNone;
     267                 :            :         }
     268                 :            :         ScAutoSum eSum;
     269         [ #  # ]:          0 :         if ( (eSum = lcl_IsAutoSumData(
     270                 :          0 :                 pDoc, nCol, nRow, nTab, eDir, nExtend )) != ScAutoSumNone )
     271                 :          0 :             return eSum;
     272                 :          0 :         ++nCount;
     273                 :            :     }
     274                 :          0 :     return ScAutoSumNone;
     275                 :            : }
     276                 :            : 
     277                 :            : #undef SC_AUTOSUM_MAXCOUNT
     278                 :            : 
     279                 :            : //----------------------------------------------------------------------------
     280                 :            : 
     281                 :          0 : bool lcl_FindNextSumEntryInColumn( ScDocument* pDoc, SCCOL nCol, SCROW& nRow,
     282                 :            :                                    SCTAB nTab, SCCOLROW& nExtend, SCROW nMinRow )
     283                 :            : {
     284                 :          0 :     const SCROW nTmp = nRow;
     285                 :          0 :     ScAutoSum eSkip = ScAutoSumNone;
     286 [ #  # ][ #  # ]:          0 :     while ( ( eSkip = lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_TOP, nExtend ) ) == ScAutoSumData &&
                 [ #  # ]
     287                 :            :             nRow > nMinRow )
     288                 :            :     {
     289                 :          0 :         --nRow;
     290                 :            :     }
     291 [ #  # ][ #  # ]:          0 :     if ( eSkip == ScAutoSumSum && nRow < nTmp )
     292                 :            :     {
     293                 :          0 :         return true;
     294                 :            :     }
     295                 :          0 :     return false;
     296                 :            : }
     297                 :            : 
     298                 :            : //----------------------------------------------------------------------------
     299                 :            : 
     300                 :          0 : bool lcl_FindNextSumEntryInRow( ScDocument* pDoc, SCCOL& nCol, SCROW nRow,
     301                 :            :                                 SCTAB nTab, SCCOLROW& nExtend, SCROW nMinCol )
     302                 :            : {
     303                 :          0 :     const SCCOL nTmp = nCol;
     304                 :          0 :     ScAutoSum eSkip = ScAutoSumNone;
     305 [ #  # ][ #  # ]:          0 :     while ( ( eSkip = lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_LEFT, nExtend ) ) == ScAutoSumData &&
                 [ #  # ]
     306                 :            :             nCol > nMinCol )
     307                 :            :     {
     308                 :          0 :         --nCol;
     309                 :            :     }
     310 [ #  # ][ #  # ]:          0 :     if ( eSkip == ScAutoSumSum && nCol < nTmp )
     311                 :            :     {
     312                 :          0 :         return true;
     313                 :            :     }
     314                 :          0 :     return false;
     315                 :            : }
     316                 :            : 
     317                 :            : //----------------------------------------------------------------------------
     318                 :            : 
     319                 :          0 : bool lcl_GetAutoSumForColumnRange( ScDocument* pDoc, ScRangeList& rRangeList, const ScRange& rRange )
     320                 :            : {
     321                 :          0 :     const ScAddress aStart = rRange.aStart;
     322                 :          0 :     const ScAddress aEnd = rRange.aEnd;
     323         [ #  # ]:          0 :     if ( aStart.Col() != aEnd.Col() )
     324                 :            :     {
     325                 :          0 :         return false;
     326                 :            :     }
     327                 :            : 
     328                 :          0 :     const SCTAB nTab = aEnd.Tab();
     329                 :          0 :     const SCCOL nCol = aEnd.Col();
     330                 :          0 :     SCROW nEndRow = aEnd.Row();
     331                 :          0 :     SCROW nStartRow = nEndRow;
     332                 :          0 :     SCCOLROW nExtend = 0;
     333         [ #  # ]:          0 :     const ScAutoSum eSum = lcl_IsAutoSumData( pDoc, nCol, nEndRow, nTab, DIR_TOP, nExtend /*out*/ );
     334                 :            : 
     335         [ #  # ]:          0 :     if ( eSum == ScAutoSumSum )
     336                 :            :     {
     337                 :          0 :         bool bContinue = false;
     338         [ #  # ]:          0 :         do
     339                 :            :         {
     340         [ #  # ]:          0 :             rRangeList.Append( ScRange( nCol, nStartRow, nTab, nCol, nEndRow, nTab ) );
     341                 :          0 :             nEndRow = static_cast< SCROW >( nExtend );
     342 [ #  # ][ #  # ]:          0 :             if ( ( bContinue = lcl_FindNextSumEntryInColumn( pDoc, nCol, nEndRow /*inout*/, nTab, nExtend /*out*/, aStart.Row() ) ) == true )
     343                 :            :             {
     344                 :          0 :                 nStartRow = nEndRow;
     345                 :            :             }
     346                 :            :         } while ( bContinue );
     347                 :            :     }
     348                 :            :     else
     349                 :            :     {
     350 [ #  # ][ #  # ]:          0 :         while ( nStartRow > aStart.Row() &&
                 [ #  # ]
     351         [ #  # ]:          0 :                 lcl_IsAutoSumData( pDoc, nCol, nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ ) != ScAutoSumSum )
     352                 :            :         {
     353                 :          0 :             --nStartRow;
     354                 :            :         }
     355         [ #  # ]:          0 :         rRangeList.Append( ScRange( nCol, nStartRow, nTab, nCol, nEndRow, nTab ) );
     356                 :            :     }
     357                 :            : 
     358                 :          0 :     return true;
     359                 :            : }
     360                 :            : 
     361                 :            : //----------------------------------------------------------------------------
     362                 :            : 
     363                 :          0 : bool lcl_GetAutoSumForRowRange( ScDocument* pDoc, ScRangeList& rRangeList, const ScRange& rRange )
     364                 :            : {
     365                 :          0 :     const ScAddress aStart = rRange.aStart;
     366                 :          0 :     const ScAddress aEnd = rRange.aEnd;
     367         [ #  # ]:          0 :     if ( aStart.Row() != aEnd.Row() )
     368                 :            :     {
     369                 :          0 :         return false;
     370                 :            :     }
     371                 :            : 
     372                 :          0 :     const SCTAB nTab = aEnd.Tab();
     373                 :          0 :     const SCROW nRow = aEnd.Row();
     374                 :          0 :     SCCOL nEndCol = aEnd.Col();
     375                 :          0 :     SCCOL nStartCol = nEndCol;
     376                 :          0 :     SCCOLROW nExtend = 0;
     377         [ #  # ]:          0 :     const ScAutoSum eSum = lcl_IsAutoSumData( pDoc, nEndCol, nRow, nTab, DIR_LEFT, nExtend /*out*/ );
     378                 :            : 
     379         [ #  # ]:          0 :     if ( eSum == ScAutoSumSum )
     380                 :            :     {
     381                 :          0 :         bool bContinue = false;
     382         [ #  # ]:          0 :         do
     383                 :            :         {
     384         [ #  # ]:          0 :             rRangeList.Append( ScRange( nStartCol, nRow, nTab, nEndCol, nRow, nTab ) );
     385                 :          0 :             nEndCol = static_cast< SCCOL >( nExtend );
     386 [ #  # ][ #  # ]:          0 :             if ( ( bContinue = lcl_FindNextSumEntryInRow( pDoc, nEndCol /*inout*/, nRow, nTab, nExtend /*out*/, aStart.Col() ) ) == true )
     387                 :            :             {
     388                 :          0 :                 nStartCol = nEndCol;
     389                 :            :             }
     390                 :            :         } while ( bContinue );
     391                 :            :     }
     392                 :            :     else
     393                 :            :     {
     394 [ #  # ][ #  # ]:          0 :         while ( nStartCol > aStart.Col() &&
                 [ #  # ]
     395         [ #  # ]:          0 :                 lcl_IsAutoSumData( pDoc, nStartCol-1, nRow, nTab, DIR_LEFT, nExtend /*out*/ ) != ScAutoSumSum )
     396                 :            :         {
     397                 :          0 :             --nStartCol;
     398                 :            :         }
     399         [ #  # ]:          0 :         rRangeList.Append( ScRange( nStartCol, nRow, nTab, nEndCol, nRow, nTab ) );
     400                 :            :     }
     401                 :            : 
     402                 :          0 :     return true;
     403                 :            : }
     404                 :            : 
     405                 :            : //----------------------------------------------------------------------------
     406                 :            : 
     407                 :          0 : sal_Bool ScViewFunc::GetAutoSumArea( ScRangeList& rRangeList )
     408                 :            : {
     409         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     410                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
     411                 :            : 
     412                 :          0 :     SCCOL nCol = GetViewData()->GetCurX();
     413                 :          0 :     SCROW nRow = GetViewData()->GetCurY();
     414                 :            : 
     415                 :          0 :     SCCOL nStartCol = nCol;
     416                 :          0 :     SCROW nStartRow = nRow;
     417                 :          0 :     SCCOL nEndCol    = nCol;
     418                 :          0 :     SCROW nEndRow    = nRow;
     419                 :          0 :     SCCOL nSeekCol   = nCol;
     420                 :          0 :     SCROW nSeekRow   = nRow;
     421                 :            :     SCCOLROW nExtend;       // will become valid via reference for ScAutoSumSum
     422                 :            : 
     423                 :          0 :     sal_Bool bCol = false;
     424                 :          0 :     sal_Bool bRow = false;
     425                 :            : 
     426                 :            :     ScAutoSum eSum;
     427 [ #  # ][ #  # ]:          0 :     if ( nRow != 0
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     428                 :            :             && ((eSum = lcl_IsAutoSumData( pDoc, nCol, nRow-1, nTab,
     429                 :          0 :                 DIR_TOP, nExtend /*out*/ )) == ScAutoSumData )
     430                 :            :             && ((eSum = lcl_IsAutoSumData( pDoc, nCol, nRow-1, nTab,
     431                 :          0 :                 DIR_LEFT, nExtend /*out*/ )) == ScAutoSumData )
     432                 :            :         )
     433                 :            :     {
     434                 :          0 :         bRow = sal_True;
     435                 :          0 :         nSeekRow = nRow - 1;
     436                 :            :     }
     437 [ #  # ][ #  # ]:          0 :     else if ( nCol != 0 && (eSum = lcl_IsAutoSumData( pDoc, nCol-1, nRow, nTab,
         [ #  # ][ #  # ]
     438                 :          0 :             DIR_LEFT, nExtend /*out*/ )) == ScAutoSumData )
     439                 :            :     {
     440                 :          0 :         bCol = sal_True;
     441                 :          0 :         nSeekCol = nCol - 1;
     442                 :            :     }
     443 [ #  # ][ #  # ]:          0 :     else if ( (eSum = lcl_SeekAutoSumData( pDoc, nCol, nSeekRow, nTab, DIR_TOP, nExtend /*out*/ )) != ScAutoSumNone )
     444                 :          0 :         bRow = sal_True;
     445 [ #  # ][ #  # ]:          0 :     else if (( eSum = lcl_SeekAutoSumData( pDoc, nSeekCol, nRow, nTab, DIR_LEFT, nExtend /*out*/ )) != ScAutoSumNone )
     446                 :          0 :         bCol = sal_True;
     447                 :            : 
     448 [ #  # ][ #  # ]:          0 :     if ( bCol || bRow )
     449                 :            :     {
     450         [ #  # ]:          0 :         if ( bRow )
     451                 :            :         {
     452                 :          0 :             nStartRow = nSeekRow;       // nSeekRow might be adjusted via reference
     453         [ #  # ]:          0 :             if ( eSum == ScAutoSumSum )
     454                 :          0 :                 nEndRow = nStartRow;        // only sum sums
     455                 :            :             else
     456                 :          0 :                 nEndRow = nRow - 1;     // maybe extend data area at bottom
     457                 :            :         }
     458                 :            :         else
     459                 :            :         {
     460                 :          0 :             nStartCol = nSeekCol;       // nSeekCol might be adjusted vie reference
     461         [ #  # ]:          0 :             if ( eSum == ScAutoSumSum )
     462                 :          0 :                 nEndCol = nStartCol;        // only sum sums
     463                 :            :             else
     464                 :          0 :                 nEndCol = nCol - 1;     // maybe extend data area to the right
     465                 :            :         }
     466                 :          0 :         sal_Bool bContinue = false;
     467         [ #  # ]:          0 :         do
     468                 :            :         {
     469         [ #  # ]:          0 :             if ( eSum == ScAutoSumData )
     470                 :            :             {
     471         [ #  # ]:          0 :                 if ( bRow )
     472                 :            :                 {
     473 [ #  # ][ #  # ]:          0 :                     while ( nStartRow != 0 && lcl_IsAutoSumData(    pDoc, nCol,
                 [ #  # ]
     474         [ #  # ]:          0 :                             nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ ) == eSum )
     475                 :          0 :                         --nStartRow;
     476                 :            :                 }
     477                 :            :                 else
     478                 :            :                 {
     479 [ #  # ][ #  # ]:          0 :                     while ( nStartCol != 0 && lcl_IsAutoSumData( pDoc, nStartCol-1,
                 [ #  # ]
     480         [ #  # ]:          0 :                             nRow, nTab, DIR_LEFT, nExtend /*out*/ ) == eSum )
     481                 :          0 :                         --nStartCol;
     482                 :            :                 }
     483                 :            :             }
     484                 :            :             rRangeList.Append(
     485         [ #  # ]:          0 :                 ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ) );
     486         [ #  # ]:          0 :             if ( eSum == ScAutoSumSum )
     487                 :            :             {
     488         [ #  # ]:          0 :                 if ( bRow )
     489                 :            :                 {
     490                 :          0 :                     nEndRow = static_cast< SCROW >( nExtend );
     491 [ #  # ][ #  # ]:          0 :                     if ( ( bContinue = lcl_FindNextSumEntryInColumn( pDoc, nCol, nEndRow /*inout*/, nTab, nExtend /*out*/, 0 ) ) == true )
     492                 :            :                     {
     493                 :          0 :                         nStartRow = nEndRow;
     494                 :            :                     }
     495                 :            :                 }
     496                 :            :                 else
     497                 :            :                 {
     498                 :          0 :                     nEndCol = static_cast< SCCOL >( nExtend );
     499 [ #  # ][ #  # ]:          0 :                     if ( ( bContinue = lcl_FindNextSumEntryInRow( pDoc, nEndCol /*inout*/, nRow, nTab, nExtend /*out*/, 0 ) ) == true )
     500                 :            :                     {
     501                 :          0 :                         nStartCol = nEndCol;
     502                 :            :                     }
     503                 :            :                 }
     504                 :            :             }
     505                 :            :         } while ( bContinue );
     506                 :          0 :         return sal_True;
     507                 :            :     }
     508                 :          0 :     return false;
     509                 :            : }
     510                 :            : 
     511                 :            : //----------------------------------------------------------------------------
     512                 :            : 
     513                 :          0 : void ScViewFunc::EnterAutoSum(const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr)
     514                 :            : {
     515         [ #  # ]:          0 :     String aFormula = GetAutoSumFormula( rRangeList, bSubTotal, rAddr );
     516 [ #  # ][ #  # ]:          0 :     EnterBlock( aFormula, NULL );
     517                 :          0 : }
     518                 :            : 
     519                 :            : //----------------------------------------------------------------------------
     520                 :            : 
     521                 :          0 : bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor, bool bContinue )
     522                 :            : {
     523         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     524                 :          0 :     const SCTAB nTab = rRange.aStart.Tab();
     525                 :          0 :     SCCOL nStartCol = rRange.aStart.Col();
     526                 :          0 :     SCROW nStartRow = rRange.aStart.Row();
     527                 :          0 :     const SCCOL nEndCol = rRange.aEnd.Col();
     528                 :          0 :     const SCROW nEndRow = rRange.aEnd.Row();
     529                 :          0 :     SCCOLROW nExtend = 0; // out parameter for lcl_IsAutoSumData
     530                 :            : 
     531                 :            :     // ignore rows at the top of the given range which don't contain autosum data
     532                 :          0 :     bool bRowData = false;
     533         [ #  # ]:          0 :     for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
     534                 :            :     {
     535         [ #  # ]:          0 :         for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
     536                 :            :         {
     537 [ #  # ][ #  # ]:          0 :             if ( lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_TOP, nExtend ) != ScAutoSumNone )
     538                 :            :             {
     539                 :          0 :                 bRowData = true;
     540                 :          0 :                 break;
     541                 :            :             }
     542                 :            :         }
     543         [ #  # ]:          0 :         if ( bRowData )
     544                 :            :         {
     545                 :          0 :             nStartRow = nRow;
     546                 :          0 :             break;
     547                 :            :         }
     548                 :            :     }
     549         [ #  # ]:          0 :     if ( !bRowData )
     550                 :            :     {
     551                 :          0 :         return false;
     552                 :            :     }
     553                 :            : 
     554                 :            :     // ignore columns at the left of the given range which don't contain autosum data
     555                 :          0 :     bool bColData = false;
     556         [ #  # ]:          0 :     for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
     557                 :            :     {
     558         [ #  # ]:          0 :         for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
     559                 :            :         {
     560 [ #  # ][ #  # ]:          0 :             if ( lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_LEFT, nExtend ) != ScAutoSumNone )
     561                 :            :             {
     562                 :          0 :                 bColData = true;
     563                 :          0 :                 break;
     564                 :            :             }
     565                 :            :         }
     566         [ #  # ]:          0 :         if ( bColData )
     567                 :            :         {
     568                 :          0 :             nStartCol = nCol;
     569                 :          0 :             break;
     570                 :            :         }
     571                 :            :     }
     572         [ #  # ]:          0 :     if ( !bColData )
     573                 :            :     {
     574                 :          0 :         return false;
     575                 :            :     }
     576                 :            : 
     577         [ #  # ]:          0 :     const bool bEndRowEmpty = pDoc->IsBlockEmpty( nTab, nStartCol, nEndRow, nEndCol, nEndRow );
     578         [ #  # ]:          0 :     const bool bEndColEmpty = pDoc->IsBlockEmpty( nTab, nEndCol, nStartRow, nEndCol, nEndRow );
     579 [ #  # ][ #  # ]:          0 :     bool bRow = ( ( nStartRow != nEndRow ) && ( bEndRowEmpty || ( !bEndRowEmpty && !bEndColEmpty ) ) );
         [ #  # ][ #  # ]
     580 [ #  # ][ #  # ]:          0 :     bool bCol = ( ( nStartCol != nEndCol ) && ( bEndColEmpty || nStartRow == nEndRow ) );
                 [ #  # ]
     581                 :            : 
     582                 :            :     // find an empty row for entering the result
     583                 :          0 :     SCROW nInsRow = nEndRow;
     584 [ #  # ][ #  # ]:          0 :     if ( bRow && !bEndRowEmpty )
     585                 :            :     {
     586         [ #  # ]:          0 :         if ( nInsRow < MAXROW )
     587                 :            :         {
     588                 :          0 :             ++nInsRow;
     589 [ #  # ][ #  # ]:          0 :             while ( !pDoc->IsBlockEmpty( nTab, nStartCol, nInsRow, nEndCol, nInsRow ) )
     590                 :            :             {
     591         [ #  # ]:          0 :                 if ( nInsRow < MAXROW )
     592                 :            :                 {
     593                 :          0 :                     ++nInsRow;
     594                 :            :                 }
     595                 :            :                 else
     596                 :            :                 {
     597                 :          0 :                     bRow = false;
     598                 :          0 :                     break;
     599                 :            :                 }
     600                 :            :             }
     601                 :            :         }
     602                 :            :         else
     603                 :            :         {
     604                 :          0 :             bRow = false;
     605                 :            :         }
     606                 :            :     }
     607                 :            : 
     608                 :            :     // find an empty column for entering the result
     609                 :          0 :     SCCOL nInsCol = nEndCol;
     610 [ #  # ][ #  # ]:          0 :     if ( bCol && !bEndColEmpty )
     611                 :            :     {
     612         [ #  # ]:          0 :         if ( nInsCol < MAXCOL )
     613                 :            :         {
     614                 :          0 :             ++nInsCol;
     615 [ #  # ][ #  # ]:          0 :             while ( !pDoc->IsBlockEmpty( nTab, nInsCol, nStartRow, nInsCol, nEndRow ) )
     616                 :            :             {
     617         [ #  # ]:          0 :                 if ( nInsCol < MAXCOL )
     618                 :            :                 {
     619                 :          0 :                     ++nInsCol;
     620                 :            :                 }
     621                 :            :                 else
     622                 :            :                 {
     623                 :          0 :                     bCol = false;
     624                 :          0 :                     break;
     625                 :            :                 }
     626                 :            :             }
     627                 :            :         }
     628                 :            :         else
     629                 :            :         {
     630                 :          0 :             bCol = false;
     631                 :            :         }
     632                 :            :     }
     633                 :            : 
     634 [ #  # ][ #  # ]:          0 :     if ( !bRow && !bCol )
     635                 :            :     {
     636                 :          0 :         return false;
     637                 :            :     }
     638                 :            : 
     639                 :          0 :     SCCOL nMarkEndCol = nEndCol;
     640                 :          0 :     SCROW nMarkEndRow = nEndRow;
     641                 :            : 
     642         [ #  # ]:          0 :     if ( bRow )
     643                 :            :     {
     644                 :            :         // calculate the row sums for all columns of the given range
     645                 :            : 
     646                 :          0 :         SCROW nSumEndRow = nEndRow;
     647                 :            : 
     648         [ #  # ]:          0 :         if ( bEndRowEmpty )
     649                 :            :         {
     650                 :            :             // the last row of the given range is empty;
     651                 :            :             // don't take into account for calculating the autosum
     652                 :          0 :             --nSumEndRow;
     653                 :            :         }
     654                 :            :         else
     655                 :            :         {
     656                 :            :             // increase mark range
     657                 :          0 :             ++nMarkEndRow;
     658                 :            :         }
     659                 :            : 
     660         [ #  # ]:          0 :         for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
     661                 :            :         {
     662 [ #  # ][ #  # ]:          0 :             if ( !pDoc->IsBlockEmpty( nTab, nCol, nStartRow, nCol, nSumEndRow ) )
     663                 :            :             {
     664         [ #  # ]:          0 :                 ScRangeList aRangeList;
     665                 :          0 :                 const ScRange aRange( nCol, nStartRow, nTab, nCol, nSumEndRow, nTab );
     666 [ #  # ][ #  # ]:          0 :                 if ( lcl_GetAutoSumForColumnRange( pDoc, aRangeList, aRange ) )
     667                 :            :                 {
     668                 :            :                     const String aFormula = GetAutoSumFormula(
     669         [ #  # ]:          0 :                         aRangeList, bSubTotal, ScAddress(nCol, nInsRow, nTab));
     670 [ #  # ][ #  # ]:          0 :                     EnterData( nCol, nInsRow, nTab, aFormula );
     671         [ #  # ]:          0 :                 }
     672                 :            :             }
     673                 :            :         }
     674                 :            :     }
     675                 :            : 
     676         [ #  # ]:          0 :     if ( bCol )
     677                 :            :     {
     678                 :            :         // calculate the column sums for all rows of the given range
     679                 :            : 
     680                 :          0 :         SCCOL nSumEndCol = nEndCol;
     681                 :            : 
     682         [ #  # ]:          0 :         if ( bEndColEmpty )
     683                 :            :         {
     684                 :            :             // the last column of the given range is empty;
     685                 :            :             // don't take into account for calculating the autosum
     686                 :          0 :             --nSumEndCol;
     687                 :            :         }
     688                 :            :         else
     689                 :            :         {
     690                 :            :             // increase mark range
     691                 :          0 :             ++nMarkEndCol;
     692                 :            :         }
     693                 :            : 
     694         [ #  # ]:          0 :         for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
     695                 :            :         {
     696 [ #  # ][ #  # ]:          0 :             if ( !pDoc->IsBlockEmpty( nTab, nStartCol, nRow, nSumEndCol, nRow ) )
     697                 :            :             {
     698         [ #  # ]:          0 :                 ScRangeList aRangeList;
     699                 :          0 :                 const ScRange aRange( nStartCol, nRow, nTab, nSumEndCol, nRow, nTab );
     700 [ #  # ][ #  # ]:          0 :                 if ( lcl_GetAutoSumForRowRange( pDoc, aRangeList, aRange ) )
     701                 :            :                 {
     702         [ #  # ]:          0 :                     const String aFormula = GetAutoSumFormula( aRangeList, bSubTotal, ScAddress(nInsCol, nRow, nTab) );
     703 [ #  # ][ #  # ]:          0 :                     EnterData( nInsCol, nRow, nTab, aFormula );
     704         [ #  # ]:          0 :                 }
     705                 :            :             }
     706                 :            :         }
     707                 :            :     }
     708                 :            : 
     709                 :            :     // set new mark range and cursor position
     710                 :          0 :     const ScRange aMarkRange( nStartCol, nStartRow, nTab, nMarkEndCol, nMarkEndRow, nTab );
     711         [ #  # ]:          0 :     MarkRange( aMarkRange, false, bContinue );
     712         [ #  # ]:          0 :     if ( bSetCursor )
     713                 :            :     {
     714         [ #  # ]:          0 :         SetCursor( nMarkEndCol, nMarkEndRow );
     715                 :            :     }
     716                 :            : 
     717                 :          0 :     return true;
     718                 :            : }
     719                 :            : 
     720                 :            : //----------------------------------------------------------------------------
     721                 :            : 
     722                 :          0 : String ScViewFunc::GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr )
     723                 :            : {
     724                 :          0 :     ScViewData* pViewData = GetViewData();
     725         [ #  # ]:          0 :     ScDocument* pDoc = pViewData->GetDocument();
     726 [ #  # ][ #  # ]:          0 :     ::boost::scoped_ptr<ScTokenArray> pArray(new ScTokenArray);
     727                 :            : 
     728 [ #  # ][ #  # ]:          0 :     pArray->AddOpCode(bSubTotal ? ocSubTotal : ocSum);
     729         [ #  # ]:          0 :     pArray->AddOpCode(ocOpen);
     730                 :            : 
     731         [ #  # ]:          0 :     if (bSubTotal)
     732                 :            :     {
     733         [ #  # ]:          0 :         pArray->AddDouble(9);
     734         [ #  # ]:          0 :         pArray->AddOpCode(ocSep);
     735                 :            :     }
     736                 :            : 
     737 [ #  # ][ #  # ]:          0 :     if(!rRangeList.empty())
     738                 :            :     {
     739         [ #  # ]:          0 :         ScRangeList aRangeList = rRangeList;
     740         [ #  # ]:          0 :         const ScRange* pFirst = aRangeList.front();
     741         [ #  # ]:          0 :         size_t ListSize = aRangeList.size();
     742         [ #  # ]:          0 :         for ( size_t i = 0; i < ListSize; ++i )
     743                 :            :         {
     744         [ #  # ]:          0 :             const ScRange* p = aRangeList[i];
     745         [ #  # ]:          0 :             if (p != pFirst)
     746         [ #  # ]:          0 :                 pArray->AddOpCode(ocSep);
     747                 :            :             ScComplexRefData aRef;
     748         [ #  # ]:          0 :             aRef.InitRangeRel(*p, rAddr);
     749         [ #  # ]:          0 :             pArray->AddDoubleReference(aRef);
     750         [ #  # ]:          0 :         }
     751                 :            :     }
     752                 :            : 
     753         [ #  # ]:          0 :     pArray->AddOpCode(ocClose);
     754                 :            : 
     755         [ #  # ]:          0 :     ScCompiler aComp(pDoc, rAddr, *pArray);
     756 [ #  # ][ #  # ]:          0 :     aComp.SetGrammar(pDoc->GetGrammar());
     757                 :          0 :     OUStringBuffer aBuf;
     758         [ #  # ]:          0 :     aComp.CreateStringFromTokenArray(aBuf);
     759         [ #  # ]:          0 :     OUString aFormula = aBuf.makeStringAndClear();
     760         [ #  # ]:          0 :     aBuf.append(sal_Unicode('='));
     761         [ #  # ]:          0 :     aBuf.append(aFormula);
     762 [ #  # ][ #  # ]:          0 :     return aBuf.makeStringAndClear();
         [ #  # ][ #  # ]
     763                 :            : }
     764                 :            : 
     765                 :            : //----------------------------------------------------------------------------
     766                 :            : 
     767                 :          0 : void ScViewFunc::EnterBlock( const String& rString, const EditTextObject* pData )
     768                 :            : {
     769                 :            :     //  test for multi selection
     770                 :            : 
     771                 :          0 :     SCCOL nCol = GetViewData()->GetCurX();
     772                 :          0 :     SCROW nRow = GetViewData()->GetCurY();
     773                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
     774         [ #  # ]:          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
     775         [ #  # ]:          0 :     if ( rMark.IsMultiMarked() )
     776                 :            :     {
     777         [ #  # ]:          0 :         rMark.MarkToSimple();
     778         [ #  # ]:          0 :         if ( rMark.IsMultiMarked() )
     779                 :            :         {       // "Insert into multi selection not possible"
     780         [ #  # ]:          0 :             ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
     781                 :            : 
     782                 :            :             //  insert into single cell
     783         [ #  # ]:          0 :             if ( pData )
     784         [ #  # ]:          0 :                 EnterData( nCol, nRow, nTab, pData );
     785                 :            :             else
     786         [ #  # ]:          0 :                 EnterData( nCol, nRow, nTab, rString );
     787                 :          0 :             return;
     788                 :            :         }
     789                 :            :     }
     790                 :            : 
     791         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     792         [ #  # ]:          0 :     String aNewStr = rString;
     793         [ #  # ]:          0 :     if ( pData )
     794                 :            :     {
     795         [ #  # ]:          0 :         const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
     796 [ #  # ][ #  # ]:          0 :         ScTabEditEngine aEngine( *pOldPattern, pDoc->GetEnginePool() );
     797         [ #  # ]:          0 :         aEngine.SetText(*pData);
     798                 :            : 
     799         [ #  # ]:          0 :         ScEditAttrTester aTester( &aEngine );
     800         [ #  # ]:          0 :         if (!aTester.NeedsObject())
     801                 :            :         {
     802 [ #  # ][ #  # ]:          0 :             aNewStr = aEngine.GetText();
                 [ #  # ]
     803                 :          0 :             pData = NULL;
     804 [ #  # ][ #  # ]:          0 :         }
     805                 :            :     }
     806                 :            : 
     807                 :            :     //  Insert via PasteFromClip
     808                 :            : 
     809         [ #  # ]:          0 :     WaitObject aWait( GetFrameWin() );
     810                 :            : 
     811                 :          0 :     ScAddress aPos( nCol, nRow, nTab );
     812                 :            : 
     813 [ #  # ][ #  # ]:          0 :     ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP );
     814         [ #  # ]:          0 :     pInsDoc->ResetClip( pDoc, nTab );
     815                 :            : 
     816         [ #  # ]:          0 :     if (aNewStr.GetChar(0) == '=')                      // Formula ?
     817                 :            :     {
     818                 :            :         //  SetString not possible, because in Clipboard-Documents nothing will be compiled!
     819 [ #  # ][ #  # ]:          0 :         ScFormulaCell* pFCell = new ScFormulaCell( pDoc, aPos, aNewStr );
                 [ #  # ]
     820 [ #  # ][ #  # ]:          0 :         pInsDoc->PutCell( nCol, nRow, nTab, pFCell );
     821                 :            :     }
     822         [ #  # ]:          0 :     else if ( pData )
     823 [ #  # ][ #  # ]:          0 :         pInsDoc->PutCell( nCol, nRow, nTab, new ScEditCell( pData, pDoc, NULL ) );
                 [ #  # ]
     824                 :            :     else
     825 [ #  # ][ #  # ]:          0 :         pInsDoc->SetString( nCol, nRow, nTab, aNewStr );
     826                 :            : 
     827         [ #  # ]:          0 :     pInsDoc->SetClipArea( ScRange(aPos) );
     828                 :            :     // insert Block, with Undo etc.
     829 [ #  # ][ #  # ]:          0 :     if ( PasteFromClip( IDF_CONTENTS, pInsDoc, PASTE_NOFUNC, false, false,
     830                 :            :             false, INS_NONE, IDF_ATTRIB ) )
     831                 :            :     {
     832                 :            :         const SfxUInt32Item* pItem = (SfxUInt32Item*) pInsDoc->GetAttr(
     833         [ #  # ]:          0 :             nCol, nRow, nTab, ATTR_VALUE_FORMAT );
     834         [ #  # ]:          0 :         if ( pItem )
     835                 :            :         {   // set number format if incompatible
     836                 :            :             // MarkData was already MarkToSimple'ed in PasteFromClip
     837                 :          0 :             ScRange aRange;
     838         [ #  # ]:          0 :             rMark.GetMarkArea( aRange );
     839 [ #  # ][ #  # ]:          0 :             ScPatternAttr* pPattern = new ScPatternAttr( pDoc->GetPool() );
                 [ #  # ]
     840         [ #  # ]:          0 :             pPattern->GetItemSet().Put( *pItem );
     841 [ #  # ][ #  # ]:          0 :             short nNewType = pDoc->GetFormatTable()->GetType( pItem->GetValue() );
     842                 :            :             pDoc->ApplyPatternIfNumberformatIncompatible( aRange, rMark,
     843         [ #  # ]:          0 :                 *pPattern, nNewType );
     844 [ #  # ][ #  # ]:          0 :             delete pPattern;
     845                 :            :         }
     846                 :            :     }
     847                 :            : 
     848 [ #  # ][ #  # ]:          0 :     delete pInsDoc;
         [ #  # ][ #  # ]
     849                 :            : }
     850                 :            : 
     851                 :            : 
     852                 :            : //----------------------------------------------------------------------------
     853                 :            : //  manual page break
     854                 :            : 
     855                 :          0 : void ScViewFunc::InsertPageBreak( sal_Bool bColumn, sal_Bool bRecord, const ScAddress* pPos,
     856                 :            :                                     sal_Bool bSetModified )
     857                 :            : {
     858                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
     859                 :          0 :     ScAddress aCursor;
     860         [ #  # ]:          0 :     if (pPos)
     861                 :          0 :         aCursor = *pPos;
     862                 :            :     else
     863                 :          0 :         aCursor = ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
     864                 :            : 
     865                 :          0 :     sal_Bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
     866         [ #  # ]:          0 :                         InsertPageBreak( bColumn, aCursor, bRecord, bSetModified, false );
     867                 :            : 
     868 [ #  # ][ #  # ]:          0 :     if ( bSuccess && bSetModified )
     869         [ #  # ]:          0 :         UpdatePageBreakData( true );    // for PageBreak-Mode
     870                 :          0 : }
     871                 :            : 
     872                 :            : 
     873                 :            : //----------------------------------------------------------------------------
     874                 :            : 
     875                 :          0 : void ScViewFunc::DeletePageBreak( sal_Bool bColumn, sal_Bool bRecord, const ScAddress* pPos,
     876                 :            :                                     sal_Bool bSetModified )
     877                 :            : {
     878                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
     879                 :          0 :     ScAddress aCursor;
     880         [ #  # ]:          0 :     if (pPos)
     881                 :          0 :         aCursor = *pPos;
     882                 :            :     else
     883                 :          0 :         aCursor = ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
     884                 :            : 
     885                 :          0 :     sal_Bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
     886         [ #  # ]:          0 :                         RemovePageBreak( bColumn, aCursor, bRecord, bSetModified, false );
     887                 :            : 
     888 [ #  # ][ #  # ]:          0 :     if ( bSuccess && bSetModified )
     889         [ #  # ]:          0 :         UpdatePageBreakData( true );    // for PageBreak-Mode
     890                 :          0 : }
     891                 :            : 
     892                 :            : //----------------------------------------------------------------------------
     893                 :            : 
     894                 :          0 : void ScViewFunc::RemoveManualBreaks()
     895                 :            : {
     896                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     897                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
     898                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
     899                 :          0 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
     900                 :            : 
     901         [ #  # ]:          0 :     if (bUndo)
     902                 :            :     {
     903         [ #  # ]:          0 :         ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     904                 :          0 :         pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, sal_True );
     905                 :          0 :         pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, false, pUndoDoc );
     906                 :          0 :         pDocSh->GetUndoManager()->AddUndoAction(
     907         [ #  # ]:          0 :                                 new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
     908                 :            :     }
     909                 :            : 
     910                 :          0 :     pDoc->RemoveManualBreaks(nTab);
     911                 :          0 :     pDoc->UpdatePageBreaks(nTab);
     912                 :            : 
     913                 :          0 :     UpdatePageBreakData( sal_True );
     914                 :          0 :     pDocSh->SetDocumentModified();
     915                 :          0 :     pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
     916                 :          0 : }
     917                 :            : 
     918                 :            : //----------------------------------------------------------------------------
     919                 :            : 
     920                 :          0 : void ScViewFunc::SetPrintZoom(sal_uInt16 nScale, sal_uInt16 nPages)
     921                 :            : {
     922                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     923                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
     924                 :          0 :     pDocSh->SetPrintZoom( nTab, nScale, nPages );
     925                 :          0 : }
     926                 :            : 
     927                 :          0 : void ScViewFunc::AdjustPrintZoom()
     928                 :            : {
     929                 :          0 :     ScRange aRange;
     930 [ #  # ][ #  # ]:          0 :     if ( GetViewData()->GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
     931 [ #  # ][ #  # ]:          0 :         GetViewData()->GetMarkData().GetMultiMarkArea( aRange );
     932         [ #  # ]:          0 :     GetViewData()->GetDocShell()->AdjustPrintZoom( aRange );
     933                 :          0 : }
     934                 :            : 
     935                 :            : //----------------------------------------------------------------------------
     936                 :            : 
     937                 :          0 : void ScViewFunc::SetPrintRanges( sal_Bool bEntireSheet, const String* pPrint,
     938                 :            :                                 const String* pRepCol, const String* pRepRow,
     939                 :            :                                 sal_Bool bAddPrint )
     940                 :            : {
     941                 :            :     //  on all selected tables
     942                 :            : 
     943                 :          0 :     ScDocShell* pDocSh  = GetViewData()->GetDocShell();
     944                 :          0 :     ScDocument* pDoc    = pDocSh->GetDocument();
     945         [ #  # ]:          0 :     ScMarkData& rMark   = GetViewData()->GetMarkData();
     946                 :            :     SCTAB nTab;
     947                 :          0 :     sal_Bool bUndo (pDoc->IsUndoEnabled());
     948                 :            : 
     949         [ #  # ]:          0 :     ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
     950                 :            : 
     951         [ #  # ]:          0 :     ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0);
     952                 :            : 
     953 [ #  # ][ #  # ]:          0 :     ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
     954 [ #  # ][ #  # ]:          0 :     for (; itr != itrEnd; ++itr)
                 [ #  # ]
     955                 :            :     {
     956         [ #  # ]:          0 :         nTab = *itr;
     957                 :          0 :         ScRange aRange( 0,0,nTab );
     958                 :            : 
     959                 :            :         //  print ranges
     960                 :            : 
     961         [ #  # ]:          0 :         if( !bAddPrint )
     962         [ #  # ]:          0 :             pDoc->ClearPrintRanges( nTab );
     963                 :            : 
     964         [ #  # ]:          0 :         if( bEntireSheet )
     965                 :            :         {
     966         [ #  # ]:          0 :             pDoc->SetPrintEntireSheet( nTab );
     967                 :            :         }
     968         [ #  # ]:          0 :         else if ( pPrint )
     969                 :            :         {
     970         [ #  # ]:          0 :             if ( pPrint->Len() )
     971                 :            :             {
     972         [ #  # ]:          0 :                 const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
     973 [ #  # ][ #  # ]:          0 :                 sal_uInt16 nTCount = comphelper::string::getTokenCount(*pPrint, sep);
     974         [ #  # ]:          0 :                 for (sal_uInt16 i=0; i<nTCount; i++)
     975                 :            :                 {
     976         [ #  # ]:          0 :                     String aToken = pPrint->GetToken(i, sep);
     977 [ #  # ][ #  # ]:          0 :                     if ( aRange.ParseAny( aToken, pDoc, aDetails ) & SCA_VALID )
     978         [ #  # ]:          0 :                         pDoc->AddPrintRange( nTab, aRange );
     979         [ #  # ]:          0 :                 }
     980                 :            :             }
     981                 :            :         }
     982                 :            :         else    // NULL = use selection (print range is always set), use empty string to delete all ranges
     983                 :            :         {
     984 [ #  # ][ #  # ]:          0 :             if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
     985                 :            :             {
     986         [ #  # ]:          0 :                 pDoc->AddPrintRange( nTab, aRange );
     987                 :            :             }
     988         [ #  # ]:          0 :             else if ( rMark.IsMultiMarked() )
     989                 :            :             {
     990         [ #  # ]:          0 :                 rMark.MarkToMulti();
     991 [ #  # ][ #  # ]:          0 :                 ScRangeListRef pList( new ScRangeList );
     992         [ #  # ]:          0 :                 rMark.FillRangeListWithMarks( pList, false );
     993 [ #  # ][ #  # ]:          0 :                 for (size_t i = 0, n = pList->size(); i < n; ++i)
     994                 :            :                 {
     995         [ #  # ]:          0 :                     ScRange* pR = (*pList)[i];
     996         [ #  # ]:          0 :                     pDoc->AddPrintRange(nTab, *pR);
     997         [ #  # ]:          0 :                 }
     998                 :            :             }
     999                 :            :         }
    1000                 :            : 
    1001                 :            :         //  repeat columns
    1002                 :            : 
    1003         [ #  # ]:          0 :         if ( pRepCol )
    1004                 :            :         {
    1005         [ #  # ]:          0 :             if ( !pRepCol->Len() )
    1006         [ #  # ]:          0 :                 pDoc->SetRepeatColRange( nTab, NULL );
    1007                 :            :             else
    1008 [ #  # ][ #  # ]:          0 :                 if ( aRange.ParseAny( *pRepCol, pDoc, aDetails ) & SCA_VALID )
    1009         [ #  # ]:          0 :                     pDoc->SetRepeatColRange( nTab, &aRange );
    1010                 :            :         }
    1011                 :            : 
    1012                 :            :         //  repeat rows
    1013                 :            : 
    1014         [ #  # ]:          0 :         if ( pRepRow )
    1015                 :            :         {
    1016         [ #  # ]:          0 :             if ( !pRepRow->Len() )
    1017         [ #  # ]:          0 :                 pDoc->SetRepeatRowRange( nTab, NULL );
    1018                 :            :             else
    1019 [ #  # ][ #  # ]:          0 :                 if ( aRange.ParseAny( *pRepRow, pDoc, aDetails ) & SCA_VALID )
    1020         [ #  # ]:          0 :                     pDoc->SetRepeatRowRange( nTab, &aRange );
    1021                 :            :         }
    1022                 :            :     }
    1023                 :            : 
    1024                 :            :     //  undo (for all tables)
    1025         [ #  # ]:          0 :     if (bUndo)
    1026                 :            :     {
    1027                 :          0 :         SCTAB nCurTab = GetViewData()->GetTabNo();
    1028         [ #  # ]:          0 :         ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver();
    1029         [ #  # ]:          0 :         pDocSh->GetUndoManager()->AddUndoAction(
    1030 [ #  # ][ #  # ]:          0 :                     new ScUndoPrintRange( pDocSh, nCurTab, pOldRanges, pNewRanges ) );
                 [ #  # ]
    1031                 :            :     }
    1032                 :            : 
    1033                 :            :     //  update page breaks
    1034                 :            : 
    1035         [ #  # ]:          0 :     itr = rMark.begin();
    1036 [ #  # ][ #  # ]:          0 :     for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1037 [ #  # ][ #  # ]:          0 :         ScPrintFunc( pDocSh, pDocSh->GetPrinter(), *itr ).UpdatePages();
         [ #  # ][ #  # ]
                 [ #  # ]
    1038                 :            : 
    1039         [ #  # ]:          0 :     SfxBindings& rBindings = GetViewData()->GetBindings();
    1040         [ #  # ]:          0 :     rBindings.Invalidate( SID_DELETE_PRINTAREA );
    1041                 :            : 
    1042         [ #  # ]:          0 :     pDocSh->SetDocumentModified();
    1043                 :          0 : }
    1044                 :            : 
    1045                 :            : //----------------------------------------------------------------------------
    1046                 :            : //  Merge cells
    1047                 :            : 
    1048                 :        240 : sal_Bool ScViewFunc::TestMergeCells()           // pre-test (for menu)
    1049                 :            : {
    1050                 :            :     //  simple test: sal_True if there's a selection but no multi selection and not filtered
    1051                 :            : 
    1052                 :        240 :     const ScMarkData& rMark = GetViewData()->GetMarkData();
    1053 [ -  + ][ -  + ]:        240 :     if ( rMark.IsMarked() || rMark.IsMultiMarked() )
                 [ +  - ]
    1054                 :            :     {
    1055                 :          0 :         ScRange aDummy;
    1056         [ #  # ]:          0 :         return GetViewData()->GetSimpleArea( aDummy) == SC_MARK_SIMPLE;
    1057                 :            :     }
    1058                 :            :     else
    1059                 :        240 :         return false;
    1060                 :            : }
    1061                 :            : 
    1062                 :            : 
    1063                 :            : //----------------------------------------------------------------------------
    1064                 :            : 
    1065                 :          0 : sal_Bool ScViewFunc::MergeCells( sal_Bool bApi, sal_Bool& rDoContents, sal_Bool bRecord, sal_Bool bCenter )
    1066                 :            : {
    1067                 :            :     //  Editable- and Being-Nested- test must be at the beginning (in DocFunc too),
    1068                 :            :     //  so that the Contents-QueryBox won't appear
    1069         [ #  # ]:          0 :     ScEditableTester aTester( this );
    1070         [ #  # ]:          0 :     if (!aTester.IsEditable())
    1071                 :            :     {
    1072 [ #  # ][ #  # ]:          0 :         ErrorMessage(aTester.GetMessageId());
    1073                 :          0 :         return false;
    1074                 :            :     }
    1075                 :            : 
    1076         [ #  # ]:          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
    1077         [ #  # ]:          0 :     rMark.MarkToSimple();
    1078         [ #  # ]:          0 :     if (!rMark.IsMarked())
    1079                 :            :     {
    1080         [ #  # ]:          0 :         ErrorMessage(STR_NOMULTISELECT);
    1081                 :          0 :         return false;
    1082                 :            :     }
    1083                 :            : 
    1084                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1085                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    1086                 :            : 
    1087                 :          0 :     ScRange aMarkRange;
    1088         [ #  # ]:          0 :     rMark.GetMarkArea( aMarkRange );
    1089                 :          0 :     SCCOL nStartCol = aMarkRange.aStart.Col();
    1090                 :          0 :     SCROW nStartRow = aMarkRange.aStart.Row();
    1091                 :          0 :     SCTAB nStartTab = aMarkRange.aStart.Tab();
    1092                 :          0 :     SCCOL nEndCol = aMarkRange.aEnd.Col();
    1093                 :          0 :     SCROW nEndRow = aMarkRange.aEnd.Row();
    1094                 :          0 :     SCTAB nEndTab = aMarkRange.aEnd.Tab();
    1095 [ #  # ][ #  # ]:          0 :     if ( nStartCol == nEndCol && nStartRow == nEndRow )
    1096                 :            :     {
    1097                 :            :         // nothing to do
    1098                 :          0 :         return true;
    1099                 :            :     }
    1100                 :            : 
    1101 [ #  # ][ #  # ]:          0 :     if ( pDoc->HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
    1102                 :          0 :                             HASATTR_MERGED | HASATTR_OVERLAPPED ) )
    1103                 :            :     {       // "Don't nest merging  !"
    1104         [ #  # ]:          0 :         ErrorMessage(STR_MSSG_MERGECELLS_0);
    1105                 :          0 :         return false;
    1106                 :            :     }
    1107                 :            : 
    1108                 :            :     // Check for the contents of all selected tables.
    1109                 :          0 :     bool bAskDialog = false;
    1110         [ #  # ]:          0 :     ScCellMergeOption aMergeOption(nStartCol, nStartRow, nEndCol, nEndRow, bCenter);
    1111 [ #  # ][ #  # ]:          0 :     ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
    1112 [ #  # ][ #  # ]:          0 :     for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1113                 :            :     {
    1114         [ #  # ]:          0 :         SCTAB i = *itr;
    1115         [ #  # ]:          0 :         aMergeOption.maTabs.insert(i);
    1116                 :            : 
    1117 [ #  # ][ #  # ]:          0 :         if (!pDoc->IsBlockEmpty(i, nStartCol, nStartRow+1, nStartCol, nEndRow) ||
         [ #  # ][ #  # ]
    1118         [ #  # ]:          0 :             !pDoc->IsBlockEmpty(i, nStartCol+1, nStartRow, nEndCol, nEndRow))
    1119                 :          0 :             bAskDialog = true;
    1120                 :            :     }
    1121                 :            : 
    1122                 :          0 :     sal_Bool bOk = true;
    1123                 :            : 
    1124         [ #  # ]:          0 :     if (bAskDialog)
    1125                 :            :     {
    1126         [ #  # ]:          0 :         if (!bApi)
    1127                 :            :         {
    1128                 :            :             MessBox aBox( GetViewData()->GetDialogParent(),
    1129                 :            :                             WinBits(WB_YES_NO_CANCEL | WB_DEF_NO),
    1130         [ #  # ]:          0 :                             ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
    1131 [ #  # ][ #  # ]:          0 :                             ScGlobal::GetRscString( STR_MERGE_NOTEMPTY ) );
                 [ #  # ]
    1132         [ #  # ]:          0 :             sal_uInt16 nRetVal = aBox.Execute();
    1133                 :            : 
    1134         [ #  # ]:          0 :             if ( nRetVal == RET_YES )
    1135                 :          0 :                 rDoContents = sal_True;
    1136         [ #  # ]:          0 :             else if ( nRetVal == RET_CANCEL )
    1137         [ #  # ]:          0 :                 bOk = false;
    1138                 :            :         }
    1139                 :            :     }
    1140                 :            : 
    1141         [ #  # ]:          0 :     if (bOk)
    1142                 :            :     {
    1143         [ #  # ]:          0 :         bOk = pDocSh->GetDocFunc().MergeCells( aMergeOption, rDoContents, bRecord, bApi );
    1144                 :            : 
    1145         [ #  # ]:          0 :         if (bOk)
    1146                 :            :         {
    1147         [ #  # ]:          0 :             SetCursor( nStartCol, nStartRow );
    1148                 :            :             //DoneBlockMode( sal_False);
    1149         [ #  # ]:          0 :             Unmark();
    1150                 :            : 
    1151         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
    1152         [ #  # ]:          0 :             UpdateInputLine();
    1153                 :            :         }
    1154                 :            :     }
    1155                 :            : 
    1156                 :          0 :     return bOk;
    1157                 :            : }
    1158                 :            : 
    1159                 :            : 
    1160                 :            : //----------------------------------------------------------------------------
    1161                 :            : 
    1162                 :        240 : sal_Bool ScViewFunc::TestRemoveMerge()
    1163                 :            : {
    1164                 :        240 :     sal_Bool bMerged = false;
    1165                 :        240 :     ScRange aRange;
    1166 [ +  - ][ +  - ]:        240 :     if (GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE)
    1167                 :            :     {
    1168         [ +  - ]:        240 :         ScDocument* pDoc = GetViewData()->GetDocument();
    1169 [ +  - ][ -  + ]:        240 :         if ( pDoc->HasAttrib( aRange, HASATTR_MERGED ) )
    1170                 :          0 :             bMerged = sal_True;
    1171                 :            :     }
    1172                 :        240 :     return bMerged;
    1173                 :            : }
    1174                 :            : 
    1175                 :            : 
    1176                 :            : //----------------------------------------------------------------------------
    1177                 :            : 
    1178                 :          0 : static bool lcl_extendMergeRange(ScCellMergeOption& rOption, const ScRange& rRange)
    1179                 :            : {
    1180                 :          0 :     bool bExtended = false;
    1181         [ #  # ]:          0 :     if (rOption.mnStartCol > rRange.aStart.Col())
    1182                 :            :     {
    1183                 :          0 :         rOption.mnStartCol = rRange.aStart.Col();
    1184                 :          0 :         bExtended = true;
    1185                 :            :     }
    1186         [ #  # ]:          0 :     if (rOption.mnStartRow > rRange.aStart.Row())
    1187                 :            :     {
    1188                 :          0 :         rOption.mnStartRow = rRange.aStart.Row();
    1189                 :          0 :         bExtended = true;
    1190                 :            :     }
    1191         [ #  # ]:          0 :     if (rOption.mnEndCol < rRange.aEnd.Col())
    1192                 :            :     {
    1193                 :          0 :         rOption.mnEndCol = rRange.aEnd.Col();
    1194                 :          0 :         bExtended = true;
    1195                 :            :     }
    1196         [ #  # ]:          0 :     if (rOption.mnEndRow < rRange.aEnd.Row())
    1197                 :            :     {
    1198                 :          0 :         rOption.mnEndRow = rRange.aEnd.Row();
    1199                 :          0 :         bExtended = true;
    1200                 :            :     }
    1201                 :          0 :     return bExtended;
    1202                 :            : }
    1203                 :            : 
    1204                 :          0 : sal_Bool ScViewFunc::RemoveMerge( sal_Bool bRecord )
    1205                 :            : {
    1206                 :          0 :     ScRange aRange;
    1207         [ #  # ]:          0 :     ScEditableTester aTester( this );
    1208         [ #  # ]:          0 :     if (!aTester.IsEditable())
    1209                 :            :     {
    1210 [ #  # ][ #  # ]:          0 :         ErrorMessage(aTester.GetMessageId());
    1211                 :          0 :         return false;
    1212                 :            :     }
    1213 [ #  # ][ #  # ]:          0 :     else if (GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE)
    1214                 :            :     {
    1215         [ #  # ]:          0 :         ScDocument* pDoc = GetViewData()->GetDocument();
    1216                 :          0 :         ScRange aExtended( aRange );
    1217         [ #  # ]:          0 :         pDoc->ExtendMerge( aExtended );
    1218                 :          0 :         ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1219         [ #  # ]:          0 :         const ScMarkData& rMark = GetViewData()->GetMarkData();
    1220         [ #  # ]:          0 :         ScCellMergeOption aOption(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row());
    1221                 :          0 :         bool bExtended = false;
    1222         [ #  # ]:          0 :         do
    1223                 :            :         {
    1224                 :          0 :             bExtended = false;
    1225 [ #  # ][ #  # ]:          0 :             ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
    1226 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1227                 :            :             {
    1228         [ #  # ]:          0 :                 SCTAB i = *itr;
    1229         [ #  # ]:          0 :                 aOption.maTabs.insert(i);
    1230                 :          0 :                 aExtended.aStart.SetTab(i);
    1231                 :          0 :                 aExtended.aEnd.SetTab(i);
    1232         [ #  # ]:          0 :                 pDoc->ExtendMerge(aExtended);
    1233         [ #  # ]:          0 :                 pDoc->ExtendOverlapped(aExtended);
    1234                 :            : 
    1235                 :            :                 // Expand the current range to be inclusive of all merged
    1236                 :            :                 // areas on all sheets.
    1237                 :          0 :                 bExtended = lcl_extendMergeRange(aOption, aExtended);
    1238                 :            :             }
    1239                 :            :         }
    1240                 :            :         while (bExtended);
    1241                 :            : 
    1242         [ #  # ]:          0 :         sal_Bool bOk = pDocSh->GetDocFunc().UnmergeCells(aOption, bRecord );
    1243         [ #  # ]:          0 :         aExtended = aOption.getFirstSingleRange();
    1244         [ #  # ]:          0 :         MarkRange( aExtended );
    1245                 :            : 
    1246         [ #  # ]:          0 :         if (bOk)
    1247         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
    1248                 :            :     }
    1249                 :          0 :     return sal_True;        //! bOk ??
    1250                 :            : }
    1251                 :            : 
    1252                 :            : //----------------------------------------------------------------------------
    1253                 :            : 
    1254                 :          0 : void ScViewFunc::FillSimple( FillDir eDir, bool bRecord )
    1255                 :            : {
    1256                 :          0 :     ScRange aRange;
    1257 [ #  # ][ #  # ]:          0 :     if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
    1258                 :            :     {
    1259                 :          0 :         ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1260         [ #  # ]:          0 :         const ScMarkData& rMark = GetViewData()->GetMarkData();
    1261         [ #  # ]:          0 :         bool bSuccess = pDocSh->GetDocFunc().FillSimple( aRange, &rMark, eDir, bRecord, false );
    1262         [ #  # ]:          0 :         if (bSuccess)
    1263                 :            :         {
    1264         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
    1265         [ #  # ]:          0 :             UpdateScrollBars();
    1266                 :            :         }
    1267                 :            :     }
    1268                 :            :     else
    1269         [ #  # ]:          0 :         ErrorMessage(STR_NOMULTISELECT);
    1270                 :          0 : }
    1271                 :            : 
    1272                 :            : //----------------------------------------------------------------------------
    1273                 :            : 
    1274                 :          0 : void ScViewFunc::FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
    1275                 :            :                              double fStart, double fStep, double fMax, sal_Bool bRecord )
    1276                 :            : {
    1277                 :          0 :     ScRange aRange;
    1278 [ #  # ][ #  # ]:          0 :     if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
    1279                 :            :     {
    1280                 :          0 :         ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1281         [ #  # ]:          0 :         const ScMarkData& rMark = GetViewData()->GetMarkData();
    1282                 :          0 :         sal_Bool bSuccess = pDocSh->GetDocFunc().
    1283                 :            :                         FillSeries( aRange, &rMark, eDir, eCmd, eDateCmd,
    1284         [ #  # ]:          0 :                                     fStart, fStep, fMax, bRecord, false );
    1285         [ #  # ]:          0 :         if (bSuccess)
    1286                 :            :         {
    1287         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
    1288         [ #  # ]:          0 :             UpdateScrollBars();
    1289                 :            : 
    1290                 :            :             // #i97876# Spreadsheet data changes are not notified
    1291 [ #  # ][ #  # ]:          0 :             ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
    1292 [ #  # ][ #  # ]:          0 :             if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
    1293                 :            :             {
    1294         [ #  # ]:          0 :                 ScRangeList aChangeRanges;
    1295         [ #  # ]:          0 :                 aChangeRanges.Append( aRange );
    1296 [ #  # ][ #  # ]:          0 :                 pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
         [ #  # ][ #  # ]
                 [ #  # ]
    1297                 :            :             }
    1298                 :            :         }
    1299                 :            :     }
    1300                 :            :     else
    1301         [ #  # ]:          0 :         ErrorMessage(STR_NOMULTISELECT);
    1302                 :          0 : }
    1303                 :            : 
    1304                 :            : //----------------------------------------------------------------------------
    1305                 :            : 
    1306                 :          0 : void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
    1307                 :            :                             SCCOL nEndCol, SCROW nEndRow, sal_uLong nCount, sal_Bool bRecord )
    1308                 :            : {
    1309                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    1310                 :          0 :     ScRange aRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab );
    1311                 :          0 :     ScRange aSourceRange( aRange );
    1312                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1313         [ #  # ]:          0 :     const ScMarkData& rMark = GetViewData()->GetMarkData();
    1314                 :          0 :     sal_Bool bSuccess = pDocSh->GetDocFunc().
    1315         [ #  # ]:          0 :                     FillAuto( aRange, &rMark, eDir, nCount, bRecord, false );
    1316         [ #  # ]:          0 :     if (bSuccess)
    1317                 :            :     {
    1318         [ #  # ]:          0 :         MarkRange( aRange, false );         // aRange was modified in FillAuto
    1319         [ #  # ]:          0 :         pDocSh->UpdateOle(GetViewData());
    1320         [ #  # ]:          0 :         UpdateScrollBars();
    1321                 :            : 
    1322                 :            :         // #i97876# Spreadsheet data changes are not notified
    1323 [ #  # ][ #  # ]:          0 :         ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
    1324 [ #  # ][ #  # ]:          0 :         if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
    1325                 :            :         {
    1326         [ #  # ]:          0 :             ScRangeList aChangeRanges;
    1327                 :          0 :             ScRange aChangeRange( aRange );
    1328   [ #  #  #  #  :          0 :             switch ( eDir )
                      # ]
    1329                 :            :             {
    1330                 :            :                 case FILL_TO_BOTTOM:
    1331                 :            :                     {
    1332                 :          0 :                         aChangeRange.aStart.SetRow( aSourceRange.aEnd.Row() + 1 );
    1333                 :            :                     }
    1334                 :          0 :                     break;
    1335                 :            :                 case FILL_TO_TOP:
    1336                 :            :                     {
    1337                 :          0 :                         aChangeRange.aEnd.SetRow( aSourceRange.aStart.Row() - 1 );
    1338                 :            :                     }
    1339                 :          0 :                     break;
    1340                 :            :                 case FILL_TO_RIGHT:
    1341                 :            :                     {
    1342                 :          0 :                         aChangeRange.aStart.SetCol( aSourceRange.aEnd.Col() + 1 );
    1343                 :            :                     }
    1344                 :          0 :                     break;
    1345                 :            :                 case FILL_TO_LEFT:
    1346                 :            :                     {
    1347                 :          0 :                         aChangeRange.aEnd.SetCol( aSourceRange.aStart.Col() - 1 );
    1348                 :            :                     }
    1349                 :          0 :                     break;
    1350                 :            :                 default:
    1351                 :            :                     {
    1352                 :            : 
    1353                 :            :                     }
    1354                 :          0 :                     break;
    1355                 :            :             }
    1356         [ #  # ]:          0 :             aChangeRanges.Append( aChangeRange );
    1357 [ #  # ][ #  # ]:          0 :             pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
         [ #  # ][ #  # ]
                 [ #  # ]
    1358                 :            :         }
    1359                 :            :     }
    1360                 :          0 : }
    1361                 :            : 
    1362                 :            : //----------------------------------------------------------------------------
    1363                 :            : 
    1364                 :          0 : void ScViewFunc::FillTab( sal_uInt16 nFlags, sal_uInt16 nFunction, sal_Bool bSkipEmpty, sal_Bool bAsLink )
    1365                 :            : {
    1366                 :            :     //! allow source sheet to be protected
    1367         [ #  # ]:          0 :     ScEditableTester aTester( this );
    1368         [ #  # ]:          0 :     if (!aTester.IsEditable())
    1369                 :            :     {
    1370 [ #  # ][ #  # ]:          0 :         ErrorMessage(aTester.GetMessageId());
    1371                 :          0 :         return;
    1372                 :            :     }
    1373                 :            : 
    1374                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1375                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    1376         [ #  # ]:          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
    1377                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    1378                 :          0 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
    1379                 :            : 
    1380                 :          0 :     ScRange aMarkRange;
    1381         [ #  # ]:          0 :     rMark.MarkToSimple();
    1382                 :          0 :     sal_Bool bMulti = rMark.IsMultiMarked();
    1383         [ #  # ]:          0 :     if (bMulti)
    1384         [ #  # ]:          0 :         rMark.GetMultiMarkArea( aMarkRange );
    1385         [ #  # ]:          0 :     else if (rMark.IsMarked())
    1386         [ #  # ]:          0 :         rMark.GetMarkArea( aMarkRange );
    1387                 :            :     else
    1388                 :          0 :         aMarkRange = ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
    1389                 :            : 
    1390                 :          0 :     ScDocument* pUndoDoc = NULL;
    1391                 :            : 
    1392         [ #  # ]:          0 :     if (bUndo)
    1393                 :            :     {
    1394 [ #  # ][ #  # ]:          0 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1395         [ #  # ]:          0 :         pUndoDoc->InitUndo( pDoc, nTab, nTab );
    1396                 :            : 
    1397 [ #  # ][ #  # ]:          0 :         ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
    1398 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1399 [ #  # ][ #  # ]:          0 :             if (*itr != nTab )
    1400                 :            :             {
    1401         [ #  # ]:          0 :                 SCTAB i = *itr;
    1402         [ #  # ]:          0 :                 pUndoDoc->AddUndoTab( i, i );
    1403                 :          0 :                 aMarkRange.aStart.SetTab( i );
    1404                 :          0 :                 aMarkRange.aEnd.SetTab( i );
    1405         [ #  # ]:          0 :                 pDoc->CopyToDocument( aMarkRange, IDF_ALL, bMulti, pUndoDoc );
    1406                 :            :             }
    1407                 :            :     }
    1408                 :            : 
    1409         [ #  # ]:          0 :     if (bMulti)
    1410         [ #  # ]:          0 :         pDoc->FillTabMarked( nTab, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
    1411                 :            :     else
    1412                 :            :     {
    1413                 :          0 :         aMarkRange.aStart.SetTab( nTab );
    1414                 :          0 :         aMarkRange.aEnd.SetTab( nTab );
    1415         [ #  # ]:          0 :         pDoc->FillTab( aMarkRange, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
    1416                 :            :     }
    1417                 :            : 
    1418         [ #  # ]:          0 :     if (bUndo)
    1419                 :            :     {   //! for ChangeTrack not until the end
    1420         [ #  # ]:          0 :         pDocSh->GetUndoManager()->AddUndoAction(
    1421                 :            :             new ScUndoFillTable( pDocSh, rMark,
    1422                 :          0 :                                 aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nTab,
    1423                 :          0 :                                 aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), nTab,
    1424 [ #  # ][ #  # ]:          0 :                                 pUndoDoc, bMulti, nTab, nFlags, nFunction, bSkipEmpty, bAsLink ) );
                 [ #  # ]
    1425                 :            :     }
    1426                 :            : 
    1427         [ #  # ]:          0 :     pDocSh->PostPaintGridAll();
    1428 [ #  # ][ #  # ]:          0 :     pDocSh->PostDataChanged();
    1429                 :            : }
    1430                 :            : 
    1431                 :            : //----------------------------------------------------------------------------
    1432                 :            : 
    1433                 :            : /** Downward fill of selected cell(s) by double-clicking cross-hair cursor
    1434                 :            : 
    1435                 :            :     Extends a current selection down to the last non-empty cell of an adjacent
    1436                 :            :     column when the lower-right corner of the selection is double-clicked.  It
    1437                 :            :     uses a left-adjoining non-empty column as a guide if such is available,
    1438                 :            :     otherwise a right-adjoining non-empty column is used.
    1439                 :            : 
    1440                 :            :     @author Kohei Yoshida (kohei@openoffice.org)
    1441                 :            : 
    1442                 :            :     @return No return value
    1443                 :            : 
    1444                 :            :     @see #i12313#
    1445                 :            : */
    1446                 :          0 : void ScViewFunc::FillCrossDblClick()
    1447                 :            : {
    1448                 :          0 :     ScRange aRange;
    1449         [ #  # ]:          0 :     GetViewData()->GetSimpleArea( aRange );
    1450         [ #  # ]:          0 :     aRange.Justify();
    1451                 :            : 
    1452         [ #  # ]:          0 :     SCTAB nTab = GetViewData()->GetCurPos().Tab();
    1453                 :          0 :     SCCOL nStartX = aRange.aStart.Col();
    1454                 :          0 :     SCROW nStartY = aRange.aStart.Row();
    1455                 :          0 :     SCCOL nEndX   = aRange.aEnd.Col();
    1456                 :          0 :     SCROW nEndY   = aRange.aEnd.Row();
    1457                 :            : 
    1458         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
    1459                 :            : 
    1460                 :            :     // Make sure the selection is not empty
    1461 [ #  # ][ #  # ]:          0 :     if ( pDoc->IsBlockEmpty( nTab, nStartX, nStartY, nEndX, nEndY ) )
    1462                 :            :         return;
    1463                 :            : 
    1464         [ #  # ]:          0 :     if ( nEndY < MAXROW )
    1465                 :            :     {
    1466         [ #  # ]:          0 :         if ( nStartX > 0 )
    1467                 :            :         {
    1468                 :          0 :             SCCOL nMovX = nStartX - 1;
    1469                 :          0 :             SCROW nMovY = nStartY;
    1470                 :            : 
    1471 [ #  # ][ #  # ]:          0 :             if ( pDoc->HasData( nMovX, nStartY, nTab ) &&
         [ #  # ][ #  # ]
    1472         [ #  # ]:          0 :                  pDoc->HasData( nMovX, nStartY + 1, nTab ) )
    1473                 :            :             {
    1474         [ #  # ]:          0 :                 pDoc->FindAreaPos( nMovX, nMovY, nTab, SC_MOVE_DOWN );
    1475                 :            : 
    1476         [ #  # ]:          0 :                 if ( nMovY > nEndY )
    1477                 :            :                 {
    1478                 :            :                     FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY,
    1479         [ #  # ]:          0 :                               nMovY - nEndY );
    1480                 :            :                     return;
    1481                 :            :                 }
    1482                 :            :             }
    1483                 :            :         }
    1484                 :            : 
    1485         [ #  # ]:          0 :         if ( nEndX < MAXCOL )
    1486                 :            :         {
    1487                 :          0 :             SCCOL nMovX = nEndX + 1;
    1488                 :          0 :             SCROW nMovY = nStartY;
    1489                 :            : 
    1490 [ #  # ][ #  # ]:          0 :             if ( pDoc->HasData( nMovX, nStartY, nTab ) &&
         [ #  # ][ #  # ]
    1491         [ #  # ]:          0 :                  pDoc->HasData( nMovX, nStartY + 1, nTab ) )
    1492                 :            :             {
    1493         [ #  # ]:          0 :                 pDoc->FindAreaPos( nMovX, nMovY, nTab, SC_MOVE_DOWN );
    1494                 :            : 
    1495         [ #  # ]:          0 :                 if ( nMovY > nEndY )
    1496                 :            :                 {
    1497                 :            :                     FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY,
    1498         [ #  # ]:          0 :                               nMovY - nEndY );
    1499                 :            :                     return;
    1500                 :            :                 }
    1501                 :            :             }
    1502                 :            :         }
    1503                 :            :     }
    1504                 :            : }
    1505                 :            : 
    1506                 :            : //----------------------------------------------------------------------------
    1507                 :            : 
    1508                 :          0 : void ScViewFunc::TransliterateText( sal_Int32 nType )
    1509                 :            : {
    1510 [ #  # ][ #  # ]:          0 :     ScMarkData aFuncMark = GetViewData()->GetMarkData();
    1511 [ #  # ][ #  # ]:          0 :     if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
                 [ #  # ]
    1512                 :            :     {
    1513                 :            :         //  no selection -> use cursor position
    1514                 :            : 
    1515                 :          0 :         ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
    1516         [ #  # ]:          0 :         aFuncMark.SetMarkArea( ScRange( aCursor ) );
    1517                 :            :     }
    1518                 :            : 
    1519                 :          0 :     sal_Bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
    1520         [ #  # ]:          0 :                         TransliterateText( aFuncMark, nType, sal_True, false );
    1521         [ #  # ]:          0 :     if (bSuccess)
    1522                 :            :     {
    1523         [ #  # ]:          0 :         GetViewData()->GetViewShell()->UpdateInputHandler();
    1524         [ #  # ]:          0 :     }
    1525                 :          0 : }
    1526                 :            : 
    1527                 :            : //----------------------------------------------------------------------------
    1528                 :            : //  AutoFormat
    1529                 :            : 
    1530                 :          0 : ScAutoFormatData* ScViewFunc::CreateAutoFormatData()
    1531                 :            : {
    1532                 :          0 :     ScAutoFormatData* pData = NULL;
    1533                 :            :     SCCOL nStartCol;
    1534                 :            :     SCROW nStartRow;
    1535                 :            :     SCTAB nStartTab;
    1536                 :            :     SCCOL nEndCol;
    1537                 :            :     SCROW nEndRow;
    1538                 :            :     SCTAB nEndTab;
    1539 [ #  # ][ #  # ]:          0 :     if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
    1540                 :            :     {
    1541 [ #  # ][ #  # ]:          0 :         if ( nEndCol-nStartCol >= 3 && nEndRow-nStartRow >= 3 )
    1542                 :            :         {
    1543         [ #  # ]:          0 :             ScDocument* pDoc = GetViewData()->GetDocument();
    1544 [ #  # ][ #  # ]:          0 :             pData = new ScAutoFormatData;
    1545         [ #  # ]:          0 :             pDoc->GetAutoFormatData( nStartTab, nStartCol,nStartRow,nEndCol,nEndRow, *pData );
    1546                 :            :         }
    1547                 :            :     }
    1548                 :          0 :     return pData;
    1549                 :            : }
    1550                 :            : 
    1551                 :            : 
    1552                 :            : //----------------------------------------------------------------------------
    1553                 :            : 
    1554                 :          0 : void ScViewFunc::AutoFormat( sal_uInt16 nFormatNo, sal_Bool bRecord )
    1555                 :            : {
    1556                 :          0 :     ScRange aRange;
    1557 [ #  # ][ #  # ]:          0 :     if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
    1558                 :            :     {
    1559                 :          0 :         ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1560         [ #  # ]:          0 :         ScMarkData& rMark = GetViewData()->GetMarkData();
    1561                 :            : 
    1562         [ #  # ]:          0 :         sal_Bool bSuccess = pDocSh->GetDocFunc().AutoFormat( aRange, &rMark, nFormatNo, bRecord, false );
    1563         [ #  # ]:          0 :         if (bSuccess)
    1564         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
    1565                 :            :     }
    1566                 :            :     else
    1567         [ #  # ]:          0 :         ErrorMessage(STR_NOMULTISELECT);
    1568                 :          0 : }
    1569                 :            : 
    1570                 :            : 
    1571                 :            : //----------------------------------------------------------------------------
    1572                 :            : //  Suchen & Ersetzen
    1573                 :            : 
    1574                 :          0 : void ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
    1575                 :            :                                         sal_Bool bAddUndo, sal_Bool bIsApi )
    1576                 :            : {
    1577                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1578                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    1579         [ #  # ]:          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
    1580 [ #  # ][ #  # ]:          0 :     if (bAddUndo && !pDoc->IsUndoEnabled())
                 [ #  # ]
    1581                 :          0 :         bAddUndo = false;
    1582                 :            : 
    1583                 :          0 :     SCCOL nCol = GetViewData()->GetCurX();
    1584                 :          0 :     SCROW nRow = GetViewData()->GetCurY();
    1585                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    1586                 :          0 :     sal_uInt16 nCommand = pSearchItem->GetCommand();
    1587                 :          0 :     bool bAllTables = pSearchItem->IsAllTables();
    1588         [ #  # ]:          0 :     std::set<SCTAB> aOldSelectedTables;
    1589                 :          0 :     SCTAB nOldTab = nTab;
    1590         [ #  # ]:          0 :     SCTAB nLastTab = pDoc->GetTableCount() - 1;
    1591                 :            :     SCTAB nStartTab, nEndTab;
    1592         [ #  # ]:          0 :     if ( bAllTables )
    1593                 :            :     {
    1594                 :          0 :         nStartTab = 0;
    1595                 :          0 :         nEndTab = nLastTab;
    1596 [ #  # ][ #  # ]:          0 :         std::set<SCTAB> aTmp(rMark.begin(), rMark.end());
                 [ #  # ]
    1597         [ #  # ]:          0 :         aOldSelectedTables.swap(aTmp);
    1598                 :            :     }
    1599                 :            :     else
    1600                 :            :     {   //! at least one is always selected
    1601         [ #  # ]:          0 :         nStartTab = rMark.GetFirstSelected();
    1602         [ #  # ]:          0 :         nEndTab = rMark.GetLastSelected();
    1603                 :            :     }
    1604                 :            : 
    1605 [ #  # ][ #  # ]:          0 :     if (   nCommand == SVX_SEARCHCMD_FIND
    1606                 :            :         || nCommand == SVX_SEARCHCMD_FIND_ALL)
    1607                 :          0 :         bAddUndo = false;
    1608                 :            : 
    1609                 :            :     //!     account for bAttrib during Undo !!!
    1610                 :            : 
    1611                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1612                 :          0 :     std::auto_ptr<ScDocument> pUndoDoc;
    1613                 :          0 :     std::auto_ptr<ScMarkData> pUndoMark;
    1614                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
    1615                 :          0 :     rtl::OUString aUndoStr;
    1616         [ #  # ]:          0 :     if (bAddUndo)
    1617                 :            :     {
    1618 [ #  # ][ #  # ]:          0 :         pUndoMark.reset(new ScMarkData(rMark));                // Mark is being modified
    1619         [ #  # ]:          0 :         if ( nCommand == SVX_SEARCHCMD_REPLACE_ALL )
    1620                 :            :         {
    1621 [ #  # ][ #  # ]:          0 :             pUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
    1622         [ #  # ]:          0 :             pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
    1623                 :            :         }
    1624                 :            :     }
    1625                 :            : 
    1626         [ #  # ]:          0 :     if ( bAllTables )
    1627                 :            :     {   //! select all, after pUndoMark has been created
    1628         [ #  # ]:          0 :         for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
    1629                 :            :         {
    1630         [ #  # ]:          0 :             rMark.SelectTable( j, true );
    1631                 :            :         }
    1632                 :            :     }
    1633                 :            : 
    1634         [ #  # ]:          0 :     DoneBlockMode(true);                // don't delete mark
    1635         [ #  # ]:          0 :     InitOwnBlockMode();
    1636                 :            : 
    1637                 :            :     //  If search starts at the beginning don't ask again whether it shall start at the beginning
    1638                 :          0 :     bool bFirst = true;
    1639 [ #  # ][ #  # ]:          0 :     if ( nCol == 0 && nRow == 0 && nTab == nStartTab && !pSearchItem->GetBackward()  )
         [ #  # ][ #  # ]
                 [ #  # ]
    1640                 :          0 :         bFirst = false;
    1641                 :            : 
    1642                 :          0 :     bool bFound = false;
    1643                 :          0 :     while (true)
    1644                 :            :     {
    1645         [ #  # ]:          0 :         GetFrameWin()->EnterWait();
    1646         [ #  # ]:          0 :         ScRangeList aMatchedRanges;
    1647 [ #  # ][ #  # ]:          0 :         if (pDoc->SearchAndReplace(*pSearchItem, nCol, nRow, nTab, rMark, aMatchedRanges, aUndoStr, pUndoDoc.get()))
    1648                 :            :         {
    1649                 :          0 :             bFound = true;
    1650                 :          0 :             bFirst = true;
    1651         [ #  # ]:          0 :             if (bAddUndo)
    1652                 :            :             {
    1653         [ #  # ]:          0 :                 GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction(
    1654                 :          0 :                     new ScUndoReplace( GetViewData()->GetDocShell(), *pUndoMark,
    1655                 :            :                                         nCol, nRow, nTab,
    1656 [ #  # ][ #  # ]:          0 :                                         aUndoStr, pUndoDoc.release(), pSearchItem ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1657                 :            :             }
    1658                 :            : 
    1659         [ #  # ]:          0 :             rMark.ResetMark();
    1660 [ #  # ][ #  # ]:          0 :             for (size_t i = 0, n = aMatchedRanges.size(); i < n; ++i)
    1661                 :            :             {
    1662         [ #  # ]:          0 :                 const ScRange& r = *aMatchedRanges[i];
    1663         [ #  # ]:          0 :                 if (r.aStart.Tab() == nTab)
    1664         [ #  # ]:          0 :                     rMark.SetMultiMarkArea(r);
    1665                 :            :             }
    1666                 :            : 
    1667                 :            :             break;                  // break 'while (TRUE)'
    1668                 :            :         }
    1669 [ #  # ][ #  # ]:          0 :         else if ( bFirst && (nCommand == SVX_SEARCHCMD_FIND ||
                 [ #  # ]
    1670                 :            :                 nCommand == SVX_SEARCHCMD_REPLACE) )
    1671                 :            :         {
    1672                 :          0 :             bFirst = false;
    1673                 :            :             sal_uInt16 nRetVal;
    1674         [ #  # ]:          0 :             GetFrameWin()->LeaveWait();
    1675         [ #  # ]:          0 :             if ( bIsApi )
    1676                 :          0 :                 nRetVal = RET_NO;
    1677                 :            :             else
    1678                 :            :             {
    1679                 :            :                 //  search dialog as parent (if available)
    1680         [ #  # ]:          0 :                 Window* pParent = GetParentOrChild(SID_SEARCH_DLG);
    1681                 :            :                 sal_uInt16 nStrId;
    1682         [ #  # ]:          0 :                 if ( pSearchItem->GetBackward() )
    1683                 :            :                 {
    1684         [ #  # ]:          0 :                     if ( nStartTab == nEndTab )
    1685                 :          0 :                         nStrId = STR_MSSG_SEARCHANDREPLACE_1;
    1686                 :            :                     else
    1687                 :          0 :                         nStrId = STR_MSSG_SEARCHANDREPLACE_4;
    1688                 :            :                 }
    1689                 :            :                 else
    1690                 :            :                 {
    1691         [ #  # ]:          0 :                     if ( nStartTab == nEndTab )
    1692                 :          0 :                         nStrId = STR_MSSG_SEARCHANDREPLACE_2;
    1693                 :            :                     else
    1694                 :          0 :                         nStrId = STR_MSSG_SEARCHANDREPLACE_5;
    1695                 :            :                 }
    1696                 :            :                 MessBox aBox( pParent, WinBits(WB_YES_NO | WB_DEF_YES),
    1697         [ #  # ]:          0 :                                 ScGlobal::GetRscString( STR_MSSG_SEARCHANDREPLACE_3 ),
    1698 [ #  # ][ #  # ]:          0 :                                 ScGlobal::GetRscString( nStrId ) );
    1699 [ #  # ][ #  # ]:          0 :                 nRetVal = aBox.Execute();
    1700                 :            :             }
    1701                 :            : 
    1702         [ #  # ]:          0 :             if ( nRetVal == RET_YES )
    1703                 :            :             {
    1704         [ #  # ]:          0 :                 ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
    1705         [ #  # ]:          0 :                 if (pSearchItem->GetBackward())
    1706                 :          0 :                     nTab = nEndTab;
    1707                 :            :                 else
    1708                 :          0 :                     nTab = nStartTab;
    1709                 :            :             }
    1710                 :            :             else
    1711                 :            :             {
    1712                 :            :                 break;                  // break 'while (TRUE)'
    1713                 :          0 :             }
    1714                 :            :         }
    1715                 :            :         else                            // nothing found
    1716                 :            :         {
    1717 [ #  # ][ #  # ]:          0 :             if ( nCommand == SVX_SEARCHCMD_FIND_ALL || nCommand == SVX_SEARCHCMD_REPLACE_ALL )
    1718                 :            :             {
    1719         [ #  # ]:          0 :                 pDocSh->PostPaintGridAll();                             // Mark
    1720                 :            :             }
    1721                 :            : 
    1722         [ #  # ]:          0 :             GetFrameWin()->LeaveWait();
    1723         [ #  # ]:          0 :             if (!bIsApi)
    1724                 :            :             {
    1725                 :            :                 //  search dialog as parent if available
    1726         [ #  # ]:          0 :                 Window* pParent = GetParentOrChild(SID_SEARCH_DLG);
    1727                 :            :                 // "nothing found"
    1728 [ #  # ][ #  # ]:          0 :                 InfoBox aBox( pParent, ScGlobal::GetRscString( STR_MSSG_SEARCHANDREPLACE_0 ) );
    1729 [ #  # ][ #  # ]:          0 :                 aBox.Execute();
    1730                 :            :             }
    1731                 :            : 
    1732                 :            :             break;                      // break 'while (TRUE)'
    1733                 :            :         }
    1734 [ #  # ][ #  # ]:          0 :     }                               // of while true
    1735                 :            : 
    1736         [ #  # ]:          0 :     if (!aOldSelectedTables.empty())
    1737                 :            :     {
    1738                 :            :         // restore originally selected table
    1739         [ #  # ]:          0 :         for (SCTAB i = 0; i <= nEndTab; ++i)
    1740         [ #  # ]:          0 :             rMark.SelectTable(i, false);
    1741                 :            : 
    1742                 :          0 :         std::set<SCTAB>::const_iterator itr = aOldSelectedTables.begin(), itrEnd = aOldSelectedTables.end();
    1743 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1744 [ #  # ][ #  # ]:          0 :             rMark.SelectTable(*itr, true);
    1745                 :            : 
    1746         [ #  # ]:          0 :         if ( bFound )
    1747                 :            :         {   // if a table is selected as a "match" it remains selected.
    1748         [ #  # ]:          0 :             rMark.SelectTable( nTab, true );
    1749                 :            :             // It's a swap if only one table was selected before
    1750                 :            :             //! otherwise now one table more might be selected
    1751 [ #  # ][ #  # ]:          0 :             if ( aOldSelectedTables.size() == 1 && nTab != nOldTab )
                 [ #  # ]
    1752         [ #  # ]:          0 :                 rMark.SelectTable( nOldTab, false );
    1753                 :            :         }
    1754                 :            :     }
    1755                 :            : 
    1756         [ #  # ]:          0 :     MarkDataChanged();
    1757                 :            : 
    1758         [ #  # ]:          0 :     if ( bFound )
    1759                 :            :     {
    1760         [ #  # ]:          0 :         if ( nTab != GetViewData()->GetTabNo() )
    1761         [ #  # ]:          0 :             SetTabNo( nTab );
    1762                 :            : 
    1763                 :            :         //  if nothing is marked, DoneBlockMode, then marking can start
    1764                 :            :         //  directly from this place via Shift-Cursor
    1765 [ #  # ][ #  # ]:          0 :         if (!rMark.IsMarked() && !rMark.IsMultiMarked())
                 [ #  # ]
    1766         [ #  # ]:          0 :             DoneBlockMode(true);
    1767                 :            : 
    1768         [ #  # ]:          0 :         AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
    1769         [ #  # ]:          0 :         SetCursor( nCol, nRow, true );
    1770                 :            : 
    1771 [ #  # ][ #  # ]:          0 :         if (   nCommand == SVX_SEARCHCMD_REPLACE
    1772                 :            :             || nCommand == SVX_SEARCHCMD_REPLACE_ALL )
    1773                 :            :         {
    1774         [ #  # ]:          0 :             if ( nCommand == SVX_SEARCHCMD_REPLACE )
    1775         [ #  # ]:          0 :                 pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID );
    1776                 :            :             else
    1777         [ #  # ]:          0 :                 pDocSh->PostPaintGridAll();
    1778         [ #  # ]:          0 :             pDocSh->SetDocumentModified();
    1779                 :            :         }
    1780         [ #  # ]:          0 :         else if ( nCommand == SVX_SEARCHCMD_FIND_ALL )
    1781         [ #  # ]:          0 :             pDocSh->PostPaintGridAll();                             // mark
    1782         [ #  # ]:          0 :         GetFrameWin()->LeaveWait();
    1783 [ #  # ][ #  # ]:          0 :     }
    1784                 :          0 : }
    1785                 :            : 
    1786                 :            : 
    1787                 :            : //----------------------------------------------------------------------------
    1788                 :            : //  Zielwertsuche
    1789                 :            : 
    1790                 :          0 : void ScViewFunc::Solve( const ScSolveParam& rParam )
    1791                 :            : {
    1792         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
    1793                 :            : 
    1794                 :          0 :     SCCOL nDestCol = rParam.aRefVariableCell.Col();
    1795                 :          0 :     SCROW nDestRow = rParam.aRefVariableCell.Row();
    1796                 :          0 :     SCTAB nDestTab = rParam.aRefVariableCell.Tab();
    1797                 :            : 
    1798         [ #  # ]:          0 :     ScEditableTester aTester( pDoc, nDestTab, nDestCol,nDestRow, nDestCol,nDestRow );
    1799         [ #  # ]:          0 :     if (!aTester.IsEditable())
    1800                 :            :     {
    1801 [ #  # ][ #  # ]:          0 :         ErrorMessage(aTester.GetMessageId());
    1802                 :          0 :         return;
    1803                 :            :     }
    1804                 :            : 
    1805         [ #  # ]:          0 :     if ( pDoc )
    1806                 :            :     {
    1807         [ #  # ]:          0 :         String  aTargetValStr;
    1808         [ #  # ]:          0 :         if ( rParam.pStrTargetVal != NULL )
    1809         [ #  # ]:          0 :             aTargetValStr = *(rParam.pStrTargetVal);
    1810                 :            : 
    1811         [ #  # ]:          0 :         String  aMsgStr;
    1812         [ #  # ]:          0 :         String  aResStr;
    1813                 :            :         double  nSolveResult;
    1814                 :            : 
    1815         [ #  # ]:          0 :         GetFrameWin()->EnterWait();
    1816                 :            : 
    1817                 :            :         sal_Bool    bExact =
    1818                 :            :                     pDoc->Solver(
    1819                 :          0 :                         rParam.aRefFormulaCell.Col(),
    1820                 :            :                         rParam.aRefFormulaCell.Row(),
    1821                 :          0 :                         rParam.aRefFormulaCell.Tab(),
    1822                 :            :                         nDestCol, nDestRow, nDestTab,
    1823                 :            :                         aTargetValStr,
    1824   [ #  #  #  # ]:          0 :                         nSolveResult );
    1825                 :            : 
    1826         [ #  # ]:          0 :         GetFrameWin()->LeaveWait();
    1827                 :            : 
    1828         [ #  # ]:          0 :         SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
    1829                 :          0 :         sal_uLong nFormat = 0;
    1830         [ #  # ]:          0 :         const ScPatternAttr* pPattern = pDoc->GetPattern( nDestCol, nDestRow, nDestTab );
    1831         [ #  # ]:          0 :         if ( pPattern )
    1832         [ #  # ]:          0 :             nFormat = pPattern->GetNumberFormat( pFormatter );
    1833                 :            :         Color* p;
    1834         [ #  # ]:          0 :         pFormatter->GetOutputString( nSolveResult, nFormat, aResStr, &p );
    1835                 :            : 
    1836         [ #  # ]:          0 :         if ( bExact )
    1837                 :            :         {
    1838 [ #  # ][ #  # ]:          0 :             aMsgStr  = ScGlobal::GetRscString( STR_MSSG_SOLVE_0 );
    1839 [ #  # ][ #  # ]:          0 :             aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_1 );
    1840 [ #  # ][ #  # ]:          0 :             aMsgStr += String( aResStr );
                 [ #  # ]
    1841 [ #  # ][ #  # ]:          0 :             aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_2 );
    1842                 :            :         }
    1843                 :            :         else
    1844                 :            :         {
    1845 [ #  # ][ #  # ]:          0 :             aMsgStr  = ScGlobal::GetRscString( STR_MSSG_SOLVE_3 );
    1846 [ #  # ][ #  # ]:          0 :             aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_4 );
    1847 [ #  # ][ #  # ]:          0 :             aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_5 );
    1848 [ #  # ][ #  # ]:          0 :             aMsgStr += String( aResStr );
                 [ #  # ]
    1849 [ #  # ][ #  # ]:          0 :             aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_6 );
    1850                 :            :         }
    1851                 :            : 
    1852                 :            :         MessBox aBox( GetViewData()->GetDialogParent(),
    1853                 :            :                         WinBits(WB_YES_NO | WB_DEF_NO),
    1854 [ #  # ][ #  # ]:          0 :                         ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), aMsgStr );
                 [ #  # ]
    1855         [ #  # ]:          0 :         sal_uInt16 nRetVal = aBox.Execute();
    1856                 :            : 
    1857         [ #  # ]:          0 :         if ( RET_YES == nRetVal )
    1858         [ #  # ]:          0 :             EnterValue( nDestCol, nDestRow, nDestTab, nSolveResult );
    1859                 :            : 
    1860 [ #  # ][ #  # ]:          0 :         GetViewData()->GetViewShell()->UpdateInputHandler( sal_True );
         [ #  # ][ #  # ]
                 [ #  # ]
    1861         [ #  # ]:          0 :     }
    1862                 :            : }
    1863                 :            : 
    1864                 :            : 
    1865                 :            : //----------------------------------------------------------------------------
    1866                 :            : //  multi operation
    1867                 :            : 
    1868                 :          0 : void ScViewFunc::TabOp( const ScTabOpParam& rParam, sal_Bool bRecord )
    1869                 :            : {
    1870                 :          0 :     ScRange aRange;
    1871 [ #  # ][ #  # ]:          0 :     if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
    1872                 :            :     {
    1873                 :          0 :         ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1874         [ #  # ]:          0 :         ScMarkData& rMark = GetViewData()->GetMarkData();
    1875         [ #  # ]:          0 :         pDocSh->GetDocFunc().TabOp( aRange, &rMark, rParam, bRecord, false );
    1876                 :            :     }
    1877                 :            :     else
    1878         [ #  # ]:          0 :         ErrorMessage(STR_NOMULTISELECT);
    1879                 :          0 : }
    1880                 :            : 
    1881                 :            : 
    1882                 :            : //----------------------------------------------------------------------------
    1883                 :            : 
    1884                 :          0 : void ScViewFunc::MakeScenario( const String& rName, const String& rComment,
    1885                 :            :                                     const Color& rColor, sal_uInt16 nFlags )
    1886                 :            : {
    1887                 :          0 :     ScDocShell* pDocSh  = GetViewData()->GetDocShell();
    1888                 :          0 :     ScMarkData& rMark   = GetViewData()->GetMarkData();
    1889                 :          0 :     SCTAB       nTab    = GetViewData()->GetTabNo();
    1890                 :            : 
    1891                 :          0 :     SCTAB nNewTab = pDocSh->MakeScenario( nTab, rName, rComment, rColor, nFlags, rMark );
    1892         [ #  # ]:          0 :     if (nFlags & SC_SCENARIO_COPYALL)
    1893                 :          0 :         SetTabNo( nNewTab, true );          // SC_SCENARIO_COPYALL -> visible
    1894                 :            :     else
    1895                 :            :     {
    1896                 :          0 :         SfxBindings& rBindings = GetViewData()->GetBindings();
    1897                 :          0 :         rBindings.Invalidate( SID_STATUS_DOCPOS );      // Statusbar
    1898                 :          0 :         rBindings.Invalidate( SID_TABLES_COUNT );
    1899                 :          0 :         rBindings.Invalidate( SID_SELECT_SCENARIO );
    1900                 :          0 :         rBindings.Invalidate( FID_TABLE_SHOW );
    1901                 :            :     }
    1902                 :          0 : }
    1903                 :            : 
    1904                 :            : 
    1905                 :            : //----------------------------------------------------------------------------
    1906                 :            : 
    1907                 :          0 : void ScViewFunc::ExtendScenario()
    1908                 :            : {
    1909         [ #  # ]:          0 :     ScEditableTester aTester( this );
    1910         [ #  # ]:          0 :     if (!aTester.IsEditable())
    1911                 :            :     {
    1912 [ #  # ][ #  # ]:          0 :         ErrorMessage(aTester.GetMessageId());
    1913                 :          0 :         return;
    1914                 :            :     }
    1915                 :            : 
    1916                 :            :         //  Undo: apply attributes
    1917                 :            : 
    1918         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
    1919 [ #  # ][ #  # ]:          0 :     ScPatternAttr aPattern( pDoc->GetPool() );
    1920 [ #  # ][ #  # ]:          0 :     aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
                 [ #  # ]
    1921 [ #  # ][ #  # ]:          0 :     aPattern.GetItemSet().Put( ScProtectionAttr( sal_True ) );
                 [ #  # ]
    1922 [ #  # ][ #  # ]:          0 :     ApplySelectionPattern(aPattern);
                 [ #  # ]
    1923                 :            : }
    1924                 :            : 
    1925                 :            : 
    1926                 :            : //----------------------------------------------------------------------------
    1927                 :            : 
    1928                 :          0 : void ScViewFunc::UseScenario( const String& rName )
    1929                 :            : {
    1930                 :          0 :     ScDocShell* pDocSh  = GetViewData()->GetDocShell();
    1931                 :          0 :     SCTAB       nTab    = GetViewData()->GetTabNo();
    1932                 :            : 
    1933                 :          0 :     DoneBlockMode();
    1934                 :          0 :     InitOwnBlockMode();
    1935                 :          0 :     pDocSh->UseScenario( nTab, rName );
    1936                 :          0 : }
    1937                 :            : 
    1938                 :            : 
    1939                 :            : //----------------------------------------------------------------------------
    1940                 :            : //  Insert table
    1941                 :            : 
    1942                 :         16 : sal_Bool ScViewFunc::InsertTable( const String& rName, SCTAB nTab, sal_Bool bRecord )
    1943                 :            : {
    1944                 :            :     //  Order Tabl/Name is inverted for DocFunc
    1945                 :         16 :     sal_Bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
    1946                 :         16 :                         InsertTable( nTab, rName, bRecord, false );
    1947         [ +  - ]:         16 :     if (bSuccess)
    1948                 :         16 :         SetTabNo( nTab, sal_True );
    1949                 :            : 
    1950                 :         16 :     return bSuccess;
    1951                 :            : }
    1952                 :            : 
    1953                 :            : //----------------------------------------------------------------------------
    1954                 :            : //  Insert tables
    1955                 :            : 
    1956                 :          0 : sal_Bool ScViewFunc::InsertTables(std::vector<rtl::OUString>& aNames, SCTAB nTab,
    1957                 :            :                                             SCTAB nCount, sal_Bool bRecord )
    1958                 :            : {
    1959                 :          0 :     ScDocShell* pDocSh    = GetViewData()->GetDocShell();
    1960                 :          0 :     ScDocument* pDoc     = pDocSh->GetDocument();
    1961 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    1962                 :          0 :         bRecord = false;
    1963                 :            : 
    1964         [ #  # ]:          0 :     WaitObject aWait( GetFrameWin() );
    1965                 :            : 
    1966         [ #  # ]:          0 :     if (bRecord)
    1967                 :            :     {
    1968         [ #  # ]:          0 :         pDoc->BeginDrawUndo();                            //    InsertTab creates a SdrUndoNewPage
    1969                 :            :     }
    1970                 :            : 
    1971                 :          0 :     bool bFlag=false;
    1972                 :            : 
    1973         [ #  # ]:          0 :     if(aNames.empty())
    1974                 :            :     {
    1975         [ #  # ]:          0 :         pDoc->CreateValidTabNames(aNames, nCount);
    1976                 :            :     }
    1977 [ #  # ][ #  # ]:          0 :     if (pDoc->InsertTabs(nTab, aNames, false))
    1978                 :            :     {
    1979 [ #  # ][ #  # ]:          0 :         pDocSh->Broadcast( ScTablesHint( SC_TABS_INSERTED, nTab, nCount ) );
                 [ #  # ]
    1980                 :          0 :         bFlag = true;
    1981                 :            :     }
    1982                 :            : 
    1983         [ #  # ]:          0 :     if (bFlag)
    1984                 :            :     {
    1985         [ #  # ]:          0 :         if (bRecord)
    1986         [ #  # ]:          0 :             pDocSh->GetUndoManager()->AddUndoAction(
    1987 [ #  # ][ #  # ]:          0 :                         new ScUndoInsertTables( pDocSh, nTab, false, aNames));
                 [ #  # ]
    1988                 :            : 
    1989                 :            :         //    Update views
    1990                 :            : 
    1991         [ #  # ]:          0 :         SetTabNo( nTab, true );
    1992         [ #  # ]:          0 :         pDocSh->PostPaintExtras();
    1993         [ #  # ]:          0 :         pDocSh->SetDocumentModified();
    1994 [ #  # ][ #  # ]:          0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
         [ #  # ][ #  # ]
    1995                 :          0 :         return true;
    1996                 :            :     }
    1997                 :            :     else
    1998                 :            :     {
    1999                 :          0 :         return false;
    2000         [ #  # ]:          0 :     }
    2001                 :            : }
    2002                 :            : 
    2003                 :            : 
    2004                 :            : //----------------------------------------------------------------------------
    2005                 :            : 
    2006                 :          0 : sal_Bool ScViewFunc::AppendTable( const String& rName, sal_Bool bRecord )
    2007                 :            : {
    2008                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2009                 :          0 :     ScDocument* pDoc   = pDocSh->GetDocument();
    2010 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    2011                 :          0 :         bRecord = false;
    2012                 :            : 
    2013         [ #  # ]:          0 :     WaitObject aWait( GetFrameWin() );
    2014                 :            : 
    2015         [ #  # ]:          0 :     if (bRecord)
    2016         [ #  # ]:          0 :         pDoc->BeginDrawUndo();                          //  InsertTab creates a SdrUndoNewPage
    2017                 :            : 
    2018 [ #  # ][ #  # ]:          0 :     if (pDoc->InsertTab( SC_TAB_APPEND, rName ))
                 [ #  # ]
    2019                 :            :     {
    2020         [ #  # ]:          0 :         SCTAB nTab = pDoc->GetTableCount()-1;
    2021         [ #  # ]:          0 :         if (bRecord)
    2022         [ #  # ]:          0 :             pDocSh->GetUndoManager()->AddUndoAction(
    2023 [ #  # ][ #  # ]:          0 :                         new ScUndoInsertTab( pDocSh, nTab, sal_True, rName));
                 [ #  # ]
    2024         [ #  # ]:          0 :         GetViewData()->InsertTab( nTab );
    2025         [ #  # ]:          0 :         SetTabNo( nTab, sal_True );
    2026         [ #  # ]:          0 :         pDocSh->PostPaintExtras();
    2027         [ #  # ]:          0 :         pDocSh->SetDocumentModified();
    2028 [ #  # ][ #  # ]:          0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
         [ #  # ][ #  # ]
    2029                 :          0 :         return sal_True;
    2030                 :            :     }
    2031                 :            :     else
    2032                 :            :     {
    2033                 :          0 :         return false;
    2034         [ #  # ]:          0 :     }
    2035                 :            : }
    2036                 :            : 
    2037                 :            : 
    2038                 :            : //----------------------------------------------------------------------------
    2039                 :            : 
    2040                 :          0 : sal_Bool ScViewFunc::DeleteTable( SCTAB nTab, sal_Bool bRecord )
    2041                 :            : {
    2042                 :          0 :     ScDocShell* pDocSh  = GetViewData()->GetDocShell();
    2043                 :          0 :     ScDocument* pDoc    = pDocSh->GetDocument();
    2044                 :            : 
    2045                 :          0 :     sal_Bool bSuccess = pDocSh->GetDocFunc().DeleteTable( nTab, bRecord, false );
    2046         [ #  # ]:          0 :     if (bSuccess)
    2047                 :            :     {
    2048                 :          0 :         SCTAB nNewTab = nTab;
    2049         [ #  # ]:          0 :         if ( nNewTab >= pDoc->GetTableCount() )
    2050                 :          0 :             --nNewTab;
    2051                 :          0 :         SetTabNo( nNewTab, sal_True );
    2052                 :            :     }
    2053                 :          0 :     return bSuccess;
    2054                 :            : }
    2055                 :            : 
    2056                 :            : //only use this method for undo for now, all sheets must be connected
    2057                 :            : //this method doesn't support undo for now, merge it when it with the other method later
    2058                 :          0 : bool ScViewFunc::DeleteTables( const SCTAB nTab, SCTAB nSheets )
    2059                 :            : {
    2060                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2061                 :          0 :     ScDocument* pDoc    = pDocSh->GetDocument();
    2062         [ #  # ]:          0 :     bool bVbaEnabled = pDoc->IsInVBAMode();
    2063                 :          0 :     SCTAB       nNewTab = nTab;
    2064         [ #  # ]:          0 :     WaitObject aWait( GetFrameWin() );
    2065                 :            : 
    2066 [ #  # ][ #  # ]:          0 :     while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
         [ #  # ][ #  # ]
    2067                 :          0 :         --nNewTab;
    2068                 :            : 
    2069 [ #  # ][ #  # ]:          0 :     if (pDoc->DeleteTabs(nTab, nSheets, NULL))
    2070                 :            :     {
    2071         [ #  # ]:          0 :         if( bVbaEnabled )
    2072                 :            :         {
    2073         [ #  # ]:          0 :             for (SCTAB aTab = 0; aTab < nSheets; ++aTab)
    2074                 :            :             {
    2075                 :          0 :                 rtl::OUString sCodeName;
    2076         [ #  # ]:          0 :                 bool bHasCodeName = pDoc->GetCodeName( nTab + aTab, sCodeName );
    2077         [ #  # ]:          0 :                 if ( bHasCodeName )
    2078         [ #  # ]:          0 :                     VBA_DeleteModule( *pDocSh, sCodeName );
    2079                 :          0 :             }
    2080                 :            :         }
    2081                 :            : 
    2082 [ #  # ][ #  # ]:          0 :         pDocSh->Broadcast( ScTablesHint( SC_TABS_DELETED, nTab, nSheets ) );
                 [ #  # ]
    2083 [ #  # ][ #  # ]:          0 :         if ( nNewTab >= pDoc->GetTableCount() )
    2084         [ #  # ]:          0 :             nNewTab = pDoc->GetTableCount() - 1;
    2085         [ #  # ]:          0 :         SetTabNo( nNewTab, sal_True );
    2086                 :            : 
    2087         [ #  # ]:          0 :         pDocSh->PostPaintExtras();
    2088         [ #  # ]:          0 :         pDocSh->SetDocumentModified();
    2089                 :            : 
    2090         [ #  # ]:          0 :         SfxApplication* pSfxApp = SFX_APP();                                // Navigator
    2091 [ #  # ][ #  # ]:          0 :         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
                 [ #  # ]
    2092 [ #  # ][ #  # ]:          0 :         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
                 [ #  # ]
    2093 [ #  # ][ #  # ]:          0 :         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
                 [ #  # ]
    2094                 :          0 :         return true;
    2095                 :            :     }
    2096         [ #  # ]:          0 :     return false;
    2097                 :            : }
    2098                 :            : 
    2099                 :          0 : sal_Bool ScViewFunc::DeleteTables(const vector<SCTAB> &TheTabs, sal_Bool bRecord )
    2100                 :            : {
    2101                 :          0 :     ScDocShell* pDocSh  = GetViewData()->GetDocShell();
    2102                 :          0 :     ScDocument* pDoc    = pDocSh->GetDocument();
    2103         [ #  # ]:          0 :     sal_Bool bVbaEnabled = pDoc->IsInVBAMode();
    2104         [ #  # ]:          0 :     SCTAB       nNewTab = TheTabs[0];
    2105         [ #  # ]:          0 :     WaitObject aWait( GetFrameWin() );
    2106 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    2107                 :          0 :         bRecord = false;
    2108         [ #  # ]:          0 :     if ( bVbaEnabled )
    2109                 :          0 :         bRecord = false;
    2110                 :            : 
    2111 [ #  # ][ #  # ]:          0 :     while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
         [ #  # ][ #  # ]
    2112                 :          0 :         --nNewTab;
    2113                 :            : 
    2114                 :          0 :     sal_Bool bWasLinked = false;
    2115                 :          0 :     ScDocument* pUndoDoc = NULL;
    2116                 :          0 :     ScRefUndoData* pUndoData = NULL;
    2117         [ #  # ]:          0 :     if (bRecord)
    2118                 :            :     {
    2119 [ #  # ][ #  # ]:          0 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    2120         [ #  # ]:          0 :         SCTAB nCount = pDoc->GetTableCount();
    2121                 :            : 
    2122                 :          0 :         rtl::OUString aOldName;
    2123         [ #  # ]:          0 :         for(unsigned int i=0; i<TheTabs.size(); ++i)
    2124                 :            :         {
    2125         [ #  # ]:          0 :             SCTAB nTab = TheTabs[i];
    2126         [ #  # ]:          0 :             if (i==0)
    2127         [ #  # ]:          0 :                 pUndoDoc->InitUndo( pDoc, nTab,nTab, true,true );   // incl. column/fow flags
    2128                 :            :             else
    2129         [ #  # ]:          0 :                 pUndoDoc->AddUndoTab( nTab,nTab, true,true );       // incl. column/fow flags
    2130                 :            : 
    2131         [ #  # ]:          0 :             pDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,false, pUndoDoc );
    2132         [ #  # ]:          0 :             pDoc->GetName( nTab, aOldName );
    2133         [ #  # ]:          0 :             pUndoDoc->RenameTab( nTab, aOldName, false );
    2134 [ #  # ][ #  # ]:          0 :             if (pDoc->IsLinked(nTab))
    2135                 :            :             {
    2136                 :          0 :                 bWasLinked = sal_True;
    2137         [ #  # ]:          0 :                 pUndoDoc->SetLink( nTab, pDoc->GetLinkMode(nTab), pDoc->GetLinkDoc(nTab),
    2138                 :            :                                     pDoc->GetLinkFlt(nTab), pDoc->GetLinkOpt(nTab),
    2139                 :            :                                     pDoc->GetLinkTab(nTab),
    2140 [ #  # ][ #  # ]:          0 :                                     pDoc->GetLinkRefreshDelay(nTab) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2141                 :            :             }
    2142 [ #  # ][ #  # ]:          0 :             if ( pDoc->IsScenario(nTab) )
    2143                 :            :             {
    2144         [ #  # ]:          0 :                 pUndoDoc->SetScenario( nTab, sal_True );
    2145                 :          0 :                 rtl::OUString aComment;
    2146                 :          0 :                 Color  aColor;
    2147                 :            :                 sal_uInt16 nScenFlags;
    2148         [ #  # ]:          0 :                 pDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags );
    2149         [ #  # ]:          0 :                 pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
    2150         [ #  # ]:          0 :                 sal_Bool bActive = pDoc->IsActiveScenario( nTab );
    2151         [ #  # ]:          0 :                 pUndoDoc->SetActiveScenario( nTab, bActive );
    2152                 :            :             }
    2153 [ #  # ][ #  # ]:          0 :             pUndoDoc->SetVisible( nTab, pDoc->IsVisible( nTab ) );
    2154 [ #  # ][ #  # ]:          0 :             pUndoDoc->SetTabBgColor( nTab, pDoc->GetTabBgColor(nTab) );
    2155 [ #  # ][ #  # ]:          0 :             pUndoDoc->SetSheetEvents( nTab, pDoc->GetSheetEvents( nTab ) );
    2156                 :            : 
    2157 [ #  # ][ #  # ]:          0 :             if ( pDoc->IsTabProtected( nTab ) )
    2158 [ #  # ][ #  # ]:          0 :                 pUndoDoc->SetTabProtection(nTab, pDoc->GetTabProtection(nTab));
    2159                 :            : 
    2160                 :            :             //  Drawing-Layer is responsible for its Undo  !!!
    2161                 :            :             //      pUndoDoc->TransferDrawPage(pDoc, nTab,nTab);
    2162                 :            :         }
    2163                 :            : 
    2164         [ #  # ]:          0 :         pUndoDoc->AddUndoTab( 0, nCount-1 );            //  all Tabs for references
    2165                 :            : 
    2166         [ #  # ]:          0 :         pDoc->BeginDrawUndo();                          //  DeleteTab creates a SdrUndoDelPage
    2167                 :            : 
    2168 [ #  # ][ #  # ]:          0 :         pUndoData = new ScRefUndoData( pDoc );
    2169                 :            :     }
    2170                 :            : 
    2171                 :          0 :     sal_Bool bDelDone = false;
    2172                 :            : 
    2173         [ #  # ]:          0 :     for(int i=TheTabs.size()-1; i>=0; --i)
    2174                 :            :     {
    2175                 :          0 :         rtl::OUString sCodeName;
    2176 [ #  # ][ #  # ]:          0 :         sal_Bool bHasCodeName = pDoc->GetCodeName( TheTabs[i], sCodeName );
    2177 [ #  # ][ #  # ]:          0 :         if (pDoc->DeleteTab( TheTabs[i], pUndoDoc ))
                 [ #  # ]
    2178                 :            :         {
    2179                 :          0 :             bDelDone = sal_True;
    2180         [ #  # ]:          0 :             if( bVbaEnabled )
    2181                 :            :             {
    2182         [ #  # ]:          0 :                 if( bHasCodeName )
    2183                 :            :                 {
    2184         [ #  # ]:          0 :                     VBA_DeleteModule( *pDocSh, sCodeName );
    2185                 :            :                 }
    2186                 :            :             }
    2187 [ #  # ][ #  # ]:          0 :             pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[i] ) );
         [ #  # ][ #  # ]
    2188                 :            :         }
    2189                 :          0 :     }
    2190         [ #  # ]:          0 :     if (bRecord)
    2191                 :            :     {
    2192         [ #  # ]:          0 :         pDocSh->GetUndoManager()->AddUndoAction(
    2193                 :          0 :                     new ScUndoDeleteTab( GetViewData()->GetDocShell(), TheTabs,
    2194 [ #  # ][ #  # ]:          0 :                                             pUndoDoc, pUndoData ));
                 [ #  # ]
    2195                 :            :     }
    2196                 :            : 
    2197                 :            : 
    2198         [ #  # ]:          0 :     if (bDelDone)
    2199                 :            :     {
    2200 [ #  # ][ #  # ]:          0 :         if ( nNewTab >= pDoc->GetTableCount() )
    2201         [ #  # ]:          0 :             nNewTab = pDoc->GetTableCount() - 1;
    2202                 :            : 
    2203         [ #  # ]:          0 :         SetTabNo( nNewTab, sal_True );
    2204                 :            : 
    2205         [ #  # ]:          0 :         if (bWasLinked)
    2206                 :            :         {
    2207         [ #  # ]:          0 :             pDocSh->UpdateLinks();              // update Link-Manager
    2208 [ #  # ][ #  # ]:          0 :             GetViewData()->GetBindings().Invalidate(SID_LINKS);
    2209                 :            :         }
    2210                 :            : 
    2211         [ #  # ]:          0 :         pDocSh->PostPaintExtras();
    2212         [ #  # ]:          0 :         pDocSh->SetDocumentModified();
    2213                 :            : 
    2214                 :            : 
    2215         [ #  # ]:          0 :         SfxApplication* pSfxApp = SFX_APP();                                // Navigator
    2216 [ #  # ][ #  # ]:          0 :         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
                 [ #  # ]
    2217 [ #  # ][ #  # ]:          0 :         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
                 [ #  # ]
    2218 [ #  # ][ #  # ]:          0 :         pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
                 [ #  # ]
    2219                 :            :     }
    2220                 :            :     else
    2221                 :            :     {
    2222 [ #  # ][ #  # ]:          0 :         delete pUndoDoc;
    2223 [ #  # ][ #  # ]:          0 :         delete pUndoData;
    2224                 :            :     }
    2225         [ #  # ]:          0 :     return bDelDone;
    2226                 :            : }
    2227                 :            : 
    2228                 :            : 
    2229                 :            : //----------------------------------------------------------------------------
    2230                 :            : 
    2231                 :          0 : sal_Bool ScViewFunc::RenameTable( const String& rName, SCTAB nTab )
    2232                 :            : {
    2233                 :            :     //  order Table/Name is inverted for DocFunc
    2234                 :          0 :     sal_Bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
    2235                 :          0 :                         RenameTable( nTab, rName, true, false );
    2236         [ #  # ]:          0 :     if (bSuccess)
    2237                 :            :     {
    2238                 :            :         //  the table name might be part of a formula
    2239                 :          0 :         GetViewData()->GetViewShell()->UpdateInputHandler();
    2240                 :            :     }
    2241                 :          0 :     return bSuccess;
    2242                 :            : }
    2243                 :            : 
    2244                 :            : 
    2245                 :            : //----------------------------------------------------------------------------
    2246                 :            : 
    2247                 :          0 : bool ScViewFunc::SetTabBgColor( const Color& rColor, SCTAB nTab )
    2248                 :            : {
    2249                 :          0 :     bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().SetTabBgColor( nTab, rColor, sal_True, false );
    2250         [ #  # ]:          0 :     if (bSuccess)
    2251                 :            :     {
    2252                 :          0 :         GetViewData()->GetViewShell()->UpdateInputHandler();
    2253                 :            :     }
    2254                 :          0 :     return bSuccess;
    2255                 :            : }
    2256                 :            : 
    2257                 :          0 : bool ScViewFunc::SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList )
    2258                 :            : {
    2259                 :          0 :     bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().SetTabBgColor( rUndoSetTabBgColorInfoList, sal_True, false );
    2260         [ #  # ]:          0 :     if (bSuccess)
    2261                 :            :     {
    2262                 :          0 :         GetViewData()->GetViewShell()->UpdateInputHandler();
    2263                 :            :     }
    2264                 :          0 :     return bSuccess;
    2265                 :            : }
    2266                 :            : 
    2267                 :            : //----------------------------------------------------------------------------
    2268                 :            : 
    2269                 :          0 : void ScViewFunc::InsertAreaLink( const String& rFile,
    2270                 :            :                                     const String& rFilter, const String& rOptions,
    2271                 :            :                                     const String& rSource, sal_uLong nRefresh )
    2272                 :            : {
    2273                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2274                 :          0 :     SCCOL nPosX = GetViewData()->GetCurX();
    2275                 :          0 :     SCROW nPosY = GetViewData()->GetCurY();
    2276                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    2277                 :          0 :     ScAddress aPos( nPosX, nPosY, nTab );
    2278                 :            : 
    2279         [ #  # ]:          0 :     pDocSh->GetDocFunc().InsertAreaLink( rFile, rFilter, rOptions, rSource, aPos, nRefresh, false, false );
    2280                 :          0 : }
    2281                 :            : 
    2282                 :            : 
    2283                 :            : //----------------------------------------------------------------------------
    2284                 :            : 
    2285                 :          0 : void ScViewFunc::InsertTableLink( const String& rFile,
    2286                 :            :                                     const String& rFilter, const String& rOptions,
    2287                 :            :                                     const String& rTabName )
    2288                 :            : {
    2289         [ #  # ]:          0 :     rtl::OUString aFilterName = rFilter;
    2290         [ #  # ]:          0 :     rtl::OUString aOpt = rOptions;
    2291         [ #  # ]:          0 :     rtl::OUString aURL = rFile;
    2292         [ #  # ]:          0 :     ScDocumentLoader aLoader( aURL, aFilterName, aOpt );
    2293 [ #  # ][ #  # ]:          0 :     if (!aLoader.IsError())
    2294                 :            :     {
    2295                 :          0 :         ScDocShell* pSrcSh = aLoader.GetDocShell();
    2296                 :          0 :         ScDocument* pSrcDoc = pSrcSh->GetDocument();
    2297                 :          0 :         SCTAB nTab = MAXTAB+1;
    2298         [ #  # ]:          0 :         if (!rTabName.Len())                // no name given -> first table
    2299                 :          0 :             nTab = 0;
    2300                 :            :         else
    2301                 :            :         {
    2302                 :          0 :             rtl::OUString aTemp;
    2303         [ #  # ]:          0 :             SCTAB nCount = pSrcDoc->GetTableCount();
    2304         [ #  # ]:          0 :             for (SCTAB i=0; i<nCount; i++)
    2305                 :            :             {
    2306         [ #  # ]:          0 :                 pSrcDoc->GetName( i, aTemp );
    2307 [ #  # ][ #  # ]:          0 :                 if ( aTemp.equals(rTabName) )
    2308                 :          0 :                     nTab = i;
    2309                 :          0 :             }
    2310                 :            :         }
    2311                 :            : 
    2312         [ #  # ]:          0 :         if ( nTab <= MAXTAB )
    2313                 :            :             ImportTables( pSrcSh, 1, &nTab, sal_True,
    2314         [ #  # ]:          0 :                         GetViewData()->GetTabNo() );
    2315         [ #  # ]:          0 :     }
    2316                 :          0 : }
    2317                 :            : 
    2318                 :            : 
    2319                 :            : //----------------------------------------------------------------------------
    2320                 :            : //  Copy/link tables from another document
    2321                 :            : 
    2322                 :          0 : void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
    2323                 :            :                                 SCTAB nCount, const SCTAB* pSrcTabs, sal_Bool bLink,SCTAB nTab )
    2324                 :            : {
    2325                 :          0 :     ScDocument* pSrcDoc = pSrcShell->GetDocument();
    2326                 :            : 
    2327                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2328                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    2329                 :          0 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
    2330                 :            : 
    2331                 :          0 :     sal_Bool bError = false;
    2332                 :          0 :     sal_Bool bRefs = false;
    2333                 :          0 :     sal_Bool bName = false;
    2334                 :            : 
    2335         [ #  # ]:          0 :     if (pSrcDoc->GetDrawLayer())
    2336                 :          0 :         pDocSh->MakeDrawLayer();
    2337                 :            : 
    2338         [ #  # ]:          0 :     if (bUndo)
    2339                 :          0 :         pDoc->BeginDrawUndo();          // drawing layer must do its own undo actions
    2340                 :            : 
    2341                 :          0 :     SCTAB nInsCount = 0;
    2342                 :            :     SCTAB i;
    2343         [ #  # ]:          0 :     for( i=0; i<nCount; i++ )
    2344                 :            :     {   // insert sheets first and update all references
    2345                 :          0 :         rtl::OUString aName;
    2346         [ #  # ]:          0 :         pSrcDoc->GetName( pSrcTabs[i], aName );
    2347         [ #  # ]:          0 :         pDoc->CreateValidTabName( aName );
    2348 [ #  # ][ #  # ]:          0 :         if ( !pDoc->InsertTab( nTab+i, aName ) )
    2349                 :            :         {
    2350                 :          0 :             bError = sal_True;      // total error
    2351                 :            :             break;  // for
    2352                 :            :         }
    2353         [ #  # ]:          0 :         ++nInsCount;
    2354                 :          0 :     }
    2355 [ #  # ][ #  # ]:          0 :     for (i=0; i<nCount && !bError; i++)
                 [ #  # ]
    2356                 :            :     {
    2357                 :          0 :         SCTAB nSrcTab = pSrcTabs[i];
    2358                 :          0 :         SCTAB nDestTab1=nTab+i;
    2359                 :            :         sal_uLong nErrVal = pDocSh->TransferTab( *pSrcShell, nSrcTab, nDestTab1,
    2360                 :          0 :             false, false );     // no insert
    2361                 :            : 
    2362   [ #  #  #  #  :          0 :         switch (nErrVal)
                      # ]
    2363                 :            :         {
    2364                 :            :             case 0:                     // internal error or full of errors
    2365                 :          0 :                 bError = true;
    2366                 :          0 :                 break;
    2367                 :            :             case 2:
    2368                 :          0 :                 bRefs = sal_True;
    2369                 :          0 :                 break;
    2370                 :            :             case 3:
    2371                 :          0 :                 bName = sal_True;
    2372                 :          0 :                 break;
    2373                 :            :             case 4:
    2374                 :          0 :                 bRefs = bName = sal_True;
    2375                 :          0 :                 break;
    2376                 :            :         }
    2377                 :            : 
    2378                 :            :     }
    2379                 :            : 
    2380         [ #  # ]:          0 :     if (bLink)
    2381                 :            :     {
    2382         [ #  # ]:          0 :         sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
    2383                 :            : 
    2384                 :          0 :         SfxMedium* pMed = pSrcShell->GetMedium();
    2385 [ #  # ][ #  # ]:          0 :         String aFileName = pMed->GetName();
    2386         [ #  # ]:          0 :         String aFilterName;
    2387 [ #  # ][ #  # ]:          0 :         if (pMed->GetFilter())
    2388 [ #  # ][ #  # ]:          0 :             aFilterName = pMed->GetFilter()->GetFilterName();
    2389 [ #  # ][ #  # ]:          0 :         String aOptions = ScDocumentLoader::GetOptions(*pMed);
    2390                 :            : 
    2391 [ #  # ][ #  # ]:          0 :         sal_Bool bWasThere = pDoc->HasLink( aFileName, aFilterName, aOptions );
         [ #  # ][ #  # ]
    2392                 :            : 
    2393                 :          0 :         sal_uLong nRefresh = 0;
    2394                 :          0 :         rtl::OUString aTabStr;
    2395         [ #  # ]:          0 :         for (i=0; i<nInsCount; i++)
    2396                 :            :         {
    2397         [ #  # ]:          0 :             pSrcDoc->GetName( pSrcTabs[i], aTabStr );
    2398                 :            :             pDoc->SetLink( nTab+i, SC_LINK_NORMAL,
    2399 [ #  # ][ #  # ]:          0 :                         aFileName, aFilterName, aOptions, aTabStr, nRefresh );
         [ #  # ][ #  # ]
    2400                 :            :         }
    2401                 :            : 
    2402         [ #  # ]:          0 :         if (!bWasThere)         // Insert link only once per source document
    2403                 :            :         {
    2404 [ #  # ][ #  # ]:          0 :             ScTableLink* pLink = new ScTableLink( pDocSh, aFileName, aFilterName, aOptions, nRefresh );
    2405                 :          0 :             pLink->SetInCreate( sal_True );
    2406         [ #  # ]:          0 :             pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aFileName, &aFilterName );
    2407         [ #  # ]:          0 :             pLink->Update();
    2408                 :          0 :             pLink->SetInCreate( false );
    2409                 :            : 
    2410         [ #  # ]:          0 :             SfxBindings& rBindings = GetViewData()->GetBindings();
    2411         [ #  # ]:          0 :             rBindings.Invalidate( SID_LINKS );
    2412 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
    2413                 :            :     }
    2414                 :            : 
    2415                 :            : 
    2416         [ #  # ]:          0 :     if (bUndo)
    2417                 :            :     {
    2418                 :          0 :         pDocSh->GetUndoManager()->AddUndoAction(
    2419         [ #  # ]:          0 :                 new ScUndoImportTab( pDocSh, nTab, nCount, bLink ) );
    2420                 :            :     }
    2421                 :            : 
    2422         [ #  # ]:          0 :     for (i=0; i<nInsCount; i++)
    2423                 :          0 :         GetViewData()->InsertTab(nTab);
    2424                 :          0 :     SetTabNo(nTab,sal_True);
    2425                 :            :     pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
    2426                 :          0 :                                 PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS );
    2427                 :            : 
    2428                 :          0 :     SfxApplication* pSfxApp = SFX_APP();
    2429         [ #  # ]:          0 :     pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
    2430         [ #  # ]:          0 :     pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
    2431                 :            : 
    2432                 :          0 :     pDocSh->PostPaintExtras();
    2433                 :          0 :     pDocSh->PostPaintGridAll();
    2434                 :          0 :     pDocSh->SetDocumentModified();
    2435                 :            : 
    2436         [ #  # ]:          0 :     if (bRefs)
    2437                 :          0 :         ErrorMessage(STR_ABSREFLOST);
    2438         [ #  # ]:          0 :     if (bName)
    2439                 :          0 :         ErrorMessage(STR_NAMECONFLICT);
    2440                 :          0 : }
    2441                 :            : 
    2442                 :            : 
    2443                 :            : //----------------------------------------------------------------------------
    2444                 :            : //  Move/Copy table to another document
    2445                 :            : 
    2446                 :          0 : void ScViewFunc::MoveTable(
    2447                 :            :     sal_uInt16 nDestDocNo, SCTAB nDestTab, bool bCopy, const rtl::OUString* pNewTabName )
    2448                 :            : {
    2449                 :          0 :     ScDocument* pDoc       = GetViewData()->GetDocument();
    2450                 :          0 :     ScDocShell* pDocShell  = GetViewData()->GetDocShell();
    2451                 :          0 :     ScDocument* pDestDoc   = NULL;
    2452                 :          0 :     ScDocShell* pDestShell = NULL;
    2453                 :          0 :     ScTabViewShell* pDestViewSh = NULL;
    2454                 :          0 :     sal_Bool bUndo (pDoc->IsUndoEnabled());
    2455 [ #  # ][ #  # ]:          0 :     bool bRename = pNewTabName && !pNewTabName->isEmpty();
    2456                 :            : 
    2457                 :          0 :     bool bNewDoc = (nDestDocNo == SC_DOC_NEW);
    2458         [ #  # ]:          0 :     if ( bNewDoc )
    2459                 :            :     {
    2460                 :          0 :         nDestTab = 0;           // firstly insert
    2461                 :            : 
    2462                 :            :         //  execute without SFX_CALLMODE_RECORD, because already contained in move command
    2463                 :            : 
    2464         [ #  # ]:          0 :         String aUrl = rtl::OUString("private:factory/");
    2465         [ #  # ]:          0 :         aUrl.AppendAscii(RTL_CONSTASCII_STRINGPARAM( STRING_SCAPP ));               // "scalc"
    2466         [ #  # ]:          0 :         SfxStringItem aItem( SID_FILE_NAME, aUrl );
    2467 [ #  # ][ #  # ]:          0 :         SfxStringItem aTarget( SID_TARGETNAME, rtl::OUString("_blank") );
                 [ #  # ]
    2468                 :            : 
    2469         [ #  # ]:          0 :         const SfxPoolItem* pRetItem = GetViewData()->GetDispatcher().Execute(
    2470         [ #  # ]:          0 :                     SID_OPENDOC, SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON, &aItem, &aTarget, 0L );
    2471         [ #  # ]:          0 :         if ( pRetItem )
    2472                 :            :         {
    2473 [ #  # ][ #  # ]:          0 :             if ( pRetItem->ISA( SfxObjectItem ) )
                 [ #  # ]
    2474 [ #  # ][ #  # ]:          0 :                 pDestShell = PTR_CAST( ScDocShell, ((const SfxObjectItem*)pRetItem)->GetShell() );
         [ #  # ][ #  # ]
    2475 [ #  # ][ #  # ]:          0 :             else if ( pRetItem->ISA( SfxViewFrameItem ) )
                 [ #  # ]
    2476                 :            :             {
    2477                 :          0 :                 SfxViewFrame* pFrm = ((const SfxViewFrameItem*)pRetItem)->GetFrame();
    2478         [ #  # ]:          0 :                 if (pFrm)
    2479 [ #  # ][ #  # ]:          0 :                     pDestShell = PTR_CAST( ScDocShell, pFrm->GetObjectShell() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2480                 :            :             }
    2481         [ #  # ]:          0 :             if (pDestShell)
    2482         [ #  # ]:          0 :                 pDestViewSh = pDestShell->GetBestViewShell();
    2483 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
    2484                 :            :     }
    2485                 :            :     else
    2486                 :          0 :         pDestShell = ScDocShell::GetShellByNum( nDestDocNo );
    2487                 :            : 
    2488         [ #  # ]:          0 :     if (!pDestShell)
    2489                 :            :     {
    2490                 :            :         OSL_FAIL("Dest-Doc nicht gefunden !!!");
    2491                 :          0 :         return;
    2492                 :            :     }
    2493                 :            : 
    2494                 :          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
    2495 [ #  # ][ #  # ]:          0 :     if (bRename && rMark.GetSelectCount() != 1)
                 [ #  # ]
    2496                 :            :     {
    2497                 :            :         // Custom sheet name is provided, but more than one sheet is selected.
    2498                 :            :         // We don't support this scenario at the moment.
    2499                 :          0 :         return;
    2500                 :            :     }
    2501                 :            : 
    2502                 :          0 :     pDestDoc = pDestShell->GetDocument();
    2503                 :            : 
    2504                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    2505                 :            : 
    2506         [ #  # ]:          0 :     if (pDestDoc != pDoc)
    2507                 :            :     {
    2508         [ #  # ]:          0 :         if (bNewDoc)
    2509                 :            :         {
    2510 [ #  # ][ #  # ]:          0 :             while (pDestDoc->GetTableCount() > 1)
    2511         [ #  # ]:          0 :                 pDestDoc->DeleteTab(0);
    2512                 :            :             pDestDoc->RenameTab( 0, rtl::OUString("______42_____"),
    2513         [ #  # ]:          0 :                         false );
    2514                 :            :         }
    2515                 :            : 
    2516         [ #  # ]:          0 :         SCTAB       nTabCount   = pDoc->GetTableCount();
    2517         [ #  # ]:          0 :         SCTAB       nTabSelCount = rMark.GetSelectCount();
    2518                 :            : 
    2519         [ #  # ]:          0 :         vector<SCTAB> TheTabs;
    2520                 :            : 
    2521         [ #  # ]:          0 :         for(SCTAB i=0; i<nTabCount; ++i)
    2522                 :            :         {
    2523 [ #  # ][ #  # ]:          0 :             if(rMark.GetTableSelect(i))
    2524                 :            :             {
    2525                 :          0 :                 rtl::OUString aTabName;
    2526         [ #  # ]:          0 :                 pDoc->GetName( i, aTabName);
    2527         [ #  # ]:          0 :                 TheTabs.push_back(i);
    2528         [ #  # ]:          0 :                 for(SCTAB j=i+1;j<nTabCount;j++)
    2529                 :            :                 {
    2530 [ #  # ][ #  # ]:          0 :                     if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j)))
         [ #  # ][ #  # ]
                 [ #  # ]
    2531                 :            :                     {
    2532         [ #  # ]:          0 :                         pDoc->GetName( j, aTabName);
    2533         [ #  # ]:          0 :                         TheTabs.push_back(j);
    2534                 :          0 :                         i=j;
    2535                 :            :                     }
    2536                 :          0 :                     else break;
    2537                 :          0 :                 }
    2538                 :            :             }
    2539                 :            :         }
    2540                 :            : 
    2541         [ #  # ]:          0 :         GetFrameWin()->EnterWait();
    2542                 :            : 
    2543 [ #  # ][ #  # ]:          0 :         if (pDoc->GetDrawLayer())
    2544         [ #  # ]:          0 :             pDestShell->MakeDrawLayer();
    2545                 :            : 
    2546 [ #  # ][ #  # ]:          0 :         if (!bNewDoc && bUndo)
    2547         [ #  # ]:          0 :             pDestDoc->BeginDrawUndo();      // drawing layer must do its own undo actions
    2548                 :            : 
    2549                 :          0 :         sal_uLong nErrVal =1;
    2550         [ #  # ]:          0 :         if(nDestTab==SC_TAB_APPEND)
    2551         [ #  # ]:          0 :             nDestTab=pDestDoc->GetTableCount();
    2552                 :          0 :         SCTAB nDestTab1=nDestTab;
    2553         [ #  # ]:          0 :         ScClipParam aParam;
    2554         [ #  # ]:          0 :         for( sal_uInt16 j=0; j<TheTabs.size(); ++j, ++nDestTab1 )
    2555                 :            :         {   // insert sheets first and update all references
    2556                 :          0 :             rtl::OUString aName;
    2557         [ #  # ]:          0 :             if (bRename)
    2558                 :          0 :                 aName = *pNewTabName;
    2559                 :            :             else
    2560 [ #  # ][ #  # ]:          0 :                 pDoc->GetName( TheTabs[j], aName );
    2561                 :            : 
    2562         [ #  # ]:          0 :             pDestDoc->CreateValidTabName( aName );
    2563 [ #  # ][ #  # ]:          0 :             if ( !pDestDoc->InsertTab( nDestTab1, aName ) )
    2564                 :            :             {
    2565                 :          0 :                 nErrVal = 0;        // total error
    2566                 :            :                 break;  // for
    2567                 :            :             }
    2568 [ #  # ][ #  # ]:          0 :             ScRange aRange( 0, 0, TheTabs[j], MAXCOL, MAXROW, TheTabs[j] );
    2569 [ #  # ][ #  # ]:          0 :             aParam.maRanges.Append(aRange);
    2570                 :          0 :         }
    2571         [ #  # ]:          0 :         pDoc->SetClipParam(aParam);
    2572         [ #  # ]:          0 :         if ( nErrVal > 0 )
    2573                 :            :         {
    2574                 :          0 :             nDestTab1 = nDestTab;
    2575         [ #  # ]:          0 :             for(sal_uInt16 i=0; i<TheTabs.size();++i)
    2576                 :            :             {
    2577 [ #  # ][ #  # ]:          0 :                 nErrVal = pDestShell->TransferTab( *pDocShell, TheTabs[i], static_cast<SCTAB>(nDestTab1), false, false );
    2578                 :          0 :                 nDestTab1++;
    2579                 :            :             }
    2580                 :            :         }
    2581                 :          0 :         rtl::OUString sName;
    2582 [ #  # ][ #  # ]:          0 :         if (!bNewDoc && bUndo)
    2583                 :            :         {
    2584         [ #  # ]:          0 :             pDestDoc->GetName(nDestTab, sName);
    2585         [ #  # ]:          0 :             pDestShell->GetUndoManager()->AddUndoAction(
    2586                 :            :                             new ScUndoImportTab( pDestShell, nDestTab,
    2587 [ #  # ][ #  # ]:          0 :                                 static_cast<SCTAB>(TheTabs.size()), false));
                 [ #  # ]
    2588                 :            : 
    2589                 :            :         }
    2590                 :            :         else
    2591                 :            :         {
    2592 [ #  # ][ #  # ]:          0 :             pDestShell->GetUndoManager()->Clear();
    2593                 :            :         }
    2594                 :            : 
    2595         [ #  # ]:          0 :         GetFrameWin()->LeaveWait();
    2596   [ #  #  #  #  :          0 :         switch (nErrVal)
                      # ]
    2597                 :            :         {
    2598                 :            :             case 0:                     // internal error or full of errors
    2599                 :            :             {
    2600         [ #  # ]:          0 :                 ErrorMessage(STR_TABINSERT_ERROR);
    2601                 :            :                 return;
    2602                 :            :             }
    2603                 :            :             //break;
    2604                 :            :             case 2:
    2605         [ #  # ]:          0 :                 ErrorMessage(STR_ABSREFLOST);
    2606                 :          0 :             break;
    2607                 :            :             case 3:
    2608         [ #  # ]:          0 :                 ErrorMessage(STR_NAMECONFLICT);
    2609                 :          0 :             break;
    2610                 :            :             case 4:
    2611                 :            :             {
    2612         [ #  # ]:          0 :                 ErrorMessage(STR_ABSREFLOST);
    2613         [ #  # ]:          0 :                 ErrorMessage(STR_NAMECONFLICT);
    2614                 :            :             }
    2615                 :          0 :             break;
    2616                 :            :             default:
    2617                 :          0 :             break;
    2618                 :            :         }
    2619                 :            : 
    2620         [ #  # ]:          0 :         if (!bCopy)
    2621                 :            :         {
    2622         [ #  # ]:          0 :             if(nTabCount!=nTabSelCount)
    2623         [ #  # ]:          0 :                 DeleteTables(TheTabs); // incl. Paint & Undo
    2624                 :            :             else
    2625         [ #  # ]:          0 :                 ErrorMessage(STR_TABREMOVE_ERROR);
    2626                 :            :         }
    2627                 :            : 
    2628         [ #  # ]:          0 :         if (bNewDoc)
    2629                 :            :         {
    2630                 :            :             //  ChartListenerCollection must be updated before DeleteTab
    2631         [ #  # ]:          0 :             if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() )
    2632         [ #  # ]:          0 :                 pDestDoc->UpdateChartListenerCollection();
    2633                 :            : 
    2634         [ #  # ]:          0 :             pDestDoc->DeleteTab(static_cast<SCTAB>(TheTabs.size()));   // old first table
    2635         [ #  # ]:          0 :             if (pDestViewSh)
    2636                 :            :             {
    2637                 :            :                 // Make sure to clear the cached page view after sheet
    2638                 :            :                 // deletion, which still points to the sdr page belonging to
    2639                 :            :                 // the deleted sheet.
    2640         [ #  # ]:          0 :                 SdrView* pSdrView = pDestViewSh->GetSdrView();
    2641         [ #  # ]:          0 :                 if (pSdrView)
    2642         [ #  # ]:          0 :                     pSdrView->ClearPageView();
    2643                 :            : 
    2644         [ #  # ]:          0 :                 pDestViewSh->TabChanged();      // Pages auf dem Drawing-Layer
    2645                 :            :             }
    2646                 :            :             pDestShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
    2647                 :            :                                     PAINT_GRID | PAINT_TOP | PAINT_LEFT |
    2648         [ #  # ]:          0 :                                     PAINT_EXTRAS | PAINT_SIZE );
    2649                 :            :             //  PAINT_SIZE for outline
    2650                 :            :         }
    2651                 :            :         else
    2652                 :            :         {
    2653 [ #  # ][ #  # ]:          0 :             pDestShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestTab ) );
                 [ #  # ]
    2654         [ #  # ]:          0 :             pDestShell->PostPaintExtras();
    2655         [ #  # ]:          0 :             pDestShell->PostPaintGridAll();
    2656                 :            :         }
    2657                 :            : 
    2658                 :          0 :         TheTabs.clear();
    2659                 :            : 
    2660         [ #  # ]:          0 :         pDestShell->SetDocumentModified();
    2661 [ #  # ][ #  # ]:          0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2662                 :            :     }
    2663                 :            :     else
    2664                 :            :     {
    2665                 :            :         // Move or copy within the same document.
    2666         [ #  # ]:          0 :         SCTAB       nTabCount   = pDoc->GetTableCount();
    2667                 :            : 
    2668                 :            :         SAL_WNODEPRECATED_DECLARATIONS_PUSH
    2669 [ #  # ][ #  # ]:          0 :         auto_ptr< vector<SCTAB> >    pSrcTabs(new vector<SCTAB>);
    2670 [ #  # ][ #  # ]:          0 :         auto_ptr< vector<SCTAB> >    pDestTabs(new vector<SCTAB>);
    2671 [ #  # ][ #  # ]:          0 :         auto_ptr< vector<OUString> > pTabNames(new vector<OUString>);
    2672                 :          0 :         auto_ptr< vector<OUString> > pDestNames(NULL);
    2673                 :            :         SAL_WNODEPRECATED_DECLARATIONS_POP
    2674         [ #  # ]:          0 :         pSrcTabs->reserve(nTabCount);
    2675         [ #  # ]:          0 :         pDestTabs->reserve(nTabCount);
    2676         [ #  # ]:          0 :         pTabNames->reserve(nTabCount);
    2677                 :          0 :         rtl::OUString aDestName;
    2678                 :            : 
    2679         [ #  # ]:          0 :         for(SCTAB i=0;i<nTabCount;i++)
    2680                 :            :         {
    2681 [ #  # ][ #  # ]:          0 :             if(rMark.GetTableSelect(i))
    2682                 :            :             {
    2683                 :          0 :                 rtl::OUString aTabName;
    2684         [ #  # ]:          0 :                 pDoc->GetName( i, aTabName);
    2685         [ #  # ]:          0 :                 pTabNames->push_back(aTabName);
    2686                 :            : 
    2687         [ #  # ]:          0 :                 for(SCTAB j=i+1;j<nTabCount;j++)
    2688                 :            :                 {
    2689 [ #  # ][ #  # ]:          0 :                     if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j)))
         [ #  # ][ #  # ]
                 [ #  # ]
    2690                 :            :                     {
    2691         [ #  # ]:          0 :                         pDoc->GetName( j, aTabName);
    2692         [ #  # ]:          0 :                         pTabNames->push_back(aTabName);
    2693                 :          0 :                         i=j;
    2694                 :            :                     }
    2695                 :          0 :                     else break;
    2696                 :          0 :                 }
    2697                 :            :             }
    2698                 :            :         }
    2699                 :            : 
    2700 [ #  # ][ #  # ]:          0 :         if (bCopy && bUndo)
    2701         [ #  # ]:          0 :             pDoc->BeginDrawUndo();          // drawing layer must do its own undo actions
    2702                 :            : 
    2703         [ #  # ]:          0 :         pDoc->GetName( nDestTab, aDestName);
    2704                 :          0 :         SCTAB nDestTab1=nDestTab;
    2705                 :          0 :         SCTAB nMovTab=0;
    2706         [ #  # ]:          0 :         for (size_t j = 0, n = pTabNames->size(); j < n; ++j)
    2707                 :            :         {
    2708         [ #  # ]:          0 :             nTabCount   = pDoc->GetTableCount();
    2709                 :          0 :             const OUString& rStr = (*pTabNames)[j];
    2710 [ #  # ][ #  # ]:          0 :             if(!pDoc->GetTable(rStr,nMovTab))
    2711                 :            :             {
    2712                 :          0 :                 nMovTab=nTabCount;
    2713                 :            :             }
    2714 [ #  # ][ #  # ]:          0 :             if(!pDoc->GetTable(aDestName,nDestTab1))
    2715                 :            :             {
    2716                 :          0 :                 nDestTab1=nTabCount;
    2717                 :            :             }
    2718         [ #  # ]:          0 :             pDocShell->MoveTable( nMovTab, nDestTab1, bCopy, false );   // Undo is here
    2719                 :            : 
    2720 [ #  # ][ #  # ]:          0 :             if(bCopy && pDoc->IsScenario(nMovTab))
         [ #  # ][ #  # ]
    2721                 :            :             {
    2722                 :          0 :                 rtl::OUString aComment;
    2723                 :          0 :                 Color  aColor;
    2724                 :            :                 sal_uInt16 nFlags;
    2725                 :            : 
    2726         [ #  # ]:          0 :                 pDoc->GetScenarioData(nMovTab, aComment,aColor, nFlags);
    2727         [ #  # ]:          0 :                 pDoc->SetScenario(nDestTab1,sal_True);
    2728         [ #  # ]:          0 :                 pDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags);
    2729         [ #  # ]:          0 :                 sal_Bool bActive = pDoc->IsActiveScenario(nMovTab );
    2730         [ #  # ]:          0 :                 pDoc->SetActiveScenario( nDestTab1, bActive );
    2731         [ #  # ]:          0 :                 sal_Bool bVisible=pDoc->IsVisible(nMovTab);
    2732         [ #  # ]:          0 :                 pDoc->SetVisible(nDestTab1,bVisible );
    2733                 :            :             }
    2734                 :            : 
    2735         [ #  # ]:          0 :             pSrcTabs->push_back(nMovTab);
    2736                 :            : 
    2737         [ #  # ]:          0 :             if(!bCopy)
    2738                 :            :             {
    2739 [ #  # ][ #  # ]:          0 :                 if(!pDoc->GetTable(rStr,nDestTab1))
    2740                 :            :                 {
    2741                 :          0 :                     nDestTab1=nTabCount;
    2742                 :            :                 }
    2743                 :            :             }
    2744                 :            : 
    2745         [ #  # ]:          0 :             pDestTabs->push_back(nDestTab1);
    2746                 :            :         }
    2747                 :            : 
    2748                 :            :         // Rename must be done after all sheets have been moved.
    2749         [ #  # ]:          0 :         if (bRename)
    2750                 :            :         {
    2751 [ #  # ][ #  # ]:          0 :             pDestNames.reset(new vector<OUString>);
    2752                 :          0 :             size_t n = pDestTabs->size();
    2753         [ #  # ]:          0 :             pDestNames->reserve(n);
    2754         [ #  # ]:          0 :             for (size_t j = 0; j < n; ++j)
    2755                 :            :             {
    2756         [ #  # ]:          0 :                 SCTAB nRenameTab = (*pDestTabs)[j];
    2757                 :          0 :                 rtl::OUString aTabName = *pNewTabName;
    2758         [ #  # ]:          0 :                 pDoc->CreateValidTabName( aTabName );
    2759         [ #  # ]:          0 :                 pDestNames->push_back(aTabName);
    2760         [ #  # ]:          0 :                 pDoc->RenameTab(nRenameTab, aTabName);
    2761                 :          0 :             }
    2762                 :            :         }
    2763                 :            :         else
    2764                 :            :             // No need to keep this around when we are not renaming.
    2765                 :          0 :             pTabNames.reset();
    2766                 :            : 
    2767                 :          0 :         nTab = GetViewData()->GetTabNo();
    2768                 :            : 
    2769         [ #  # ]:          0 :         if (bUndo)
    2770                 :            :         {
    2771         [ #  # ]:          0 :             if (bCopy)
    2772                 :            :             {
    2773         [ #  # ]:          0 :                 pDocShell->GetUndoManager()->AddUndoAction(
    2774                 :            :                         new ScUndoCopyTab(
    2775 [ #  # ][ #  # ]:          0 :                             pDocShell, pSrcTabs.release(), pDestTabs.release(), pDestNames.release()));
                 [ #  # ]
    2776                 :            :             }
    2777                 :            :             else
    2778                 :            :             {
    2779         [ #  # ]:          0 :                 pDocShell->GetUndoManager()->AddUndoAction(
    2780                 :            :                         new ScUndoMoveTab(
    2781 [ #  # ][ #  # ]:          0 :                             pDocShell, pSrcTabs.release(), pDestTabs.release(), pTabNames.release(), pDestNames.release()));
                 [ #  # ]
    2782                 :            :             }
    2783                 :            :         }
    2784                 :            : 
    2785                 :          0 :         SCTAB nNewTab = nDestTab;
    2786         [ #  # ]:          0 :         if (nNewTab == SC_TAB_APPEND)
    2787         [ #  # ]:          0 :             nNewTab = pDoc->GetTableCount()-1;
    2788 [ #  # ][ #  # ]:          0 :         else if (!bCopy && nTab<nDestTab)
    2789                 :          0 :             nNewTab--;
    2790                 :            : 
    2791         [ #  # ]:          0 :         SetTabNo( nNewTab, sal_True );
    2792                 :            : 
    2793                 :            :         //#i29848# adjust references to data on the copied sheet
    2794         [ #  # ]:          0 :         if( bCopy )
    2795 [ #  # ][ #  # ]:          0 :             ScChartHelper::AdjustRangesOfChartsOnDestinationPage( pDoc, pDestDoc, nTab, nNewTab );
                 [ #  # ]
    2796                 :            :     }
    2797                 :            : }
    2798                 :            : 
    2799                 :            : 
    2800                 :            : //----------------------------------------------------------------------------
    2801                 :            : 
    2802                 :          0 : void ScViewFunc::ShowTable( const String& rName )
    2803                 :            : {
    2804                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2805                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    2806                 :          0 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
    2807                 :          0 :     sal_Bool bFound = false;
    2808                 :          0 :     SCTAB nPos = 0;
    2809                 :          0 :     rtl::OUString aTabName;
    2810         [ #  # ]:          0 :     SCTAB nCount = pDoc->GetTableCount();
    2811         [ #  # ]:          0 :     for (SCTAB i=0; i<nCount; i++)
    2812                 :            :     {
    2813         [ #  # ]:          0 :         pDoc->GetName( i, aTabName );
    2814 [ #  # ][ #  # ]:          0 :         if ( aTabName.equals(rName) )
    2815                 :            :         {
    2816                 :          0 :             nPos = i;
    2817                 :          0 :             bFound = sal_True;
    2818                 :            :         }
    2819                 :            :     }
    2820                 :            : 
    2821         [ #  # ]:          0 :     if (bFound)
    2822                 :            :     {
    2823         [ #  # ]:          0 :         pDoc->SetVisible( nPos, sal_True );
    2824         [ #  # ]:          0 :         if (bUndo)
    2825                 :            :         {
    2826 [ #  # ][ #  # ]:          0 :             pDocSh->GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( pDocSh, nPos, sal_True ) );
         [ #  # ][ #  # ]
    2827                 :            :         }
    2828         [ #  # ]:          0 :         SetTabNo( nPos, sal_True );
    2829 [ #  # ][ #  # ]:          0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
         [ #  # ][ #  # ]
    2830         [ #  # ]:          0 :         pDocSh->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS);
    2831         [ #  # ]:          0 :         pDocSh->SetDocumentModified();
    2832                 :          0 :     }
    2833                 :          0 : }
    2834                 :            : 
    2835                 :            : 
    2836                 :            : //----------------------------------------------------------------------------
    2837                 :            : 
    2838                 :          0 : void ScViewFunc::HideTable( SCTAB nTab )
    2839                 :            : {
    2840                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2841                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    2842                 :          0 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
    2843                 :          0 :     SCTAB nVisible = 0;
    2844                 :          0 :     SCTAB nCount = pDoc->GetTableCount();
    2845         [ #  # ]:          0 :     for (SCTAB i=0; i<nCount; i++)
    2846                 :            :     {
    2847         [ #  # ]:          0 :         if (pDoc->IsVisible(i))
    2848                 :          0 :             ++nVisible;
    2849                 :            :     }
    2850                 :            : 
    2851         [ #  # ]:          0 :     if (nVisible > 1)
    2852                 :            :     {
    2853                 :          0 :         pDoc->SetVisible( nTab, false );
    2854         [ #  # ]:          0 :         if (bUndo)
    2855                 :            :         {
    2856         [ #  # ]:          0 :             pDocSh->GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( pDocSh, nTab, false ) );
    2857                 :            :         }
    2858                 :            : 
    2859                 :            :         //  Update views
    2860         [ #  # ]:          0 :         pDocSh->Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) );
    2861                 :            : 
    2862                 :          0 :         SetTabNo( nTab, sal_True );
    2863 [ #  # ][ #  # ]:          0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
    2864                 :          0 :         pDocSh->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS);
    2865                 :          0 :         pDocSh->SetDocumentModified();
    2866                 :            :     }
    2867                 :          0 : }
    2868                 :            : 
    2869                 :            : 
    2870                 :            : //----------------------------------------------------------------------------
    2871                 :            : 
    2872                 :          0 : void ScViewFunc::InsertSpecialChar( const String& rStr, const Font& rFont )
    2873                 :            : {
    2874         [ #  # ]:          0 :     ScEditableTester aTester( this );
    2875         [ #  # ]:          0 :     if (!aTester.IsEditable())
    2876                 :            :     {
    2877 [ #  # ][ #  # ]:          0 :         ErrorMessage(aTester.GetMessageId());
    2878                 :          0 :         return;
    2879                 :            :     }
    2880                 :            : 
    2881                 :          0 :     const sal_Unicode* pChar    = rStr.GetBuffer();
    2882                 :          0 :     ScTabViewShell* pViewShell  = GetViewData()->GetViewShell();
    2883                 :            :     SvxFontItem     aFontItem( rFont.GetFamily(),
    2884         [ #  # ]:          0 :                                rFont.GetName(),
    2885         [ #  # ]:          0 :                                rFont.GetStyleName(),
    2886                 :            :                                rFont.GetPitch(),
    2887         [ #  # ]:          0 :                                rFont.GetCharSet(),
    2888 [ #  # ][ #  # ]:          0 :                                ATTR_FONT );
                 [ #  # ]
    2889                 :            : 
    2890                 :            :     //  if string contains WEAK characters, set all fonts
    2891                 :            :     sal_uInt8 nScript;
    2892         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
    2893 [ #  # ][ #  # ]:          0 :     if ( pDoc->HasStringWeakCharacters( rStr ) )
                 [ #  # ]
    2894                 :          0 :         nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
    2895                 :            :     else
    2896 [ #  # ][ #  # ]:          0 :         nScript = pDoc->GetStringScriptType( rStr );
    2897                 :            : 
    2898         [ #  # ]:          0 :     SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, pViewShell->GetPool() );
    2899         [ #  # ]:          0 :     aSetItem.PutItemForScriptType( nScript, aFontItem );
    2900         [ #  # ]:          0 :     ApplyUserItemSet( aSetItem.GetItemSet() );
    2901                 :            : 
    2902         [ #  # ]:          0 :     while ( *pChar )
    2903 [ #  # ][ #  # ]:          0 :         pViewShell->TabKeyInput( KeyEvent( *(pChar++), KeyCode() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2904                 :            : }
    2905                 :            : 
    2906                 :            : 
    2907                 :            : //----------------------------------------------------------------------------
    2908                 :            : 
    2909                 :          0 : void ScViewFunc::UpdateLineAttrs( SvxBorderLine&       rLine,
    2910                 :            :                                   const SvxBorderLine* pDestLine,
    2911                 :            :                                   const SvxBorderLine* pSrcLine,
    2912                 :            :                                   sal_Bool                 bColor )
    2913                 :            : {
    2914 [ #  # ][ #  # ]:          0 :     if ( pSrcLine && pDestLine )
    2915                 :            :     {
    2916         [ #  # ]:          0 :         if ( bColor )
    2917                 :            :         {
    2918                 :          0 :             rLine.SetColor      ( pSrcLine->GetColor() );
    2919                 :          0 :             rLine.SetBorderLineStyle(pDestLine->GetBorderLineStyle());
    2920                 :          0 :             rLine.SetWidth      ( pDestLine->GetWidth() );
    2921                 :            :         }
    2922                 :            :         else
    2923                 :            :         {
    2924                 :          0 :             rLine.SetColor      ( pDestLine->GetColor() );
    2925                 :          0 :             rLine.SetBorderLineStyle(pSrcLine->GetBorderLineStyle());
    2926                 :          0 :             rLine.SetWidth      ( pSrcLine->GetWidth() );
    2927                 :            :         }
    2928                 :            :     }
    2929                 :          0 : }
    2930                 :            : 
    2931                 :            : 
    2932                 :            : #define SET_LINE_ATTRIBUTES(LINE,BOXLINE) \
    2933                 :            :     pBoxLine = aBoxItem.Get##LINE();                                \
    2934                 :            :     if ( pBoxLine )                                                 \
    2935                 :            :     {                                                               \
    2936                 :            :         if ( pLine )                                                \
    2937                 :            :         {                                                           \
    2938                 :            :             UpdateLineAttrs( aLine, pBoxLine, pLine, bColorOnly );  \
    2939                 :            :             aBoxItem.SetLine( &aLine, BOXLINE );                    \
    2940                 :            :         }                                                           \
    2941                 :            :         else                                                        \
    2942                 :            :             aBoxItem.SetLine( NULL, BOXLINE );                      \
    2943                 :            :     }
    2944                 :            : 
    2945                 :            : 
    2946                 :            : //----------------------------------------------------------------------------
    2947                 :            : 
    2948                 :          0 : void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine,
    2949                 :            :                                          sal_Bool bColorOnly )
    2950                 :            : {
    2951                 :            :     // Not editable only due to a matrix? Attribute is ok anyhow.
    2952                 :            :     bool bOnlyNotBecauseOfMatrix;
    2953 [ #  # ][ #  # ]:          0 :     if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
         [ #  # ][ #  # ]
    2954                 :            :     {
    2955         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    2956                 :          0 :         return;
    2957                 :            :     }
    2958                 :            : 
    2959         [ #  # ]:          0 :     ScDocument*             pDoc = GetViewData()->GetDocument();
    2960 [ #  # ][ #  # ]:          0 :     ScMarkData aFuncMark( GetViewData()->GetMarkData() );       // local copy for UnmarkFiltered
    2961         [ #  # ]:          0 :     ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
    2962                 :          0 :     ScDocShell*             pDocSh = GetViewData()->GetDocShell();
    2963         [ #  # ]:          0 :     const ScPatternAttr*    pSelAttrs = GetSelectionPattern();
    2964                 :          0 :     const SfxItemSet&       rSelItemSet = pSelAttrs->GetItemSet();
    2965                 :            : 
    2966                 :          0 :     const SfxPoolItem*      pBorderAttr = NULL;
    2967         [ #  # ]:          0 :     SfxItemState            eItemState = rSelItemSet.GetItemState( ATTR_BORDER, sal_True, &pBorderAttr );
    2968                 :            : 
    2969                 :          0 :     const SfxPoolItem*      pTLBRItem = 0;
    2970         [ #  # ]:          0 :     SfxItemState            eTLBRState = rSelItemSet.GetItemState( ATTR_BORDER_TLBR, sal_True, &pTLBRItem );
    2971                 :            : 
    2972                 :          0 :     const SfxPoolItem*      pBLTRItem = 0;
    2973         [ #  # ]:          0 :     SfxItemState            eBLTRState = rSelItemSet.GetItemState( ATTR_BORDER_BLTR, sal_True, &pBLTRItem );
    2974                 :            : 
    2975                 :            :     // any of the lines visible?
    2976 [ #  # ][ #  # ]:          0 :     if( (eItemState != SFX_ITEM_DEFAULT) || (eTLBRState != SFX_ITEM_DEFAULT) || (eBLTRState != SFX_ITEM_DEFAULT) )
                 [ #  # ]
    2977                 :            :     {
    2978                 :            :         // none of the lines don't care?
    2979 [ #  # ][ #  # ]:          0 :         if( (eItemState != SFX_ITEM_DONTCARE) && (eTLBRState != SFX_ITEM_DONTCARE) && (eBLTRState != SFX_ITEM_DONTCARE) )
                 [ #  # ]
    2980                 :            :         {
    2981                 :            :             SfxItemSet*     pOldSet = new SfxItemSet(
    2982         [ #  # ]:          0 :                                             *(pDoc->GetPool()),
    2983                 :            :                                             ATTR_PATTERN_START,
    2984 [ #  # ][ #  # ]:          0 :                                             ATTR_PATTERN_END );
    2985                 :            :             SfxItemSet*     pNewSet = new SfxItemSet(
    2986         [ #  # ]:          0 :                                             *(pDoc->GetPool()),
    2987                 :            :                                             ATTR_PATTERN_START,
    2988 [ #  # ][ #  # ]:          0 :                                             ATTR_PATTERN_END );
    2989                 :            : 
    2990                 :            :             //------------------------------------------------------------
    2991                 :          0 :             const SvxBorderLine*    pBoxLine = NULL;
    2992         [ #  # ]:          0 :             SvxBorderLine           aLine;
    2993                 :            : 
    2994                 :            :             // here pBoxLine is used
    2995                 :            : 
    2996         [ #  # ]:          0 :             if( pBorderAttr )
    2997                 :            :             {
    2998         [ #  # ]:          0 :                 SvxBoxItem      aBoxItem( *(const SvxBoxItem*)pBorderAttr );
    2999         [ #  # ]:          0 :                 SvxBoxInfoItem  aBoxInfoItem( ATTR_BORDER_INNER );
    3000                 :            : 
    3001 [ #  # ][ #  # ]:          0 :                 SET_LINE_ATTRIBUTES(Top,BOX_LINE_TOP)
         [ #  # ][ #  # ]
                 [ #  # ]
    3002 [ #  # ][ #  # ]:          0 :                 SET_LINE_ATTRIBUTES(Bottom,BOX_LINE_BOTTOM)
         [ #  # ][ #  # ]
                 [ #  # ]
    3003 [ #  # ][ #  # ]:          0 :                 SET_LINE_ATTRIBUTES(Left,BOX_LINE_LEFT)
         [ #  # ][ #  # ]
                 [ #  # ]
    3004 [ #  # ][ #  # ]:          0 :                 SET_LINE_ATTRIBUTES(Right,BOX_LINE_RIGHT)
         [ #  # ][ #  # ]
                 [ #  # ]
    3005                 :            : 
    3006         [ #  # ]:          0 :                 aBoxInfoItem.SetLine( aBoxItem.GetTop(), BOXINFO_LINE_HORI );
    3007         [ #  # ]:          0 :                 aBoxInfoItem.SetLine( aBoxItem.GetLeft(), BOXINFO_LINE_VERT );
    3008         [ #  # ]:          0 :                 aBoxInfoItem.ResetFlags(); // set Lines to Valid
    3009                 :            : 
    3010         [ #  # ]:          0 :                 pOldSet->Put( *pBorderAttr );
    3011         [ #  # ]:          0 :                 pNewSet->Put( aBoxItem );
    3012 [ #  # ][ #  # ]:          0 :                 pNewSet->Put( aBoxInfoItem );
                 [ #  # ]
    3013                 :            :             }
    3014                 :            : 
    3015 [ #  # ][ #  # ]:          0 :             if( pTLBRItem && ((const SvxLineItem*)pTLBRItem)->GetLine() )
                 [ #  # ]
    3016                 :            :             {
    3017         [ #  # ]:          0 :                 SvxLineItem aTLBRItem( *(const SvxLineItem*)pTLBRItem );
    3018         [ #  # ]:          0 :                 UpdateLineAttrs( aLine, aTLBRItem.GetLine(), pLine, bColorOnly );
    3019         [ #  # ]:          0 :                 aTLBRItem.SetLine( &aLine );
    3020         [ #  # ]:          0 :                 pOldSet->Put( *pTLBRItem );
    3021 [ #  # ][ #  # ]:          0 :                 pNewSet->Put( aTLBRItem );
    3022                 :            :             }
    3023                 :            : 
    3024 [ #  # ][ #  # ]:          0 :             if( pBLTRItem && ((const SvxLineItem*)pBLTRItem)->GetLine() )
                 [ #  # ]
    3025                 :            :             {
    3026         [ #  # ]:          0 :                 SvxLineItem aBLTRItem( *(const SvxLineItem*)pBLTRItem );
    3027         [ #  # ]:          0 :                 UpdateLineAttrs( aLine, aBLTRItem.GetLine(), pLine, bColorOnly );
    3028         [ #  # ]:          0 :                 aBLTRItem.SetLine( &aLine );
    3029         [ #  # ]:          0 :                 pOldSet->Put( *pBLTRItem );
    3030 [ #  # ][ #  # ]:          0 :                 pNewSet->Put( aBLTRItem );
    3031                 :            :             }
    3032                 :            : 
    3033         [ #  # ]:          0 :             ApplyAttributes( pNewSet, pOldSet );
    3034                 :            : 
    3035 [ #  # ][ #  # ]:          0 :             delete pOldSet;
    3036 [ #  # ][ #  # ]:          0 :             delete pNewSet;
    3037                 :            :         }
    3038                 :            :         else // if ( eItemState == SFX_ITEM_DONTCARE )
    3039                 :            :         {
    3040         [ #  # ]:          0 :             aFuncMark.MarkToMulti();
    3041         [ #  # ]:          0 :             pDoc->ApplySelectionLineStyle( aFuncMark, pLine, bColorOnly );
    3042                 :            :         }
    3043                 :            : 
    3044                 :          0 :         ScRange aMarkRange;
    3045         [ #  # ]:          0 :         aFuncMark.GetMultiMarkArea( aMarkRange );
    3046                 :          0 :         SCCOL nStartCol = aMarkRange.aStart.Col();
    3047                 :          0 :         SCROW nStartRow = aMarkRange.aStart.Row();
    3048                 :          0 :         SCTAB nStartTab = aMarkRange.aStart.Tab();
    3049                 :          0 :         SCCOL nEndCol = aMarkRange.aEnd.Col();
    3050                 :          0 :         SCROW nEndRow = aMarkRange.aEnd.Row();
    3051                 :          0 :         SCTAB nEndTab = aMarkRange.aEnd.Tab();
    3052                 :            :         pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
    3053                 :            :                            nEndCol, nEndRow, nEndTab,
    3054         [ #  # ]:          0 :                            PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
    3055                 :            : 
    3056         [ #  # ]:          0 :         pDocSh->UpdateOle( GetViewData() );
    3057         [ #  # ]:          0 :         pDocSh->SetDocumentModified();
    3058         [ #  # ]:          0 :     }
    3059                 :            : }
    3060                 :            : 
    3061                 :            : #undef SET_LINE_ATTRIBUTES
    3062                 :            : 
    3063                 :            : //----------------------------------------------------------------------------
    3064                 :            : 
    3065                 :          0 : void ScViewFunc::SetValidation( const ScValidationData& rNew )
    3066                 :            : {
    3067         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
    3068         [ #  # ]:          0 :     sal_uLong nIndex = pDoc->AddValidationEntry(rNew);      // for it there is no Undo
    3069         [ #  # ]:          0 :     SfxUInt32Item aItem( ATTR_VALIDDATA, nIndex );
    3070                 :            : 
    3071 [ #  # ][ #  # ]:          0 :     ApplyAttr( aItem );         // with Paint and Undo...
    3072                 :          0 : }
    3073                 :            : 
    3074                 :            : 
    3075                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10