xref: /AOO41X/main/svx/source/xoutdev/xtable.cxx (revision 97e8a92935060941ca19899fb79596f616025ec0)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svx/xtable.hxx>
28cdf0e10cSrcweir #include <svx/xpool.hxx>
29*97e8a929SArmin Le Grand #include <svx/svdobj.hxx>
30*97e8a929SArmin Le Grand #include <svx/svdpool.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #define GLOBALOVERFLOW
33cdf0e10cSrcweir 
34cdf0e10cSrcweir // Vergleichsstrings
35cdf0e10cSrcweir sal_Unicode __FAR_DATA pszStandard[] = { 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', 0 };
36cdf0e10cSrcweir 
37cdf0e10cSrcweir // Konvertiert in echte RGB-Farben, damit in den Listboxen
38cdf0e10cSrcweir // endlich mal richtig selektiert werden kann.
39cdf0e10cSrcweir Color RGB_Color( ColorData nColorName )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	Color aColor( nColorName );
42cdf0e10cSrcweir 	Color aRGBColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
43cdf0e10cSrcweir 	return aRGBColor;
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir // --------------------
47cdf0e10cSrcweir // class XPropertyList
48cdf0e10cSrcweir // --------------------
49cdf0e10cSrcweir 
50*97e8a929SArmin Le Grand XPropertyList::XPropertyList( const String& rPath, XOutdevItemPool* pInPool ) :
51*97e8a929SArmin Le Grand 			maName			( pszStandard, 8 ),
52*97e8a929SArmin Le Grand 			maPath			( rPath ),
53*97e8a929SArmin Le Grand 			mpXPool			( pInPool ),
54*97e8a929SArmin Le Grand 			maList			( 16, 16 ),
55*97e8a929SArmin Le Grand 			mbListDirty		(true)
56cdf0e10cSrcweir {
57*97e8a929SArmin Le Grand 	if( !mpXPool )
58cdf0e10cSrcweir 	{
59*97e8a929SArmin Le Grand 		mpXPool = static_cast< XOutdevItemPool* >(&SdrObject::GetGlobalDrawObjectItemPool());
60cdf0e10cSrcweir 	}
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir /*************************************************************************
64cdf0e10cSrcweir |*
65cdf0e10cSrcweir |* XPropertyList::~XPropertyList()
66cdf0e10cSrcweir |*
67cdf0e10cSrcweir *************************************************************************/
68cdf0e10cSrcweir 
69cdf0e10cSrcweir XPropertyList::~XPropertyList()
70cdf0e10cSrcweir {
71*97e8a929SArmin Le Grand 	XPropertyEntry* pEntry = (XPropertyEntry*)maList.First();
72*97e8a929SArmin Le Grand 	for( sal_uIntPtr nIndex = 0; nIndex < maList.Count(); nIndex++ )
73cdf0e10cSrcweir 	{
74cdf0e10cSrcweir 		delete pEntry;
75*97e8a929SArmin Le Grand 		pEntry = (XPropertyEntry*)maList.Next();
76cdf0e10cSrcweir 	}
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir /*************************************************************************
80cdf0e10cSrcweir |*
81cdf0e10cSrcweir |* XPropertyList::Clear()
82cdf0e10cSrcweir |*
83cdf0e10cSrcweir *************************************************************************/
84cdf0e10cSrcweir 
85cdf0e10cSrcweir void XPropertyList::Clear()
86cdf0e10cSrcweir {
87*97e8a929SArmin Le Grand 	maList.Clear();
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir /************************************************************************/
91cdf0e10cSrcweir 
92cdf0e10cSrcweir long XPropertyList::Count() const
93cdf0e10cSrcweir {
94*97e8a929SArmin Le Grand 	if( mbListDirty )
95cdf0e10cSrcweir 	{
96cdf0e10cSrcweir 		// ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load()
97cdf0e10cSrcweir 		if( !( (XPropertyList*) this )->Load() )
98cdf0e10cSrcweir 			( (XPropertyList*) this )->Create();
99cdf0e10cSrcweir 	}
100*97e8a929SArmin Le Grand 	return( maList.Count() );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir /*************************************************************************
104cdf0e10cSrcweir |*
105cdf0e10cSrcweir |* XPropertyEntry* XPropertyList::Get()
106cdf0e10cSrcweir |*
107cdf0e10cSrcweir *************************************************************************/
108cdf0e10cSrcweir 
109cdf0e10cSrcweir XPropertyEntry* XPropertyList::Get( long nIndex, sal_uInt16 /*nDummy*/) const
110cdf0e10cSrcweir {
111*97e8a929SArmin Le Grand 	if( mbListDirty )
112cdf0e10cSrcweir 	{
113cdf0e10cSrcweir 		// ( (XPropertyList*) this )->bListDirty = sal_False; <- im Load()
114cdf0e10cSrcweir 		if( !( (XPropertyList*) this )->Load() )
115cdf0e10cSrcweir 			( (XPropertyList*) this )->Create();
116cdf0e10cSrcweir 	}
117*97e8a929SArmin Le Grand 	return (XPropertyEntry*) maList.GetObject( (sal_uIntPtr) nIndex );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir /*************************************************************************
121cdf0e10cSrcweir |*
122cdf0e10cSrcweir |* XPropertyList::Get()
123cdf0e10cSrcweir |*
124cdf0e10cSrcweir *************************************************************************/
125cdf0e10cSrcweir 
126cdf0e10cSrcweir long XPropertyList::Get(const XubString& rName)
127cdf0e10cSrcweir {
128*97e8a929SArmin Le Grand 	if( mbListDirty )
129cdf0e10cSrcweir 	{
130cdf0e10cSrcweir 		//bListDirty = sal_False;
131cdf0e10cSrcweir 		if( !Load() )
132cdf0e10cSrcweir 			Create();
133cdf0e10cSrcweir 	}
134cdf0e10cSrcweir 	long nPos = 0;
135*97e8a929SArmin Le Grand 	XPropertyEntry* pEntry = (XPropertyEntry*)maList.First();
136cdf0e10cSrcweir 	while (pEntry && pEntry->GetName() != rName)
137cdf0e10cSrcweir 	{
138cdf0e10cSrcweir 		nPos++;
139*97e8a929SArmin Le Grand 		pEntry = (XPropertyEntry*)maList.Next();
140cdf0e10cSrcweir 	}
141cdf0e10cSrcweir 	if (!pEntry) nPos = -1;
142cdf0e10cSrcweir 	return nPos;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir /*************************************************************************
146cdf0e10cSrcweir |*
147cdf0e10cSrcweir |* Bitmap* XPropertyList::GetBitmap()
148cdf0e10cSrcweir |*
149cdf0e10cSrcweir *************************************************************************/
150cdf0e10cSrcweir 
151*97e8a929SArmin Le Grand Bitmap XPropertyList::GetUiBitmap( long nIndex ) const
152cdf0e10cSrcweir {
153*97e8a929SArmin Le Grand     Bitmap aRetval;
154*97e8a929SArmin Le Grand     XPropertyEntry* pEntry = (XPropertyEntry*)maList.GetObject((sal_uIntPtr)nIndex);
155*97e8a929SArmin Le Grand 
156*97e8a929SArmin Le Grand     if(pEntry)
157cdf0e10cSrcweir     {
158*97e8a929SArmin Le Grand         aRetval = pEntry->GetUiBitmap();
159*97e8a929SArmin Le Grand 
160*97e8a929SArmin Le Grand         if(aRetval.IsEmpty())
161cdf0e10cSrcweir         {
162*97e8a929SArmin Le Grand             aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex);
163*97e8a929SArmin Le Grand             pEntry->SetUiBitmap(aRetval);
164cdf0e10cSrcweir         }
165cdf0e10cSrcweir     }
166*97e8a929SArmin Le Grand 
167*97e8a929SArmin Le Grand 	return aRetval;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir /*************************************************************************
171cdf0e10cSrcweir |*
172cdf0e10cSrcweir |* void XPropertyList::Insert()
173cdf0e10cSrcweir |*
174cdf0e10cSrcweir *************************************************************************/
175cdf0e10cSrcweir 
176cdf0e10cSrcweir void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex )
177cdf0e10cSrcweir {
178*97e8a929SArmin Le Grand 	maList.Insert( pEntry, (sal_uIntPtr) nIndex );
179cdf0e10cSrcweir }
180cdf0e10cSrcweir 
181cdf0e10cSrcweir /*************************************************************************
182cdf0e10cSrcweir |*
183cdf0e10cSrcweir |* void XPropertyList::Replace()
184cdf0e10cSrcweir |*
185cdf0e10cSrcweir *************************************************************************/
186cdf0e10cSrcweir 
187cdf0e10cSrcweir XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex )
188cdf0e10cSrcweir {
189*97e8a929SArmin Le Grand 	return  (XPropertyEntry*) maList.Replace( pEntry, (sal_uIntPtr) nIndex );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir /*************************************************************************
193cdf0e10cSrcweir |*
194cdf0e10cSrcweir |* void XPropertyList::Remove()
195cdf0e10cSrcweir |*
196cdf0e10cSrcweir *************************************************************************/
197cdf0e10cSrcweir 
198cdf0e10cSrcweir XPropertyEntry* XPropertyList::Remove( long nIndex, sal_uInt16 /*nDummy*/)
199cdf0e10cSrcweir {
200*97e8a929SArmin Le Grand 	return (XPropertyEntry*) maList.Remove( (sal_uIntPtr) nIndex );
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir /************************************************************************/
204cdf0e10cSrcweir 
205cdf0e10cSrcweir void XPropertyList::SetName( const String& rString )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir 	if(rString.Len())
208cdf0e10cSrcweir 	{
209*97e8a929SArmin Le Grand 		maName = rString;
210cdf0e10cSrcweir 	}
211cdf0e10cSrcweir }
212cdf0e10cSrcweir 
213*97e8a929SArmin Le Grand sal_uInt32 XPropertyList::getUiBitmapWidth() const
214*97e8a929SArmin Le Grand {
215*97e8a929SArmin Le Grand     static sal_uInt32 nWidth = 32; // alternative: 42;
216cdf0e10cSrcweir 
217*97e8a929SArmin Le Grand     return nWidth;
218*97e8a929SArmin Le Grand }
219cdf0e10cSrcweir 
220*97e8a929SArmin Le Grand sal_uInt32 XPropertyList::getUiBitmapHeight() const
221*97e8a929SArmin Le Grand {
222*97e8a929SArmin Le Grand     static sal_uInt32 nHeight = 12; // alternative: 16;
223*97e8a929SArmin Le Grand 
224*97e8a929SArmin Le Grand     return nHeight;
225*97e8a929SArmin Le Grand }
226*97e8a929SArmin Le Grand 
227*97e8a929SArmin Le Grand sal_uInt32 XPropertyList::getUiBitmapLineWidth() const
228*97e8a929SArmin Le Grand {
229*97e8a929SArmin Le Grand     static sal_uInt32 nLineWidth = 3;
230*97e8a929SArmin Le Grand 
231*97e8a929SArmin Le Grand     return nLineWidth;
232*97e8a929SArmin Le Grand }
233*97e8a929SArmin Le Grand 
234*97e8a929SArmin Le Grand // eof
235