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