LCOV - code coverage report
Current view: top level - sc/source/core/data - documen9.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 221 337 65.6 %
Date: 2012-08-25 Functions: 34 40 85.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 199 522 38.1 %

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

Generated by: LCOV version 1.10