merge the formfield patch from ooo-build
[ooovba.git] / toolkit / source / layout / core / helper.hxx
blobbfbd81976b17df6e72dd4402b24e09f0cb6585ba
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile$
11 * $Revision$
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef LAYOUT_CORE_HELPER_HXX
33 #define LAYOUT_CORE_HELPER_HXX
35 #include <toolkit/dllapi.h>
36 #include <vector>
38 #include <com/sun/star/awt/XLayoutConstrains.hpp>
39 #include <com/sun/star/awt/XLayoutContainer.hpp>
40 #include <com/sun/star/awt/XVclWindowPeer.hpp>
41 #include <com/sun/star/xml/input/XRoot.hpp>
42 #include <com/sun/star/graphic/XGraphic.hpp>
43 #include <cppuhelper/implbase1.hxx>
44 #include <cppuhelper/propshlp.hxx>
45 #include <osl/module.h>
46 #include <rtl/ustring.hxx>
48 class Window;
49 class VCLXWindow;
50 extern "C"
52 typedef Window* (SAL_CALL *WindowCreator) (VCLXWindow** component, rtl::OUString const& name, Window* parent, long& attributes);
55 namespace layoutimpl
58 namespace css = ::com::sun::star;
60 /* ChildProps -- a helper to set child properties for the XLayoutContainer interface. */
62 class LockHelper
64 public:
65 osl::Mutex maGuard;
66 cppu::OBroadcastHelper maBrdcstHelper;
67 LockHelper() : maBrdcstHelper( maGuard )
72 class PropHelper : public LockHelper
73 , public cppu::OPropertySetHelper
74 , public cppu::OWeakObject
76 cppu::OPropertyArrayHelper *pHelper;
78 struct PropDetails
80 rtl::OUString aName;
81 css::uno::Type aType;
82 void *pValue;
84 std::vector< PropDetails > maDetails;
86 protected:
87 void addProp( char const *pName, sal_Int32 nNameLen, rtl_TextEncoding e,
88 css::uno::Type aType, void *pPtr );
90 public:
91 PropHelper();
93 // com::sun::star::uno::XInterface
94 void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
95 void SAL_CALL release() throw() { OWeakObject::release(); }
96 ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
98 // cppu::OPropertySetHelper
99 virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
100 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any &,
101 css::uno::Any &, sal_Int32 nHandle, const css::uno::Any & )
102 throw(css::lang::IllegalArgumentException);
103 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
104 const css::uno::Any& rValue ) throw (css::uno::Exception);
105 using OPropertySetHelper::getFastPropertyValue;
106 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue,
107 sal_Int32 nHandle ) const;
109 virtual css::uno::Reference <css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo () throw (css::uno::RuntimeException);
111 struct Listener
113 virtual void propertiesChanged() = 0;
116 void setChangeListener( Listener *pListener )
118 mpListener = pListener;
121 protected:
122 Listener *mpListener;
125 css::uno::Any anyFromString (const rtl::OUString &value, const css::uno::Type &type);
127 // The native widgets wrapper hierarchy may not reflect that of the layout
128 // hierarchy as some containers don't have an associated native widget.
129 // Use this function to get the native parent of the given peer.
130 css::uno::Reference< css::awt::XWindowPeer >
131 getParent( css::uno::Reference< css::uno::XInterface > xPeer );
133 class TOOLKIT_DLLPUBLIC WidgetFactory
135 public:
136 static oslModule mSfx2Library;
137 static WindowCreator mSfx2CreateWidget;
139 // Should use UNO services in due course
140 static css::uno::Reference <css::awt::XLayoutConstrains> toolkitCreateWidget (css::uno::Reference <css::awt::XToolkit> xToolkit, css::uno::Reference <css::uno::XInterface> xParent, rtl::OUString const& name, long properties);
141 static css::uno::Reference< css::awt::XLayoutConstrains > createWidget( css::uno::Reference <css::awt::XToolkit > xToolkit, css::uno::Reference< css::uno::XInterface > xParent, rtl::OUString const &name, long properties);
142 static css::uno::Reference <css::awt::XLayoutContainer> createContainer (rtl::OUString const& name);
143 static css::uno::Reference <css::awt::XLayoutConstrains> implCreateWidget (css::uno::Reference <css::uno::XInterface> xParent, rtl::OUString name, long attributes);
144 static Window* sfx2CreateWindow (VCLXWindow** component, Window* parent, rtl::OUString const& name, long& attributes);
145 static Window* layoutCreateWindow (VCLXWindow** component, Window *parent, rtl::OUString const& name, long& attributes);
149 css::uno::Reference< css::graphic::XGraphic > loadGraphic( const char *pName );
151 } // end namespace layoutimpl
153 #endif /* LAYOUT_CORE_HELPER_HXX */