Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_sch / globfunc.hxx
blob4ad0a00eacc3c13f790c6366f6cafa8a5f36a866
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: globfunc.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef __GLOBFUNC_HXX
33 #define __GLOBFUNC_HXX
35 #ifndef _E3D_LABEL3D_HXX //autogen
36 #include <bf_svx/label3d.hxx>
37 #endif
39 #include "schgroup.hxx"
40 #include "objid.hxx"
41 #include "datapoin.hxx"
42 #include "datarow.hxx"
43 #include "objadj.hxx"
44 #ifndef _SVX_CHRTITEM_HXX //autogen
45 #include <bf_svx/chrtitem.hxx>
46 #endif
48 #ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
49 #include <com/sun/star/drawing/XShape.hpp>
50 #endif
51 #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
52 #include <com/sun/star/uno/Reference.h>
53 #endif
55 #include <vector>
56 namespace binfilter {
58 //Item-Debugging
59 #ifdef DBG_UTIL
60 class ChartModel;
61 extern void Dbg_DebugItems(SfxItemSet& rSet,ChartModel* pModel,long num = 32);
62 #define DBG_ITEMS(a,b) Dbg_DebugItems(a,b)
63 #define DBG_ITEMSX(a,b,c) Dbg_DebugItems(a,b,c)
64 #else
65 #define DBG_ITEMS(a,b)
66 #define DBG_ITEMSX(a,b,c)
67 #endif
69 //hunderstel Grad (centi-degrees)in Rad
70 #define CDEG2RAD(fAngle) ( (double)(fAngle)*F_PI/18000.0 )
72 void AxisAttrOld2New(SfxItemSet &rDestSet,BOOL bClear,long nId);
73 void AxisAttrNew2Old(SfxItemSet &rDestSet,long nId,BOOL bClear);
75 Size GetRotatedTextSize(const Size& rSize,const long nDegrees);
76 long GetTextRotation(SfxItemSet &rAttr);
77 long GetTextRotation(SfxItemSet &rAttr,SvxChartTextOrient eOrient);
79 SdrObject *SetObjectAttr (SdrObject *pObj,
80 UINT16 nID,
81 BOOL bProtect,
82 BOOL bResize,
83 SfxItemSet *pAttr);
85 SdrObjList *CreateGroup (SdrObjList &rObjList,
86 UINT16 nID,
87 ULONG nIndex = CONTAINER_APPEND);
89 SchObjGroup *CreateSimpleGroup (UINT16 nID,
90 BOOL bProtect,
91 BOOL bResize);
94 void CubicSpline (XPolygon &pKnownPoints,
95 int n,
96 int splineSize,
97 XPolygon &pSplines);
99 void TVector (int n,
100 int k,
101 double *t);
103 double TLeft (double x,
104 int i,
105 int k,
106 double *t);
108 double TRight (double x,
109 int i,
110 int k,
111 double *t);
113 void BVector (double x,
114 int n,
115 int k,
116 double *b,
117 double *t);
119 void BSPoint (int n,
120 Point &p1,
121 Point &p2,
122 XPolygon &pKnownPoints,
123 double *b);
125 void approxMesh (int splineSize,
126 XPolygon &pSplines,
127 XPolygon &pKnownPoints,
128 int n,
129 int k);
131 double SizeBounds (double,
132 double,
133 BOOL);
135 void IncValue(double& rValue,
136 double fInc,
137 BOOL bLogarithm);
139 void DecValue(double& rValue,
140 double fInc,
141 BOOL bLogarithm);
144 Color RGBColor(ColorData nColorName);
146 String StackString(const String& aString);
150 void AdjustRect (Rectangle &rRect,
151 ChartAdjust eAdjust);
153 Size AdjustRotatedRect (const Rectangle &rRect,
154 ChartAdjust eAdjust,
155 const Rectangle &rOldRect);
157 void SetAdjust(ChartAdjust &eAdjust,
158 SvxChartTextOrient eOrient);
160 void SetTextPos(SdrTextObj &rTextObj,
161 const Point &rPos,SfxItemSet* pAttr);
163 void AdjustTextSize(SdrTextObj &rTextObj,
164 const Size &rTextSize);
166 Size GetOutputSize(SdrTextObj& rTextObj);
168 /** Creates an SchObjGroup containing SdrPathObjects, which are created from the
169 XPolygons given in the vector rPolygons. The items in rItems are applied to
170 all of the created objects.
172 Note: The ChartModel is needed for the CTOR of SchObjGroup.
174 SdrObject * CreateErrorGroup(
175 ChartModel * pModel,
176 const ::std::vector< XPolygon > & rPolygons,
177 const SfxItemSet & rItems );
181 void CreateChartGroup( SchObjGroup* &, SdrObjList* & );
186 /** Intersect two SfxItemSets in the following way: Modify rDestSet such that
187 after this function completes there are only items left that are contained
188 in both sets and have equal content (using the != operator of SfxPoolItem)
190 Items that are set in either of the itemsets but are not equal are
191 invalidated. This is useful for dialogs. For a template-like usage, you
192 can remove the invalid items by calling ClearInvalidItems() at the result.
194 Note: The Intersect method of SfxItemSet works differently for equal and
195 non-equal which-ranges. If the ranges are equal it does something
196 like this method, otherwise it just removes items which are not
197 contained in the which range of the other item set.
199 @param rSourceSet is the item set which will be iterated over
200 @param rDestSet is the item set which is modified such that the condition
201 described above is maintained.
203 void IntersectSets( const SfxItemSet & rSource, SfxItemSet & rDest );
205 Point SetPointOfRectangle (const Rectangle& rRect, ChartAdjust eAdjust);
207 void ItemsToFont(const SfxItemSet& rSet,Font& rFont);
209 BOOL ChIsPointInsideRectangle( const Point& rPoint, const Rectangle& rRect );
212 namespace sch {
213 /** @descr Extract an item for a given which id from one of two item
214 sets. If the the second item set rOverride is valid and
215 defines the requested item then return that item, else extract
216 the item from the base set. This has the same effect as merging
217 the override item set into the base set but with the advantage
218 that no item set has to be copied or even modified.
219 @param nWhich Specifies the requested item.
220 @param rBaseSet The item set from which the item is taken if
221 it the override item set is not valid or does not contain it.
222 @param rOverrideSet The item set first search for the requested
223 item.
224 @param bOverrideIsValid If TRUE then rOverrideSet is search for the
225 requested item prior to rBaseSet. If it is FALSE then
226 rOverrideSet is ignored.
228 inline const SfxPoolItem * GetItem (USHORT nWhich,
229 const SfxItemSet & rBaseSet,
230 const SfxItemSet & rOverrideSet,
231 BOOL bOverrideIsValid)
233 const SfxPoolItem * pItem;
235 if ( bOverrideIsValid
236 && rOverrideSet.GetItemState (
237 nWhich, TRUE, &pItem) == SFX_ITEM_SET)
238 return pItem;
239 else
240 return rBaseSet.GetItem (nWhich);
244 } //namespace binfilter
245 #endif