xref: /aoo41x/main/svx/source/xoutdev/xtable.cxx (revision 97e8a929)
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 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <svx/xtable.hxx>
28 #include <svx/xpool.hxx>
29 #include <svx/svdobj.hxx>
30 #include <svx/svdpool.hxx>
31 
32 #define GLOBALOVERFLOW
33 
34 // Vergleichsstrings
35 sal_Unicode __FAR_DATA pszStandard[] = { 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', 0 };
36 
37 // Konvertiert in echte RGB-Farben, damit in den Listboxen
38 // endlich mal richtig selektiert werden kann.
39 Color RGB_Color( ColorData nColorName )
40 {
41 	Color aColor( nColorName );
42 	Color aRGBColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
43 	return aRGBColor;
44 }
45 
46 // --------------------
47 // class XPropertyList
48 // --------------------
49 
50 XPropertyList::XPropertyList( const String& rPath, XOutdevItemPool* pInPool ) :
51 			maName			( pszStandard, 8 ),
52 			maPath			( rPath ),
53 			mpXPool			( pInPool ),
54 			maList			( 16, 16 ),
55 			mbListDirty		(true)
56 {
57 	if( !mpXPool )
58 	{
59 		mpXPool = static_cast< XOutdevItemPool* >(&SdrObject::GetGlobalDrawObjectItemPool());
60 	}
61 }
62 
63 /*************************************************************************
64 |*
65 |* XPropertyList::~XPropertyList()
66 |*
67 *************************************************************************/
68 
69 XPropertyList::~XPropertyList()
70 {
71 	XPropertyEntry* pEntry = (XPropertyEntry*)maList.First();
72 	for( sal_uIntPtr nIndex = 0; nIndex < maList.Count(); nIndex++ )
73 	{
74 		delete pEntry;
75 		pEntry = (XPropertyEntry*)maList.Next();
76 	}
77 }
78 
79 /*************************************************************************
80 |*
81 |* XPropertyList::Clear()
82 |*
83 *************************************************************************/
84 
85 void XPropertyList::Clear()
86 {
87 	maList.Clear();
88 }
89 
90 /************************************************************************/
91 
92 long XPropertyList::Count() const
93 {
94 	if( mbListDirty )
95 	{
96 		// ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load()
97 		if( !( (XPropertyList*) this )->Load() )
98 			( (XPropertyList*) this )->Create();
99 	}
100 	return( maList.Count() );
101 }
102 
103 /*************************************************************************
104 |*
105 |* XPropertyEntry* XPropertyList::Get()
106 |*
107 *************************************************************************/
108 
109 XPropertyEntry* XPropertyList::Get( long nIndex, sal_uInt16 /*nDummy*/) const
110 {
111 	if( mbListDirty )
112 	{
113 		// ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load()
114 		if( !( (XPropertyList*) this )->Load() )
115 			( (XPropertyList*) this )->Create();
116 	}
117 	return (XPropertyEntry*) maList.GetObject( (sal_uIntPtr) nIndex );
118 }
119 
120 /*************************************************************************
121 |*
122 |* XPropertyList::Get()
123 |*
124 *************************************************************************/
125 
126 long XPropertyList::Get(const XubString& rName)
127 {
128 	if( mbListDirty )
129 	{
130 		//bListDirty = sal_False;
131 		if( !Load() )
132 			Create();
133 	}
134 	long nPos = 0;
135 	XPropertyEntry* pEntry = (XPropertyEntry*)maList.First();
136 	while (pEntry && pEntry->GetName() != rName)
137 	{
138 		nPos++;
139 		pEntry = (XPropertyEntry*)maList.Next();
140 	}
141 	if (!pEntry) nPos = -1;
142 	return nPos;
143 }
144 
145 /*************************************************************************
146 |*
147 |* Bitmap* XPropertyList::GetBitmap()
148 |*
149 *************************************************************************/
150 
151 Bitmap XPropertyList::GetUiBitmap( long nIndex ) const
152 {
153     Bitmap aRetval;
154     XPropertyEntry* pEntry = (XPropertyEntry*)maList.GetObject((sal_uIntPtr)nIndex);
155 
156     if(pEntry)
157     {
158         aRetval = pEntry->GetUiBitmap();
159 
160         if(aRetval.IsEmpty())
161         {
162             aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex);
163             pEntry->SetUiBitmap(aRetval);
164         }
165     }
166 
167 	return aRetval;
168 }
169 
170 /*************************************************************************
171 |*
172 |* void XPropertyList::Insert()
173 |*
174 *************************************************************************/
175 
176 void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex )
177 {
178 	maList.Insert( pEntry, (sal_uIntPtr) nIndex );
179 }
180 
181 /*************************************************************************
182 |*
183 |* void XPropertyList::Replace()
184 |*
185 *************************************************************************/
186 
187 XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex )
188 {
189 	return  (XPropertyEntry*) maList.Replace( pEntry, (sal_uIntPtr) nIndex );
190 }
191 
192 /*************************************************************************
193 |*
194 |* void XPropertyList::Remove()
195 |*
196 *************************************************************************/
197 
198 XPropertyEntry* XPropertyList::Remove( long nIndex, sal_uInt16 /*nDummy*/)
199 {
200 	return (XPropertyEntry*) maList.Remove( (sal_uIntPtr) nIndex );
201 }
202 
203 /************************************************************************/
204 
205 void XPropertyList::SetName( const String& rString )
206 {
207 	if(rString.Len())
208 	{
209 		maName = rString;
210 	}
211 }
212 
213 sal_uInt32 XPropertyList::getUiBitmapWidth() const
214 {
215     static sal_uInt32 nWidth = 32; // alternative: 42;
216 
217     return nWidth;
218 }
219 
220 sal_uInt32 XPropertyList::getUiBitmapHeight() const
221 {
222     static sal_uInt32 nHeight = 12; // alternative: 16;
223 
224     return nHeight;
225 }
226 
227 sal_uInt32 XPropertyList::getUiBitmapLineWidth() const
228 {
229     static sal_uInt32 nLineWidth = 3;
230 
231     return nLineWidth;
232 }
233 
234 // eof
235