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