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. 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 XPropertyList 45 // -------------------- 46 47 XPropertyList::XPropertyList( const String& rPath ) : 48 maName ( pszStandard, 8 ), 49 maPath ( rPath ), 50 maContent(), 51 mbListDirty (true) 52 { 53 } 54 55 /************************************************************************* 56 |* 57 |* XPropertyList::~XPropertyList() 58 |* 59 *************************************************************************/ 60 61 XPropertyList::~XPropertyList() 62 { 63 while(!maContent.empty()) 64 { 65 delete maContent.back(); 66 maContent.pop_back(); 67 } 68 } 69 70 /************************************************************************* 71 |* 72 |* XPropertyList::Clear() 73 |* 74 *************************************************************************/ 75 76 void XPropertyList::Clear() 77 { 78 while(!maContent.empty()) 79 { 80 delete maContent.back(); 81 maContent.pop_back(); 82 } 83 } 84 85 /************************************************************************/ 86 87 long XPropertyList::Count() const 88 { 89 if( mbListDirty ) 90 { 91 if(!const_cast< XPropertyList* >(this)->Load()) 92 { 93 const_cast< XPropertyList* >(this)->Create(); 94 } 95 } 96 97 return maContent.size(); 98 } 99 100 /************************************************************************* 101 |* 102 |* XPropertyEntry* XPropertyList::Get() 103 |* 104 *************************************************************************/ 105 106 XPropertyEntry* XPropertyList::Get( long nIndex ) const 107 { 108 if( mbListDirty ) 109 { 110 if(!const_cast< XPropertyList* >(this)->Load()) 111 { 112 const_cast< XPropertyList* >(this)->Create(); 113 } 114 } 115 116 const long nObjectCount(maContent.size()); 117 118 if(nIndex >= nObjectCount) 119 { 120 return 0; 121 } 122 123 return maContent[nIndex]; 124 } 125 126 /************************************************************************* 127 |* 128 |* XPropertyList::Get() 129 |* 130 *************************************************************************/ 131 132 long XPropertyList::GetIndex(const XubString& rName) const 133 { 134 if( mbListDirty ) 135 { 136 if(!const_cast< XPropertyList* >(this)->Load()) 137 { 138 const_cast< XPropertyList* >(this)->Create(); 139 } 140 } 141 142 ::std::vector< XPropertyEntry* >::const_iterator aStart(maContent.begin()); 143 const ::std::vector< XPropertyEntry* >::const_iterator aEnd(maContent.end()); 144 145 for(long a(0); aStart != aEnd; a++, aStart++) 146 { 147 const XPropertyEntry* pEntry = *aStart; 148 149 if(pEntry && pEntry->GetName() == rName) 150 { 151 return a; 152 } 153 } 154 155 return -1; 156 } 157 158 /************************************************************************* 159 |* 160 |* Bitmap* XPropertyList::GetBitmap() 161 |* 162 *************************************************************************/ 163 164 Bitmap XPropertyList::GetUiBitmap( long nIndex ) const 165 { 166 Bitmap aRetval; 167 XPropertyEntry* pEntry = Get(nIndex); 168 169 if(pEntry) 170 { 171 aRetval = pEntry->GetUiBitmap(); 172 173 if(aRetval.IsEmpty()) 174 { 175 aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex); 176 pEntry->SetUiBitmap(aRetval); 177 } 178 } 179 180 return aRetval; 181 } 182 183 /************************************************************************* 184 |* 185 |* void XPropertyList::Insert() 186 |* 187 *************************************************************************/ 188 189 void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex ) 190 { 191 if(pEntry) 192 { 193 const long nObjectCount(maContent.size()); 194 195 if(static_cast< long >(LIST_APPEND) == nIndex || nIndex >= nObjectCount) 196 { 197 maContent.push_back(pEntry); 198 } 199 else 200 { 201 maContent.insert(maContent.begin() + nIndex, pEntry); 202 } 203 } 204 } 205 206 /************************************************************************* 207 |* 208 |* void XPropertyList::Replace() 209 |* 210 *************************************************************************/ 211 212 XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex ) 213 { 214 XPropertyEntry* pRetval = 0; 215 216 if(pEntry) 217 { 218 const long nObjectCount(maContent.size()); 219 220 if(nIndex < nObjectCount) 221 { 222 pRetval = maContent[nIndex]; 223 maContent[nIndex] = pEntry; 224 } 225 } 226 227 return pRetval; 228 } 229 230 /************************************************************************* 231 |* 232 |* void XPropertyList::Remove() 233 |* 234 *************************************************************************/ 235 236 XPropertyEntry* XPropertyList::Remove( long nIndex ) 237 { 238 XPropertyEntry* pRetval = 0; 239 const long nObjectCount(maContent.size()); 240 241 if(nIndex < nObjectCount) 242 { 243 if(nIndex + 1 == nObjectCount) 244 { 245 pRetval = maContent.back(); 246 maContent.pop_back(); 247 } 248 else 249 { 250 pRetval = maContent[nIndex]; 251 maContent.erase(maContent.begin() + nIndex); 252 } 253 } 254 255 return pRetval; 256 } 257 258 /************************************************************************/ 259 260 void XPropertyList::SetName( const String& rString ) 261 { 262 if(rString.Len()) 263 { 264 maName = rString; 265 } 266 } 267 268 ////////////////////////////////////////////////////////////////////////////// 269 270 XColorListSharedPtr XPropertyListFactory::CreateSharedXColorList( const String& rPath ) 271 { 272 return XColorListSharedPtr(new XColorList(rPath)); 273 } 274 275 XLineEndListSharedPtr XPropertyListFactory::CreateSharedXLineEndList( const String& rPath ) 276 { 277 return XLineEndListSharedPtr(new XLineEndList(rPath)); 278 } 279 280 XDashListSharedPtr XPropertyListFactory::CreateSharedXDashList( const String& rPath ) 281 { 282 return XDashListSharedPtr(new XDashList(rPath)); 283 } 284 285 XHatchListSharedPtr XPropertyListFactory::CreateSharedXHatchList( const String& rPath ) 286 { 287 return XHatchListSharedPtr(new XHatchList(rPath)); 288 } 289 290 XGradientListSharedPtr XPropertyListFactory::CreateSharedXGradientList( const String& rPath ) 291 { 292 return XGradientListSharedPtr(new XGradientList(rPath)); 293 } 294 295 XBitmapListSharedPtr XPropertyListFactory::CreateSharedXBitmapList( const String& rPath ) 296 { 297 return XBitmapListSharedPtr(new XBitmapList(rPath)); 298 } 299 300 ////////////////////////////////////////////////////////////////////////////// 301 // eof 302