xref: /aoo42x/main/reportdesign/inc/RptDef.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _REPORT_RPTUIDEF_HXX
29 #define _REPORT_RPTUIDEF_HXX
30 
31 #include "dllapi.h"
32 #include <tools/solar.h>
33 #include <svx/svdobj.hxx>
34 #include <comphelper/stl_types.hxx>
35 #include <comphelper/uno3.hxx>
36 #include <svx/fmglob.hxx>
37 #include <boost/shared_ptr.hpp>
38 
39 
40 FORWARD_DECLARE_INTERFACE(report,XReportComponent)
41 FORWARD_DECLARE_INTERFACE(report,XReportDefinition)
42 FORWARD_DECLARE_INTERFACE(style,XStyle)
43 FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
44 
45 namespace rptui
46 {
47 // not all used at the moment
48 #define RPT_LAYER_FRONT		    0
49 #define RPT_LAYER_BACK		    1
50 #define RPT_LAYER_HIDDEN        2
51 
52 
53 const sal_uInt32 ReportInventor = sal_uInt32('R')*0x00000001+
54 				           sal_uInt32('P')*0x00000100+
55 						   sal_uInt32('T')*0x00010000+
56 						   sal_uInt32('1')*0x01000000;
57 
58 
59 #define OBJ_DLG_FIXEDTEXT       ((sal_uInt16) OBJ_MAXI + 1)
60 #define OBJ_DLG_IMAGECONTROL    OBJ_FM_IMAGECONTROL
61 #define OBJ_DLG_FORMATTEDFIELD  ((sal_uInt16) OBJ_MAXI + 3)
62 #define OBJ_DLG_HFIXEDLINE      ((sal_uInt16) OBJ_MAXI + 4)
63 #define OBJ_DLG_VFIXEDLINE      ((sal_uInt16) OBJ_MAXI + 5)
64 #define OBJ_DLG_SUBREPORT       ((sal_uInt16) OBJ_MAXI + 6)
65 
66 // allows the alignment and resizing of controls
67 namespace ControlModification
68 {
69     static const ::sal_Int32 NONE               = (sal_Int32)0;
70     static const ::sal_Int32 LEFT               = (sal_Int32)1;
71     static const ::sal_Int32 RIGHT              = (sal_Int32)2;
72     static const ::sal_Int32 TOP                = (sal_Int32)3;
73     static const ::sal_Int32 BOTTOM             = (sal_Int32)4;
74     static const ::sal_Int32 CENTER_HORIZONTAL  = (sal_Int32)5;
75     static const ::sal_Int32 CENTER_VERTICAL    = (sal_Int32)6;
76     static const ::sal_Int32 WIDTH_SMALLEST     = (sal_Int32)7;
77     static const ::sal_Int32 HEIGHT_SMALLEST    = (sal_Int32)8;
78     static const ::sal_Int32 WIDTH_GREATEST     = (sal_Int32)9;
79     static const ::sal_Int32 HEIGHT_GREATEST    = (sal_Int32)10;
80 }
81 
82 class AnyConverter : public ::std::binary_function< ::rtl::OUString,::com::sun::star::uno::Any,::com::sun::star::uno::Any >
83 {
84 public:
85     virtual ~AnyConverter(){}
86     virtual ::com::sun::star::uno::Any operator() (const ::rtl::OUString& /*_sPropertyName*/,const ::com::sun::star::uno::Any& lhs) const
87 	{
88 		return lhs;
89 	}
90 };
91 /** returns teh object type depending on the service name
92 	@param	_xComponent the report component
93 */
94 REPORTDESIGN_DLLPUBLIC sal_uInt16 getObjectType(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
95 typedef ::std::pair< ::rtl::OUString, ::boost::shared_ptr<AnyConverter> > TPropertyConverter;
96 DECLARE_STL_USTRINGACCESS_MAP(TPropertyConverter , TPropertyNamePair);
97 /** returns the property name map for the givern property id
98 	@param	_nObjectId	the object id
99 */
100 REPORTDESIGN_DLLPUBLIC const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId);
101 REPORTDESIGN_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle> getUsedStyle(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition>& _xReport);
102 
103 // -----------------------------------------------------------------------------
104 template < typename T> T getStyleProperty(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition>& _xReport,const ::rtl::OUString& _sPropertyName)
105 {
106     T nReturn = T();
107     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xProp(getUsedStyle(_xReport),::com::sun::star::uno::UNO_QUERY_THROW);
108     xProp->getPropertyValue(_sPropertyName) >>= nReturn;
109     return nReturn;
110 }
111 // -----------------------------------------------------------------------------
112 template<typename T> void setStyleProperty(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition>& _xReport,const ::rtl::OUString& _sPropertyName,const T& _aValue)
113 {
114     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xProp(getUsedStyle(_xReport),::com::sun::star::uno::UNO_QUERY);
115     if ( xProp.is() )
116         xProp->setPropertyValue(_sPropertyName,::com::sun::star::uno::makeAny(_aValue));
117 }
118 }
119 
120 #endif // _REPORT_RPTUIDEF_HXX
121