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"
27 extern "C" void SAL_CALL
createRegistryInfo_OControlFontDialog()
29 ::pcr::OAutoRegistration
< ::pcr::OControlFontDialog
> aAutoRegistration
;
32 //........................................................................
35 //........................................................................
37 using namespace ::com::sun::star::uno
;
38 using namespace ::com::sun::star::lang
;
39 using namespace ::com::sun::star::beans
;
41 //====================================================================
42 //= OControlFontDialog
43 //====================================================================
44 //---------------------------------------------------------------------
45 OControlFontDialog::OControlFontDialog(const Reference
< XComponentContext
>& _rxContext
)
46 :OGenericUnoDialog( _rxContext
)
49 ,m_pItemPoolDefaults(NULL
)
51 registerProperty(PROPERTY_INTROSPECTEDOBJECT
, OWN_PROPERTY_ID_INTROSPECTEDOBJECT
,
52 PropertyAttribute::BOUND
| PropertyAttribute::TRANSIENT
,
53 &m_xControlModel
, ::getCppuType(&m_xControlModel
));
56 //---------------------------------------------------------------------
57 OControlFontDialog::~OControlFontDialog()
61 ::osl::MutexGuard
aGuard(m_aMutex
);
67 //---------------------------------------------------------------------
68 Sequence
<sal_Int8
> SAL_CALL
OControlFontDialog::getImplementationId( ) throw(RuntimeException
)
70 static ::cppu::OImplementationId aId
;
71 return aId
.getImplementationId();
74 //---------------------------------------------------------------------
75 Reference
< XInterface
> SAL_CALL
OControlFontDialog::Create( const Reference
< XComponentContext
>& _rxContext
)
77 return *( new OControlFontDialog( _rxContext
) );
80 //---------------------------------------------------------------------
81 OUString SAL_CALL
OControlFontDialog::getImplementationName() throw(RuntimeException
)
83 return getImplementationName_static();
86 //---------------------------------------------------------------------
87 OUString
OControlFontDialog::getImplementationName_static() throw(RuntimeException
)
89 return OUString("org.openoffice.comp.form.ui.OControlFontDialog");
92 //---------------------------------------------------------------------
93 ::comphelper::StringSequence SAL_CALL
OControlFontDialog::getSupportedServiceNames() throw(RuntimeException
)
95 return getSupportedServiceNames_static();
98 //---------------------------------------------------------------------
99 ::comphelper::StringSequence
OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException
)
101 ::comphelper::StringSequence
aSupported(1);
102 aSupported
.getArray()[0] = OUString("com.sun.star.form.ControlFontDialog");
106 void OControlFontDialog::initialize( const Sequence
< Any
>& aArguments
) throw(Exception
, RuntimeException
)
108 Reference
<XPropertySet
> xGridModel
;
109 if (aArguments
.getLength() == 1 && (aArguments
[0] >>= xGridModel
))
112 aArg
.Name
= OUString("IntrospectedObject");
113 aArg
.Value
<<= xGridModel
;
114 Sequence
< Any
> aNewArguments(1);
115 aNewArguments
[0] <<= aArg
;
116 OControlFontDialog_DBase::initialize(aNewArguments
);
119 OControlFontDialog_DBase::initialize(aArguments
);
122 //---------------------------------------------------------------------
123 Reference
<XPropertySetInfo
> SAL_CALL
OControlFontDialog::getPropertySetInfo() throw(RuntimeException
)
125 Reference
<XPropertySetInfo
> xInfo( createPropertySetInfo( getInfoHelper() ) );
129 //---------------------------------------------------------------------
130 ::cppu::IPropertyArrayHelper
& OControlFontDialog::getInfoHelper()
132 return *const_cast<OControlFontDialog
*>(this)->getArrayHelper();
135 //--------------------------------------------------------------------------
136 ::cppu::IPropertyArrayHelper
* OControlFontDialog::createArrayHelper( ) const
138 Sequence
< Property
> aProps
;
139 describeProperties(aProps
);
140 return new ::cppu::OPropertyArrayHelper(aProps
);
143 //--------------------------------------------------------------------------
144 Dialog
* OControlFontDialog::createDialog(Window
* _pParent
)
146 ControlCharacterDialog::createItemSet(m_pFontItems
, m_pItemPool
, m_pItemPoolDefaults
);
148 OSL_ENSURE(m_xControlModel
.is(), "OControlFontDialog::createDialog: no introspectee set!");
149 if (m_xControlModel
.is())
150 ControlCharacterDialog::translatePropertiesToItems(m_xControlModel
, m_pFontItems
);
151 // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
152 // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
153 // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
155 ControlCharacterDialog
* pDialog
= new ControlCharacterDialog(_pParent
, *m_pFontItems
);
159 //-------------------------------------------------------------------------
160 void OControlFontDialog::destroyDialog()
162 OGenericUnoDialog::destroyDialog();
163 ControlCharacterDialog::destroyItemSet(m_pFontItems
, m_pItemPool
, m_pItemPoolDefaults
);
166 //-------------------------------------------------------------------------
167 void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult
)
169 OSL_ENSURE(m_pDialog
, "OControlFontDialog::executedDialog: no dialog anymore?!!");
170 if (m_pDialog
&& (sal_True
== _nExecutionResult
) && m_xControlModel
.is())
172 const SfxItemSet
* pOutput
= static_cast<ControlCharacterDialog
*>(m_pDialog
)->GetOutputItemSet();
174 ControlCharacterDialog::translateItemsToProperties( *pOutput
, m_xControlModel
);
178 //........................................................................
180 //........................................................................
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */