1*50e6b072SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*50e6b072SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*50e6b072SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*50e6b072SAndrew Rist * distributed with this work for additional information 6*50e6b072SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*50e6b072SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*50e6b072SAndrew Rist * "License"); you may not use this file except in compliance 9*50e6b072SAndrew Rist * with the License. You may obtain a copy of the License at 10*50e6b072SAndrew Rist * 11*50e6b072SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*50e6b072SAndrew Rist * 13*50e6b072SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*50e6b072SAndrew Rist * software distributed under the License is distributed on an 15*50e6b072SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*50e6b072SAndrew Rist * KIND, either express or implied. See the License for the 17*50e6b072SAndrew Rist * specific language governing permissions and limitations 18*50e6b072SAndrew Rist * under the License. 19*50e6b072SAndrew Rist * 20*50e6b072SAndrew Rist *************************************************************/ 21*50e6b072SAndrew Rist 22*50e6b072SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef LAYOUT_CORE_HELPER_HXX 25cdf0e10cSrcweir #define LAYOUT_CORE_HELPER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <toolkit/dllapi.h> 28cdf0e10cSrcweir #include <vector> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <com/sun/star/awt/XLayoutConstrains.hpp> 31cdf0e10cSrcweir #include <com/sun/star/awt/XLayoutContainer.hpp> 32cdf0e10cSrcweir #include <com/sun/star/awt/XVclWindowPeer.hpp> 33cdf0e10cSrcweir #include <com/sun/star/xml/input/XRoot.hpp> 34cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp> 35cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 36cdf0e10cSrcweir #include <cppuhelper/propshlp.hxx> 37cdf0e10cSrcweir #include <osl/module.h> 38cdf0e10cSrcweir #include <rtl/ustring.hxx> 39cdf0e10cSrcweir 40cdf0e10cSrcweir class Window; 41cdf0e10cSrcweir class VCLXWindow; 42cdf0e10cSrcweir extern "C" 43cdf0e10cSrcweir { 44cdf0e10cSrcweir typedef Window* (SAL_CALL *WindowCreator) (VCLXWindow** component, rtl::OUString const& name, Window* parent, long& attributes); 45cdf0e10cSrcweir } 46cdf0e10cSrcweir 47cdf0e10cSrcweir namespace layoutimpl 48cdf0e10cSrcweir { 49cdf0e10cSrcweir 50cdf0e10cSrcweir namespace css = ::com::sun::star; 51cdf0e10cSrcweir 52cdf0e10cSrcweir /* ChildProps -- a helper to set child properties for the XLayoutContainer interface. */ 53cdf0e10cSrcweir 54cdf0e10cSrcweir class LockHelper 55cdf0e10cSrcweir { 56cdf0e10cSrcweir public: 57cdf0e10cSrcweir osl::Mutex maGuard; 58cdf0e10cSrcweir cppu::OBroadcastHelper maBrdcstHelper; LockHelper()59cdf0e10cSrcweir LockHelper() : maBrdcstHelper( maGuard ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir } 62cdf0e10cSrcweir }; 63cdf0e10cSrcweir 64cdf0e10cSrcweir class PropHelper : public LockHelper 65cdf0e10cSrcweir , public cppu::OPropertySetHelper 66cdf0e10cSrcweir , public cppu::OWeakObject 67cdf0e10cSrcweir { 68cdf0e10cSrcweir cppu::OPropertyArrayHelper *pHelper; 69cdf0e10cSrcweir 70cdf0e10cSrcweir struct PropDetails 71cdf0e10cSrcweir { 72cdf0e10cSrcweir rtl::OUString aName; 73cdf0e10cSrcweir css::uno::Type aType; 74cdf0e10cSrcweir void *pValue; 75cdf0e10cSrcweir }; 76cdf0e10cSrcweir std::vector< PropDetails > maDetails; 77cdf0e10cSrcweir 78cdf0e10cSrcweir protected: 79cdf0e10cSrcweir void addProp( char const *pName, sal_Int32 nNameLen, rtl_TextEncoding e, 80cdf0e10cSrcweir css::uno::Type aType, void *pPtr ); 81cdf0e10cSrcweir 82cdf0e10cSrcweir public: 83cdf0e10cSrcweir PropHelper(); 84cdf0e10cSrcweir 85cdf0e10cSrcweir // com::sun::star::uno::XInterface acquire()86cdf0e10cSrcweir void SAL_CALL acquire() throw() { OWeakObject::acquire(); } release()87cdf0e10cSrcweir void SAL_CALL release() throw() { OWeakObject::release(); } 88cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 89cdf0e10cSrcweir 90cdf0e10cSrcweir // cppu::OPropertySetHelper 91cdf0e10cSrcweir virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 92cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any &, 93cdf0e10cSrcweir css::uno::Any &, sal_Int32 nHandle, const css::uno::Any & ) 94cdf0e10cSrcweir throw(css::lang::IllegalArgumentException); 95cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, 96cdf0e10cSrcweir const css::uno::Any& rValue ) throw (css::uno::Exception); 97cdf0e10cSrcweir using OPropertySetHelper::getFastPropertyValue; 98cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, 99cdf0e10cSrcweir sal_Int32 nHandle ) const; 100cdf0e10cSrcweir 101cdf0e10cSrcweir virtual css::uno::Reference <css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo () throw (css::uno::RuntimeException); 102cdf0e10cSrcweir 103cdf0e10cSrcweir struct Listener 104cdf0e10cSrcweir { 105cdf0e10cSrcweir virtual void propertiesChanged() = 0; 106cdf0e10cSrcweir }; 107cdf0e10cSrcweir setChangeListener(Listener * pListener)108cdf0e10cSrcweir void setChangeListener( Listener *pListener ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir mpListener = pListener; 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir protected: 114cdf0e10cSrcweir Listener *mpListener; 115cdf0e10cSrcweir }; 116cdf0e10cSrcweir 117cdf0e10cSrcweir css::uno::Any anyFromString (const rtl::OUString &value, const css::uno::Type &type); 118cdf0e10cSrcweir 119cdf0e10cSrcweir // The native widgets wrapper hierarchy may not reflect that of the layout 120cdf0e10cSrcweir // hierarchy as some containers don't have an associated native widget. 121cdf0e10cSrcweir // Use this function to get the native parent of the given peer. 122cdf0e10cSrcweir css::uno::Reference< css::awt::XWindowPeer > 123cdf0e10cSrcweir getParent( css::uno::Reference< css::uno::XInterface > xPeer ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir class TOOLKIT_DLLPUBLIC WidgetFactory 126cdf0e10cSrcweir { 127cdf0e10cSrcweir public: 128cdf0e10cSrcweir static oslModule mSfx2Library; 129cdf0e10cSrcweir static WindowCreator mSfx2CreateWidget; 130cdf0e10cSrcweir 131cdf0e10cSrcweir // Should use UNO services in due course 132cdf0e10cSrcweir 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); 133cdf0e10cSrcweir 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); 134cdf0e10cSrcweir static css::uno::Reference <css::awt::XLayoutContainer> createContainer (rtl::OUString const& name); 135cdf0e10cSrcweir static css::uno::Reference <css::awt::XLayoutConstrains> implCreateWidget (css::uno::Reference <css::uno::XInterface> xParent, rtl::OUString name, long attributes); 136cdf0e10cSrcweir static Window* sfx2CreateWindow (VCLXWindow** component, Window* parent, rtl::OUString const& name, long& attributes); 137cdf0e10cSrcweir static Window* layoutCreateWindow (VCLXWindow** component, Window *parent, rtl::OUString const& name, long& attributes); 138cdf0e10cSrcweir }; 139cdf0e10cSrcweir 140cdf0e10cSrcweir 141cdf0e10cSrcweir css::uno::Reference< css::graphic::XGraphic > loadGraphic( const char *pName ); 142cdf0e10cSrcweir 143cdf0e10cSrcweir } // end namespace layoutimpl 144cdf0e10cSrcweir 145cdf0e10cSrcweir #endif /* LAYOUT_CORE_HELPER_HXX */ 146