LCOV - code coverage report
Current view: top level - libreoffice/svx/source/xoutdev - xpool.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 115 121 95.0 %
Date: 2012-12-27 Functions: 3 5 60.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/xtable.hxx>
      21             : #include "svx/xattr.hxx"
      22             : #include <svx/xpool.hxx>
      23             : #include <svx/svdattr.hxx>
      24             : #include <svx/svxids.hrc>
      25             : #include <svl/itemset.hxx>
      26             : 
      27             : /*************************************************************************
      28             : |*
      29             : |* Constructor
      30             : |*
      31             : \************************************************************************/
      32             : 
      33         408 : XOutdevItemPool::XOutdevItemPool(
      34             :     SfxItemPool* _pMaster,
      35             :     sal_uInt16 nAttrStart,
      36             :     sal_uInt16 nAttrEnd,
      37             :     sal_Bool bLoadRefCounts)
      38         408 : :   SfxItemPool(String("XOutdevItemPool", osl_getThreadTextEncoding()), nAttrStart, nAttrEnd, 0L, 0L, bLoadRefCounts)
      39             : {
      40             :     // prepare some defaults
      41         408 :     const XubString aNullStr;
      42         408 :     const Bitmap aNullBmp;
      43         408 :     const basegfx::B2DPolyPolygon aNullPol;
      44         408 :     const Color aNullLineCol(RGB_Color(COL_BLACK));
      45         408 :     const Color aNullFillCol(RGB_COLORDATA( 153, 204, 255 ));
      46         408 :     const Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY));
      47         408 :     const XDash aNullDash;
      48         408 :     const XGradient aNullGrad(aNullLineCol, RGB_Color(COL_WHITE));
      49         408 :     const XHatch aNullHatch(aNullLineCol);
      50             : 
      51             :     // get master pointer, evtl. add myself to the end of the pools
      52         408 :     if(!_pMaster)
      53             :     {
      54         146 :         _pMaster = this;
      55             :     }
      56             :     else
      57             :     {
      58         262 :         SfxItemPool* pParent = _pMaster;
      59             : 
      60         524 :         while(pParent->GetSecondaryPool())
      61             :         {
      62           0 :             pParent = pParent->GetSecondaryPool();
      63             :         }
      64             : 
      65         262 :         pParent->SetSecondaryPool(this);
      66             :     }
      67             : 
      68             :     // prepare PoolDefaults
      69         408 :     mppLocalPoolDefaults = new SfxPoolItem*[GetLastWhich() - GetFirstWhich() + 1];
      70             : 
      71         408 :     mppLocalPoolDefaults[XATTR_LINESTYLE          -XATTR_START] = new XLineStyleItem;
      72         408 :     mppLocalPoolDefaults[XATTR_LINEDASH           -XATTR_START] = new XLineDashItem(this,aNullDash);
      73         408 :     mppLocalPoolDefaults[XATTR_LINEWIDTH          -XATTR_START] = new XLineWidthItem;
      74         408 :     mppLocalPoolDefaults[XATTR_LINECOLOR          -XATTR_START] = new XLineColorItem(aNullStr,aNullLineCol);
      75         408 :     mppLocalPoolDefaults[XATTR_LINESTART          -XATTR_START] = new XLineStartItem(this,aNullPol);
      76         408 :     mppLocalPoolDefaults[XATTR_LINEEND            -XATTR_START] = new XLineEndItem  (this,aNullPol);
      77         408 :     mppLocalPoolDefaults[XATTR_LINESTARTWIDTH     -XATTR_START] = new XLineStartWidthItem;
      78         408 :     mppLocalPoolDefaults[XATTR_LINEENDWIDTH       -XATTR_START] = new XLineEndWidthItem;
      79         408 :     mppLocalPoolDefaults[XATTR_LINESTARTCENTER    -XATTR_START] = new XLineStartCenterItem;
      80         408 :     mppLocalPoolDefaults[XATTR_LINEENDCENTER      -XATTR_START] = new XLineEndCenterItem;
      81         408 :     mppLocalPoolDefaults[XATTR_LINETRANSPARENCE   -XATTR_START] = new XLineTransparenceItem;
      82         408 :     mppLocalPoolDefaults[XATTR_LINEJOINT            -XATTR_START] = new XLineJointItem;
      83         408 :     mppLocalPoolDefaults[XATTR_LINECAP            -XATTR_START] = new XLineCapItem;
      84         408 :     mppLocalPoolDefaults[XATTR_FILLSTYLE                -XATTR_START] = new XFillStyleItem;
      85         408 :     mppLocalPoolDefaults[XATTR_FILLCOLOR                -XATTR_START] = new XFillColorItem   (aNullStr,aNullFillCol);
      86         408 :     mppLocalPoolDefaults[XATTR_FILLGRADIENT         -XATTR_START] = new XFillGradientItem(aNullGrad);
      87         408 :     mppLocalPoolDefaults[XATTR_FILLHATCH                -XATTR_START] = new XFillHatchItem   (this,aNullHatch);
      88         408 :     mppLocalPoolDefaults[XATTR_FILLBITMAP               -XATTR_START] = new XFillBitmapItem  (this,aNullBmp);
      89         408 :     mppLocalPoolDefaults[XATTR_FILLTRANSPARENCE     -XATTR_START] = new XFillTransparenceItem;
      90         408 :     mppLocalPoolDefaults[XATTR_GRADIENTSTEPCOUNT        -XATTR_START] = new XGradientStepCountItem;
      91         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_TILE         -XATTR_START] = new XFillBmpTileItem;
      92         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_POS          -XATTR_START] = new XFillBmpPosItem;
      93         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_SIZEX            -XATTR_START] = new XFillBmpSizeXItem;
      94         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_SIZEY            -XATTR_START] = new XFillBmpSizeYItem;
      95         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_SIZELOG      -XATTR_START] = new XFillBmpSizeLogItem;
      96         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETX  -XATTR_START] = new XFillBmpTileOffsetXItem;
      97         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETY  -XATTR_START] = new XFillBmpTileOffsetYItem;
      98         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_STRETCH      -XATTR_START] = new XFillBmpStretchItem;
      99         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETX       -XATTR_START] = new XFillBmpPosOffsetXItem;
     100         408 :     mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETY       -XATTR_START] = new XFillBmpPosOffsetYItem;
     101         408 :     mppLocalPoolDefaults[XATTR_FILLFLOATTRANSPARENCE    -XATTR_START] = new XFillFloatTransparenceItem( this, aNullGrad, sal_False );
     102         408 :     mppLocalPoolDefaults[XATTR_SECONDARYFILLCOLOR       -XATTR_START] = new XSecondaryFillColorItem(aNullStr, aNullFillCol);
     103         408 :     mppLocalPoolDefaults[XATTR_FILLBACKGROUND           -XATTR_START] = new XFillBackgroundItem;
     104         408 :     mppLocalPoolDefaults[XATTR_FORMTXTSTYLE       -XATTR_START] = new XFormTextStyleItem;
     105         408 :     mppLocalPoolDefaults[XATTR_FORMTXTADJUST      -XATTR_START] = new XFormTextAdjustItem;
     106         408 :     mppLocalPoolDefaults[XATTR_FORMTXTDISTANCE    -XATTR_START] = new XFormTextDistanceItem;
     107         408 :     mppLocalPoolDefaults[XATTR_FORMTXTSTART       -XATTR_START] = new XFormTextStartItem;
     108         408 :     mppLocalPoolDefaults[XATTR_FORMTXTMIRROR      -XATTR_START] = new XFormTextMirrorItem;
     109         408 :     mppLocalPoolDefaults[XATTR_FORMTXTOUTLINE     -XATTR_START] = new XFormTextOutlineItem;
     110         408 :     mppLocalPoolDefaults[XATTR_FORMTXTSHADOW      -XATTR_START] = new XFormTextShadowItem;
     111         408 :     mppLocalPoolDefaults[XATTR_FORMTXTSHDWCOLOR   -XATTR_START] = new XFormTextShadowColorItem(aNullStr,aNullShadowCol);
     112         408 :     mppLocalPoolDefaults[XATTR_FORMTXTSHDWXVAL    -XATTR_START] = new XFormTextShadowXValItem;
     113         408 :     mppLocalPoolDefaults[XATTR_FORMTXTSHDWYVAL    -XATTR_START] = new XFormTextShadowYValItem;
     114         408 :     mppLocalPoolDefaults[XATTR_FORMTXTSTDFORM     -XATTR_START] = new XFormTextStdFormItem;
     115         408 :     mppLocalPoolDefaults[XATTR_FORMTXTHIDEFORM    -XATTR_START] = new XFormTextHideFormItem;
     116         408 :     mppLocalPoolDefaults[XATTR_FORMTXTSHDWTRANSP  -XATTR_START] = new XFormTextShadowTranspItem;
     117             : 
     118             :     // create SetItems
     119         408 :     SfxItemSet* pSet=new SfxItemSet(*_pMaster, XATTR_LINE_FIRST, XATTR_LINE_LAST);
     120         408 :     mppLocalPoolDefaults[XATTRSET_LINE - XATTR_START] = new XLineAttrSetItem(pSet);
     121         408 :     pSet=new SfxItemSet(*_pMaster, XATTR_FILL_FIRST, XATTR_FILL_LAST);
     122         408 :     mppLocalPoolDefaults[XATTRSET_FILL - XATTR_START] = new XFillAttrSetItem(pSet);
     123             : 
     124             :     // create ItemInfos
     125         408 :     mpLocalItemInfos = new SfxItemInfo[GetLastWhich() - GetFirstWhich() + 1];
     126       94458 :     for(sal_uInt16 i(GetFirstWhich()); i <= GetLastWhich(); i++)
     127             :     {
     128       94050 :         mpLocalItemInfos[i - XATTR_START]._nSID = 0;
     129       94050 :         mpLocalItemInfos[i - XATTR_START]._nFlags = SFX_ITEM_POOLABLE;
     130             :     }
     131             : 
     132         408 :     mpLocalItemInfos[XATTR_LINESTYLE        -XATTR_START]._nSID = SID_ATTR_LINE_STYLE;
     133         408 :     mpLocalItemInfos[XATTR_LINEDASH         -XATTR_START]._nSID = SID_ATTR_LINE_DASH;
     134         408 :     mpLocalItemInfos[XATTR_LINEWIDTH        -XATTR_START]._nSID = SID_ATTR_LINE_WIDTH;
     135         408 :     mpLocalItemInfos[XATTR_LINECOLOR        -XATTR_START]._nSID = SID_ATTR_LINE_COLOR;
     136         408 :     mpLocalItemInfos[XATTR_LINESTART        -XATTR_START]._nSID = SID_ATTR_LINE_START;
     137         408 :     mpLocalItemInfos[XATTR_LINEEND          -XATTR_START]._nSID = SID_ATTR_LINE_END;
     138         408 :     mpLocalItemInfos[XATTR_LINESTARTWIDTH   -XATTR_START]._nSID = SID_ATTR_LINE_STARTWIDTH;
     139         408 :     mpLocalItemInfos[XATTR_LINEENDWIDTH     -XATTR_START]._nSID = SID_ATTR_LINE_ENDWIDTH;
     140         408 :     mpLocalItemInfos[XATTR_LINESTARTCENTER  -XATTR_START]._nSID = SID_ATTR_LINE_STARTCENTER;
     141         408 :     mpLocalItemInfos[XATTR_LINEENDCENTER    -XATTR_START]._nSID = SID_ATTR_LINE_ENDCENTER;
     142         408 :     mpLocalItemInfos[XATTR_FILLSTYLE        -XATTR_START]._nSID = SID_ATTR_FILL_STYLE;
     143         408 :     mpLocalItemInfos[XATTR_FILLCOLOR        -XATTR_START]._nSID = SID_ATTR_FILL_COLOR;
     144         408 :     mpLocalItemInfos[XATTR_FILLGRADIENT     -XATTR_START]._nSID = SID_ATTR_FILL_GRADIENT;
     145         408 :     mpLocalItemInfos[XATTR_FILLHATCH        -XATTR_START]._nSID = SID_ATTR_FILL_HATCH;
     146         408 :     mpLocalItemInfos[XATTR_FILLBITMAP       -XATTR_START]._nSID = SID_ATTR_FILL_BITMAP;
     147         408 :     mpLocalItemInfos[XATTR_FORMTXTSTYLE     -XATTR_START]._nSID = SID_FORMTEXT_STYLE;
     148         408 :     mpLocalItemInfos[XATTR_FORMTXTADJUST    -XATTR_START]._nSID = SID_FORMTEXT_ADJUST;
     149         408 :     mpLocalItemInfos[XATTR_FORMTXTDISTANCE  -XATTR_START]._nSID = SID_FORMTEXT_DISTANCE;
     150         408 :     mpLocalItemInfos[XATTR_FORMTXTSTART     -XATTR_START]._nSID = SID_FORMTEXT_START;
     151         408 :     mpLocalItemInfos[XATTR_FORMTXTMIRROR    -XATTR_START]._nSID = SID_FORMTEXT_MIRROR;
     152         408 :     mpLocalItemInfos[XATTR_FORMTXTOUTLINE   -XATTR_START]._nSID = SID_FORMTEXT_OUTLINE;
     153         408 :     mpLocalItemInfos[XATTR_FORMTXTSHADOW    -XATTR_START]._nSID = SID_FORMTEXT_SHADOW;
     154         408 :     mpLocalItemInfos[XATTR_FORMTXTSHDWCOLOR -XATTR_START]._nSID = SID_FORMTEXT_SHDWCOLOR;
     155         408 :     mpLocalItemInfos[XATTR_FORMTXTSHDWXVAL  -XATTR_START]._nSID = SID_FORMTEXT_SHDWXVAL;
     156         408 :     mpLocalItemInfos[XATTR_FORMTXTSHDWYVAL  -XATTR_START]._nSID = SID_FORMTEXT_SHDWYVAL;
     157         408 :     mpLocalItemInfos[XATTR_FORMTXTSTDFORM   -XATTR_START]._nSID = SID_FORMTEXT_STDFORM;
     158         408 :     mpLocalItemInfos[XATTR_FORMTXTHIDEFORM  -XATTR_START]._nSID = SID_FORMTEXT_HIDEFORM;
     159             : 
     160             :     // if it's my own creation level, set Defaults and ItemInfos
     161         408 :     if(XATTR_START == GetFirstWhich() && XATTR_END == GetLastWhich())
     162             :     {
     163          14 :         SetDefaults(mppLocalPoolDefaults);
     164          14 :         SetItemInfos(mpLocalItemInfos);
     165         408 :     }
     166         408 : }
     167             : 
     168             : /*************************************************************************
     169             : |*
     170             : |* copy ctor, sorgt dafuer, dass die static defaults gecloned werden
     171             : |*            (Parameter 2 = sal_True)
     172             : |*
     173             : \************************************************************************/
     174             : 
     175           0 : XOutdevItemPool::XOutdevItemPool(const XOutdevItemPool& rPool)
     176             : :   SfxItemPool(rPool, sal_True),
     177             :     mppLocalPoolDefaults(0L),
     178           0 :     mpLocalItemInfos(0L)
     179             : {
     180           0 : }
     181             : 
     182             : /*************************************************************************
     183             : |*
     184             : |* Clone()
     185             : |*
     186             : \************************************************************************/
     187             : 
     188           0 : SfxItemPool* XOutdevItemPool::Clone() const
     189             : {
     190           0 :     return new XOutdevItemPool(*this);
     191             : }
     192             : 
     193             : /*************************************************************************
     194             : |*
     195             : |* Destruktor
     196             : |*
     197             : \************************************************************************/
     198             : 
     199         398 : XOutdevItemPool::~XOutdevItemPool()
     200             : {
     201         198 :     Delete();
     202             : 
     203             :     // remove own static defaults
     204         198 :     if(mppLocalPoolDefaults)
     205             :     {
     206         198 :         SfxPoolItem** ppDefaultItem = mppLocalPoolDefaults;
     207       46746 :         for(sal_uInt16 i(GetLastWhich() - GetFirstWhich() + 1); i; --i, ++ppDefaultItem)
     208             :         {
     209       46548 :             if ( *ppDefaultItem ) //Teile schon von abgel. Klasse abgeraeumt!
     210             :             {
     211        9504 :                 SetRefCount( **ppDefaultItem, 0 );
     212        9504 :                 delete *ppDefaultItem;
     213             :             }
     214             :         }
     215             : 
     216         198 :         delete[] mppLocalPoolDefaults;
     217             :     }
     218             : 
     219         198 :     if(mpLocalItemInfos)
     220             :     {
     221         198 :         delete[] mpLocalItemInfos;
     222             :     }
     223         200 : }
     224             : 
     225             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10