xref: /trunk/main/svx/source/xoutdev/xpool.cxx (revision 1e9c32af)
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 
XOutdevItemPool(SfxItemPool * _pMaster,sal_uInt16 nAttrStart,sal_uInt16 nAttrEnd,sal_Bool bLoadRefCounts)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 Graphic aNullGraphic;
50 	const basegfx::B2DPolyPolygon aNullPol;
51 	const Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); // #121448# Use defined default color
52 	const Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING); // #121448# Use defined default color
53 	const Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY));
54 	const XDash aNullDash;
55 	const XGradient aNullGrad(RGB_Color(COL_BLACK), 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_LINECAP            -XATTR_START] = new XLineCapItem;
91 	mppLocalPoolDefaults[XATTR_FILLSTYLE				-XATTR_START] = new XFillStyleItem;
92 	mppLocalPoolDefaults[XATTR_FILLCOLOR				-XATTR_START] = new XFillColorItem   (aNullStr,aNullFillCol);
93 	mppLocalPoolDefaults[XATTR_FILLGRADIENT			-XATTR_START] = new XFillGradientItem(this,aNullGrad);
94 	mppLocalPoolDefaults[XATTR_FILLHATCH				-XATTR_START] = new XFillHatchItem   (this,aNullHatch);
95 	mppLocalPoolDefaults[XATTR_FILLBITMAP				-XATTR_START] = new XFillBitmapItem  (this, aNullGraphic);
96 	mppLocalPoolDefaults[XATTR_FILLTRANSPARENCE		-XATTR_START] = new XFillTransparenceItem;
97 	mppLocalPoolDefaults[XATTR_GRADIENTSTEPCOUNT		-XATTR_START] = new XGradientStepCountItem;
98 	mppLocalPoolDefaults[XATTR_FILLBMP_TILE			-XATTR_START] = new XFillBmpTileItem;
99 	mppLocalPoolDefaults[XATTR_FILLBMP_POS			-XATTR_START] = new XFillBmpPosItem;
100 	mppLocalPoolDefaults[XATTR_FILLBMP_SIZEX			-XATTR_START] = new XFillBmpSizeXItem;
101 	mppLocalPoolDefaults[XATTR_FILLBMP_SIZEY			-XATTR_START] = new XFillBmpSizeYItem;
102 	mppLocalPoolDefaults[XATTR_FILLBMP_SIZELOG		-XATTR_START] = new XFillBmpSizeLogItem;
103 	mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETX	-XATTR_START] = new XFillBmpTileOffsetXItem;
104 	mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETY	-XATTR_START] = new XFillBmpTileOffsetYItem;
105 	mppLocalPoolDefaults[XATTR_FILLBMP_STRETCH		-XATTR_START] = new XFillBmpStretchItem;
106 	mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETX		-XATTR_START] = new XFillBmpPosOffsetXItem;
107 	mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETY		-XATTR_START] = new XFillBmpPosOffsetYItem;
108 	mppLocalPoolDefaults[XATTR_FILLFLOATTRANSPARENCE	-XATTR_START] = new XFillFloatTransparenceItem( this, aNullGrad, sal_False );
109 	mppLocalPoolDefaults[XATTR_SECONDARYFILLCOLOR		-XATTR_START] = new XSecondaryFillColorItem(aNullStr, aNullFillCol);
110 	mppLocalPoolDefaults[XATTR_FILLBACKGROUND			-XATTR_START] = new XFillBackgroundItem;
111 	mppLocalPoolDefaults[XATTR_FORMTXTSTYLE       -XATTR_START] = new XFormTextStyleItem;
112 	mppLocalPoolDefaults[XATTR_FORMTXTADJUST      -XATTR_START] = new XFormTextAdjustItem;
113 	mppLocalPoolDefaults[XATTR_FORMTXTDISTANCE    -XATTR_START] = new XFormTextDistanceItem;
114 	mppLocalPoolDefaults[XATTR_FORMTXTSTART       -XATTR_START] = new XFormTextStartItem;
115 	mppLocalPoolDefaults[XATTR_FORMTXTMIRROR      -XATTR_START] = new XFormTextMirrorItem;
116 	mppLocalPoolDefaults[XATTR_FORMTXTOUTLINE     -XATTR_START] = new XFormTextOutlineItem;
117 	mppLocalPoolDefaults[XATTR_FORMTXTSHADOW      -XATTR_START] = new XFormTextShadowItem;
118 	mppLocalPoolDefaults[XATTR_FORMTXTSHDWCOLOR   -XATTR_START] = new XFormTextShadowColorItem(aNullStr,aNullShadowCol);
119 	mppLocalPoolDefaults[XATTR_FORMTXTSHDWXVAL    -XATTR_START] = new XFormTextShadowXValItem;
120 	mppLocalPoolDefaults[XATTR_FORMTXTSHDWYVAL    -XATTR_START] = new XFormTextShadowYValItem;
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_FORMTXTHIDEFORM  -XATTR_START]._nSID = SID_FORMTEXT_HIDEFORM;
164 
165     // associate new slots for panels with known items
166     mpLocalItemInfos[XATTR_FILLTRANSPARENCE - XATTR_START]._nSID = SID_ATTR_FILL_TRANSPARENCE;
167     mpLocalItemInfos[XATTR_FILLFLOATTRANSPARENCE - XATTR_START]._nSID = SID_ATTR_FILL_FLOATTRANSPARENCE;
168     mpLocalItemInfos[XATTR_LINETRANSPARENCE - XATTR_START]._nSID = SID_ATTR_LINE_TRANSPARENCE;
169     mpLocalItemInfos[XATTR_LINEJOINT - XATTR_START]._nSID = SID_ATTR_LINE_JOINT;
170     mpLocalItemInfos[XATTR_LINECAP - XATTR_START]._nSID = SID_ATTR_LINE_CAP;
171 
172 	// if it's my own creation level, set Defaults and ItemInfos
173 	if(XATTR_START == GetFirstWhich() && XATTR_END == GetLastWhich())
174 	{
175 		SetDefaults(mppLocalPoolDefaults);
176 		SetItemInfos(mpLocalItemInfos);
177 	}
178 }
179 
180 /*************************************************************************
181 |*
182 |* copy ctor, sorgt dafuer, dass die static defaults gecloned werden
183 |*            (Parameter 2 = sal_True)
184 |*
185 \************************************************************************/
186 
XOutdevItemPool(const XOutdevItemPool & rPool)187 XOutdevItemPool::XOutdevItemPool(const XOutdevItemPool& rPool)
188 :	SfxItemPool(rPool, sal_True),
189 	mppLocalPoolDefaults(0L),
190 	mpLocalItemInfos(0L)
191 {
192 }
193 
194 /*************************************************************************
195 |*
196 |* Clone()
197 |*
198 \************************************************************************/
199 
Clone() const200 SfxItemPool* XOutdevItemPool::Clone() const
201 {
202 	return new XOutdevItemPool(*this);
203 }
204 
205 /*************************************************************************
206 |*
207 |* Destruktor
208 |*
209 \************************************************************************/
210 
~XOutdevItemPool()211 XOutdevItemPool::~XOutdevItemPool()
212 {
213 	Delete();
214 
215 	// remove own static defaults
216 	if(mppLocalPoolDefaults)
217 	{
218 		SfxPoolItem** ppDefaultItem = mppLocalPoolDefaults;
219 		for(sal_uInt16 i(GetLastWhich() - GetFirstWhich() + 1); i; --i, ++ppDefaultItem)
220 		{
221 			if ( *ppDefaultItem ) //Teile schon von abgel. Klasse abgeraeumt!
222 			{
223 				SetRefCount( **ppDefaultItem, 0 );
224 				delete *ppDefaultItem;
225 			}
226 		}
227 
228 		delete[] mppLocalPoolDefaults;
229 	}
230 
231 	if(mpLocalItemInfos)
232 	{
233 		delete[] mpLocalItemInfos;
234 	}
235 }
236 
237 // eof
238