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