fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / core / recovery / subcomponentloader.cxx
blob77869a6934c0d16727e0836ea71cbd39c7806774
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 "subcomponentloader.hxx"
22 #include <com/sun/star/ucb/Command.hpp>
23 #include <com/sun/star/frame/XController2.hpp>
25 #include <tools/diagnose_ex.h>
27 namespace dbaccess
30 using ::com::sun::star::uno::Reference;
31 using ::com::sun::star::uno::XInterface;
32 using ::com::sun::star::uno::UNO_QUERY;
33 using ::com::sun::star::uno::UNO_QUERY_THROW;
34 using ::com::sun::star::uno::UNO_SET_THROW;
35 using ::com::sun::star::uno::Exception;
36 using ::com::sun::star::uno::RuntimeException;
37 using ::com::sun::star::uno::Any;
38 using ::com::sun::star::uno::makeAny;
39 using ::com::sun::star::uno::Sequence;
40 using ::com::sun::star::uno::Type;
41 using ::com::sun::star::frame::XController;
42 using ::com::sun::star::frame::XFrame;
43 using ::com::sun::star::awt::XWindow;
44 using ::com::sun::star::awt::WindowEvent;
45 using ::com::sun::star::lang::EventObject;
46 using ::com::sun::star::ucb::Command;
47 using ::com::sun::star::ucb::XCommandProcessor;
48 using ::com::sun::star::frame::XController2;
49 using ::com::sun::star::lang::XComponent;
51 // SubComponentLoader
52 struct DBACCESS_DLLPRIVATE SubComponentLoader_Data
54 const Reference< XCommandProcessor > xDocDefCommands;
55 const Reference< XComponent > xNonDocComponent;
56 Reference< XWindow > xAppComponentWindow;
58 SubComponentLoader_Data( const Reference< XCommandProcessor >& i_rDocumentDefinition )
59 :xDocDefCommands( i_rDocumentDefinition )
60 ,xNonDocComponent()
64 SubComponentLoader_Data( const Reference< XComponent >& i_rNonDocumentComponent )
65 :xDocDefCommands()
66 ,xNonDocComponent( i_rNonDocumentComponent )
71 // helper
72 namespace
74 void lcl_onWindowShown_nothrow( const SubComponentLoader_Data& i_rData )
76 try
78 if ( i_rData.xDocDefCommands.is() )
80 Command aCommandOpen;
81 aCommandOpen.Name = "show";
83 const sal_Int32 nCommandIdentifier = i_rData.xDocDefCommands->createCommandIdentifier();
84 i_rData.xDocDefCommands->execute( aCommandOpen, nCommandIdentifier, NULL );
86 else
88 const Reference< XController > xController( i_rData.xNonDocComponent, UNO_QUERY_THROW );
89 const Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
90 const Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
91 xWindow->setVisible( sal_True );
94 catch( const Exception& )
96 DBG_UNHANDLED_EXCEPTION();
101 // SubComponentLoader
102 SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
103 const Reference< XCommandProcessor >& i_rSubDocumentDefinition )
104 :m_pData( new SubComponentLoader_Data( i_rSubDocumentDefinition ) )
106 // add as window listener to the controller's container window, so we get notified when it is shown
107 Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
108 m_pData->xAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
110 osl_atomic_increment( &m_refCount );
112 m_pData->xAppComponentWindow->addWindowListener( this );
114 osl_atomic_decrement( &m_refCount );
117 SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
118 const Reference< XComponent >& i_rNonDocumentComponent )
119 :m_pData( new SubComponentLoader_Data( i_rNonDocumentComponent ) )
121 // add as window listener to the controller's container window, so we get notified when it is shown
122 Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
123 m_pData->xAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
125 osl_atomic_increment( &m_refCount );
127 m_pData->xAppComponentWindow->addWindowListener( this );
129 osl_atomic_decrement( &m_refCount );
132 SubComponentLoader::~SubComponentLoader()
134 delete m_pData, m_pData = NULL;
137 void SAL_CALL SubComponentLoader::windowResized( const WindowEvent& i_rEvent ) throw (RuntimeException, std::exception)
139 // not interested in
140 (void)i_rEvent;
143 void SAL_CALL SubComponentLoader::windowMoved( const WindowEvent& i_rEvent ) throw (RuntimeException, std::exception)
145 // not interested in
146 (void)i_rEvent;
149 void SAL_CALL SubComponentLoader::windowShown( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
151 (void)i_rEvent;
153 lcl_onWindowShown_nothrow( *m_pData );
154 m_pData->xAppComponentWindow->removeWindowListener( this );
157 void SAL_CALL SubComponentLoader::windowHidden( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
159 // not interested in
160 (void)i_rEvent;
163 void SAL_CALL SubComponentLoader::disposing( const EventObject& i_rEvent ) throw (RuntimeException, std::exception)
165 // not interested in
166 (void)i_rEvent;
169 } // namespace dbaccess
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */