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 7788 : XOutdevItemPool::XOutdevItemPool(
28 : SfxItemPool* _pMaster,
29 : sal_uInt16 nAttrStart,
30 : sal_uInt16 nAttrEnd,
31 : bool bLoadRefCounts)
32 7788 : : SfxItemPool("XOutdevItemPool", nAttrStart, nAttrEnd, 0L, 0L, bLoadRefCounts)
33 : {
34 : // prepare some defaults
35 7788 : const OUString aNullStr;
36 15576 : const Graphic aNullGraphic;
37 15576 : const basegfx::B2DPolyPolygon aNullPol;
38 7788 : const Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); // #i121448# Use defined default color
39 7788 : const Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING); // #i121448# Use defined default color
40 7788 : const Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY));
41 7788 : const XDash aNullDash;
42 7788 : const XGradient aNullGrad(RGB_Color(COL_BLACK), RGB_Color(COL_WHITE));
43 7788 : const XHatch aNullHatch(aNullLineCol);
44 :
45 : // get master pointer, evtl. add myself to the end of the pools
46 7788 : if(!_pMaster)
47 : {
48 2648 : _pMaster = this;
49 : }
50 : else
51 : {
52 5140 : SfxItemPool* pParent = _pMaster;
53 :
54 10280 : while(pParent->GetSecondaryPool())
55 : {
56 0 : pParent = pParent->GetSecondaryPool();
57 : }
58 :
59 5140 : pParent->SetSecondaryPool(this);
60 : }
61 :
62 : // prepare PoolDefaults
63 7788 : mppLocalPoolDefaults = new SfxPoolItem*[GetLastWhich() - GetFirstWhich() + 1];
64 :
65 7788 : mppLocalPoolDefaults[XATTR_LINESTYLE -XATTR_START] = new XLineStyleItem;
66 7788 : mppLocalPoolDefaults[XATTR_LINEDASH -XATTR_START] = new XLineDashItem(this,aNullDash);
67 7788 : mppLocalPoolDefaults[XATTR_LINEWIDTH -XATTR_START] = new XLineWidthItem;
68 7788 : mppLocalPoolDefaults[XATTR_LINECOLOR -XATTR_START] = new XLineColorItem(aNullStr,aNullLineCol);
69 7788 : mppLocalPoolDefaults[XATTR_LINESTART -XATTR_START] = new XLineStartItem(this,aNullPol);
70 7788 : mppLocalPoolDefaults[XATTR_LINEEND -XATTR_START] = new XLineEndItem (this,aNullPol);
71 7788 : mppLocalPoolDefaults[XATTR_LINESTARTWIDTH -XATTR_START] = new XLineStartWidthItem;
72 7788 : mppLocalPoolDefaults[XATTR_LINEENDWIDTH -XATTR_START] = new XLineEndWidthItem;
73 7788 : mppLocalPoolDefaults[XATTR_LINESTARTCENTER -XATTR_START] = new XLineStartCenterItem;
74 7788 : mppLocalPoolDefaults[XATTR_LINEENDCENTER -XATTR_START] = new XLineEndCenterItem;
75 7788 : mppLocalPoolDefaults[XATTR_LINETRANSPARENCE -XATTR_START] = new XLineTransparenceItem;
76 7788 : mppLocalPoolDefaults[XATTR_LINEJOINT -XATTR_START] = new XLineJointItem;
77 7788 : mppLocalPoolDefaults[XATTR_LINECAP -XATTR_START] = new XLineCapItem;
78 7788 : mppLocalPoolDefaults[XATTR_FILLSTYLE -XATTR_START] = new XFillStyleItem;
79 7788 : mppLocalPoolDefaults[XATTR_FILLCOLOR -XATTR_START] = new XFillColorItem (aNullStr,aNullFillCol);
80 7788 : mppLocalPoolDefaults[XATTR_FILLGRADIENT -XATTR_START] = new XFillGradientItem(aNullGrad);
81 7788 : mppLocalPoolDefaults[XATTR_FILLHATCH -XATTR_START] = new XFillHatchItem (this,aNullHatch);
82 7788 : mppLocalPoolDefaults[XATTR_FILLBITMAP -XATTR_START] = new XFillBitmapItem (this, aNullGraphic);
83 7788 : mppLocalPoolDefaults[XATTR_FILLTRANSPARENCE -XATTR_START] = new XFillTransparenceItem;
84 7788 : mppLocalPoolDefaults[XATTR_GRADIENTSTEPCOUNT -XATTR_START] = new XGradientStepCountItem;
85 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_TILE -XATTR_START] = new XFillBmpTileItem;
86 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_POS -XATTR_START] = new XFillBmpPosItem;
87 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_SIZEX -XATTR_START] = new XFillBmpSizeXItem;
88 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_SIZEY -XATTR_START] = new XFillBmpSizeYItem;
89 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_SIZELOG -XATTR_START] = new XFillBmpSizeLogItem;
90 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETX -XATTR_START] = new XFillBmpTileOffsetXItem;
91 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETY -XATTR_START] = new XFillBmpTileOffsetYItem;
92 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_STRETCH -XATTR_START] = new XFillBmpStretchItem;
93 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETX -XATTR_START] = new XFillBmpPosOffsetXItem;
94 7788 : mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETY -XATTR_START] = new XFillBmpPosOffsetYItem;
95 7788 : mppLocalPoolDefaults[XATTR_FILLFLOATTRANSPARENCE -XATTR_START] = new XFillFloatTransparenceItem( this, aNullGrad, false );
96 7788 : mppLocalPoolDefaults[XATTR_SECONDARYFILLCOLOR -XATTR_START] = new XSecondaryFillColorItem(aNullStr, aNullFillCol);
97 7788 : mppLocalPoolDefaults[XATTR_FILLBACKGROUND -XATTR_START] = new XFillBackgroundItem;
98 7788 : mppLocalPoolDefaults[XATTR_FORMTXTSTYLE -XATTR_START] = new XFormTextStyleItem;
99 7788 : mppLocalPoolDefaults[XATTR_FORMTXTADJUST -XATTR_START] = new XFormTextAdjustItem;
100 7788 : mppLocalPoolDefaults[XATTR_FORMTXTDISTANCE -XATTR_START] = new XFormTextDistanceItem;
101 7788 : mppLocalPoolDefaults[XATTR_FORMTXTSTART -XATTR_START] = new XFormTextStartItem;
102 7788 : mppLocalPoolDefaults[XATTR_FORMTXTMIRROR -XATTR_START] = new XFormTextMirrorItem;
103 7788 : mppLocalPoolDefaults[XATTR_FORMTXTOUTLINE -XATTR_START] = new XFormTextOutlineItem;
104 7788 : mppLocalPoolDefaults[XATTR_FORMTXTSHADOW -XATTR_START] = new XFormTextShadowItem;
105 7788 : mppLocalPoolDefaults[XATTR_FORMTXTSHDWCOLOR -XATTR_START] = new XFormTextShadowColorItem(aNullStr,aNullShadowCol);
106 7788 : mppLocalPoolDefaults[XATTR_FORMTXTSHDWXVAL -XATTR_START] = new XFormTextShadowXValItem;
107 7788 : mppLocalPoolDefaults[XATTR_FORMTXTSHDWYVAL -XATTR_START] = new XFormTextShadowYValItem;
108 7788 : mppLocalPoolDefaults[XATTR_FORMTXTHIDEFORM -XATTR_START] = new XFormTextHideFormItem;
109 7788 : mppLocalPoolDefaults[XATTR_FORMTXTSHDWTRANSP -XATTR_START] = new XFormTextShadowTranspItem;
110 :
111 : // create SetItems
112 7788 : SfxItemSet* pSet=new SfxItemSet(*_pMaster, XATTR_LINE_FIRST, XATTR_LINE_LAST);
113 7788 : mppLocalPoolDefaults[XATTRSET_LINE - XATTR_START] = new XLineAttrSetItem(pSet);
114 7788 : pSet=new SfxItemSet(*_pMaster, XATTR_FILL_FIRST, XATTR_FILL_LAST);
115 7788 : mppLocalPoolDefaults[XATTRSET_FILL - XATTR_START] = new XFillAttrSetItem(pSet);
116 :
117 : // create ItemInfos
118 7788 : mpLocalItemInfos = new SfxItemInfo[GetLastWhich() - GetFirstWhich() + 1];
119 1845756 : for(sal_uInt16 i(GetFirstWhich()); i <= GetLastWhich(); i++)
120 : {
121 1837968 : mpLocalItemInfos[i - XATTR_START]._nSID = 0;
122 1837968 : mpLocalItemInfos[i - XATTR_START]._nFlags = SFX_ITEM_POOLABLE;
123 : }
124 :
125 7788 : mpLocalItemInfos[XATTR_LINESTYLE -XATTR_START]._nSID = SID_ATTR_LINE_STYLE;
126 7788 : mpLocalItemInfos[XATTR_LINEDASH -XATTR_START]._nSID = SID_ATTR_LINE_DASH;
127 7788 : mpLocalItemInfos[XATTR_LINEWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_WIDTH;
128 7788 : mpLocalItemInfos[XATTR_LINECOLOR -XATTR_START]._nSID = SID_ATTR_LINE_COLOR;
129 7788 : mpLocalItemInfos[XATTR_LINESTART -XATTR_START]._nSID = SID_ATTR_LINE_START;
130 7788 : mpLocalItemInfos[XATTR_LINEEND -XATTR_START]._nSID = SID_ATTR_LINE_END;
131 7788 : mpLocalItemInfos[XATTR_LINESTARTWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_STARTWIDTH;
132 7788 : mpLocalItemInfos[XATTR_LINEENDWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_ENDWIDTH;
133 7788 : mpLocalItemInfos[XATTR_LINESTARTCENTER -XATTR_START]._nSID = SID_ATTR_LINE_STARTCENTER;
134 7788 : mpLocalItemInfos[XATTR_LINEENDCENTER -XATTR_START]._nSID = SID_ATTR_LINE_ENDCENTER;
135 7788 : mpLocalItemInfos[XATTR_FILLSTYLE -XATTR_START]._nSID = SID_ATTR_FILL_STYLE;
136 7788 : mpLocalItemInfos[XATTR_FILLCOLOR -XATTR_START]._nSID = SID_ATTR_FILL_COLOR;
137 7788 : mpLocalItemInfos[XATTR_FILLGRADIENT -XATTR_START]._nSID = SID_ATTR_FILL_GRADIENT;
138 7788 : mpLocalItemInfos[XATTR_FILLHATCH -XATTR_START]._nSID = SID_ATTR_FILL_HATCH;
139 7788 : mpLocalItemInfos[XATTR_FILLBITMAP -XATTR_START]._nSID = SID_ATTR_FILL_BITMAP;
140 7788 : mpLocalItemInfos[XATTR_FORMTXTSTYLE -XATTR_START]._nSID = SID_FORMTEXT_STYLE;
141 7788 : mpLocalItemInfos[XATTR_FORMTXTADJUST -XATTR_START]._nSID = SID_FORMTEXT_ADJUST;
142 7788 : mpLocalItemInfos[XATTR_FORMTXTDISTANCE -XATTR_START]._nSID = SID_FORMTEXT_DISTANCE;
143 7788 : mpLocalItemInfos[XATTR_FORMTXTSTART -XATTR_START]._nSID = SID_FORMTEXT_START;
144 7788 : mpLocalItemInfos[XATTR_FORMTXTMIRROR -XATTR_START]._nSID = SID_FORMTEXT_MIRROR;
145 7788 : mpLocalItemInfos[XATTR_FORMTXTOUTLINE -XATTR_START]._nSID = SID_FORMTEXT_OUTLINE;
146 7788 : mpLocalItemInfos[XATTR_FORMTXTSHADOW -XATTR_START]._nSID = SID_FORMTEXT_SHADOW;
147 7788 : mpLocalItemInfos[XATTR_FORMTXTSHDWCOLOR -XATTR_START]._nSID = SID_FORMTEXT_SHDWCOLOR;
148 7788 : mpLocalItemInfos[XATTR_FORMTXTSHDWXVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWXVAL;
149 7788 : mpLocalItemInfos[XATTR_FORMTXTSHDWYVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWYVAL;
150 7788 : mpLocalItemInfos[XATTR_FORMTXTHIDEFORM -XATTR_START]._nSID = SID_FORMTEXT_HIDEFORM;
151 :
152 : // associate new slots for panels with known items
153 7788 : mpLocalItemInfos[XATTR_FILLTRANSPARENCE - XATTR_START]._nSID = SID_ATTR_FILL_TRANSPARENCE;
154 7788 : mpLocalItemInfos[XATTR_FILLFLOATTRANSPARENCE - XATTR_START]._nSID = SID_ATTR_FILL_FLOATTRANSPARENCE;
155 7788 : mpLocalItemInfos[XATTR_LINETRANSPARENCE - XATTR_START]._nSID = SID_ATTR_LINE_TRANSPARENCE;
156 7788 : mpLocalItemInfos[XATTR_LINEJOINT - XATTR_START]._nSID = SID_ATTR_LINE_JOINT;
157 7788 : mpLocalItemInfos[XATTR_LINECAP - XATTR_START]._nSID = SID_ATTR_LINE_CAP;
158 :
159 : // if it's my own creation level, set Defaults and ItemInfos
160 7788 : if(XATTR_START == GetFirstWhich() && XATTR_END == GetLastWhich())
161 : {
162 0 : SetDefaults(mppLocalPoolDefaults);
163 0 : SetItemInfos(mpLocalItemInfos);
164 7788 : }
165 7788 : }
166 :
167 : // copy ctor, clones all static defaults
168 0 : XOutdevItemPool::XOutdevItemPool(const XOutdevItemPool& rPool)
169 : : SfxItemPool(rPool, true),
170 : mppLocalPoolDefaults(0L),
171 0 : mpLocalItemInfos(0L)
172 : {
173 0 : }
174 :
175 0 : SfxItemPool* XOutdevItemPool::Clone() const
176 : {
177 0 : return new XOutdevItemPool(*this);
178 : }
179 :
180 15230 : XOutdevItemPool::~XOutdevItemPool()
181 : {
182 7615 : Delete();
183 :
184 : // remove own static defaults
185 7615 : if(mppLocalPoolDefaults)
186 : {
187 7615 : SfxPoolItem** ppDefaultItem = mppLocalPoolDefaults;
188 1804755 : for(sal_uInt16 i(GetLastWhich() - GetFirstWhich() + 1); i; --i, ++ppDefaultItem)
189 : {
190 1797140 : if ( *ppDefaultItem ) // these parts might be already cleaned up from a derived class
191 : {
192 357905 : SetRefCount( **ppDefaultItem, 0 );
193 357905 : delete *ppDefaultItem;
194 : }
195 : }
196 :
197 7615 : delete[] mppLocalPoolDefaults;
198 : }
199 :
200 7615 : if(mpLocalItemInfos)
201 : {
202 7615 : delete[] mpLocalItemInfos;
203 : }
204 8266 : }
205 :
206 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|