1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <osl/mutex.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/component.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XTerminateListener.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <vcl/svapp.hxx>
#include <rtl/instance.hxx>
#include <comphelper/processfactory.hxx>
#include "xmlfiltersettingsdialog.hxx"
using namespace ::cppu;
using namespace ::osl;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::registry;
using namespace ::com::sun::star::frame;
namespace {
class XMLFilterDialogComponentBase
{
protected:
::osl::Mutex maMutex;
};
class XMLFilterDialogComponent : public XMLFilterDialogComponentBase,
public OComponentHelper,
public css::ui::dialogs::XExecutableDialog,
public XServiceInfo,
public XInitialization,
public XTerminateListener
{
public:
explicit XMLFilterDialogComponent( const Reference< XComponentContext >& rxContext );
protected:
// XInterface
virtual Any SAL_CALL queryInterface( const Type& aType ) override;
virtual Any SAL_CALL queryAggregation( Type const & rType ) override;
virtual void SAL_CALL acquire() throw () override;
virtual void SAL_CALL release() throw () override;
// XTypeProvider
virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
virtual Sequence< Type > SAL_CALL getTypes() override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() override;
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
// XExecutableDialog
virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
virtual sal_Int16 SAL_CALL execute( ) override;
// XInitialization
virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) override;
// XTerminateListener
virtual void SAL_CALL queryTermination( const EventObject& Event ) override;
virtual void SAL_CALL notifyTermination( const EventObject& Event ) override;
virtual void SAL_CALL disposing( const EventObject& Source ) override;
/** Called in dispose method after the listeners were notified.
*/
virtual void SAL_CALL disposing() override;
private:
css::uno::Reference<css::awt::XWindow> mxParent; /// parent window
css::uno::Reference< XComponentContext > mxContext;
std::shared_ptr<XMLFilterSettingsDialog> mxDialog;
};
}
XMLFilterDialogComponent::XMLFilterDialogComponent(const css::uno::Reference< XComponentContext >& rxContext)
: OComponentHelper(maMutex)
, mxContext(rxContext)
{
Reference< XDesktop2 > xDesktop = Desktop::create( rxContext );
Reference< XTerminateListener > xListener( this );
xDesktop->addTerminateListener( xListener );
}
// XInterface
Any SAL_CALL XMLFilterDialogComponent::queryInterface( const Type& aType )
{
return OComponentHelper::queryInterface( aType );
}
Any SAL_CALL XMLFilterDialogComponent::queryAggregation( Type const & rType )
{
if (rType == cppu::UnoType<css::ui::dialogs::XExecutableDialog>::get())
{
void * p = static_cast< css::ui::dialogs::XExecutableDialog * >( this );
return Any( &p, rType );
}
else if (rType == cppu::UnoType<XServiceInfo>::get())
{
void * p = static_cast< XServiceInfo * >( this );
return Any( &p, rType );
}
else if (rType == cppu::UnoType<XInitialization>::get())
{
void * p = static_cast< XInitialization * >( this );
return Any( &p, rType );
}
else if (rType == cppu::UnoType<XTerminateListener>::get())
{
void * p = static_cast< XTerminateListener * >( this );
return Any( &p, rType );
}
return OComponentHelper::queryAggregation( rType );
}
void SAL_CALL XMLFilterDialogComponent::acquire() throw ()
{
OComponentHelper::acquire();
}
void SAL_CALL XMLFilterDialogComponent::release() throw ()
{
OComponentHelper::release();
}
/// @throws RuntimeException
static OUString XMLFilterDialogComponent_getImplementationName()
{
return "com.sun.star.comp.ui.XSLTFilterDialog";
}
/// @throws RuntimeException
static Sequence< OUString > XMLFilterDialogComponent_getSupportedServiceNames()
{
Sequence< OUString > aSupported { "com.sun.star.ui.dialogs.XSLTFilterDialog" };
return aSupported;
}
/// @throws Exception
static Reference< XInterface > XMLFilterDialogComponent_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
{
return static_cast<OWeakObject*>(new XMLFilterDialogComponent( comphelper::getComponentContext(rSMgr) ));
}
OUString SAL_CALL XMLFilterDialogComponent::getImplementationName()
{
return XMLFilterDialogComponent_getImplementationName();
}
namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; }
Sequence< sal_Int8 > SAL_CALL XMLFilterDialogComponent::getImplementationId()
{
return css::uno::Sequence<sal_Int8>();
}
namespace
{
class DialogComponentTypes
{
private:
OTypeCollection m_aTypes;
public:
DialogComponentTypes() :
m_aTypes(
cppu::UnoType<XComponent>::get(),
cppu::UnoType<XTypeProvider>::get(),
cppu::UnoType<XAggregation>::get(),
cppu::UnoType<XWeak>::get(),
cppu::UnoType<XServiceInfo>::get(),
cppu::UnoType<XInitialization>::get(),
cppu::UnoType<XTerminateListener>::get(),
cppu::UnoType<css::ui::dialogs::XExecutableDialog>::get())
{
}
OTypeCollection& getTypeCollection() { return m_aTypes; }
};
struct theDialogComponentTypes : rtl::Static<DialogComponentTypes, theDialogComponentTypes> {};
}
Sequence< Type > XMLFilterDialogComponent::getTypes()
{
return theDialogComponentTypes::get().getTypeCollection().getTypes();
}
Sequence< OUString > SAL_CALL XMLFilterDialogComponent::getSupportedServiceNames()
{
return XMLFilterDialogComponent_getSupportedServiceNames();
}
sal_Bool SAL_CALL XMLFilterDialogComponent::supportsService(const OUString& ServiceName)
{
return cppu::supportsService( this, ServiceName );
}
/** Called in dispose method after the listeners were notified.
*/
void SAL_CALL XMLFilterDialogComponent::disposing()
{
::SolarMutexGuard aGuard;
if (mxDialog)
mxDialog->response(RET_CLOSE);
}
// XTerminateListener
void SAL_CALL XMLFilterDialogComponent::queryTermination( const EventObject& /* Event */ )
{
::SolarMutexGuard aGuard;
if (!mxDialog)
return;
mxDialog->present();
}
void SAL_CALL XMLFilterDialogComponent::notifyTermination( const EventObject& /* Event */ )
{
{
::SolarMutexGuard aGuard;
if (mxDialog)
mxDialog->response(RET_CLOSE);
}
// we are going down, so dispose us!
dispose();
}
void SAL_CALL XMLFilterDialogComponent::disposing( const EventObject& /* Source */ )
{
}
void SAL_CALL XMLFilterDialogComponent::setTitle( const OUString& /* _rTitle */ )
{
}
sal_Int16 SAL_CALL XMLFilterDialogComponent::execute()
{
::SolarMutexGuard aGuard;
bool bLaunch = false;
if (!mxDialog)
{
Reference< XComponent > xKeepAlive( this );
mxDialog = std::make_shared<XMLFilterSettingsDialog>(Application::GetFrameWeld(mxParent), mxContext);
bLaunch = true;
}
mxDialog->UpdateWindow();
if (!bLaunch)
{
mxDialog->present();
return 0;
}
weld::DialogController::runAsync(mxDialog, [this](sal_Int32)
{
mxDialog.reset();
});
return 0;
}
void SAL_CALL XMLFilterDialogComponent::initialize( const Sequence< Any >& aArguments )
{
for(const Any& rArgument : aArguments)
{
PropertyValue aProperty;
if(rArgument >>= aProperty)
{
if( aProperty.Name == "ParentWindow" )
{
aProperty.Value >>= mxParent;
}
}
}
}
extern "C"
{
SAL_DLLPUBLIC_EXPORT void * xsltdlg_component_getFactory(<--- The function 'xsltdlg_component_getFactory' is never used.
const char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
{
void * pRet = nullptr;
if( pServiceManager )
{
Reference< XSingleServiceFactory > xFactory;
OUString implName = OUString::createFromAscii( pImplName );
if ( implName == XMLFilterDialogComponent_getImplementationName() )
{
xFactory = createOneInstanceFactory(
static_cast< XMultiServiceFactory * >( pServiceManager ),
OUString::createFromAscii( pImplName ),
XMLFilterDialogComponent_createInstance, XMLFilterDialogComponent_getSupportedServiceNames() );
}
if (xFactory.is())
{
xFactory->acquire();
pRet = xFactory.get();
}
}
return pRet;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|