LCOV - code coverage report
Current view: top level - sw/source/core/draw - drawdoc.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 37 46 80.4 %
Date: 2015-06-13 12:38:46 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svx/svxids.hrc>
      21             : #include <tools/stream.hxx>
      22             : #include <unotools/pathoptions.hxx>
      23             : #include <sot/storage.hxx>
      24             : #include <svl/intitem.hxx>
      25             : #include <editeng/forbiddencharacterstable.hxx>
      26             : 
      27             : #include <unotools/ucbstreamhelper.hxx>
      28             : #include <svx/xtable.hxx>
      29             : #include <svx/drawitem.hxx>
      30             : #include <viewsh.hxx>
      31             : #include <doc.hxx>
      32             : #include <rootfrm.hxx>
      33             : #include <drawdoc.hxx>
      34             : #include <dpage.hxx>
      35             : #include <docsh.hxx>
      36             : #include <shellio.hxx>
      37             : #include <hintids.hxx>
      38             : #include <com/sun/star/embed/ElementModes.hpp>
      39             : #include <DocumentSettingManager.hxx>
      40             : #include <IDocumentDrawModelAccess.hxx>
      41             : 
      42             : using namespace com::sun::star;
      43             : 
      44             : // Constructor
      45             : 
      46        2958 : const OUString GetPalettePath()
      47             : {
      48        2958 :     SvtPathOptions aPathOpt;
      49        2958 :     return aPathOpt.GetPalettePath();
      50             : }
      51             : 
      52        2958 : SwDrawModel::SwDrawModel(SwDoc *const pDoc)
      53        2958 :     : FmFormModel( ::GetPalettePath(), &pDoc->GetAttrPool(),
      54        2958 :                      pDoc->GetDocShell(), true )
      55        2958 :     , m_pDoc( pDoc )
      56             : {
      57        2958 :     SetScaleUnit( MAP_TWIP );
      58        2958 :     SetSwapGraphics( true );
      59             : 
      60             :     // use common InitDrawModelAndDocShell which will set the associations as needed,
      61             :     // including SvxColorTableItem  with WhichID SID_COLOR_TABLE
      62        2958 :     InitDrawModelAndDocShell(m_pDoc->GetDocShell(), this);
      63             : 
      64             :     // copy all the default values to the SdrModel
      65        2958 :     SfxItemPool* pSdrPool = m_pDoc->GetAttrPool().GetSecondaryPool();
      66        2958 :     if( pSdrPool )
      67             :     {
      68             :         const sal_uInt16 aWhichRanges[] =
      69             :             {
      70             :                 RES_CHRATR_BEGIN, RES_CHRATR_END,
      71             :                 RES_PARATR_BEGIN, RES_PARATR_END,
      72             :                 0
      73        2958 :             };
      74             : 
      75        2958 :         SfxItemPool& rDocPool = m_pDoc->GetAttrPool();
      76             :         sal_uInt16 nEdtWhich, nSlotId;
      77             :         const SfxPoolItem* pItem;
      78        8874 :         for( const sal_uInt16* pRangeArr = aWhichRanges;
      79             :             *pRangeArr; pRangeArr += 2 )
      80      195228 :             for( sal_uInt16 nW = *pRangeArr, nEnd = *(pRangeArr+1);
      81             :                     nW < nEnd; ++nW )
      82      378624 :                 if( 0 != (pItem = rDocPool.GetPoolDefaultItem( nW )) &&
      83           0 :                     0 != (nSlotId = rDocPool.GetSlotId( nW ) ) &&
      84           0 :                     nSlotId != nW &&
      85      189312 :                     0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
      86             :                     nSlotId != nEdtWhich )
      87             :                 {
      88           0 :                     SfxPoolItem* pCpy = pItem->Clone();
      89           0 :                     pCpy->SetWhich( nEdtWhich );
      90           0 :                     pSdrPool->SetPoolDefaultItem( *pCpy );
      91           0 :                     delete pCpy;
      92             :                 }
      93             :     }
      94             : 
      95        2958 :     SetForbiddenCharsTable(m_pDoc->GetDocumentSettingManager().getForbiddenCharacterTable());
      96             :     // Implementation for asian compression
      97             :     SetCharCompressType( static_cast<sal_uInt16>(
      98        2958 :             m_pDoc->GetDocumentSettingManager().getCharacterCompressionType()));
      99        2958 : }
     100             : 
     101             : // Destructor
     102             : 
     103        8847 : SwDrawModel::~SwDrawModel()
     104             : {
     105        2949 :     Broadcast(SdrHint(HINT_MODELCLEARED));
     106             : 
     107        2949 :     ClearModel(true);
     108        5898 : }
     109             : 
     110             : /** Create a new page (SdPage) and return a pointer to it back.
     111             :  *
     112             :  * The drawing engine is using this method while loading for the creating of
     113             :  * pages (whose type it not even know, because they are inherited from SdrPage).
     114             :  *
     115             :  * @return Pointer to the new page.
     116             :  */
     117        2958 : SdrPage* SwDrawModel::AllocPage(bool bMasterPage)
     118             : {
     119        2958 :     SwDPage* pPage = new SwDPage(*this, bMasterPage);
     120        2958 :     pPage->SetName(OUString("Controls"));
     121        2958 :     return pPage;
     122             : }
     123             : 
     124          11 : uno::Reference<embed::XStorage> SwDrawModel::GetDocumentStorage() const
     125             : {
     126          11 :     return m_pDoc->GetDocStorage();
     127             : }
     128             : 
     129           0 : SdrLayerID SwDrawModel::GetControlExportLayerId( const SdrObject & ) const
     130             : {
     131             :     //for versions < 5.0, there was only Hell and Heaven
     132           0 :     return static_cast<SdrLayerID>(m_pDoc->getIDocumentDrawModelAccess().GetHeavenId());
     133             : }
     134             : 
     135          74 : uno::Reference< uno::XInterface > SwDrawModel::createUnoModel()
     136             : {
     137          74 :     uno::Reference< uno::XInterface > xModel;
     138             : 
     139             :     try
     140             :     {
     141          74 :         if ( GetDoc().GetDocShell() )
     142             :         {
     143          74 :             xModel = GetDoc().GetDocShell()->GetModel();
     144             :         }
     145             :     }
     146           0 :     catch( uno::RuntimeException& )
     147             :     {
     148             :         OSL_FAIL( "<SwDrawModel::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
     149             :     }
     150             : 
     151          74 :     return xModel;
     152         177 : }
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11