1c142477cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3c142477cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4c142477cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5c142477cSAndrew Rist  * distributed with this work for additional information
6c142477cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7c142477cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8c142477cSAndrew Rist  * "License"); you may not use this file except in compliance
9c142477cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10c142477cSAndrew Rist  *
11c142477cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12c142477cSAndrew Rist  *
13c142477cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14c142477cSAndrew Rist  * software distributed under the License is distributed on an
15c142477cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c142477cSAndrew Rist  * KIND, either express or implied.  See the License for the
17c142477cSAndrew Rist  * specific language governing permissions and limitations
18c142477cSAndrew Rist  * under the License.
19c142477cSAndrew Rist  *
20c142477cSAndrew Rist  *************************************************************/
21c142477cSAndrew Rist 
22c142477cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sdext.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "unodialog.hxx"
28*597a4c59SAriel Constenla-Haile 
29*597a4c59SAriel Constenla-Haile #include <com/sun/star/awt/MessageBoxButtons.hpp>
30*597a4c59SAriel Constenla-Haile #include <com/sun/star/awt/XVclWindowPeer.hpp>
31*597a4c59SAriel Constenla-Haile #include <com/sun/star/awt/PosSize.hpp>
32*597a4c59SAriel Constenla-Haile #include <com/sun/star/awt/XMessageBoxFactory.hpp>
33*597a4c59SAriel Constenla-Haile #include <com/sun/star/awt/XStyleSettingsSupplier.hpp>
34880c69c6SAriel Constenla-Haile #include <com/sun/star/container/XIndexAccess.hpp>
35*597a4c59SAriel Constenla-Haile #include <com/sun/star/drawing/XShapes.hpp>
36880c69c6SAriel Constenla-Haile #include <com/sun/star/frame/XDispatch.hpp>
37*597a4c59SAriel Constenla-Haile #include <com/sun/star/text/XTextRange.hpp>
38*597a4c59SAriel Constenla-Haile #include <com/sun/star/view/XControlAccess.hpp>
39*597a4c59SAriel Constenla-Haile #include <com/sun/star/view/XSelectionSupplier.hpp>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // -------------
42cdf0e10cSrcweir // - UnoDialog -
43cdf0e10cSrcweir // -------------
44cdf0e10cSrcweir 
45cdf0e10cSrcweir using namespace ::com::sun::star::awt;
46cdf0e10cSrcweir using namespace ::com::sun::star::uno;
47cdf0e10cSrcweir using namespace ::com::sun::star::util;
48cdf0e10cSrcweir using namespace ::com::sun::star::lang;
49cdf0e10cSrcweir using namespace ::com::sun::star::view;
50cdf0e10cSrcweir using namespace ::com::sun::star::frame;
51cdf0e10cSrcweir using namespace ::com::sun::star::beans;
52cdf0e10cSrcweir using namespace ::com::sun::star::script;
53cdf0e10cSrcweir 
54*597a4c59SAriel Constenla-Haile using ::rtl::OUString;
55*597a4c59SAriel Constenla-Haile 
UnoDialog(const Reference<XComponentContext> & rxContext,const Reference<XWindowPeer> & rxParent)56*597a4c59SAriel Constenla-Haile UnoDialog::UnoDialog(
57*597a4c59SAriel Constenla-Haile     const Reference< XComponentContext > &rxContext,
58*597a4c59SAriel Constenla-Haile     const Reference< XWindowPeer >& rxParent ) :
59*597a4c59SAriel Constenla-Haile 	mxContext( rxContext ),
60*597a4c59SAriel Constenla-Haile 	mxParent( rxParent ),
61*597a4c59SAriel Constenla-Haile 	mxDialogModel( mxContext->getServiceManager()->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM(
62*597a4c59SAriel Constenla-Haile 		"com.sun.star.awt.UnoControlDialogModel" ) ), mxContext ), UNO_QUERY_THROW ),
63cdf0e10cSrcweir 	mxDialogModelMultiPropertySet( mxDialogModel, UNO_QUERY_THROW ),
64cdf0e10cSrcweir 	mxDialogModelPropertySet( mxDialogModel, UNO_QUERY_THROW ),
65cdf0e10cSrcweir 	mxDialogModelMSF( mxDialogModel, UNO_QUERY_THROW ),
66cdf0e10cSrcweir 	mxDialogModelNameContainer( mxDialogModel, UNO_QUERY_THROW ),
67cdf0e10cSrcweir 	mxDialogModelNameAccess( mxDialogModel, UNO_QUERY_THROW ),
68cdf0e10cSrcweir 	mxControlModel( mxDialogModel, UNO_QUERY_THROW ),
69*597a4c59SAriel Constenla-Haile 	mxDialog( mxContext->getServiceManager()->createInstanceWithContext( OUString( RTL_CONSTASCII_USTRINGPARAM(
70*597a4c59SAriel Constenla-Haile 		"com.sun.star.awt.UnoControlDialog" ) ), mxContext ), UNO_QUERY_THROW ),
71cdf0e10cSrcweir 	mxControl( mxDialog, UNO_QUERY_THROW ),
72cdf0e10cSrcweir 	mbStatus( sal_False )
73cdf0e10cSrcweir {
74*597a4c59SAriel Constenla-Haile     OSL_TRACE("UnoDialog::UnoDialog");
75cdf0e10cSrcweir 	mxControl->setModel( mxControlModel );
76cdf0e10cSrcweir 	mxDialogControlContainer = Reference< XControlContainer >( mxDialog, UNO_QUERY_THROW );
77*597a4c59SAriel Constenla-Haile     mxDialogWindow = Reference< XWindow >( mxDialog, UNO_QUERY );
78*597a4c59SAriel Constenla-Haile 	mxDialogWindowPeer = createWindowPeer();
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir // -----------------------------------------------------------------------------
82cdf0e10cSrcweir 
~UnoDialog()83cdf0e10cSrcweir UnoDialog::~UnoDialog()
84cdf0e10cSrcweir {
85*597a4c59SAriel Constenla-Haile     OSL_TRACE("UnoDialog::~UnoDialog");
86*597a4c59SAriel Constenla-Haile     Reference< XComponent > xComponent( mxDialog, UNO_QUERY );
87*597a4c59SAriel Constenla-Haile     if ( xComponent.is() )
88*597a4c59SAriel Constenla-Haile     {
89*597a4c59SAriel Constenla-Haile         xComponent->dispose();
90*597a4c59SAriel Constenla-Haile     }
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // -----------------------------------------------------------------------------
94cdf0e10cSrcweir 
setTitle(const rtl::OUString & rTitle)95*597a4c59SAriel Constenla-Haile void UnoDialog::setTitle( const rtl::OUString &rTitle )
96*597a4c59SAriel Constenla-Haile {
97*597a4c59SAriel Constenla-Haile     if ( rTitle.getLength() )
98*597a4c59SAriel Constenla-Haile     {
99*597a4c59SAriel Constenla-Haile         mxDialog->setTitle( rTitle );
100*597a4c59SAriel Constenla-Haile     }
101*597a4c59SAriel Constenla-Haile }
102*597a4c59SAriel Constenla-Haile 
execute()103cdf0e10cSrcweir void UnoDialog::execute()
104cdf0e10cSrcweir {
105*597a4c59SAriel Constenla-Haile     OSL_TRACE("UnoDialog::execute");
106cdf0e10cSrcweir 	mxDialogWindow->setEnable( sal_True );
107cdf0e10cSrcweir 	mxDialogWindow->setVisible( sal_True );
108cdf0e10cSrcweir 	mxDialog->execute();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
endExecute(sal_Bool bStatus)111cdf0e10cSrcweir void UnoDialog::endExecute( sal_Bool bStatus )
112cdf0e10cSrcweir {
113*597a4c59SAriel Constenla-Haile     OSL_TRACE("UnoDialog::endExecute");
114cdf0e10cSrcweir 	mbStatus = bStatus;
115cdf0e10cSrcweir 	mxDialog->endExecute();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
centerDialog()118*597a4c59SAriel Constenla-Haile void UnoDialog::centerDialog()
119*597a4c59SAriel Constenla-Haile {
120*597a4c59SAriel Constenla-Haile     Reference< XWindow > xParent( mxParent, UNO_QUERY );
121*597a4c59SAriel Constenla-Haile     if ( !xParent.is() )
122*597a4c59SAriel Constenla-Haile         return;
123*597a4c59SAriel Constenla-Haile 
124*597a4c59SAriel Constenla-Haile     Rectangle aParentPosSize = xParent->getPosSize();
125*597a4c59SAriel Constenla-Haile     Rectangle aWinPosSize = mxDialogWindow->getPosSize();
126*597a4c59SAriel Constenla-Haile     Point aWinPos((aParentPosSize.Width - aWinPosSize.Width) / 2,
127*597a4c59SAriel Constenla-Haile                   (aParentPosSize.Height - aWinPosSize.Height) / 2);
128*597a4c59SAriel Constenla-Haile 
129*597a4c59SAriel Constenla-Haile     if ( ( aWinPos.X + aWinPosSize.Width ) > ( aParentPosSize.X + aParentPosSize.Width ) )
130*597a4c59SAriel Constenla-Haile         aWinPos.X = aParentPosSize.X + aParentPosSize.Width - aWinPosSize.Width;
131*597a4c59SAriel Constenla-Haile 
132*597a4c59SAriel Constenla-Haile     if ( ( aWinPos.Y + aWinPosSize.Height ) > ( aParentPosSize.Y + aParentPosSize.Height ) )
133*597a4c59SAriel Constenla-Haile         aWinPos.Y = aParentPosSize.Y + aParentPosSize.Height - aWinPosSize.Height;
134*597a4c59SAriel Constenla-Haile 
135*597a4c59SAriel Constenla-Haile     mxDialogWindow->setPosSize( aWinPos.X, aWinPos.Y,
136*597a4c59SAriel Constenla-Haile                                 aWinPosSize.Width,
137*597a4c59SAriel Constenla-Haile                                 aWinPosSize.Height,
138*597a4c59SAriel Constenla-Haile                                 PosSize::POS );
139*597a4c59SAriel Constenla-Haile }
140*597a4c59SAriel Constenla-Haile 
141cdf0e10cSrcweir // -----------------------------------------------------------------------------
142cdf0e10cSrcweir 
createWindowPeer()143*597a4c59SAriel Constenla-Haile Reference< XWindowPeer > UnoDialog::createWindowPeer()
144cdf0e10cSrcweir 	throw ( Exception )
145cdf0e10cSrcweir {
146*597a4c59SAriel Constenla-Haile     mxDialogWindow->setVisible( sal_False );
147*597a4c59SAriel Constenla-Haile 
148*597a4c59SAriel Constenla-Haile     // reuse the parent's toolkit
149*597a4c59SAriel Constenla-Haile 	Reference< XToolkit > xToolkit;
150*597a4c59SAriel Constenla-Haile     if ( mxParent.is() )
151*597a4c59SAriel Constenla-Haile         xToolkit.set( mxParent->getToolkit() );
152*597a4c59SAriel Constenla-Haile 
153*597a4c59SAriel Constenla-Haile     if ( !xToolkit.is() )
154*597a4c59SAriel Constenla-Haile          xToolkit.set( mxContext->getServiceManager()->createInstanceWithContext(
155*597a4c59SAriel Constenla-Haile              OUString( RTL_CONSTASCII_USTRINGPARAM(
156*597a4c59SAriel Constenla-Haile                  "com.sun.star.awt.Toolkit" ) ), mxContext ),
157*597a4c59SAriel Constenla-Haile                     UNO_QUERY_THROW  );
158*597a4c59SAriel Constenla-Haile 
159cdf0e10cSrcweir 	mxReschedule = Reference< XReschedule >( xToolkit, UNO_QUERY );
160*597a4c59SAriel Constenla-Haile 	mxControl->createPeer( xToolkit, mxParent );
161*597a4c59SAriel Constenla-Haile 
162cdf0e10cSrcweir 	return mxControl->getPeer();
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
165cdf0e10cSrcweir // -----------------------------------------------------------------------------
166cdf0e10cSrcweir 
insertControlModel(const OUString & rServiceName,const OUString & rName,const Sequence<OUString> & rPropertyNames,const Sequence<Any> & rPropertyValues)167cdf0e10cSrcweir Reference< XInterface > UnoDialog::insertControlModel( const OUString& rServiceName, const OUString& rName,
168cdf0e10cSrcweir 														const Sequence< OUString >& rPropertyNames, const Sequence< Any >& rPropertyValues )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	Reference< XInterface > xControlModel;
171cdf0e10cSrcweir 	try
172cdf0e10cSrcweir 	{
173cdf0e10cSrcweir         xControlModel = mxDialogModelMSF->createInstance( rServiceName );
174cdf0e10cSrcweir 		Reference< XMultiPropertySet > xMultiPropSet( xControlModel, UNO_QUERY_THROW );
175cdf0e10cSrcweir 		xMultiPropSet->setPropertyValues( rPropertyNames, rPropertyValues );
176cdf0e10cSrcweir         mxDialogModelNameContainer->insertByName( rName, Any( xControlModel ) );
177cdf0e10cSrcweir     }
178cdf0e10cSrcweir 	catch( Exception& )
179cdf0e10cSrcweir 	{
180cdf0e10cSrcweir     }
181cdf0e10cSrcweir 	return xControlModel;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir // -----------------------------------------------------------------------------
185cdf0e10cSrcweir 
setVisible(const OUString & rName,sal_Bool bVisible)186cdf0e10cSrcweir void UnoDialog::setVisible( const OUString& rName, sal_Bool bVisible )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir 	try
189cdf0e10cSrcweir 	{
190cdf0e10cSrcweir 		Reference< XInterface > xControl( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
191cdf0e10cSrcweir 		Reference< XWindow > xWindow( xControl, UNO_QUERY_THROW );
192cdf0e10cSrcweir 		xWindow->setVisible( bVisible );
193cdf0e10cSrcweir 	}
194cdf0e10cSrcweir 	catch ( Exception& )
195cdf0e10cSrcweir 	{
196cdf0e10cSrcweir 	}
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir // -----------------------------------------------------------------------------
200cdf0e10cSrcweir 
isHighContrast()201cdf0e10cSrcweir sal_Bool UnoDialog::isHighContrast()
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	sal_Bool bHighContrast = sal_False;
204cdf0e10cSrcweir 	try
205cdf0e10cSrcweir 	{
206*597a4c59SAriel Constenla-Haile         Reference< XStyleSettingsSupplier > xStyleSettingsSuppl( mxDialogWindow, UNO_QUERY_THROW );
207*597a4c59SAriel Constenla-Haile         Reference< XStyleSettings > xStyleSettings( xStyleSettingsSuppl->getStyleSettings() );
208*597a4c59SAriel Constenla-Haile         bHighContrast = xStyleSettings->getHighContrastMode();
209cdf0e10cSrcweir 	}
210cdf0e10cSrcweir 	catch( Exception& )
211cdf0e10cSrcweir 	{
212cdf0e10cSrcweir 	}
213cdf0e10cSrcweir 	return bHighContrast;
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir // -----------------------------------------------------------------------------
217cdf0e10cSrcweir 
insertButton(const OUString & rName,Reference<XActionListener> xActionListener,const Sequence<OUString> & rPropertyNames,const Sequence<Any> & rPropertyValues)218cdf0e10cSrcweir Reference< XButton > UnoDialog::insertButton( const OUString& rName, Reference< XActionListener > xActionListener,
219cdf0e10cSrcweir 			const Sequence< OUString >& rPropertyNames, const Sequence< Any >& rPropertyValues )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir 	Reference< XButton > xButton;
222cdf0e10cSrcweir 	try
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir         Reference< XInterface > xButtonModel( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ),
225cdf0e10cSrcweir 			rName, rPropertyNames, rPropertyValues ) );
226cdf0e10cSrcweir 		Reference< XPropertySet > xPropertySet( xButtonModel, UNO_QUERY_THROW );
227cdf0e10cSrcweir 		xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) );
228cdf0e10cSrcweir 		xButton = Reference< XButton >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 		if ( xActionListener.is() )
231cdf0e10cSrcweir 		{
232cdf0e10cSrcweir             xButton->addActionListener( xActionListener );
233cdf0e10cSrcweir 			xButton->setActionCommand( rName );
234cdf0e10cSrcweir 		}
235cdf0e10cSrcweir 		return xButton;
236cdf0e10cSrcweir 	}
237cdf0e10cSrcweir 	catch( Exception& )
238cdf0e10cSrcweir 	{
239cdf0e10cSrcweir 	}
240cdf0e10cSrcweir 	return xButton;
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir // -----------------------------------------------------------------------------
244cdf0e10cSrcweir 
insertFixedText(const OUString & rName,const Sequence<OUString> rPropertyNames,const Sequence<Any> rPropertyValues)245cdf0e10cSrcweir Reference< XFixedText > UnoDialog::insertFixedText( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir 	Reference< XFixedText > xFixedText;
248cdf0e10cSrcweir 	try
249cdf0e10cSrcweir 	{
250cdf0e10cSrcweir 		Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ),
251cdf0e10cSrcweir 			rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW );
252cdf0e10cSrcweir         xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) );
253cdf0e10cSrcweir 		xFixedText = Reference< XFixedText >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 	catch ( Exception& )
256cdf0e10cSrcweir 	{
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir 	return xFixedText;
259cdf0e10cSrcweir }
260cdf0e10cSrcweir 
261cdf0e10cSrcweir // -----------------------------------------------------------------------------
262cdf0e10cSrcweir 
insertCheckBox(const OUString & rName,const Sequence<OUString> rPropertyNames,const Sequence<Any> rPropertyValues)263cdf0e10cSrcweir Reference< XCheckBox > UnoDialog::insertCheckBox( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir 	Reference< XCheckBox > xCheckBox;
266cdf0e10cSrcweir 	try
267cdf0e10cSrcweir 	{
268cdf0e10cSrcweir 		Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ),
269cdf0e10cSrcweir 			rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW );
270cdf0e10cSrcweir         xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) );
271cdf0e10cSrcweir 		xCheckBox = Reference< XCheckBox >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
272cdf0e10cSrcweir 	}
273cdf0e10cSrcweir 	catch ( Exception& )
274cdf0e10cSrcweir 	{
275cdf0e10cSrcweir     }
276cdf0e10cSrcweir 	return xCheckBox;
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir // -----------------------------------------------------------------------------
280cdf0e10cSrcweir 
insertFormattedField(const OUString & rName,const Sequence<OUString> rPropertyNames,const Sequence<Any> rPropertyValues)281cdf0e10cSrcweir Reference< XControl > UnoDialog::insertFormattedField( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir 	Reference< XControl > xControl;
284cdf0e10cSrcweir 	try
285cdf0e10cSrcweir 	{
286cdf0e10cSrcweir 		Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFormattedFieldModel" ) ),
287cdf0e10cSrcweir 			rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW );
288cdf0e10cSrcweir         xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) );
289cdf0e10cSrcweir 		xControl = Reference< XControl >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
290cdf0e10cSrcweir 	}
291cdf0e10cSrcweir 	catch ( Exception& )
292cdf0e10cSrcweir 	{
293cdf0e10cSrcweir     }
294cdf0e10cSrcweir 	return xControl;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir 
297cdf0e10cSrcweir // -----------------------------------------------------------------------------
298cdf0e10cSrcweir 
insertComboBox(const OUString & rName,const Sequence<OUString> rPropertyNames,const Sequence<Any> rPropertyValues)299cdf0e10cSrcweir Reference< XComboBox > UnoDialog::insertComboBox( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	Reference< XComboBox > xControl;
302cdf0e10cSrcweir 	try
303cdf0e10cSrcweir 	{
304cdf0e10cSrcweir 		Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ),
305cdf0e10cSrcweir 			rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW );
306cdf0e10cSrcweir         xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) );
307cdf0e10cSrcweir 		xControl = Reference< XComboBox >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
308cdf0e10cSrcweir 	}
309cdf0e10cSrcweir 	catch ( Exception& )
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir 	}
312cdf0e10cSrcweir 	return xControl;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir // -----------------------------------------------------------------------------
316cdf0e10cSrcweir 
insertRadioButton(const OUString & rName,const Sequence<OUString> rPropertyNames,const Sequence<Any> rPropertyValues)317cdf0e10cSrcweir Reference< XRadioButton > UnoDialog::insertRadioButton( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir 	Reference< XRadioButton > xControl;
320cdf0e10cSrcweir 	try
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 		Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ),
323cdf0e10cSrcweir 			rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW );
324cdf0e10cSrcweir         xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) );
325cdf0e10cSrcweir 		xControl = Reference< XRadioButton >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
326cdf0e10cSrcweir 	}
327cdf0e10cSrcweir 	catch ( Exception& )
328cdf0e10cSrcweir 	{
329cdf0e10cSrcweir 	}
330cdf0e10cSrcweir 	return xControl;
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir // -----------------------------------------------------------------------------
334cdf0e10cSrcweir 
insertListBox(const OUString & rName,const Sequence<OUString> rPropertyNames,const Sequence<Any> rPropertyValues)335cdf0e10cSrcweir Reference< XListBox > UnoDialog::insertListBox( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 	Reference< XListBox > xControl;
338cdf0e10cSrcweir 	try
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ),
341cdf0e10cSrcweir 			rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW );
342cdf0e10cSrcweir         xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) );
343cdf0e10cSrcweir 		xControl = Reference< XListBox >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
344cdf0e10cSrcweir 	}
345cdf0e10cSrcweir 	catch ( Exception& )
346cdf0e10cSrcweir 	{
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 	return xControl;
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir // -----------------------------------------------------------------------------
352cdf0e10cSrcweir 
insertImage(const OUString & rName,const Sequence<OUString> rPropertyNames,const Sequence<Any> rPropertyValues)353cdf0e10cSrcweir Reference< XControl > UnoDialog::insertImage( const OUString& rName, const Sequence< OUString > rPropertyNames, const Sequence< Any > rPropertyValues )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir 	Reference< XControl > xControl;
356cdf0e10cSrcweir 	try
357cdf0e10cSrcweir 	{
358cdf0e10cSrcweir 		Reference< XPropertySet > xPropertySet( insertControlModel( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ),
359cdf0e10cSrcweir 			rName, rPropertyNames, rPropertyValues ), UNO_QUERY_THROW );
360cdf0e10cSrcweir         xPropertySet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ), Any( rName ) );
361cdf0e10cSrcweir 		xControl = Reference< XControl >( mxDialogControlContainer->getControl( rName ), UNO_QUERY_THROW );
362cdf0e10cSrcweir 	}
363cdf0e10cSrcweir 	catch ( Exception& )
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir     }
366cdf0e10cSrcweir 	return xControl;
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir // -----------------------------------------------------------------------------
370cdf0e10cSrcweir 
setControlProperty(const OUString & rControlName,const OUString & rPropertyName,const Any & rPropertyValue)371cdf0e10cSrcweir void UnoDialog::setControlProperty( const OUString& rControlName, const OUString& rPropertyName, const Any& rPropertyValue )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir     try
374cdf0e10cSrcweir 	{
375cdf0e10cSrcweir 		if ( mxDialogModelNameAccess->hasByName( rControlName ) )
376cdf0e10cSrcweir 		{
377cdf0e10cSrcweir 			Reference< XPropertySet > xPropertySet( mxDialogModelNameAccess->getByName( rControlName ), UNO_QUERY_THROW );
378cdf0e10cSrcweir 			xPropertySet->setPropertyValue( rPropertyName, rPropertyValue );
379cdf0e10cSrcweir 		}
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir 	catch ( Exception& )
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir     }
384cdf0e10cSrcweir }
385cdf0e10cSrcweir 
386cdf0e10cSrcweir // -----------------------------------------------------------------------------
387cdf0e10cSrcweir 
getMapsFromPixels(sal_Int32 nPixels) const388cdf0e10cSrcweir sal_Int32 UnoDialog::getMapsFromPixels( sal_Int32 nPixels ) const
389cdf0e10cSrcweir {
390cdf0e10cSrcweir 	double dMaps = 0;
391cdf0e10cSrcweir 	try
392cdf0e10cSrcweir 	{
393cdf0e10cSrcweir 		sal_Int32 nMapWidth = 0;
394cdf0e10cSrcweir 		const OUString sWidth( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
395cdf0e10cSrcweir 		if ( mxDialogModelPropertySet->getPropertyValue( sWidth  ) >>= nMapWidth )
396cdf0e10cSrcweir 		{
397cdf0e10cSrcweir 			Reference< XWindow > xWindow( mxDialog, UNO_QUERY_THROW );
398cdf0e10cSrcweir 			double pxWidth = xWindow->getPosSize().Width;
399cdf0e10cSrcweir 			double mapRatio = ( pxWidth / nMapWidth );
400cdf0e10cSrcweir 			dMaps = nPixels / mapRatio;
401cdf0e10cSrcweir 		}
402cdf0e10cSrcweir 	}
403cdf0e10cSrcweir 	catch ( Exception& )
404cdf0e10cSrcweir 	{
405cdf0e10cSrcweir 	}
406cdf0e10cSrcweir 	return static_cast< sal_Int32 >( dMaps );
407cdf0e10cSrcweir }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir // -----------------------------------------------------------------------------
410cdf0e10cSrcweir 
getControlProperty(const OUString & rControlName,const OUString & rPropertyName)411cdf0e10cSrcweir Any UnoDialog::getControlProperty( const OUString& rControlName, const OUString& rPropertyName )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir 	Any aRet;
414cdf0e10cSrcweir     try
415cdf0e10cSrcweir 	{
416cdf0e10cSrcweir 		if ( mxDialogModelNameAccess->hasByName( rControlName ) )
417cdf0e10cSrcweir 		{
418cdf0e10cSrcweir 			Reference< XPropertySet > xPropertySet( mxDialogModelNameAccess->getByName( rControlName ), UNO_QUERY_THROW );
419cdf0e10cSrcweir 			aRet = xPropertySet->getPropertyValue( rPropertyName );
420cdf0e10cSrcweir 		}
421cdf0e10cSrcweir     }
422cdf0e10cSrcweir 	catch ( Exception& )
423cdf0e10cSrcweir 	{
424cdf0e10cSrcweir     }
425cdf0e10cSrcweir 	return aRet;
426cdf0e10cSrcweir }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir // -----------------------------------------------------------------------------
429cdf0e10cSrcweir 
enableControl(const OUString & rControlName)430cdf0e10cSrcweir void UnoDialog::enableControl( const OUString& rControlName )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	const OUString sEnabled( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) );
433cdf0e10cSrcweir 	setControlProperty( rControlName, sEnabled, Any( sal_True ) );
434cdf0e10cSrcweir }
435cdf0e10cSrcweir 
436cdf0e10cSrcweir // -----------------------------------------------------------------------------
437cdf0e10cSrcweir 
disableControl(const OUString & rControlName)438cdf0e10cSrcweir void UnoDialog::disableControl( const OUString& rControlName )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir 	const OUString sEnabled( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) );
441cdf0e10cSrcweir 	setControlProperty( rControlName, sEnabled, Any( sal_False ) );
442cdf0e10cSrcweir }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir // -----------------------------------------------------------------------------
445