xref: /trunk/main/toolkit/source/layout/core/helper.cxx (revision b0724fc6)
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     throw (lang::IllegalArgumentException)
281 {
282     OSL_ASSERT( nHandle >= 0 && nHandle < (sal_Int32) maDetails.size() );
283 
284     // FIXME: no Any::getValue ...
285     getFastPropertyValue( rOldValue, nHandle );
286     if ( rOldValue != rValue )
287     {
288         rConvertedValue = rValue;
289         return sal_True; // changed
290     }
291     else
292     {
293         rConvertedValue.clear();
294         rOldValue.clear();
295     }
296     return sal_False;
297 }
298 
299 
300 void SAL_CALL
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const uno::Any & rValue)301 PropHelper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
302                                               const uno::Any& rValue )
303     throw (uno::Exception)
304 {
305     OSL_ASSERT( nHandle >= 0 && nHandle < (sal_Int32) maDetails.size() );
306 
307     const PropDetails &rInfo = maDetails[ nHandle ];
308 
309     uno_type_assignData( rInfo.pValue, rInfo.aType.getTypeLibType(),
310                          rValue.pData, rValue.pType,
311                          0, 0, 0 );
312 
313     if ( mpListener )
314         mpListener->propertiesChanged();
315 }
316 
317 void SAL_CALL
getFastPropertyValue(uno::Any & rValue,sal_Int32 nHandle) const318 PropHelper::getFastPropertyValue( uno::Any& rValue,
319                                   sal_Int32 nHandle ) const
320 {
321     OSL_ASSERT( nHandle >= 0 && nHandle < (sal_Int32) maDetails.size() );
322     const PropDetails &rInfo = maDetails[ nHandle ];
323 #if 0
324     switch ( rInfo.aType.getTypeClass() )
325     {
326 #define MAP(classtype,ctype)                        \
327         case uno::TypeClass_##classtype:       \
328             rValue <<= *(ctype *)(rInfo.pValue);    \
329         break
330         MAP( DOUBLE, double );
331         MAP( SHORT, sal_Int16 );
332         MAP( LONG,  sal_Int32 );
333         MAP( UNSIGNED_SHORT, sal_uInt16 );
334         MAP( UNSIGNED_LONG, sal_uInt32 );
335         MAP( STRING, ::rtl::OUString );
336         default:
337             DBG_ERROR( "ERROR: unknown type to map!" );
338             break;
339     }
340 #undef MAP
341 #endif
342     rValue.setValue( rInfo.pValue, rInfo.aType );
343 }
344 
345 ::com::sun::star::uno::Any
queryInterface(const::com::sun::star::uno::Type & rType)346 PropHelper::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
347 {
348     return OPropertySetHelper::queryInterface( rType );
349 }
350 
getPropertySetInfo()351 uno::Reference <beans::XPropertySetInfo> SAL_CALL PropHelper::getPropertySetInfo () throw (uno::RuntimeException)
352 {
353     return css::uno::Reference <css::beans::XPropertySetInfo> (createPropertySetInfo (getInfoHelper ()));
354 }
355 
356 } // namespace layoutimpl
357 
358 #include <awt/vclxbutton.hxx>
359 #include <awt/vclxdialog.hxx>
360 #include <awt/vclxfixedline.hxx>
361 #include <awt/vclxplugin.hxx>
362 #include <awt/vclxscroller.hxx>
363 #include <awt/vclxsplitter.hxx>
364 #include <awt/vclxtabcontrol.hxx>
365 #include <awt/vclxtabpage.hxx>
366 #include <toolkit/awt/vclxtoolkit.hxx>
367 #include <toolkit/awt/vclxwindow.hxx>
368 #include <vcl/button.hxx>
369 #include <vcl/dialog.hxx>
370 #include <vcl/fixed.hxx>
371 #include <vcl/tabctrl.hxx>
372 #include <vcl/tabpage.hxx>
373 #include <vcl/unohelp.hxx>
374 
375 #include <layout/layout.hxx>
376 #include <toolkit/awt/vclxwindows.hxx>
377 #include <vcl/lstbox.hxx>
378 #include <vcl.hxx>
379 
380 #include <typeinfo>
381 
382 namespace layoutimpl
383 {
384 
implCreateWidget(uno::Reference<uno::XInterface> xParent,OUString name,long attributes)385 uno::Reference <awt::XLayoutConstrains> WidgetFactory::implCreateWidget (uno::Reference <uno::XInterface> xParent, OUString name, long attributes)
386 {
387     Window* parent = 0;
388 
389     if (VCLXWindow* parentComponent = VCLXWindow::GetImplementation (xParent))
390         parent = parentComponent->GetWindow ();
391 
392     VCLXWindow* component = 0;
393     Window* window = 0; //sfx2CreateWindow (&component, parent, name, attributes);
394     if (!window)
395         window = layoutCreateWindow (&component, parent, name, attributes);
396 
397     uno::Reference <awt::XLayoutConstrains> reference;
398     if (window)
399     {
400         window->SetCreatedWithToolkit( sal_True );
401         if ( component )
402             component->SetCreatedWithToolkit( true );
403         reference = component;
404         window->SetComponentInterface( component );
405         if ( attributes & awt::WindowAttribute::SHOW )
406             window->Show();
407     }
408 
409     return reference;
410 }
411 
thisModule()412 extern "C" { static void SAL_CALL thisModule() {} }
413 
sfx2CreateWindow(VCLXWindow ** component,Window * parent,OUString const & name,long & attributes)414 Window* WidgetFactory::sfx2CreateWindow (VCLXWindow** component, Window* parent, OUString const& name, long& attributes)
415 {
416     OSL_TRACE("Asking sfx2: %s", OUSTRING_CSTR (name));
417 
418 	if (!mSfx2Library)
419 	{
420 		OUString libraryName = ::vcl::unohelper::CreateLibraryName ("sfx", sal_True);
421         mSfx2Library = osl_loadModuleRelative (&thisModule, libraryName.pData, SAL_LOADMODULE_DEFAULT);
422         if (mSfx2Library)
423         {
424             OUString functionName (RTL_CONSTASCII_USTRINGPARAM ("CreateWindow"));
425             mSfx2CreateWidget = (WindowCreator) osl_getFunctionSymbol (mSfx2Library, functionName.pData);
426         }
427     }
428 
429 	if (mSfx2CreateWidget)
430 		return mSfx2CreateWidget (component, name, parent, attributes);
431 
432     return 0;
433 }
434 
layoutCreateWindow(VCLXWindow ** component,Window * parent,OUString const & name,long & attributes)435 Window* WidgetFactory::layoutCreateWindow (VCLXWindow** component, Window *parent, OUString const& name, long& attributes)
436 {
437     Window* window = 0;
438 
439     if (0)
440     {
441         ;
442     }
443     if ( name.equalsAscii( "dialog" ) )
444     {
445         if ( parent == NULL )
446             parent = DIALOG_NO_PARENT;
447         window = new Dialog( parent, ImplGetWinBits( attributes, 0 ) );
448         *component = new layoutimpl::VCLXDialog();
449 
450         attributes ^= awt::WindowAttribute::SHOW;
451     }
452     else if ( name.equalsAscii( "modaldialog" ) )
453     {
454         if ( parent == NULL )
455             parent = DIALOG_NO_PARENT;
456         window = new ModalDialog( parent, ImplGetWinBits( attributes, 0 ) );
457         *component = new layoutimpl::VCLXDialog();
458 
459         attributes ^= awt::WindowAttribute::SHOW;
460     }
461     else if ( name.equalsAscii( "modelessdialog" ) )
462     {
463         if ( parent == NULL )
464             parent = DIALOG_NO_PARENT;
465         window = new ModelessDialog (parent, ImplGetWinBits (attributes, 0));
466         *component = new layoutimpl::VCLXDialog();
467 
468         attributes ^= awt::WindowAttribute::SHOW;
469     }
470     else if ( name.equalsAscii( "sfxdialog" ) )
471     {
472         if ( parent == NULL )
473             parent = DIALOG_NO_PARENT;
474         window = new ClosingDialog (parent, ImplGetWinBits (attributes, 0));
475         *component = new layoutimpl::VCLXDialog();
476 
477         attributes ^= awt::WindowAttribute::SHOW;
478     }
479     else if ( name.equalsAscii( "sfxmodaldialog" ) )
480     {
481         if ( parent == NULL )
482             parent = DIALOG_NO_PARENT;
483         window = new ClosingModalDialog( parent,
484                                          ImplGetWinBits( attributes, 0 ) );
485         *component = new layoutimpl::VCLXDialog();
486 
487         attributes ^= awt::WindowAttribute::SHOW;
488     }
489     else if ( name.equalsAscii( "sfxmodelessdialog" ) )
490     {
491         if ( parent == NULL )
492             parent = DIALOG_NO_PARENT;
493         window = new ClosingModelessDialog (parent, ImplGetWinBits (attributes, 0));
494         *component = new layoutimpl::VCLXDialog();
495 
496         attributes ^= awt::WindowAttribute::SHOW;
497     }
498     else if ( name.equalsAscii( "tabcontrol" ) )
499     {
500         window = new TabControl( parent, ImplGetWinBits( attributes, WINDOW_TABCONTROL ) );
501         *component = new layoutimpl::VCLXTabControl();
502     }
503     else if ( name.equalsAscii( "scroller" ) )
504     {
505         // used FixedImage because I just want some empty non-intrusive widget
506         window = new FixedImage( parent, ImplGetWinBits( attributes, 0 ) );
507         *component = new layoutimpl::VCLXScroller();
508     }
509     else if ( name.equalsAscii( "hsplitter" ) || name.equalsAscii( "vsplitter" ) )
510     {
511         window = new FixedImage( parent, ImplGetWinBits( attributes, 0 ) );
512         *component = new layoutimpl::VCLXSplitter( name.equalsAscii( "hsplitter" ) );
513     }
514     else if ( name.equalsAscii( "hfixedline" ) || name.equalsAscii( "vfixedline" ) )
515     {
516         WinBits nStyle = ImplGetWinBits( attributes, 0 );
517         nStyle ^= WB_HORZ;
518         if ( name.equalsAscii( "hfixedline" ) )
519             nStyle |= WB_HORZ;
520         else
521             nStyle |= WB_VERT;
522         window = new FixedLine( parent, nStyle );
523         *component = new layoutimpl::VCLXFixedLine();
524     }
525     else if ( name.equalsAscii( "okbutton" ) )
526     {
527         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
528         *component = new layoutimpl::VCLXOKButton( window );
529         window->SetType (WINDOW_OKBUTTON);
530     }
531     else if ( name.equalsAscii( "cancelbutton" ) )
532     {
533         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
534         *component = new layoutimpl::VCLXCancelButton( window );
535         window->SetType (WINDOW_CANCELBUTTON);
536     }
537     else if ( name.equalsAscii( "yesbutton" ) )
538     {
539         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
540         *component = new layoutimpl::VCLXYesButton( window );
541         window->SetType (WINDOW_OKBUTTON);
542     }
543     else if ( name.equalsAscii( "nobutton" ) )
544     {
545         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
546         window->SetType (WINDOW_CANCELBUTTON);
547         *component = new layoutimpl::VCLXNoButton( window );
548     }
549     else if ( name.equalsAscii( "retrybutton" ) )
550     {
551         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
552         *component = new layoutimpl::VCLXRetryButton( window );
553     }
554     else if ( name.equalsAscii( "ignorebutton" ) )
555     {
556         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
557         *component = new layoutimpl::VCLXIgnoreButton( window );
558     }
559     else if ( name.equalsAscii( "resetbutton" ) )
560     {
561         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
562         *component = new layoutimpl::VCLXResetButton( window );
563     }
564     else if ( name.equalsAscii( "applybutton" ) )
565     {
566         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
567         *component = new layoutimpl::VCLXApplyButton( window );
568     }
569     else if ( name.equalsAscii( "helpbutton" ) )
570     {
571         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
572         *component = new layoutimpl::VCLXHelpButton( window );
573         window->SetType (WINDOW_HELPBUTTON);
574     }
575     else if ( name.equalsAscii( "morebutton" ) )
576     {
577         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
578         *component = new layoutimpl::VCLXMoreButton( window );
579         window->SetType (WINDOW_MOREBUTTON);
580     }
581     else if ( name.equalsAscii( "advancedbutton" ) )
582     {
583         window = new PushButton( parent, ImplGetWinBits( attributes, 0 ) );
584         *component = new layoutimpl::VCLXAdvancedButton( window );
585     }
586     else if ( name.equalsAscii( "plugin" ) )
587     {
588         window = new Control( parent, ImplGetWinBits( attributes, 0 ) );
589 #ifndef __SUNPRO_CC
590         OSL_TRACE( "%s: parent=%p (%s)\n", __FUNCTION__, parent, typeid( *parent ).name() );
591 #endif
592         *component = new layoutimpl::VCLXPlugin( window, ImplGetWinBits( attributes, 0 ) );
593     }
594     else if ( name.equalsAscii( "tabpage" ) )
595     {
596 #if 0
597         if ( !parent )
598             parent = layout::TabPage::global_parent;
599 #else
600         if (layout::TabPage::global_parent)
601             parent = layout::TabPage::global_parent;
602         layout::TabPage::global_parent = 0;
603 #endif
604         //window = new TabPage( parent, ImplGetWinBits( attributes, 0 ) );
605         attributes ^= awt::WindowAttribute::SHOW;
606         WinBits nStyle = ImplGetWinBits( attributes, 0 );
607         nStyle |= WB_HIDE;
608 
609         if (!parent)
610         {
611             window = new Dialog( parent, nStyle );
612             *component = new VCLXDialog();
613         }
614         else
615         {
616             window = new TabPage( parent, nStyle );
617             *component = new VCLXTabPage( window );
618         }
619     }
620     else if ( name.equalsAscii( "string" ) )
621     {
622         // FIXME: move <string>s.text to simple map<string> in root?
623         attributes &= ~awt::WindowAttribute::SHOW;
624         window = new Window( parent, ImplGetWinBits( attributes, 0 ) );
625         *component = new layoutimpl::LocalizedString();
626     }
627 #if 0 // parent paranoia
628     else if ( name.equalsAscii( "listbox" ) )
629     {
630         window = new ListBox (parent, ImplGetWinBits (attributes, 0));
631         *component = new VCLXListBox ();
632     }
633 #endif
634     else if (name.equalsAscii ("svxfontlistbox")
635              || name.equalsAscii ("svxlanguagebox"))
636     {
637         window = new ListBox (parent, ImplGetWinBits (attributes, 0));
638         *component = new VCLXListBox ();
639     }
640     return window;
641 }
642 
643 } // namespace layoutimpl
644 
645 // Avoid polluting the rest of the code with vcl linkage pieces ...
646 
647 #include <vcl/imagerepository.hxx>
648 #include <vcl/bitmapex.hxx>
649 #include <vcl/graph.hxx>
650 
651 namespace layoutimpl
652 {
653 
loadGraphic(const char * pName)654 uno::Reference< graphic::XGraphic > loadGraphic( const char *pName )
655 {
656     BitmapEx aBmp;
657 
658     OUString aStr( pName, strlen( pName ), RTL_TEXTENCODING_ASCII_US );
659     if ( aStr.compareToAscii( ".uno:" ) == 0 )
660         aStr = aStr.copy( 5 ).toAsciiLowerCase();
661 
662     if ( !vcl::ImageRepository::loadImage( OUString::createFromAscii( pName ), aBmp, true ) )
663         return uno::Reference< graphic::XGraphic >();
664 
665     return Graphic( aBmp ).GetXGraphic();
666 }
667 
668 } // namespace layoutimpl
669