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 LAYOUT_CORE_PROPLIST_HXX
25 #define LAYOUT_CORE_PROPLIST_HXX
26 
27 #include <com/sun/star/beans/XPropertySetInfo.hpp>
28 #include <com/sun/star/xml/input/XAttributes.hpp>
29 #include <list>
30 #include <rtl/ustring.hxx>
31 #include <toolkit/dllapi.h>
32 \
33 namespace layoutimpl
34 {
35 
36 namespace css = ::com::sun::star;
37 
38 typedef std::list< std::pair< rtl::OUString, rtl::OUString > > PropList;
39 
40 void propsFromAttributes( const css::uno::Reference<css::xml::input::XAttributes> & xAttributes,
41                           PropList &rProps, sal_Int32 nNamespace );
42 
43 void setProperties( css::uno::Reference< css::uno::XInterface > const& xPeer,
44                     PropList const& rProps);
45 
46 void setProperty( css::uno::Reference< css::uno::XInterface > const& xPeer,
47                   rtl::OUString const& attr, rtl::OUString const& value );
48 
49 long getAttributeProps( PropList &rProps );
50 bool findAndRemove( const char *pAttr, PropList &rProps, rtl::OUString &rValue);
51 
52 // Helpers - unfortunately VCLXWindows don't implement XPropertySet
53 // but containers do - these helpers help us to hide this
54 namespace prophlp
55 {
56 
57 // can we set properties on this handle ?
58 bool TOOLKIT_DLLPUBLIC canHandleProps( const css::uno::Reference< css::uno::XInterface > &xRef );
59 // if so which properties ?
60 css::uno::Reference< css::beans::XPropertySetInfo > TOOLKIT_DLLPUBLIC queryPropertyInfo(
61     const css::uno::Reference< css::uno::XInterface > &xRef );
62 // set / get ...
63 void TOOLKIT_DLLPUBLIC setProperty( const css::uno::Reference< css::uno::XInterface > &xRef,
64                   const rtl::OUString &rName,
65                   css::uno::Any aValue );
66 css::uno::Any TOOLKIT_DLLPUBLIC getProperty( const css::uno::Reference< css::uno::XInterface > &xRef,
67                            const rtl::OUString &rName );
68 } // namespace prophlp
69 
70 } // namespace layoutimpl
71 
72 
73 #if !OUSTRING_CSTR_PARANOIA
74 #define OUSTRING_CSTR( str ) \
75     rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ).getStr()
76 #else
77 
OUSTRING_CSTR(rtl::OUString const & str)78 inline char const* OUSTRING_CSTR( rtl::OUString const& str )
79 {
80     rtl::OString *leak
81         = new rtl::OString (rtl::OUStringToOString (str, RTL_TEXTENCODING_ASCII_US));
82     return leak->getStr();
83 }
84 
85 #endif
86 
87 #endif /* LAYOUT_CORE_PROPLIST_HXX */
88