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

Generated by: LCOV version 1.10