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

Generated by: LCOV version 1.10