1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include <svx/xtable.hxx> 32 #include "svx/xattr.hxx" 33 #include <svx/xpool.hxx> 34 #include <svx/svdattr.hxx> 35 #include <svx/svxids.hrc> 36 #include <svl/itemset.hxx> 37 38 /************************************************************************* 39 |* 40 |* Konstruktor 41 |* 42 \************************************************************************/ 43 44 XOutdevItemPool::XOutdevItemPool( 45 SfxItemPool* _pMaster, 46 sal_uInt16 nAttrStart, 47 sal_uInt16 nAttrEnd, 48 sal_Bool bLoadRefCounts) 49 : SfxItemPool(String("XOutdevItemPool", gsl_getSystemTextEncoding()), nAttrStart, nAttrEnd, 0L, 0L, bLoadRefCounts) 50 { 51 // prepare some defaults 52 const XubString aNullStr; 53 const Bitmap aNullBmp; 54 const basegfx::B2DPolyPolygon aNullPol; 55 const Color aNullLineCol(RGB_Color(COL_BLACK)); 56 const Color aNullFillCol(RGB_COLORDATA( 153, 204, 255 )); 57 const Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY)); 58 const XDash aNullDash; 59 const XGradient aNullGrad(aNullLineCol, RGB_Color(COL_WHITE)); 60 const XHatch aNullHatch(aNullLineCol); 61 62 // get master pointer, evtl. add myself to the end of the pools 63 if(!_pMaster) 64 { 65 _pMaster = this; 66 } 67 else 68 { 69 SfxItemPool* pParent = _pMaster; 70 71 while(pParent->GetSecondaryPool()) 72 { 73 pParent = pParent->GetSecondaryPool(); 74 } 75 76 pParent->SetSecondaryPool(this); 77 } 78 79 // prepare PoolDefaults 80 mppLocalPoolDefaults = new SfxPoolItem*[GetLastWhich() - GetFirstWhich() + 1]; 81 82 mppLocalPoolDefaults[XATTR_LINESTYLE -XATTR_START] = new XLineStyleItem; 83 mppLocalPoolDefaults[XATTR_LINEDASH -XATTR_START] = new XLineDashItem(this,aNullDash); 84 mppLocalPoolDefaults[XATTR_LINEWIDTH -XATTR_START] = new XLineWidthItem; 85 mppLocalPoolDefaults[XATTR_LINECOLOR -XATTR_START] = new XLineColorItem(aNullStr,aNullLineCol); 86 mppLocalPoolDefaults[XATTR_LINESTART -XATTR_START] = new XLineStartItem(this,aNullPol); 87 mppLocalPoolDefaults[XATTR_LINEEND -XATTR_START] = new XLineEndItem (this,aNullPol); 88 mppLocalPoolDefaults[XATTR_LINESTARTWIDTH -XATTR_START] = new XLineStartWidthItem; 89 mppLocalPoolDefaults[XATTR_LINEENDWIDTH -XATTR_START] = new XLineEndWidthItem; 90 mppLocalPoolDefaults[XATTR_LINESTARTCENTER -XATTR_START] = new XLineStartCenterItem; 91 mppLocalPoolDefaults[XATTR_LINEENDCENTER -XATTR_START] = new XLineEndCenterItem; 92 mppLocalPoolDefaults[XATTR_LINETRANSPARENCE -XATTR_START] = new XLineTransparenceItem; 93 mppLocalPoolDefaults[XATTR_LINEJOINT -XATTR_START] = new XLineJointItem; 94 mppLocalPoolDefaults[XATTR_FILLSTYLE -XATTR_START] = new XFillStyleItem; 95 mppLocalPoolDefaults[XATTR_FILLCOLOR -XATTR_START] = new XFillColorItem (aNullStr,aNullFillCol); 96 mppLocalPoolDefaults[XATTR_FILLGRADIENT -XATTR_START] = new XFillGradientItem(this,aNullGrad); 97 mppLocalPoolDefaults[XATTR_FILLHATCH -XATTR_START] = new XFillHatchItem (this,aNullHatch); 98 mppLocalPoolDefaults[XATTR_FILLBITMAP -XATTR_START] = new XFillBitmapItem (this,aNullBmp); 99 mppLocalPoolDefaults[XATTR_FILLTRANSPARENCE -XATTR_START] = new XFillTransparenceItem; 100 mppLocalPoolDefaults[XATTR_GRADIENTSTEPCOUNT -XATTR_START] = new XGradientStepCountItem; 101 mppLocalPoolDefaults[XATTR_FILLBMP_TILE -XATTR_START] = new XFillBmpTileItem; 102 mppLocalPoolDefaults[XATTR_FILLBMP_POS -XATTR_START] = new XFillBmpPosItem; 103 mppLocalPoolDefaults[XATTR_FILLBMP_SIZEX -XATTR_START] = new XFillBmpSizeXItem; 104 mppLocalPoolDefaults[XATTR_FILLBMP_SIZEY -XATTR_START] = new XFillBmpSizeYItem; 105 mppLocalPoolDefaults[XATTR_FILLBMP_SIZELOG -XATTR_START] = new XFillBmpSizeLogItem; 106 mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETX -XATTR_START] = new XFillBmpTileOffsetXItem; 107 mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETY -XATTR_START] = new XFillBmpTileOffsetYItem; 108 mppLocalPoolDefaults[XATTR_FILLBMP_STRETCH -XATTR_START] = new XFillBmpStretchItem; 109 mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETX -XATTR_START] = new XFillBmpPosOffsetXItem; 110 mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETY -XATTR_START] = new XFillBmpPosOffsetYItem; 111 mppLocalPoolDefaults[XATTR_FILLFLOATTRANSPARENCE -XATTR_START] = new XFillFloatTransparenceItem( this, aNullGrad, sal_False ); 112 mppLocalPoolDefaults[XATTR_SECONDARYFILLCOLOR -XATTR_START] = new XSecondaryFillColorItem(aNullStr, aNullFillCol); 113 mppLocalPoolDefaults[XATTR_FILLBACKGROUND -XATTR_START] = new XFillBackgroundItem; 114 mppLocalPoolDefaults[XATTR_FORMTXTSTYLE -XATTR_START] = new XFormTextStyleItem; 115 mppLocalPoolDefaults[XATTR_FORMTXTADJUST -XATTR_START] = new XFormTextAdjustItem; 116 mppLocalPoolDefaults[XATTR_FORMTXTDISTANCE -XATTR_START] = new XFormTextDistanceItem; 117 mppLocalPoolDefaults[XATTR_FORMTXTSTART -XATTR_START] = new XFormTextStartItem; 118 mppLocalPoolDefaults[XATTR_FORMTXTMIRROR -XATTR_START] = new XFormTextMirrorItem; 119 mppLocalPoolDefaults[XATTR_FORMTXTOUTLINE -XATTR_START] = new XFormTextOutlineItem; 120 mppLocalPoolDefaults[XATTR_FORMTXTSHADOW -XATTR_START] = new XFormTextShadowItem; 121 mppLocalPoolDefaults[XATTR_FORMTXTSHDWCOLOR -XATTR_START] = new XFormTextShadowColorItem(aNullStr,aNullShadowCol); 122 mppLocalPoolDefaults[XATTR_FORMTXTSHDWXVAL -XATTR_START] = new XFormTextShadowXValItem; 123 mppLocalPoolDefaults[XATTR_FORMTXTSHDWYVAL -XATTR_START] = new XFormTextShadowYValItem; 124 mppLocalPoolDefaults[XATTR_FORMTXTSTDFORM -XATTR_START] = new XFormTextStdFormItem; 125 mppLocalPoolDefaults[XATTR_FORMTXTHIDEFORM -XATTR_START] = new XFormTextHideFormItem; 126 mppLocalPoolDefaults[XATTR_FORMTXTSHDWTRANSP -XATTR_START] = new XFormTextShadowTranspItem; 127 128 // create SetItems 129 SfxItemSet* pSet=new SfxItemSet(*_pMaster, XATTR_LINE_FIRST, XATTR_LINE_LAST); 130 mppLocalPoolDefaults[XATTRSET_LINE - XATTR_START] = new XLineAttrSetItem(pSet); 131 pSet=new SfxItemSet(*_pMaster, XATTR_FILL_FIRST, XATTR_FILL_LAST); 132 mppLocalPoolDefaults[XATTRSET_FILL - XATTR_START] = new XFillAttrSetItem(pSet); 133 134 // create ItemInfos 135 mpLocalItemInfos = new SfxItemInfo[GetLastWhich() - GetFirstWhich() + 1]; 136 for(sal_uInt16 i(GetFirstWhich()); i <= GetLastWhich(); i++) 137 { 138 mpLocalItemInfos[i - XATTR_START]._nSID = 0; 139 mpLocalItemInfos[i - XATTR_START]._nFlags = SFX_ITEM_POOLABLE; 140 } 141 142 mpLocalItemInfos[XATTR_LINESTYLE -XATTR_START]._nSID = SID_ATTR_LINE_STYLE; 143 mpLocalItemInfos[XATTR_LINEDASH -XATTR_START]._nSID = SID_ATTR_LINE_DASH; 144 mpLocalItemInfos[XATTR_LINEWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_WIDTH; 145 mpLocalItemInfos[XATTR_LINECOLOR -XATTR_START]._nSID = SID_ATTR_LINE_COLOR; 146 mpLocalItemInfos[XATTR_LINESTART -XATTR_START]._nSID = SID_ATTR_LINE_START; 147 mpLocalItemInfos[XATTR_LINEEND -XATTR_START]._nSID = SID_ATTR_LINE_END; 148 mpLocalItemInfos[XATTR_LINESTARTWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_STARTWIDTH; 149 mpLocalItemInfos[XATTR_LINEENDWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_ENDWIDTH; 150 mpLocalItemInfos[XATTR_LINESTARTCENTER -XATTR_START]._nSID = SID_ATTR_LINE_STARTCENTER; 151 mpLocalItemInfos[XATTR_LINEENDCENTER -XATTR_START]._nSID = SID_ATTR_LINE_ENDCENTER; 152 mpLocalItemInfos[XATTR_FILLSTYLE -XATTR_START]._nSID = SID_ATTR_FILL_STYLE; 153 mpLocalItemInfos[XATTR_FILLCOLOR -XATTR_START]._nSID = SID_ATTR_FILL_COLOR; 154 mpLocalItemInfos[XATTR_FILLGRADIENT -XATTR_START]._nSID = SID_ATTR_FILL_GRADIENT; 155 mpLocalItemInfos[XATTR_FILLHATCH -XATTR_START]._nSID = SID_ATTR_FILL_HATCH; 156 mpLocalItemInfos[XATTR_FILLBITMAP -XATTR_START]._nSID = SID_ATTR_FILL_BITMAP; 157 mpLocalItemInfos[XATTR_FORMTXTSTYLE -XATTR_START]._nSID = SID_FORMTEXT_STYLE; 158 mpLocalItemInfos[XATTR_FORMTXTADJUST -XATTR_START]._nSID = SID_FORMTEXT_ADJUST; 159 mpLocalItemInfos[XATTR_FORMTXTDISTANCE -XATTR_START]._nSID = SID_FORMTEXT_DISTANCE; 160 mpLocalItemInfos[XATTR_FORMTXTSTART -XATTR_START]._nSID = SID_FORMTEXT_START; 161 mpLocalItemInfos[XATTR_FORMTXTMIRROR -XATTR_START]._nSID = SID_FORMTEXT_MIRROR; 162 mpLocalItemInfos[XATTR_FORMTXTOUTLINE -XATTR_START]._nSID = SID_FORMTEXT_OUTLINE; 163 mpLocalItemInfos[XATTR_FORMTXTSHADOW -XATTR_START]._nSID = SID_FORMTEXT_SHADOW; 164 mpLocalItemInfos[XATTR_FORMTXTSHDWCOLOR -XATTR_START]._nSID = SID_FORMTEXT_SHDWCOLOR; 165 mpLocalItemInfos[XATTR_FORMTXTSHDWXVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWXVAL; 166 mpLocalItemInfos[XATTR_FORMTXTSHDWYVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWYVAL; 167 mpLocalItemInfos[XATTR_FORMTXTSTDFORM -XATTR_START]._nSID = SID_FORMTEXT_STDFORM; 168 mpLocalItemInfos[XATTR_FORMTXTHIDEFORM -XATTR_START]._nSID = SID_FORMTEXT_HIDEFORM; 169 170 // if it's my own creation level, set Defaults and ItemInfos 171 if(XATTR_START == GetFirstWhich() && XATTR_END == GetLastWhich()) 172 { 173 SetDefaults(mppLocalPoolDefaults); 174 SetItemInfos(mpLocalItemInfos); 175 } 176 } 177 178 /************************************************************************* 179 |* 180 |* copy ctor, sorgt dafuer, dass die static defaults gecloned werden 181 |* (Parameter 2 = sal_True) 182 |* 183 \************************************************************************/ 184 185 XOutdevItemPool::XOutdevItemPool(const XOutdevItemPool& rPool) 186 : SfxItemPool(rPool, sal_True), 187 mppLocalPoolDefaults(0L), 188 mpLocalItemInfos(0L) 189 { 190 } 191 192 /************************************************************************* 193 |* 194 |* Clone() 195 |* 196 \************************************************************************/ 197 198 SfxItemPool* XOutdevItemPool::Clone() const 199 { 200 return new XOutdevItemPool(*this); 201 } 202 203 /************************************************************************* 204 |* 205 |* Destruktor 206 |* 207 \************************************************************************/ 208 209 XOutdevItemPool::~XOutdevItemPool() 210 { 211 Delete(); 212 213 // remove own static defaults 214 if(mppLocalPoolDefaults) 215 { 216 SfxPoolItem** ppDefaultItem = mppLocalPoolDefaults; 217 for(sal_uInt16 i(GetLastWhich() - GetFirstWhich() + 1); i; --i, ++ppDefaultItem) 218 { 219 if ( *ppDefaultItem ) //Teile schon von abgel. Klasse abgeraeumt! 220 { 221 SetRefCount( **ppDefaultItem, 0 ); 222 delete *ppDefaultItem; 223 } 224 } 225 226 delete[] mppLocalPoolDefaults; 227 } 228 229 if(mpLocalItemInfos) 230 { 231 delete[] mpLocalItemInfos; 232 } 233 } 234 235 // eof 236