LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/core/data - documen9.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 234 340 68.8 %
Date: 2013-07-09 Functions: 35 42 83.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 "scitems.hxx"
      21             : #include <editeng/eeitem.hxx>
      22             : 
      23             : #include <sot/exchange.hxx>
      24             : #include <editeng/autokernitem.hxx>
      25             : #include <editeng/fontitem.hxx>
      26             : #include <editeng/forbiddencharacterstable.hxx>
      27             : #include <editeng/langitem.hxx>
      28             : #include <svx/svdetc.hxx>
      29             : #include <svx/svditer.hxx>
      30             : #include <svx/svdocapt.hxx>
      31             : #include <svx/svdograf.hxx>
      32             : #include <svx/svdoole2.hxx>
      33             : #include <svx/svdouno.hxx>
      34             : #include <svx/svdpage.hxx>
      35             : #include <svx/svdundo.hxx>
      36             : #include <svx/xtable.hxx>
      37             : #include <sfx2/objsh.hxx>
      38             : #include <sfx2/printer.hxx>
      39             : #include <unotools/saveopt.hxx>
      40             : #include <unotools/pathoptions.hxx>
      41             : 
      42             : #include "document.hxx"
      43             : #include "docoptio.hxx"
      44             : #include "table.hxx"
      45             : #include "drwlayer.hxx"
      46             : #include "markdata.hxx"
      47             : #include "patattr.hxx"
      48             : #include "rechead.hxx"
      49             : #include "poolhelp.hxx"
      50             : #include "docpool.hxx"
      51             : #include "detfunc.hxx"      // for UpdateAllComments
      52             : #include "editutil.hxx"
      53             : #include "postit.hxx"
      54             : #include "charthelper.hxx"
      55             : #include "interpre.hxx"
      56             : 
      57             : using namespace ::com::sun::star;
      58             : #include <stdio.h>
      59             : // -----------------------------------------------------------------------
      60             : 
      61             : 
      62          36 : SfxBroadcaster* ScDocument::GetDrawBroadcaster()
      63             : {
      64          36 :     return pDrawLayer;
      65             : }
      66             : 
      67         129 : void ScDocument::BeginDrawUndo()
      68             : {
      69         129 :     if (pDrawLayer)
      70         127 :         pDrawLayer->BeginCalcUndo(false);
      71         129 : }
      72             : 
      73           0 : rtl::Reference<XColorList> ScDocument::GetColorList()
      74             : {
      75           0 :     if (pDrawLayer)
      76           0 :         return pDrawLayer->GetColorList();
      77             :     else
      78             :     {
      79           0 :         if (!pColorList.is())
      80           0 :             pColorList = XColorList::CreateStdColorList();
      81           0 :         return pColorList;
      82             :     }
      83             : }
      84             : 
      85           3 : void ScDocument::TransferDrawPage(ScDocument* pSrcDoc, SCTAB nSrcPos, SCTAB nDestPos)
      86             : {
      87           3 :     if (pDrawLayer && pSrcDoc->pDrawLayer)
      88             :     {
      89           1 :         SdrPage* pOldPage = pSrcDoc->pDrawLayer->GetPage(static_cast<sal_uInt16>(nSrcPos));
      90           1 :         SdrPage* pNewPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nDestPos));
      91             : 
      92           1 :         if (pOldPage && pNewPage)
      93             :         {
      94           1 :             SdrObjListIter aIter( *pOldPage, IM_FLAT );
      95           1 :             SdrObject* pOldObject = aIter.Next();
      96           2 :             while (pOldObject)
      97             :             {
      98             :                 // #116235#
      99           0 :                 SdrObject* pNewObject = pOldObject->Clone();
     100             :                 // SdrObject* pNewObject = pOldObject->Clone( pNewPage, pDrawLayer );
     101           0 :                 pNewObject->SetModel(pDrawLayer);
     102           0 :                 pNewObject->SetPage(pNewPage);
     103             : 
     104           0 :                 pNewObject->NbcMove(Size(0,0));
     105           0 :                 pNewPage->InsertObject( pNewObject );
     106             : 
     107           0 :                 if (pDrawLayer->IsRecording())
     108           0 :                     pDrawLayer->AddCalcUndo( new SdrUndoInsertObj( *pNewObject ) );
     109             : 
     110           0 :                 pOldObject = aIter.Next();
     111           1 :             }
     112             :         }
     113             :     }
     114             : 
     115             :     //  make sure the data references of charts are adapted
     116             :     //  (this must be after InsertObject!)
     117           3 :     ScChartHelper::AdjustRangesOfChartsOnDestinationPage( pSrcDoc, this, nSrcPos, nDestPos );
     118           3 :     ScChartHelper::UpdateChartsOnDestinationPage(this, nDestPos);
     119           3 : }
     120             : 
     121        1514 : void ScDocument::InitDrawLayer( SfxObjectShell* pDocShell )
     122             : {
     123        1514 :     if (pDocShell && !pShell)
     124           0 :         pShell = pDocShell;
     125             : 
     126        1514 :     if (!pDrawLayer)
     127             :     {
     128         266 :         OUString aName;
     129         266 :         if ( pShell && !pShell->IsLoading() )       // don't call GetTitle while loading
     130         168 :             aName = pShell->GetTitle();
     131         266 :         pDrawLayer = new ScDrawLayer( this, aName );
     132         266 :         if (GetLinkManager())
     133         266 :             pDrawLayer->SetLinkManager( pLinkManager );
     134             : 
     135             :         //  Drawing pages are accessed by table number, so they must also be present
     136             :         //  for preceding table numbers, even if the tables aren't allocated
     137             :         //  (important for clipboard documents).
     138             : 
     139         266 :         SCTAB nDrawPages = 0;
     140             :         SCTAB nTab;
     141         572 :         for (nTab=0; nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
     142         306 :             if (maTabs[nTab])
     143         306 :                 nDrawPages = nTab + 1;          // needed number of pages
     144             : 
     145         572 :         for (nTab=0; nTab<nDrawPages && nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
     146             :         {
     147         306 :             pDrawLayer->ScAddPage( nTab );      // always add page, with or without the table
     148         306 :             if (maTabs[nTab])
     149             :             {
     150         306 :                 OUString aTabName;
     151         306 :                 maTabs[nTab]->GetName(aTabName);
     152         306 :                 pDrawLayer->ScRenamePage( nTab, aTabName );
     153             : 
     154         306 :                 maTabs[nTab]->SetDrawPageSize(false,false);     // set the right size immediately
     155             :             }
     156             :         }
     157             : 
     158         266 :         pDrawLayer->SetDefaultTabulator( GetDocOptions().GetTabDistance() );
     159             : 
     160         266 :         UpdateDrawPrinter();
     161             : 
     162             :         // set draw defaults directly
     163         266 :         SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
     164         266 :         rDrawPool.SetPoolDefaultItem( SvxAutoKernItem( sal_True, EE_CHAR_PAIRKERNING ) );
     165             : 
     166         266 :         UpdateDrawLanguages();
     167         266 :         if (bImportingXML)
     168          30 :             pDrawLayer->EnableAdjust(false);
     169             : 
     170         266 :         pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
     171         266 :         pDrawLayer->SetCharCompressType( GetAsianCompression() );
     172         266 :         pDrawLayer->SetKernAsianPunctuation( GetAsianKerning() );
     173             :     }
     174        1514 : }
     175             : 
     176        2277 : void ScDocument::UpdateDrawLanguages()
     177             : {
     178        2277 :     if (pDrawLayer)
     179             :     {
     180         314 :         SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
     181         314 :         rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eLanguage, EE_CHAR_LANGUAGE ) );
     182         314 :         rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eCjkLanguage, EE_CHAR_LANGUAGE_CJK ) );
     183         314 :         rDrawPool.SetPoolDefaultItem( SvxLanguageItem( eCtlLanguage, EE_CHAR_LANGUAGE_CTL ) );
     184             :     }
     185        2277 : }
     186             : 
     187         416 : void ScDocument::UpdateDrawPrinter()
     188             : {
     189         416 :     if (pDrawLayer)
     190             :     {
     191             :         // use the printer even if IsValid is false
     192             :         // Application::GetDefaultDevice causes trouble with changing MapModes
     193         281 :         pDrawLayer->SetRefDevice(GetRefDevice());
     194             :     }
     195         416 : }
     196             : 
     197         803 : void ScDocument::SetDrawPageSize(SCTAB nTab)
     198             : {
     199         803 :     if (!ValidTab(nTab) || nTab >= static_cast<SCTAB>(maTabs.size()) || !maTabs[nTab])
     200         803 :         return;
     201             : 
     202         803 :     maTabs[nTab]->SetDrawPageSize();
     203             : }
     204             : 
     205          64 : bool ScDocument::IsChart( const SdrObject* pObject )
     206             : {
     207             :     // #109985#
     208             :     // IsChart() implementation moved to svx drawinglayer
     209          64 :     if(pObject && OBJ_OLE2 == pObject->GetObjIdentifier())
     210             :     {
     211          64 :         return ((SdrOle2Obj*)pObject)->IsChart();
     212             :     }
     213             : 
     214           0 :     return false;
     215             : }
     216             : 
     217           0 : IMPL_LINK_INLINE_START( ScDocument, GetUserDefinedColor, sal_uInt16 *, pColorIndex )
     218             : {
     219           0 :     return (sal_IntPtr) &((GetColorList()->GetColor(*pColorIndex))->GetColor());
     220             : }
     221           0 : IMPL_LINK_INLINE_END( ScDocument, GetUserDefinedColor, sal_uInt16 *, pColorIndex )
     222             : 
     223        1340 : void ScDocument::DeleteDrawLayer()
     224             : {
     225        1340 :     delete pDrawLayer;
     226        1340 : }
     227             : 
     228        1682 : bool ScDocument::DrawGetPrintArea( ScRange& rRange, bool bSetHor, bool bSetVer ) const
     229             : {
     230        1682 :     return pDrawLayer->GetPrintArea( rRange, bSetHor, bSetVer );
     231             : }
     232             : 
     233           1 : void ScDocument::DrawMovePage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
     234             : {
     235           1 :     pDrawLayer->ScMovePage(nOldPos,nNewPos);
     236           1 : }
     237             : 
     238           2 : void ScDocument::DrawCopyPage( sal_uInt16 nOldPos, sal_uInt16 nNewPos )
     239             : {
     240             :     // angelegt wird die Page schon im ScTable ctor
     241           2 :     pDrawLayer->ScCopyPage( nOldPos, nNewPos, false );
     242           2 : }
     243             : 
     244           2 : void ScDocument::DeleteObjectsInArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     245             :                         const ScMarkData& rMark )
     246             : {
     247           2 :     if (!pDrawLayer)
     248           3 :         return;
     249             : 
     250           1 :     SCTAB nTabCount = GetTableCount();
     251           1 :     ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end();
     252           2 :     for (; itr != itrEnd && *itr < nTabCount; ++itr)
     253           1 :         if (maTabs[*itr])
     254           1 :             pDrawLayer->DeleteObjectsInArea( *itr, nCol1, nRow1, nCol2, nRow2 );
     255             : }
     256             : 
     257           0 : void ScDocument::DeleteObjectsInSelection( const ScMarkData& rMark )
     258             : {
     259           0 :     if (!pDrawLayer)
     260           0 :         return;
     261             : 
     262           0 :     pDrawLayer->DeleteObjectsInSelection( rMark );
     263             : }
     264             : 
     265          14 : bool ScDocument::HasOLEObjectsInArea( const ScRange& rRange, const ScMarkData* pTabMark )
     266             : {
     267             :     //  pTabMark is used only for selected tables. If pTabMark is 0, all tables of rRange are used.
     268             : 
     269          14 :     if (!pDrawLayer)
     270           1 :         return false;
     271             : 
     272          13 :     SCTAB nStartTab = 0;
     273          13 :     SCTAB nEndTab = static_cast<SCTAB>(maTabs.size());
     274          13 :     if ( !pTabMark )
     275             :     {
     276          13 :         nStartTab = rRange.aStart.Tab();
     277          13 :         nEndTab = rRange.aEnd.Tab();
     278             :     }
     279             : 
     280          26 :     for (SCTAB nTab = nStartTab; nTab <= nEndTab; nTab++)
     281             :     {
     282          13 :         if ( !pTabMark || pTabMark->GetTableSelect(nTab) )
     283             :         {
     284          13 :             Rectangle aMMRect = GetMMRect( rRange.aStart.Col(), rRange.aStart.Row(),
     285          26 :                                             rRange.aEnd.Col(), rRange.aEnd.Row(), nTab );
     286             : 
     287          13 :             SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
     288             :             OSL_ENSURE(pPage,"Page ?");
     289          13 :             if (pPage)
     290             :             {
     291          13 :                 SdrObjListIter aIter( *pPage, IM_FLAT );
     292          13 :                 SdrObject* pObject = aIter.Next();
     293          39 :                 while (pObject)
     294             :                 {
     295          13 :                     if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
     296           0 :                             aMMRect.IsInside( pObject->GetCurrentBoundRect() ) )
     297           0 :                         return true;
     298             : 
     299          13 :                     pObject = aIter.Next();
     300          13 :                 }
     301             :             }
     302             :         }
     303             :     }
     304             : 
     305          13 :     return false;
     306             : }
     307             : 
     308             : 
     309           0 : void ScDocument::StartAnimations( SCTAB nTab, Window* pWin )
     310             : {
     311           0 :     if (!pDrawLayer)
     312           0 :         return;
     313           0 :     SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
     314             :     OSL_ENSURE(pPage,"Page ?");
     315           0 :     if (!pPage)
     316           0 :         return;
     317             : 
     318           0 :     SdrObjListIter aIter( *pPage, IM_FLAT );
     319           0 :     SdrObject* pObject = aIter.Next();
     320           0 :     while (pObject)
     321             :     {
     322           0 :         if (pObject->ISA(SdrGrafObj))
     323             :         {
     324           0 :             SdrGrafObj* pGrafObj = (SdrGrafObj*)pObject;
     325           0 :             if ( pGrafObj->IsAnimated() )
     326             :             {
     327           0 :                 const Rectangle& rRect = pGrafObj->GetCurrentBoundRect();
     328           0 :                 pGrafObj->StartAnimation( pWin, rRect.TopLeft(), rRect.GetSize() );
     329             :             }
     330             :         }
     331           0 :         pObject = aIter.Next();
     332           0 :     }
     333             : }
     334             : 
     335             : 
     336        1143 : bool ScDocument::HasBackgroundDraw( SCTAB nTab, const Rectangle& rMMRect ) const
     337             : {
     338             :     //  Gibt es Objekte auf dem Hintergrund-Layer, die (teilweise) von rMMRect
     339             :     //  betroffen sind?
     340             :     //  (fuer Drawing-Optimierung, vor dem Hintergrund braucht dann nicht geloescht
     341             :     //   zu werden)
     342             : 
     343        1143 :     if (!pDrawLayer)
     344           0 :         return false;
     345        1143 :     SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
     346             :     OSL_ENSURE(pPage,"Page ?");
     347        1143 :     if (!pPage)
     348           0 :         return false;
     349             : 
     350        1143 :     bool bFound = false;
     351             : 
     352        1143 :     SdrObjListIter aIter( *pPage, IM_FLAT );
     353        1143 :     SdrObject* pObject = aIter.Next();
     354        2605 :     while (pObject && !bFound)
     355             :     {
     356         319 :         if ( pObject->GetLayer() == SC_LAYER_BACK && pObject->GetCurrentBoundRect().IsOver( rMMRect ) )
     357           0 :             bFound = true;
     358         319 :         pObject = aIter.Next();
     359             :     }
     360             : 
     361        1143 :     return bFound;
     362             : }
     363             : 
     364           1 : bool ScDocument::HasAnyDraw( SCTAB nTab, const Rectangle& rMMRect ) const
     365             : {
     366             :     //  Gibt es ueberhaupt Objekte, die (teilweise) von rMMRect
     367             :     //  betroffen sind?
     368             :     //  (um leere Seiten beim Drucken zu erkennen)
     369             : 
     370           1 :     if (!pDrawLayer)
     371           1 :         return false;
     372           0 :     SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
     373             :     OSL_ENSURE(pPage,"Page ?");
     374           0 :     if (!pPage)
     375           0 :         return false;
     376             : 
     377           0 :     bool bFound = false;
     378             : 
     379           0 :     SdrObjListIter aIter( *pPage, IM_FLAT );
     380           0 :     SdrObject* pObject = aIter.Next();
     381           0 :     while (pObject && !bFound)
     382             :     {
     383           0 :         if ( pObject->GetCurrentBoundRect().IsOver( rMMRect ) )
     384           0 :             bFound = true;
     385           0 :         pObject = aIter.Next();
     386             :     }
     387             : 
     388           0 :     return bFound;
     389             : }
     390             : 
     391          47 : void ScDocument::EnsureGraphicNames()
     392             : {
     393          47 :     if (pDrawLayer)
     394          47 :         pDrawLayer->EnsureGraphicNames();
     395          47 : }
     396             : 
     397           0 : SdrObject* ScDocument::GetObjectAtPoint( SCTAB nTab, const Point& rPos )
     398             : {
     399             :     //  fuer Drag&Drop auf Zeichenobjekt
     400             : 
     401           0 :     SdrObject* pFound = NULL;
     402           0 :     if (pDrawLayer && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
     403             :     {
     404           0 :         SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
     405             :         OSL_ENSURE(pPage,"Page ?");
     406           0 :         if (pPage)
     407             :         {
     408           0 :             SdrObjListIter aIter( *pPage, IM_FLAT );
     409           0 :             SdrObject* pObject = aIter.Next();
     410           0 :             while (pObject)
     411             :             {
     412           0 :                 if ( pObject->GetCurrentBoundRect().IsInside(rPos) )
     413             :                 {
     414             :                     //  Intern interessiert gar nicht
     415             :                     //  Objekt vom Back-Layer nur, wenn kein Objekt von anderem Layer getroffen
     416             : 
     417           0 :                     SdrLayerID nLayer = pObject->GetLayer();
     418           0 :                     if ( (nLayer != SC_LAYER_INTERN) && (nLayer != SC_LAYER_HIDDEN) )
     419             :                     {
     420           0 :                         if ( nLayer != SC_LAYER_BACK ||
     421           0 :                                 !pFound || pFound->GetLayer() == SC_LAYER_BACK )
     422             :                         {
     423           0 :                             pFound = pObject;
     424             :                         }
     425             :                     }
     426             :                 }
     427             :                 //  weitersuchen -> letztes (oberstes) getroffenes Objekt nehmen
     428             : 
     429           0 :                 pObject = aIter.Next();
     430           0 :             }
     431             :         }
     432             :     }
     433           0 :     return pFound;
     434             : }
     435             : 
     436         150 : bool ScDocument::IsPrintEmpty( SCTAB nTab, SCCOL nStartCol, SCROW nStartRow,
     437             :                                 SCCOL nEndCol, SCROW nEndRow, bool bLeftIsEmpty,
     438             :                                 ScRange* pLastRange, Rectangle* pLastMM ) const
     439             : {
     440         150 :     if (!IsBlockEmpty( nTab, nStartCol, nStartRow, nEndCol, nEndRow ))
     441         148 :         return false;
     442             : 
     443           2 :     if (HasAttrib(ScRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab), HASATTR_LINES))
     444             :         // We want to print sheets with borders even if there is no cell content.
     445           1 :         return false;
     446             : 
     447           1 :     Rectangle aMMRect;
     448           1 :     if ( pLastRange && pLastMM && nTab == pLastRange->aStart.Tab() &&
     449           1 :             nStartRow == pLastRange->aStart.Row() && nEndRow == pLastRange->aEnd.Row() )
     450             :     {
     451             :         //  keep vertical part of aMMRect, only update horizontal position
     452           0 :         aMMRect = *pLastMM;
     453             : 
     454           0 :         long nLeft = 0;
     455             :         SCCOL i;
     456           0 :         for (i=0; i<nStartCol; i++)
     457           0 :             nLeft += GetColWidth(i,nTab);
     458           0 :         long nRight = nLeft;
     459           0 :         for (i=nStartCol; i<=nEndCol; i++)
     460           0 :             nRight += GetColWidth(i,nTab);
     461             : 
     462           0 :         aMMRect.Left()  = (long)(nLeft  * HMM_PER_TWIPS);
     463           0 :         aMMRect.Right() = (long)(nRight * HMM_PER_TWIPS);
     464             :     }
     465             :     else
     466           1 :         aMMRect = GetMMRect( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
     467             : 
     468           1 :     if ( pLastRange && pLastMM )
     469             :     {
     470           0 :         *pLastRange = ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
     471           0 :         *pLastMM = aMMRect;
     472             :     }
     473             : 
     474           1 :     if ( HasAnyDraw( nTab, aMMRect ))
     475           0 :         return false;
     476             : 
     477           1 :     if ( nStartCol > 0 && !bLeftIsEmpty )
     478             :     {
     479             :         //  aehnlich wie in ScPrintFunc::AdjustPrintArea
     480             :         //! ExtendPrintArea erst ab Start-Spalte des Druckbereichs
     481             : 
     482           0 :         SCCOL nExtendCol = nStartCol - 1;
     483           0 :         SCROW nTmpRow = nEndRow;
     484             : 
     485             :         // ExtendMerge() is non-const, but called without refresh. GetPrinter()
     486             :         // might create and assign a printer.
     487           0 :         ScDocument* pThis = const_cast<ScDocument*>(this);
     488             : 
     489             :         pThis->ExtendMerge( 0,nStartRow, nExtendCol,nTmpRow, nTab,
     490           0 :                             false );      // kein Refresh, incl. Attrs
     491             : 
     492           0 :         OutputDevice* pDev = pThis->GetPrinter();
     493           0 :         pDev->SetMapMode( MAP_PIXEL );              // wichtig fuer GetNeededSize
     494           0 :         ExtendPrintArea( pDev, nTab, 0, nStartRow, nExtendCol, nEndRow );
     495           0 :         if ( nExtendCol >= nStartCol )
     496           0 :             return false;
     497             :     }
     498             : 
     499           1 :     return true;
     500             : }
     501             : 
     502        2217 : void ScDocument::Clear( bool bFromDestructor )
     503             : {
     504        2217 :     TableContainer::iterator it = maTabs.begin();
     505        3709 :     for (;it != maTabs.end(); ++it)
     506        1492 :         delete *it;
     507        2217 :     maTabs.clear();
     508        2217 :     delete pSelectionAttr;
     509        2217 :     pSelectionAttr = NULL;
     510             : 
     511        2217 :     if (pDrawLayer)
     512             :     {
     513         256 :         pDrawLayer->ClearModel( bFromDestructor );
     514             :     }
     515        2217 : }
     516             : 
     517        1259 : bool ScDocument::HasDetectiveObjects(SCTAB nTab) const
     518             : {
     519             :     //  looks for detective objects, annotations don't count
     520             :     //  (used to adjust scale so detective objects hit their cells better)
     521             : 
     522        1259 :     bool bFound = false;
     523             : 
     524        1259 :     if (pDrawLayer)
     525             :     {
     526         935 :         SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
     527             :         OSL_ENSURE(pPage,"Page ?");
     528         935 :         if (pPage)
     529             :         {
     530         935 :             SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
     531         935 :             SdrObject* pObject = aIter.Next();
     532        2164 :             while (pObject && !bFound)
     533             :             {
     534             :                 // anything on the internal layer except captions (annotations)
     535         294 :                 if ( (pObject->GetLayer() == SC_LAYER_INTERN) && !ScDrawLayer::IsNoteCaption( pObject ) )
     536           0 :                     bFound = true;
     537             : 
     538         294 :                 pObject = aIter.Next();
     539         935 :             }
     540             :         }
     541             :     }
     542             : 
     543        1259 :     return bFound;
     544             : }
     545             : 
     546          47 : void ScDocument::UpdateFontCharSet()
     547             : {
     548             :     //  In alten Versionen (bis incl. 4.0 ohne SP) wurden beim Austausch zwischen
     549             :     //  Systemen die CharSets in den Font-Attributen nicht angepasst.
     550             :     //  Das muss fuer Dokumente bis incl SP2 nun nachgeholt werden:
     551             :     //  Alles, was nicht SYMBOL ist, wird auf den System-CharSet umgesetzt.
     552             :     //  Bei neuen Dokumenten (Version SC_FONTCHARSET) sollte der CharSet stimmen.
     553             : 
     554          47 :     bool bUpdateOld = ( nSrcVer < SC_FONTCHARSET );
     555             : 
     556          47 :     CharSet eSysSet = osl_getThreadTextEncoding();
     557          47 :     if ( eSrcSet != eSysSet || bUpdateOld )
     558             :     {
     559             :         sal_uInt32 nCount,i;
     560             :         SvxFontItem* pItem;
     561             : 
     562          46 :         ScDocumentPool* pPool = xPoolHelper->GetDocPool();
     563          46 :         nCount = pPool->GetItemCount2(ATTR_FONT);
     564         107 :         for (i=0; i<nCount; i++)
     565             :         {
     566          61 :             pItem = (SvxFontItem*)pPool->GetItem2(ATTR_FONT, i);
     567         112 :             if ( pItem && ( pItem->GetCharSet() == eSrcSet ||
     568           0 :                             ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
     569          51 :                 pItem->SetCharSet(eSysSet);
     570             :         }
     571             : 
     572          46 :         if ( pDrawLayer )
     573             :         {
     574          46 :             SfxItemPool& rDrawPool = pDrawLayer->GetItemPool();
     575          46 :             nCount = rDrawPool.GetItemCount2(EE_CHAR_FONTINFO);
     576          49 :             for (i=0; i<nCount; i++)
     577             :             {
     578           3 :                 pItem = (SvxFontItem*)rDrawPool.GetItem2(EE_CHAR_FONTINFO, i);
     579           3 :                 if ( pItem && ( pItem->GetCharSet() == eSrcSet ||
     580           0 :                                 ( bUpdateOld && pItem->GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) )
     581           0 :                     pItem->SetCharSet( eSysSet );
     582             :             }
     583             :         }
     584             :     }
     585          47 : }
     586             : 
     587         570 : void ScDocument::SetLoadingMedium( bool bVal )
     588             : {
     589         570 :     bLoadingMedium = bVal;
     590         570 :     TableContainer::iterator it = maTabs.begin();
     591        1457 :     for (; it != maTabs.end(); ++it)
     592             :     {
     593         887 :         if (!*it)
     594         570 :             return;
     595             : 
     596         887 :         (*it)->SetLoadingMedium(bVal);
     597             :     }
     598             : }
     599             : 
     600         152 : void ScDocument::SetImportingXML( bool bVal )
     601             : {
     602         152 :     bImportingXML = bVal;
     603         152 :     if (pDrawLayer)
     604          32 :         pDrawLayer->EnableAdjust(!bImportingXML);
     605             : 
     606         152 :     if ( !bVal )
     607             :     {
     608             :         // #i57869# after loading, do the real RTL mirroring for the sheets that have the LoadingRTL flag set
     609             : 
     610         245 :         for ( SCTAB nTab=0; nTab< static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]; nTab++ )
     611         169 :             if ( maTabs[nTab]->IsLoadingRTL() )
     612             :             {
     613           0 :                 maTabs[nTab]->SetLoadingRTL( false );
     614           0 :                 SetLayoutRTL( nTab, true );             // includes mirroring; bImportingXML must be cleared first
     615             :             }
     616             :     }
     617             : 
     618         152 :     SetLoadingMedium(bVal);
     619         152 : }
     620             : 
     621         150 : void ScDocument::SetXMLFromWrapper( bool bVal )
     622             : {
     623         150 :     bXMLFromWrapper = bVal;
     624         150 : }
     625             : 
     626        1281 : rtl::Reference<SvxForbiddenCharactersTable> ScDocument::GetForbiddenCharacters()
     627             : {
     628        1281 :     return xForbiddenCharacters;
     629             : }
     630             : 
     631          13 : void ScDocument::SetForbiddenCharacters( const rtl::Reference<SvxForbiddenCharactersTable> xNew )
     632             : {
     633          13 :     xForbiddenCharacters = xNew;
     634          13 :     if ( pEditEngine )
     635           0 :         pEditEngine->SetForbiddenCharsTable( xForbiddenCharacters );
     636          13 :     if ( pDrawLayer )
     637           9 :         pDrawLayer->SetForbiddenCharsTable( xForbiddenCharacters );
     638          13 : }
     639             : 
     640         635 : bool ScDocument::IsValidAsianCompression() const
     641             : {
     642         635 :     return ( nAsianCompression != SC_ASIANCOMPRESSION_INVALID );
     643             : }
     644             : 
     645        1388 : sal_uInt8 ScDocument::GetAsianCompression() const
     646             : {
     647        1388 :     if ( nAsianCompression == SC_ASIANCOMPRESSION_INVALID )
     648           6 :         return 0;
     649             :     else
     650        1382 :         return nAsianCompression;
     651             : }
     652             : 
     653         315 : void ScDocument::SetAsianCompression(sal_uInt8 nNew)
     654             : {
     655         315 :     nAsianCompression = nNew;
     656         315 :     if ( pEditEngine )
     657           0 :         pEditEngine->SetAsianCompressionMode( nAsianCompression );
     658         315 :     if ( pDrawLayer )
     659           2 :         pDrawLayer->SetCharCompressType( nAsianCompression );
     660         315 : }
     661             : 
     662         635 : bool ScDocument::IsValidAsianKerning() const
     663             : {
     664         635 :     return ( nAsianKerning != SC_ASIANKERNING_INVALID );
     665             : }
     666             : 
     667        1388 : bool ScDocument::GetAsianKerning() const
     668             : {
     669        1388 :     if ( nAsianKerning == SC_ASIANKERNING_INVALID )
     670           6 :         return false;
     671             :     else
     672        1382 :         return static_cast<bool>(nAsianKerning);
     673             : }
     674             : 
     675         315 : void ScDocument::SetAsianKerning(bool bNew)
     676             : {
     677         315 :     nAsianKerning = (sal_uInt8)bNew;
     678         315 :     if ( pEditEngine )
     679           0 :         pEditEngine->SetKernAsianPunctuation( static_cast<bool>( nAsianKerning ) );
     680         315 :     if ( pDrawLayer )
     681           2 :         pDrawLayer->SetKernAsianPunctuation( static_cast<bool>( nAsianKerning ) );
     682         315 : }
     683             : 
     684        1109 : void ScDocument::ApplyAsianEditSettings( ScEditEngineDefaulter& rEngine )
     685             : {
     686        1109 :     rEngine.SetForbiddenCharsTable( xForbiddenCharacters );
     687        1109 :     rEngine.SetAsianCompressionMode( GetAsianCompression() );
     688        1109 :     rEngine.SetKernAsianPunctuation( GetAsianKerning() );
     689        1109 : }
     690             : 
     691           0 : void ScDocument::RebuildFormulaGroups()
     692             : {
     693             :     SCTAB nTab;
     694           0 :     for (nTab=0; nTab < static_cast<SCTAB>(maTabs.size()); nTab++)
     695           0 :         if (maTabs[nTab])
     696           0 :             maTabs[nTab]->RebuildFormulaGroups();
     697          93 : }
     698             : 
     699             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10