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 #ifndef _CHART2_PROPERTYMAPPER_HXX
24 #define _CHART2_PROPERTYMAPPER_HXX
25 
26 #include <comphelper/InlineContainer.hxx>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/drawing/XShape.hpp>
29 
30 //.............................................................................
31 namespace chart
32 {
33 //.............................................................................
34 
35 //-----------------------------------------------------------------------------
36 /**
37 */
38 
39 typedef ::std::map< ::rtl::OUString, ::rtl::OUString >            tPropertyNameMap;
40 typedef ::comphelper::MakeMap< ::rtl::OUString, ::rtl::OUString > tMakePropertyNameMap;
41 
42 typedef ::std::map< ::rtl::OUString, ::com::sun::star::uno::Any >            tPropertyNameValueMap;
43 typedef ::comphelper::MakeMap< ::rtl::OUString, ::com::sun::star::uno::Any > tMakePropertyNameValueMap;
44 
45 typedef ::com::sun::star::uno::Sequence< rtl::OUString > tNameSequence;
46 typedef ::comphelper::MakeSequence< rtl::OUString >      tMakeNameSequence;
47 
48 typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > tAnySequence;
49 typedef ::comphelper::MakeSequence< ::com::sun::star::uno::Any >      tMakeAnySequence;
50 
51 class PropertyMapper
52 {
53 public:
54     static void setMappedProperties(
55           const ::com::sun::star::uno::Reference<
56                 ::com::sun::star::beans::XPropertySet >& xTarget
57         , const ::com::sun::star::uno::Reference<
58                 ::com::sun::star::beans::XPropertySet >& xSource
59         , const tPropertyNameMap& rMap
60         , tPropertyNameValueMap* pOverwriteMap=0 );
61 
62     static void getValueMap(
63           tPropertyNameValueMap& rValueMap
64         , const tPropertyNameMap& rNameMap
65         , const ::com::sun::star::uno::Reference<
66                 ::com::sun::star::beans::XPropertySet >& xSourceProp
67         );
68 
69     static void getMultiPropertyLists(
70                   tNameSequence& rNames
71                 , tAnySequence&  rValues
72                 , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xProp
73                 , const tPropertyNameMap& rMap
74                 );
75 
76     static void getMultiPropertyListsFromValueMap(
77                   tNameSequence& rNames
78                 , tAnySequence&  rValues
79                 , const tPropertyNameValueMap& rValueMap
80                 );
81 
82     static ::com::sun::star::uno::Any*
83                 getValuePointer( tAnySequence& rPropValues
84                          , const tNameSequence& rPropNames
85                          , const rtl::OUString& rPropName );
86 
87     static ::com::sun::star::uno::Any*
88                 getValuePointerForLimitedSpace( tAnySequence& rPropValues
89                          , const tNameSequence& rPropNames
90                          , bool bLimitedHeight );
91 
92     static void setMultiProperties(
93                   const tNameSequence& rNames
94                 , const tAnySequence&  rValues
95                 , const ::com::sun::star::uno::Reference<
96                     ::com::sun::star::beans::XPropertySet >& xTarget );
97 
98     static const tMakePropertyNameMap& getPropertyNameMapForCharacterProperties();
99     static const tMakePropertyNameMap& getPropertyNameMapForParagraphProperties();
100     static const tMakePropertyNameMap& getPropertyNameMapForFillProperties();
101     static const tMakePropertyNameMap& getPropertyNameMapForLineProperties();
102     static const tMakePropertyNameMap& getPropertyNameMapForFillAndLineProperties();
103     static const tMakePropertyNameMap& getPropertyNameMapForTextShapeProperties();
104 
105     static const tMakePropertyNameMap& getPropertyNameMapForFilledSeriesProperties();
106     static const tMakePropertyNameMap& getPropertyNameMapForLineSeriesProperties();
107 
108     static void getTextLabelMultiPropertyLists(
109                 const ::com::sun::star::uno::Reference<
110                       ::com::sun::star::beans::XPropertySet >& xSourceProp
111                 , tNameSequence& rPropNames, tAnySequence& rPropValues
112                 , bool bName=true
113                 , sal_Int32 nLimitedSpace=-1
114                 , bool bLimitedHeight=false );
115 
116     /** adds line-, fill- and character properties and sets some suitable
117         defaults for auto-grow properties
118      */
119     static void getPreparedTextShapePropertyLists(
120         const ::com::sun::star::uno::Reference<
121               ::com::sun::star::beans::XPropertySet >& xSourceProp
122         , tNameSequence& rPropNames
123         , tAnySequence& rPropValues );
124 };
125 
126 //.............................................................................
127 } //namespace chart
128 //.............................................................................
129 #endif
130