Line data Source code
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 :
21 : #include "controlfontdialog.hxx"
22 : #include <cppuhelper/typeprovider.hxx>
23 : #include "fontdialog.hxx"
24 : #include "formstrings.hxx"
25 : #include "pcrcommon.hxx"
26 :
27 0 : extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog()
28 : {
29 0 : ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
30 0 : }
31 :
32 :
33 : namespace pcr
34 : {
35 :
36 :
37 : using namespace ::com::sun::star::uno;
38 : using namespace ::com::sun::star::lang;
39 : using namespace ::com::sun::star::beans;
40 :
41 :
42 : //= OControlFontDialog
43 :
44 :
45 0 : OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
46 : :OGenericUnoDialog( _rxContext )
47 : ,m_pFontItems(NULL)
48 : ,m_pItemPool(NULL)
49 0 : ,m_pItemPoolDefaults(NULL)
50 : {
51 : registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
52 : PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
53 0 : &m_xControlModel, ::getCppuType(&m_xControlModel));
54 0 : }
55 :
56 :
57 0 : OControlFontDialog::~OControlFontDialog()
58 : {
59 0 : if (m_pDialog)
60 : {
61 0 : ::osl::MutexGuard aGuard(m_aMutex);
62 0 : if (m_pDialog)
63 0 : destroyDialog();
64 : }
65 0 : }
66 :
67 :
68 0 : Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( ) throw(RuntimeException, std::exception)
69 : {
70 0 : return css::uno::Sequence<sal_Int8>();
71 : }
72 :
73 :
74 0 : Reference< XInterface > SAL_CALL OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
75 : {
76 0 : return *( new OControlFontDialog( _rxContext ) );
77 : }
78 :
79 :
80 0 : OUString SAL_CALL OControlFontDialog::getImplementationName() throw(RuntimeException, std::exception)
81 : {
82 0 : return getImplementationName_static();
83 : }
84 :
85 :
86 0 : OUString OControlFontDialog::getImplementationName_static() throw(RuntimeException)
87 : {
88 0 : return OUString("org.openoffice.comp.form.ui.OControlFontDialog");
89 : }
90 :
91 :
92 0 : ::comphelper::StringSequence SAL_CALL OControlFontDialog::getSupportedServiceNames() throw(RuntimeException, std::exception)
93 : {
94 0 : return getSupportedServiceNames_static();
95 : }
96 :
97 :
98 0 : ::comphelper::StringSequence OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException)
99 : {
100 0 : ::comphelper::StringSequence aSupported(1);
101 0 : aSupported[0] = "com.sun.star.form.ControlFontDialog";
102 0 : return aSupported;
103 : }
104 :
105 0 : void OControlFontDialog::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException, std::exception)
106 : {
107 0 : Reference<XPropertySet> xGridModel;
108 0 : if (aArguments.getLength() == 1 && (aArguments[0] >>= xGridModel))
109 : {
110 0 : PropertyValue aArg;
111 0 : aArg.Name = "IntrospectedObject";
112 0 : aArg.Value <<= xGridModel;
113 0 : Sequence< Any > aNewArguments(1);
114 0 : aNewArguments[0] <<= aArg;
115 0 : OControlFontDialog_DBase::initialize(aNewArguments);
116 : }
117 : else
118 0 : OControlFontDialog_DBase::initialize(aArguments);
119 0 : }
120 :
121 :
122 0 : Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo() throw(RuntimeException, std::exception)
123 : {
124 0 : Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
125 0 : return xInfo;
126 : }
127 :
128 :
129 0 : ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
130 : {
131 0 : return *const_cast<OControlFontDialog*>(this)->getArrayHelper();
132 : }
133 :
134 :
135 0 : ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
136 : {
137 0 : Sequence< Property > aProps;
138 0 : describeProperties(aProps);
139 0 : return new ::cppu::OPropertyArrayHelper(aProps);
140 : }
141 :
142 :
143 0 : Dialog* OControlFontDialog::createDialog(Window* _pParent)
144 : {
145 0 : ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
146 :
147 : OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
148 0 : if (m_xControlModel.is())
149 0 : ControlCharacterDialog::translatePropertiesToItems(m_xControlModel, m_pFontItems);
150 : // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
151 : // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
152 : // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
153 :
154 0 : ControlCharacterDialog* pDialog = new ControlCharacterDialog(_pParent, *m_pFontItems);
155 0 : return pDialog;
156 : }
157 :
158 :
159 0 : void OControlFontDialog::destroyDialog()
160 : {
161 0 : OGenericUnoDialog::destroyDialog();
162 0 : ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
163 0 : }
164 :
165 :
166 0 : void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
167 : {
168 : OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
169 0 : if (m_pDialog && (sal_True == _nExecutionResult) && m_xControlModel.is())
170 : {
171 0 : const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog)->GetOutputItemSet();
172 0 : if (pOutput)
173 0 : ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
174 : }
175 0 : }
176 :
177 :
178 0 : } // namespace pcr
179 :
180 :
181 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|