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