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 28 #ifndef LAYOUT_CORE_HELPER_HXX 29 #define LAYOUT_CORE_HELPER_HXX 30 31 #include <toolkit/dllapi.h> 32 #include <vector> 33 34 #include <com/sun/star/awt/XLayoutConstrains.hpp> 35 #include <com/sun/star/awt/XLayoutContainer.hpp> 36 #include <com/sun/star/awt/XVclWindowPeer.hpp> 37 #include <com/sun/star/xml/input/XRoot.hpp> 38 #include <com/sun/star/graphic/XGraphic.hpp> 39 #include <cppuhelper/implbase1.hxx> 40 #include <cppuhelper/propshlp.hxx> 41 #include <osl/module.h> 42 #include <rtl/ustring.hxx> 43 44 class Window; 45 class VCLXWindow; 46 extern "C" 47 { 48 typedef Window* (SAL_CALL *WindowCreator) (VCLXWindow** component, rtl::OUString const& name, Window* parent, long& attributes); 49 } 50 51 namespace layoutimpl 52 { 53 54 namespace css = ::com::sun::star; 55 56 /* ChildProps -- a helper to set child properties for the XLayoutContainer interface. */ 57 58 class LockHelper 59 { 60 public: 61 osl::Mutex maGuard; 62 cppu::OBroadcastHelper maBrdcstHelper; 63 LockHelper() : maBrdcstHelper( maGuard ) 64 { 65 } 66 }; 67 68 class PropHelper : public LockHelper 69 , public cppu::OPropertySetHelper 70 , public cppu::OWeakObject 71 { 72 cppu::OPropertyArrayHelper *pHelper; 73 74 struct PropDetails 75 { 76 rtl::OUString aName; 77 css::uno::Type aType; 78 void *pValue; 79 }; 80 std::vector< PropDetails > maDetails; 81 82 protected: 83 void addProp( char const *pName, sal_Int32 nNameLen, rtl_TextEncoding e, 84 css::uno::Type aType, void *pPtr ); 85 86 public: 87 PropHelper(); 88 89 // com::sun::star::uno::XInterface 90 void SAL_CALL acquire() throw() { OWeakObject::acquire(); } 91 void SAL_CALL release() throw() { OWeakObject::release(); } 92 ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 93 94 // cppu::OPropertySetHelper 95 virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 96 virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any &, 97 css::uno::Any &, sal_Int32 nHandle, const css::uno::Any & ) 98 throw(css::lang::IllegalArgumentException); 99 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, 100 const css::uno::Any& rValue ) throw (css::uno::Exception); 101 using OPropertySetHelper::getFastPropertyValue; 102 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, 103 sal_Int32 nHandle ) const; 104 105 virtual css::uno::Reference <css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo () throw (css::uno::RuntimeException); 106 107 struct Listener 108 { 109 virtual void propertiesChanged() = 0; 110 }; 111 112 void setChangeListener( Listener *pListener ) 113 { 114 mpListener = pListener; 115 } 116 117 protected: 118 Listener *mpListener; 119 }; 120 121 css::uno::Any anyFromString (const rtl::OUString &value, const css::uno::Type &type); 122 123 // The native widgets wrapper hierarchy may not reflect that of the layout 124 // hierarchy as some containers don't have an associated native widget. 125 // Use this function to get the native parent of the given peer. 126 css::uno::Reference< css::awt::XWindowPeer > 127 getParent( css::uno::Reference< css::uno::XInterface > xPeer ); 128 129 class TOOLKIT_DLLPUBLIC WidgetFactory 130 { 131 public: 132 static oslModule mSfx2Library; 133 static WindowCreator mSfx2CreateWidget; 134 135 // Should use UNO services in due course 136 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); 137 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); 138 static css::uno::Reference <css::awt::XLayoutContainer> createContainer (rtl::OUString const& name); 139 static css::uno::Reference <css::awt::XLayoutConstrains> implCreateWidget (css::uno::Reference <css::uno::XInterface> xParent, rtl::OUString name, long attributes); 140 static Window* sfx2CreateWindow (VCLXWindow** component, Window* parent, rtl::OUString const& name, long& attributes); 141 static Window* layoutCreateWindow (VCLXWindow** component, Window *parent, rtl::OUString const& name, long& attributes); 142 }; 143 144 145 css::uno::Reference< css::graphic::XGraphic > loadGraphic( const char *pName ); 146 147 } // end namespace layoutimpl 148 149 #endif /* LAYOUT_CORE_HELPER_HXX */ 150