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

Generated by: LCOV version 1.10