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