xref: /trunk/main/toolkit/source/layout/core/helper.cxx (revision cdf0e10c)
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 #include "helper.hxx"
29 
30 #include <assert.h>
31 #include <list>
32 #include <com/sun/star/awt/WindowAttribute.hpp>
33 #include <com/sun/star/awt/XWindow.hpp>
34 #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
35 #include <toolkit/awt/vclxwindow.hxx>
36 #include <tools/debug.hxx>
37 
38 #include "proplist.hxx"
39 
40 #if TEST_LAYOUT && !defined( DBG_UTIL )
41 #undef DBG_ERROR
42 #define DBG_ERROR OSL_TRACE
43 #undef DBG_ERROR1
44 #define DBG_ERROR1 OSL_TRACE
45 #undef DBG_ERROR2
46 #define DBG_ERROR2 OSL_TRACE
47 #endif /* TEST_LAYOUT && !DBG_UTIL */
48 
49 namespace layoutimpl
50 {
51 using namespace com::sun::star;
52 using rtl::OUString;
53 
54 uno::Reference< awt::XWindowPeer >
55 getParent( uno::Reference< uno::XInterface > xRef )
56 {
57     do
58     {
59         uno::Reference< awt::XWindowPeer > xPeer( xRef, uno::UNO_QUERY );
60         if ( xPeer.is() )
61             return xPeer;
62 
63         uno::Reference< awt::XLayoutContainer > xCont( xRef, uno::UNO_QUERY );
64         if ( xCont.is() )
65             xRef = xCont->getParent();
66     }
67     while ( xRef.is() );
68 
69     return uno::Reference< awt::XWindowPeer >();
70 }
71 
72 #if 0
73 static uno::Reference< awt::XWindowPeer >
74 getToplevel( uno::Reference< uno::XInterface > xRef )
75 {
76     uno::Reference< awt::XWindowPeer > xTop, i;
77     while ( ( i = uno::Reference< awt::XWindowPeer >( xRef, uno::UNO_QUERY ) ).is() )
78     {
79         xTop = i;
80 
81         uno::Reference< awt::XLayoutContainer > xCont( xRef, uno::UNO_QUERY );
82         if ( xCont.is() )
83             xRef = xCont->getParent();
84         else
85             xRef = uno::Reference< awt::XWindowPeer >();
86     }
87 
88     return xTop;
89 }
90 #endif
91 
92 }
93 
94 #include "bin.hxx"
95 #include "box.hxx"
96 #include "dialogbuttonhbox.hxx"
97 #include "flow.hxx"
98 #include "localized-string.hxx"
99 #include "table.hxx"
100 
101 namespace layoutimpl
102 {
103 
104 oslModule WidgetFactory::mSfx2Library = 0;
105 WindowCreator WidgetFactory::mSfx2CreateWidget = 0;
106 
107 uno::Reference <awt::XLayoutContainer> WidgetFactory::createContainer (OUString const& name)
108 {
109     uno::Reference< awt::XLayoutContainer > xPeer;
110 
111     if ( name.equalsAscii( "hbox" ) )
112         xPeer = uno::Reference< awt::XLayoutContainer >( new HBox() );
113     else if ( name.equalsAscii( "vbox" ) )
114         xPeer = uno::Reference< awt::XLayoutContainer >( new VBox() );
115     else if ( name.equalsAscii( "table" ) )
116         xPeer = uno::Reference< awt::XLayoutContainer >( new Table() );
117     else if ( name.equalsAscii( "flow" ) )
118         xPeer = uno::Reference< awt::XLayoutContainer >( new Flow() );
119     else if ( name.equalsAscii( "bin" ) )
120         xPeer = uno::Reference< awt::XLayoutContainer >( new Bin() );
121     else if ( name.equalsAscii( "min-size" ) )
122         xPeer = uno::Reference< awt::XLayoutContainer >( new MinSize() );
123     else if ( name.equalsAscii( "align" ) )
124         xPeer = uno::Reference< awt::XLayoutContainer >( new Align() );
125     else if ( name.equalsAscii( "dialogbuttonhbox" ) )
126         xPeer = uno::Reference< awt::XLayoutContainer >( new DialogButtonHBox() );
127 
128     return xPeer;
129 }
130 
131 uno::Reference <awt::XLayoutConstrains> WidgetFactory::toolkitCreateWidget (uno::Reference <awt::XToolkit> xToolkit, uno::Reference <uno::XInterface> xParent, OUString const& name, long properties)
132 {
133     uno::Reference< awt::XLayoutConstrains > xPeer;
134     bool bToplevel = !xParent.is();
135 
136     // UNO Control Widget
137     awt::WindowDescriptor desc;
138     if ( bToplevel )
139         desc.Type = awt::WindowClass_TOP;
140     else
141     {
142         desc.Type = awt::WindowClass_SIMPLE;
143 
144 #if 0
145         // top container -- a wrapper for framewindow -- is de-coupled
146         // from awt::XWindowPeer. So, getParent() fails at it.
147         uno::Reference< awt::XWindowPeer > xWinParent = getParent( xParent );
148 #else
149         uno::Reference< awt::XWindowPeer > xWinParent( xParent, uno::UNO_QUERY );
150 #endif
151         assert( xParent.is() );
152         assert( xWinParent.is() );
153         /*
154           With the new three layer instarr/rpath feature, when
155           prepending toolkit/unxlngx6.pro/lib or $SOLARVER/lib to
156           LD_LIBRARY_PATH, VCLXWindow::GetImplementation returns 0x0
157           vclxtoolkit::ImplCreateWindow failing to create any widget;
158           although it succeeds here.
159 
160           While developing, one now must copy libtlx.so to
161           $OOO_INSTALL_PREFIX/openoffice.org/basis3.0/program/libtklx.so
162           each time.
163         */
164 		VCLXWindow* parentComponent = VCLXWindow::GetImplementation( xWinParent );
165         if ( !parentComponent )
166             throw uno::RuntimeException(
167                 OUString::createFromAscii( "parent has no implementation" ),
168                 uno::Reference< uno::XInterface >() );
169         desc.Parent = xWinParent;
170     }
171 
172     desc.ParentIndex = 0;
173     // debugging help ...
174     desc.Bounds.X = 0;
175     desc.Bounds.Y = 0;
176     desc.Bounds.Width = 300;
177     desc.Bounds.Height = 200;
178 
179     desc.WindowAttributes = properties;
180     desc.WindowServiceName = name;
181 
182     uno::Reference< awt::XWindowPeer > xWinPeer;
183     try
184     {
185         OSL_TRACE("Asking toolkit: %s", OUSTRING_CSTR( desc.WindowServiceName ) );
186         xWinPeer = xToolkit->createWindow( desc );
187         if ( !xWinPeer.is() )
188             throw uno::RuntimeException(
189                 OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot create peer" ) ),
190                 uno::Reference< uno::XInterface >() );
191         xPeer = uno::Reference< awt::XLayoutConstrains >( xWinPeer, uno::UNO_QUERY );
192     }
193     catch( uno::Exception & )
194     {
195         DBG_ERROR1( "Warning: %s is not a recognized type\n", OUSTRING_CSTR( name ) );
196         return uno::Reference< awt::XLayoutConstrains >();
197     }
198 
199 #if 0 // This shadows the show="false" property and seems otherwise
200       // unnecessary
201 
202     // default to visible, let then people change it on properties
203     if ( ! bToplevel )
204     {
205         uno::Reference< awt::XWindow> xWindow( xPeer, uno::UNO_QUERY );
206         if ( xWindow.is() )
207             xWindow->setVisible( true );
208     }
209 #endif
210 
211     return xPeer;
212 }
213 
214 uno::Reference< awt::XLayoutConstrains >
215 WidgetFactory::createWidget (uno::Reference< awt::XToolkit > xToolkit, uno::Reference< uno::XInterface > xParent, OUString const& name, long properties)
216 {
217     uno::Reference< awt::XLayoutConstrains > xPeer;
218 
219     xPeer = uno::Reference <awt::XLayoutConstrains> (createContainer (name), uno::UNO_QUERY);
220     if ( xPeer.is() )
221         return xPeer;
222 
223     xPeer = implCreateWidget (xParent, name, properties);
224     if (xPeer.is ())
225         return xPeer;
226 
227 #define FIXED_INFO 1
228 #if FIXED_INFO
229     OUString tName = name;
230     // FIXME
231     if ( name.equalsAscii( "fixedinfo" ) )
232         tName = OUString::createFromAscii( "fixedtext" );
233     xPeer = toolkitCreateWidget (xToolkit, xParent, tName, properties);
234 #else
235     xPeer = toolkitCreateWidget (xToolkit, xParent, name, properties);
236 #endif
237 
238     return xPeer;
239 }
240 
241 PropHelper::PropHelper() : LockHelper()
242                          , cppu::OPropertySetHelper( maBrdcstHelper )
243                          , pHelper( NULL )
244 {
245 }
246 
247 void
248 PropHelper::addProp (const char *pName, sal_Int32 nNameLen, rtl_TextEncoding e,
249                      uno::Type aType, void *pPtr)
250 {
251     // this sucks rocks for effiency ...
252     PropDetails aDetails;
253     aDetails.aName = rtl::OUString::intern( pName, nNameLen, e );
254     aDetails.aType = aType;
255     aDetails.pValue = pPtr;
256     maDetails.push_back( aDetails );
257 }
258 
259 cppu::IPropertyArrayHelper & SAL_CALL
260 PropHelper::getInfoHelper()
261 {
262     if ( ! pHelper )
263     {
264         uno::Sequence< beans::Property > aProps( maDetails.size() );
265         for ( unsigned int i = 0; i < maDetails.size(); i++)
266         {
267             aProps[i].Name = maDetails[i].aName;
268             aProps[i].Type = maDetails[i].aType;
269             aProps[i].Handle = i;
270             aProps[i].Attributes = 0;
271         }
272         pHelper = new cppu::OPropertyArrayHelper( aProps, false /* fixme: faster ? */ );
273 
274     }
275     return *pHelper;
276 }
277 
278 sal_Bool SAL_CALL
279 PropHelper::convertFastPropertyValue(
280     uno::Any & rConvertedValue,
281     uno::Any & rOldValue,
282     sal_Int32 nHandle,
283     const uno::Any& rValue )
284     throw (lang::IllegalArgumentException)
285 {
286     OSL_ASSERT( nHandle >= 0 && nHandle < (sal_Int32) maDetails.size() );
287 
288     // FIXME: no Any::getValue ...
289     getFastPropertyValue( rOldValue, nHandle );
290     if ( rOldValue != rValue )
291     {
292         rConvertedValue = rValue;
293         return sal_True; // changed
294     }
295     else
296     {
297         rConvertedValue.clear();
298         rOldValue.clear();
299     }
300     return sal_False;
301 }
302 
303 
304 void SAL_CALL
305 PropHelper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
306                                               const uno::Any& rValue )
307     throw (uno::Exception)
308 {
309     OSL_ASSERT( nHandle >= 0 && nHandle < (sal_Int32) maDetails.size() );
310 
311     const PropDetails &rInfo = maDetails[ nHandle ];
312 
313     uno_type_assignData( rInfo.pValue, rInfo.aType.getTypeLibType(),
314                          rValue.pData, rValue.pType,
315                          0, 0, 0 );
316 
317     if ( mpListener )
318         mpListener->propertiesChanged();
319 }
320 
321 void SAL_CALL
322 PropHelper::getFastPropertyValue( uno::Any& rValue,
323                                   sal_Int32 nHandle ) const
324 {
325     OSL_ASSERT( nHandle >= 0 && nHandle < (sal_Int32) maDetails.size() );
326     const PropDetails &rInfo = maDetails[ nHandle ];
327 #if 0
328     switch ( rInfo.aType.getTypeClass() )
329     {
330 #define MAP(classtype,ctype)                        \
331         case uno::TypeClass_##classtype:       \
332             rValue <<= *(ctype *)(rInfo.pValue);    \
333         break
334         MAP( DOUBLE, double );
335         MAP( SHORT, sal_Int16 );
336         MAP( LONG,  sal_Int32 );
337         MAP( UNSIGNED_SHORT, sal_uInt16 );
338         MAP( UNSIGNED_LONG, sal_uInt32 );
339         MAP( STRING, ::rtl::OUString );
340         default:
341             DBG_ERROR( "ERROR: unknown type to map!" );
342             break;
343     }
344 #undef MAP
345 #endif
346     rValue.setValue( rInfo.pValue, rInfo.aType );
347 }
348 
349 ::com::sun::star::uno::Any
350 PropHelper::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
351 {
352     return OPropertySetHelper::queryInterface( rType );
353 }
354 
355 uno::Reference <beans::XPropertySetInfo> SAL_CALL PropHelper::getPropertySetInfo () throw (uno::RuntimeException)
356 {
357     return css::uno::Reference <css::beans::XPropertySetInfo> (createPropertySetInfo (getInfoHelper ()));
358 }
359 
360 } // namespace layoutimpl
361 
362 #include <awt/vclxbutton.hxx>
363 #include <awt/vclxdialog.hxx>
364 #include <awt/vclxfixedline.hxx>
365 #include <awt/vclxplugin.hxx>
366 #include <awt/vclxscroller.hxx>
367 #include <awt/vclxsplitter.hxx>
368 #include <awt/vclxtabcontrol.hxx>
369 #include <awt/vclxtabpage.hxx>
370 #include <toolkit/awt/vclxtoolkit.hxx>
371 #include <toolkit/awt/vclxwindow.hxx>
372 #include <vcl/button.hxx>
373 #include <vcl/dialog.hxx>
374 #include <vcl/fixed.hxx>
375 #include <vcl/tabctrl.hxx>
376 #include <vcl/tabpage.hxx>
377 #include <vcl/unohelp.hxx>
378 
379 #include <layout/layout.hxx>
380 #include <toolkit/awt/vclxwindows.hxx>
381 #include <vcl/lstbox.hxx>
382 #include <vcl.hxx>
383 
384 #include <typeinfo>
385 
386 namespace layoutimpl
387 {
388 
389 uno::Reference <awt::XLayoutConstrains> WidgetFactory::implCreateWidget (uno::Reference <uno::XInterface> xParent, OUString name, long attributes)
390 {
391     Window* parent = 0;
392 
393     if (VCLXWindow* parentComponent = VCLXWindow::GetImplementation (xParent))
394         parent = parentComponent->GetWindow ();
395 
396     VCLXWindow* component = 0;
397     Window* window = 0; //sfx2CreateWindow (&component, parent, name, attributes);
398     if (!window)
399         window = layoutCreateWindow (&component, parent, name, attributes);
400 
401     uno::Reference <awt::XLayoutConstrains> reference;
402     if (window)
403     {
404         window->SetCreatedWithToolkit( sal_True );
405         if ( component )
406             component->SetCreatedWithToolkit( true );
407         reference = component;
408         window->SetComponentInterface( component );
409         if ( attributes & awt::WindowAttribute::SHOW )
410             window->Show();
411     }
412 
413     return reference;
414 }
415 
416 extern "C" { static void SAL_CALL thisModule() {} }
417 
418 Window* WidgetFactory::sfx2CreateWindow (VCLXWindow** component, Window* parent, OUString const& name, long& attributes)
419 {
420     OSL_TRACE("Asking sfx2: %s", OUSTRING_CSTR (name));
421 
422 	if (!mSfx2Library)
423 	{
424 		OUString libraryName = ::vcl::unohelper::CreateLibraryName ("sfx", sal_True);
425         mSfx2Library = osl_loadModuleRelative (&thisModule, libraryName.pData, SAL_LOADMODULE_DEFAULT);
426         if (mSfx2Library)
427         {
428             OUString functionName (RTL_CONSTASCII_USTRINGPARAM ("CreateWindow"));
429             mSfx2CreateWidget = (WindowCreator) osl_getFunctionSymbol (mSfx2Library, functionName.pData);
430         }
431     }
432 
433 	if (mSfx2CreateWidget)
434 		return mSfx2CreateWidget (component, name, parent, attributes);
435 
436     return 0;
437 }
438 
439 Window* WidgetFactory::layoutCreateWindow (VCLXWindow** component, Window *parent, OUString const& name, long& attributes)
440 {
441     Window* window = 0;
442 
443     if (0)
444     {
445         ;
446     }
447     if ( name.equalsAscii( "dialog" ) )
448     {
449         if ( parent == NULL )
450             parent = DIALOG_NO_PARENT;
451         window = new Dialog( parent, ImplGetWinBits( attributes, 0 ) );
452         *component = new layoutimpl::VCLXDialog();
453 
454         attributes ^= awt::WindowAttribute::SHOW;
455     }
456     else if ( name.equalsAscii( "modaldialog" ) )
457     {
458         if ( parent == NULL )
459             parent = DIALOG_NO_PARENT;
460         window = new ModalDialog( parent, ImplGetWinBits( attributes, 0 ) );
461         *component = new layoutimpl::VCLXDialog();
462 
463         attributes ^= awt::WindowAttribute::SHOW;
464     }
465     else if ( name.equalsAscii( "modelessdialog" ) )
466     {
467         if ( parent == NULL )
468             parent = DIALOG_NO_PARENT;
469         window = new ModelessDialog (parent, ImplGetWinBits (attributes, 0));
470         *component = new layoutimpl::VCLXDialog();
471 
472         attributes ^= awt::WindowAttribute::SHOW;
473     }
474     else if ( name.equalsAscii( "sfxdialog" ) )
475     {
476         if ( parent == NULL )
477             parent = DIALOG_NO_PARENT;
478         window = new ClosingDialog (parent, ImplGetWinBits (attributes, 0));
479         *component = new layoutimpl::VCLXDialog();
480 
481         attributes ^= awt::WindowAttribute::SHOW;
482     }
483     else if ( name.equalsAscii( "sfxmodaldialog" ) )
484     {
485         if ( parent == NULL )
486             parent = DIALOG_NO_PARENT;
487         window = new ClosingModalDialog( parent,
488                                          ImplGetWinBits( attributes, 0 ) );
489         *component = new layoutimpl::VCLXDialog();
490 
491         attributes ^= awt::WindowAttribute::SHOW;
492     }
493     else if ( name.equalsAscii( "sfxmodelessdialog" ) )
494     {
495         if ( parent == NULL )
496             parent = DIALOG_NO_PARENT;
497         window = new ClosingModelessDialog (parent, ImplGetWinBits (attributes, 0));
498         *component = new layoutimpl::VCLXDialog();
499 
500         attributes ^= awt::WindowAttribute::SHOW;
501     }
502     else if ( name.equalsAscii( "tabcontrol" ) )
503     {
504         window = new TabControl( parent, ImplGetWinBits( attributes, WINDOW_TABCONTROL ) );
505         *component = new layoutimpl::VCLXTabControl();
506     }
507     else if ( name.equalsAscii( "scroller" ) )
508     {
509         // used FixedImage because I just want some empty non-intrusive widget
510         window = new FixedImage( parent, ImplGetWinBits( attributes, 0 ) );
511         *component = new layoutimpl::VCLXScroller();
512     }
513     else if ( name.equalsAscii( "hsplitter" ) || name.equalsAscii( "vsplitter" ) )
514     {
515         window = new FixedImage( parent, ImplGetWinBits( attributes, 0 ) );
516         *component = new layoutimpl::VCLXSplitter( name.equalsAscii( "hsplitter" ) );
517     }
518     else if ( name.equalsAscii( "hfixedline" ) || name.equalsAscii( "vfixedline" ) )
519     {
520         WinBits nStyle = ImplGetWinBits( attributes, 0 );
521         nStyle ^= WB_HORZ;
522         if ( name.equalsAscii( "hfixedline" ) )
523             nStyle |= WB_HORZ;
524         else
525             nStyle |= WB_VERT;
526         window = new FixedLine( parent, nStyle );
527         *component = new layoutimpl::VCLXFixedLine();
528     }
529     else if ( name.equalsAscii( "okbutton" ) )
530     {
531         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
532         *component = new layoutimpl::VCLXOKButton( window );
533         window->SetType (WINDOW_OKBUTTON);
534     }
535     else if ( name.equalsAscii( "cancelbutton" ) )
536     {
537         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
538         *component = new layoutimpl::VCLXCancelButton( window );
539         window->SetType (WINDOW_CANCELBUTTON);
540     }
541     else if ( name.equalsAscii( "yesbutton" ) )
542     {
543         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
544         *component = new layoutimpl::VCLXYesButton( window );
545         window->SetType (WINDOW_OKBUTTON);
546     }
547     else if ( name.equalsAscii( "nobutton" ) )
548     {
549         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
550         window->SetType (WINDOW_CANCELBUTTON);
551         *component = new layoutimpl::VCLXNoButton( window );
552     }
553     else if ( name.equalsAscii( "retrybutton" ) )
554     {
555         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
556         *component = new layoutimpl::VCLXRetryButton( window );
557     }
558     else if ( name.equalsAscii( "ignorebutton" ) )
559     {
560         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
561         *component = new layoutimpl::VCLXIgnoreButton( window );
562     }
563     else if ( name.equalsAscii( "resetbutton" ) )
564     {
565         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
566         *component = new layoutimpl::VCLXResetButton( window );
567     }
568     else if ( name.equalsAscii( "applybutton" ) )
569     {
570         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
571         *component = new layoutimpl::VCLXApplyButton( window );
572     }
573     else if ( name.equalsAscii( "helpbutton" ) )
574     {
575         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
576         *component = new layoutimpl::VCLXHelpButton( window );
577         window->SetType (WINDOW_HELPBUTTON);
578     }
579     else if ( name.equalsAscii( "morebutton" ) )
580     {
581         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
582         *component = new layoutimpl::VCLXMoreButton( window );
583         window->SetType (WINDOW_MOREBUTTON);
584     }
585     else if ( name.equalsAscii( "advancedbutton" ) )
586     {
587         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
588         *component = new layoutimpl::VCLXAdvancedButton( window );
589     }
590     else if ( name.equalsAscii( "plugin" ) )
591     {
592         window = new Control( parent, ImplGetWinBits( attributes, 0 ) );
593 #ifndef __SUNPRO_CC
594         OSL_TRACE( "%s: parent=%p (%s)\n", __FUNCTION__, parent, typeid( *parent ).name() );
595 #endif
596         *component = new layoutimpl::VCLXPlugin( window, ImplGetWinBits( attributes, 0 ) );
597     }
598     else if ( name.equalsAscii( "tabpage" ) )
599     {
600 #if 0
601         if ( !parent )
602             parent = layout::TabPage::global_parent;
603 #else
604         if (layout::TabPage::global_parent)
605             parent = layout::TabPage::global_parent;
606         layout::TabPage::global_parent = 0;
607 #endif
608         //window = new TabPage( parent, ImplGetWinBits( attributes, 0 ) );
609         attributes ^= awt::WindowAttribute::SHOW;
610         WinBits nStyle = ImplGetWinBits( attributes, 0 );
611         nStyle |= WB_HIDE;
612 
613         if (!parent)
614         {
615             window = new Dialog( parent, nStyle );
616             *component = new VCLXDialog();
617         }
618         else
619         {
620             window = new TabPage( parent, nStyle );
621             *component = new VCLXTabPage( window );
622         }
623     }
624     else if ( name.equalsAscii( "string" ) )
625     {
626         // FIXME: move <string>s.text to simple map<string> in root?
627         attributes &= ~awt::WindowAttribute::SHOW;
628         window = new Window( parent, ImplGetWinBits( attributes, 0 ) );
629         *component = new layoutimpl::LocalizedString();
630     }
631 #if 0 // parent paranoia
632     else if ( name.equalsAscii( "listbox" ) )
633     {
634         window = new ListBox (parent, ImplGetWinBits (attributes, 0));
635         *component = new VCLXListBox ();
636     }
637 #endif
638     else if (name.equalsAscii ("svxfontlistbox")
639              || name.equalsAscii ("svxlanguagebox"))
640     {
641         window = new ListBox (parent, ImplGetWinBits (attributes, 0));
642         *component = new VCLXListBox ();
643     }
644     return window;
645 }
646 
647 } // namespace layoutimpl
648 
649 // Avoid polluting the rest of the code with vcl linkage pieces ...
650 
651 #include <vcl/imagerepository.hxx>
652 #include <vcl/bitmapex.hxx>
653 #include <vcl/graph.hxx>
654 
655 namespace layoutimpl
656 {
657 
658 uno::Reference< graphic::XGraphic > loadGraphic( const char *pName )
659 {
660     BitmapEx aBmp;
661 
662     OUString aStr( pName, strlen( pName ), RTL_TEXTENCODING_ASCII_US );
663     if ( aStr.compareToAscii( ".uno:" ) == 0 )
664         aStr = aStr.copy( 5 ).toAsciiLowerCase();
665 
666     if ( !vcl::ImageRepository::loadImage( OUString::createFromAscii( pName ), aBmp, true ) )
667         return uno::Reference< graphic::XGraphic >();
668 
669     return Graphic( aBmp ).GetXGraphic();
670 }
671 
672 } // namespace layoutimpl
673