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_IMPORT_HXX
33 #define LAYOUT_CORE_IMPORT_HXX
37 #define _BACKWARD_BACKWARD_WARNING_H 1
41 #include <com/sun/star/xml/input/XRoot.hpp>
42 #include <cppuhelper/implbase1.hxx>
43 #include <com/sun/star/awt/XButton.hpp>
44 #include <com/sun/star/awt/XRadioButton.hpp>
50 namespace css
= ::com::sun::star
;
57 void addItem( rtl::OUString id
, css::uno::Reference
< css::awt::XRadioButton
> xRadio
)
58 throw (css::uno::RuntimeException
);
61 class RadioGroup
: public ::cppu::WeakImplHelper1
< css::awt::XItemListener
>
62 , public ::cppu::WeakImplHelper1
< css::awt::XActionListener
>
66 void addItem( css::uno::Reference
< css::awt::XRadioButton
> xRadio
);
69 typedef std::list
< css::uno::Reference
< css::awt::XRadioButton
> > RadioButtonsList
;
70 RadioButtonsList mxRadios
;
71 css::uno::Reference
< css::awt::XRadioButton
> mxSelectedRadio
;
73 void handleSelected ()
74 throw (css::uno::RuntimeException
);
77 void SAL_CALL
itemStateChanged( const css::awt::ItemEvent
& e
)
78 throw (css::uno::RuntimeException
);
80 // awt::XActionListener
81 void SAL_CALL
actionPerformed( const css::awt::ActionEvent
& e
)
82 throw (css::uno::RuntimeException
);
84 // lang::XEventListener
85 void SAL_CALL
disposing( const css::lang::EventObject
& )
86 throw (css::uno::RuntimeException
);
89 // each RadioGroup will stay alive after RadioGroups die with the ImportContext
90 // because they are referenced by every XRadioButton through the listener
91 typedef std::map
< rtl::OUString
, css::uno::Reference
< RadioGroup
> > RadioGroupsMap
;
92 RadioGroupsMap mxRadioGroups
;
100 Widget( css::uno::Reference
< css::awt::XToolkit
> xToolkit
,
101 css::uno::Reference
< css::awt::XWindow
> xToplevel
,
102 rtl::OUString unoName
, long attrbs
);
105 virtual void setProperties( const PropList
&rProps
);
107 virtual bool addChild( Widget
*pChild
);
108 virtual void setChildProperties( Widget
*pChild
, const PropList
&rProps
);
110 inline css::uno::Reference
< css::awt::XLayoutConstrains
> getPeer()
113 inline css::uno::Reference
< css::awt::XLayoutConstrains
> getContainer()
114 { return mxContainer
; }
117 css::uno::Reference
< css::awt::XLayoutConstrains
> mxWidget
;
118 css::uno::Reference
< css::awt::XLayoutContainer
> mxContainer
;
124 Root( css::uno::Reference
< css::awt::XToolkit
> xToolkit
)
125 : mxToolkit( xToolkit
) {}
128 virtual Widget
*create( rtl::OUString id
, const rtl::OUString unoName
, long attrbs
);
130 css::uno::Reference
< css::awt::XLayoutConstrains
> getById( rtl::OUString id
);
131 inline css::uno::Reference
< css::awt::XLayoutConstrains
> getToplevel();
134 css::uno::Reference
< css::awt::XToolkit
> mxToolkit
;
137 typedef std::hash_map
< rtl::OUString
, css::uno::Reference
< css::awt::XLayoutConstrains
>,
138 rtl::OUStringHash
> ItemHash
;
144 class ImportContext
: public ::cppu::WeakImplHelper1
< css::xml::input::XRoot
>
147 sal_Int32 XMLNS_LAYOUT_UID
, XMLNS_CONTAINER_UID
;
148 LayoutRoot
&mrRoot
; // switch to XNameContainer ref ?
149 RadioGroups mxRadioGroups
;
151 inline ImportContext( LayoutRoot
&rRoot
) SAL_THROW( () )
153 virtual ~ImportContext() {}
156 virtual void SAL_CALL
startDocument(
157 css::uno::Reference
< css::xml::input::XNamespaceMapping
>
158 const & xNamespaceMapping
)
159 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
);
160 virtual void SAL_CALL
endDocument()
161 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
)
163 virtual void SAL_CALL
processingInstruction(
164 ::rtl::OUString
const & /* rTarget */, ::rtl::OUString
const & /* rData */ )
165 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
)
167 virtual void SAL_CALL
setDocumentLocator(
168 css::uno::Reference
< css::xml::sax::XLocator
> const & /* xLocator */ )
169 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
)
171 virtual css::uno::Reference
< css::xml::input::XElement
>
172 SAL_CALL
startRootElement(
173 sal_Int32 nUid
, ::rtl::OUString
const & rLocalName
,
174 css::uno::Reference
<css::xml::input::XAttributes
> const & xAttributes
)
175 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
);
178 class ElementBase
: public ::cppu::WeakImplHelper1
< css::xml::input::XElement
>
181 ImportContext
*mpImport
;
182 /* TODO: check if all this memebers are needed. */
183 ElementBase
*mpParent
;
186 ::rtl::OUString maLocalName
;
187 css::uno::Reference
< css::xml::input::XAttributes
> mxAttributes
;
190 sal_Int32 nUid
, ::rtl::OUString
const & rLocalName
,
191 css::uno::Reference
< css::xml::input::XAttributes
> const & xAttributes
,
192 ElementBase
* pParent
, ImportContext
* pImport
)
194 virtual ~ElementBase() SAL_THROW(());
197 virtual css::uno::Reference
<css::xml::input::XElement
> SAL_CALL
getParent()
198 throw (css::uno::RuntimeException
)
199 { return static_cast< css::xml::input::XElement
* >( mpParent
); }
200 virtual ::rtl::OUString SAL_CALL
getLocalName() throw (css::uno::RuntimeException
)
201 { return maLocalName
; }
202 virtual sal_Int32 SAL_CALL
getUid() throw (css::uno::RuntimeException
)
204 virtual css::uno::Reference
< css::xml::input::XAttributes
>
205 SAL_CALL
getAttributes() throw (css::uno::RuntimeException
)
206 { return mxAttributes
; }
208 virtual void SAL_CALL
ignorableWhitespace(
209 ::rtl::OUString
const & /* rWhitespaces */ )
210 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
)
212 virtual void SAL_CALL
characters( ::rtl::OUString
const & /* rChars */ )
213 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
)
215 virtual void SAL_CALL
processingInstruction(
216 ::rtl::OUString
const & /* Target */, ::rtl::OUString
const & /* Data */ )
217 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
)
220 virtual css::uno::Reference
< css::xml::input::XElement
>
221 SAL_CALL
startChildElement(
222 sal_Int32 nUid
, ::rtl::OUString
const & rLocalName
,
223 css::uno::Reference
<css::xml::input::XAttributes
> const & xAttributes
)
224 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
) = 0;
225 virtual void SAL_CALL
endElement()
226 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
)
230 class WidgetElement
: public ElementBase
233 LayoutWidget
*mpWidget
;
236 WidgetElement( sal_Int32 nUid
, rtl::OUString
const &name
,
237 css::uno::Reference
< css::xml::input::XAttributes
> const &attributes
,
238 ElementBase
*parent
, ImportContext
*import
) SAL_THROW (());
243 virtual css::uno::Reference
< css::xml::input::XElement
> SAL_CALL
244 startChildElement (sal_Int32 id
, rtl::OUString
const &name
,
245 css::uno::Reference
< css::xml::input::XAttributes
> const &attributes
)
246 throw( css::xml::sax::SAXException
, css::uno::RuntimeException
);
247 virtual void SAL_CALL
characters( ::rtl::OUString
const & /* rChars */ )
248 throw (css::xml::sax::SAXException
, css::uno::RuntimeException
);
251 class ToplevelElement
: public WidgetElement
254 ToplevelElement( rtl::OUString
const &name
,
255 css::uno::Reference
< css::xml::input::XAttributes
> const &attributes
,
256 ImportContext
*import
) SAL_THROW (());
261 } // namespace layoutimpl
263 #endif /* LAYOUT_CORE_IMPORT_HXX */