LCOV - code coverage report
Current view: top level - sc/source/ui/docshell - olinefun.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 320 416 76.9 %
Date: 2014-04-11 Functions: 10 11 90.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sfx2/bindings.hxx>
      21             : 
      22             : #include "olinefun.hxx"
      23             : 
      24             : #include "docsh.hxx"
      25             : #include "olinetab.hxx"
      26             : #include "undodat.hxx"
      27             : #include "globstr.hrc"
      28             : #include "sc.hrc"
      29             : 
      30             : 
      31          61 : static void lcl_InvalidateOutliner( SfxBindings* pBindings )
      32             : {
      33          61 :     if ( pBindings )
      34             :     {
      35          61 :         pBindings->Invalidate( SID_OUTLINE_SHOW );
      36          61 :         pBindings->Invalidate( SID_OUTLINE_HIDE );
      37          61 :         pBindings->Invalidate( SID_OUTLINE_REMOVE );
      38             : 
      39          61 :         pBindings->Invalidate( SID_STATUS_SUM );            // wegen ein-/ausblenden
      40          61 :         pBindings->Invalidate( SID_ATTR_SIZE );
      41             :     }
      42          61 : }
      43             : 
      44             : //! PaintWidthHeight zur DocShell verschieben?
      45             : 
      46           1 : static void lcl_PaintWidthHeight( ScDocShell& rDocShell, SCTAB nTab,
      47             :                                     sal_Bool bColumns, SCCOLROW nStart, SCCOLROW nEnd )
      48             : {
      49           1 :     ScDocument* pDoc = rDocShell.GetDocument();
      50             : 
      51           1 :     sal_uInt16 nParts = PAINT_GRID;
      52           1 :     SCCOL nStartCol = 0;
      53           1 :     SCROW nStartRow = 0;
      54           1 :     SCCOL nEndCol = MAXCOL;         // fuer Test auf Merge
      55           1 :     SCROW nEndRow = MAXROW;
      56           1 :     if ( bColumns )
      57             :     {
      58           1 :         nParts |= PAINT_TOP;
      59           1 :         nStartCol = static_cast<SCCOL>(nStart);
      60           1 :         nEndCol = static_cast<SCCOL>(nEnd);
      61             :     }
      62             :     else
      63             :     {
      64           0 :         nParts |= PAINT_LEFT;
      65           0 :         nStartRow = nStart;
      66           0 :         nEndRow = nEnd;
      67             :     }
      68           1 :     if (pDoc->HasAttrib( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
      69           1 :                             HASATTR_MERGED | HASATTR_OVERLAPPED ))
      70             :     {
      71           0 :         nStartCol = 0;
      72           0 :         nStartRow = 0;
      73             :     }
      74           1 :     rDocShell.PostPaint( nStartCol,nStartRow,nTab, MAXCOL,MAXROW,nTab, nParts );
      75           1 : }
      76             : 
      77           8 : bool ScOutlineDocFunc::MakeOutline( const ScRange& rRange, bool bColumns, bool bRecord, bool bApi )
      78             : {
      79           8 :     bool bSuccess = false;
      80           8 :     SCCOL nStartCol = rRange.aStart.Col();
      81           8 :     SCROW nStartRow = rRange.aStart.Row();
      82           8 :     SCCOL nEndCol = rRange.aEnd.Col();
      83           8 :     SCROW nEndRow = rRange.aEnd.Row();
      84           8 :     SCTAB nTab = rRange.aStart.Tab();
      85             : 
      86           8 :     ScDocument* pDoc = rDocShell.GetDocument();
      87           8 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab, true );
      88           8 :     ScOutlineTable* pUndoTab = NULL;
      89             : 
      90           8 :     if (bRecord && !pDoc->IsUndoEnabled())
      91           0 :         bRecord = false;
      92             : 
      93           8 :     if (bRecord)
      94           8 :         pUndoTab = new ScOutlineTable( *pTable );
      95             : 
      96           8 :     ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
      97             : 
      98             :     bool bRes;
      99           8 :     bool bSize = false;
     100           8 :     if ( bColumns )
     101           2 :         bRes = pArray->Insert( nStartCol, nEndCol, bSize );
     102             :     else
     103           6 :         bRes = pArray->Insert( nStartRow, nEndRow, bSize );
     104             : 
     105           8 :     if ( bRes )
     106             :     {
     107           8 :         if (bRecord)
     108             :         {
     109           8 :             rDocShell.GetUndoManager()->AddUndoAction(
     110             :                 new ScUndoMakeOutline( &rDocShell,
     111             :                                         nStartCol,nStartRow,nTab,nEndCol,nEndRow,nTab,
     112           8 :                                         pUndoTab, bColumns, true ) );
     113             :         }
     114             : 
     115           8 :         if (pDoc->IsStreamValid(nTab))
     116           0 :             pDoc->SetStreamValid(nTab, false);
     117             : 
     118           8 :         sal_uInt16 nParts = 0;              // Datenbereich nicht geaendert
     119           8 :         if ( bColumns )
     120           2 :             nParts |= PAINT_TOP;
     121             :         else
     122           6 :             nParts |= PAINT_LEFT;
     123           8 :         if ( bSize )
     124           4 :             nParts |= PAINT_SIZE;
     125             : 
     126           8 :         rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, nParts );
     127           8 :         rDocShell.SetDocumentModified();
     128           8 :         lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     129           8 :         bSuccess = true;
     130             :     }
     131             :     else
     132             :     {
     133           0 :         if (!bApi)
     134           0 :             rDocShell.ErrorMessage(STR_MSSG_MAKEOUTLINE_0); // "Gruppierung nicht moeglich"
     135           0 :         delete pUndoTab;
     136             :     }
     137             : 
     138           8 :     return bSuccess;
     139             : }
     140             : 
     141           4 : bool ScOutlineDocFunc::RemoveOutline( const ScRange& rRange, bool bColumns, bool bRecord, bool bApi )
     142             : {
     143           4 :     bool bDone = false;
     144             : 
     145           4 :     SCCOL nStartCol = rRange.aStart.Col();
     146           4 :     SCROW nStartRow = rRange.aStart.Row();
     147           4 :     SCCOL nEndCol = rRange.aEnd.Col();
     148           4 :     SCROW nEndRow = rRange.aEnd.Row();
     149           4 :     SCTAB nTab = rRange.aStart.Tab();
     150             : 
     151           4 :     ScDocument* pDoc = rDocShell.GetDocument();
     152             : 
     153           4 :     if (bRecord && !pDoc->IsUndoEnabled())
     154           0 :         bRecord = false;
     155           4 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     156           4 :     if (pTable)
     157             :     {
     158           4 :         ScOutlineTable* pUndoTab = NULL;
     159           4 :         if (bRecord)
     160           4 :             pUndoTab = new ScOutlineTable( *pTable );
     161             : 
     162           4 :         ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
     163             : 
     164             :         bool bRes;
     165           4 :         bool bSize = false;
     166           4 :         if ( bColumns )
     167           1 :             bRes = pArray->Remove( nStartCol, nEndCol, bSize );
     168             :         else
     169           3 :             bRes = pArray->Remove( nStartRow, nEndRow, bSize );
     170             : 
     171           4 :         if ( bRes )
     172             :         {
     173           4 :             if (bRecord)
     174             :             {
     175           4 :                 rDocShell.GetUndoManager()->AddUndoAction(
     176             :                     new ScUndoMakeOutline( &rDocShell,
     177             :                                             nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
     178           4 :                                             pUndoTab, bColumns, false ) );
     179             :             }
     180             : 
     181           4 :             if (pDoc->IsStreamValid(nTab))
     182           0 :                 pDoc->SetStreamValid(nTab, false);
     183             : 
     184           4 :             sal_uInt16 nParts = 0;              // Datenbereich nicht geaendert
     185           4 :             if ( bColumns )
     186           1 :                 nParts |= PAINT_TOP;
     187             :             else
     188           3 :                 nParts |= PAINT_LEFT;
     189           4 :             if ( bSize )
     190           2 :                 nParts |= PAINT_SIZE;
     191             : 
     192           4 :             rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, nParts );
     193           4 :             rDocShell.SetDocumentModified();
     194           4 :             bDone = true;
     195           4 :             lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     196             : 
     197             :             // es wird nicht wieder eingeblendet -> kein UpdatePageBreaks
     198             :         }
     199             :         else
     200           0 :             delete pUndoTab;
     201             :     }
     202             : 
     203           4 :     if (!bDone && !bApi)
     204           0 :         rDocShell.ErrorMessage(STR_MSSG_REMOVEOUTLINE_0);   // "Aufheben nicht moeglich"
     205             : 
     206           4 :     return bDone;
     207             : }
     208             : 
     209           7 : bool ScOutlineDocFunc::RemoveAllOutlines( SCTAB nTab, bool bRecord )
     210             : {
     211           7 :     sal_Bool bSuccess = false;
     212           7 :     ScDocument* pDoc = rDocShell.GetDocument();
     213             : 
     214           7 :     if (bRecord && !pDoc->IsUndoEnabled())
     215           0 :         bRecord = false;
     216           7 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     217           7 :     if (pTable)
     218             :     {
     219           4 :         if (bRecord)
     220             :         {
     221             :             SCCOLROW nCol1, nCol2, nRow1, nRow2;
     222           4 :             pTable->GetColArray()->GetRange( nCol1, nCol2 );
     223           4 :             pTable->GetRowArray()->GetRange( nRow1, nRow2 );
     224           4 :             SCCOL nStartCol = static_cast<SCCOL>(nCol1);
     225           4 :             SCROW nStartRow = nRow1;
     226           4 :             SCCOL nEndCol = static_cast<SCCOL>(nCol2);
     227           4 :             SCROW nEndRow = nRow2;
     228             : 
     229           4 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     230           4 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, true, true );
     231           4 :             pDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, false, pUndoDoc );
     232           4 :             pDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, false, pUndoDoc );
     233             : 
     234           4 :             ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
     235             : 
     236           4 :             rDocShell.GetUndoManager()->AddUndoAction(
     237             :                 new ScUndoRemoveAllOutlines( &rDocShell,
     238             :                                                 nStartCol, nStartRow, nTab,
     239             :                                                 nEndCol, nEndRow, nTab,
     240           4 :                                                 pUndoDoc, pUndoTab ) );
     241             :         }
     242             : 
     243           4 :         SelectLevel( nTab, true,  pTable->GetColArray()->GetDepth(), false, false );
     244           4 :         SelectLevel( nTab, false, pTable->GetRowArray()->GetDepth(), false, false );
     245           4 :         pDoc->SetOutlineTable( nTab, NULL );
     246             : 
     247           4 :         pDoc->UpdatePageBreaks( nTab );
     248             : 
     249           4 :         if (pDoc->IsStreamValid(nTab))
     250           0 :             pDoc->SetStreamValid(nTab, false);
     251             : 
     252             :         rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
     253           4 :                                     PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
     254           4 :         rDocShell.SetDocumentModified();
     255           4 :         lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     256           4 :         bSuccess = sal_True;
     257             :     }
     258             : 
     259           7 :     return bSuccess;
     260             : }
     261             : 
     262           1 : bool ScOutlineDocFunc::AutoOutline( const ScRange& rRange, bool bRecord )
     263             : {
     264           1 :     SCCOL nStartCol = rRange.aStart.Col();
     265           1 :     SCROW nStartRow = rRange.aStart.Row();
     266           1 :     SCCOL nEndCol = rRange.aEnd.Col();
     267           1 :     SCROW nEndRow = rRange.aEnd.Row();
     268           1 :     SCTAB nTab = rRange.aStart.Tab();
     269             : 
     270           1 :     ScDocument* pDoc = rDocShell.GetDocument();
     271             : 
     272           1 :     if (bRecord && !pDoc->IsUndoEnabled())
     273           0 :         bRecord = false;
     274           1 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     275             : 
     276           1 :     ScDocument* pUndoDoc = NULL;
     277           1 :     ScOutlineTable* pUndoTab = NULL;
     278             : 
     279           1 :     if ( pTable )
     280             :     {
     281           0 :         if ( bRecord )
     282             :         {
     283           0 :             pUndoTab = new ScOutlineTable( *pTable );
     284             : 
     285             :             SCCOLROW nCol1, nCol2, nRow1, nRow2;
     286           0 :             pTable->GetColArray()->GetRange( nCol1, nCol2 );
     287           0 :             pTable->GetRowArray()->GetRange( nRow1, nRow2 );
     288           0 :             SCCOL nOutStartCol = static_cast<SCCOL>(nCol1);
     289           0 :             SCROW nOutStartRow = nRow1;
     290           0 :             SCCOL nOutEndCol = static_cast<SCCOL>(nCol2);
     291           0 :             SCROW nOutEndRow = nRow2;
     292             : 
     293           0 :             pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     294           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, true, true );
     295           0 :             pDoc->CopyToDocument( nOutStartCol, 0, nTab, nOutEndCol, MAXROW, nTab, IDF_NONE, false, pUndoDoc );
     296           0 :             pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, false, pUndoDoc );
     297             :         }
     298             : 
     299             :         // einblenden
     300           0 :         SelectLevel( nTab, true,  pTable->GetColArray()->GetDepth(), false, false );
     301           0 :         SelectLevel( nTab, false, pTable->GetRowArray()->GetDepth(), false, false );
     302           0 :         pDoc->SetOutlineTable( nTab, NULL );
     303             :     }
     304             : 
     305           1 :     pDoc->DoAutoOutline( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
     306             : 
     307           1 :     if (bRecord)
     308             :     {
     309           1 :         rDocShell.GetUndoManager()->AddUndoAction(
     310             :             new ScUndoAutoOutline( &rDocShell,
     311             :                                     nStartCol, nStartRow, nTab,
     312             :                                     nEndCol, nEndRow, nTab,
     313           1 :                                     pUndoDoc, pUndoTab ) );
     314             :     }
     315             : 
     316           1 :     if (pDoc->IsStreamValid(nTab))
     317           0 :         pDoc->SetStreamValid(nTab, false);
     318             : 
     319           1 :     rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
     320           1 :     rDocShell.SetDocumentModified();
     321           1 :     lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     322             : 
     323           1 :     return true;
     324             : }
     325             : 
     326           9 : bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel,
     327             :                                     bool bRecord, bool bPaint )
     328             : {
     329           9 :     ScDocument* pDoc = rDocShell.GetDocument();
     330             : 
     331           9 :     if (bRecord && !pDoc->IsUndoEnabled())
     332           0 :         bRecord = false;
     333           9 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );             // ist schon da
     334           9 :     if (!pTable)
     335           0 :         return false;
     336           9 :     ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
     337           9 :     if (!pArray)
     338           0 :         return false;
     339             : 
     340             :     SCCOLROW nStart, nEnd;
     341           9 :     pArray->GetRange( nStart, nEnd );
     342             : 
     343           9 :     if ( bRecord )
     344             :     {
     345           1 :         ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
     346           1 :         ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     347           1 :         if (bColumns)
     348             :         {
     349           1 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, true, false );
     350             :             pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
     351             :                     static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, false,
     352           1 :                     pUndoDoc );
     353             :         }
     354             :         else
     355             :         {
     356           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, false, true );
     357           0 :             pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, false, pUndoDoc );
     358             :         }
     359             : 
     360           1 :         rDocShell.GetUndoManager()->AddUndoAction(
     361             :             new ScUndoOutlineLevel( &rDocShell,
     362             :                                     nStart, nEnd, nTab,             //! start und end berechnen
     363             :                                     pUndoDoc, pUndoTab,
     364           1 :                                     bColumns, nLevel ) );
     365             :     }
     366             : 
     367           9 :     ScSubOutlineIterator aIter( pArray );                   // alle Eintraege
     368             :     ScOutlineEntry* pEntry;
     369          36 :     while ((pEntry=aIter.GetNext()) != NULL)
     370             :     {
     371          18 :         sal_uInt16 nThisLevel = aIter.LastLevel();
     372          18 :         sal_Bool bShow = (nThisLevel < nLevel);
     373          18 :         if (bShow)                                          // einblenden
     374             :         {
     375          16 :             pEntry->SetHidden( false );
     376          16 :             pEntry->SetVisible( true );
     377             :         }
     378           2 :         else if ( nThisLevel == nLevel )                    // ausblenden
     379             :         {
     380           1 :             pEntry->SetHidden( true );
     381           1 :             pEntry->SetVisible( true );
     382             :         }
     383             :         else                                                // verdeckt
     384             :         {
     385           1 :             pEntry->SetVisible( false );
     386             :         }
     387             : 
     388          18 :         SCCOLROW nThisStart = pEntry->GetStart();
     389          18 :         SCCOLROW nThisEnd   = pEntry->GetEnd();
     390         187 :         for (SCCOLROW i=nThisStart; i<=nThisEnd; i++)
     391             :         {
     392         169 :             if ( bColumns )
     393         160 :                 pDoc->ShowCol( static_cast<SCCOL>(i), nTab, bShow );
     394             :             else
     395             :             {
     396             :                 // show several rows together, don't show filtered rows
     397           9 :                 SCROW nFilterEnd = i;
     398           9 :                 bool bFiltered = pDoc->RowFiltered( i, nTab, NULL, &nFilterEnd );
     399           9 :                 nFilterEnd = std::min( nThisEnd, nFilterEnd );
     400           9 :                 if ( !bShow || !bFiltered )
     401           9 :                     pDoc->ShowRows( i, nFilterEnd, nTab, bShow );
     402           9 :                 i = nFilterEnd;
     403             :             }
     404             :         }
     405             :     }
     406             : 
     407           9 :     pDoc->SetDrawPageSize(nTab);
     408           9 :     pDoc->UpdatePageBreaks( nTab );
     409             : 
     410           9 :     if (bPaint)
     411           1 :         lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
     412             : 
     413           9 :     rDocShell.SetDocumentModified();
     414           9 :     lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     415             : 
     416           9 :     return true;
     417             : }
     418             : 
     419          10 : bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, bool bRecord )
     420             : {
     421          10 :     bool bDone = false;
     422             : 
     423          10 :     SCCOL nStartCol = rRange.aStart.Col();
     424          10 :     SCROW nStartRow = rRange.aStart.Row();
     425          10 :     SCCOL nEndCol = rRange.aEnd.Col();
     426          10 :     SCROW nEndRow = rRange.aEnd.Row();
     427          10 :     SCTAB nTab = rRange.aStart.Tab();
     428             : 
     429          10 :     ScDocument* pDoc = rDocShell.GetDocument();
     430             : 
     431          10 :     if (bRecord && !pDoc->IsUndoEnabled())
     432           0 :         bRecord = false;
     433          10 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     434             : 
     435          10 :     if (pTable)
     436             :     {
     437             :         ScOutlineArray* pArray;
     438             :         ScOutlineEntry* pEntry;
     439             :         SCCOLROW nStart;
     440             :         SCCOLROW nEnd;
     441             :         SCCOLROW nMin;
     442             :         SCCOLROW nMax;
     443             :         SCCOLROW i;
     444             : 
     445          10 :         if ( bRecord )
     446             :         {
     447          10 :             ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
     448          10 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     449          10 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, true, true );
     450          10 :             pDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, false, pUndoDoc );
     451          10 :             pDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, false, pUndoDoc );
     452             : 
     453          10 :             rDocShell.GetUndoManager()->AddUndoAction(
     454             :                 new ScUndoOutlineBlock( &rDocShell,
     455             :                                         nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
     456          10 :                                         pUndoDoc, pUndoTab, true ) );
     457             :         }
     458             : 
     459             :         //  Spalten
     460             : 
     461          10 :         nMin=MAXCOL;
     462          10 :         nMax=0;
     463          10 :         pArray = pTable->GetColArray();
     464          10 :         ScSubOutlineIterator aColIter( pArray );
     465          56 :         while ((pEntry=aColIter.GetNext()) != NULL)
     466             :         {
     467          36 :             nStart = pEntry->GetStart();
     468          36 :             nEnd   = pEntry->GetEnd();
     469          36 :             if ( nStart>=nStartCol && nEnd<=nEndCol )
     470             :             {
     471          14 :                 pEntry->SetHidden( false );
     472          14 :                 pEntry->SetVisible( true );
     473          14 :                 if (nStart<nMin) nMin=nStart;
     474          14 :                 if (nEnd>nMax) nMax=nEnd;
     475             :             }
     476             :         }
     477         104 :         for ( i=nMin; i<=nMax; i++ )
     478          94 :             pDoc->ShowCol( static_cast<SCCOL>(i), nTab, true );
     479             : 
     480             :         //  Zeilen
     481             : 
     482          10 :         nMin=MAXROW;
     483          10 :         nMax=0;
     484          10 :         pArray = pTable->GetRowArray();
     485          10 :         ScSubOutlineIterator aRowIter( pArray );
     486          59 :         while ((pEntry=aRowIter.GetNext()) != NULL)
     487             :         {
     488          39 :             nStart = pEntry->GetStart();
     489          39 :             nEnd   = pEntry->GetEnd();
     490          39 :             if ( nStart>=nStartRow && nEnd<=nEndRow )
     491             :             {
     492          14 :                 pEntry->SetHidden( false );
     493          14 :                 pEntry->SetVisible( true );
     494          14 :                 if (nStart<nMin) nMin=nStart;
     495          14 :                 if (nEnd>nMax) nMax=nEnd;
     496             :             }
     497             :         }
     498          14 :         for ( i=nMin; i<=nMax; i++ )
     499             :         {
     500             :             // show several rows together, don't show filtered rows
     501           4 :             SCROW nFilterEnd = i;
     502           4 :             bool bFiltered = pDoc->RowFiltered( i, nTab, NULL, &nFilterEnd );
     503           4 :             nFilterEnd = std::min( nMax, nFilterEnd );
     504           4 :             if ( !bFiltered )
     505           4 :                 pDoc->ShowRows( i, nFilterEnd, nTab, true );
     506           4 :             i = nFilterEnd;
     507             :         }
     508             : 
     509          10 :         pDoc->SetDrawPageSize(nTab);
     510          10 :         pDoc->UpdatePageBreaks( nTab );
     511             : 
     512          10 :         rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP );
     513          10 :         rDocShell.SetDocumentModified();
     514          10 :         bDone = true;
     515             : 
     516          10 :         lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     517             :     }
     518             : 
     519          10 :     return bDone;
     520             : }
     521             : 
     522          13 : bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange& rRange, bool bRecord )
     523             : {
     524          13 :     bool bDone = false;
     525             : 
     526          13 :     SCCOL nStartCol = rRange.aStart.Col();
     527          13 :     SCROW nStartRow = rRange.aStart.Row();
     528          13 :     SCCOL nEndCol = rRange.aEnd.Col();
     529          13 :     SCROW nEndRow = rRange.aEnd.Row();
     530          13 :     SCTAB nTab = rRange.aStart.Tab();
     531             : 
     532          13 :     ScDocument* pDoc = rDocShell.GetDocument();
     533             : 
     534          13 :     if (bRecord && !pDoc->IsUndoEnabled())
     535           0 :         bRecord = false;
     536          13 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     537             : 
     538          13 :     if (pTable)
     539             :     {
     540             :         const ScOutlineEntry* pEntry;
     541             :         size_t nColLevel;
     542             :         size_t nRowLevel;
     543             :         sal_uInt16 nCount;
     544             :         SCCOLROW nStart;
     545             :         SCCOLROW nEnd;
     546             :         sal_uInt16 i;
     547             : 
     548          11 :         SCCOLROW nEffStartCol = nStartCol;
     549          11 :         SCCOLROW nEffEndCol   = nEndCol;
     550          11 :         ScOutlineArray* pColArray = pTable->GetColArray();
     551          11 :         pColArray->FindTouchedLevel( nStartCol, nEndCol, nColLevel );
     552          11 :         pColArray->ExtendBlock( nColLevel, nEffStartCol, nEffEndCol );
     553          11 :         SCCOLROW nEffStartRow = nStartRow;
     554          11 :         SCCOLROW nEffEndRow   = nEndRow;
     555          11 :         ScOutlineArray* pRowArray = pTable->GetRowArray();
     556          11 :         pRowArray->FindTouchedLevel( nStartRow, nEndRow, nRowLevel );
     557          11 :         pRowArray->ExtendBlock( nRowLevel, nEffStartRow, nEffEndRow );
     558             : 
     559          11 :         if ( bRecord )
     560             :         {
     561          11 :             ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
     562          11 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     563          11 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, true, true );
     564             :             pDoc->CopyToDocument( static_cast<SCCOL>(nEffStartCol), 0, nTab,
     565             :                     static_cast<SCCOL>(nEffEndCol), MAXROW, nTab, IDF_NONE,
     566          11 :                     false, pUndoDoc );
     567          11 :             pDoc->CopyToDocument( 0, nEffStartRow, nTab, MAXCOL, nEffEndRow, nTab, IDF_NONE, false, pUndoDoc );
     568             : 
     569          11 :             rDocShell.GetUndoManager()->AddUndoAction(
     570             :                 new ScUndoOutlineBlock( &rDocShell,
     571             :                                         nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
     572          11 :                                         pUndoDoc, pUndoTab, false ) );
     573             :         }
     574             : 
     575             :         //  Spalten
     576             : 
     577          11 :         nCount = pColArray->GetCount(nColLevel);
     578          24 :         for ( i=0; i<nCount; i++ )
     579             :         {
     580          13 :             pEntry = pColArray->GetEntry(nColLevel,i);
     581          13 :             nStart = pEntry->GetStart();
     582          13 :             nEnd   = pEntry->GetEnd();
     583             : 
     584          13 :             if ( static_cast<SCCOLROW>(nStartCol)<=nEnd && static_cast<SCCOLROW>(nEndCol)>=nStart )
     585          10 :                 HideOutline( nTab, true, nColLevel, i, false, false );
     586             :         }
     587             : 
     588             :         //  Zeilen
     589             : 
     590          11 :         nCount = pRowArray->GetCount(nRowLevel);
     591          24 :         for ( i=0; i<nCount; i++ )
     592             :         {
     593          13 :             pEntry = pRowArray->GetEntry(nRowLevel,i);
     594          13 :             nStart = pEntry->GetStart();
     595          13 :             nEnd   = pEntry->GetEnd();
     596             : 
     597          13 :             if ( nStartRow<=nEnd && nEndRow>=nStart )
     598           4 :                 HideOutline( nTab, false, nRowLevel, i, false, false );
     599             :         }
     600             : 
     601          11 :         pDoc->SetDrawPageSize(nTab);
     602          11 :         pDoc->UpdatePageBreaks( nTab );
     603             : 
     604          11 :         rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP );
     605             : 
     606          11 :         rDocShell.SetDocumentModified();
     607          11 :         bDone = true;
     608             : 
     609          11 :         lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     610             :     }
     611             : 
     612          13 :     return bDone;
     613             : }
     614             : 
     615           0 : bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry,
     616             :                                     bool bRecord, bool bPaint )
     617             : {
     618           0 :     ScDocument* pDoc = rDocShell.GetDocument();
     619           0 :     if (bRecord && !pDoc->IsUndoEnabled())
     620           0 :         bRecord = false;
     621             : 
     622           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     623           0 :     ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
     624           0 :     ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntry );
     625           0 :     SCCOLROW nStart = pEntry->GetStart();
     626           0 :     SCCOLROW nEnd   = pEntry->GetEnd();
     627             : 
     628           0 :     if ( bRecord )
     629             :     {
     630           0 :         ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     631           0 :         if (bColumns)
     632             :         {
     633           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, true, false );
     634             :             pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
     635             :                     static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, false,
     636           0 :                     pUndoDoc );
     637             :         }
     638             :         else
     639             :         {
     640           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, false, true );
     641           0 :             pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, false, pUndoDoc );
     642             :         }
     643             : 
     644           0 :         rDocShell.GetUndoManager()->AddUndoAction(
     645             :             new ScUndoDoOutline( &rDocShell,
     646             :                                     nStart, nEnd, nTab, pUndoDoc,       //! start und end berechnen
     647           0 :                                     bColumns, nLevel, nEntry, true ) );
     648             :     }
     649             : 
     650           0 :     pEntry->SetHidden(false);
     651             :     SCCOLROW i;
     652           0 :     for ( i = nStart; i <= nEnd; i++ )
     653             :     {
     654           0 :         if ( bColumns )
     655           0 :             pDoc->ShowCol( static_cast<SCCOL>(i), nTab, true );
     656             :         else
     657             :         {
     658             :             // show several rows together, don't show filtered rows
     659           0 :             SCROW nFilterEnd = i;
     660           0 :             bool bFiltered = pDoc->RowFiltered( i, nTab, NULL, &nFilterEnd );
     661           0 :             nFilterEnd = std::min( nEnd, nFilterEnd );
     662           0 :             if ( !bFiltered )
     663           0 :                 pDoc->ShowRows( i, nFilterEnd, nTab, true );
     664           0 :             i = nFilterEnd;
     665             :         }
     666             :     }
     667             : 
     668           0 :     ScSubOutlineIterator aIter( pArray, nLevel, nEntry );
     669           0 :     while ((pEntry=aIter.GetNext()) != NULL)
     670             :     {
     671           0 :         if ( pEntry->IsHidden() )
     672             :         {
     673           0 :             SCCOLROW nSubStart = pEntry->GetStart();
     674           0 :             SCCOLROW nSubEnd   = pEntry->GetEnd();
     675           0 :             if ( bColumns )
     676           0 :                 for ( i = nSubStart; i <= nSubEnd; i++ )
     677           0 :                     pDoc->ShowCol( static_cast<SCCOL>(i), nTab, false );
     678             :             else
     679           0 :                 pDoc->ShowRows( nSubStart, nSubEnd, nTab, false );
     680             :         }
     681             :     }
     682             : 
     683           0 :     pArray->SetVisibleBelow( nLevel, nEntry, true, true );
     684             : 
     685           0 :     pDoc->SetDrawPageSize(nTab);
     686           0 :     pDoc->InvalidatePageBreaks(nTab);
     687           0 :     pDoc->UpdatePageBreaks( nTab );
     688             : 
     689           0 :     if (bPaint)
     690           0 :         lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
     691             : 
     692           0 :     rDocShell.SetDocumentModified();
     693             : 
     694           0 :     lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     695             : 
     696           0 :     return true;        //! immer ???
     697             : }
     698             : 
     699          14 : bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry,
     700             :                                     bool bRecord, bool bPaint )
     701             : {
     702          14 :     ScDocument* pDoc = rDocShell.GetDocument();
     703          14 :     if (bRecord && !pDoc->IsUndoEnabled())
     704           0 :         bRecord = false;
     705             : 
     706          14 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     707          14 :     ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
     708          14 :     ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntry );
     709          14 :     SCCOLROW nStart = pEntry->GetStart();
     710          14 :     SCCOLROW nEnd   = pEntry->GetEnd();
     711             : 
     712          14 :     if ( bRecord )
     713             :     {
     714           0 :         ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     715           0 :         if (bColumns)
     716             :         {
     717           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, true, false );
     718             :             pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
     719             :                     static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, false,
     720           0 :                     pUndoDoc );
     721             :         }
     722             :         else
     723             :         {
     724           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, false, true );
     725           0 :             pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, false, pUndoDoc );
     726             :         }
     727             : 
     728           0 :         rDocShell.GetUndoManager()->AddUndoAction(
     729             :             new ScUndoDoOutline( &rDocShell,
     730             :                                     nStart, nEnd, nTab, pUndoDoc,
     731           0 :                                     bColumns, nLevel, nEntry, false ) );
     732             :     }
     733             : 
     734          14 :     pEntry->SetHidden(true);
     735             :     SCCOLROW i;
     736          14 :     if ( bColumns )
     737         198 :         for ( i = nStart; i <= nEnd; i++ )
     738         188 :             pDoc->ShowCol( static_cast<SCCOL>(i), nTab, false );
     739             :     else
     740           4 :         pDoc->ShowRows( nStart, nEnd, nTab, false );
     741             : 
     742          14 :     pArray->SetVisibleBelow( nLevel, nEntry, false );
     743             : 
     744          14 :     pDoc->SetDrawPageSize(nTab);
     745          14 :     pDoc->InvalidatePageBreaks(nTab);
     746          14 :     pDoc->UpdatePageBreaks( nTab );
     747             : 
     748          14 :     if (bPaint)
     749           0 :         lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
     750             : 
     751          14 :     rDocShell.SetDocumentModified();
     752             : 
     753          14 :     lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     754             : 
     755          14 :     return true;        //! immer ???
     756             : }
     757             : 
     758             : 
     759             : 
     760             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10