xref: /aoo41x/main/reportdesign/inc/RptDef.hxx (revision 9ee13d13)
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 #ifndef _REPORT_RPTUIDEF_HXX
25 #define _REPORT_RPTUIDEF_HXX
26 
27 #include "dllapi.h"
28 #include <tools/solar.h>
29 #include <svx/svdobj.hxx>
30 #include <comphelper/stl_types.hxx>
31 #include <comphelper/uno3.hxx>
32 #include <svx/fmglob.hxx>
33 #include <boost/shared_ptr.hpp>
34 
35 
36 FORWARD_DECLARE_INTERFACE(report,XReportComponent)
37 FORWARD_DECLARE_INTERFACE(report,XReportDefinition)
38 FORWARD_DECLARE_INTERFACE(style,XStyle)
39 FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
40 
41 namespace rptui
42 {
43 // not all used at the moment
44 #define RPT_LAYER_FRONT		    0
45 #define RPT_LAYER_BACK		    1
46 #define RPT_LAYER_HIDDEN        2
47 
48 
49 const sal_uInt32 ReportInventor = sal_uInt32('R')*0x00000001+
50 				           sal_uInt32('P')*0x00000100+
51 						   sal_uInt32('T')*0x00010000+
52 						   sal_uInt32('1')*0x01000000;
53 
54 
55 #define OBJ_DLG_FIXEDTEXT       ((sal_uInt16) OBJ_MAXI + 1)
56 #define OBJ_DLG_IMAGECONTROL    OBJ_FM_IMAGECONTROL
57 #define OBJ_DLG_FORMATTEDFIELD  ((sal_uInt16) OBJ_MAXI + 3)
58 #define OBJ_DLG_HFIXEDLINE      ((sal_uInt16) OBJ_MAXI + 4)
59 #define OBJ_DLG_VFIXEDLINE      ((sal_uInt16) OBJ_MAXI + 5)
60 #define OBJ_DLG_SUBREPORT       ((sal_uInt16) OBJ_MAXI + 6)
61 
62 // allows the alignment and resizing of controls
63 namespace ControlModification
64 {
65     static const ::sal_Int32 NONE               = (sal_Int32)0;
66     static const ::sal_Int32 LEFT               = (sal_Int32)1;
67     static const ::sal_Int32 RIGHT              = (sal_Int32)2;
68     static const ::sal_Int32 TOP                = (sal_Int32)3;
69     static const ::sal_Int32 BOTTOM             = (sal_Int32)4;
70     static const ::sal_Int32 CENTER_HORIZONTAL  = (sal_Int32)5;
71     static const ::sal_Int32 CENTER_VERTICAL    = (sal_Int32)6;
72     static const ::sal_Int32 WIDTH_SMALLEST     = (sal_Int32)7;
73     static const ::sal_Int32 HEIGHT_SMALLEST    = (sal_Int32)8;
74     static const ::sal_Int32 WIDTH_GREATEST     = (sal_Int32)9;
75     static const ::sal_Int32 HEIGHT_GREATEST    = (sal_Int32)10;
76 }
77 
78 class AnyConverter : public ::std::binary_function< ::rtl::OUString,::com::sun::star::uno::Any,::com::sun::star::uno::Any >
79 {
80 public:
~AnyConverter()81     virtual ~AnyConverter(){}
operator ()(const::rtl::OUString &,const::com::sun::star::uno::Any & lhs) const82     virtual ::com::sun::star::uno::Any operator() (const ::rtl::OUString& /*_sPropertyName*/,const ::com::sun::star::uno::Any& lhs) const
83 	{
84 		return lhs;
85 	}
86 };
87 /** returns teh object type depending on the service name
88 	@param	_xComponent the report component
89 */
90 REPORTDESIGN_DLLPUBLIC sal_uInt16 getObjectType(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
91 typedef ::std::pair< ::rtl::OUString, ::boost::shared_ptr<AnyConverter> > TPropertyConverter;
92 DECLARE_STL_USTRINGACCESS_MAP(TPropertyConverter , TPropertyNamePair);
93 /** returns the property name map for the givern property id
94 	@param	_nObjectId	the object id
95 */
96 REPORTDESIGN_DLLPUBLIC const TPropertyNamePair& getPropertyNameMap(sal_uInt16 _nObjectId);
97 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);
98 
99 // -----------------------------------------------------------------------------
getStyleProperty(const::com::sun::star::uno::Reference<::com::sun::star::report::XReportDefinition> & _xReport,const::rtl::OUString & _sPropertyName)100 template < typename T> T getStyleProperty(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition>& _xReport,const ::rtl::OUString& _sPropertyName)
101 {
102     T nReturn = T();
103     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xProp(getUsedStyle(_xReport),::com::sun::star::uno::UNO_QUERY_THROW);
104     xProp->getPropertyValue(_sPropertyName) >>= nReturn;
105     return nReturn;
106 }
107 // -----------------------------------------------------------------------------
setStyleProperty(const::com::sun::star::uno::Reference<::com::sun::star::report::XReportDefinition> & _xReport,const::rtl::OUString & _sPropertyName,const T & _aValue)108 template<typename T> void setStyleProperty(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition>& _xReport,const ::rtl::OUString& _sPropertyName,const T& _aValue)
109 {
110     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xProp(getUsedStyle(_xReport),::com::sun::star::uno::UNO_QUERY);
111     if ( xProp.is() )
112         xProp->setPropertyValue(_sPropertyName,::com::sun::star::uno::makeAny(_aValue));
113 }
114 }
115 
116 #endif // _REPORT_RPTUIDEF_HXX
117