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 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_svx.hxx"
24
25 #include <svx/xtable.hxx>
26 #include <svx/xpool.hxx>
27 #include <svx/svdpool.hxx>
28
29 #define GLOBALOVERFLOW
30
31 // Vergleichsstrings
32 sal_Unicode __FAR_DATA pszStandard[] = { 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', 0 };
33
34 // Konvertiert in echte RGB-Farben, damit in den Listboxen
35 // endlich mal richtig selektiert werden kann.
RGB_Color(ColorData nColorName)36 Color RGB_Color( ColorData nColorName )
37 {
38 Color aColor( nColorName );
39 Color aRGBColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
40 return aRGBColor;
41 }
42
43 //////////////////////////////////////////////////////////////////////////////
44 // class XColorEntry
45
XColorEntry(const Color & rColor,const String & rName)46 XColorEntry::XColorEntry(const Color& rColor, const String& rName)
47 : XPropertyEntry(rName),
48 aColor(rColor)
49 {
50 }
51
XColorEntry(const XColorEntry & rOther)52 XColorEntry::XColorEntry(const XColorEntry& rOther)
53 : XPropertyEntry(rOther),
54 aColor(rOther.aColor)
55 {
56 }
57
58 //////////////////////////////////////////////////////////////////////////////
59 // class XLineEndEntry
60
XLineEndEntry(const basegfx::B2DPolyPolygon & rB2DPolyPolygon,const String & rName)61 XLineEndEntry::XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const String& rName)
62 : XPropertyEntry(rName),
63 aB2DPolyPolygon(rB2DPolyPolygon)
64 {
65 }
66
XLineEndEntry(const XLineEndEntry & rOther)67 XLineEndEntry::XLineEndEntry(const XLineEndEntry& rOther)
68 : XPropertyEntry(rOther),
69 aB2DPolyPolygon(rOther.aB2DPolyPolygon)
70 {
71 }
72
73 //////////////////////////////////////////////////////////////////////////////
74 // class XDashEntry
75
XDashEntry(const XDash & rDash,const String & rName)76 XDashEntry::XDashEntry(const XDash& rDash, const String& rName)
77 : XPropertyEntry(rName),
78 aDash(rDash)
79 {
80 }
81
XDashEntry(const XDashEntry & rOther)82 XDashEntry::XDashEntry(const XDashEntry& rOther)
83 : XPropertyEntry(rOther),
84 aDash(rOther.aDash)
85 {
86 }
87
88 //////////////////////////////////////////////////////////////////////////////
89 // class XHatchEntry
90
XHatchEntry(const XHatch & rHatch,const String & rName)91 XHatchEntry::XHatchEntry(const XHatch& rHatch, const String& rName)
92 : XPropertyEntry(rName),
93 aHatch(rHatch)
94 {
95 }
96
XHatchEntry(const XHatchEntry & rOther)97 XHatchEntry::XHatchEntry(const XHatchEntry& rOther)
98 : XPropertyEntry(rOther),
99 aHatch(rOther.aHatch)
100 {
101 }
102
103 //////////////////////////////////////////////////////////////////////////////
104 // class XGradientEntry
105
XGradientEntry(const XGradient & rGradient,const String & rName)106 XGradientEntry::XGradientEntry(const XGradient& rGradient, const String& rName)
107 : XPropertyEntry(rName),
108 aGradient(rGradient)
109 {
110 }
111
XGradientEntry(const XGradientEntry & rOther)112 XGradientEntry::XGradientEntry(const XGradientEntry& rOther)
113 : XPropertyEntry(rOther),
114 aGradient(rOther.aGradient)
115 {
116 }
117
118 //////////////////////////////////////////////////////////////////////////////
119 // class XBitmapEntry
120
XBitmapEntry(const GraphicObject & rGraphicObject,const String & rName)121 XBitmapEntry::XBitmapEntry(const GraphicObject& rGraphicObject, const String& rName)
122 : XPropertyEntry(rName),
123 maGraphicObject(rGraphicObject)
124 {
125 }
126
XBitmapEntry(const XBitmapEntry & rOther)127 XBitmapEntry::XBitmapEntry(const XBitmapEntry& rOther)
128 : XPropertyEntry(rOther),
129 maGraphicObject(rOther.maGraphicObject)
130 {
131 }
132
133 //////////////////////////////////////////////////////////////////////////////
134 // class XPropertyList
135
XPropertyList(const String & rPath)136 XPropertyList::XPropertyList( const String& rPath ) :
137 maName ( pszStandard, 8 ),
138 maPath ( rPath ),
139 maContent(),
140 mbListDirty (true)
141 {
142 }
143
~XPropertyList()144 XPropertyList::~XPropertyList()
145 {
146 while(!maContent.empty())
147 {
148 delete maContent.back();
149 maContent.pop_back();
150 }
151 }
152
Clear()153 void XPropertyList::Clear()
154 {
155 while(!maContent.empty())
156 {
157 delete maContent.back();
158 maContent.pop_back();
159 }
160 }
161
Count() const162 long XPropertyList::Count() const
163 {
164 if( mbListDirty )
165 {
166 if(!const_cast< XPropertyList* >(this)->Load())
167 {
168 const_cast< XPropertyList* >(this)->Create();
169 }
170 }
171
172 return maContent.size();
173 }
174
Get(long nIndex) const175 XPropertyEntry* XPropertyList::Get( long nIndex ) const
176 {
177 if( mbListDirty )
178 {
179 if(!const_cast< XPropertyList* >(this)->Load())
180 {
181 const_cast< XPropertyList* >(this)->Create();
182 }
183 }
184
185 const long nObjectCount(maContent.size());
186
187 if(nIndex >= nObjectCount)
188 {
189 return 0;
190 }
191
192 return maContent[nIndex];
193 }
194
GetIndex(const XubString & rName) const195 long XPropertyList::GetIndex(const XubString& rName) const
196 {
197 if( mbListDirty )
198 {
199 if(!const_cast< XPropertyList* >(this)->Load())
200 {
201 const_cast< XPropertyList* >(this)->Create();
202 }
203 }
204
205 ::std::vector< XPropertyEntry* >::const_iterator aStart(maContent.begin());
206 const ::std::vector< XPropertyEntry* >::const_iterator aEnd(maContent.end());
207
208 for(long a(0); aStart != aEnd; a++, aStart++)
209 {
210 const XPropertyEntry* pEntry = *aStart;
211
212 if(pEntry && pEntry->GetName() == rName)
213 {
214 return a;
215 }
216 }
217
218 return -1;
219 }
220
GetUiBitmap(long nIndex) const221 Bitmap XPropertyList::GetUiBitmap( long nIndex ) const
222 {
223 Bitmap aRetval;
224 XPropertyEntry* pEntry = Get(nIndex);
225
226 if(pEntry)
227 {
228 aRetval = pEntry->GetUiBitmap();
229
230 if(aRetval.IsEmpty())
231 {
232 aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex);
233 pEntry->SetUiBitmap(aRetval);
234 }
235 }
236
237 return aRetval;
238 }
239
Insert(XPropertyEntry * pEntry,long nIndex)240 void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex )
241 {
242 if(pEntry)
243 {
244 const long nObjectCount(maContent.size());
245
246 if(static_cast< long >(LIST_APPEND) == nIndex || nIndex >= nObjectCount)
247 {
248 maContent.push_back(pEntry);
249 }
250 else
251 {
252 maContent.insert(maContent.begin() + nIndex, pEntry);
253 }
254 }
255 }
256
Replace(XPropertyEntry * pEntry,long nIndex)257 XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex )
258 {
259 XPropertyEntry* pRetval = 0;
260
261 if(pEntry)
262 {
263 const long nObjectCount(maContent.size());
264
265 if(nIndex < nObjectCount)
266 {
267 pRetval = maContent[nIndex];
268 maContent[nIndex] = pEntry;
269 }
270 }
271
272 return pRetval;
273 }
274
Remove(long nIndex)275 XPropertyEntry* XPropertyList::Remove( long nIndex )
276 {
277 XPropertyEntry* pRetval = 0;
278 const long nObjectCount(maContent.size());
279
280 if(nIndex < nObjectCount)
281 {
282 if(nIndex + 1 == nObjectCount)
283 {
284 pRetval = maContent.back();
285 maContent.pop_back();
286 }
287 else
288 {
289 pRetval = maContent[nIndex];
290 maContent.erase(maContent.begin() + nIndex);
291 }
292 }
293
294 return pRetval;
295 }
296
SetName(const String & rString)297 void XPropertyList::SetName( const String& rString )
298 {
299 if(rString.Len())
300 {
301 maName = rString;
302 }
303 }
304
305 //////////////////////////////////////////////////////////////////////////////
306
CreateSharedXColorList(const String & rPath)307 XColorListSharedPtr XPropertyListFactory::CreateSharedXColorList( const String& rPath )
308 {
309 return XColorListSharedPtr(new XColorList(rPath));
310 }
311
CreateSharedXLineEndList(const String & rPath)312 XLineEndListSharedPtr XPropertyListFactory::CreateSharedXLineEndList( const String& rPath )
313 {
314 return XLineEndListSharedPtr(new XLineEndList(rPath));
315 }
316
CreateSharedXDashList(const String & rPath)317 XDashListSharedPtr XPropertyListFactory::CreateSharedXDashList( const String& rPath )
318 {
319 return XDashListSharedPtr(new XDashList(rPath));
320 }
321
CreateSharedXHatchList(const String & rPath)322 XHatchListSharedPtr XPropertyListFactory::CreateSharedXHatchList( const String& rPath )
323 {
324 return XHatchListSharedPtr(new XHatchList(rPath));
325 }
326
CreateSharedXGradientList(const String & rPath)327 XGradientListSharedPtr XPropertyListFactory::CreateSharedXGradientList( const String& rPath )
328 {
329 return XGradientListSharedPtr(new XGradientList(rPath));
330 }
331
CreateSharedXBitmapList(const String & rPath)332 XBitmapListSharedPtr XPropertyListFactory::CreateSharedXBitmapList( const String& rPath )
333 {
334 return XBitmapListSharedPtr(new XBitmapList(rPath));
335 }
336
337 //////////////////////////////////////////////////////////////////////////////
338 // eof
339