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