LCOV - code coverage report
Current view: top level - sw/source/core/draw - drawdoc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 48 59 81.4 %
Date: 2012-08-25 Functions: 5 8 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 81 162 50.0 %

           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                 :            : 
      30                 :            : #include <svx/svxids.hrc>
      31                 :            : #include <tools/stream.hxx>
      32                 :            : #include <unotools/pathoptions.hxx>
      33                 :            : #include <sot/storage.hxx>
      34                 :            : #include <svl/intitem.hxx>
      35                 :            : #include <editeng/forbiddencharacterstable.hxx>
      36                 :            : 
      37                 :            : #include <unotools/ucbstreamhelper.hxx>
      38                 :            : #include <svx/xtable.hxx>
      39                 :            : #include <svx/drawitem.hxx>
      40                 :            : #include <viewsh.hxx>
      41                 :            : #include <doc.hxx>
      42                 :            : #include <rootfrm.hxx>
      43                 :            : #include <drawdoc.hxx>
      44                 :            : #include <dpage.hxx>
      45                 :            : #include <docsh.hxx>
      46                 :            : #include <shellio.hxx>
      47                 :            : #include <hintids.hxx>
      48                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      49                 :            : 
      50                 :            : using namespace com::sun::star;
      51                 :            : 
      52                 :            : /*************************************************************************
      53                 :            : |*
      54                 :            : |* Konstruktor
      55                 :            : |*
      56                 :            : \************************************************************************/
      57                 :            : 
      58                 :       1386 : const String GetPalettePath()
      59                 :            : {
      60         [ +  - ]:       1386 :     SvtPathOptions aPathOpt;
      61 [ +  - ][ +  - ]:       1386 :     return aPathOpt.GetPalettePath();
                 [ +  - ]
      62                 :            : }
      63                 :            : 
      64                 :       1386 : SwDrawDocument::SwDrawDocument( SwDoc* pD ) :
      65                 :       1386 :     FmFormModel( ::GetPalettePath(), &pD->GetAttrPool(),
      66                 :       1386 :                  pD->GetDocShell(), sal_True ),
      67         [ +  - ]:       1386 :     pDoc( pD )
      68                 :            : {
      69         [ +  - ]:       1386 :     SetScaleUnit( MAP_TWIP );
      70         [ +  - ]:       1386 :     SetSwapGraphics( sal_True );
      71                 :            : 
      72                 :       1386 :     SwDocShell* pDocSh = pDoc->GetDocShell();
      73         [ +  - ]:       1386 :     if ( pDocSh )
      74                 :            :     {
      75         [ +  - ]:       1386 :         SetObjectShell( pDocSh );
      76                 :            :         SvxColorListItem* pColItem = ( SvxColorListItem* )
      77         [ +  - ]:       1386 :                                 ( pDocSh->GetItem( SID_COLOR_TABLE ) );
      78                 :            :         XColorListRef pXCol = pColItem ? pColItem->GetColorList() :
      79 [ +  + ][ +  - ]:       1386 :                                          XColorList::GetStdColorList();
                 [ +  - ]
      80         [ +  - ]:       1386 :         SetPropertyList( static_cast<XPropertyList *> (pXCol.get()) );
      81                 :            : 
      82         [ +  + ]:       1386 :         if ( !pColItem )
      83 [ +  - ][ +  - ]:         63 :             pDocSh->PutItem( SvxColorListItem( pXCol, SID_COLOR_TABLE ) );
                 [ +  - ]
      84                 :            : 
      85 [ +  - ][ +  - ]:       1386 :         pDocSh->PutItem( SvxGradientListItem( GetGradientList(), SID_GRADIENT_LIST ));
         [ +  - ][ +  - ]
      86 [ +  - ][ +  - ]:       1386 :         pDocSh->PutItem( SvxHatchListItem( GetHatchList(), SID_HATCH_LIST ) );
         [ +  - ][ +  - ]
      87 [ +  - ][ +  - ]:       1386 :         pDocSh->PutItem( SvxBitmapListItem( GetBitmapList(), SID_BITMAP_LIST ) );
         [ +  - ][ +  - ]
      88 [ +  - ][ +  - ]:       1386 :         pDocSh->PutItem( SvxDashListItem( GetDashList(), SID_DASH_LIST ) );
         [ +  - ][ +  - ]
      89 [ +  - ][ +  - ]:       1386 :         pDocSh->PutItem( SvxLineEndListItem( GetLineEndList(), SID_LINEEND_LIST ) );
         [ +  - ][ +  - ]
      90 [ +  - ][ +  - ]:       1386 :         pDocSh->PutItem( SfxUInt16Item(SID_ATTR_LINEEND_WIDTH_DEFAULT, 111) );
                 [ +  - ]
      91         [ +  - ]:       1386 :         SetObjectShell( pDocSh );
      92                 :            :     }
      93                 :            :     else
      94 [ #  # ][ #  # ]:          0 :         SetPropertyList( static_cast<XPropertyList *> (XColorList::GetStdColorList().get()) );
      95                 :            : 
      96                 :            :     // copy all the default values to the SdrModel
      97         [ +  - ]:       1386 :     SfxItemPool* pSdrPool = pD->GetAttrPool().GetSecondaryPool();
      98         [ +  - ]:       1386 :     if( pSdrPool )
      99                 :            :     {
     100                 :            :         const sal_uInt16 aWhichRanges[] =
     101                 :            :             {
     102                 :            :                 RES_CHRATR_BEGIN, RES_CHRATR_END,
     103                 :            :                 RES_PARATR_BEGIN, RES_PARATR_END,
     104                 :            :                 0
     105                 :       1386 :             };
     106                 :            : 
     107                 :       1386 :         SfxItemPool& rDocPool = pD->GetAttrPool();
     108                 :            :         sal_uInt16 nEdtWhich, nSlotId;
     109                 :            :         const SfxPoolItem* pItem;
     110         [ +  + ]:       4158 :         for( const sal_uInt16* pRangeArr = aWhichRanges;
     111                 :            :             *pRangeArr; pRangeArr += 2 )
     112         [ +  + ]:      83160 :             for( sal_uInt16 nW = *pRangeArr, nEnd = *(pRangeArr+1);
     113                 :            :                     nW < nEnd; ++nW )
     114 [ +  - ][ +  + ]:      80388 :                 if( 0 != (pItem = rDocPool.GetPoolDefaultItem( nW )) &&
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
     115                 :      17087 :                     0 != (nSlotId = rDocPool.GetSlotId( nW ) ) &&
     116                 :            :                     nSlotId != nW &&
     117                 :      17087 :                     0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
     118                 :            :                     nSlotId != nEdtWhich )
     119                 :            :                 {
     120         [ +  - ]:      15768 :                     SfxPoolItem* pCpy = pItem->Clone();
     121                 :      15768 :                     pCpy->SetWhich( nEdtWhich );
     122         [ +  - ]:      15768 :                     pSdrPool->SetPoolDefaultItem( *pCpy );
     123 [ +  - ][ +  - ]:      15768 :                     delete pCpy;
     124                 :            :                 }
     125                 :            :     }
     126                 :            : 
     127 [ +  - ][ +  - ]:       1386 :     SetForbiddenCharsTable( pD->getForbiddenCharacterTable() );
         [ +  - ][ +  - ]
     128                 :            :     // Implementation for asian compression
     129 [ +  - ][ +  - ]:       1386 :     SetCharCompressType( static_cast<sal_uInt16>(pD->getCharacterCompressionType() ));
     130                 :       1386 : }
     131                 :            : 
     132                 :            : /*************************************************************************
     133                 :            : |*
     134                 :            : |* Destruktor
     135                 :            : |*
     136                 :            : \************************************************************************/
     137                 :            : 
     138                 :            : 
     139                 :       1297 : SwDrawDocument::~SwDrawDocument()
     140                 :            : {
     141 [ +  - ][ +  - ]:       1297 :     Broadcast(SdrHint(HINT_MODELCLEARED));
                 [ +  - ]
     142                 :            : 
     143         [ +  - ]:       1297 :     ClearModel(sal_True);
     144         [ -  + ]:       2594 : }
     145                 :            : 
     146                 :            : /*************************************************************************
     147                 :            : |*
     148                 :            : |* Diese Methode erzeugt eine neue Seite (SdPage) und gibt einen Zeiger
     149                 :            : |* darauf zurueck. Die Drawing Engine benutzt diese Methode beim Laden
     150                 :            : |* zur Erzeugung von Seiten (deren Typ sie ja nicht kennt, da es ABLEITUNGEN
     151                 :            : |* der SdrPage sind).
     152                 :            : |*
     153                 :            : \************************************************************************/
     154                 :            : 
     155                 :            : 
     156                 :       1386 : SdrPage* SwDrawDocument::AllocPage(bool bMasterPage)
     157                 :            : {
     158         [ +  - ]:       1386 :     SwDPage* pPage = new SwDPage(*this, 0 != bMasterPage);
     159 [ +  - ][ +  - ]:       1386 :     pPage->SetName(rtl::OUString("Controls"));
                 [ +  - ]
     160                 :       1386 :     return pPage;
     161                 :            : }
     162                 :            : 
     163                 :          0 : uno::Reference<embed::XStorage> SwDrawDocument::GetDocumentStorage() const
     164                 :            : {
     165                 :          0 :     return pDoc->GetDocStorage();
     166                 :            : }
     167                 :            : 
     168                 :          0 : SdrLayerID SwDrawDocument::GetControlExportLayerId( const SdrObject & ) const
     169                 :            : {
     170                 :            :     //fuer Versionen < 5.0, es gab nur Hell und Heaven
     171                 :          0 :     return (SdrLayerID)pDoc->GetHeavenId();
     172                 :            : }
     173                 :            : 
     174                 :          0 : uno::Reference< uno::XInterface > SwDrawDocument::createUnoModel()
     175                 :            : {
     176                 :            : 
     177                 :          0 :     uno::Reference< uno::XInterface > xModel;
     178                 :            : 
     179                 :            :     try
     180                 :            :     {
     181         [ #  # ]:          0 :         if ( GetDoc().GetDocShell() )
     182                 :            :         {
     183 [ #  # ][ #  # ]:          0 :             xModel = GetDoc().GetDocShell()->GetModel();
                 [ #  # ]
     184                 :            :         }
     185                 :            :     }
     186         [ #  # ]:          0 :     catch( uno::RuntimeException& )
     187                 :            :     {
     188                 :            :         OSL_FAIL( "<SwDrawDocument::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
     189                 :            :     }
     190                 :            : 
     191                 :          0 :     return xModel;
     192                 :            : }
     193                 :            : 
     194                 :            : 
     195                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10