LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/docshell - olinefun.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 422 0.0 %
Date: 2012-12-27 Functions: 0 11 0.0 %
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           0 : static void lcl_InvalidateOutliner( SfxBindings* pBindings )
      34             : {
      35           0 :     if ( pBindings )
      36             :     {
      37           0 :         pBindings->Invalidate( SID_OUTLINE_SHOW );
      38           0 :         pBindings->Invalidate( SID_OUTLINE_HIDE );
      39           0 :         pBindings->Invalidate( SID_OUTLINE_REMOVE );
      40             : 
      41           0 :         pBindings->Invalidate( SID_STATUS_SUM );            // wegen ein-/ausblenden
      42           0 :         pBindings->Invalidate( SID_ATTR_SIZE );
      43             :     }
      44           0 : }
      45             : 
      46             : //------------------------------------------------------------------------
      47             : 
      48             : //! PaintWidthHeight zur DocShell verschieben?
      49             : 
      50           0 : static void lcl_PaintWidthHeight( ScDocShell& rDocShell, SCTAB nTab,
      51             :                                     sal_Bool bColumns, SCCOLROW nStart, SCCOLROW nEnd )
      52             : {
      53           0 :     ScDocument* pDoc = rDocShell.GetDocument();
      54             : 
      55           0 :     sal_uInt16 nParts = PAINT_GRID;
      56           0 :     SCCOL nStartCol = 0;
      57           0 :     SCROW nStartRow = 0;
      58           0 :     SCCOL nEndCol = MAXCOL;         // fuer Test auf Merge
      59           0 :     SCROW nEndRow = MAXROW;
      60           0 :     if ( bColumns )
      61             :     {
      62           0 :         nParts |= PAINT_TOP;
      63           0 :         nStartCol = static_cast<SCCOL>(nStart);
      64           0 :         nEndCol = static_cast<SCCOL>(nEnd);
      65             :     }
      66             :     else
      67             :     {
      68           0 :         nParts |= PAINT_LEFT;
      69           0 :         nStartRow = nStart;
      70           0 :         nEndRow = nEnd;
      71             :     }
      72           0 :     if (pDoc->HasAttrib( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
      73           0 :                             HASATTR_MERGED | HASATTR_OVERLAPPED ))
      74             :     {
      75           0 :         nStartCol = 0;
      76           0 :         nStartRow = 0;
      77             :     }
      78           0 :     rDocShell.PostPaint( nStartCol,nStartRow,nTab, MAXCOL,MAXROW,nTab, nParts );
      79           0 : }
      80             : 
      81             : //------------------------------------------------------------------------
      82             : 
      83           0 : sal_Bool ScOutlineDocFunc::MakeOutline( const ScRange& rRange, sal_Bool bColumns, sal_Bool bRecord, sal_Bool bApi )
      84             : {
      85           0 :     sal_Bool bSuccess = false;
      86           0 :     SCCOL nStartCol = rRange.aStart.Col();
      87           0 :     SCROW nStartRow = rRange.aStart.Row();
      88           0 :     SCCOL nEndCol = rRange.aEnd.Col();
      89           0 :     SCROW nEndRow = rRange.aEnd.Row();
      90           0 :     SCTAB nTab = rRange.aStart.Tab();
      91             : 
      92           0 :     ScDocument* pDoc = rDocShell.GetDocument();
      93           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab, sal_True );
      94           0 :     ScOutlineTable* pUndoTab = NULL;
      95             : 
      96           0 :     if (bRecord && !pDoc->IsUndoEnabled())
      97           0 :         bRecord = false;
      98             : 
      99           0 :     if (bRecord)
     100           0 :         pUndoTab = new ScOutlineTable( *pTable );
     101             : 
     102           0 :     ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
     103             : 
     104             :     bool bRes;
     105           0 :     bool bSize = false;
     106           0 :     if ( bColumns )
     107           0 :         bRes = pArray->Insert( nStartCol, nEndCol, bSize );
     108             :     else
     109           0 :         bRes = pArray->Insert( nStartRow, nEndRow, bSize );
     110             : 
     111           0 :     if ( bRes )
     112             :     {
     113           0 :         if (bRecord)
     114             :         {
     115           0 :             rDocShell.GetUndoManager()->AddUndoAction(
     116             :                 new ScUndoMakeOutline( &rDocShell,
     117             :                                         nStartCol,nStartRow,nTab,nEndCol,nEndRow,nTab,
     118           0 :                                         pUndoTab, bColumns, sal_True ) );
     119             :         }
     120             : 
     121           0 :         if (pDoc->IsStreamValid(nTab))
     122           0 :             pDoc->SetStreamValid(nTab, false);
     123             : 
     124           0 :         sal_uInt16 nParts = 0;              // Datenbereich nicht geaendert
     125           0 :         if ( bColumns )
     126           0 :             nParts |= PAINT_TOP;
     127             :         else
     128           0 :             nParts |= PAINT_LEFT;
     129           0 :         if ( bSize )
     130           0 :             nParts |= PAINT_SIZE;
     131             : 
     132           0 :         rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, nParts );
     133           0 :         rDocShell.SetDocumentModified();
     134           0 :         lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     135           0 :         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           0 :     return bSuccess;
     145             : }
     146             : 
     147           0 : sal_Bool ScOutlineDocFunc::RemoveOutline( const ScRange& rRange, sal_Bool bColumns, sal_Bool bRecord, sal_Bool bApi )
     148             : {
     149           0 :     sal_Bool bDone = false;
     150             : 
     151           0 :     SCCOL nStartCol = rRange.aStart.Col();
     152           0 :     SCROW nStartRow = rRange.aStart.Row();
     153           0 :     SCCOL nEndCol = rRange.aEnd.Col();
     154           0 :     SCROW nEndRow = rRange.aEnd.Row();
     155           0 :     SCTAB nTab = rRange.aStart.Tab();
     156             : 
     157           0 :     ScDocument* pDoc = rDocShell.GetDocument();
     158             : 
     159           0 :     if (bRecord && !pDoc->IsUndoEnabled())
     160           0 :         bRecord = false;
     161           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     162           0 :     if (pTable)
     163             :     {
     164           0 :         ScOutlineTable* pUndoTab = NULL;
     165           0 :         if (bRecord)
     166           0 :             pUndoTab = new ScOutlineTable( *pTable );
     167             : 
     168           0 :         ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
     169             : 
     170             :         bool bRes;
     171           0 :         bool bSize = false;
     172           0 :         if ( bColumns )
     173           0 :             bRes = pArray->Remove( nStartCol, nEndCol, bSize );
     174             :         else
     175           0 :             bRes = pArray->Remove( nStartRow, nEndRow, bSize );
     176             : 
     177           0 :         if ( bRes )
     178             :         {
     179           0 :             if (bRecord)
     180             :             {
     181           0 :                 rDocShell.GetUndoManager()->AddUndoAction(
     182             :                     new ScUndoMakeOutline( &rDocShell,
     183             :                                             nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
     184           0 :                                             pUndoTab, bColumns, false ) );
     185             :             }
     186             : 
     187           0 :             if (pDoc->IsStreamValid(nTab))
     188           0 :                 pDoc->SetStreamValid(nTab, false);
     189             : 
     190           0 :             sal_uInt16 nParts = 0;              // Datenbereich nicht geaendert
     191           0 :             if ( bColumns )
     192           0 :                 nParts |= PAINT_TOP;
     193             :             else
     194           0 :                 nParts |= PAINT_LEFT;
     195           0 :             if ( bSize )
     196           0 :                 nParts |= PAINT_SIZE;
     197             : 
     198           0 :             rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, nParts );
     199           0 :             rDocShell.SetDocumentModified();
     200           0 :             bDone = sal_True;
     201           0 :             lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     202             : 
     203             :             // es wird nicht wieder eingeblendet -> kein UpdatePageBreaks
     204             :         }
     205             :         else
     206           0 :             delete pUndoTab;
     207             :     }
     208             : 
     209           0 :     if (!bDone && !bApi)
     210           0 :         rDocShell.ErrorMessage(STR_MSSG_REMOVEOUTLINE_0);   // "Aufheben nicht moeglich"
     211             : 
     212           0 :     return bDone;
     213             : }
     214             : 
     215           0 : sal_Bool ScOutlineDocFunc::RemoveAllOutlines( SCTAB nTab, sal_Bool bRecord, sal_Bool bApi )
     216             : {
     217           0 :     sal_Bool bSuccess = false;
     218           0 :     ScDocument* pDoc = rDocShell.GetDocument();
     219             : 
     220           0 :     if (bRecord && !pDoc->IsUndoEnabled())
     221           0 :         bRecord = false;
     222           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     223           0 :     if (pTable)
     224             :     {
     225           0 :         if (bRecord)
     226             :         {
     227             :             SCCOLROW nCol1, nCol2, nRow1, nRow2;
     228           0 :             pTable->GetColArray()->GetRange( nCol1, nCol2 );
     229           0 :             pTable->GetRowArray()->GetRange( nRow1, nRow2 );
     230           0 :             SCCOL nStartCol = static_cast<SCCOL>(nCol1);
     231           0 :             SCROW nStartRow = nRow1;
     232           0 :             SCCOL nEndCol = static_cast<SCCOL>(nCol2);
     233           0 :             SCROW nEndRow = nRow2;
     234             : 
     235           0 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     236           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, sal_True );
     237           0 :             pDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, false, pUndoDoc );
     238           0 :             pDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, false, pUndoDoc );
     239             : 
     240           0 :             ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
     241             : 
     242           0 :             rDocShell.GetUndoManager()->AddUndoAction(
     243             :                 new ScUndoRemoveAllOutlines( &rDocShell,
     244             :                                                 nStartCol, nStartRow, nTab,
     245             :                                                 nEndCol, nEndRow, nTab,
     246           0 :                                                 pUndoDoc, pUndoTab ) );
     247             :         }
     248             : 
     249           0 :         SelectLevel( nTab, sal_True,  pTable->GetColArray()->GetDepth(), false, false, bApi );
     250           0 :         SelectLevel( nTab, false, pTable->GetRowArray()->GetDepth(), false, false, bApi );
     251           0 :         pDoc->SetOutlineTable( nTab, NULL );
     252             : 
     253           0 :         pDoc->UpdatePageBreaks( nTab );
     254             : 
     255           0 :         if (pDoc->IsStreamValid(nTab))
     256           0 :             pDoc->SetStreamValid(nTab, false);
     257             : 
     258             :         rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
     259           0 :                                     PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
     260           0 :         rDocShell.SetDocumentModified();
     261           0 :         lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     262           0 :         bSuccess = sal_True;
     263             :     }
     264             : 
     265           0 :     return bSuccess;
     266             : }
     267             : 
     268             : //------------------------------------------------------------------------
     269             : 
     270           0 : sal_Bool ScOutlineDocFunc::AutoOutline( const ScRange& rRange, sal_Bool bRecord, sal_Bool bApi )
     271             : {
     272           0 :     SCCOL nStartCol = rRange.aStart.Col();
     273           0 :     SCROW nStartRow = rRange.aStart.Row();
     274           0 :     SCCOL nEndCol = rRange.aEnd.Col();
     275           0 :     SCROW nEndRow = rRange.aEnd.Row();
     276           0 :     SCTAB nTab = rRange.aStart.Tab();
     277             : 
     278           0 :     ScDocument* pDoc = rDocShell.GetDocument();
     279             : 
     280           0 :     if (bRecord && !pDoc->IsUndoEnabled())
     281           0 :         bRecord = false;
     282           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     283             : 
     284           0 :     ScDocument* pUndoDoc = NULL;
     285           0 :     ScOutlineTable* pUndoTab = NULL;
     286             : 
     287           0 :     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           0 :     pDoc->DoAutoOutline( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
     314             : 
     315           0 :     if (bRecord)
     316             :     {
     317           0 :         rDocShell.GetUndoManager()->AddUndoAction(
     318             :             new ScUndoAutoOutline( &rDocShell,
     319             :                                     nStartCol, nStartRow, nTab,
     320             :                                     nEndCol, nEndRow, nTab,
     321           0 :                                     pUndoDoc, pUndoTab ) );
     322             :     }
     323             : 
     324           0 :     if (pDoc->IsStreamValid(nTab))
     325           0 :         pDoc->SetStreamValid(nTab, false);
     326             : 
     327           0 :     rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
     328           0 :     rDocShell.SetDocumentModified();
     329           0 :     lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     330             : 
     331           0 :     return sal_True;
     332             : }
     333             : 
     334             : //------------------------------------------------------------------------
     335             : 
     336           0 : sal_Bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, sal_Bool bColumns, sal_uInt16 nLevel,
     337             :                                     sal_Bool bRecord, sal_Bool bPaint, sal_Bool /* bApi */ )
     338             : {
     339           0 :     ScDocument* pDoc = rDocShell.GetDocument();
     340             : 
     341           0 :     if (bRecord && !pDoc->IsUndoEnabled())
     342           0 :         bRecord = false;
     343           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );             // ist schon da
     344           0 :     if (!pTable)
     345           0 :         return false;
     346           0 :     ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
     347           0 :     if (!pArray)
     348           0 :         return false;
     349             : 
     350             :     SCCOLROW nStart, nEnd;
     351           0 :     pArray->GetRange( nStart, nEnd );
     352             : 
     353           0 :     if ( bRecord )
     354             :     {
     355           0 :         ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
     356           0 :         ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     357           0 :         if (bColumns)
     358             :         {
     359           0 :             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           0 :                     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           0 :         rDocShell.GetUndoManager()->AddUndoAction(
     371             :             new ScUndoOutlineLevel( &rDocShell,
     372             :                                     nStart, nEnd, nTab,             //! start und end berechnen
     373             :                                     pUndoDoc, pUndoTab,
     374           0 :                                     bColumns, nLevel ) );
     375             :     }
     376             : 
     377           0 :     pDoc->InitializeNoteCaptions(nTab);
     378           0 :     ScSubOutlineIterator aIter( pArray );                   // alle Eintraege
     379             :     ScOutlineEntry* pEntry;
     380           0 :     while ((pEntry=aIter.GetNext()) != NULL)
     381             :     {
     382           0 :         sal_uInt16 nThisLevel = aIter.LastLevel();
     383           0 :         sal_Bool bShow = (nThisLevel < nLevel);
     384           0 :         if (bShow)                                          // einblenden
     385             :         {
     386           0 :             pEntry->SetHidden( false );
     387           0 :             pEntry->SetVisible( sal_True );
     388             :         }
     389           0 :         else if ( nThisLevel == nLevel )                    // ausblenden
     390             :         {
     391           0 :             pEntry->SetHidden( sal_True );
     392           0 :             pEntry->SetVisible( sal_True );
     393             :         }
     394             :         else                                                // verdeckt
     395             :         {
     396           0 :             pEntry->SetVisible( false );
     397             :         }
     398             : 
     399           0 :         SCCOLROW nThisStart = pEntry->GetStart();
     400           0 :         SCCOLROW nThisEnd   = pEntry->GetEnd();
     401           0 :         for (SCCOLROW i=nThisStart; i<=nThisEnd; i++)
     402             :         {
     403           0 :             if ( bColumns )
     404           0 :                 pDoc->ShowCol( static_cast<SCCOL>(i), nTab, bShow );
     405             :             else
     406             :             {
     407             :                 // show several rows together, don't show filtered rows
     408           0 :                 SCROW nFilterEnd = i;
     409           0 :                 bool bFiltered = pDoc->RowFiltered( i, nTab, NULL, &nFilterEnd );
     410           0 :                 nFilterEnd = std::min( nThisEnd, nFilterEnd );
     411           0 :                 if ( !bShow || !bFiltered )
     412           0 :                     pDoc->ShowRows( i, nFilterEnd, nTab, bShow );
     413           0 :                 i = nFilterEnd;
     414             :             }
     415             :         }
     416             :     }
     417             : 
     418           0 :     pDoc->SetDrawPageSize(nTab);
     419           0 :     pDoc->UpdatePageBreaks( nTab );
     420             : 
     421           0 :     if (bPaint)
     422           0 :         lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
     423             : 
     424           0 :     rDocShell.SetDocumentModified();
     425           0 :     lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     426             : 
     427           0 :     return sal_True;
     428             : }
     429             : 
     430             : //------------------------------------------------------------------------
     431             : 
     432           0 : sal_Bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, sal_Bool bRecord )
     433             : {
     434           0 :     sal_Bool bDone = false;
     435             : 
     436           0 :     SCCOL nStartCol = rRange.aStart.Col();
     437           0 :     SCROW nStartRow = rRange.aStart.Row();
     438           0 :     SCCOL nEndCol = rRange.aEnd.Col();
     439           0 :     SCROW nEndRow = rRange.aEnd.Row();
     440           0 :     SCTAB nTab = rRange.aStart.Tab();
     441             : 
     442           0 :     ScDocument* pDoc = rDocShell.GetDocument();
     443             : 
     444           0 :     if (bRecord && !pDoc->IsUndoEnabled())
     445           0 :         bRecord = false;
     446           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     447             : 
     448           0 :     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           0 :         if ( bRecord )
     459             :         {
     460           0 :             ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
     461           0 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     462           0 :             pUndoDoc->InitUndo( pDoc, nTab, nTab, sal_True, sal_True );
     463           0 :             pDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, false, pUndoDoc );
     464           0 :             pDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, false, pUndoDoc );
     465             : 
     466           0 :             rDocShell.GetUndoManager()->AddUndoAction(
     467             :                 new ScUndoOutlineBlock( &rDocShell,
     468             :                                         nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
     469           0 :                                         pUndoDoc, pUndoTab, sal_True ) );
     470             :         }
     471             : 
     472           0 :         pDoc->InitializeNoteCaptions(nTab);
     473             : 
     474             :         //  Spalten
     475             : 
     476           0 :         nMin=MAXCOL;
     477           0 :         nMax=0;
     478           0 :         pArray = pTable->GetColArray();
     479           0 :         ScSubOutlineIterator aColIter( pArray );
     480           0 :         while ((pEntry=aColIter.GetNext()) != NULL)
     481             :         {
     482           0 :             nStart = pEntry->GetStart();
     483           0 :             nEnd   = pEntry->GetEnd();
     484           0 :             if ( nStart>=nStartCol && nEnd<=nEndCol )
     485             :             {
     486           0 :                 pEntry->SetHidden( false );
     487           0 :                 pEntry->SetVisible( sal_True );
     488           0 :                 if (nStart<nMin) nMin=nStart;
     489           0 :                 if (nEnd>nMax) nMax=nEnd;
     490             :             }
     491             :         }
     492           0 :         for ( i=nMin; i<=nMax; i++ )
     493           0 :             pDoc->ShowCol( static_cast<SCCOL>(i), nTab, sal_True );
     494             : 
     495             :         //  Zeilen
     496             : 
     497           0 :         nMin=MAXROW;
     498           0 :         nMax=0;
     499           0 :         pArray = pTable->GetRowArray();
     500           0 :         ScSubOutlineIterator aRowIter( pArray );
     501           0 :         pDoc->InitializeNoteCaptions(nTab);
     502           0 :         while ((pEntry=aRowIter.GetNext()) != NULL)
     503             :         {
     504           0 :             nStart = pEntry->GetStart();
     505           0 :             nEnd   = pEntry->GetEnd();
     506           0 :             if ( nStart>=nStartRow && nEnd<=nEndRow )
     507             :             {
     508           0 :                 pEntry->SetHidden( false );
     509           0 :                 pEntry->SetVisible( sal_True );
     510           0 :                 if (nStart<nMin) nMin=nStart;
     511           0 :                 if (nEnd>nMax) nMax=nEnd;
     512             :             }
     513             :         }
     514           0 :         for ( i=nMin; i<=nMax; i++ )
     515             :         {
     516             :             // show several rows together, don't show filtered rows
     517           0 :             SCROW nFilterEnd = i;
     518           0 :             bool bFiltered = pDoc->RowFiltered( i, nTab, NULL, &nFilterEnd );
     519           0 :             nFilterEnd = std::min( nMax, nFilterEnd );
     520           0 :             if ( !bFiltered )
     521           0 :                 pDoc->ShowRows( i, nFilterEnd, nTab, sal_True );
     522           0 :             i = nFilterEnd;
     523             :         }
     524             : 
     525           0 :         pDoc->SetDrawPageSize(nTab);
     526           0 :         pDoc->UpdatePageBreaks( nTab );
     527             : 
     528           0 :         rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP );
     529           0 :         rDocShell.SetDocumentModified();
     530           0 :         bDone = sal_True;
     531             : 
     532           0 :         lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     533             :     }
     534             : 
     535           0 :     return bDone;
     536             : }
     537             : 
     538           0 : sal_Bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange& rRange, sal_Bool bRecord, sal_Bool bApi )
     539             : {
     540           0 :     sal_Bool bDone = false;
     541             : 
     542           0 :     SCCOL nStartCol = rRange.aStart.Col();
     543           0 :     SCROW nStartRow = rRange.aStart.Row();
     544           0 :     SCCOL nEndCol = rRange.aEnd.Col();
     545           0 :     SCROW nEndRow = rRange.aEnd.Row();
     546           0 :     SCTAB nTab = rRange.aStart.Tab();
     547             : 
     548           0 :     ScDocument* pDoc = rDocShell.GetDocument();
     549             : 
     550           0 :     if (bRecord && !pDoc->IsUndoEnabled())
     551           0 :         bRecord = false;
     552           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     553             : 
     554           0 :     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           0 :         SCCOLROW nEffStartCol = nStartCol;
     565           0 :         SCCOLROW nEffEndCol   = nEndCol;
     566           0 :         ScOutlineArray* pColArray = pTable->GetColArray();
     567           0 :         pColArray->FindTouchedLevel( nStartCol, nEndCol, nColLevel );
     568           0 :         pColArray->ExtendBlock( nColLevel, nEffStartCol, nEffEndCol );
     569           0 :         SCCOLROW nEffStartRow = nStartRow;
     570           0 :         SCCOLROW nEffEndRow   = nEndRow;
     571           0 :         ScOutlineArray* pRowArray = pTable->GetRowArray();
     572           0 :         pRowArray->FindTouchedLevel( nStartRow, nEndRow, nRowLevel );
     573           0 :         pRowArray->ExtendBlock( nRowLevel, nEffStartRow, nEffEndRow );
     574             : 
     575           0 :         if ( bRecord )
     576             :         {
     577           0 :             ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
     578           0 :             ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
     579           0 :             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           0 :                     false, pUndoDoc );
     583           0 :             pDoc->CopyToDocument( 0, nEffStartRow, nTab, MAXCOL, nEffEndRow, nTab, IDF_NONE, false, pUndoDoc );
     584             : 
     585           0 :             rDocShell.GetUndoManager()->AddUndoAction(
     586             :                 new ScUndoOutlineBlock( &rDocShell,
     587             :                                         nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
     588           0 :                                         pUndoDoc, pUndoTab, false ) );
     589             :         }
     590             : 
     591           0 :         pDoc->InitializeNoteCaptions(nTab);
     592             : 
     593             :         //  Spalten
     594             : 
     595           0 :         nCount = pColArray->GetCount(nColLevel);
     596           0 :         for ( i=0; i<nCount; i++ )
     597             :         {
     598           0 :             pEntry = pColArray->GetEntry(nColLevel,i);
     599           0 :             nStart = pEntry->GetStart();
     600           0 :             nEnd   = pEntry->GetEnd();
     601             : 
     602           0 :             if ( static_cast<SCCOLROW>(nStartCol)<=nEnd && static_cast<SCCOLROW>(nEndCol)>=nStart )
     603           0 :                 HideOutline( nTab, sal_True, nColLevel, i, false, false, bApi );
     604             :         }
     605             : 
     606             :         //  Zeilen
     607             : 
     608           0 :         nCount = pRowArray->GetCount(nRowLevel);
     609           0 :         for ( i=0; i<nCount; i++ )
     610             :         {
     611           0 :             pEntry = pRowArray->GetEntry(nRowLevel,i);
     612           0 :             nStart = pEntry->GetStart();
     613           0 :             nEnd   = pEntry->GetEnd();
     614             : 
     615           0 :             if ( nStartRow<=nEnd && nEndRow>=nStart )
     616           0 :                 HideOutline( nTab, false, nRowLevel, i, false, false, bApi );
     617             :         }
     618             : 
     619           0 :         pDoc->SetDrawPageSize(nTab);
     620           0 :         pDoc->UpdatePageBreaks( nTab );
     621             : 
     622           0 :         rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP );
     623             : 
     624           0 :         rDocShell.SetDocumentModified();
     625           0 :         bDone = sal_True;
     626             : 
     627           0 :         lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     628             :     }
     629             : 
     630           0 :     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           0 : 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           0 :     ScDocument* pDoc = rDocShell.GetDocument();
     724           0 :     if (bRecord && !pDoc->IsUndoEnabled())
     725           0 :         bRecord = false;
     726             : 
     727           0 :     ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
     728           0 :     ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
     729           0 :     ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntry );
     730           0 :     SCCOLROW nStart = pEntry->GetStart();
     731           0 :     SCCOLROW nEnd   = pEntry->GetEnd();
     732             : 
     733           0 :     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           0 :     pDoc->InitializeNoteCaptions(nTab);
     756           0 :     pEntry->SetHidden(true);
     757             :     SCCOLROW i;
     758           0 :     if ( bColumns )
     759           0 :         for ( i = nStart; i <= nEnd; i++ )
     760           0 :             pDoc->ShowCol( static_cast<SCCOL>(i), nTab, sal_False );
     761             :     else
     762           0 :         pDoc->ShowRows( nStart, nEnd, nTab, sal_False );
     763             : 
     764           0 :     pArray->SetVisibleBelow( nLevel, nEntry, false );
     765             : 
     766           0 :     pDoc->SetDrawPageSize(nTab);
     767           0 :     pDoc->InvalidatePageBreaks(nTab);
     768           0 :     pDoc->UpdatePageBreaks( nTab );
     769             : 
     770           0 :     if (bPaint)
     771           0 :         lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
     772             : 
     773           0 :     rDocShell.SetDocumentModified();
     774             : 
     775           0 :     lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
     776             : 
     777           0 :     return sal_True;        //! immer ???
     778             : }
     779             : 
     780             : 
     781             : 
     782             : 
     783             : 
     784             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10