LibreOffice Module svx (master)  1
xpool.cxx
Go to the documentation of this file.
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 <sal/config.h>
21 
22 #include <svx/xflbckit.hxx>
23 #include <xftshtit.hxx>
24 #include <svx/xflboxy.hxx>
25 #include <svx/xflbstit.hxx>
26 #include <svx/xflclit.hxx>
27 #include <svx/xflgrit.hxx>
28 #include <svx/xflhtit.hxx>
29 #include <svx/xbtmpit.hxx>
30 #include <svx/xflftrit.hxx>
31 #include <svx/xsflclit.hxx>
32 #include <svx/xlntrit.hxx>
33 #include <svx/xfltrit.hxx>
34 #include <svx/xgrscit.hxx>
35 #include <svx/xflasit.hxx>
36 #include <svx/xflbmtit.hxx>
37 #include <svx/xflbmpit.hxx>
38 #include <svx/xflbmsxy.hxx>
39 #include <svx/xflbmsli.hxx>
40 #include <svx/xflbtoxy.hxx>
41 #include <svx/xlineit0.hxx>
42 #include <svx/xlinjoit.hxx>
43 #include <svx/xlncapit.hxx>
44 #include <svx/xfillit0.hxx>
45 #include <svx/xtextit0.hxx>
46 #include <svx/xlnasit.hxx>
47 #include <svx/xlndsit.hxx>
48 #include <svx/xlnwtit.hxx>
49 #include <svx/xlnclit.hxx>
50 #include <svx/xlnstit.hxx>
51 #include <svx/xlnedit.hxx>
52 #include <svx/xlnstwit.hxx>
53 #include <svx/xlnedwit.hxx>
54 #include <svx/xlnstcit.hxx>
55 #include <svx/xlnedcit.hxx>
56 #include <svx/xpool.hxx>
57 #include <svx/svddef.hxx>
58 #include <svx/svxids.hrc>
59 #include <svl/itemset.hxx>
60 #include <svx/xftadit.hxx>
61 #include <svx/xftdiit.hxx>
62 #include <svx/xftstit.hxx>
63 #include <svx/xftmrit.hxx>
64 #include <svx/xftouit.hxx>
65 #include <svx/xftshit.hxx>
66 #include <svx/xftshcit.hxx>
67 #include <svx/xftshxy.hxx>
68 
70  : SfxItemPool("XOutdevItemPool", SDRATTR_START, SDRATTR_END, nullptr, nullptr)
71  , mpLocalPoolDefaults(new std::vector<SfxPoolItem*>(SDRATTR_END - SDRATTR_START + 1))
72  , mpLocalItemInfos(new SfxItemInfo[SDRATTR_END - SDRATTR_START + 1])
73 {
74  // prepare some defaults
75  const OUString aNullStr;
76  const Graphic aNullGraphic;
77  const basegfx::B2DPolyPolygon aNullPol;
78  const Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); // #i121448# Use defined default color
79  const Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING); // #i121448# Use defined default color
80  const Color aNullShadowCol(COL_LIGHTGRAY);
81  const XDash aNullDash;
82  const XHatch aNullHatch(aNullLineCol);
83 
84  // get master pointer, evtl. add myself to the end of the pools
85  if(!_pMaster)
86  {
87  _pMaster = this;
88  }
89  else
90  {
91  SfxItemPool* pParent = _pMaster;
92 
93  while(pParent->GetSecondaryPool())
94  {
95  pParent = pParent->GetSecondaryPool();
96  }
97 
98  pParent->SetSecondaryPool(this);
99  }
100 
101  // prepare PoolDefaults
102  std::vector<SfxPoolItem*>& rPoolDefaults = *mpLocalPoolDefaults;
103  rPoolDefaults[XATTR_LINESTYLE -XATTR_START] = new XLineStyleItem;
104  rPoolDefaults[XATTR_LINEDASH -XATTR_START] = new XLineDashItem(aNullDash);
105  rPoolDefaults[XATTR_LINEWIDTH -XATTR_START] = new XLineWidthItem;
106  rPoolDefaults[XATTR_LINECOLOR -XATTR_START] = new XLineColorItem(aNullStr,aNullLineCol);
107  rPoolDefaults[XATTR_LINESTART -XATTR_START] = new XLineStartItem(aNullPol);
108  rPoolDefaults[XATTR_LINEEND -XATTR_START] = new XLineEndItem (aNullPol);
110  rPoolDefaults[XATTR_LINEENDWIDTH -XATTR_START] = new XLineEndWidthItem;
112  rPoolDefaults[XATTR_LINEENDCENTER -XATTR_START] = new XLineEndCenterItem;
114  rPoolDefaults[XATTR_LINEJOINT -XATTR_START] = new XLineJointItem;
115  rPoolDefaults[XATTR_LINECAP -XATTR_START] = new XLineCapItem;
116  rPoolDefaults[XATTR_FILLSTYLE -XATTR_START] = new XFillStyleItem;
117  rPoolDefaults[XATTR_FILLCOLOR -XATTR_START] = new XFillColorItem (aNullStr,aNullFillCol);
119  rPoolDefaults[XATTR_FILLHATCH -XATTR_START] = new XFillHatchItem (aNullHatch);
120  rPoolDefaults[XATTR_FILLBITMAP -XATTR_START] = new XFillBitmapItem (aNullGraphic);
123  rPoolDefaults[XATTR_FILLBMP_TILE -XATTR_START] = new XFillBmpTileItem;
124  rPoolDefaults[XATTR_FILLBMP_POS -XATTR_START] = new XFillBmpPosItem;
125  rPoolDefaults[XATTR_FILLBMP_SIZEX -XATTR_START] = new XFillBmpSizeXItem;
126  rPoolDefaults[XATTR_FILLBMP_SIZEY -XATTR_START] = new XFillBmpSizeYItem;
134  rPoolDefaults[XATTR_SECONDARYFILLCOLOR -XATTR_START] = new XSecondaryFillColorItem(aNullStr, aNullFillCol);
136  rPoolDefaults[XATTR_FORMTXTSTYLE -XATTR_START] = new XFormTextStyleItem;
139  rPoolDefaults[XATTR_FORMTXTSTART -XATTR_START] = new XFormTextStartItem;
143  rPoolDefaults[XATTR_FORMTXTSHDWCOLOR -XATTR_START] = new XFormTextShadowColorItem(aNullStr,aNullShadowCol);
148 
149  // create SetItems
150  rPoolDefaults[XATTRSET_LINE - XATTR_START] = new XLineAttrSetItem(
151  std::make_unique<SfxItemSet>(
153  rPoolDefaults[XATTRSET_FILL - XATTR_START] = new XFillAttrSetItem(
154  std::make_unique<SfxItemSet>(
156 
157  // create ItemInfos
158  for(sal_uInt16 i(GetFirstWhich()); i <= GetLastWhich(); i++)
159  {
160  mpLocalItemInfos[i - XATTR_START]._nSID = 0;
161  mpLocalItemInfos[i - XATTR_START]._bPoolable = true;
162  }
163 
164  mpLocalItemInfos[XATTR_LINESTYLE -XATTR_START]._nSID = SID_ATTR_LINE_STYLE;
165  mpLocalItemInfos[XATTR_LINEDASH -XATTR_START]._nSID = SID_ATTR_LINE_DASH;
166  mpLocalItemInfos[XATTR_LINEWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_WIDTH;
167  mpLocalItemInfos[XATTR_LINECOLOR -XATTR_START]._nSID = SID_ATTR_LINE_COLOR;
168  mpLocalItemInfos[XATTR_LINESTART -XATTR_START]._nSID = SID_ATTR_LINE_START;
169  mpLocalItemInfos[XATTR_LINEEND -XATTR_START]._nSID = SID_ATTR_LINE_END;
170  mpLocalItemInfos[XATTR_LINESTARTWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_STARTWIDTH;
171  mpLocalItemInfos[XATTR_LINEENDWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_ENDWIDTH;
172  mpLocalItemInfos[XATTR_LINESTARTCENTER -XATTR_START]._nSID = SID_ATTR_LINE_STARTCENTER;
173  mpLocalItemInfos[XATTR_LINEENDCENTER -XATTR_START]._nSID = SID_ATTR_LINE_ENDCENTER;
174  mpLocalItemInfos[XATTR_FILLSTYLE -XATTR_START]._nSID = SID_ATTR_FILL_STYLE;
175  mpLocalItemInfos[XATTR_FILLCOLOR -XATTR_START]._nSID = SID_ATTR_FILL_COLOR;
176  mpLocalItemInfos[XATTR_FILLGRADIENT -XATTR_START]._nSID = SID_ATTR_FILL_GRADIENT;
177  mpLocalItemInfos[XATTR_FILLHATCH -XATTR_START]._nSID = SID_ATTR_FILL_HATCH;
178  mpLocalItemInfos[XATTR_FILLBITMAP -XATTR_START]._nSID = SID_ATTR_FILL_BITMAP;
179  mpLocalItemInfos[XATTR_FORMTXTSTYLE -XATTR_START]._nSID = SID_FORMTEXT_STYLE;
180  mpLocalItemInfos[XATTR_FORMTXTADJUST -XATTR_START]._nSID = SID_FORMTEXT_ADJUST;
181  mpLocalItemInfos[XATTR_FORMTXTDISTANCE -XATTR_START]._nSID = SID_FORMTEXT_DISTANCE;
182  mpLocalItemInfos[XATTR_FORMTXTSTART -XATTR_START]._nSID = SID_FORMTEXT_START;
183  mpLocalItemInfos[XATTR_FORMTXTMIRROR -XATTR_START]._nSID = SID_FORMTEXT_MIRROR;
184  mpLocalItemInfos[XATTR_FORMTXTOUTLINE -XATTR_START]._nSID = SID_FORMTEXT_OUTLINE;
185  mpLocalItemInfos[XATTR_FORMTXTSHADOW -XATTR_START]._nSID = SID_FORMTEXT_SHADOW;
186  mpLocalItemInfos[XATTR_FORMTXTSHDWCOLOR -XATTR_START]._nSID = SID_FORMTEXT_SHDWCOLOR;
187  mpLocalItemInfos[XATTR_FORMTXTSHDWXVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWXVAL;
188  mpLocalItemInfos[XATTR_FORMTXTSHDWYVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWYVAL;
189  mpLocalItemInfos[XATTR_FORMTXTHIDEFORM -XATTR_START]._nSID = SID_FORMTEXT_HIDEFORM;
190 
191  // associate new slots for panels with known items
192  mpLocalItemInfos[XATTR_FILLTRANSPARENCE - XATTR_START]._nSID = SID_ATTR_FILL_TRANSPARENCE;
193  mpLocalItemInfos[XATTR_FILLFLOATTRANSPARENCE - XATTR_START]._nSID = SID_ATTR_FILL_FLOATTRANSPARENCE;
194  mpLocalItemInfos[XATTR_LINETRANSPARENCE - XATTR_START]._nSID = SID_ATTR_LINE_TRANSPARENCE;
195  mpLocalItemInfos[XATTR_LINEJOINT - XATTR_START]._nSID = SID_ATTR_LINE_JOINT;
196  mpLocalItemInfos[XATTR_LINECAP - XATTR_START]._nSID = SID_ATTR_LINE_CAP;
197 
198  // if it's my own creation level, set Defaults and ItemInfos
200  {
203  }
204 }
205 
206 // copy ctor, clones all static defaults
208 : SfxItemPool(rPool, true),
209  mpLocalPoolDefaults(nullptr)
210 {
211 }
212 
214 {
215  return new XOutdevItemPool(*this);
216 }
217 
219 {
220  Delete();
221  // release and delete static pool default items
222  ReleaseDefaults(true);
223 }
224 
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< XFormTextHideFormItem > XATTR_FORMTXTHIDEFORM(XATTR_TEXT_FIRST+10)
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
constexpr TypedWhichId< XLineEndCenterItem > XATTR_LINEENDCENTER(XATTR_LINE_FIRST+9)
constexpr TypedWhichId< XFillBmpTileOffsetYItem > XATTR_FILLBMP_TILEOFFSETY(XATTR_FILL_FIRST+15)
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)
virtual ~XOutdevItemPool() override
Definition: xpool.cxx:218
constexpr TypedWhichId< XLineJointItem > XATTR_LINEJOINT(XATTR_LINE_FIRST+11)
#define COL_DEFAULT_SHAPE_FILLING
Definition: xdef.hxx:84
constexpr TypedWhichId< SfxMetricItem > XATTR_FILLBMP_SIZEX(XATTR_FILL_FIRST+9)
constexpr TypedWhichId< XFormTextOutlineItem > XATTR_FORMTXTOUTLINE(XATTR_TEXT_FIRST+5)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
constexpr TypedWhichId< XLineWidthItem > XATTR_LINEWIDTH(XATTR_LINE_FIRST+2)
constexpr TypedWhichId< XFormTextShadowTranspItem > XATTR_FORMTXTSHDWTRANSP(XATTR_TEXT_FIRST+11)
sal_uInt16 GetLastWhich() const
void SetDefaults(std::vector< SfxPoolItem * > *pDefaults)
constexpr TypedWhichId< XLineStyleItem > XATTR_LINESTYLE(XATTR_LINE_FIRST)
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
void Delete()
constexpr TypedWhichId< XFillBackgroundItem > XATTR_FILLBACKGROUND(XATTR_FILL_FIRST+19)
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
constexpr TypedWhichId< XFormTextDistanceItem > XATTR_FORMTXTDISTANCE(XATTR_TEXT_FIRST+2)
constexpr TypedWhichId< XLineTransparenceItem > XATTR_LINETRANSPARENCE(XATTR_LINE_FIRST+10)
void ReleaseDefaults(bool bDelete=false)
Definition: xdash.hxx:31
std::vector< SfxPoolItem * > * mpLocalPoolDefaults
Definition: xpool.hxx:35
constexpr TypedWhichId< XLineAttrSetItem > XATTRSET_LINE(XATTR_LINE_LAST+1)
constexpr TypedWhichId< XFormTextStyleItem > XATTR_FORMTXTSTYLE(XATTR_TEXT_FIRST)
constexpr TypedWhichId< XLineStartWidthItem > XATTR_LINESTARTWIDTH(XATTR_LINE_FIRST+6)
constexpr TypedWhichId< XFillTransparenceItem > XATTR_FILLTRANSPARENCE(XATTR_FILL_FIRST+5)
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
int i
constexpr TypedWhichId< XSecondaryFillColorItem > XATTR_SECONDARYFILLCOLOR(XATTR_FILL_FIRST+12)
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XLineEndWidthItem > XATTR_LINEENDWIDTH(XATTR_LINE_FIRST+7)
constexpr sal_uInt16 XATTR_START
Definition: xdef.hxx:87
std::unique_ptr< SfxItemInfo[]> mpLocalItemInfos
Definition: xpool.hxx:36
constexpr TypedWhichId< XFillBmpPosItem > XATTR_FILLBMP_POS(XATTR_FILL_FIRST+8)
void SetItemInfos(const SfxItemInfo *pInfos)
constexpr TypedWhichId< XFormTextShadowXValItem > XATTR_FORMTXTSHDWXVAL(XATTR_TEXT_FIRST+8)
constexpr TypedWhichId< XFormTextShadowItem > XATTR_FORMTXTSHADOW(XATTR_TEXT_FIRST+6)
constexpr TypedWhichId< XFormTextAdjustItem > XATTR_FORMTXTADJUST(XATTR_TEXT_FIRST+1)
constexpr sal_uInt16 XATTR_END
Definition: xdef.hxx:145
constexpr TypedWhichId< XLineStartCenterItem > XATTR_LINESTARTCENTER(XATTR_LINE_FIRST+8)
virtual SfxItemPool * Clone() const override
Definition: xpool.cxx:213
SfxItemPool * GetSecondaryPool() const
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XGradientStepCountItem > XATTR_GRADIENTSTEPCOUNT(XATTR_FILL_FIRST+6)
#define COL_DEFAULT_SHAPE_STROKE
Definition: xdef.hxx:85
constexpr sal_uInt16 SDRATTR_END(SDRATTR_SOFTEDGE_LAST)
constexpr TypedWhichId< XFillAttrSetItem > XATTRSET_FILL(XATTR_FILL_LAST+1)
XOutdevItemPool(SfxItemPool *pMaster)
Definition: xpool.cxx:69
constexpr TypedWhichId< XFormTextStartItem > XATTR_FORMTXTSTART(XATTR_TEXT_FIRST+3)
constexpr TypedWhichId< XFillFloatTransparenceItem > XATTR_FILLFLOATTRANSPARENCE(XATTR_FILL_FIRST+11)
constexpr TypedWhichId< XFillBmpPosOffsetYItem > XATTR_FILLBMP_POSOFFSETY(XATTR_FILL_FIRST+18)
constexpr TypedWhichId< XFormTextShadowYValItem > XATTR_FORMTXTSHDWYVAL(XATTR_TEXT_FIRST+9)
constexpr TypedWhichId< XFillBmpStretchItem > XATTR_FILLBMP_STRETCH(XATTR_FILL_FIRST+16)
sal_uInt16 GetFirstWhich() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
constexpr TypedWhichId< XLineCapItem > XATTR_LINECAP(XATTR_LINE_FIRST+12)
constexpr TypedWhichId< XFillBmpPosOffsetXItem > XATTR_FILLBMP_POSOFFSETX(XATTR_FILL_FIRST+17)
constexpr TypedWhichId< XFillBmpTileItem > XATTR_FILLBMP_TILE(XATTR_FILL_FIRST+7)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
constexpr TypedWhichId< XFillBmpSizeLogItem > XATTR_FILLBMP_SIZELOG(XATTR_FILL_FIRST+13)
constexpr TypedWhichId< XFormTextMirrorItem > XATTR_FORMTXTMIRROR(XATTR_TEXT_FIRST+4)
constexpr TypedWhichId< XFillBmpTileOffsetXItem > XATTR_FILLBMP_TILEOFFSETX(XATTR_FILL_FIRST+14)
constexpr TypedWhichId< XLineColorItem > XATTR_LINECOLOR(XATTR_LINE_FIRST+3)
constexpr TypedWhichId< XFillBmpSizeYItem > XATTR_FILLBMP_SIZEY(XATTR_FILL_FIRST+10)
void SetSecondaryPool(SfxItemPool *pPool)
constexpr TypedWhichId< XFormTextShadowColorItem > XATTR_FORMTXTSHDWCOLOR(XATTR_TEXT_FIRST+7)