LibreOffice Module dbaccess (master) 1
subcomponentloader.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21
22#include <com/sun/star/ucb/Command.hpp>
23#include <com/sun/star/frame/XController2.hpp>
24
26
27namespace dbaccess
28{
29
30 using ::com::sun::star::uno::Reference;
31 using ::com::sun::star::uno::UNO_QUERY_THROW;
32 using ::com::sun::star::uno::UNO_SET_THROW;
33 using ::com::sun::star::uno::Exception;
34 using ::com::sun::star::frame::XController;
35 using ::com::sun::star::frame::XFrame;
36 using ::com::sun::star::awt::XWindow;
37 using ::com::sun::star::awt::WindowEvent;
38 using ::com::sun::star::lang::EventObject;
39 using ::com::sun::star::ucb::Command;
40 using ::com::sun::star::ucb::XCommandProcessor;
41 using ::com::sun::star::frame::XController2;
42 using ::com::sun::star::lang::XComponent;
43
44 // SubComponentLoader
45 SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
46 const Reference< XCommandProcessor >& i_rSubDocumentDefinition )
47 :mxDocDefCommands( i_rSubDocumentDefinition )
48 {
49 // add as window listener to the controller's container window, so we get notified when it is shown
50 Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
51 mxAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
52
53 osl_atomic_increment( &m_refCount );
54 {
55 mxAppComponentWindow->addWindowListener( this );
56 }
57 osl_atomic_decrement( &m_refCount );
58 }
59
60 SubComponentLoader::SubComponentLoader( const Reference< XController >& i_rApplicationController,
61 const Reference< XComponent >& i_rNonDocumentComponent )
62 :mxNonDocComponent( i_rNonDocumentComponent )
63 {
64 // add as window listener to the controller's container window, so we get notified when it is shown
65 Reference< XController2 > xController( i_rApplicationController, UNO_QUERY_THROW );
66 mxAppComponentWindow.set( xController->getComponentWindow(), UNO_SET_THROW );
67
68 osl_atomic_increment( &m_refCount );
69 {
70 mxAppComponentWindow->addWindowListener( this );
71 }
72 osl_atomic_decrement( &m_refCount );
73 }
74
75 SubComponentLoader::~SubComponentLoader()
76 {
77 }
78
79 void SAL_CALL SubComponentLoader::windowResized( const WindowEvent& )
80 {
81 }
82
83 void SAL_CALL SubComponentLoader::windowMoved( const WindowEvent& )
84 {
85 }
86
87 void SAL_CALL SubComponentLoader::windowShown( const EventObject& )
88 {
89 try
90 {
91 if ( mxDocDefCommands.is() )
92 {
93 Command aCommandOpen;
94 aCommandOpen.Name = "show";
95
96 const sal_Int32 nCommandIdentifier = mxDocDefCommands->createCommandIdentifier();
97 mxDocDefCommands->execute( aCommandOpen, nCommandIdentifier, nullptr );
98 }
99 else
100 {
101 const Reference< XController > xController( mxNonDocComponent, UNO_QUERY_THROW );
102 const Reference< XFrame > xFrame( xController->getFrame(), UNO_SET_THROW );
103 const Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_SET_THROW );
104 xWindow->setVisible( true );
105 }
106 }
107 catch( const Exception& )
108 {
109 DBG_UNHANDLED_EXCEPTION("dbaccess");
110 }
111 mxAppComponentWindow->removeWindowListener( this );
112 }
113
114 void SAL_CALL SubComponentLoader::windowHidden( const EventObject& )
115 {
116 }
117
118 void SAL_CALL SubComponentLoader::disposing( const EventObject& )
119 {
120 }
121
122} // namespace dbaccess
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SubComponentLoader(const css::uno::Reference< css::frame::XController > &i_rApplicationController, const css::uno::Reference< css::ucb::XCommandProcessor > &i_rSubDocumentDefinition)
#define DBG_UNHANDLED_EXCEPTION(...)
@ Exception
Reference< XController > xController
the controller of the sub component. Must not be <NULL>
Reference< XFrame > xFrame
the frame which the component resides in. Must not be <NULL>