fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / source / tabwin / tabwinfactory.cxx
blobbcc705b2813d2870cdc29e8ff20fbbdda5796634
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tabwin/tabwinfactory.hxx>
21 #include <tabwin/tabwindow.hxx>
23 #include <com/sun/star/util/XURLTransformer.hpp>
24 #include <com/sun/star/lang/XInitialization.hpp>
25 #include <com/sun/star/awt/Toolkit.hpp>
26 #include <com/sun/star/awt/XTopWindow.hpp>
27 #include <com/sun/star/awt/WindowAttribute.hpp>
29 #include <vcl/svapp.hxx>
30 #include <rtl/ustrbuf.hxx>
32 // Defines
34 using namespace com::sun::star::uno;
35 using namespace com::sun::star::lang;
36 using namespace com::sun::star::beans;
37 using namespace com::sun::star::util;
39 namespace framework
42 // XInterface, XTypeProvider, XServiceInfo
44 DEFINE_XSERVICEINFO_ONEINSTANCESERVICE_2( TabWinFactory ,
45 ::cppu::OWeakObject ,
46 SERVICENAME_TABWINFACTORY ,
47 IMPLEMENTATIONNAME_TABWINFACTORY
50 DEFINE_INIT_SERVICE ( TabWinFactory, {} )
52 TabWinFactory::TabWinFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ) :
53 m_xContext( xContext )
57 TabWinFactory::~TabWinFactory()
61 css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithContext(
62 const css::uno::Reference< css::uno::XComponentContext >& xContext )
63 throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
65 css::uno::Sequence< css::uno::Any > aArgs;
67 return createInstanceWithArgumentsAndContext( aArgs, xContext );
70 css::uno::Reference< css::uno::XInterface > SAL_CALL TabWinFactory::createInstanceWithArgumentsAndContext(
71 const css::uno::Sequence< css::uno::Any >& Arguments, const css::uno::Reference< css::uno::XComponentContext >& )
72 throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
74 const OUString aTopWindowArgName( "TopWindow");
76 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
77 SolarMutexResettableGuard aLock;
78 css::uno::Reference< css::awt::XToolkit2 > xToolkit = m_xToolkit;
79 css::uno::Reference< css::uno::XComponentContext > xContext( m_xContext );
80 aLock.clear();
81 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
83 css::uno::Reference< css::uno::XInterface > xReturn;
84 css::uno::Reference< css::awt::XTopWindow > xTopWindow;
85 css::beans::PropertyValue aPropValue;
87 for ( sal_Int32 i = 0; i < Arguments.getLength(); i++ )
89 if ( Arguments[i] >>= aPropValue )
91 if ( aPropValue.Name == aTopWindowArgName )
92 aPropValue.Value >>= xTopWindow;
96 if ( !xToolkit.is() && xContext.is() )
98 xToolkit = css::awt::Toolkit::create( xContext );
99 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
100 aLock.reset();
101 m_xToolkit = xToolkit;
102 aLock.clear();
103 /* SAFE AREA ----------------------------------------------------------------------------------------------- */
106 if ( !xTopWindow.is() )
108 // describe window properties.
109 css::awt::WindowDescriptor aDescriptor;
110 aDescriptor.Type = css::awt::WindowClass_TOP;
111 aDescriptor.ParentIndex = -1;
112 aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >();
113 aDescriptor.Bounds = css::awt::Rectangle(0,0,0,0);
114 aDescriptor.WindowAttributes = css::awt::WindowAttribute::BORDER|
115 css::awt::WindowAttribute::SIZEABLE|
116 css::awt::WindowAttribute::MOVEABLE|
117 css::awt::WindowAttribute::CLOSEABLE|
118 css::awt::WindowAttribute::MINSIZE;
120 // create a parent window
121 xTopWindow = css::uno::Reference< css::awt::XTopWindow >(
122 xToolkit->createWindow( aDescriptor ), css::uno::UNO_QUERY );
125 if ( xTopWindow.is() )
127 TabWindow* pTabWindow = new TabWindow( xContext );
129 css::uno::Sequence< css::uno::Any > aArgs( 1 );
131 aPropValue.Name = aTopWindowArgName;
132 aPropValue.Value = css::uno::makeAny( xTopWindow );
133 aArgs[0] = css::uno::makeAny( aPropValue );
134 pTabWindow->initialize( aArgs );
136 xReturn = css::uno::Reference< css::uno::XInterface >(
137 static_cast< OWeakObject* >( pTabWindow ), css::uno::UNO_QUERY );
140 return xReturn;
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */