1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <comphelper/servicehelper.hxx>
21 #include <cppuhelper/factory.hxx>
22 #include <comphelper/compbase.hxx>
23 #include <com/sun/star/frame/Desktop.hpp>
24 #include <com/sun/star/frame/XTerminateListener.hpp>
25 #include <cppuhelper/supportsservice.hxx>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/awt/XWindow.hpp>
29 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <vcl/svapp.hxx>
33 #include "xmlfiltersettingsdialog.hxx"
35 using namespace ::cppu
;
36 using namespace ::osl
;
37 using namespace ::com::sun::star::uno
;
38 using namespace ::com::sun::star::lang
;
39 using namespace ::com::sun::star::beans
;
40 using namespace ::com::sun::star::registry
;
41 using namespace ::com::sun::star::frame
;
46 class XMLFilterDialogComponent
: public comphelper::WeakComponentImplHelper
<
47 css::ui::dialogs::XExecutableDialog
,
53 explicit XMLFilterDialogComponent( const Reference
< XComponentContext
>& rxContext
);
57 virtual Sequence
< sal_Int8
> SAL_CALL
getImplementationId() override
;
60 virtual OUString SAL_CALL
getImplementationName() override
;
61 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
62 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
65 virtual void SAL_CALL
setTitle( const OUString
& aTitle
) override
;
66 virtual sal_Int16 SAL_CALL
execute( ) override
;
69 virtual void SAL_CALL
initialize( const Sequence
< Any
>& aArguments
) override
;
72 virtual void SAL_CALL
queryTermination( const EventObject
& Event
) override
;
73 virtual void SAL_CALL
notifyTermination( const EventObject
& Event
) override
;
74 virtual void SAL_CALL
disposing( const EventObject
& Source
) override
;
76 /** Called in dispose method after the listeners were notified.
78 virtual void disposing(std::unique_lock
<std::mutex
>& rGuard
) override
;
81 css::uno::Reference
<css::awt::XWindow
> mxParent
; /// parent window
82 css::uno::Reference
< XComponentContext
> mxContext
;
84 std::shared_ptr
<XMLFilterSettingsDialog
> mxDialog
;
89 XMLFilterDialogComponent::XMLFilterDialogComponent(const css::uno::Reference
< XComponentContext
>& rxContext
)
90 : mxContext(rxContext
)
92 Reference
< XDesktop2
> xDesktop
= Desktop::create( rxContext
);
93 Reference
< XTerminateListener
> xListener( this );
94 xDesktop
->addTerminateListener( xListener
);
97 OUString SAL_CALL
XMLFilterDialogComponent::getImplementationName()
99 return "com.sun.star.comp.ui.XSLTFilterDialog";
102 Sequence
< sal_Int8
> SAL_CALL
XMLFilterDialogComponent::getImplementationId()
104 static const comphelper::UnoIdInit implId
;
105 return implId
.getSeq();
109 Sequence
< OUString
> SAL_CALL
XMLFilterDialogComponent::getSupportedServiceNames()
111 return { "com.sun.star.ui.dialogs.XSLTFilterDialog" };
114 sal_Bool SAL_CALL
XMLFilterDialogComponent::supportsService(const OUString
& ServiceName
)
116 return cppu::supportsService( this, ServiceName
);
119 /** Called in dispose method after the listeners were notified.
121 void XMLFilterDialogComponent::disposing(std::unique_lock
<std::mutex
>& rGuard
)
125 ::SolarMutexGuard aGuard
;
128 mxDialog
->response(RET_CLOSE
);
134 // XTerminateListener
135 void SAL_CALL
XMLFilterDialogComponent::queryTermination( const EventObject
& /* Event */ )
137 ::SolarMutexGuard aGuard
;
143 void SAL_CALL
XMLFilterDialogComponent::notifyTermination( const EventObject
& /* Event */ )
146 ::SolarMutexGuard aGuard
;
148 mxDialog
->response(RET_CLOSE
);
151 // we are going down, so dispose us!
155 void SAL_CALL
XMLFilterDialogComponent::disposing( const EventObject
& /* Source */ )
159 void SAL_CALL
XMLFilterDialogComponent::setTitle( const OUString
& /* _rTitle */ )
163 sal_Int16 SAL_CALL
XMLFilterDialogComponent::execute()
165 ::SolarMutexGuard aGuard
;
167 bool bLaunch
= false;
170 Reference
< XComponent
> xKeepAlive( this );
171 mxDialog
= std::make_shared
<XMLFilterSettingsDialog
>(Application::GetFrameWeld(mxParent
), mxContext
);
175 mxDialog
->UpdateWindow();
183 weld::DialogController::runAsync(mxDialog
, [this](sal_Int32
)
191 void SAL_CALL
XMLFilterDialogComponent::initialize( const Sequence
< Any
>& aArguments
)
193 for(const Any
& rArgument
: aArguments
)
195 PropertyValue aProperty
;
196 if(rArgument
>>= aProperty
)
198 if( aProperty
.Name
== "ParentWindow" )
200 aProperty
.Value
>>= mxParent
;
207 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
208 filter_XSLTFilterDialog_get_implementation(
209 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
211 return cppu::acquire(new XMLFilterDialogComponent(context
));
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */