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 .
21 #include "controlfontdialog.hxx"
22 #include <cppuhelper/typeprovider.hxx>
23 #include "fontdialog.hxx"
24 #include "formstrings.hxx"
25 #include "pcrcommon.hxx"
26 #include "pcrservices.hxx"
28 extern "C" void SAL_CALL
createRegistryInfo_OControlFontDialog()
30 ::pcr::OAutoRegistration
< ::pcr::OControlFontDialog
> aAutoRegistration
;
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::lang
;
40 using namespace ::com::sun::star::beans
;
42 OControlFontDialog::OControlFontDialog(const Reference
< XComponentContext
>& _rxContext
)
43 :OGenericUnoDialog( _rxContext
)
46 ,m_pItemPoolDefaults(NULL
)
48 registerProperty(PROPERTY_INTROSPECTEDOBJECT
, OWN_PROPERTY_ID_INTROSPECTEDOBJECT
,
49 PropertyAttribute::BOUND
| PropertyAttribute::TRANSIENT
,
50 &m_xControlModel
, cppu::UnoType
<decltype(m_xControlModel
)>::get());
54 OControlFontDialog::~OControlFontDialog()
58 ::osl::MutexGuard
aGuard(m_aMutex
);
65 Sequence
<sal_Int8
> SAL_CALL
OControlFontDialog::getImplementationId( ) throw(RuntimeException
, std::exception
)
67 return css::uno::Sequence
<sal_Int8
>();
71 Reference
< XInterface
> SAL_CALL
OControlFontDialog::Create( const Reference
< XComponentContext
>& _rxContext
)
73 return *( new OControlFontDialog( _rxContext
) );
77 OUString SAL_CALL
OControlFontDialog::getImplementationName() throw(RuntimeException
, std::exception
)
79 return getImplementationName_static();
83 OUString
OControlFontDialog::getImplementationName_static() throw(RuntimeException
)
85 return OUString("org.openoffice.comp.form.ui.OControlFontDialog");
89 ::comphelper::StringSequence SAL_CALL
OControlFontDialog::getSupportedServiceNames() throw(RuntimeException
, std::exception
)
91 return getSupportedServiceNames_static();
95 ::comphelper::StringSequence
OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException
)
97 ::comphelper::StringSequence
aSupported(1);
98 aSupported
[0] = "com.sun.star.form.ControlFontDialog";
102 void OControlFontDialog::initialize( const Sequence
< Any
>& aArguments
) throw(Exception
, RuntimeException
, std::exception
)
104 Reference
<XPropertySet
> xGridModel
;
105 if (aArguments
.getLength() == 1 && (aArguments
[0] >>= xGridModel
))
108 aArg
.Name
= "IntrospectedObject";
109 aArg
.Value
<<= xGridModel
;
110 Sequence
< Any
> aNewArguments(1);
111 aNewArguments
[0] <<= aArg
;
112 OControlFontDialog_DBase::initialize(aNewArguments
);
115 OControlFontDialog_DBase::initialize(aArguments
);
119 Reference
<XPropertySetInfo
> SAL_CALL
OControlFontDialog::getPropertySetInfo() throw(RuntimeException
, std::exception
)
121 Reference
<XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
126 ::cppu::IPropertyArrayHelper
& OControlFontDialog::getInfoHelper()
128 return *getArrayHelper();
132 ::cppu::IPropertyArrayHelper
* OControlFontDialog::createArrayHelper( ) const
134 Sequence
< Property
> aProps
;
135 describeProperties(aProps
);
136 return new ::cppu::OPropertyArrayHelper(aProps
);
140 VclPtr
<Dialog
> OControlFontDialog::createDialog(vcl::Window
* _pParent
)
142 ControlCharacterDialog::createItemSet(m_pFontItems
, m_pItemPool
, m_pItemPoolDefaults
);
144 OSL_ENSURE(m_xControlModel
.is(), "OControlFontDialog::createDialog: no introspectee set!");
145 if (m_xControlModel
.is())
146 ControlCharacterDialog::translatePropertiesToItems(m_xControlModel
, m_pFontItems
);
147 // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
148 // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
149 // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
151 return VclPtr
<ControlCharacterDialog
>::Create(_pParent
, *m_pFontItems
);
155 void OControlFontDialog::destroyDialog()
157 OGenericUnoDialog::destroyDialog();
158 ControlCharacterDialog::destroyItemSet(m_pFontItems
, m_pItemPool
, m_pItemPoolDefaults
);
162 void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult
)
164 OSL_ENSURE(m_pDialog
, "OControlFontDialog::executedDialog: no dialog anymore?!!");
165 if (m_pDialog
&& (RET_OK
== _nExecutionResult
) && m_xControlModel
.is())
167 const SfxItemSet
* pOutput
= static_cast<ControlCharacterDialog
*>(m_pDialog
.get())->GetOutputItemSet();
169 ControlCharacterDialog::translateItemsToProperties( *pOutput
, m_xControlModel
);
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */