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 10cdf0e10cSrcweir * 11*50e6b072SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 20*50e6b072SAndrew Rist *************************************************************/ 21*50e6b072SAndrew Rist 22*50e6b072SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef LAYOUT_CORE_ROOT_HXX 25cdf0e10cSrcweir #define LAYOUT_CORE_ROOT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #define _BACKWARD_BACKWARD_WARNING_H 1 28cdf0e10cSrcweir #include <hash_map> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <com/sun/star/awt/XLayoutRoot.hpp> 31cdf0e10cSrcweir #include <com/sun/star/awt/XToolkit.hpp> 32cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 33cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 34cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 35cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 36cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 37cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h> 38cdf0e10cSrcweir #include <toolkit/dllapi.h> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include <layout/core/proplist.hxx> 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace layoutimpl 43cdf0e10cSrcweir { 44cdf0e10cSrcweir 45cdf0e10cSrcweir namespace css = ::com::sun::star; 46cdf0e10cSrcweir 47cdf0e10cSrcweir css::uno::Reference< css::io::XInputStream > getFileAsStream( const rtl::OUString &rName ); 48cdf0e10cSrcweir 49cdf0e10cSrcweir /* Interface generation code -- to hook to a parser. */ 50cdf0e10cSrcweir 51cdf0e10cSrcweir /* 52cdf0e10cSrcweir TODO: (ricardo) I think we should cut on LayoutRoot, stripping out its widget 53cdf0e10cSrcweir proxy interface (just make it return the root widget). Would even make it easier 54cdf0e10cSrcweir if there was interest to support multiple toplevel widgets in the same file. 55cdf0e10cSrcweir 56cdf0e10cSrcweir We also need to make sure the code gets diposed well... There is no need to keep 57cdf0e10cSrcweir these objects around after initialization... 58cdf0e10cSrcweir */ 59cdf0e10cSrcweir 60cdf0e10cSrcweir 61cdf0e10cSrcweir class LayoutWidget; 62cdf0e10cSrcweir 63cdf0e10cSrcweir class TOOLKIT_DLLPUBLIC LayoutRoot : public ::cppu::WeakImplHelper3< 64cdf0e10cSrcweir css::awt::XLayoutRoot, 65cdf0e10cSrcweir css::lang::XInitialization, 66cdf0e10cSrcweir css::lang::XComponent> 67cdf0e10cSrcweir { 68cdf0e10cSrcweir protected: 69cdf0e10cSrcweir ::osl::Mutex maMutex; 70cdf0e10cSrcweir 71cdf0e10cSrcweir typedef std::hash_map< rtl::OUString, 72cdf0e10cSrcweir css::uno::Reference< css::awt::XLayoutConstrains >, 73cdf0e10cSrcweir ::rtl::OUStringHash > ItemHash; 74cdf0e10cSrcweir ItemHash maItems; 75cdf0e10cSrcweir 76cdf0e10cSrcweir sal_Bool mbDisposed; 77cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > mxFactory; 78cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper *mpListeners; 79cdf0e10cSrcweir 80cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > mxWindow; 81cdf0e10cSrcweir css::uno::Reference< css::awt::XLayoutContainer > mxContainer; 82cdf0e10cSrcweir 83cdf0e10cSrcweir css::uno::Reference< css::awt::XToolkit > mxToolkit; 84cdf0e10cSrcweir LayoutWidget *mpToplevel; 85cdf0e10cSrcweir css::uno::Reference< css::awt::XLayoutUnit > mxLayoutUnit; 86cdf0e10cSrcweir 87cdf0e10cSrcweir void error( rtl::OUString const& message ); 88cdf0e10cSrcweir 89cdf0e10cSrcweir public: 90cdf0e10cSrcweir LayoutRoot( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); 91cdf0e10cSrcweir virtual ~LayoutRoot(); 92cdf0e10cSrcweir 93cdf0e10cSrcweir void addItem( const rtl::OUString &rName, 94cdf0e10cSrcweir const css::uno::Reference< css::awt::XLayoutConstrains > &xRef ); 95cdf0e10cSrcweir setWindow(css::uno::Reference<css::awt::XLayoutConstrains> xPeer)96cdf0e10cSrcweir void setWindow( css::uno::Reference< css::awt::XLayoutConstrains > xPeer ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir mxWindow = css::uno::Reference< css::awt::XWindow >( xPeer, css::uno::UNO_QUERY ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir 101cdf0e10cSrcweir // get XLayoutContainer 102cdf0e10cSrcweir virtual css::uno::Reference< css::awt::XLayoutContainer > SAL_CALL getLayoutContainer() throw (css::uno::RuntimeException); 103cdf0e10cSrcweir 104cdf0e10cSrcweir // XInitialization 105cdf0e10cSrcweir virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw (css::uno::Exception, css::uno::RuntimeException); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // XNameAccess 108cdf0e10cSrcweir virtual css::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException); 109cdf0e10cSrcweir virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw (css::uno::RuntimeException); 110cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); 111cdf0e10cSrcweir virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); 112cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException); 113cdf0e10cSrcweir 114cdf0e10cSrcweir // XComponent 115cdf0e10cSrcweir virtual void SAL_CALL dispose() throw (css::uno::RuntimeException); 116cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) throw (css::uno::RuntimeException); 117cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) throw (css::uno::RuntimeException); 118cdf0e10cSrcweir 119cdf0e10cSrcweir // generator 120cdf0e10cSrcweir virtual LayoutWidget *create( rtl::OUString id, const rtl::OUString unoName, long attrbs, css::uno::Reference< css::awt::XLayoutContainer > xParent ); 121cdf0e10cSrcweir }; 122cdf0e10cSrcweir 123cdf0e10cSrcweir class TOOLKIT_DLLPUBLIC LayoutWidget 124cdf0e10cSrcweir { 125cdf0e10cSrcweir friend class LayoutRoot; 126cdf0e10cSrcweir 127cdf0e10cSrcweir public: LayoutWidget()128cdf0e10cSrcweir LayoutWidget() {} 129cdf0e10cSrcweir LayoutWidget( css::uno::Reference< css::awt::XToolkit > xToolkit, 130cdf0e10cSrcweir css::uno::Reference< css::awt::XLayoutContainer > xToplevel, 131cdf0e10cSrcweir rtl::OUString unoName, long attrbs ); 132cdf0e10cSrcweir virtual ~LayoutWidget(); 133cdf0e10cSrcweir 134cdf0e10cSrcweir virtual void setProperties( const PropList &rProps ); 135cdf0e10cSrcweir virtual void setProperty( rtl::OUString const& attr, rtl::OUString const& value ); 136cdf0e10cSrcweir 137cdf0e10cSrcweir virtual bool addChild( LayoutWidget *pChild ); 138cdf0e10cSrcweir virtual void setChildProperties( LayoutWidget *pChild, const PropList &rProps ); 139cdf0e10cSrcweir getPeer()140cdf0e10cSrcweir inline css::uno::Reference< css::awt::XLayoutConstrains > getPeer() 141cdf0e10cSrcweir { return mxWidget; } getContainer()142cdf0e10cSrcweir inline css::uno::Reference< css::awt::XLayoutContainer > getContainer() 143cdf0e10cSrcweir { return mxContainer; } 144cdf0e10cSrcweir 145cdf0e10cSrcweir protected: 146cdf0e10cSrcweir css::uno::Reference< css::awt::XLayoutConstrains > mxWidget; 147cdf0e10cSrcweir css::uno::Reference< css::awt::XLayoutContainer > mxContainer; 148cdf0e10cSrcweir }; 149cdf0e10cSrcweir 150cdf0e10cSrcweir } // namespace layoutimpl 151cdf0e10cSrcweir 152cdf0e10cSrcweir #endif /* LAYOUT_CORE_ROOT_HXX */ 153