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 
20 #ifndef INCLUDED_UNOCONTROLS_SOURCE_INC_FRAMECONTROL_HXX
21 #define INCLUDED_UNOCONTROLS_SOURCE_INC_FRAMECONTROL_HXX
22 
23 #include <com/sun/star/lang/XConnectionPointContainer.hpp>
24 #include <cppuhelper/propshlp.hxx>
25 #include <rtl/ref.hxx>
26 
27 #include <basecontrol.hxx>
28 
29 namespace com::sun::star::beans { struct PropertyValue; }
30 namespace com::sun::star::frame { class XFrame2; }
31 namespace unocontrols { class OConnectionPointContainerHelper; }
32 
33 namespace unocontrols {
34 
35 class FrameControl  : public css::awt::XControlModel
36                     , public css::lang::XConnectionPointContainer
37                     , public BaseControl                                // This order is necessary for right initialization of m_aMutex!
38                     , public ::cppu::OBroadcastHelper
39                     , public ::cppu::OPropertySetHelper
40 {
41 public:
42 
43     FrameControl( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
44 
45     virtual ~FrameControl() override;
46 
47     //  XInterface
48 
49     virtual css::uno::Any SAL_CALL queryInterface(
50         const css::uno::Type& aType
51     ) override;
52 
53     /**
54         @short      increment refcount
55         @seealso    XInterface
56         @seealso    release()
57         @onerror    A RuntimeException is thrown.
58     */
59 
60     virtual void SAL_CALL acquire() throw() override;
61 
62     /**
63         @short      decrement refcount
64         @seealso    XInterface
65         @seealso    acquire()
66         @onerror    A RuntimeException is thrown.
67     */
68 
69     virtual void SAL_CALL release() throw() override;
70 
71     //  XTypeProvider
72 
73     virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
74 
75     //  XAggregation
76 
77     css::uno::Any SAL_CALL queryAggregation(
78         const css::uno::Type& aType
79     ) override;
80 
81     OUString SAL_CALL getImplementationName() override;
82 
83     css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
84 
85     //  XControl
86 
87     virtual void SAL_CALL createPeer(
88         const css::uno::Reference< css::awt::XToolkit >&      xToolkit ,
89         const css::uno::Reference< css::awt::XWindowPeer >&   xParent
90     ) override;
91 
92     virtual sal_Bool SAL_CALL setModel(
93         const css::uno::Reference< css::awt::XControlModel >& xModel
94     ) override;
95 
96     virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override;
97 
98     //  XComponent
99 
100     virtual void SAL_CALL dispose() override;
101 
102     //  XView
103 
104     virtual sal_Bool SAL_CALL setGraphics(
105         const css::uno::Reference< css::awt::XGraphics >& xDevice
106     ) override;
107 
108     virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() override;
109 
110     //  XConnectionPointContainer
111 
112     virtual css::uno::Sequence< css::uno::Type > SAL_CALL getConnectionPointTypes() override;
113 
114     virtual css::uno::Reference< css::lang::XConnectionPoint > SAL_CALL queryConnectionPoint(
115         const css::uno::Type& aType
116     ) override;
117 
118     virtual void SAL_CALL advise(
119         const css::uno::Type&                                aType       ,
120         const css::uno::Reference< css::uno::XInterface >&    xListener
121     ) override;
122 
123     virtual void SAL_CALL unadvise(
124         const css::uno::Type&                                aType ,
125         const css::uno::Reference< css::uno::XInterface >&    xListener
126     ) override;
127 
128     //  impl but public methods to register service!
129 
130     static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
131 
132     static OUString impl_getStaticImplementationName();
133 
134 protected:
135     using OPropertySetHelper::getFastPropertyValue;
136 
137     //  OPropertySetHelper
138 
139     virtual sal_Bool SAL_CALL convertFastPropertyValue(
140         css::uno::Any&       rConvertedValue   ,
141         css::uno::Any&       rOldValue         ,
142         sal_Int32           nHandle           ,
143         const css::uno::Any& rValue
144     ) override;
145 
146     virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
147         sal_Int32 nHandle ,
148         const css::uno::Any& rValue
149     ) override;
150 
151     virtual void SAL_CALL getFastPropertyValue( css::uno::Any&   rValue  ,
152                                                 sal_Int32       nHandle ) const override;
153 
154     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
155 
156     //  XPropertySet
157 
158     css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
159 
160     //  BaseControl
161 
162     virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
163         const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer
164     ) override;
165 
166 private:
167 
168     void impl_createFrame(  const css::uno::Reference< css::awt::XWindowPeer >&       xPeer           ,
169                             const OUString&                                         sURL            ,
170                             const css::uno::Sequence< css::beans::PropertyValue >&    seqArguments    );
171 
172     void impl_deleteFrame();
173 
174     css::uno::Reference< css::frame::XFrame2 >              m_xFrame;
175     OUString                                                m_sComponentURL;
176     css::uno::Sequence< css::beans::PropertyValue >         m_seqLoaderArguments;
177     rtl::Reference<OConnectionPointContainerHelper>         m_aConnectionPointContainer;
178 
179 };
180 
181 }
182 
183 #endif // INCLUDED_UNOCONTROLS_SOURCE_INC_FRAMECONTROL_HXX
184 
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
186