LCOV - code coverage report
Current view: top level - sc/source/ui/view - viewfunc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 59 1572 3.8 %
Date: 2012-08-25 Functions: 6 47 12.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 39 3066 1.3 %

           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 <editeng/eeitem.hxx>
      31                 :            : 
      32                 :            : #include <sfx2/app.hxx>
      33                 :            : #include <svx/algitem.hxx>
      34                 :            : #include <editeng/boxitem.hxx>
      35                 :            : #include <editeng/editobj.hxx>
      36                 :            : #include <editeng/editview.hxx>
      37                 :            : #include <editeng/langitem.hxx>
      38                 :            : #include <editeng/scripttypeitem.hxx>
      39                 :            : #include <editeng/justifyitem.hxx>
      40                 :            : #include <sfx2/bindings.hxx>
      41                 :            : #include <svl/zforlist.hxx>
      42                 :            : #include <svl/zformat.hxx>
      43                 :            : #include <vcl/msgbox.hxx>
      44                 :            : #include <vcl/virdev.hxx>
      45                 :            : #include <vcl/waitobj.hxx>
      46                 :            : #include <vcl/wrkwin.hxx>
      47                 :            : #include <stdlib.h>             // qsort
      48                 :            : 
      49                 :            : #include "viewfunc.hxx"
      50                 :            : #include "tabvwsh.hxx"
      51                 :            : #include "docsh.hxx"
      52                 :            : #include "attrib.hxx"
      53                 :            : #include "patattr.hxx"
      54                 :            : #include "docpool.hxx"
      55                 :            : #include "uiitems.hxx"
      56                 :            : #include "sc.hrc"
      57                 :            : #include "undocell.hxx"
      58                 :            : #include "undoblk.hxx"
      59                 :            : #include "undotab.hxx"
      60                 :            : #include "refundo.hxx"
      61                 :            : #include "dbdata.hxx"
      62                 :            : #include "olinetab.hxx"
      63                 :            : #include "rangeutl.hxx"
      64                 :            : #include "rangenam.hxx"
      65                 :            : #include "globstr.hrc"
      66                 :            : #include "global.hxx"
      67                 :            : #include "stlsheet.hxx"
      68                 :            : #include "editutil.hxx"
      69                 :            : #include "cell.hxx"
      70                 :            : #include "scresid.hxx"
      71                 :            : #include "inputhdl.hxx"
      72                 :            : #include "scmod.hxx"
      73                 :            : #include "inputopt.hxx"
      74                 :            : #include "compiler.hxx"
      75                 :            : #include "docfunc.hxx"
      76                 :            : #include "appoptio.hxx"
      77                 :            : #include "dociter.hxx"
      78                 :            : #include "sizedev.hxx"
      79                 :            : #include "editable.hxx"
      80                 :            : #include "scui_def.hxx"
      81                 :            : #include "funcdesc.hxx"
      82                 :            : #include "docuno.hxx"
      83                 :            : #include "cellsuno.hxx"
      84                 :            : //==================================================================
      85                 :            : 
      86                 :          0 : static void lcl_PostRepaintCondFormat( const ScConditionalFormat *pCondFmt, ScDocShell *pDocSh )
      87                 :            : {
      88         [ #  # ]:          0 :     if( pCondFmt )
      89                 :            :     {
      90                 :          0 :         const ScRangeList& rRanges = pCondFmt->GetRange();
      91                 :            : 
      92                 :          0 :         pDocSh->PostPaint( rRanges, PAINT_ALL );
      93                 :            :     }
      94                 :          0 : }
      95                 :            : 
      96                 :            : 
      97                 :            : //==================================================================
      98                 :            : 
      99                 :        229 : ScViewFunc::ScViewFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) :
     100                 :            :     ScTabView( pParent, rDocSh, pViewShell ),
     101                 :        229 :     bFormatValid( false )
     102                 :            : {
     103                 :        229 : }
     104                 :            : 
     105                 :        225 : ScViewFunc::~ScViewFunc()
     106                 :            : {
     107                 :        225 : }
     108                 :            : 
     109                 :            : //------------------------------------------------------------------------------------
     110                 :            : 
     111                 :          0 : void ScViewFunc::StartFormatArea()
     112                 :            : {
     113                 :            :     //  anything to do?
     114 [ #  # ][ #  # ]:          0 :     if ( !SC_MOD()->GetInputOptions().GetExtendFormat() )
                 [ #  # ]
     115                 :          0 :         return;
     116                 :            : 
     117                 :            :     //  start only with single cell (marked or cursor position)
     118                 :          0 :     ScRange aMarkRange;
     119         [ #  # ]:          0 :     sal_Bool bOk = (GetViewData()->GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE);
     120 [ #  # ][ #  # ]:          0 :     if ( bOk && aMarkRange.aStart != aMarkRange.aEnd )
                 [ #  # ]
     121                 :          0 :         bOk = false;
     122                 :            : 
     123         [ #  # ]:          0 :     if (bOk)
     124                 :            :     {
     125                 :          0 :         bFormatValid = sal_True;
     126                 :          0 :         aFormatSource = aMarkRange.aStart;
     127                 :          0 :         aFormatArea = ScRange( aFormatSource );
     128                 :            :     }
     129                 :            :     else
     130                 :          0 :         bFormatValid = false;       // discard old range
     131                 :            : }
     132                 :            : 
     133                 :          0 : sal_Bool ScViewFunc::TestFormatArea( SCCOL nCol, SCROW nRow, SCTAB nTab, sal_Bool bAttrChanged )
     134                 :            : {
     135                 :            :     //  anything to do?
     136 [ #  # ][ #  # ]:          0 :     if ( !SC_MOD()->GetInputOptions().GetExtendFormat() )
                 [ #  # ]
     137                 :          0 :         return false;
     138                 :            : 
     139                 :            :     //  Test: treat input with numberformat (bAttrChanged) always as new Attribute
     140                 :            :     //  (discard old Area ). If not not wanted, discard if-statement
     141         [ #  # ]:          0 :     if ( bAttrChanged )
     142                 :            :     {
     143         [ #  # ]:          0 :         StartFormatArea();
     144                 :          0 :         return false;
     145                 :            :     }
     146                 :            : 
     147                 :            :     //! Test if cell empty ???
     148                 :            : 
     149                 :          0 :     sal_Bool bFound = false;
     150                 :          0 :     ScRange aNewRange = aFormatArea;
     151 [ #  # ][ #  # ]:          0 :     if ( bFormatValid && nTab == aFormatSource.Tab() )
                 [ #  # ]
     152                 :            :     {
     153 [ #  # ][ #  # ]:          0 :         if ( nRow >= aFormatArea.aStart.Row() && nRow <= aFormatArea.aEnd.Row() )
                 [ #  # ]
     154                 :            :         {
     155                 :            :             //  within range?
     156 [ #  # ][ #  # ]:          0 :             if ( nCol >= aFormatArea.aStart.Col() && nCol <= aFormatArea.aEnd.Col() )
                 [ #  # ]
     157                 :            :             {
     158                 :          0 :                 bFound = sal_True;          // do not change range
     159                 :            :             }
     160                 :            :             //  left ?
     161         [ #  # ]:          0 :             if ( nCol+1 == aFormatArea.aStart.Col() )
     162                 :            :             {
     163                 :          0 :                 bFound = sal_True;
     164                 :          0 :                 aNewRange.aStart.SetCol( nCol );
     165                 :            :             }
     166                 :            :             //  right ?
     167         [ #  # ]:          0 :             if ( nCol == aFormatArea.aEnd.Col()+1 )
     168                 :            :             {
     169                 :          0 :                 bFound = sal_True;
     170                 :          0 :                 aNewRange.aEnd.SetCol( nCol );
     171                 :            :             }
     172                 :            :         }
     173 [ #  # ][ #  # ]:          0 :         if ( nCol >= aFormatArea.aStart.Col() && nCol <= aFormatArea.aEnd.Col() )
                 [ #  # ]
     174                 :            :         {
     175                 :            :             //  top ?
     176         [ #  # ]:          0 :             if ( nRow+1 == aFormatArea.aStart.Row() )
     177                 :            :             {
     178                 :          0 :                 bFound = sal_True;
     179                 :          0 :                 aNewRange.aStart.SetRow( nRow );
     180                 :            :             }
     181                 :            :             //  bottom ?
     182         [ #  # ]:          0 :             if ( nRow == aFormatArea.aEnd.Row()+1 )
     183                 :            :             {
     184                 :          0 :                 bFound = sal_True;
     185                 :          0 :                 aNewRange.aEnd.SetRow( nRow );
     186                 :            :             }
     187                 :            :         }
     188                 :            :     }
     189                 :            : 
     190         [ #  # ]:          0 :     if (bFound)
     191                 :          0 :         aFormatArea = aNewRange;    // extend
     192                 :            :     else
     193                 :            :     {
     194                 :          0 :         bFormatValid = false;       // outdside of range -> break
     195         [ #  # ]:          0 :         if ( bAttrChanged )         // if value entered with numberformat?
     196         [ #  # ]:          0 :             StartFormatArea();      // then start again
     197                 :            :     }
     198                 :            : 
     199                 :          0 :     return bFound;
     200                 :            : }
     201                 :            : 
     202                 :          0 : void ScViewFunc::DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab,
     203                 :            :                                    sal_Bool bAttrChanged, sal_Bool bAddUndo )
     204                 :            : {
     205                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     206                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
     207 [ #  # ][ #  # ]:          0 :     if (bAddUndo && !pDoc->IsUndoEnabled())
                 [ #  # ]
     208                 :          0 :         bAddUndo = false;
     209                 :            : 
     210                 :            :     const ScPatternAttr* pSource = pDoc->GetPattern(
     211                 :          0 :                             aFormatSource.Col(), aFormatSource.Row(), nTab );
     212         [ #  # ]:          0 :     if ( !((const ScMergeAttr&)pSource->GetItem(ATTR_MERGE)).IsMerged() )
     213                 :            :     {
     214                 :          0 :         ScRange aRange( nCol, nRow, nTab, nCol, nRow, nTab );
     215         [ #  # ]:          0 :         ScMarkData aMark;
     216         [ #  # ]:          0 :         aMark.SetMarkArea( aRange );
     217                 :            : 
     218         [ #  # ]:          0 :         ScDocFunc &rFunc = GetViewData()->GetDocFunc();
     219                 :            : 
     220                 :            :         // pOldPattern is only valid until call to ApplyAttributes!
     221         [ #  # ]:          0 :         const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
     222                 :          0 :         const ScStyleSheet* pSrcStyle = pSource->GetStyleSheet();
     223 [ #  # ][ #  # ]:          0 :         if ( pSrcStyle && pSrcStyle != pOldPattern->GetStyleSheet() )
                 [ #  # ]
     224 [ #  # ][ #  # ]:          0 :             rFunc.ApplyStyle( aMark, pSrcStyle->GetName(), sal_True, sal_False );
     225                 :            : 
     226 [ #  # ][ #  # ]:          0 :         rFunc.ApplyAttributes( aMark, *pSource, sal_True, sal_False );
     227                 :            :     }
     228                 :            : 
     229         [ #  # ]:          0 :     if ( bAttrChanged )                             // value entered with number format?
     230                 :          0 :         aFormatSource.Set( nCol, nRow, nTab );      // then set a new source
     231                 :          0 : }
     232                 :            : 
     233                 :            : //------------------------------------------------------------------------------------
     234                 :            : 
     235                 :            : //      additional routines
     236                 :            : 
     237                 :          0 : sal_uInt16 ScViewFunc::GetOptimalColWidth( SCCOL nCol, SCTAB nTab, sal_Bool bFormula )
     238                 :            : {
     239                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     240                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
     241         [ #  # ]:          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
     242                 :            : 
     243                 :          0 :     double nPPTX = GetViewData()->GetPPTX();
     244                 :          0 :     double nPPTY = GetViewData()->GetPPTY();
     245         [ #  # ]:          0 :     Fraction aZoomX = GetViewData()->GetZoomX();
     246         [ #  # ]:          0 :     Fraction aZoomY = GetViewData()->GetZoomY();
     247                 :            : 
     248         [ #  # ]:          0 :     ScSizeDeviceProvider aProv(pDocSh);
     249         [ #  # ]:          0 :     if (aProv.IsPrinter())
     250                 :            :     {
     251                 :          0 :         nPPTX = aProv.GetPPTX();
     252                 :          0 :         nPPTY = aProv.GetPPTY();
     253 [ #  # ][ #  # ]:          0 :         aZoomX = aZoomY = Fraction( 1, 1 );
                 [ #  # ]
     254                 :            :     }
     255                 :            : 
     256                 :            :     sal_uInt16 nTwips = pDoc->GetOptimalColWidth( nCol, nTab, aProv.GetDevice(),
     257         [ #  # ]:          0 :                                 nPPTX, nPPTY, aZoomX, aZoomY, bFormula, &rMark );
     258         [ #  # ]:          0 :     return nTwips;
     259                 :            : }
     260                 :            : 
     261                 :       1229 : sal_Bool ScViewFunc::SelectionEditable( bool* pOnlyNotBecauseOfMatrix /* = NULL */ )
     262                 :            : {
     263                 :            :     bool bRet;
     264                 :       1229 :     ScDocument* pDoc = GetViewData()->GetDocument();
     265                 :       1229 :     ScMarkData& rMark = GetViewData()->GetMarkData();
     266 [ +  + ][ +  + ]:       1229 :     if (rMark.IsMarked() || rMark.IsMultiMarked())
                 [ +  - ]
     267                 :          4 :         bRet = pDoc->IsSelectionEditable( rMark, pOnlyNotBecauseOfMatrix );
     268                 :            :     else
     269                 :            :     {
     270                 :       1225 :         SCCOL nCol = GetViewData()->GetCurX();
     271                 :       1225 :         SCROW nRow = GetViewData()->GetCurY();
     272                 :       1225 :         SCTAB nTab = GetViewData()->GetTabNo();
     273                 :            :         bRet = pDoc->IsBlockEditable( nTab, nCol, nRow, nCol, nRow,
     274                 :       1225 :             pOnlyNotBecauseOfMatrix );
     275                 :            :     }
     276                 :       1229 :     return bRet;
     277                 :            : }
     278                 :            : 
     279                 :            : #ifndef LRU_MAX
     280                 :            : #define LRU_MAX 10
     281                 :            : #endif
     282                 :            : 
     283                 :          0 : sal_Bool lcl_FunctionKnown( sal_uInt16 nOpCode )
     284                 :            : {
     285                 :          0 :     const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
     286         [ #  # ]:          0 :     if ( pFuncList )
     287                 :            :     {
     288                 :          0 :         sal_uLong nCount = pFuncList->GetCount();
     289         [ #  # ]:          0 :         for (sal_uLong i=0; i<nCount; i++)
     290         [ #  # ]:          0 :             if ( pFuncList->GetFunction(i)->nFIndex == nOpCode )
     291                 :          0 :                 return sal_True;
     292                 :            :     }
     293                 :          0 :     return false;
     294                 :            : }
     295                 :            : 
     296                 :          0 : sal_Bool lcl_AddFunction( ScAppOptions& rAppOpt, sal_uInt16 nOpCode )
     297                 :            : {
     298                 :          0 :     sal_uInt16 nOldCount = rAppOpt.GetLRUFuncListCount();
     299                 :          0 :     sal_uInt16* pOldList = rAppOpt.GetLRUFuncList();
     300                 :            :     sal_uInt16 nPos;
     301         [ #  # ]:          0 :     for (nPos=0; nPos<nOldCount; nPos++)
     302         [ #  # ]:          0 :         if (pOldList[nPos] == nOpCode)          // is the function already in the list?
     303                 :            :         {
     304         [ #  # ]:          0 :             if ( nPos == 0 )
     305                 :          0 :                 return false;                   // already at the top -> no change
     306                 :            : 
     307                 :            :             //  count doesn't change, so the original array is modified
     308                 :            : 
     309         [ #  # ]:          0 :             for (sal_uInt16 nCopy=nPos; nCopy>0; nCopy--)
     310                 :          0 :                 pOldList[nCopy] = pOldList[nCopy-1];
     311                 :          0 :             pOldList[0] = nOpCode;
     312                 :            : 
     313                 :          0 :             return sal_True;                        // list has changed
     314                 :            :         }
     315                 :            : 
     316 [ #  # ][ #  # ]:          0 :     if ( !lcl_FunctionKnown( nOpCode ) )
     317                 :          0 :         return false;                           // not in function list -> no change
     318                 :            : 
     319                 :          0 :     sal_uInt16 nNewCount = Min( (sal_uInt16)(nOldCount + 1), (sal_uInt16)LRU_MAX );
     320                 :            :     sal_uInt16 nNewList[LRU_MAX];
     321                 :          0 :     nNewList[0] = nOpCode;
     322         [ #  # ]:          0 :     for (nPos=1; nPos<nNewCount; nPos++)
     323                 :          0 :         nNewList[nPos] = pOldList[nPos-1];
     324         [ #  # ]:          0 :     rAppOpt.SetLRUFuncList( nNewList, nNewCount );
     325                 :            : 
     326                 :          0 :     return sal_True;                                // list has changed
     327                 :            : }
     328                 :            : 
     329                 :            : //      actual functions
     330                 :            : 
     331                 :            : //  input - undo OK
     332                 :            : 
     333                 :          0 : void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
     334                 :            :                             const String& rString,
     335                 :            :                             const EditTextObject* pData )
     336                 :            : {
     337         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     338         [ #  # ]:          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
     339                 :          0 :     bool bRecord = pDoc->IsUndoEnabled();
     340                 :            :     SCTAB i;
     341                 :            : 
     342                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     343         [ #  # ]:          0 :     ScDocFunc &rFunc = GetViewData()->GetDocFunc();
     344         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
     345                 :            : 
     346         [ #  # ]:          0 :     ScEditableTester aTester( pDoc, nCol,nRow, nCol,nRow, rMark );
     347         [ #  # ]:          0 :     if (aTester.IsEditable())
     348                 :            :     {
     349         [ #  # ]:          0 :         if ( bRecord )
     350         [ #  # ]:          0 :             rFunc.EnterListAction( STR_UNDO_ENTERDATA );
     351                 :            : 
     352                 :          0 :         bool bFormula = false;
     353                 :            : 
     354                 :            :         // a single '=' character is handled as string (needed for special filters)
     355         [ #  # ]:          0 :         if ( rString.Len() > 1 )
     356                 :            :         {
     357         [ #  # ]:          0 :             if ( rString.GetChar(0) == '=' )
     358                 :            :             {
     359                 :            :                 // handle as formula
     360                 :          0 :                 bFormula = true;
     361                 :            :             }
     362 [ #  # ][ #  # ]:          0 :             else if ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' )
                 [ #  # ]
     363                 :            :             {
     364                 :            :                 // if there is more than one leading '+' or '-' character, remove the additional ones
     365         [ #  # ]:          0 :                 String aString( rString );
     366                 :          0 :                 xub_StrLen nIndex = 1;
     367                 :          0 :                 xub_StrLen nLen = aString.Len();
     368 [ #  # ][ #  # ]:          0 :                 while ( nIndex < nLen && ( aString.GetChar( nIndex ) == '+' || aString.GetChar( nIndex ) == '-' ) )
         [ #  # ][ #  # ]
     369                 :            :                 {
     370                 :          0 :                     ++nIndex;
     371                 :            :                 }
     372         [ #  # ]:          0 :                 aString.Erase( 1, nIndex - 1 );
     373                 :            : 
     374                 :            :                 // if the remaining part without the leading '+' or '-' character
     375                 :            :                 // is non-empty and not a number, handle as formula
     376         [ #  # ]:          0 :                 if ( aString.Len() > 1 )
     377                 :            :                 {
     378                 :          0 :                     sal_uInt32 nFormat = 0;
     379         [ #  # ]:          0 :                     pDoc->GetNumberFormat( nCol, nRow, nTab, nFormat );
     380         [ #  # ]:          0 :                     SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
     381                 :          0 :                     double fNumber = 0;
     382 [ #  # ][ #  # ]:          0 :                     if ( !pFormatter->IsNumberFormat( aString, nFormat, fNumber ) )
     383                 :            :                     {
     384                 :          0 :                         bFormula = true;
     385                 :            :                     }
     386         [ #  # ]:          0 :                 }
     387                 :            :             }
     388                 :            :         }
     389                 :            : 
     390                 :          0 :         sal_Bool bNumFmtChanged = false;
     391         [ #  # ]:          0 :         if ( bFormula )
     392                 :            :         {   // formula, compile with autoCorrection
     393         [ #  # ]:          0 :             i = rMark.GetFirstSelected();
     394                 :          0 :             ScAddress aPos( nCol, nRow, i );
     395         [ #  # ]:          0 :             ScCompiler aComp( pDoc, aPos);
     396 [ #  # ][ #  # ]:          0 :             aComp.SetGrammar(pDoc->GetGrammar());
     397                 :            : //2do: enable/disable autoCorrection via calcoptions
     398                 :          0 :             aComp.SetAutoCorrection( sal_True );
     399 [ #  # ][ #  # ]:          0 :             if ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' )
                 [ #  # ]
     400                 :            :             {
     401                 :          0 :                 aComp.SetExtendedErrorDetection( ScCompiler::EXTENDED_ERROR_DETECTION_NAME_BREAK );
     402                 :            :             }
     403         [ #  # ]:          0 :             String aFormula( rString );
     404                 :            :             ScTokenArray* pArr;
     405                 :            :             sal_Bool bAgain;
     406         [ #  # ]:          0 :             do
     407                 :            :             {
     408                 :          0 :                 bAgain = false;
     409                 :          0 :                 bool bAddEqual = false;
     410         [ #  # ]:          0 :                 ScTokenArray* pArrFirst = pArr = aComp.CompileString( aFormula );
     411                 :          0 :                 bool bCorrected = aComp.IsCorrected();
     412         [ #  # ]:          0 :                 if ( bCorrected )
     413                 :            :                 {   // try to parse with first parser-correction
     414         [ #  # ]:          0 :                     pArr = aComp.CompileString( aComp.GetCorrectedFormula() );
     415                 :            :                 }
     416         [ #  # ]:          0 :                 if ( !pArr->GetCodeError() )
     417                 :            :                 {
     418                 :          0 :                     bAddEqual = true;
     419         [ #  # ]:          0 :                     aComp.CompileTokenArray();
     420                 :          0 :                     bCorrected |= aComp.IsCorrected();
     421                 :            :                 }
     422         [ #  # ]:          0 :                 if ( bCorrected )
     423                 :            :                 {
     424         [ #  # ]:          0 :                     String aCorrectedFormula;
     425         [ #  # ]:          0 :                     if ( bAddEqual )
     426                 :            :                     {
     427         [ #  # ]:          0 :                         aCorrectedFormula = '=';
     428         [ #  # ]:          0 :                         aCorrectedFormula += aComp.GetCorrectedFormula();
     429                 :            :                     }
     430                 :            :                     else
     431         [ #  # ]:          0 :                         aCorrectedFormula = aComp.GetCorrectedFormula();
     432                 :            :                     short nResult;
     433         [ #  # ]:          0 :                     if ( aCorrectedFormula.Len() == 1 )
     434                 :          0 :                         nResult = RET_NO;   // empty formula, just '='
     435                 :            :                     else
     436                 :            :                     {
     437 [ #  # ][ #  # ]:          0 :                         String aMessage( ScResId( SCSTR_FORMULA_AUTOCORRECTION ) );
     438         [ #  # ]:          0 :                         aMessage += aCorrectedFormula;
     439                 :            :                         nResult = QueryBox( GetViewData()->GetDialogParent(),
     440                 :            :                                                 WinBits(WB_YES_NO | WB_DEF_YES),
     441 [ #  # ][ #  # ]:          0 :                                                 aMessage ).Execute();
         [ #  # ][ #  # ]
                 [ #  # ]
     442                 :            :                     }
     443         [ #  # ]:          0 :                     if ( nResult == RET_YES )
     444                 :            :                     {
     445         [ #  # ]:          0 :                         aFormula = aCorrectedFormula;
     446         [ #  # ]:          0 :                         if ( pArr != pArrFirst )
     447 [ #  # ][ #  # ]:          0 :                             delete pArrFirst;
     448                 :          0 :                         bAgain = sal_True;
     449                 :            :                     }
     450                 :            :                     else
     451                 :            :                     {
     452         [ #  # ]:          0 :                         if ( pArr != pArrFirst )
     453                 :            :                         {
     454 [ #  # ][ #  # ]:          0 :                             delete pArr;
     455                 :          0 :                             pArr = pArrFirst;
     456                 :            :                         }
     457         [ #  # ]:          0 :                     }
     458                 :            :                 }
     459                 :            :             } while ( bAgain );
     460                 :            :             // to be used in multiple tabs, the formula must be compiled anew
     461                 :            :             // via ScFormulaCell copy-ctor because of RangeNames,
     462                 :            :             // the same code-array for all cells is not possible.
     463                 :            :             // If the array has an error, (it) must be RPN-erased in the newly generated
     464                 :            :             // cellst and the error be set explicitly, so that
     465                 :            :             // via FormulaCell copy-ctor and Interpreter it will be, when possible,
     466                 :            :             // ironed out again, too intelligent.. e.g.: =1))
     467                 :          0 :             sal_uInt16 nError = pArr->GetCodeError();
     468         [ #  # ]:          0 :             if ( !nError )
     469                 :            :             {
     470                 :            :                 //  update list of recent functions with all functions that
     471                 :            :                 //  are not within parentheses
     472                 :            : 
     473         [ #  # ]:          0 :                 ScModule* pScMod = SC_MOD();
     474 [ #  # ][ #  # ]:          0 :                 ScAppOptions aAppOpt = pScMod->GetAppOptions();
     475                 :          0 :                 sal_Bool bOptChanged = false;
     476                 :            : 
     477                 :          0 :                 formula::FormulaToken** ppToken = pArr->GetArray();
     478                 :          0 :                 sal_uInt16 nTokens = pArr->GetLen();
     479                 :          0 :                 sal_uInt16 nLevel = 0;
     480         [ #  # ]:          0 :                 for (sal_uInt16 nTP=0; nTP<nTokens; nTP++)
     481                 :            :                 {
     482                 :          0 :                     formula::FormulaToken* pTok = ppToken[nTP];
     483                 :          0 :                     OpCode eOp = pTok->GetOpCode();
     484         [ #  # ]:          0 :                     if ( eOp == ocOpen )
     485                 :          0 :                         ++nLevel;
     486 [ #  # ][ #  # ]:          0 :                     else if ( eOp == ocClose && nLevel )
     487                 :          0 :                         --nLevel;
     488 [ #  # ][ #  # ]:          0 :                     if ( nLevel == 0 && pTok->IsFunction() &&
         [ #  # ][ #  # ]
                 [ #  # ]
     489         [ #  # ]:          0 :                             lcl_AddFunction( aAppOpt, sal::static_int_cast<sal_uInt16>( eOp ) ) )
     490                 :          0 :                         bOptChanged = sal_True;
     491                 :            :                 }
     492                 :            : 
     493         [ #  # ]:          0 :                 if ( bOptChanged )
     494                 :            :                 {
     495         [ #  # ]:          0 :                     pScMod->SetAppOptions(aAppOpt);
     496         [ #  # ]:          0 :                     pScMod->RecentFunctionsChanged();
     497         [ #  # ]:          0 :                 }
     498                 :            :             }
     499                 :            : 
     500         [ #  # ]:          0 :             ScFormulaCell aCell( pDoc, aPos, pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE );
     501 [ #  # ][ #  # ]:          0 :             delete pArr;
     502                 :            : 
     503         [ #  # ]:          0 :             SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
     504 [ #  # ][ #  # ]:          0 :             ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
     505 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
     506                 :            :             {
     507         [ #  # ]:          0 :                 i = *itr;
     508                 :          0 :                 aPos.SetTab( i );
     509                 :            :                 sal_uLong nIndex = (sal_uLong) ((SfxUInt32Item*) pDoc->GetAttr(
     510         [ #  # ]:          0 :                     nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue();
     511   [ #  #  #  #  :          0 :                 if ( pFormatter->GetType( nIndex ) == NUMBERFORMAT_TEXT ||
           #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     512         [ #  # ]:          0 :                      ( ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' ) && nError && rString.Equals( aFormula ) ) )
     513                 :            :                 {
     514                 :            :                     ScBaseCell *pCell;
     515         [ #  # ]:          0 :                     if ( pData )
     516 [ #  # ][ #  # ]:          0 :                         pCell = new ScEditCell( pData, pDoc, NULL );
     517                 :            :                     else
     518 [ #  # ][ #  # ]:          0 :                         pCell = new ScStringCell( aFormula );
                 [ #  # ]
     519         [ #  # ]:          0 :                     rFunc.PutCell( aPos, pCell, sal_False );
     520                 :            :                 }
     521                 :            :                 else
     522                 :            :                 {
     523 [ #  # ][ #  # ]:          0 :                     ScFormulaCell* pCell = new ScFormulaCell( aCell, *pDoc, aPos );
     524         [ #  # ]:          0 :                     if ( nError )
     525                 :            :                     {
     526         [ #  # ]:          0 :                         pCell->GetCode()->DelRPN();
     527         [ #  # ]:          0 :                         pCell->SetErrCode( nError );
     528         [ #  # ]:          0 :                         if(pCell->GetCode()->IsHyperLink())
     529                 :          0 :                             pCell->GetCode()->SetHyperLink(false);
     530                 :            :                     }
     531 [ #  # ][ #  # ]:          0 :                     rFunc.PutCell( aPos, pCell, sal_False );
     532                 :            :                 }
     533 [ #  # ][ #  # ]:          0 :             }
                 [ #  # ]
     534                 :            :         }
     535                 :            :         else
     536                 :            :         {
     537 [ #  # ][ #  # ]:          0 :             ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
     538 [ #  # ][ #  # ]:          0 :             for ( ; itr != itrEnd; ++itr )
                 [ #  # ]
     539                 :            :             {
     540                 :          0 :                 bool bNumFmtSet = false;
     541 [ #  # ][ #  # ]:          0 :                 rFunc.SetNormalString( bNumFmtSet, ScAddress( nCol, nRow, *itr ), rString, sal_False );
     542         [ #  # ]:          0 :                 if (bNumFmtSet)
     543                 :            :                 {
     544                 :            :                     /* FIXME: if set on any sheet results in changed only on
     545                 :            :                      * sheet nTab for TestFormatArea() and DoAutoAttributes() */
     546                 :          0 :                     bNumFmtChanged = true;
     547                 :            :                 }
     548                 :            :             }
     549                 :            :         }
     550                 :            : 
     551         [ #  # ]:          0 :         sal_Bool bAutoFormat = TestFormatArea(nCol, nRow, nTab, bNumFmtChanged);
     552                 :            : 
     553         [ #  # ]:          0 :         if (bAutoFormat)
     554         [ #  # ]:          0 :             DoAutoAttributes(nCol, nRow, nTab, bNumFmtChanged, bRecord);
     555                 :            : 
     556         [ #  # ]:          0 :         pDocSh->UpdateOle(GetViewData());
     557                 :            : 
     558                 :            :         // #i97876# Spreadsheet data changes are not notified
     559 [ #  # ][ #  # ]:          0 :         ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
     560 [ #  # ][ #  # ]:          0 :         if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
     561                 :            :         {
     562         [ #  # ]:          0 :             ScRangeList aChangeRanges;
     563 [ #  # ][ #  # ]:          0 :             ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
     564 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
     565 [ #  # ][ #  # ]:          0 :                 aChangeRanges.Append( ScRange( nCol, nRow, *itr ) );
     566                 :            : 
     567 [ #  # ][ #  # ]:          0 :             pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
         [ #  # ][ #  # ]
                 [ #  # ]
     568                 :            :         }
     569                 :            : 
     570         [ #  # ]:          0 :         if ( bRecord )
     571         [ #  # ]:          0 :             rFunc.EndListAction();
     572                 :            : 
     573         [ #  # ]:          0 :         aModificator.SetDocumentModified();
     574 [ #  # ][ #  # ]:          0 :         lcl_PostRepaintCondFormat( pDoc->GetCondFormat( nCol, nRow, nTab ), pDocSh );
     575                 :            :     }
     576                 :            :     else
     577                 :            :     {
     578 [ #  # ][ #  # ]:          0 :         ErrorMessage(aTester.GetMessageId());
     579         [ #  # ]:          0 :         PaintArea( nCol, nRow, nCol, nRow );        // possibly the edit-engine is still painted there
     580         [ #  # ]:          0 :     }
     581                 :          0 : }
     582                 :            : 
     583                 :            : // enter value in single cell (on nTab only)
     584                 :            : 
     585                 :          0 : void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rValue )
     586                 :            : {
     587                 :          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     588                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     589                 :            : 
     590 [ #  # ][ #  # ]:          0 :     if ( pDoc && pDocSh )
     591                 :            :     {
     592                 :          0 :         sal_Bool bUndo(pDoc->IsUndoEnabled());
     593         [ #  # ]:          0 :         ScDocShellModificator aModificator( *pDocSh );
     594                 :            : 
     595         [ #  # ]:          0 :         ScEditableTester aTester( pDoc, nTab, nCol,nRow, nCol,nRow );
     596         [ #  # ]:          0 :         if (aTester.IsEditable())
     597                 :            :         {
     598                 :          0 :             ScAddress aPos( nCol, nRow, nTab );
     599         [ #  # ]:          0 :             ScBaseCell* pOldCell = pDoc->GetCell( aPos );
     600                 :          0 :             sal_Bool bNeedHeight = ( pOldCell && pOldCell->GetCellType() == CELLTYPE_EDIT )
     601                 :            :                                 || pDoc->HasAttrib(
     602   [ #  #  #  # ]:          0 :                                     nCol,nRow,nTab, nCol,nRow,nTab, HASATTR_NEEDHEIGHT );
         [ #  # ][ #  # ]
     603                 :            : 
     604                 :            :             //  undo
     605 [ #  # ][ #  # ]:          0 :             ScBaseCell* pUndoCell = (bUndo && pOldCell) ? pOldCell->Clone( *pDoc ) : 0;
                 [ #  # ]
     606                 :            : 
     607         [ #  # ]:          0 :             pDoc->SetValue( nCol, nRow, nTab, rValue );
     608                 :            : 
     609                 :            :             // because of ChangeTrack after change in document
     610         [ #  # ]:          0 :             if (bUndo)
     611                 :            :             {
     612         [ #  # ]:          0 :                 pDocSh->GetUndoManager()->AddUndoAction(
     613 [ #  # ][ #  # ]:          0 :                     new ScUndoEnterValue( pDocSh, aPos, pUndoCell, rValue, bNeedHeight ) );
                 [ #  # ]
     614                 :            :             }
     615                 :            : 
     616         [ #  # ]:          0 :             pDocSh->PostPaintCell( aPos );
     617         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
     618         [ #  # ]:          0 :             aModificator.SetDocumentModified();
     619                 :            :         }
     620                 :            :         else
     621 [ #  # ][ #  # ]:          0 :             ErrorMessage(aTester.GetMessageId());
                 [ #  # ]
     622                 :            :     }
     623                 :          0 : }
     624                 :            : 
     625                 :          0 : void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
     626                 :            :                             const EditTextObject* pData, bool bTestSimple )
     627                 :            : {
     628                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
     629         [ #  # ]:          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
     630                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
     631                 :          0 :     bool bRecord = pDoc->IsUndoEnabled();
     632                 :            : 
     633         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
     634                 :            : 
     635         [ #  # ]:          0 :     ScEditableTester aTester( pDoc, nTab, nCol,nRow, nCol,nRow );
     636         [ #  # ]:          0 :     if (aTester.IsEditable())
     637                 :            :     {
     638                 :            :         //
     639                 :            :         //      test for attribute
     640                 :            :         //
     641                 :          0 :         sal_Bool bSimple = false;
     642                 :          0 :         sal_Bool bCommon = false;
     643                 :          0 :         ScPatternAttr* pCellAttrs = NULL;
     644                 :          0 :         EditTextObject* pNewData = NULL;
     645         [ #  # ]:          0 :         String aString;
     646                 :            : 
     647         [ #  # ]:          0 :         const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
     648 [ #  # ][ #  # ]:          0 :         ScTabEditEngine aEngine( *pOldPattern, pDoc->GetEnginePool() );
     649         [ #  # ]:          0 :         aEngine.SetText(*pData);
     650                 :            : 
     651         [ #  # ]:          0 :         if (bTestSimple)                    // test, if simple string without attribute
     652                 :            :         {
     653         [ #  # ]:          0 :             ScEditAttrTester aAttrTester( &aEngine );
     654                 :          0 :             bSimple = !aAttrTester.NeedsObject();
     655                 :          0 :             bCommon = aAttrTester.NeedsCellAttr();
     656                 :            : 
     657                 :            :             // formulas have to be recognized even if they're formatted
     658                 :            :             // (but commmon attributes are still collected)
     659                 :            : 
     660 [ #  # ][ #  # ]:          0 :             if ( !bSimple && aEngine.GetParagraphCount() == 1 )
         [ #  # ][ #  # ]
     661                 :            :             {
     662         [ #  # ]:          0 :                 String aParStr = aEngine.GetText( (sal_uInt16) 0 );
     663         [ #  # ]:          0 :                 if ( aParStr.GetChar(0) == '=' )
     664         [ #  # ]:          0 :                     bSimple = sal_True;
     665                 :            :             }
     666                 :            : 
     667         [ #  # ]:          0 :             if (bCommon)                // attribute for tab
     668                 :            :             {
     669 [ #  # ][ #  # ]:          0 :                 pCellAttrs = new ScPatternAttr( *pOldPattern );
     670         [ #  # ]:          0 :                 pCellAttrs->GetFromEditItemSet( &aAttrTester.GetAttribs() );
     671                 :            :                 //! remove common attributes from EditEngine?
     672         [ #  # ]:          0 :             }
     673                 :            :         }
     674                 :            : 
     675                 :            :         // #i97726# always get text for "repeat" of undo action
     676 [ #  # ][ #  # ]:          0 :         aString = ScEditUtil::GetSpaceDelimitedString(aEngine);
                 [ #  # ]
     677                 :            : 
     678                 :            :         //
     679                 :            :         //      undo
     680                 :            :         //
     681                 :            : 
     682         [ #  # ]:          0 :         SCTAB nSelCount = rMark.GetSelectCount();
     683                 :          0 :         ScBaseCell** ppOldCells = NULL;
     684                 :          0 :         SCTAB* pTabs            = NULL;
     685                 :          0 :         SCTAB nPos = 0;
     686                 :          0 :         EditTextObject* pUndoData = NULL;
     687 [ #  # ][ #  # ]:          0 :         if (bRecord && !bSimple)
     688                 :            :         {
     689         [ #  # ]:          0 :             ppOldCells  = new ScBaseCell*[nSelCount];
     690         [ #  # ]:          0 :             pTabs       = new SCTAB[nSelCount];
     691                 :          0 :             nPos = 0;
     692                 :            : 
     693 [ #  # ][ #  # ]:          0 :             ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
     694 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
     695                 :            :             {
     696         [ #  # ]:          0 :                 pTabs[nPos] = *itr;
     697                 :            :                 ScBaseCell* pDocCell;
     698 [ #  # ][ #  # ]:          0 :                 pDoc->GetCell( nCol, nRow, *itr, pDocCell );
     699 [ #  # ][ #  # ]:          0 :                 ppOldCells[nPos] = pDocCell ? pDocCell->Clone( *pDoc ) : 0;
     700                 :          0 :                 ++nPos;
     701                 :            :             }
     702                 :            : 
     703                 :            :             OSL_ENSURE( nPos==nSelCount, "nPos!=nSelCount" );
     704                 :            : 
     705         [ #  # ]:          0 :             pUndoData = pData->Clone();
     706                 :            :         }
     707                 :            : 
     708                 :            :         //
     709                 :            :         //      enter data
     710                 :            :         //
     711                 :            : 
     712         [ #  # ]:          0 :         if (bCommon)
     713         [ #  # ]:          0 :             pDoc->ApplyPattern(nCol,nRow,nTab,*pCellAttrs);         //! undo
     714                 :            : 
     715         [ #  # ]:          0 :         if (bSimple)
     716                 :            :         {
     717         [ #  # ]:          0 :             if (bCommon)
     718         [ #  # ]:          0 :                 AdjustRowHeight(nRow,nRow);
     719                 :            : 
     720         [ #  # ]:          0 :             EnterData(nCol,nRow,nTab,aString);
     721                 :            :         }
     722                 :            :         else
     723                 :            :         {
     724 [ #  # ][ #  # ]:          0 :             ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
     725 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
     726 [ #  # ][ #  # ]:          0 :                 pDoc->PutCell( nCol, nRow, *itr, new ScEditCell( pData, pDoc, NULL ) );
         [ #  # ][ #  # ]
     727                 :            : 
     728         [ #  # ]:          0 :             if ( bRecord )
     729                 :            :             {   //  because of ChangeTrack current first
     730         [ #  # ]:          0 :                 pDocSh->GetUndoManager()->AddUndoAction(
     731                 :            :                     new ScUndoEnterData( pDocSh, nCol, nRow, nTab, nPos, pTabs,
     732                 :            :                                         ppOldCells, NULL, NULL, aString,
     733 [ #  # ][ #  # ]:          0 :                                         pUndoData ) );
                 [ #  # ]
     734                 :            :             }
     735                 :            : 
     736         [ #  # ]:          0 :             HideAllCursors();
     737                 :            : 
     738         [ #  # ]:          0 :             AdjustRowHeight(nRow,nRow);
     739                 :            : 
     740         [ #  # ]:          0 :             itr = rMark.begin();
     741 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
     742 [ #  # ][ #  # ]:          0 :                 pDocSh->PostPaintCell( nCol, nRow, *itr );
     743                 :            : 
     744         [ #  # ]:          0 :             ShowAllCursors();
     745                 :            : 
     746         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
     747                 :            : 
     748                 :            :             // #i97876# Spreadsheet data changes are not notified
     749 [ #  # ][ #  # ]:          0 :             ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
     750 [ #  # ][ #  # ]:          0 :             if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
     751                 :            :             {
     752         [ #  # ]:          0 :                 ScRangeList aChangeRanges;
     753         [ #  # ]:          0 :                 itr = rMark.begin();
     754 [ #  # ][ #  # ]:          0 :                 for (; itr != itrEnd; ++itr)
                 [ #  # ]
     755                 :            :                 {
     756 [ #  # ][ #  # ]:          0 :                     aChangeRanges.Append( ScRange( nCol, nRow, *itr ) );
     757                 :            :                 }
     758 [ #  # ][ #  # ]:          0 :                 pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
         [ #  # ][ #  # ]
                 [ #  # ]
     759                 :            :             }
     760                 :            : 
     761         [ #  # ]:          0 :             aModificator.SetDocumentModified();
     762                 :            :         }
     763 [ #  # ][ #  # ]:          0 :         lcl_PostRepaintCondFormat( pDoc->GetCondFormat( nCol, nRow, nTab ), pDocSh );
     764                 :            : 
     765 [ #  # ][ #  # ]:          0 :         delete pCellAttrs;
     766 [ #  # ][ #  # ]:          0 :         delete pNewData;
         [ #  # ][ #  # ]
     767                 :            :     }
     768                 :            :     else
     769                 :            :     {
     770 [ #  # ][ #  # ]:          0 :         ErrorMessage(aTester.GetMessageId());
     771         [ #  # ]:          0 :         PaintArea( nCol, nRow, nCol, nRow );        // possibly the edit-engine is still painted there
     772         [ #  # ]:          0 :     }
     773                 :          0 : }
     774                 :            : 
     775                 :          0 : void ScViewFunc::EnterDataAtCursor( const String& rString )
     776                 :            : {
     777                 :          0 :     SCCOL nPosX = GetViewData()->GetCurX();
     778                 :          0 :     SCROW nPosY = GetViewData()->GetCurY();
     779                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
     780                 :            : 
     781                 :          0 :     EnterData( nPosX, nPosY, nTab, rString );
     782                 :          0 : }
     783                 :            : 
     784                 :          0 : void ScViewFunc::EnterMatrix( const String& rString, ::formula::FormulaGrammar::Grammar eGram )
     785                 :            : {
     786                 :          0 :     ScViewData* pData = GetViewData();
     787         [ #  # ]:          0 :     const ScMarkData& rMark = pData->GetMarkData();
     788 [ #  # ][ #  # ]:          0 :     if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
                 [ #  # ]
     789                 :            :     {
     790                 :            :         //  nothing marked -> temporarily calculate block
     791                 :            :         //  with size of result formula to get the size
     792                 :            : 
     793         [ #  # ]:          0 :         ScDocument* pDoc = pData->GetDocument();
     794                 :          0 :         SCCOL nCol = pData->GetCurX();
     795                 :          0 :         SCROW nRow = pData->GetCurY();
     796                 :          0 :         SCTAB nTab = pData->GetTabNo();
     797 [ #  # ][ #  # ]:          0 :         ScFormulaCell aFormCell( pDoc, ScAddress(nCol,nRow,nTab), rString, eGram, MM_FORMULA );
     798                 :            : 
     799                 :            :         SCSIZE nSizeX;
     800                 :            :         SCSIZE nSizeY;
     801         [ #  # ]:          0 :         aFormCell.GetResultDimensions( nSizeX, nSizeY );
     802 [ #  # ][ #  #  :          0 :         if ( nSizeX != 0 && nSizeY != 0 &&
             #  #  #  # ]
                 [ #  # ]
     803                 :          0 :              nCol+nSizeX-1 <= sal::static_int_cast<SCSIZE>(MAXCOL) &&
     804                 :          0 :              nRow+nSizeY-1 <= sal::static_int_cast<SCSIZE>(MAXROW) )
     805                 :            :         {
     806                 :            :             ScRange aResult( nCol, nRow, nTab,
     807                 :          0 :                              sal::static_int_cast<SCCOL>(nCol+nSizeX-1),
     808                 :          0 :                              sal::static_int_cast<SCROW>(nRow+nSizeY-1), nTab );
     809         [ #  # ]:          0 :             MarkRange( aResult, false );
     810         [ #  # ]:          0 :         }
     811                 :            :     }
     812                 :            : 
     813                 :          0 :     ScRange aRange;
     814 [ #  # ][ #  # ]:          0 :     if (pData->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
     815                 :            :     {
     816                 :          0 :         ScDocShell* pDocSh = pData->GetDocShell();
     817                 :          0 :         bool bSuccess = pDocSh->GetDocFunc().EnterMatrix(
     818 [ #  # ][ #  # ]:          0 :             aRange, &rMark, NULL, rString, false, false, EMPTY_STRING, eGram );
     819         [ #  # ]:          0 :         if (bSuccess)
     820         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
     821                 :            :     }
     822                 :            :     else
     823         [ #  # ]:          0 :         ErrorMessage(STR_NOMULTISELECT);
     824                 :          0 : }
     825                 :            : 
     826                 :       1110 : sal_uInt8 ScViewFunc::GetSelectionScriptType()
     827                 :            : {
     828                 :       1110 :     sal_uInt8 nScript = 0;
     829                 :            : 
     830                 :       1110 :     ScDocument* pDoc = GetViewData()->GetDocument();
     831                 :       1110 :     const ScMarkData& rMark = GetViewData()->GetMarkData();
     832 [ +  + ][ +  + ]:       1110 :     if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
                 [ +  - ]
     833                 :            :     {
     834                 :            :         // no selection -> cursor
     835                 :            : 
     836                 :       1102 :         nScript = pDoc->GetScriptType( GetViewData()->GetCurX(),
     837                 :       2204 :                             GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
     838                 :            :     }
     839                 :            :     else
     840                 :            :     {
     841         [ +  - ]:          8 :         ScRangeList aRanges;
     842         [ +  - ]:          8 :         rMark.FillRangeListWithMarks( &aRanges, false );
     843         [ +  - ]:          8 :         size_t nCount = aRanges.size();
     844         [ +  + ]:         16 :         for ( size_t i=0; i < nCount; i++ )
     845                 :            :         {
     846         [ +  - ]:          8 :             ScRange aRange = *aRanges[i];
     847         [ +  - ]:          8 :             ScCellIterator aIter( pDoc, aRange );
     848         [ +  - ]:          8 :             ScBaseCell* pCell = aIter.GetFirst();
     849         [ +  + ]:         88 :             while ( pCell )
     850                 :            :             {
     851         [ +  - ]:         80 :                 nScript |= pDoc->GetScriptType( aIter.GetCol(), aIter.GetRow(), aIter.GetTab(), pCell );
     852         [ +  - ]:         80 :                 pCell = aIter.GetNext();
     853                 :            :             }
     854         [ +  - ]:          8 :         }
     855                 :            :     }
     856                 :            : 
     857         [ +  + ]:       1110 :     if (nScript == 0)
     858                 :        959 :         nScript = ScGlobal::GetDefaultScriptType();
     859                 :            : 
     860                 :       1110 :     return nScript;
     861                 :            : }
     862                 :            : 
     863                 :       6180 : const ScPatternAttr* ScViewFunc::GetSelectionPattern()
     864                 :            : {
     865                 :            :     // Don't use UnmarkFiltered in slot state functions, for performance reasons.
     866                 :            :     // The displayed state is always that of the whole selection including filtered rows.
     867                 :            : 
     868                 :       6180 :     const ScMarkData& rMark = GetViewData()->GetMarkData();
     869                 :       6180 :     ScDocument* pDoc = GetViewData()->GetDocument();
     870 [ +  + ][ +  + ]:       6180 :     if ( rMark.IsMarked() || rMark.IsMultiMarked() )
                 [ +  - ]
     871                 :            :     {
     872                 :            :         //  MarkToMulti is no longer necessary for pDoc->GetSelectionPattern
     873                 :          8 :         const ScPatternAttr* pAttr = pDoc->GetSelectionPattern( rMark );
     874                 :          8 :         return pAttr;
     875                 :            :     }
     876                 :            :     else
     877                 :            :     {
     878                 :       6172 :         SCCOL  nCol = GetViewData()->GetCurX();
     879                 :       6172 :         SCROW  nRow = GetViewData()->GetCurY();
     880                 :       6172 :         SCTAB  nTab = GetViewData()->GetTabNo();
     881                 :            : 
     882         [ +  - ]:       6172 :         ScMarkData aTempMark( rMark );      // copy sheet selection
     883         [ +  - ]:       6172 :         aTempMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
     884         [ +  - ]:       6172 :         const ScPatternAttr* pAttr = pDoc->GetSelectionPattern( aTempMark );
     885         [ +  - ]:       6180 :         return pAttr;
     886                 :            :     }
     887                 :            : }
     888                 :            : 
     889                 :          0 : void ScViewFunc::GetSelectionFrame( SvxBoxItem&     rLineOuter,
     890                 :            :                                     SvxBoxInfoItem& rLineInner )
     891                 :            : {
     892                 :          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
     893                 :          0 :     const ScMarkData& rMark = GetViewData()->GetMarkData();
     894                 :            : 
     895 [ #  # ][ #  # ]:          0 :     if ( rMark.IsMarked() || rMark.IsMultiMarked() )
                 [ #  # ]
     896                 :            :     {
     897         [ #  # ]:          0 :         if ( rMark.IsMultiMarked() )
     898                 :            :         {
     899         [ #  # ]:          0 :             ScMarkData aNewMark( rMark );   // use local copy for MarkToSimple
     900         [ #  # ]:          0 :             aNewMark.MarkToSimple();        // simple block is needed for GetSelectionFrame
     901 [ #  # ][ #  # ]:          0 :             pDoc->GetSelectionFrame( aNewMark, rLineOuter, rLineInner );
     902                 :            :         }
     903                 :            :         else
     904                 :          0 :             pDoc->GetSelectionFrame( rMark, rLineOuter, rLineInner );
     905                 :            :     }
     906                 :            :     else
     907                 :            :     {
     908                 :            :         const ScPatternAttr* pAttrs =
     909                 :          0 :                     pDoc->GetPattern( GetViewData()->GetCurX(),
     910                 :            :                                       GetViewData()->GetCurY(),
     911                 :          0 :                                       GetViewData()->GetTabNo() );
     912                 :            : 
     913                 :          0 :         rLineOuter = (const SvxBoxItem&)    (pAttrs->GetItem( ATTR_BORDER ));
     914                 :          0 :         rLineInner = (const SvxBoxInfoItem&)(pAttrs->GetItem( ATTR_BORDER_INNER ));
     915                 :          0 :         rLineInner.SetTable(false);
     916                 :          0 :         rLineInner.SetDist(sal_True);
     917                 :          0 :         rLineInner.SetMinDist(false);
     918                 :            :     }
     919                 :          0 : }
     920                 :            : 
     921                 :            : //
     922                 :            : //  apply attribute - undo OK
     923                 :            : //
     924                 :            : //  complete set ( ATTR_STARTINDEX, ATTR_ENDINDEX )
     925                 :            : //
     926                 :            : 
     927                 :          0 : void ScViewFunc::ApplyAttributes( const SfxItemSet* pDialogSet,
     928                 :            :                                   const SfxItemSet* pOldSet,
     929                 :            :                                   sal_Bool              bRecord )
     930                 :            : {
     931                 :            :     // not editable because of matrix only? attribute OK nonetheless
     932                 :            :     bool bOnlyNotBecauseOfMatrix;
     933 [ #  # ][ #  # ]:          0 :     if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
         [ #  # ][ #  # ]
     934                 :            :     {
     935         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
     936                 :          0 :         return;
     937                 :            :     }
     938                 :            : 
     939 [ #  # ][ #  # ]:          0 :     ScPatternAttr aOldAttrs( new SfxItemSet(*pOldSet) );
                 [ #  # ]
     940 [ #  # ][ #  # ]:          0 :     ScPatternAttr aNewAttrs( new SfxItemSet(*pDialogSet) );
                 [ #  # ]
     941         [ #  # ]:          0 :     aNewAttrs.DeleteUnchanged( &aOldAttrs );
     942                 :            : 
     943 [ #  # ][ #  # ]:          0 :     if ( pDialogSet->GetItemState( ATTR_VALUE_FORMAT ) == SFX_ITEM_SET )
     944                 :            :     {   // don't reset to default SYSTEM GENERAL if not intended
     945                 :            :         sal_uInt32 nOldFormat =
     946         [ #  # ]:          0 :             ((const SfxUInt32Item&)pOldSet->Get( ATTR_VALUE_FORMAT )).GetValue();
     947                 :            :         sal_uInt32 nNewFormat =
     948         [ #  # ]:          0 :             ((const SfxUInt32Item&)pDialogSet->Get( ATTR_VALUE_FORMAT )).GetValue();
     949         [ #  # ]:          0 :         if ( nNewFormat != nOldFormat )
     950                 :            :         {
     951                 :            :             SvNumberFormatter* pFormatter =
     952 [ #  # ][ #  # ]:          0 :                 GetViewData()->GetDocument()->GetFormatTable();
     953         [ #  # ]:          0 :             const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat );
     954                 :            :             LanguageType eOldLang =
     955         [ #  # ]:          0 :                 pOldEntry ? pOldEntry->GetLanguage() : LANGUAGE_DONTKNOW;
     956         [ #  # ]:          0 :             const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
     957                 :            :             LanguageType eNewLang =
     958         [ #  # ]:          0 :                 pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
     959         [ #  # ]:          0 :             if ( eNewLang != eOldLang )
     960                 :            :             {
     961                 :          0 :                 aNewAttrs.GetItemSet().Put(
     962   [ #  #  #  # ]:          0 :                     SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
                 [ #  # ]
     963                 :            : 
     964                 :            :                 //  only the language has changed -> do not touch numberformat-attribute
     965                 :          0 :                 sal_uInt32 nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
     966 [ #  # ][ #  # ]:          0 :                 if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
     967                 :            :                      nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
     968         [ #  # ]:          0 :                     aNewAttrs.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
     969                 :            :             }
     970                 :            :         }
     971                 :            :     }
     972                 :            : 
     973         [ #  # ]:          0 :     const SvxBoxItem*     pOldOuter = (const SvxBoxItem*)     &pOldSet->Get( ATTR_BORDER );
     974         [ #  # ]:          0 :     const SvxBoxItem*     pNewOuter = (const SvxBoxItem*)     &pDialogSet->Get( ATTR_BORDER );
     975         [ #  # ]:          0 :     const SvxBoxInfoItem* pOldInner = (const SvxBoxInfoItem*) &pOldSet->Get( ATTR_BORDER_INNER );
     976         [ #  # ]:          0 :     const SvxBoxInfoItem* pNewInner = (const SvxBoxInfoItem*) &pDialogSet->Get( ATTR_BORDER_INNER );
     977                 :          0 :     SfxItemSet&           rNewSet   = aNewAttrs.GetItemSet();
     978                 :          0 :     SfxItemPool*          pNewPool  = rNewSet.GetPool();
     979                 :            : 
     980         [ #  # ]:          0 :     pNewPool->Put( *pNewOuter );        // don't delete yet
     981         [ #  # ]:          0 :     pNewPool->Put( *pNewInner );
     982         [ #  # ]:          0 :     rNewSet.ClearItem( ATTR_BORDER );
     983         [ #  # ]:          0 :     rNewSet.ClearItem( ATTR_BORDER_INNER );
     984                 :            : 
     985                 :            :     /*
     986                 :            :      * establish whether border attribute is to be set:
     987                 :            :      * 1. new != old
     988                 :            :      * 2. is one of the borders not-DontCare (since 238.f: IsxxValid())
     989                 :            :      *
     990                 :            :      */
     991                 :            : 
     992         [ #  # ]:          0 :     sal_Bool bFrame =    (pDialogSet->GetItemState( ATTR_BORDER ) != SFX_ITEM_DEFAULT)
     993 [ #  # ][ #  # ]:          0 :                   || (pDialogSet->GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_DEFAULT);
                 [ #  # ]
     994                 :            : 
     995 [ #  # ][ #  # ]:          0 :     if ( pNewOuter==pOldOuter && pNewInner==pOldInner )
     996                 :          0 :         bFrame = false;
     997                 :            : 
     998                 :            :     //  this should be intercepted by the pool: ?!??!??
     999                 :            : 
    1000 [ #  # ][ #  # ]:          0 :     if ( bFrame && pNewOuter && pNewInner )
                 [ #  # ]
    1001 [ #  # ][ #  # ]:          0 :         if ( *pNewOuter == *pOldOuter && *pNewInner == *pOldInner )
         [ #  # ][ #  # ]
                 [ #  # ]
    1002                 :          0 :             bFrame = false;
    1003                 :            : 
    1004         [ #  # ]:          0 :     if ( pNewInner )
    1005                 :            :     {
    1006                 :            :         bFrame =   bFrame
    1007                 :          0 :                 && (   pNewInner->IsValid(VALID_LEFT)
    1008                 :          0 :                     || pNewInner->IsValid(VALID_RIGHT)
    1009                 :          0 :                     || pNewInner->IsValid(VALID_TOP)
    1010                 :          0 :                     || pNewInner->IsValid(VALID_BOTTOM)
    1011                 :          0 :                     || pNewInner->IsValid(VALID_HORI)
    1012   [ #  #  #  #  :          0 :                     || pNewInner->IsValid(VALID_VERT) );
          #  #  #  #  #  
                #  #  # ]
                 [ #  # ]
    1013                 :            :     }
    1014                 :            :     else
    1015                 :          0 :         bFrame = false;
    1016                 :            : 
    1017         [ #  # ]:          0 :     if (!bFrame)
    1018         [ #  # ]:          0 :         ApplySelectionPattern( aNewAttrs, bRecord );                // standard only
    1019                 :            :     else
    1020                 :            :     {
    1021                 :            :         // if new items are default-items, overwrite the old items:
    1022                 :            : 
    1023                 :          0 :         sal_Bool bDefNewOuter = ( SFX_ITEMS_STATICDEFAULT == pNewOuter->GetKind() );
    1024                 :          0 :         sal_Bool bDefNewInner = ( SFX_ITEMS_STATICDEFAULT == pNewInner->GetKind() );
    1025                 :            : 
    1026                 :            :         ApplyPatternLines( aNewAttrs,
    1027                 :            :                            bDefNewOuter ? pOldOuter : pNewOuter,
    1028                 :            :                            bDefNewInner ? pOldInner : pNewInner,
    1029 [ #  # ][ #  # ]:          0 :                            bRecord );
                 [ #  # ]
    1030                 :            :     }
    1031                 :            : 
    1032         [ #  # ]:          0 :     pNewPool->Remove( *pNewOuter );         // release
    1033         [ #  # ]:          0 :     pNewPool->Remove( *pNewInner );
    1034                 :            : 
    1035                 :            :     //  adjust height
    1036 [ #  # ][ #  # ]:          0 :     AdjustBlockHeight();
                 [ #  # ]
    1037                 :            : 
    1038                 :            :     // CellContentChanged is called in ApplySelectionPattern / ApplyPatternLines
    1039                 :            : }
    1040                 :            : 
    1041                 :          0 : void ScViewFunc::ApplyAttr( const SfxPoolItem& rAttrItem )
    1042                 :            : {
    1043                 :            :     // not editable because of matrix only? attribute OK nonetheless
    1044                 :            :     bool bOnlyNotBecauseOfMatrix;
    1045 [ #  # ][ #  # ]:          0 :     if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
         [ #  # ][ #  # ]
    1046                 :            :     {
    1047         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    1048                 :          0 :         return;
    1049                 :            :     }
    1050                 :            : 
    1051 [ #  # ][ #  # ]:          0 :     ScPatternAttr aNewAttrs( new SfxItemSet( *GetViewData()->GetDocument()->GetPool(),
    1052 [ #  # ][ #  # ]:          0 :                                             ATTR_PATTERN_START, ATTR_PATTERN_END ) );
                 [ #  # ]
    1053                 :            : 
    1054         [ #  # ]:          0 :     aNewAttrs.GetItemSet().Put( rAttrItem );
    1055                 :            :     //  if justify is set (with Buttons), always indentation 0
    1056         [ #  # ]:          0 :     if ( rAttrItem.Which() == ATTR_HOR_JUSTIFY )
    1057 [ #  # ][ #  # ]:          0 :         aNewAttrs.GetItemSet().Put( SfxUInt16Item( ATTR_INDENT, 0 ) );
                 [ #  # ]
    1058         [ #  # ]:          0 :     ApplySelectionPattern( aNewAttrs );
    1059                 :            : 
    1060 [ #  # ][ #  # ]:          0 :     AdjustBlockHeight();
    1061                 :            : 
    1062                 :            :     // CellContentChanged is called in ApplySelectionPattern
    1063                 :            : }
    1064                 :            : 
    1065                 :            : 
    1066                 :            : //  patterns and borders
    1067                 :            : 
    1068                 :          0 : void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem* pNewOuter,
    1069                 :            :                                     const SvxBoxInfoItem* pNewInner, sal_Bool bRecord )
    1070                 :            : {
    1071         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
    1072 [ #  # ][ #  # ]:          0 :     ScMarkData aFuncMark( GetViewData()->GetMarkData() );       // local copy for UnmarkFiltered
    1073         [ #  # ]:          0 :     ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
    1074 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    1075                 :          0 :         bRecord = false;
    1076                 :            : 
    1077                 :          0 :     ScRange aMarkRange;
    1078         [ #  # ]:          0 :     aFuncMark.MarkToSimple();
    1079                 :          0 :     sal_Bool bMulti = aFuncMark.IsMultiMarked();
    1080         [ #  # ]:          0 :     if (bMulti)
    1081         [ #  # ]:          0 :         aFuncMark.GetMultiMarkArea( aMarkRange );
    1082         [ #  # ]:          0 :     else if (aFuncMark.IsMarked())
    1083         [ #  # ]:          0 :         aFuncMark.GetMarkArea( aMarkRange );
    1084                 :            :     else
    1085                 :            :     {
    1086                 :          0 :         aMarkRange = ScRange( GetViewData()->GetCurX(),
    1087                 :          0 :                             GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
    1088         [ #  # ]:          0 :         DoneBlockMode();
    1089         [ #  # ]:          0 :         InitOwnBlockMode();
    1090         [ #  # ]:          0 :         aFuncMark.SetMarkArea(aMarkRange);
    1091         [ #  # ]:          0 :         MarkDataChanged();
    1092                 :            :     }
    1093                 :            : 
    1094                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1095                 :            : 
    1096         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
    1097                 :            : 
    1098         [ #  # ]:          0 :     if (bRecord)
    1099                 :            :     {
    1100 [ #  # ][ #  # ]:          0 :         ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1101                 :          0 :         SCTAB nStartTab = aMarkRange.aStart.Tab();
    1102         [ #  # ]:          0 :         SCTAB nTabCount = pDoc->GetTableCount();
    1103         [ #  # ]:          0 :         pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
    1104 [ #  # ][ #  # ]:          0 :         ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end();
    1105 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1106 [ #  # ][ #  # ]:          0 :             if (*itr != nStartTab)
    1107 [ #  # ][ #  # ]:          0 :                 pUndoDoc->AddUndoTab( *itr, *itr );
                 [ #  # ]
    1108                 :            : 
    1109                 :          0 :         ScRange aCopyRange = aMarkRange;
    1110                 :          0 :         aCopyRange.aStart.SetTab(0);
    1111                 :          0 :         aCopyRange.aEnd.SetTab(nTabCount-1);
    1112         [ #  # ]:          0 :         pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pUndoDoc, &aFuncMark );
    1113                 :            : 
    1114         [ #  # ]:          0 :         pDocSh->GetUndoManager()->AddUndoAction(
    1115                 :            :             new ScUndoSelectionAttr(
    1116                 :            :             pDocSh, aFuncMark,
    1117                 :          0 :             aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), aMarkRange.aStart.Tab(),
    1118                 :          0 :             aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), aMarkRange.aEnd.Tab(),
    1119 [ #  # ][ #  # ]:          0 :             pUndoDoc, bMulti, &rAttr, pNewOuter, pNewInner ) );
                 [ #  # ]
    1120                 :            :     }
    1121                 :            : 
    1122                 :          0 :     sal_uInt16 nExt = SC_PF_TESTMERGE;
    1123         [ #  # ]:          0 :     pDocSh->UpdatePaintExt( nExt, aMarkRange ); // content before the change
    1124                 :            : 
    1125         [ #  # ]:          0 :     pDoc->ApplySelectionFrame( aFuncMark, pNewOuter, pNewInner );
    1126                 :            : 
    1127         [ #  # ]:          0 :     pDocSh->UpdatePaintExt( nExt, aMarkRange ); // content after the change
    1128                 :            : 
    1129         [ #  # ]:          0 :     aFuncMark.MarkToMulti();
    1130         [ #  # ]:          0 :     pDoc->ApplySelectionPattern( rAttr, aFuncMark );
    1131                 :            : 
    1132 [ #  # ][ #  # ]:          0 :     pDocSh->PostPaint( aMarkRange, PAINT_GRID, nExt );
                 [ #  # ]
    1133         [ #  # ]:          0 :     pDocSh->UpdateOle(GetViewData());
    1134         [ #  # ]:          0 :     aModificator.SetDocumentModified();
    1135         [ #  # ]:          0 :     CellContentChanged();
    1136                 :            : 
    1137 [ #  # ][ #  # ]:          0 :     StartFormatArea();
                 [ #  # ]
    1138                 :          0 : }
    1139                 :            : 
    1140                 :            : //  pattern only
    1141                 :            : 
    1142                 :          0 : void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr,
    1143                 :            :                                             sal_Bool bRecord, sal_Bool bCursorOnly )
    1144                 :            : {
    1145                 :          0 :     ScViewData* pViewData   = GetViewData();
    1146                 :          0 :     ScDocShell* pDocSh      = pViewData->GetDocShell();
    1147                 :          0 :     ScDocument* pDoc        = pDocSh->GetDocument();
    1148 [ #  # ][ #  # ]:          0 :     ScMarkData aFuncMark( pViewData->GetMarkData() );       // local copy for UnmarkFiltered
    1149         [ #  # ]:          0 :     ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
    1150                 :            : 
    1151 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    1152                 :          0 :         bRecord = false;
    1153                 :            : 
    1154                 :            :     //  State from old ItemSet doesn't matter for paint flags, as any change will be
    1155                 :            :     //  from SFX_ITEM_SET in the new ItemSet (default is ignored in ApplyPattern).
    1156                 :            :     //  New alignment is checked (check in PostPaint isn't enough) in case a right
    1157                 :            :     //  alignment is changed to left.
    1158                 :          0 :     const SfxItemSet& rNewSet = rAttr.GetItemSet();
    1159         [ #  # ]:          0 :     sal_Bool bSetLines = rNewSet.GetItemState( ATTR_BORDER, sal_True ) == SFX_ITEM_SET ||
    1160 [ #  # ][ #  # ]:          0 :                      rNewSet.GetItemState( ATTR_SHADOW, sal_True ) == SFX_ITEM_SET;
                 [ #  # ]
    1161         [ #  # ]:          0 :     sal_Bool bSetAlign = rNewSet.GetItemState( ATTR_HOR_JUSTIFY, sal_True ) == SFX_ITEM_SET;
    1162                 :            : 
    1163                 :          0 :     sal_uInt16 nExtFlags = 0;
    1164         [ #  # ]:          0 :     if ( bSetLines )
    1165                 :          0 :         nExtFlags |= SC_PF_LINES;
    1166         [ #  # ]:          0 :     if ( bSetAlign )
    1167                 :          0 :         nExtFlags |= SC_PF_WHOLEROWS;
    1168                 :            : 
    1169         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
    1170                 :            : 
    1171                 :          0 :     sal_Bool bMulti = aFuncMark.IsMultiMarked();
    1172         [ #  # ]:          0 :     aFuncMark.MarkToMulti();
    1173 [ #  # ][ #  # ]:          0 :     sal_Bool bOnlyTab = (!aFuncMark.IsMultiMarked() && !bCursorOnly && aFuncMark.GetSelectCount() > 1);
         [ #  # ][ #  # ]
    1174         [ #  # ]:          0 :     if (bOnlyTab)
    1175                 :            :     {
    1176                 :          0 :         SCCOL nCol = pViewData->GetCurX();
    1177                 :          0 :         SCROW nRow = pViewData->GetCurY();
    1178                 :          0 :         SCTAB nTab = pViewData->GetTabNo();
    1179         [ #  # ]:          0 :         aFuncMark.SetMarkArea(ScRange(nCol,nRow,nTab));
    1180         [ #  # ]:          0 :         aFuncMark.MarkToMulti();
    1181                 :            :     }
    1182                 :            : 
    1183         [ #  # ]:          0 :     ScRangeList aChangeRanges;
    1184                 :            : 
    1185 [ #  # ][ #  # ]:          0 :     if (aFuncMark.IsMultiMarked() && !bCursorOnly)
                 [ #  # ]
    1186                 :            :     {
    1187                 :          0 :         ScRange aMarkRange;
    1188         [ #  # ]:          0 :         aFuncMark.GetMultiMarkArea( aMarkRange );
    1189         [ #  # ]:          0 :         SCTAB nTabCount = pDoc->GetTableCount();
    1190 [ #  # ][ #  # ]:          0 :         ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end();
    1191 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1192                 :            :         {
    1193                 :          0 :             ScRange aChangeRange( aMarkRange );
    1194         [ #  # ]:          0 :             aChangeRange.aStart.SetTab( *itr );
    1195         [ #  # ]:          0 :             aChangeRange.aEnd.SetTab( *itr );
    1196         [ #  # ]:          0 :             aChangeRanges.Append( aChangeRange );
    1197                 :            :         }
    1198                 :            : 
    1199                 :          0 :         SCCOL nStartCol = aMarkRange.aStart.Col();
    1200                 :          0 :         SCROW nStartRow = aMarkRange.aStart.Row();
    1201                 :          0 :         SCTAB nStartTab = aMarkRange.aStart.Tab();
    1202                 :          0 :         SCCOL nEndCol = aMarkRange.aEnd.Col();
    1203                 :          0 :         SCROW nEndRow = aMarkRange.aEnd.Row();
    1204                 :          0 :         SCTAB nEndTab = aMarkRange.aEnd.Tab();
    1205                 :            : 
    1206                 :          0 :         ScUndoSelectionAttr* pUndoAttr = NULL;
    1207                 :          0 :         ScEditDataArray* pEditDataArray = NULL;
    1208         [ #  # ]:          0 :         if (bRecord)
    1209                 :            :         {
    1210                 :          0 :             ScRange aCopyRange = aMarkRange;
    1211                 :          0 :             aCopyRange.aStart.SetTab(0);
    1212                 :          0 :             aCopyRange.aEnd.SetTab(nTabCount-1);
    1213                 :            : 
    1214 [ #  # ][ #  # ]:          0 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1215         [ #  # ]:          0 :             pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
    1216         [ #  # ]:          0 :             itr = aFuncMark.begin();
    1217 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1218 [ #  # ][ #  # ]:          0 :                 if (*itr != nStartTab)
    1219 [ #  # ][ #  # ]:          0 :                     pUndoDoc->AddUndoTab( *itr, *itr );
                 [ #  # ]
    1220         [ #  # ]:          0 :             pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pUndoDoc, &aFuncMark );
    1221                 :            : 
    1222         [ #  # ]:          0 :             aFuncMark.MarkToMulti();
    1223                 :            : 
    1224                 :            :             pUndoAttr = new ScUndoSelectionAttr(
    1225                 :            :                 pDocSh, aFuncMark, nStartCol, nStartRow, nStartTab,
    1226 [ #  # ][ #  # ]:          0 :                 nEndCol, nEndRow, nEndTab, pUndoDoc, bMulti, &rAttr );
    1227 [ #  # ][ #  # ]:          0 :             pDocSh->GetUndoManager()->AddUndoAction(pUndoAttr);
    1228         [ #  # ]:          0 :             pEditDataArray = pUndoAttr->GetDataArray();
    1229                 :            :         }
    1230                 :            : 
    1231         [ #  # ]:          0 :         pDoc->ApplySelectionPattern( rAttr, aFuncMark, pEditDataArray );
    1232                 :            : 
    1233                 :            :         pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
    1234                 :            :                            nEndCol,   nEndRow,   nEndTab,
    1235         [ #  # ]:          0 :                            PAINT_GRID, nExtFlags | SC_PF_TESTMERGE );
    1236         [ #  # ]:          0 :         pDocSh->UpdateOle(GetViewData());
    1237         [ #  # ]:          0 :         aModificator.SetDocumentModified();
    1238         [ #  # ]:          0 :         CellContentChanged();
    1239                 :            :     }
    1240                 :            :     else                            // single cell - simpler undo
    1241                 :            :     {
    1242                 :          0 :         SCCOL nCol = pViewData->GetCurX();
    1243                 :          0 :         SCROW nRow = pViewData->GetCurY();
    1244                 :          0 :         SCTAB nTab = pViewData->GetTabNo();
    1245                 :            : 
    1246                 :            :         ScBaseCell* pCell;
    1247         [ #  # ]:          0 :         pDoc->GetCell(nCol, nRow, nTab, pCell);
    1248                 :          0 :         EditTextObject* pOldEditData = NULL;
    1249                 :          0 :         EditTextObject* pNewEditData = NULL;
    1250 [ #  # ][ #  # ]:          0 :         if (pCell && pCell->GetCellType() == CELLTYPE_EDIT)
                 [ #  # ]
    1251                 :            :         {
    1252                 :          0 :             ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
    1253         [ #  # ]:          0 :             pOldEditData = pEditCell->GetData()->Clone();
    1254         [ #  # ]:          0 :             pEditCell->RemoveCharAttribs(rAttr);
    1255         [ #  # ]:          0 :             pNewEditData = pEditCell->GetData()->Clone();
    1256                 :            :         }
    1257                 :            : 
    1258         [ #  # ]:          0 :         aChangeRanges.Append( ScRange( nCol, nRow, nTab ) );
    1259 [ #  # ][ #  # ]:          0 :         ScPatternAttr* pOldPat = new ScPatternAttr(*pDoc->GetPattern( nCol, nRow, nTab ));
                 [ #  # ]
    1260                 :            : 
    1261         [ #  # ]:          0 :         pDoc->ApplyPattern( nCol, nRow, nTab, rAttr );
    1262                 :            : 
    1263         [ #  # ]:          0 :         const ScPatternAttr* pNewPat = pDoc->GetPattern( nCol, nRow, nTab );
    1264                 :            : 
    1265         [ #  # ]:          0 :         if (bRecord)
    1266                 :            :         {
    1267                 :            :             ScUndoCursorAttr* pUndo = new ScUndoCursorAttr(
    1268 [ #  # ][ #  # ]:          0 :                 pDocSh, nCol, nRow, nTab, pOldPat, pNewPat, &rAttr, false );
    1269         [ #  # ]:          0 :             pUndo->SetEditData(pOldEditData, pNewEditData);
    1270 [ #  # ][ #  # ]:          0 :             pDocSh->GetUndoManager()->AddUndoAction(pUndo);
    1271                 :            :         }
    1272 [ #  # ][ #  # ]:          0 :         delete pOldPat;     // is copied in undo (Pool)
    1273                 :            : 
    1274         [ #  # ]:          0 :         pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, nExtFlags | SC_PF_TESTMERGE );
    1275         [ #  # ]:          0 :         pDocSh->UpdateOle(GetViewData());
    1276         [ #  # ]:          0 :         aModificator.SetDocumentModified();
    1277         [ #  # ]:          0 :         CellContentChanged();
    1278                 :            :     }
    1279                 :            : 
    1280                 :            :     // #i97876# Spreadsheet data changes are not notified
    1281 [ #  # ][ #  # ]:          0 :     ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
    1282 [ #  # ][ #  # ]:          0 :     if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
    1283                 :            :     {
    1284         [ #  # ]:          0 :         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aProperties;
    1285                 :          0 :         sal_Int32 nCount = 0;
    1286         [ #  # ]:          0 :         const SfxItemPropertyMap& rMap = ScCellObj::GetCellPropertyMap();
    1287         [ #  # ]:          0 :         PropertyEntryVector_t aPropVector = rMap.getPropertyEntries();
    1288         [ #  # ]:          0 :         for ( sal_uInt16 nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; ++nWhich )
    1289                 :            :         {
    1290                 :          0 :             const SfxPoolItem* pItem = 0;
    1291 [ #  # ][ #  # ]:          0 :             if ( rNewSet.GetItemState( nWhich, sal_True, &pItem ) == SFX_ITEM_SET && pItem )
         [ #  # ][ #  # ]
    1292                 :            :             {
    1293         [ #  # ]:          0 :                 PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
    1294 [ #  # ][ #  # ]:          0 :                 while ( aIt != aPropVector.end())
    1295                 :            :                 {
    1296         [ #  # ]:          0 :                     if ( aIt->nWID == nWhich )
    1297                 :            :                     {
    1298                 :          0 :                         ::com::sun::star::uno::Any aVal;
    1299         [ #  # ]:          0 :                         pItem->QueryValue( aVal, aIt->nMemberId );
    1300         [ #  # ]:          0 :                         aProperties.realloc( nCount + 1 );
    1301         [ #  # ]:          0 :                         aProperties[ nCount ].Name = aIt->sName;
    1302 [ #  # ][ #  # ]:          0 :                         aProperties[ nCount ].Value <<= aVal;
    1303                 :          0 :                         ++nCount;
    1304                 :            :                     }
    1305                 :          0 :                     ++aIt;
    1306                 :            :                 }
    1307                 :            :             }
    1308                 :            :         }
    1309 [ #  # ][ #  # ]:          0 :         pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "attribute" ) ), aChangeRanges, aProperties );
                 [ #  # ]
    1310                 :            :     }
    1311                 :            : 
    1312 [ #  # ][ #  # ]:          0 :     StartFormatArea();
         [ #  # ][ #  # ]
    1313                 :          0 : }
    1314                 :            : 
    1315                 :          0 : void ScViewFunc::ApplyUserItemSet( const SfxItemSet& rItemSet )
    1316                 :            : {
    1317                 :            :     //  ItemSet from UI, may have different pool
    1318                 :            : 
    1319                 :            :     bool bOnlyNotBecauseOfMatrix;
    1320 [ #  # ][ #  # ]:          0 :     if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
         [ #  # ][ #  # ]
    1321                 :            :     {
    1322         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    1323                 :          0 :         return;
    1324                 :            :     }
    1325                 :            : 
    1326 [ #  # ][ #  # ]:          0 :     ScPatternAttr aNewAttrs( GetViewData()->GetDocument()->GetPool() );
                 [ #  # ]
    1327                 :          0 :     SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
    1328         [ #  # ]:          0 :     rNewSet.Put( rItemSet, false );
    1329         [ #  # ]:          0 :     ApplySelectionPattern( aNewAttrs );
    1330                 :            : 
    1331 [ #  # ][ #  # ]:          0 :     AdjustBlockHeight();
    1332                 :            : }
    1333                 :            : 
    1334                 :        120 : const SfxStyleSheet* ScViewFunc::GetStyleSheetFromMarked()
    1335                 :            : {
    1336                 :            :     // Don't use UnmarkFiltered in slot state functions, for performance reasons.
    1337                 :            :     // The displayed state is always that of the whole selection including filtered rows.
    1338                 :            : 
    1339                 :        120 :     const ScStyleSheet* pSheet      = NULL;
    1340                 :        120 :     ScViewData*         pViewData   = GetViewData();
    1341                 :        120 :     ScDocument*         pDoc        = pViewData->GetDocument();
    1342                 :        120 :     ScMarkData&         rMark       = pViewData->GetMarkData();
    1343                 :            : 
    1344 [ +  + ][ +  + ]:        120 :     if ( rMark.IsMarked() || rMark.IsMultiMarked() )
                 [ +  - ]
    1345                 :          8 :         pSheet = pDoc->GetSelectionStyle( rMark );                  // MarkToMulti isn't necessary
    1346                 :            :     else
    1347                 :        112 :         pSheet = pDoc->GetStyle( pViewData->GetCurX(),
    1348                 :            :                                  pViewData->GetCurY(),
    1349                 :        224 :                                  pViewData->GetTabNo() );
    1350                 :            : 
    1351                 :        120 :     return pSheet;
    1352                 :            : }
    1353                 :            : 
    1354                 :          0 : void ScViewFunc::SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet, sal_Bool bRecord )
    1355                 :            : {
    1356                 :            :     // not editable because of matrix only? attribute OK nonetheless
    1357                 :            :     bool bOnlyNotBecauseOfMatrix;
    1358 [ #  # ][ #  # ]:          0 :     if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
         [ #  # ][ #  # ]
    1359                 :            :     {
    1360         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    1361                 :            :         return;
    1362                 :            :     }
    1363                 :            : 
    1364         [ #  # ]:          0 :     if ( !pStyleSheet) return;
    1365                 :            :     // -------------------------------------------------------------------
    1366                 :            : 
    1367                 :          0 :     ScViewData* pViewData   = GetViewData();
    1368                 :          0 :     ScDocShell* pDocSh      = pViewData->GetDocShell();
    1369                 :          0 :     ScDocument* pDoc        = pDocSh->GetDocument();
    1370 [ #  # ][ #  # ]:          0 :     ScMarkData aFuncMark( pViewData->GetMarkData() );       // local copy for UnmarkFiltered
    1371         [ #  # ]:          0 :     ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
    1372         [ #  # ]:          0 :     SCTAB nTabCount     = pDoc->GetTableCount();
    1373 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    1374                 :          0 :         bRecord = false;
    1375                 :            : 
    1376         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
    1377                 :            : 
    1378 [ #  # ][ #  # ]:          0 :     if ( aFuncMark.IsMarked() || aFuncMark.IsMultiMarked() )
                 [ #  # ]
    1379                 :            :     {
    1380                 :          0 :         ScRange aMarkRange;
    1381         [ #  # ]:          0 :         aFuncMark.MarkToMulti();
    1382         [ #  # ]:          0 :         aFuncMark.GetMultiMarkArea( aMarkRange );
    1383                 :            : 
    1384         [ #  # ]:          0 :         if ( bRecord )
    1385                 :            :         {
    1386                 :          0 :             SCTAB nTab = pViewData->GetTabNo();
    1387 [ #  # ][ #  # ]:          0 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1388         [ #  # ]:          0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab );
    1389 [ #  # ][ #  # ]:          0 :             ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end();
    1390 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1391 [ #  # ][ #  # ]:          0 :                 if (*itr != nTab)
    1392 [ #  # ][ #  # ]:          0 :                     pUndoDoc->AddUndoTab( *itr, *itr );
                 [ #  # ]
    1393                 :            : 
    1394                 :          0 :             ScRange aCopyRange = aMarkRange;
    1395                 :          0 :             aCopyRange.aStart.SetTab(0);
    1396                 :          0 :             aCopyRange.aEnd.SetTab(nTabCount-1);
    1397         [ #  # ]:          0 :             pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, sal_True, pUndoDoc, &aFuncMark );
    1398         [ #  # ]:          0 :             aFuncMark.MarkToMulti();
    1399                 :            : 
    1400 [ #  # ][ #  # ]:          0 :             String aName = pStyleSheet->GetName();
    1401         [ #  # ]:          0 :             pDocSh->GetUndoManager()->AddUndoAction(
    1402 [ #  # ][ #  # ]:          0 :                 new ScUndoSelectionStyle( pDocSh, aFuncMark, aMarkRange, aName, pUndoDoc ) );
         [ #  # ][ #  # ]
    1403                 :            :         }
    1404                 :            : 
    1405         [ #  # ]:          0 :         pDoc->ApplySelectionStyle( (ScStyleSheet&)*pStyleSheet, aFuncMark );
    1406                 :            : 
    1407 [ #  # ][ #  # ]:          0 :         if (!AdjustBlockHeight())
    1408 [ #  # ][ #  # ]:          0 :             pViewData->GetDocShell()->PostPaint( aMarkRange, PAINT_GRID );
                 [ #  # ]
    1409                 :            : 
    1410         [ #  # ]:          0 :         aFuncMark.MarkToSimple();
    1411                 :            :     }
    1412                 :            :     else
    1413                 :            :     {
    1414                 :          0 :         SCCOL nCol = pViewData->GetCurX();
    1415                 :          0 :         SCROW nRow = pViewData->GetCurY();
    1416                 :          0 :         SCTAB nTab = pViewData->GetTabNo();
    1417                 :            : 
    1418         [ #  # ]:          0 :         if ( bRecord )
    1419                 :            :         {
    1420 [ #  # ][ #  # ]:          0 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1421         [ #  # ]:          0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab );
    1422 [ #  # ][ #  # ]:          0 :             ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end();
    1423 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1424 [ #  # ][ #  # ]:          0 :                 if (*itr != nTab)
    1425 [ #  # ][ #  # ]:          0 :                     pUndoDoc->AddUndoTab( *itr, *itr );
                 [ #  # ]
    1426                 :            : 
    1427                 :          0 :             ScRange aCopyRange( nCol, nRow, 0, nCol, nRow, nTabCount-1 );
    1428         [ #  # ]:          0 :             pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, false, pUndoDoc );
    1429                 :            : 
    1430                 :          0 :             ScRange aMarkRange ( nCol, nRow, nTab );
    1431         [ #  # ]:          0 :             ScMarkData aUndoMark = aFuncMark;
    1432         [ #  # ]:          0 :             aUndoMark.SetMultiMarkArea( aMarkRange );
    1433                 :            : 
    1434 [ #  # ][ #  # ]:          0 :             String aName = pStyleSheet->GetName();
    1435         [ #  # ]:          0 :             pDocSh->GetUndoManager()->AddUndoAction(
    1436 [ #  # ][ #  # ]:          0 :                 new ScUndoSelectionStyle( pDocSh, aUndoMark, aMarkRange, aName, pUndoDoc ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1437                 :            :         }
    1438                 :            : 
    1439 [ #  # ][ #  # ]:          0 :         ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end();
    1440 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1441 [ #  # ][ #  # ]:          0 :             pDoc->ApplyStyle( nCol, nRow, *itr, (ScStyleSheet&)*pStyleSheet );
    1442                 :            : 
    1443 [ #  # ][ #  # ]:          0 :         if (!AdjustBlockHeight())
    1444         [ #  # ]:          0 :             pViewData->GetDocShell()->PostPaintCell( nCol, nRow, nTab );
    1445                 :            : 
    1446                 :            :     }
    1447                 :            : 
    1448         [ #  # ]:          0 :     aModificator.SetDocumentModified();
    1449                 :            : 
    1450 [ #  # ][ #  # ]:          0 :     StartFormatArea();
                 [ #  # ]
    1451                 :            : }
    1452                 :            : 
    1453                 :            : 
    1454                 :          0 : void ScViewFunc::RemoveStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet )
    1455                 :            : {
    1456         [ #  # ]:          0 :     if ( !pStyleSheet) return;
    1457                 :            :     // -------------------------------------------------------------------
    1458                 :            : 
    1459                 :          0 :     ScViewData* pViewData   = GetViewData();
    1460         [ #  # ]:          0 :     ScDocument* pDoc        = pViewData->GetDocument();
    1461                 :          0 :     ScDocShell* pDocSh      = pViewData->GetDocShell();
    1462                 :            : 
    1463         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
    1464                 :            : 
    1465         [ #  # ]:          0 :     VirtualDevice aVirtDev;
    1466 [ #  # ][ #  # ]:          0 :     aVirtDev.SetMapMode(MAP_PIXEL);
                 [ #  # ]
    1467                 :            :     pDoc->StyleSheetChanged( pStyleSheet, sal_True, &aVirtDev,
    1468                 :            :                                 pViewData->GetPPTX(),
    1469                 :            :                                 pViewData->GetPPTY(),
    1470                 :          0 :                                 pViewData->GetZoomX(),
    1471         [ #  # ]:          0 :                                 pViewData->GetZoomY() );
    1472                 :            : 
    1473         [ #  # ]:          0 :     pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
    1474         [ #  # ]:          0 :     aModificator.SetDocumentModified();
    1475                 :            : 
    1476 [ #  # ][ #  # ]:          0 :     ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
    1477         [ #  # ]:          0 :     if (pHdl)
    1478 [ #  # ][ #  # ]:          0 :         pHdl->ForgetLastPattern();
                 [ #  # ]
    1479                 :            : }
    1480                 :            : 
    1481                 :          0 : void ScViewFunc::UpdateStyleSheetInUse( const SfxStyleSheetBase* pStyleSheet )
    1482                 :            : {
    1483         [ #  # ]:          0 :     if ( !pStyleSheet) return;
    1484                 :            :     // -------------------------------------------------------------------
    1485                 :            : 
    1486                 :          0 :     ScViewData* pViewData   = GetViewData();
    1487         [ #  # ]:          0 :     ScDocument* pDoc        = pViewData->GetDocument();
    1488                 :          0 :     ScDocShell* pDocSh      = pViewData->GetDocShell();
    1489                 :            : 
    1490         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
    1491                 :            : 
    1492         [ #  # ]:          0 :     VirtualDevice aVirtDev;
    1493 [ #  # ][ #  # ]:          0 :     aVirtDev.SetMapMode(MAP_PIXEL);
                 [ #  # ]
    1494                 :            :     pDoc->StyleSheetChanged( pStyleSheet, false, &aVirtDev,
    1495                 :            :                                 pViewData->GetPPTX(),
    1496                 :            :                                 pViewData->GetPPTY(),
    1497                 :          0 :                                 pViewData->GetZoomX(),
    1498         [ #  # ]:          0 :                                 pViewData->GetZoomY() );
    1499                 :            : 
    1500         [ #  # ]:          0 :     pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
    1501         [ #  # ]:          0 :     aModificator.SetDocumentModified();
    1502                 :            : 
    1503 [ #  # ][ #  # ]:          0 :     ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
    1504         [ #  # ]:          0 :     if (pHdl)
    1505 [ #  # ][ #  # ]:          0 :         pHdl->ForgetLastPattern();
                 [ #  # ]
    1506                 :            : }
    1507                 :            : 
    1508                 :            : //  insert cells - undo OK
    1509                 :            : 
    1510                 :          0 : sal_Bool ScViewFunc::InsertCells( InsCellCmd eCmd, sal_Bool bRecord, sal_Bool bPartOfPaste )
    1511                 :            : {
    1512                 :          0 :     ScRange aRange;
    1513 [ #  # ][ #  # ]:          0 :     if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
    1514                 :            :     {
    1515                 :          0 :         ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1516         [ #  # ]:          0 :         const ScMarkData& rMark = GetViewData()->GetMarkData();
    1517         [ #  # ]:          0 :         sal_Bool bSuccess = pDocSh->GetDocFunc().InsertCells( aRange, &rMark, eCmd, bRecord, false, bPartOfPaste );
    1518         [ #  # ]:          0 :         if (bSuccess)
    1519                 :            :         {
    1520         [ #  # ]:          0 :             pDocSh->UpdateOle(GetViewData());
    1521         [ #  # ]:          0 :             CellContentChanged();
    1522                 :            : 
    1523                 :            :             // #i97876# Spreadsheet data changes are not notified
    1524 [ #  # ][ #  # ]:          0 :             ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
    1525 [ #  # ][ #  # ]:          0 :             if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
    1526                 :            :             {
    1527 [ #  # ][ #  # ]:          0 :                 if ( eCmd == INS_INSROWS || eCmd == INS_INSCOLS )
    1528                 :            :                 {
    1529         [ #  # ]:          0 :                     ScRangeList aChangeRanges;
    1530         [ #  # ]:          0 :                     aChangeRanges.Append( aRange );
    1531                 :            :                     ::rtl::OUString aOperation = ( eCmd == INS_INSROWS ?
    1532                 :            :                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert-rows" ) ) :
    1533 [ #  # ][ #  # ]:          0 :                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert-columns" ) ) );
                 [ #  # ]
    1534 [ #  # ][ #  # ]:          0 :                     pModelObj->NotifyChanges( aOperation, aChangeRanges );
         [ #  # ][ #  # ]
    1535                 :            :                 }
    1536                 :            :             }
    1537                 :            :         }
    1538                 :          0 :         return bSuccess;
    1539                 :            :     }
    1540                 :            :     else
    1541                 :            :     {
    1542         [ #  # ]:          0 :         ErrorMessage(STR_NOMULTISELECT);
    1543                 :          0 :         return false;
    1544                 :            :     }
    1545                 :            : }
    1546                 :            : 
    1547                 :            : //  delete cells - undo OK
    1548                 :            : 
    1549                 :          0 : void ScViewFunc::DeleteCells( DelCellCmd eCmd, sal_Bool bRecord )
    1550                 :            : {
    1551                 :          0 :     ScRange aRange;
    1552 [ #  # ][ #  # ]:          0 :     if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
    1553                 :            :     {
    1554                 :          0 :         ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1555         [ #  # ]:          0 :         const ScMarkData& rMark = GetViewData()->GetMarkData();
    1556                 :            : 
    1557                 :            :         // #i94841# [Collaboration] if deleting rows is rejected, the content is sometimes wrong
    1558 [ #  # ][ #  # ]:          0 :         if ( pDocSh->IsDocShared() && ( eCmd == DEL_DELROWS || eCmd == DEL_DELCOLS ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1559                 :            :         {
    1560                 :          0 :             ScRange aDelRange( aRange.aStart );
    1561                 :          0 :             SCCOLROW nCount = 0;
    1562         [ #  # ]:          0 :             if ( eCmd == DEL_DELROWS )
    1563                 :            :             {
    1564                 :          0 :                 nCount = sal::static_int_cast< SCCOLROW >( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
    1565                 :            :             }
    1566                 :            :             else
    1567                 :            :             {
    1568                 :          0 :                 nCount = sal::static_int_cast< SCCOLROW >( aRange.aEnd.Col() - aRange.aStart.Col() + 1 );
    1569                 :            :             }
    1570         [ #  # ]:          0 :             while ( nCount > 0 )
    1571                 :            :             {
    1572         [ #  # ]:          0 :                 pDocSh->GetDocFunc().DeleteCells( aDelRange, &rMark, eCmd, bRecord, false );
    1573                 :          0 :                 --nCount;
    1574                 :            :             }
    1575                 :            :         }
    1576                 :            :         else
    1577                 :            :         {
    1578         [ #  # ]:          0 :             pDocSh->GetDocFunc().DeleteCells( aRange, &rMark, eCmd, bRecord, false );
    1579                 :            :         }
    1580                 :            : 
    1581         [ #  # ]:          0 :         pDocSh->UpdateOle(GetViewData());
    1582         [ #  # ]:          0 :         CellContentChanged();
    1583                 :            : 
    1584                 :            :         // #i97876# Spreadsheet data changes are not notified
    1585 [ #  # ][ #  # ]:          0 :         ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
    1586 [ #  # ][ #  # ]:          0 :         if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
    1587                 :            :         {
    1588 [ #  # ][ #  # ]:          0 :             if ( eCmd == DEL_DELROWS || eCmd == DEL_DELCOLS )
    1589                 :            :             {
    1590         [ #  # ]:          0 :                 ScRangeList aChangeRanges;
    1591         [ #  # ]:          0 :                 aChangeRanges.Append( aRange );
    1592                 :            :                 ::rtl::OUString aOperation = ( eCmd == DEL_DELROWS ?
    1593                 :            :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete-rows" ) ) :
    1594 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete-columns" ) ) );
                 [ #  # ]
    1595 [ #  # ][ #  # ]:          0 :                 pModelObj->NotifyChanges( aOperation, aChangeRanges );
         [ #  # ][ #  # ]
    1596                 :            :             }
    1597                 :            :         }
    1598                 :            : 
    1599                 :            :         //  put cursor directly behind deleted range
    1600                 :          0 :         SCCOL nCurX = GetViewData()->GetCurX();
    1601                 :          0 :         SCROW nCurY = GetViewData()->GetCurY();
    1602 [ #  # ][ #  # ]:          0 :         if ( eCmd==DEL_CELLSLEFT || eCmd==DEL_DELCOLS )
    1603                 :          0 :             nCurX = aRange.aStart.Col();
    1604                 :            :         else
    1605                 :          0 :             nCurY = aRange.aStart.Row();
    1606         [ #  # ]:          0 :         SetCursor( nCurX, nCurY );
    1607                 :            :     }
    1608                 :            :     else
    1609                 :            :     {
    1610         [ #  # ]:          0 :         if (eCmd == DEL_DELCOLS)
    1611         [ #  # ]:          0 :             DeleteMulti( false, bRecord );
    1612         [ #  # ]:          0 :         else if (eCmd == DEL_DELROWS)
    1613         [ #  # ]:          0 :             DeleteMulti( sal_True, bRecord );
    1614                 :            :         else
    1615         [ #  # ]:          0 :             ErrorMessage(STR_NOMULTISELECT);
    1616                 :            :     }
    1617                 :            : 
    1618         [ #  # ]:          0 :     Unmark();
    1619                 :          0 : }
    1620                 :            : 
    1621                 :          0 : void ScViewFunc::DeleteMulti( sal_Bool bRows, sal_Bool bRecord )
    1622                 :            : {
    1623                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1624         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
    1625                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    1626                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    1627 [ #  # ][ #  # ]:          0 :     ScMarkData aFuncMark( GetViewData()->GetMarkData() );       // local copy for UnmarkFiltered
    1628         [ #  # ]:          0 :     ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
    1629                 :            : 
    1630 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    1631                 :          0 :         bRecord = false;
    1632         [ #  # ]:          0 :     SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT];
    1633                 :            :     SCCOLROW nRangeCnt = bRows ? aFuncMark.GetMarkRowRanges( pRanges ) :
    1634 [ #  # ][ #  # ]:          0 :                                 aFuncMark.GetMarkColumnRanges( pRanges );
                 [ #  # ]
    1635         [ #  # ]:          0 :     if (nRangeCnt == 0)
    1636                 :            :     {
    1637         [ #  # ]:          0 :         pRanges[0] = pRanges[1] = bRows ? static_cast<SCCOLROW>(GetViewData()->GetCurY()) : static_cast<SCCOLROW>(GetViewData()->GetCurX());
    1638                 :          0 :         nRangeCnt = 1;
    1639                 :            :     }
    1640                 :            : 
    1641                 :            :     //  test if allowed
    1642                 :            : 
    1643                 :          0 :     SCCOLROW* pOneRange = pRanges;
    1644                 :          0 :     sal_uInt16 nErrorId = 0;
    1645                 :          0 :     sal_Bool bNeedRefresh = false;
    1646                 :            :     SCCOLROW nRangeNo;
    1647 [ #  # ][ #  # ]:          0 :     for (nRangeNo=0; nRangeNo<nRangeCnt && !nErrorId; nRangeNo++)
                 [ #  # ]
    1648                 :            :     {
    1649                 :          0 :         SCCOLROW nStart = *(pOneRange++);
    1650                 :          0 :         SCCOLROW nEnd = *(pOneRange++);
    1651                 :            : 
    1652                 :            :         SCCOL nStartCol, nEndCol;
    1653                 :            :         SCROW nStartRow, nEndRow;
    1654         [ #  # ]:          0 :         if ( bRows )
    1655                 :            :         {
    1656                 :          0 :             nStartCol = 0;
    1657                 :          0 :             nEndCol   = MAXCOL;
    1658                 :          0 :             nStartRow = static_cast<SCROW>(nStart);
    1659                 :          0 :             nEndRow   = static_cast<SCROW>(nEnd);
    1660                 :            :         }
    1661                 :            :         else
    1662                 :            :         {
    1663                 :          0 :             nStartCol = static_cast<SCCOL>(nStart);
    1664                 :          0 :             nEndCol   = static_cast<SCCOL>(nEnd);
    1665                 :          0 :             nStartRow = 0;
    1666                 :          0 :             nEndRow   = MAXROW;
    1667                 :            :         }
    1668                 :            : 
    1669                 :            :         // cell protection (only needed for first range, as all following cells are moved)
    1670         [ #  # ]:          0 :         if ( nRangeNo == 0 )
    1671                 :            :         {
    1672                 :            :             // test to the end of the sheet
    1673         [ #  # ]:          0 :             ScEditableTester aTester( pDoc, nTab, nStartCol, nStartRow, MAXCOL, MAXROW );
    1674         [ #  # ]:          0 :             if (!aTester.IsEditable())
    1675         [ #  # ]:          0 :                 nErrorId = aTester.GetMessageId();
    1676                 :            :         }
    1677                 :            : 
    1678                 :            :         // merged cells
    1679                 :          0 :         SCCOL nMergeStartX = nStartCol;
    1680                 :          0 :         SCROW nMergeStartY = nStartRow;
    1681                 :          0 :         SCCOL nMergeEndX   = nEndCol;
    1682                 :          0 :         SCROW nMergeEndY   = nEndRow;
    1683         [ #  # ]:          0 :         pDoc->ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, nTab );
    1684         [ #  # ]:          0 :         pDoc->ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, nTab );
    1685                 :            : 
    1686 [ #  # ][ #  # ]:          0 :         if ( nMergeStartX != nStartCol || nMergeStartY != nStartRow )
    1687                 :            :         {
    1688                 :            :             // Disallow deleting parts of a merged cell.
    1689                 :            :             // Deleting the start is allowed (merge is removed), so the end doesn't have to be checked.
    1690                 :            : 
    1691                 :          0 :             nErrorId = STR_MSSG_DELETECELLS_0;
    1692                 :            :         }
    1693 [ #  # ][ #  # ]:          0 :         if ( nMergeEndX != nEndCol || nMergeEndY != nEndRow )
    1694                 :            :         {
    1695                 :            :             // detect if the start of a merged cell is deleted, so the merge flags can be refreshed
    1696                 :            : 
    1697                 :          0 :             bNeedRefresh = sal_True;
    1698                 :            :         }
    1699                 :            :     }
    1700                 :            : 
    1701         [ #  # ]:          0 :     if ( nErrorId )
    1702                 :            :     {
    1703         [ #  # ]:          0 :         ErrorMessage( nErrorId );
    1704         [ #  # ]:          0 :         delete[] pRanges;
    1705                 :          0 :         return;
    1706                 :            :     }
    1707                 :            : 
    1708                 :            :     //  proceed
    1709                 :            : 
    1710         [ #  # ]:          0 :     WaitObject aWait( GetFrameWin() );      // important for TrackFormulas in UpdateReference
    1711                 :            : 
    1712                 :          0 :     ScDocument* pUndoDoc = NULL;
    1713                 :          0 :     ScRefUndoData* pUndoData = NULL;
    1714         [ #  # ]:          0 :     if (bRecord)
    1715                 :            :     {
    1716 [ #  # ][ #  # ]:          0 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1717         [ #  # ]:          0 :         pUndoDoc->InitUndo( pDoc, nTab, nTab, !bRows, bRows );      // row height
    1718                 :            : 
    1719                 :          0 :         pOneRange = pRanges;
    1720         [ #  # ]:          0 :         for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
    1721                 :            :         {
    1722                 :          0 :             SCCOLROW nStart = *(pOneRange++);
    1723                 :          0 :             SCCOLROW nEnd = *(pOneRange++);
    1724         [ #  # ]:          0 :             if (bRows)
    1725         [ #  # ]:          0 :                 pDoc->CopyToDocument( 0,nStart,nTab, MAXCOL,nEnd,nTab, IDF_ALL,false,pUndoDoc );
    1726                 :            :             else
    1727                 :            :                 pDoc->CopyToDocument( static_cast<SCCOL>(nStart),0,nTab,
    1728                 :            :                         static_cast<SCCOL>(nEnd),MAXROW,nTab,
    1729         [ #  # ]:          0 :                         IDF_ALL,false,pUndoDoc );
    1730                 :            :         }
    1731                 :            : 
    1732                 :            :         //  all Formulas because of references
    1733         [ #  # ]:          0 :         SCTAB nTabCount = pDoc->GetTableCount();
    1734         [ #  # ]:          0 :         pUndoDoc->AddUndoTab( 0, nTabCount-1, false, false );
    1735         [ #  # ]:          0 :         pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,MAXTAB, IDF_FORMULA,false,pUndoDoc );
    1736                 :            : 
    1737 [ #  # ][ #  # ]:          0 :         pUndoData = new ScRefUndoData( pDoc );
    1738                 :            : 
    1739         [ #  # ]:          0 :         pDoc->BeginDrawUndo();
    1740                 :            :     }
    1741                 :            : 
    1742                 :          0 :     pOneRange = &pRanges[2*nRangeCnt];      // backwards
    1743         [ #  # ]:          0 :     for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
    1744                 :            :     {
    1745                 :          0 :         SCCOLROW nEnd = *(--pOneRange);
    1746                 :          0 :         SCCOLROW nStart = *(--pOneRange);
    1747                 :            : 
    1748         [ #  # ]:          0 :         if (bRows)
    1749         [ #  # ]:          0 :             pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, nStart, static_cast<SCSIZE>(nEnd-nStart+1) );
    1750                 :            :         else
    1751         [ #  # ]:          0 :             pDoc->DeleteCol( 0,nTab, MAXROW,nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd-nStart+1) );
    1752                 :            :     }
    1753                 :            : 
    1754         [ #  # ]:          0 :     if (bNeedRefresh)
    1755                 :            :     {
    1756                 :          0 :         SCCOLROW nFirstStart = pRanges[0];
    1757         [ #  # ]:          0 :         SCCOL nStartCol = bRows ? 0 : static_cast<SCCOL>(nFirstStart);
    1758         [ #  # ]:          0 :         SCROW nStartRow = bRows ? static_cast<SCROW>(nFirstStart) : 0;
    1759                 :          0 :         SCCOL nEndCol = MAXCOL;
    1760                 :          0 :         SCROW nEndRow = MAXROW;
    1761                 :            : 
    1762         [ #  # ]:          0 :         pDoc->RemoveFlagsTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, SC_MF_HOR | SC_MF_VER );
    1763         [ #  # ]:          0 :         pDoc->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab, sal_True );
    1764                 :            :     }
    1765                 :            : 
    1766         [ #  # ]:          0 :     if (bRecord)
    1767                 :            :     {
    1768         [ #  # ]:          0 :         pDocSh->GetUndoManager()->AddUndoAction(
    1769                 :            :             new ScUndoDeleteMulti( pDocSh, bRows, bNeedRefresh, nTab, pRanges, nRangeCnt,
    1770 [ #  # ][ #  # ]:          0 :                                     pUndoDoc, pUndoData ) );
                 [ #  # ]
    1771                 :            :     }
    1772                 :            : 
    1773 [ #  # ][ #  # ]:          0 :     if (!AdjustRowHeight(0, MAXROW))
    1774                 :            :     {
    1775         [ #  # ]:          0 :         if (bRows)
    1776         [ #  # ]:          0 :             pDocSh->PostPaint( 0,pRanges[0],nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT );
    1777                 :            :         else
    1778                 :          0 :             pDocSh->PostPaint( static_cast<SCCOL>(pRanges[0]),0,nTab,
    1779         [ #  # ]:          0 :                     MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_TOP );
    1780                 :            :     }
    1781         [ #  # ]:          0 :     aModificator.SetDocumentModified();
    1782                 :            : 
    1783         [ #  # ]:          0 :     CellContentChanged();
    1784                 :            : 
    1785                 :            :     //  put cursor directly behind the first deleted range
    1786                 :          0 :     SCCOL nCurX = GetViewData()->GetCurX();
    1787                 :          0 :     SCROW nCurY = GetViewData()->GetCurY();
    1788         [ #  # ]:          0 :     if ( bRows )
    1789                 :          0 :         nCurY = pRanges[0];
    1790                 :            :     else
    1791                 :          0 :         nCurX = static_cast<SCCOL>(pRanges[0]);
    1792         [ #  # ]:          0 :     SetCursor( nCurX, nCurY );
    1793                 :            : 
    1794         [ #  # ]:          0 :     delete[] pRanges;
    1795                 :            : 
    1796 [ #  # ][ #  # ]:          0 :     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1797                 :            : }
    1798                 :            : 
    1799                 :            : //  delete contents
    1800                 :            : 
    1801                 :          0 : void ScViewFunc::DeleteContents( sal_uInt16 nFlags, sal_Bool bRecord )
    1802                 :            : {
    1803                 :          0 :     ScViewData* pViewData = GetViewData();
    1804                 :          0 :     pViewData->SetPasteMode( SC_PASTE_NONE );
    1805         [ #  # ]:          0 :     pViewData->GetViewShell()->UpdateCopySourceOverlay();
    1806                 :            : 
    1807                 :            :     // not editable because of matrix only? attribute OK nonetheless
    1808                 :            :     bool bOnlyNotBecauseOfMatrix;
    1809         [ #  # ]:          0 :     sal_Bool bEditable = SelectionEditable( &bOnlyNotBecauseOfMatrix );
    1810         [ #  # ]:          0 :     if ( !bEditable )
    1811                 :            :     {
    1812         [ #  # ]:          0 :         if ( !(bOnlyNotBecauseOfMatrix &&
    1813         [ #  # ]:          0 :                 ((nFlags & (IDF_ATTRIB | IDF_EDITATTR)) == nFlags)) )
    1814                 :            :         {
    1815 [ #  # ][ #  # ]:          0 :             ErrorMessage(bOnlyNotBecauseOfMatrix ? STR_MATRIXFRAGMENTERR : STR_PROTECTIONERR);
    1816                 :          0 :             return;
    1817                 :            :         }
    1818                 :            :     }
    1819                 :            : 
    1820                 :          0 :     ScRange aMarkRange;
    1821                 :          0 :     sal_Bool bSimple = false;
    1822                 :            : 
    1823         [ #  # ]:          0 :     ScDocument* pDoc = GetViewData()->GetDocument();
    1824                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1825 [ #  # ][ #  # ]:          0 :     ScMarkData aFuncMark( GetViewData()->GetMarkData() );       // local copy for UnmarkFiltered
    1826         [ #  # ]:          0 :     ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
    1827                 :            : 
    1828 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    1829                 :          0 :         bRecord = false;
    1830                 :            : 
    1831         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
    1832                 :            : 
    1833 [ #  # ][ #  # ]:          0 :     if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
                 [ #  # ]
    1834                 :            :     {
    1835                 :          0 :         aMarkRange.aStart.SetCol(GetViewData()->GetCurX());
    1836                 :          0 :         aMarkRange.aStart.SetRow(GetViewData()->GetCurY());
    1837                 :          0 :         aMarkRange.aStart.SetTab(GetViewData()->GetTabNo());
    1838                 :          0 :         aMarkRange.aEnd = aMarkRange.aStart;
    1839 [ #  # ][ #  # ]:          0 :         if ( pDoc->HasAttrib( aMarkRange, HASATTR_MERGED ) )
    1840                 :            :         {
    1841         [ #  # ]:          0 :             aFuncMark.SetMarkArea( aMarkRange );
    1842                 :            :         }
    1843                 :            :         else
    1844                 :          0 :             bSimple = sal_True;
    1845                 :            :     }
    1846                 :            : 
    1847                 :          0 :     aFuncMark.SetMarking(false);        // for MarkToMulti
    1848         [ #  # ]:          0 :     aFuncMark.MarkToSimple();           // before bMulti test below
    1849                 :            : 
    1850                 :            :     OSL_ENSURE( aFuncMark.IsMarked() || aFuncMark.IsMultiMarked() || bSimple, "delete what?" );
    1851                 :            : 
    1852                 :          0 :     ScDocument* pUndoDoc = NULL;
    1853 [ #  # ][ #  # ]:          0 :     sal_Bool bMulti = !bSimple && aFuncMark.IsMultiMarked();
    1854         [ #  # ]:          0 :     if (!bSimple)
    1855                 :            :     {
    1856         [ #  # ]:          0 :         aFuncMark.MarkToMulti();
    1857         [ #  # ]:          0 :         aFuncMark.GetMultiMarkArea( aMarkRange );
    1858                 :            :     }
    1859                 :          0 :     ScRange aExtendedRange(aMarkRange);
    1860         [ #  # ]:          0 :     if (!bSimple)
    1861                 :            :     {
    1862 [ #  # ][ #  # ]:          0 :         if ( pDoc->ExtendMerge( aExtendedRange, sal_True ) )
    1863                 :          0 :             bMulti = false;
    1864                 :            :     }
    1865                 :            : 
    1866                 :            :     // no objects on protected tabs
    1867                 :          0 :     sal_Bool bObjects = false;
    1868         [ #  # ]:          0 :     if ( nFlags & IDF_OBJECTS )
    1869                 :            :     {
    1870                 :          0 :         bObjects = sal_True;
    1871 [ #  # ][ #  # ]:          0 :         ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end();
    1872 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1873 [ #  # ][ #  # ]:          0 :             if (pDoc->IsTabProtected(*itr))
                 [ #  # ]
    1874                 :          0 :                 bObjects = false;
    1875                 :            :     }
    1876                 :            : 
    1877                 :          0 :     sal_uInt16 nExtFlags = 0;       // extra flags are needed only if attributes are deleted
    1878         [ #  # ]:          0 :     if ( nFlags & IDF_ATTRIB )
    1879         [ #  # ]:          0 :         pDocSh->UpdatePaintExt( nExtFlags, aMarkRange );
    1880                 :            : 
    1881                 :            :     //  order op opeeration:
    1882                 :            :     //  1) BeginDrawUndo
    1883                 :            :     //  2) delete objects (DrawUndo is filled)
    1884                 :            :     //  3) copy contents for undo
    1885                 :            :     //  4) delete contents
    1886                 :            :     //  5) add undo-action
    1887                 :            : 
    1888 [ #  # ][ #  # ]:          0 :     sal_Bool bDrawUndo = bObjects || ( nFlags & IDF_NOTE );     // needed for shown notes
    1889 [ #  # ][ #  # ]:          0 :     if ( bDrawUndo && bRecord )
    1890         [ #  # ]:          0 :         pDoc->BeginDrawUndo();
    1891                 :            : 
    1892         [ #  # ]:          0 :     if (bObjects)
    1893                 :            :     {
    1894         [ #  # ]:          0 :         if (bMulti)
    1895         [ #  # ]:          0 :             pDoc->DeleteObjectsInSelection( aFuncMark );
    1896                 :            :         else
    1897                 :          0 :             pDoc->DeleteObjectsInArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
    1898                 :          0 : /*!*/                                  aMarkRange.aEnd.Col(),   aMarkRange.aEnd.Row(),
    1899         [ #  # ]:          0 :                                        aFuncMark );
    1900                 :            :     }
    1901                 :            : 
    1902         [ #  # ]:          0 :     if ( bRecord )
    1903                 :            :     {
    1904 [ #  # ][ #  # ]:          0 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    1905                 :          0 :         SCTAB nTab = aMarkRange.aStart.Tab();
    1906         [ #  # ]:          0 :         pUndoDoc->InitUndo( pDoc, nTab, nTab );
    1907         [ #  # ]:          0 :         SCTAB nTabCount = pDoc->GetTableCount();
    1908 [ #  # ][ #  # ]:          0 :         ScMarkData::iterator itr = aFuncMark.begin(), itrEnd = aFuncMark.end();
    1909 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    1910 [ #  # ][ #  # ]:          0 :             if (*itr != nTab)
    1911 [ #  # ][ #  # ]:          0 :                 pUndoDoc->AddUndoTab( *itr, *itr );
                 [ #  # ]
    1912                 :          0 :         ScRange aCopyRange = aExtendedRange;
    1913                 :          0 :         aCopyRange.aStart.SetTab(0);
    1914                 :          0 :         aCopyRange.aEnd.SetTab(nTabCount-1);
    1915                 :            : 
    1916                 :            :         //  in case of "Format/Standard" copy all attributes, because CopyToDocument
    1917                 :            :         //  with IDF_HARDATTR only is too time-consuming:
    1918                 :          0 :         sal_uInt16 nUndoDocFlags = nFlags;
    1919         [ #  # ]:          0 :         if (nFlags & IDF_ATTRIB)
    1920                 :          0 :             nUndoDocFlags |= IDF_ATTRIB;
    1921         [ #  # ]:          0 :         if (nFlags & IDF_EDITATTR)          // Edit-Engine-Attribute
    1922                 :          0 :             nUndoDocFlags |= IDF_STRING;    // -> cells will be changed
    1923         [ #  # ]:          0 :         if (nFlags & IDF_NOTE)
    1924                 :          0 :             nUndoDocFlags |= IDF_CONTENTS;  // copy all cells with their notes
    1925                 :            :         // do not copy note captions to undo document
    1926                 :          0 :         nUndoDocFlags |= IDF_NOCAPTIONS;
    1927         [ #  # ]:          0 :         pDoc->CopyToDocument( aCopyRange, nUndoDocFlags, bMulti, pUndoDoc, &aFuncMark );
    1928                 :            :     }
    1929                 :            : 
    1930         [ #  # ]:          0 :     HideAllCursors();   // for if summary is cancelled
    1931         [ #  # ]:          0 :     if (bSimple)
    1932                 :          0 :         pDoc->DeleteArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
    1933                 :          0 :                           aMarkRange.aEnd.Col(),   aMarkRange.aEnd.Row(),
    1934         [ #  # ]:          0 :                           aFuncMark, nFlags );
    1935                 :            :     else
    1936                 :            :     {
    1937         [ #  # ]:          0 :         pDoc->DeleteSelection( nFlags, aFuncMark );
    1938                 :            :     }
    1939                 :            : 
    1940         [ #  # ]:          0 :     if ( bRecord )
    1941                 :            :     {
    1942         [ #  # ]:          0 :         pDocSh->GetUndoManager()->AddUndoAction(
    1943                 :            :             new ScUndoDeleteContents( pDocSh, aFuncMark, aExtendedRange,
    1944 [ #  # ][ #  # ]:          0 :                                       pUndoDoc, bMulti, nFlags, bDrawUndo ) );
                 [ #  # ]
    1945                 :            :     }
    1946                 :            : 
    1947 [ #  # ][ #  # ]:          0 :     if (!AdjustRowHeight( aExtendedRange.aStart.Row(), aExtendedRange.aEnd.Row() ))
    1948 [ #  # ][ #  # ]:          0 :         pDocSh->PostPaint( aExtendedRange, PAINT_GRID, nExtFlags );
                 [ #  # ]
    1949                 :            : 
    1950         [ #  # ]:          0 :     pDocSh->UpdateOle(GetViewData());
    1951                 :            : 
    1952                 :            :     // #i97876# Spreadsheet data changes are not notified
    1953 [ #  # ][ #  # ]:          0 :     ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
    1954 [ #  # ][ #  # ]:          0 :     if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
    1955                 :            :     {
    1956         [ #  # ]:          0 :         ScRangeList aChangeRanges;
    1957         [ #  # ]:          0 :         if ( bSimple )
    1958                 :            :         {
    1959         [ #  # ]:          0 :             aChangeRanges.Append( aMarkRange );
    1960                 :            :         }
    1961                 :            :         else
    1962                 :            :         {
    1963         [ #  # ]:          0 :             aFuncMark.FillRangeListWithMarks( &aChangeRanges, false );
    1964                 :            :         }
    1965 [ #  # ][ #  # ]:          0 :         pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
         [ #  # ][ #  # ]
                 [ #  # ]
    1966                 :            :     }
    1967                 :            : 
    1968         [ #  # ]:          0 :     aModificator.SetDocumentModified();
    1969         [ #  # ]:          0 :     CellContentChanged();
    1970         [ #  # ]:          0 :     ShowAllCursors();
    1971                 :            : 
    1972         [ #  # ]:          0 :     if ( nFlags & IDF_ATTRIB )
    1973                 :            :     {
    1974         [ #  # ]:          0 :         if ( nFlags & IDF_CONTENTS )
    1975                 :          0 :             ForgetFormatArea();
    1976                 :            :         else
    1977         [ #  # ]:          0 :             StartFormatArea();              // delete attribute is also attribute-change
    1978 [ #  # ][ #  # ]:          0 :     }
    1979                 :            : }
    1980                 :            : 
    1981                 :            : //  column width/row height (via header) - undo OK
    1982                 :            : 
    1983                 :          0 : void ScViewFunc::SetWidthOrHeight( sal_Bool bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
    1984                 :            :                                     ScSizeMode eMode, sal_uInt16 nSizeTwips,
    1985                 :            :                                     sal_Bool bRecord, sal_Bool bPaint, ScMarkData* pMarkData )
    1986                 :            : {
    1987         [ #  # ]:          0 :     if (nRangeCnt == 0)
    1988                 :            :         return;
    1989                 :            : 
    1990                 :            :     // use view's mark if none specified
    1991         [ #  # ]:          0 :     if ( !pMarkData )
    1992         [ #  # ]:          0 :         pMarkData = &GetViewData()->GetMarkData();
    1993                 :            : 
    1994                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    1995                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    1996         [ #  # ]:          0 :     SCTAB nFirstTab = pMarkData->GetFirstSelected();
    1997                 :          0 :     SCTAB nCurTab = GetViewData()->GetTabNo();
    1998                 :            :     SCTAB nTab;
    1999 [ #  # ][ #  # ]:          0 :     if (bRecord && !pDoc->IsUndoEnabled())
                 [ #  # ]
    2000                 :          0 :         bRecord = false;
    2001                 :            : 
    2002         [ #  # ]:          0 :     ScDocShellModificator aModificator( *pDocSh );
    2003                 :            : 
    2004                 :          0 :     bool bAllowed = true;
    2005 [ #  # ][ #  # ]:          0 :     ScMarkData::iterator itr = pMarkData->begin(), itrEnd = pMarkData->end();
    2006 [ #  # ][ #  # ]:          0 :     for (; itr != itrEnd && bAllowed; ++itr)
         [ #  # ][ #  # ]
                 [ #  # ]
    2007 [ #  # ][ #  # ]:          0 :         for ( SCCOLROW i=0; i<nRangeCnt && bAllowed; i++ )
                 [ #  # ]
    2008                 :            :         {
    2009                 :            :             bool bOnlyMatrix;
    2010         [ #  # ]:          0 :             if (bWidth)
    2011         [ #  # ]:          0 :                 bAllowed = pDoc->IsBlockEditable( *itr,
    2012                 :          0 :                         static_cast<SCCOL>(pRanges[2*i]),0,
    2013                 :          0 :                         static_cast<SCCOL>(pRanges[2*i+1]),MAXROW,
    2014 [ #  # ][ #  # ]:          0 :                         &bOnlyMatrix ) || bOnlyMatrix;
                 [ #  # ]
    2015                 :            :             else
    2016         [ #  # ]:          0 :                 bAllowed = pDoc->IsBlockEditable( *itr, 0,pRanges[2*i],
    2017         [ #  # ]:          0 :                         MAXCOL,pRanges[2*i+1], &bOnlyMatrix ) ||
    2018 [ #  # ][ #  # ]:          0 :                     bOnlyMatrix;
    2019                 :            :         }
    2020                 :            : 
    2021                 :            :     // Allow users to resize cols/rows in readonly docs despite the r/o state.
    2022                 :            :     // It is frustrating to be unable to see content in mis-sized cells.
    2023 [ #  # ][ #  # ]:          0 :     if( !bAllowed && !pDocSh->IsReadOnly() )
         [ #  # ][ #  # ]
    2024                 :            :     {
    2025         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    2026                 :            :         return;
    2027                 :            :     }
    2028                 :            : 
    2029                 :          0 :     SCCOLROW nStart = pRanges[0];
    2030                 :          0 :     SCCOLROW nEnd = pRanges[2*nRangeCnt-1];
    2031                 :            : 
    2032                 :          0 :     sal_Bool bFormula = false;
    2033         [ #  # ]:          0 :     if ( eMode == SC_SIZE_OPTIMAL )
    2034                 :            :     {
    2035                 :          0 :         const ScViewOptions& rOpts = GetViewData()->GetOptions();
    2036                 :          0 :         bFormula = rOpts.GetOption( VOPT_FORMULAS );
    2037                 :            :     }
    2038                 :            : 
    2039                 :          0 :     ScDocument*     pUndoDoc = NULL;
    2040                 :          0 :     ScOutlineTable* pUndoTab = NULL;
    2041                 :          0 :     SCCOLROW*       pUndoRanges = NULL;
    2042                 :            : 
    2043         [ #  # ]:          0 :     if ( bRecord )
    2044                 :            :     {
    2045         [ #  # ]:          0 :         pDoc->BeginDrawUndo();                          // Drawing Updates
    2046                 :            : 
    2047 [ #  # ][ #  # ]:          0 :         pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
    2048         [ #  # ]:          0 :         itr = pMarkData->begin();
    2049 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    2050                 :            :         {
    2051         [ #  # ]:          0 :             if (bWidth)
    2052                 :            :             {
    2053 [ #  # ][ #  # ]:          0 :                 if ( *itr == nFirstTab )
    2054 [ #  # ][ #  # ]:          0 :                     pUndoDoc->InitUndo( pDoc, *itr, *itr, true, false );
                 [ #  # ]
    2055                 :            :                 else
    2056 [ #  # ][ #  # ]:          0 :                     pUndoDoc->AddUndoTab( *itr, *itr, true, false );
                 [ #  # ]
    2057         [ #  # ]:          0 :                 pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, *itr,
    2058         [ #  # ]:          0 :                         static_cast<SCCOL>(nEnd), MAXROW, *itr, IDF_NONE,
    2059         [ #  # ]:          0 :                         false, pUndoDoc );
    2060                 :            :             }
    2061                 :            :             else
    2062                 :            :             {
    2063 [ #  # ][ #  # ]:          0 :                 if ( *itr == nFirstTab )
    2064 [ #  # ][ #  # ]:          0 :                     pUndoDoc->InitUndo( pDoc, *itr, *itr, false, true );
                 [ #  # ]
    2065                 :            :                 else
    2066 [ #  # ][ #  # ]:          0 :                     pUndoDoc->AddUndoTab( *itr, *itr, false, true );
                 [ #  # ]
    2067 [ #  # ][ #  # ]:          0 :                 pDoc->CopyToDocument( 0, nStart, *itr, MAXCOL, nEnd, *itr, IDF_NONE, false, pUndoDoc );
                 [ #  # ]
    2068                 :            :             }
    2069                 :            :         }
    2070                 :            : 
    2071         [ #  # ]:          0 :         pUndoRanges = new SCCOLROW[ 2*nRangeCnt ];
    2072                 :          0 :         memmove( pUndoRanges, pRanges, 2*nRangeCnt*sizeof(SCCOLROW) );
    2073                 :            : 
    2074                 :            :         //! outlines from all tab?
    2075         [ #  # ]:          0 :         ScOutlineTable* pTable = pDoc->GetOutlineTable( nCurTab );
    2076         [ #  # ]:          0 :         if (pTable)
    2077 [ #  # ][ #  # ]:          0 :             pUndoTab = new ScOutlineTable( *pTable );
    2078                 :            :     }
    2079                 :            : 
    2080 [ #  # ][ #  # ]:          0 :     if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
    2081         [ #  # ]:          0 :         pMarkData->MarkToMulti();
    2082                 :            : 
    2083 [ #  # ][ #  # ]:          0 :     sal_Bool bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT;
    2084                 :          0 :     sal_Bool bOutline = false;
    2085                 :            : 
    2086         [ #  # ]:          0 :     itr = pMarkData->begin();
    2087 [ #  # ][ #  # ]:          0 :     for (; itr != itrEnd; ++itr)
                 [ #  # ]
    2088                 :            :     {
    2089         [ #  # ]:          0 :         nTab = *itr;
    2090                 :          0 :         const SCCOLROW* pTabRanges = pRanges;
    2091                 :            : 
    2092         [ #  # ]:          0 :         pDoc->InitializeNoteCaptions( nTab );
    2093         [ #  # ]:          0 :         for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
    2094                 :            :         {
    2095                 :          0 :             SCCOLROW nStartNo = *(pTabRanges++);
    2096                 :          0 :             SCCOLROW nEndNo = *(pTabRanges++);
    2097                 :            : 
    2098         [ #  # ]:          0 :             if ( !bWidth )                      // height always blockwise
    2099                 :            :             {
    2100 [ #  # ][ #  # ]:          0 :                 if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
    2101                 :            :                 {
    2102                 :          0 :                     sal_Bool bAll = ( eMode==SC_SIZE_OPTIMAL );
    2103         [ #  # ]:          0 :                     if (!bAll)
    2104                 :            :                     {
    2105                 :            :                         //  delete CR_MANUALSIZE for all in range,
    2106                 :            :                         //  then SetOptimalHeight with bShrink = FALSE
    2107         [ #  # ]:          0 :                         for (SCROW nRow = nStartNo; nRow <= nEndNo; ++nRow)
    2108                 :            :                         {
    2109                 :          0 :                             SCROW nLastRow = nRow;
    2110 [ #  # ][ #  # ]:          0 :                             if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
    2111                 :            :                             {
    2112                 :          0 :                                 nRow = nLastRow;
    2113                 :          0 :                                 continue;
    2114                 :            :                             }
    2115                 :            : 
    2116         [ #  # ]:          0 :                             sal_uInt8 nOld = pDoc->GetRowFlags(nRow, nTab);
    2117         [ #  # ]:          0 :                             if (nOld & CR_MANUALSIZE)
    2118         [ #  # ]:          0 :                                 pDoc->SetRowFlags(nRow, nTab, nOld & ~CR_MANUALSIZE);
    2119                 :            :                         }
    2120                 :            :                     }
    2121                 :            : 
    2122                 :          0 :                     double nPPTX = GetViewData()->GetPPTX();
    2123                 :          0 :                     double nPPTY = GetViewData()->GetPPTY();
    2124         [ #  # ]:          0 :                     Fraction aZoomX = GetViewData()->GetZoomX();
    2125         [ #  # ]:          0 :                     Fraction aZoomY = GetViewData()->GetZoomY();
    2126                 :            : 
    2127         [ #  # ]:          0 :                     ScSizeDeviceProvider aProv(pDocSh);
    2128         [ #  # ]:          0 :                     if (aProv.IsPrinter())
    2129                 :            :                     {
    2130                 :          0 :                         nPPTX = aProv.GetPPTX();
    2131                 :          0 :                         nPPTY = aProv.GetPPTY();
    2132 [ #  # ][ #  # ]:          0 :                         aZoomX = aZoomY = Fraction( 1, 1 );
                 [ #  # ]
    2133                 :            :                     }
    2134                 :            : 
    2135                 :            :                     pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, nSizeTwips, aProv.GetDevice(),
    2136         [ #  # ]:          0 :                                                 nPPTX, nPPTY, aZoomX, aZoomY, bAll );
    2137         [ #  # ]:          0 :                     if (bAll)
    2138 [ #  # ][ #  # ]:          0 :                         pDoc->ShowRows( nStartNo, nEndNo, nTab, sal_True );
    2139                 :            : 
    2140                 :            :                     //  Manual-Flag already (re)set in SetOptimalHeight in case of bAll=sal_True
    2141                 :            :                     //  (set for Extra-Height, else reset).
    2142                 :            :                 }
    2143         [ #  # ]:          0 :                 else if ( eMode==SC_SIZE_DIRECT )
    2144                 :            :                 {
    2145         [ #  # ]:          0 :                     if (nSizeTwips)
    2146                 :            :                     {
    2147         [ #  # ]:          0 :                         pDoc->SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips );
    2148         [ #  # ]:          0 :                         pDoc->SetManualHeight( nStartNo, nEndNo, nTab, sal_True );          // height was set manually
    2149                 :            :                     }
    2150         [ #  # ]:          0 :                     pDoc->ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 );
    2151                 :            :                 }
    2152         [ #  # ]:          0 :                 else if ( eMode==SC_SIZE_SHOW )
    2153                 :            :                 {
    2154         [ #  # ]:          0 :                     pDoc->ShowRows( nStartNo, nEndNo, nTab, sal_True );
    2155                 :            :                 }
    2156                 :            :             }
    2157                 :            :             else                                // column width
    2158                 :            :             {
    2159         [ #  # ]:          0 :                 for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
    2160                 :            :                 {
    2161 [ #  # ][ #  # ]:          0 :                     if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab) )
         [ #  # ][ #  # ]
    2162                 :            :                     {
    2163                 :          0 :                         sal_uInt16 nThisSize = nSizeTwips;
    2164                 :            : 
    2165 [ #  # ][ #  # ]:          0 :                         if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
    2166         [ #  # ]:          0 :                             nThisSize = nSizeTwips + GetOptimalColWidth( nCol, nTab, bFormula );
    2167         [ #  # ]:          0 :                         if ( nThisSize )
    2168         [ #  # ]:          0 :                             pDoc->SetColWidth( nCol, nTab, nThisSize );
    2169                 :            : 
    2170         [ #  # ]:          0 :                         pDoc->ShowCol( nCol, nTab, bShow );
    2171                 :            :                     }
    2172                 :            :                 }
    2173                 :            :             }
    2174                 :            : 
    2175                 :            :                                     //  adjust outline
    2176                 :            : 
    2177         [ #  # ]:          0 :             if (bWidth)
    2178                 :            :             {
    2179 [ #  # ][ #  # ]:          0 :                 if ( pDoc->UpdateOutlineCol( static_cast<SCCOL>(nStartNo),
    2180                 :          0 :                             static_cast<SCCOL>(nEndNo), nTab, bShow ) )
    2181                 :          0 :                     bOutline = sal_True;
    2182                 :            :             }
    2183                 :            :             else
    2184                 :            :             {
    2185 [ #  # ][ #  # ]:          0 :                 if ( pDoc->UpdateOutlineRow( nStartNo, nEndNo, nTab, bShow ) )
    2186                 :          0 :                     bOutline = sal_True;
    2187                 :            :             }
    2188                 :            :         }
    2189         [ #  # ]:          0 :         pDoc->SetDrawPageSize(nTab);
    2190                 :            :     }
    2191                 :            : 
    2192                 :            : 
    2193         [ #  # ]:          0 :     if (!bOutline)
    2194 [ #  # ][ #  # ]:          0 :         DELETEZ(pUndoTab);
    2195                 :            : 
    2196         [ #  # ]:          0 :     if (bRecord)
    2197                 :            :     {
    2198         [ #  # ]:          0 :         pDocSh->GetUndoManager()->AddUndoAction(
    2199                 :            :             new ScUndoWidthOrHeight( pDocSh, *pMarkData,
    2200                 :            :                                      nStart, nCurTab, nEnd, nCurTab,
    2201                 :            :                                      pUndoDoc, nRangeCnt, pUndoRanges,
    2202 [ #  # ][ #  # ]:          0 :                                      pUndoTab, eMode, nSizeTwips, bWidth ) );
                 [ #  # ]
    2203                 :            :     }
    2204                 :            : 
    2205                 :            :     // fdo#36247 Ensure that the drawing layer's map mode scaling factors match
    2206                 :            :     // the new heights and widths.
    2207         [ #  # ]:          0 :     GetViewData()->GetView()->RefreshZoom();
    2208                 :            : 
    2209         [ #  # ]:          0 :     itr = pMarkData->begin();
    2210 [ #  # ][ #  # ]:          0 :     for (; itr != itrEnd; ++itr)
                 [ #  # ]
    2211 [ #  # ][ #  # ]:          0 :         pDoc->UpdatePageBreaks( *itr );
    2212                 :            : 
    2213         [ #  # ]:          0 :     GetViewData()->GetView()->UpdateScrollBars();
    2214                 :            : 
    2215         [ #  # ]:          0 :     if (bPaint)
    2216                 :            :     {
    2217         [ #  # ]:          0 :         itr = pMarkData->begin();
    2218 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    2219                 :            :         {
    2220         [ #  # ]:          0 :             nTab = *itr;
    2221         [ #  # ]:          0 :             if (bWidth)
    2222                 :            :             {
    2223 [ #  # ][ #  # ]:          0 :                 if (pDoc->HasAttrib( static_cast<SCCOL>(nStart),0,nTab,
    2224                 :            :                             static_cast<SCCOL>(nEnd),MAXROW,nTab,
    2225                 :          0 :                             HASATTR_MERGED | HASATTR_OVERLAPPED ))
    2226                 :          0 :                     nStart = 0;
    2227         [ #  # ]:          0 :                 if (nStart > 0)             // go upwards because of Lines and cursor
    2228                 :          0 :                     --nStart;
    2229                 :            :                 pDocSh->PostPaint( static_cast<SCCOL>(nStart), 0, nTab,
    2230         [ #  # ]:          0 :                         MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_TOP );
    2231                 :            :             }
    2232                 :            :             else
    2233                 :            :             {
    2234 [ #  # ][ #  # ]:          0 :                 if (pDoc->HasAttrib( 0,nStart,nTab, MAXCOL,nEnd,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ))
    2235                 :          0 :                     nStart = 0;
    2236         [ #  # ]:          0 :                 if (nStart != 0)
    2237                 :          0 :                     --nStart;
    2238         [ #  # ]:          0 :                 pDocSh->PostPaint( 0, nStart, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_LEFT );
    2239                 :            :             }
    2240                 :            :         }
    2241                 :            : 
    2242         [ #  # ]:          0 :         pDocSh->UpdateOle(GetViewData());
    2243 [ #  # ][ #  # ]:          0 :         if( !pDocSh->IsReadOnly() )
    2244         [ #  # ]:          0 :         aModificator.SetDocumentModified();
    2245                 :            :     }
    2246                 :            : 
    2247                 :            :     // #i97876# Spreadsheet data changes are not notified
    2248         [ #  # ]:          0 :     if ( bWidth )
    2249                 :            :     {
    2250 [ #  # ][ #  # ]:          0 :         ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
    2251 [ #  # ][ #  # ]:          0 :         if ( pModelObj && pModelObj->HasChangesListeners() )
         [ #  # ][ #  # ]
    2252                 :            :         {
    2253         [ #  # ]:          0 :             ScRangeList aChangeRanges;
    2254         [ #  # ]:          0 :             itr = pMarkData->begin();
    2255 [ #  # ][ #  # ]:          0 :             for (; itr != itrEnd; ++itr)
                 [ #  # ]
    2256                 :            :             {
    2257         [ #  # ]:          0 :                 nTab = *itr;
    2258                 :          0 :                 const SCCOLROW* pTabRanges = pRanges;
    2259         [ #  # ]:          0 :                 for ( SCCOLROW nRange = 0; nRange < nRangeCnt; ++nRange )
    2260                 :            :                 {
    2261                 :          0 :                     SCCOL nStartCol = static_cast< SCCOL >( *(pTabRanges++) );
    2262                 :          0 :                     SCCOL nEndCol = static_cast< SCCOL >( *(pTabRanges++) );
    2263         [ #  # ]:          0 :                     for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
    2264                 :            :                     {
    2265         [ #  # ]:          0 :                         aChangeRanges.Append( ScRange( nCol, 0, nTab ) );
    2266                 :            :                     }
    2267                 :            :                 }
    2268                 :            :             }
    2269 [ #  # ][ #  # ]:          0 :             pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "column-resize" ) ), aChangeRanges );
         [ #  # ][ #  # ]
                 [ #  # ]
    2270                 :            :         }
    2271 [ #  # ][ #  # ]:          0 :     }
    2272                 :            : }
    2273                 :            : 
    2274                 :            : //  column width/row height (via marked range)
    2275                 :            : 
    2276                 :          0 : void ScViewFunc::SetMarkedWidthOrHeight( sal_Bool bWidth, ScSizeMode eMode, sal_uInt16 nSizeTwips,
    2277                 :            :                                         sal_Bool bRecord, sal_Bool bPaint )
    2278                 :            : {
    2279                 :          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
    2280                 :            : 
    2281                 :          0 :     rMark.MarkToMulti();
    2282         [ #  # ]:          0 :     if (!rMark.IsMultiMarked())
    2283                 :            :     {
    2284                 :          0 :         SCCOL nCol = GetViewData()->GetCurX();
    2285                 :          0 :         SCROW nRow = GetViewData()->GetCurY();
    2286                 :          0 :         SCTAB nTab = GetViewData()->GetTabNo();
    2287                 :          0 :         DoneBlockMode();
    2288                 :          0 :         InitOwnBlockMode();
    2289         [ #  # ]:          0 :         rMark.SetMultiMarkArea( ScRange( nCol,nRow,nTab ), sal_True );
    2290                 :          0 :         MarkDataChanged();
    2291                 :            :     }
    2292                 :            : 
    2293                 :          0 :     SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT];
    2294                 :          0 :     SCCOLROW nRangeCnt = 0;
    2295                 :            : 
    2296         [ #  # ]:          0 :     if ( bWidth )
    2297                 :          0 :         nRangeCnt = rMark.GetMarkColumnRanges( pRanges );
    2298                 :            :     else
    2299                 :          0 :         nRangeCnt = rMark.GetMarkRowRanges( pRanges );
    2300                 :            : 
    2301                 :          0 :     SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nSizeTwips, bRecord, bPaint );
    2302                 :            : 
    2303         [ #  # ]:          0 :     delete[] pRanges;
    2304                 :          0 :     rMark.MarkToSimple();
    2305                 :          0 : }
    2306                 :            : 
    2307                 :          0 : void ScViewFunc::ModifyCellSize( ScDirection eDir, sal_Bool bOptimal )
    2308                 :            : {
    2309                 :            :     //! step size adjustable
    2310                 :            :     //  step size is also minumum
    2311                 :          0 :     sal_uInt16 nStepX = STD_COL_WIDTH / 5;
    2312                 :          0 :     sal_uInt16 nStepY = ScGlobal::nStdRowHeight;
    2313                 :            : 
    2314         [ #  # ]:          0 :     ScModule* pScMod = SC_MOD();
    2315         [ #  # ]:          0 :     sal_Bool bAnyEdit = pScMod->IsInputMode();
    2316                 :          0 :     SCCOL nCol = GetViewData()->GetCurX();
    2317                 :          0 :     SCROW nRow = GetViewData()->GetCurY();
    2318                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    2319                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2320                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    2321                 :            : 
    2322                 :            :     bool bAllowed, bOnlyMatrix;
    2323 [ #  # ][ #  # ]:          0 :     if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
    2324         [ #  # ]:          0 :         bAllowed = pDoc->IsBlockEditable( nTab, nCol,0, nCol,MAXROW, &bOnlyMatrix );
    2325                 :            :     else
    2326         [ #  # ]:          0 :         bAllowed = pDoc->IsBlockEditable( nTab, 0,nRow, MAXCOL,nRow, &bOnlyMatrix );
    2327 [ #  # ][ #  # ]:          0 :     if ( !bAllowed && !bOnlyMatrix )
    2328                 :            :     {
    2329         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    2330                 :          0 :         return;
    2331                 :            :     }
    2332                 :            : 
    2333         [ #  # ]:          0 :     HideAllCursors();
    2334                 :            : 
    2335         [ #  # ]:          0 :     sal_uInt16 nWidth = pDoc->GetColWidth( nCol, nTab );
    2336         [ #  # ]:          0 :     sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTab );
    2337                 :            :     SCCOLROW nRange[2];
    2338 [ #  # ][ #  # ]:          0 :     if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
    2339                 :            :     {
    2340         [ #  # ]:          0 :         if (bOptimal)               // width of this single cell
    2341                 :            :         {
    2342         [ #  # ]:          0 :             if ( bAnyEdit )
    2343                 :            :             {
    2344                 :            :                 //  when editing the actual entered width
    2345         [ #  # ]:          0 :                 ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData()->GetViewShell() );
    2346         [ #  # ]:          0 :                 if (pHdl)
    2347                 :            :                 {
    2348         [ #  # ]:          0 :                     long nEdit = pHdl->GetTextSize().Width();       // in 0.01 mm
    2349                 :            : 
    2350         [ #  # ]:          0 :                     const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
    2351                 :            :                     const SvxMarginItem& rMItem =
    2352         [ #  # ]:          0 :                             (const SvxMarginItem&)pPattern->GetItem(ATTR_MARGIN);
    2353                 :          0 :                     sal_uInt16 nMargin = rMItem.GetLeftMargin() + rMItem.GetRightMargin();
    2354         [ #  # ]:          0 :                     if ( ((const SvxHorJustifyItem&) pPattern->
    2355         [ #  # ]:          0 :                             GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_LEFT )
    2356                 :            :                         nMargin = sal::static_int_cast<sal_uInt16>(
    2357         [ #  # ]:          0 :                             nMargin + ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue() );
    2358                 :            : 
    2359         [ #  # ]:          0 :                     nWidth = (sal_uInt16)(nEdit * pDocSh->GetOutputFactor() / HMM_PER_TWIPS)
    2360                 :          0 :                                 + nMargin + STD_EXTRA_WIDTH;
    2361                 :            :                 }
    2362                 :            :             }
    2363                 :            :             else
    2364                 :            :             {
    2365                 :          0 :                 double nPPTX = GetViewData()->GetPPTX();
    2366                 :          0 :                 double nPPTY = GetViewData()->GetPPTY();
    2367         [ #  # ]:          0 :                 Fraction aZoomX = GetViewData()->GetZoomX();
    2368         [ #  # ]:          0 :                 Fraction aZoomY = GetViewData()->GetZoomY();
    2369                 :            : 
    2370         [ #  # ]:          0 :                 ScSizeDeviceProvider aProv(pDocSh);
    2371         [ #  # ]:          0 :                 if (aProv.IsPrinter())
    2372                 :            :                 {
    2373                 :          0 :                     nPPTX = aProv.GetPPTX();
    2374                 :          0 :                     nPPTY = aProv.GetPPTY();
    2375 [ #  # ][ #  # ]:          0 :                     aZoomX = aZoomY = Fraction( 1, 1 );
                 [ #  # ]
    2376                 :            :                 }
    2377                 :            : 
    2378                 :            :                 long nPixel = pDoc->GetNeededSize( nCol, nRow, nTab, aProv.GetDevice(),
    2379         [ #  # ]:          0 :                                             nPPTX, nPPTY, aZoomX, aZoomY, sal_True );
    2380                 :          0 :                 sal_uInt16 nTwips = (sal_uInt16)( nPixel / nPPTX );
    2381         [ #  # ]:          0 :                 if (nTwips != 0)
    2382                 :          0 :                     nWidth = nTwips + STD_EXTRA_WIDTH;
    2383                 :            :                 else
    2384         [ #  # ]:          0 :                     nWidth = STD_COL_WIDTH;
    2385                 :            :             }
    2386                 :            :         }
    2387                 :            :         else                        // increment / decrement
    2388                 :            :         {
    2389         [ #  # ]:          0 :             if ( eDir == DIR_RIGHT )
    2390                 :          0 :                 nWidth = sal::static_int_cast<sal_uInt16>( nWidth + nStepX );
    2391         [ #  # ]:          0 :             else if ( nWidth > nStepX )
    2392                 :          0 :                 nWidth = sal::static_int_cast<sal_uInt16>( nWidth - nStepX );
    2393         [ #  # ]:          0 :             if ( nWidth < nStepX ) nWidth = nStepX;
    2394         [ #  # ]:          0 :             if ( nWidth > MAX_COL_WIDTH ) nWidth = MAX_COL_WIDTH;
    2395                 :            :         }
    2396                 :          0 :         nRange[0] = nRange[1] = nCol;
    2397         [ #  # ]:          0 :         SetWidthOrHeight( sal_True, 1, nRange, SC_SIZE_DIRECT, nWidth );
    2398                 :            : 
    2399                 :            :         //  adjust height of this row if width demands/allows this
    2400                 :            : 
    2401         [ #  # ]:          0 :         if (!bAnyEdit)
    2402                 :            :         {
    2403         [ #  # ]:          0 :             const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
    2404                 :            :             sal_Bool bNeedHeight =
    2405         [ #  # ]:          0 :                     ((const SfxBoolItem&)pPattern->GetItem( ATTR_LINEBREAK )).GetValue() ||
    2406                 :            :                     ((const SvxHorJustifyItem&)pPattern->
    2407 [ #  # ][ #  # ]:          0 :                         GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK;
                 [ #  # ]
    2408         [ #  # ]:          0 :             if (bNeedHeight)
    2409         [ #  # ]:          0 :                 AdjustRowHeight( nRow, nRow );
    2410                 :          0 :         }
    2411                 :            :     }
    2412                 :            :     else
    2413                 :            :     {
    2414                 :            :         ScSizeMode eMode;
    2415         [ #  # ]:          0 :         if (bOptimal)
    2416                 :            :         {
    2417                 :          0 :             eMode = SC_SIZE_OPTIMAL;
    2418                 :          0 :             nHeight = 0;
    2419                 :            :         }
    2420                 :            :         else
    2421                 :            :         {
    2422                 :          0 :             eMode = SC_SIZE_DIRECT;
    2423         [ #  # ]:          0 :             if ( eDir == DIR_BOTTOM )
    2424                 :          0 :                 nHeight = sal::static_int_cast<sal_uInt16>( nHeight + nStepY );
    2425         [ #  # ]:          0 :             else if ( nHeight > nStepY )
    2426                 :          0 :                 nHeight = sal::static_int_cast<sal_uInt16>( nHeight - nStepY );
    2427         [ #  # ]:          0 :             if ( nHeight < nStepY ) nHeight = nStepY;
    2428         [ #  # ]:          0 :             if ( nHeight > MAX_ROW_HEIGHT ) nHeight = MAX_ROW_HEIGHT;
    2429                 :            :         }
    2430                 :          0 :         nRange[0] = nRange[1] = nRow;
    2431         [ #  # ]:          0 :         SetWidthOrHeight( false, 1, nRange, eMode, nHeight );
    2432                 :            :     }
    2433                 :            : 
    2434         [ #  # ]:          0 :     if ( bAnyEdit )
    2435                 :            :     {
    2436         [ #  # ]:          0 :         UpdateEditView();
    2437 [ #  # ][ #  # ]:          0 :         if ( pDoc->HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_NEEDHEIGHT ) )
    2438                 :            :         {
    2439         [ #  # ]:          0 :             ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData()->GetViewShell() );
    2440         [ #  # ]:          0 :             if (pHdl)
    2441                 :          0 :                 pHdl->SetModified();    // so that the height is adjusted with Enter
    2442                 :            :         }
    2443                 :            :     }
    2444                 :            : 
    2445         [ #  # ]:          0 :     ShowAllCursors();
    2446                 :            : }
    2447                 :            : 
    2448                 :          0 : void ScViewFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect )
    2449                 :            : {
    2450         [ #  # ]:          0 :     if (nTab == TABLEID_DOC)
    2451                 :          0 :         return;
    2452                 :            : 
    2453         [ #  # ]:          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
    2454                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2455                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    2456                 :          0 :     ScDocFunc &rFunc = pDocSh->GetDocFunc();
    2457                 :          0 :     bool bUndo(pDoc->IsUndoEnabled());
    2458                 :            : 
    2459                 :            :     //  modifying several tabs is handled here
    2460                 :            : 
    2461         [ #  # ]:          0 :     if (bUndo)
    2462                 :            :     {
    2463 [ #  # ][ #  # ]:          0 :         String aUndo = ScGlobal::GetRscString( STR_UNDO_PROTECT_TAB );
    2464 [ #  # ][ #  # ]:          0 :         pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
                 [ #  # ]
    2465                 :            :     }
    2466                 :            : 
    2467 [ #  # ][ #  # ]:          0 :     ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
    2468 [ #  # ][ #  # ]:          0 :     for (; itr != itrEnd; ++itr)
                 [ #  # ]
    2469 [ #  # ][ #  # ]:          0 :         rFunc.ProtectSheet(*itr, rProtect);
    2470                 :            : 
    2471         [ #  # ]:          0 :     if (bUndo)
    2472 [ #  # ][ #  # ]:          0 :         pDocSh->GetUndoManager()->LeaveListAction();
    2473                 :            : 
    2474         [ #  # ]:          0 :     UpdateLayerLocks();         //! broadcast to all views
    2475                 :            : }
    2476                 :            : 
    2477                 :          0 : void ScViewFunc::Protect( SCTAB nTab, const String& rPassword )
    2478                 :            : {
    2479                 :          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
    2480                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2481                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    2482                 :          0 :     ScDocFunc &rFunc = pDocSh->GetDocFunc();
    2483                 :          0 :     sal_Bool bUndo(pDoc->IsUndoEnabled());
    2484                 :            : 
    2485 [ #  # ][ #  # ]:          0 :     if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 )
                 [ #  # ]
    2486                 :          0 :         rFunc.Protect( nTab, rPassword, false );
    2487                 :            :     else
    2488                 :            :     {
    2489                 :            :         //  modifying several tabs is handled here
    2490                 :            : 
    2491         [ #  # ]:          0 :         if (bUndo)
    2492                 :            :         {
    2493 [ #  # ][ #  # ]:          0 :             String aUndo = ScGlobal::GetRscString( STR_UNDO_PROTECT_TAB );
    2494 [ #  # ][ #  # ]:          0 :             pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
                 [ #  # ]
    2495                 :            :         }
    2496                 :            : 
    2497 [ #  # ][ #  # ]:          0 :         ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
    2498 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    2499 [ #  # ][ #  # ]:          0 :             rFunc.Protect( *itr, rPassword, false );
    2500                 :            : 
    2501         [ #  # ]:          0 :         if (bUndo)
    2502 [ #  # ][ #  # ]:          0 :             pDocSh->GetUndoManager()->LeaveListAction();
    2503                 :            :     }
    2504                 :            : 
    2505                 :          0 :     UpdateLayerLocks();         //! broadcast to all views
    2506                 :          0 : }
    2507                 :            : 
    2508                 :          0 : sal_Bool ScViewFunc::Unprotect( SCTAB nTab, const String& rPassword )
    2509                 :            : {
    2510                 :          0 :     ScMarkData& rMark = GetViewData()->GetMarkData();
    2511                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2512                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    2513                 :          0 :     ScDocFunc &rFunc = pDocSh->GetDocFunc();
    2514                 :          0 :     sal_Bool bChanged = false;
    2515                 :          0 :     sal_Bool bUndo (pDoc->IsUndoEnabled());
    2516                 :            : 
    2517 [ #  # ][ #  # ]:          0 :     if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 )
                 [ #  # ]
    2518                 :          0 :         bChanged = rFunc.Unprotect( nTab, rPassword, false );
    2519                 :            :     else
    2520                 :            :     {
    2521                 :            :         //  modifying several tabs is handled here
    2522                 :            : 
    2523         [ #  # ]:          0 :         if (bUndo)
    2524                 :            :         {
    2525 [ #  # ][ #  # ]:          0 :             String aUndo = ScGlobal::GetRscString( STR_UNDO_UNPROTECT_TAB );
    2526 [ #  # ][ #  # ]:          0 :             pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
                 [ #  # ]
    2527                 :            :         }
    2528                 :            : 
    2529 [ #  # ][ #  # ]:          0 :         ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
    2530 [ #  # ][ #  # ]:          0 :         for (; itr != itrEnd; ++itr)
                 [ #  # ]
    2531 [ #  # ][ #  # ]:          0 :             if ( rFunc.Unprotect( *itr, rPassword, false ) )
                 [ #  # ]
    2532                 :          0 :                     bChanged = sal_True;
    2533                 :            : 
    2534         [ #  # ]:          0 :         if (bUndo)
    2535 [ #  # ][ #  # ]:          0 :             pDocSh->GetUndoManager()->LeaveListAction();
    2536                 :            :     }
    2537                 :            : 
    2538         [ #  # ]:          0 :     if (bChanged)
    2539                 :          0 :         UpdateLayerLocks();     //! broadcast to all views
    2540                 :            : 
    2541                 :          0 :     return bChanged;
    2542                 :            : }
    2543                 :            : 
    2544                 :          0 : void ScViewFunc::SetNoteText( const ScAddress& rPos, const String& rNoteText )
    2545                 :            : {
    2546                 :          0 :     GetViewData()->GetDocShell()->GetDocFunc().SetNoteText( rPos, rNoteText, false );
    2547                 :          0 : }
    2548                 :            : 
    2549                 :          0 : void ScViewFunc::ReplaceNote( const ScAddress& rPos, const String& rNoteText, const String* pAuthor, const String* pDate )
    2550                 :            : {
    2551                 :          0 :     GetViewData()->GetDocShell()->GetDocFunc().ReplaceNote( rPos, rNoteText, pAuthor, pDate, false );
    2552                 :          0 : }
    2553                 :            : 
    2554                 :          0 : void ScViewFunc::SetNumberFormat( short nFormatType, sal_uLong nAdd )
    2555                 :            : {
    2556                 :            :     // not editable because of matrix only? attribute OK nonetheless
    2557                 :            :     bool bOnlyNotBecauseOfMatrix;
    2558 [ #  # ][ #  # ]:          0 :     if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
         [ #  # ][ #  # ]
    2559                 :            :     {
    2560         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    2561                 :          0 :         return;
    2562                 :            :     }
    2563                 :            : 
    2564                 :          0 :     sal_uInt32          nNumberFormat = 0;
    2565                 :          0 :     ScViewData*         pViewData = GetViewData();
    2566         [ #  # ]:          0 :     ScDocument*         pDoc = pViewData->GetDocument();
    2567         [ #  # ]:          0 :     SvNumberFormatter*  pNumberFormatter = pDoc->GetFormatTable();
    2568                 :          0 :     LanguageType        eLanguage = ScGlobal::eLnge;
    2569 [ #  # ][ #  # ]:          0 :     ScPatternAttr       aNewAttrs( pDoc->GetPool() );
    2570                 :            : 
    2571                 :            :     //  always take language from cursor position, even if there is a selection
    2572                 :            : 
    2573                 :            :     sal_uInt32 nCurrentNumberFormat;
    2574                 :          0 :     pDoc->GetNumberFormat( pViewData->GetCurX(),
    2575                 :            :                            pViewData->GetCurY(),
    2576                 :          0 :                            pViewData->GetTabNo(),
    2577         [ #  # ]:          0 :                            nCurrentNumberFormat );
    2578         [ #  # ]:          0 :     const SvNumberformat* pEntry = pNumberFormatter->GetEntry( nCurrentNumberFormat );
    2579         [ #  # ]:          0 :     if (pEntry)
    2580                 :          0 :         eLanguage = pEntry->GetLanguage();      // else keep ScGlobal::eLnge
    2581                 :            : 
    2582         [ #  # ]:          0 :     nNumberFormat = pNumberFormatter->GetStandardFormat( nFormatType, eLanguage ) + nAdd;
    2583                 :            : 
    2584                 :          0 :     SfxItemSet& rSet = aNewAttrs.GetItemSet();
    2585 [ #  # ][ #  # ]:          0 :     rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) );
                 [ #  # ]
    2586                 :            :     //  ATTR_LANGUAGE_FORMAT not
    2587 [ #  # ][ #  # ]:          0 :     ApplySelectionPattern( aNewAttrs, sal_True );
    2588                 :            : }
    2589                 :            : 
    2590                 :          0 : void ScViewFunc::SetNumFmtByStr( const String& rCode )
    2591                 :            : {
    2592                 :            :     // not editable because of matrix only? attribute OK nonetheless
    2593                 :            :     bool bOnlyNotBecauseOfMatrix;
    2594 [ #  # ][ #  # ]:          0 :     if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
         [ #  # ][ #  # ]
    2595                 :            :     {
    2596         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    2597                 :          0 :         return;
    2598                 :            :     }
    2599                 :            : 
    2600                 :          0 :     ScViewData*         pViewData = GetViewData();
    2601         [ #  # ]:          0 :     ScDocument*         pDoc = pViewData->GetDocument();
    2602         [ #  # ]:          0 :     SvNumberFormatter*  pFormatter = pDoc->GetFormatTable();
    2603                 :            : 
    2604                 :            :     //  language always from cursor position
    2605                 :            : 
    2606                 :            :     sal_uInt32 nCurrentNumberFormat;
    2607                 :          0 :     pDoc->GetNumberFormat( pViewData->GetCurX(), pViewData->GetCurY(),
    2608         [ #  # ]:          0 :                            pViewData->GetTabNo(), nCurrentNumberFormat );
    2609         [ #  # ]:          0 :     const SvNumberformat* pEntry = pFormatter->GetEntry( nCurrentNumberFormat );
    2610         [ #  # ]:          0 :     LanguageType eLanguage = pEntry ? pEntry->GetLanguage() : ScGlobal::eLnge;
    2611                 :            : 
    2612                 :            :     //  determine index for String
    2613                 :            : 
    2614                 :          0 :     sal_Bool bOk = sal_True;
    2615         [ #  # ]:          0 :     sal_uInt32 nNumberFormat = pFormatter->GetEntryKey( rCode, eLanguage );
    2616         [ #  # ]:          0 :     if ( nNumberFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
    2617                 :            :     {
    2618                 :            :         //  enter new
    2619                 :            : 
    2620         [ #  # ]:          0 :         String      aFormat = rCode;    // will be changed
    2621                 :          0 :         xub_StrLen  nErrPos = 0;
    2622                 :          0 :         short       nType   = 0;        //! ???
    2623 [ #  # ][ #  # ]:          0 :         bOk = pFormatter->PutEntry( aFormat, nErrPos, nType, nNumberFormat, eLanguage );
    2624                 :            :     }
    2625                 :            : 
    2626         [ #  # ]:          0 :     if ( bOk )          // valid format?
    2627                 :            :     {
    2628 [ #  # ][ #  # ]:          0 :         ScPatternAttr aNewAttrs( pDoc->GetPool() );
    2629                 :          0 :         SfxItemSet& rSet = aNewAttrs.GetItemSet();
    2630 [ #  # ][ #  # ]:          0 :         rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) );
                 [ #  # ]
    2631 [ #  # ][ #  # ]:          0 :         rSet.Put( SvxLanguageItem( eLanguage, ATTR_LANGUAGE_FORMAT ) );
                 [ #  # ]
    2632 [ #  # ][ #  # ]:          0 :         ApplySelectionPattern( aNewAttrs, sal_True );
    2633                 :            :     }
    2634                 :            : 
    2635                 :            :     //! else return error / issue warning ???
    2636                 :            : }
    2637                 :            : 
    2638                 :          0 : void ScViewFunc::ChangeNumFmtDecimals( sal_Bool bIncrement )
    2639                 :            : {
    2640                 :            :     // not editable because of matrix only? attribute OK nonetheless
    2641                 :            :     bool bOnlyNotBecauseOfMatrix;
    2642 [ #  # ][ #  # ]:          0 :     if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
         [ #  # ][ #  # ]
    2643                 :            :     {
    2644         [ #  # ]:          0 :         ErrorMessage(STR_PROTECTIONERR);
    2645                 :            :         return;
    2646                 :            :     }
    2647                 :            : 
    2648         [ #  # ]:          0 :     ScDocument*         pDoc = GetViewData()->GetDocument();
    2649         [ #  # ]:          0 :     SvNumberFormatter*  pFormatter = pDoc->GetFormatTable();
    2650                 :            : 
    2651                 :          0 :     SCCOL nCol = GetViewData()->GetCurX();
    2652                 :          0 :     SCROW nRow = GetViewData()->GetCurY();
    2653                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    2654                 :            : 
    2655                 :            :     sal_uInt32 nOldFormat;
    2656         [ #  # ]:          0 :     pDoc->GetNumberFormat( nCol, nRow, nTab, nOldFormat );
    2657         [ #  # ]:          0 :     const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat );
    2658         [ #  # ]:          0 :     if (!pOldEntry)
    2659                 :            :     {
    2660                 :            :         OSL_FAIL("numberformat not found !!!");
    2661                 :            :         return;
    2662                 :            :     }
    2663                 :            : 
    2664                 :            :     //  what have we got here?
    2665                 :            : 
    2666                 :          0 :     sal_uInt32 nNewFormat = nOldFormat;
    2667                 :          0 :     sal_Bool bError = false;
    2668                 :            : 
    2669                 :          0 :     LanguageType eLanguage = pOldEntry->GetLanguage();
    2670                 :            :     bool bThousand, bNegRed;
    2671                 :            :     sal_uInt16 nPrecision, nLeading;
    2672         [ #  # ]:          0 :     pOldEntry->GetFormatSpecialInfo( bThousand, bNegRed, nPrecision, nLeading );
    2673                 :            : 
    2674                 :          0 :     short nOldType = pOldEntry->GetType();
    2675         [ #  # ]:          0 :     if ( 0 == ( nOldType & (
    2676                 :            :                 NUMBERFORMAT_NUMBER |  NUMBERFORMAT_CURRENCY | NUMBERFORMAT_PERCENT ) ) )
    2677                 :            :     {
    2678                 :            :         //  date, time, fraction, logical, text can not be changed
    2679                 :            :         //! in case of scientific the Numberformatter also can't
    2680                 :          0 :         bError = sal_True;
    2681                 :            :     }
    2682                 :            : 
    2683                 :            :     //! SvNumberformat has a Member bStandard, but doesn't disclose it
    2684         [ #  # ]:          0 :     sal_Bool bWasStandard = ( nOldFormat == pFormatter->GetStandardIndex( eLanguage ) );
    2685         [ #  # ]:          0 :     if (bWasStandard)
    2686                 :            :     {
    2687                 :            :         //  with "Standard" the decimal places depend on cell content
    2688                 :            :         //  0 if empty or text -> no decimal places
    2689         [ #  # ]:          0 :         double nVal = pDoc->GetValue( ScAddress( nCol, nRow, nTab ) );
    2690                 :            : 
    2691                 :            :         //  the ways of the Numberformatters are unfathomable, so try:
    2692         [ #  # ]:          0 :         String aOut;
    2693                 :            :         Color* pCol;
    2694         [ #  # ]:          0 :         ((SvNumberformat*)pOldEntry)->GetOutputString( nVal, aOut, &pCol );
    2695                 :            : 
    2696                 :          0 :         nPrecision = 0;
    2697                 :            :         // 'E' for exponential is fixed in Numberformatter
    2698 [ #  # ][ #  # ]:          0 :         if ( aOut.Search('E') != STRING_NOTFOUND )
    2699                 :          0 :             bError = sal_True;                              // exponential not changed
    2700                 :            :         else
    2701                 :            :         {
    2702         [ #  # ]:          0 :             String aDecSep( pFormatter->GetFormatDecimalSep( nOldFormat ) );
    2703         [ #  # ]:          0 :             xub_StrLen nPos = aOut.Search( aDecSep );
    2704         [ #  # ]:          0 :             if ( nPos != STRING_NOTFOUND )
    2705         [ #  # ]:          0 :                 nPrecision = aOut.Len() - nPos - aDecSep.Len();
    2706                 :            :             // else keep 0
    2707         [ #  # ]:          0 :         }
    2708                 :            :     }
    2709                 :            : 
    2710         [ #  # ]:          0 :     if (!bError)
    2711                 :            :     {
    2712         [ #  # ]:          0 :         if (bIncrement)
    2713                 :            :         {
    2714         [ #  # ]:          0 :             if (nPrecision<20)
    2715                 :          0 :                 ++nPrecision;           // increment
    2716                 :            :             else
    2717                 :          0 :                 bError = sal_True;          // 20 is maximum
    2718                 :            :         }
    2719                 :            :         else
    2720                 :            :         {
    2721         [ #  # ]:          0 :             if (nPrecision)
    2722                 :          0 :                 --nPrecision;           // decrement
    2723                 :            :             else
    2724                 :          0 :                 bError = sal_True;          // 0 is minumum
    2725                 :            :         }
    2726                 :            :     }
    2727                 :            : 
    2728         [ #  # ]:          0 :     if (!bError)
    2729                 :            :     {
    2730         [ #  # ]:          0 :         String aNewPicture;
    2731                 :            :         pFormatter->GenerateFormat( aNewPicture, nOldFormat, eLanguage,
    2732         [ #  # ]:          0 :                                     bThousand, bNegRed, nPrecision, nLeading );
    2733                 :            : 
    2734         [ #  # ]:          0 :         nNewFormat = pFormatter->GetEntryKey( aNewPicture, eLanguage );
    2735         [ #  # ]:          0 :         if ( nNewFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
    2736                 :            :         {
    2737                 :          0 :             xub_StrLen nErrPos = 0;
    2738                 :          0 :             short nNewType = 0;
    2739                 :            :             sal_Bool bOk = pFormatter->PutEntry( aNewPicture, nErrPos,
    2740         [ #  # ]:          0 :                                                 nNewType, nNewFormat, eLanguage );
    2741                 :            :             OSL_ENSURE( bOk, "incorrect numberformat generated" );
    2742         [ #  # ]:          0 :             if (!bOk)
    2743                 :          0 :                 bError = sal_True;
    2744         [ #  # ]:          0 :         }
    2745                 :            :     }
    2746                 :            : 
    2747         [ #  # ]:          0 :     if (!bError)
    2748                 :            :     {
    2749 [ #  # ][ #  # ]:          0 :         ScPatternAttr aNewAttrs( pDoc->GetPool() );
    2750                 :          0 :         SfxItemSet& rSet = aNewAttrs.GetItemSet();
    2751 [ #  # ][ #  # ]:          0 :         rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
                 [ #  # ]
    2752                 :            :         //  ATTR_LANGUAGE_FORMAT not
    2753 [ #  # ][ #  # ]:          0 :         ApplySelectionPattern( aNewAttrs, sal_True );
    2754                 :            :     }
    2755                 :            : }
    2756                 :            : 
    2757                 :          0 : void ScViewFunc::ChangeIndent( sal_Bool bIncrement )
    2758                 :            : {
    2759                 :          0 :     ScViewData* pViewData = GetViewData();
    2760                 :          0 :     ScDocShell* pDocSh  = pViewData->GetDocShell();
    2761         [ #  # ]:          0 :     ScMarkData& rMark   = pViewData->GetMarkData();
    2762                 :            : 
    2763         [ #  # ]:          0 :     ScMarkData aWorkMark = rMark;
    2764         [ #  # ]:          0 :     ScViewUtil::UnmarkFiltered( aWorkMark, pDocSh->GetDocument() );
    2765         [ #  # ]:          0 :     aWorkMark.MarkToMulti();
    2766         [ #  # ]:          0 :     if (!aWorkMark.IsMultiMarked())
    2767                 :            :     {
    2768                 :          0 :         SCCOL nCol = pViewData->GetCurX();
    2769                 :          0 :         SCROW nRow = pViewData->GetCurY();
    2770                 :          0 :         SCTAB nTab = pViewData->GetTabNo();
    2771         [ #  # ]:          0 :         aWorkMark.SetMultiMarkArea( ScRange(nCol,nRow,nTab) );
    2772                 :            :     }
    2773                 :            : 
    2774         [ #  # ]:          0 :     sal_Bool bSuccess = pDocSh->GetDocFunc().ChangeIndent( aWorkMark, bIncrement, false );
    2775         [ #  # ]:          0 :     if (bSuccess)
    2776                 :            :     {
    2777         [ #  # ]:          0 :         pDocSh->UpdateOle(pViewData);
    2778         [ #  # ]:          0 :         StartFormatArea();
    2779         [ #  # ]:          0 :     }
    2780                 :          0 : }
    2781                 :            : 
    2782                 :          0 : sal_Bool ScViewFunc::InsertName( const String& rName, const String& rSymbol,
    2783                 :            :                                 const String& rType )
    2784                 :            : {
    2785                 :            :     //  Type = P,R,C,F (and combinations)
    2786                 :            :     //! undo...
    2787                 :            : 
    2788                 :          0 :     sal_Bool bOk = false;
    2789                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2790                 :          0 :     ScDocument* pDoc = pDocSh->GetDocument();
    2791                 :          0 :     SCTAB nTab = GetViewData()->GetTabNo();
    2792         [ #  # ]:          0 :     ScRangeName* pList = pDoc->GetRangeName();
    2793                 :            : 
    2794                 :          0 :     RangeType nType = RT_NAME;
    2795                 :            :     ScRangeData* pNewEntry = new ScRangeData( pDoc, rName, rSymbol,
    2796                 :          0 :             ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
    2797 [ #  # ][ #  # ]:          0 :                 nTab), nType );
                 [ #  # ]
    2798         [ #  # ]:          0 :     String aUpType = rType;
    2799         [ #  # ]:          0 :     aUpType.ToUpperAscii();
    2800 [ #  # ][ #  # ]:          0 :     if ( aUpType.Search( 'P' ) != STRING_NOTFOUND )
    2801                 :          0 :         nType |= RT_PRINTAREA;
    2802 [ #  # ][ #  # ]:          0 :     if ( aUpType.Search( 'R' ) != STRING_NOTFOUND )
    2803                 :          0 :         nType |= RT_ROWHEADER;
    2804 [ #  # ][ #  # ]:          0 :     if ( aUpType.Search( 'C' ) != STRING_NOTFOUND )
    2805                 :          0 :         nType |= RT_COLHEADER;
    2806 [ #  # ][ #  # ]:          0 :     if ( aUpType.Search( 'F' ) != STRING_NOTFOUND )
    2807                 :          0 :         nType |= RT_CRITERIA;
    2808                 :          0 :     pNewEntry->AddType(nType);
    2809                 :            : 
    2810 [ #  # ][ #  # ]:          0 :     if ( !pNewEntry->GetErrCode() )     //  text valid?
    2811                 :            :     {
    2812         [ #  # ]:          0 :         ScDocShellModificator aModificator( *pDocSh );
    2813                 :            : 
    2814         [ #  # ]:          0 :         pDoc->CompileNameFormula( sal_True );   // CreateFormulaString
    2815                 :            : 
    2816                 :            :         // input available yet? Then remove beforehand (=change)
    2817 [ #  # ][ #  # ]:          0 :         ScRangeData* pData = pList->findByUpperName(ScGlobal::pCharClass->uppercase(rName));
                 [ #  # ]
    2818         [ #  # ]:          0 :         if (pData)
    2819                 :            :         {                                   // take old Index
    2820                 :          0 :             pNewEntry->SetIndex(pData->GetIndex());
    2821         [ #  # ]:          0 :             pList->erase(*pData);
    2822                 :            :         }
    2823                 :            : 
    2824 [ #  # ][ #  # ]:          0 :         if ( pList->insert( pNewEntry ) )
    2825                 :          0 :             bOk = sal_True;
    2826                 :          0 :         pNewEntry = NULL;   // never delete, insert took ownership
    2827                 :            : 
    2828         [ #  # ]:          0 :         pDoc->CompileNameFormula( false );  // CompileFormulaString
    2829         [ #  # ]:          0 :         aModificator.SetDocumentModified();
    2830 [ #  # ][ #  # ]:          0 :         SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2831                 :            :     }
    2832                 :            : 
    2833 [ #  # ][ #  # ]:          0 :     delete pNewEntry;       // if it wasn't inserted
    2834         [ #  # ]:          0 :     return bOk;
    2835                 :            : }
    2836                 :            : 
    2837                 :          0 : void ScViewFunc::CreateNames( sal_uInt16 nFlags )
    2838                 :            : {
    2839                 :          0 :     sal_Bool bDone = false;
    2840                 :          0 :     ScRange aRange;
    2841 [ #  # ][ #  # ]:          0 :     if ( GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE )
    2842         [ #  # ]:          0 :         bDone = GetViewData()->GetDocShell()->GetDocFunc().CreateNames( aRange, nFlags, false );
    2843                 :            : 
    2844         [ #  # ]:          0 :     if (!bDone)
    2845         [ #  # ]:          0 :         ErrorMessage(STR_CREATENAME_MARKERR);
    2846                 :          0 : }
    2847                 :            : 
    2848                 :          0 : sal_uInt16 ScViewFunc::GetCreateNameFlags()
    2849                 :            : {
    2850                 :          0 :     sal_uInt16 nFlags = 0;
    2851                 :            : 
    2852                 :            :     SCCOL nStartCol, nEndCol;
    2853                 :            :     SCROW nStartRow, nEndRow;
    2854                 :            :     SCTAB nDummy;
    2855 [ #  # ][ #  # ]:          0 :     if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nDummy,nEndCol,nEndRow,nDummy) == SC_MARK_SIMPLE)
    2856                 :            :     {
    2857         [ #  # ]:          0 :         ScDocument* pDoc = GetViewData()->GetDocument();
    2858                 :          0 :         SCTAB nTab = GetViewData()->GetTabNo();
    2859                 :            :         sal_Bool bOk;
    2860                 :            :         SCCOL i;
    2861                 :            :         SCROW j;
    2862                 :            : 
    2863                 :          0 :         bOk = sal_True;
    2864                 :          0 :         SCCOL nFirstCol = nStartCol;
    2865                 :          0 :         SCCOL nLastCol  = nEndCol;
    2866         [ #  # ]:          0 :         if (nStartCol+1 < nEndCol) { ++nFirstCol; --nLastCol; }
    2867 [ #  # ][ #  # ]:          0 :         for (i=nFirstCol; i<=nLastCol && bOk; i++)
                 [ #  # ]
    2868 [ #  # ][ #  # ]:          0 :             if (!pDoc->HasStringData( i,nStartRow,nTab ))
    2869                 :          0 :                 bOk = false;
    2870         [ #  # ]:          0 :         if (bOk)
    2871                 :          0 :             nFlags |= NAME_TOP;
    2872                 :            :         else                            // Bottom only if not Top
    2873                 :            :         {
    2874                 :          0 :             bOk = sal_True;
    2875 [ #  # ][ #  # ]:          0 :             for (i=nFirstCol; i<=nLastCol && bOk; i++)
                 [ #  # ]
    2876 [ #  # ][ #  # ]:          0 :                 if (!pDoc->HasStringData( i,nEndRow,nTab ))
    2877                 :          0 :                     bOk = false;
    2878         [ #  # ]:          0 :             if (bOk)
    2879                 :          0 :                 nFlags |= NAME_BOTTOM;
    2880                 :            :         }
    2881                 :            : 
    2882                 :          0 :         bOk = sal_True;
    2883                 :          0 :         SCROW nFirstRow = nStartRow;
    2884                 :          0 :         SCROW nLastRow  = nEndRow;
    2885         [ #  # ]:          0 :         if (nStartRow+1 < nEndRow) { ++nFirstRow; --nLastRow; }
    2886 [ #  # ][ #  # ]:          0 :         for (j=nFirstRow; j<=nLastRow && bOk; j++)
                 [ #  # ]
    2887 [ #  # ][ #  # ]:          0 :             if (!pDoc->HasStringData( nStartCol,j,nTab ))
    2888                 :          0 :                 bOk = false;
    2889         [ #  # ]:          0 :         if (bOk)
    2890                 :          0 :             nFlags |= NAME_LEFT;
    2891                 :            :         else                            // Right only if not Left
    2892                 :            :         {
    2893                 :          0 :             bOk = sal_True;
    2894 [ #  # ][ #  # ]:          0 :             for (j=nFirstRow; j<=nLastRow && bOk; j++)
                 [ #  # ]
    2895 [ #  # ][ #  # ]:          0 :                 if (!pDoc->HasStringData( nEndCol,j,nTab ))
    2896                 :          0 :                     bOk = false;
    2897         [ #  # ]:          0 :             if (bOk)
    2898                 :          0 :                 nFlags |= NAME_RIGHT;
    2899                 :            :         }
    2900                 :            :     }
    2901                 :            : 
    2902         [ #  # ]:          0 :     if (nStartCol == nEndCol)
    2903                 :          0 :         nFlags &= ~( NAME_LEFT | NAME_RIGHT );
    2904         [ #  # ]:          0 :     if (nStartRow == nEndRow)
    2905                 :          0 :         nFlags &= ~( NAME_TOP | NAME_BOTTOM );
    2906                 :            : 
    2907                 :          0 :     return nFlags;
    2908                 :            : }
    2909                 :            : 
    2910                 :          0 : void ScViewFunc::InsertNameList()
    2911                 :            : {
    2912                 :          0 :     ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
    2913                 :          0 :     ScDocShell* pDocSh = GetViewData()->GetDocShell();
    2914 [ #  # ][ #  # ]:          0 :     if ( pDocSh->GetDocFunc().InsertNameList( aPos, false ) )
    2915         [ #  # ]:          0 :         pDocSh->UpdateOle(GetViewData());
    2916                 :          0 : }
    2917                 :            : 
    2918                 :            : 
    2919                 :            : 
    2920                 :            : 
    2921                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10