LCOV - code coverage report
Current view: top level - sw/source/core/draw - drawdoc.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 55 60 91.7 %
Date: 2014-04-11 Functions: 6 8 75.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             : 
      40             : using namespace com::sun::star;
      41             : 
      42             : // Constructor
      43             : 
      44        1774 : const OUString GetPalettePath()
      45             : {
      46        1774 :     SvtPathOptions aPathOpt;
      47        1774 :     return aPathOpt.GetPalettePath();
      48             : }
      49             : 
      50        1774 : SwDrawDocument::SwDrawDocument( SwDoc* pD ) :
      51        1774 :     FmFormModel( ::GetPalettePath(), &pD->GetAttrPool(),
      52        1774 :                  pD->GetDocShell(), true ),
      53        1774 :     pDoc( pD )
      54             : {
      55        1774 :     SetScaleUnit( MAP_TWIP );
      56        1774 :     SetSwapGraphics( true );
      57             : 
      58        1774 :     SwDocShell* pDocSh = pDoc->GetDocShell();
      59        1774 :     if ( pDocSh )
      60             :     {
      61        1773 :         SetObjectShell( pDocSh );
      62             :         SvxColorListItem* pColItem = ( SvxColorListItem* )
      63        1773 :                                 ( pDocSh->GetItem( SID_COLOR_TABLE ) );
      64             :         XColorListRef pXCol = pColItem ? pColItem->GetColorList() :
      65        1773 :                                          XColorList::GetStdColorList();
      66        1773 :         SetPropertyList( static_cast<XPropertyList *> (pXCol.get()) );
      67             : 
      68        1773 :         if ( !pColItem )
      69         113 :             pDocSh->PutItem( SvxColorListItem( pXCol, SID_COLOR_TABLE ) );
      70             : 
      71        1773 :         pDocSh->PutItem( SvxGradientListItem( GetGradientList(), SID_GRADIENT_LIST ));
      72        1773 :         pDocSh->PutItem( SvxHatchListItem( GetHatchList(), SID_HATCH_LIST ) );
      73        1773 :         pDocSh->PutItem( SvxBitmapListItem( GetBitmapList(), SID_BITMAP_LIST ) );
      74        1773 :         pDocSh->PutItem( SvxDashListItem( GetDashList(), SID_DASH_LIST ) );
      75        1773 :         pDocSh->PutItem( SvxLineEndListItem( GetLineEndList(), SID_LINEEND_LIST ) );
      76        1773 :         pDocSh->PutItem( SfxUInt16Item(SID_ATTR_LINEEND_WIDTH_DEFAULT, 111) );
      77        1773 :         SetObjectShell( pDocSh );
      78             :     }
      79             :     else
      80           1 :         SetPropertyList( static_cast<XPropertyList *> (XColorList::GetStdColorList().get()) );
      81             : 
      82             :     // copy all the default values to the SdrModel
      83        1774 :     SfxItemPool* pSdrPool = pD->GetAttrPool().GetSecondaryPool();
      84        1774 :     if( pSdrPool )
      85             :     {
      86             :         const sal_uInt16 aWhichRanges[] =
      87             :             {
      88             :                 RES_CHRATR_BEGIN, RES_CHRATR_END,
      89             :                 RES_PARATR_BEGIN, RES_PARATR_END,
      90             :                 0
      91        1774 :             };
      92             : 
      93        1774 :         SfxItemPool& rDocPool = pD->GetAttrPool();
      94             :         sal_uInt16 nEdtWhich, nSlotId;
      95             :         const SfxPoolItem* pItem;
      96        5322 :         for( const sal_uInt16* pRangeArr = aWhichRanges;
      97             :             *pRangeArr; pRangeArr += 2 )
      98      117084 :             for( sal_uInt16 nW = *pRangeArr, nEnd = *(pRangeArr+1);
      99             :                     nW < nEnd; ++nW )
     100      248569 :                 if( 0 != (pItem = rDocPool.GetPoolDefaultItem( nW )) &&
     101       42994 :                     0 != (nSlotId = rDocPool.GetSlotId( nW ) ) &&
     102       21497 :                     nSlotId != nW &&
     103      156530 :                     0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
     104             :                     nSlotId != nEdtWhich )
     105             :                 {
     106       19839 :                     SfxPoolItem* pCpy = pItem->Clone();
     107       19839 :                     pCpy->SetWhich( nEdtWhich );
     108       19839 :                     pSdrPool->SetPoolDefaultItem( *pCpy );
     109       19839 :                     delete pCpy;
     110             :                 }
     111             :     }
     112             : 
     113        1774 :     SetForbiddenCharsTable( pD->getForbiddenCharacterTable() );
     114             :     // Implementation for asian compression
     115        1774 :     SetCharCompressType( static_cast<sal_uInt16>(pD->getCharacterCompressionType() ));
     116        1774 : }
     117             : 
     118             : // Destructor
     119             : 
     120        5316 : SwDrawDocument::~SwDrawDocument()
     121             : {
     122        1772 :     Broadcast(SdrHint(HINT_MODELCLEARED));
     123             : 
     124        1772 :     ClearModel(true);
     125        3544 : }
     126             : 
     127             : /** Create a new page (SdPage) and return a pointer to it back.
     128             :  *
     129             :  * The drawing engine is using this method while loading for the creating of
     130             :  * pages (whose type it not even know, because they are inherited from SdrPage).
     131             :  *
     132             :  * @return Pointer to the new page.
     133             :  */
     134        1774 : SdrPage* SwDrawDocument::AllocPage(bool bMasterPage)
     135             : {
     136        1774 :     SwDPage* pPage = new SwDPage(*this, bMasterPage);
     137        1774 :     pPage->SetName(OUString("Controls"));
     138        1774 :     return pPage;
     139             : }
     140             : 
     141           0 : uno::Reference<embed::XStorage> SwDrawDocument::GetDocumentStorage() const
     142             : {
     143           0 :     return pDoc->GetDocStorage();
     144             : }
     145             : 
     146           0 : SdrLayerID SwDrawDocument::GetControlExportLayerId( const SdrObject & ) const
     147             : {
     148             :     //for versions < 5.0, there was only Hell and Heaven
     149           0 :     return (SdrLayerID)pDoc->GetHeavenId();
     150             : }
     151             : 
     152          43 : uno::Reference< uno::XInterface > SwDrawDocument::createUnoModel()
     153             : {
     154          43 :     uno::Reference< uno::XInterface > xModel;
     155             : 
     156             :     try
     157             :     {
     158          43 :         if ( GetDoc().GetDocShell() )
     159             :         {
     160          43 :             xModel = GetDoc().GetDocShell()->GetModel();
     161             :         }
     162             :     }
     163           0 :     catch( uno::RuntimeException& )
     164             :     {
     165             :         OSL_FAIL( "<SwDrawDocument::createUnoModel()> - could *not* retrieve model at <SwDocShell>" );
     166             :     }
     167             : 
     168          43 :     return xModel;
     169             : }
     170             : 
     171             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10