1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
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_ROOT_HXX
33 #define LAYOUT_CORE_ROOT_HXX
35 #define _BACKWARD_BACKWARD_WARNING_H 1
38 #include <com/sun/star/awt/XLayoutRoot.hpp>
39 #include <com/sun/star/awt/XToolkit.hpp>
40 #include <com/sun/star/awt/XWindow.hpp>
41 #include <com/sun/star/io/XInputStream.hpp>
42 #include <com/sun/star/lang/XComponent.hpp>
43 #include <com/sun/star/lang/XInitialization.hpp>
44 #include <cppuhelper/implbase3.hxx>
45 #include <cppuhelper/interfacecontainer.h>
46 #include <toolkit/dllapi.h>
48 #include <layout/core/proplist.hxx>
53 namespace css
= ::com::sun::star
;
55 css::uno::Reference
< css::io::XInputStream
> getFileAsStream( const rtl::OUString
&rName
);
57 /* Interface generation code -- to hook to a parser. */
60 TODO: (ricardo) I think we should cut on LayoutRoot, stripping out its widget
61 proxy interface (just make it return the root widget). Would even make it easier
62 if there was interest to support multiple toplevel widgets in the same file.
64 We also need to make sure the code gets diposed well... There is no need to keep
65 these objects around after initialization...
71 class TOOLKIT_DLLPUBLIC LayoutRoot
: public ::cppu::WeakImplHelper3
<
72 css::awt::XLayoutRoot
,
73 css::lang::XInitialization
,
74 css::lang::XComponent
>
79 typedef std::hash_map
< rtl::OUString
,
80 css::uno::Reference
< css::awt::XLayoutConstrains
>,
81 ::rtl::OUStringHash
> ItemHash
;
85 css::uno::Reference
< css::lang::XMultiServiceFactory
> mxFactory
;
86 ::cppu::OInterfaceContainerHelper
*mpListeners
;
88 css::uno::Reference
< css::awt::XWindow
> mxWindow
;
89 css::uno::Reference
< css::awt::XLayoutContainer
> mxContainer
;
91 css::uno::Reference
< css::awt::XToolkit
> mxToolkit
;
92 LayoutWidget
*mpToplevel
;
93 css::uno::Reference
< css::awt::XLayoutUnit
> mxLayoutUnit
;
95 void error( rtl::OUString
const& message
);
98 LayoutRoot( const css::uno::Reference
< css::lang::XMultiServiceFactory
>& xFactory
);
99 virtual ~LayoutRoot();
101 void addItem( const rtl::OUString
&rName
,
102 const css::uno::Reference
< css::awt::XLayoutConstrains
> &xRef
);
104 void setWindow( css::uno::Reference
< css::awt::XLayoutConstrains
> xPeer
)
106 mxWindow
= css::uno::Reference
< css::awt::XWindow
>( xPeer
, css::uno::UNO_QUERY
);
109 // get XLayoutContainer
110 virtual css::uno::Reference
< css::awt::XLayoutContainer
> SAL_CALL
getLayoutContainer() throw (css::uno::RuntimeException
);
113 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) throw (css::uno::Exception
, css::uno::RuntimeException
);
116 virtual css::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
) throw (css::container::NoSuchElementException
, css::lang::WrappedTargetException
, css::uno::RuntimeException
);
117 virtual css::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames() throw (css::uno::RuntimeException
);
118 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
) throw (css::uno::RuntimeException
);
119 virtual css::uno::Type SAL_CALL
getElementType() throw (css::uno::RuntimeException
);
120 virtual sal_Bool SAL_CALL
hasElements() throw (css::uno::RuntimeException
);
123 virtual void SAL_CALL
dispose() throw (css::uno::RuntimeException
);
124 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) throw (css::uno::RuntimeException
);
125 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) throw (css::uno::RuntimeException
);
128 virtual LayoutWidget
*create( rtl::OUString id
, const rtl::OUString unoName
, long attrbs
, css::uno::Reference
< css::awt::XLayoutContainer
> xParent
);
131 class TOOLKIT_DLLPUBLIC LayoutWidget
133 friend class LayoutRoot
;
137 LayoutWidget( css::uno::Reference
< css::awt::XToolkit
> xToolkit
,
138 css::uno::Reference
< css::awt::XLayoutContainer
> xToplevel
,
139 rtl::OUString unoName
, long attrbs
);
140 virtual ~LayoutWidget();
142 virtual void setProperties( const PropList
&rProps
);
143 virtual void setProperty( rtl::OUString
const& attr
, rtl::OUString
const& value
);
145 virtual bool addChild( LayoutWidget
*pChild
);
146 virtual void setChildProperties( LayoutWidget
*pChild
, const PropList
&rProps
);
148 inline css::uno::Reference
< css::awt::XLayoutConstrains
> getPeer()
150 inline css::uno::Reference
< css::awt::XLayoutContainer
> getContainer()
151 { return mxContainer
; }
154 css::uno::Reference
< css::awt::XLayoutConstrains
> mxWidget
;
155 css::uno::Reference
< css::awt::XLayoutContainer
> mxContainer
;
158 } // namespace layoutimpl
160 #endif /* LAYOUT_CORE_ROOT_HXX */