xref: /AOO41X/main/toolkit/source/helper/formpdfexport.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <toolkit/helper/formpdfexport.hxx>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir /** === begin UNO includes === **/
34*cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/style/VerticalAlignment.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/form/FormSubmitMethod.hpp>
46*cdf0e10cSrcweir /** === end UNO includes === **/
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
49*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
50*cdf0e10cSrcweir #include <vcl/pdfextoutdevdata.hxx>
51*cdf0e10cSrcweir #include <vcl/outdev.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #include <functional>
54*cdf0e10cSrcweir #include <algorithm>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir //........................................................................
57*cdf0e10cSrcweir namespace toolkitform
58*cdf0e10cSrcweir {
59*cdf0e10cSrcweir //........................................................................
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     using namespace ::com::sun::star;
62*cdf0e10cSrcweir     using namespace ::com::sun::star::uno;
63*cdf0e10cSrcweir     using namespace ::com::sun::star::awt;
64*cdf0e10cSrcweir     using namespace ::com::sun::star::style;
65*cdf0e10cSrcweir     using namespace ::com::sun::star::beans;
66*cdf0e10cSrcweir     using namespace ::com::sun::star::form;
67*cdf0e10cSrcweir     using namespace ::com::sun::star::lang;
68*cdf0e10cSrcweir     using namespace ::com::sun::star::container;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     // used strings
71*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_CLASSID(RTL_CONSTASCII_USTRINGPARAM("ClassId"));
72*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_NAME(RTL_CONSTASCII_USTRINGPARAM("Name"));
73*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_STRINGITEMLIST(RTL_CONSTASCII_USTRINGPARAM("StringItemList"));
74*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_HELPTEXT(RTL_CONSTASCII_USTRINGPARAM("HelpText"));
75*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_TEXT(RTL_CONSTASCII_USTRINGPARAM("Text"));
76*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_LABEL(RTL_CONSTASCII_USTRINGPARAM("Label"));
77*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_READONLY(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
78*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_BORDER(RTL_CONSTASCII_USTRINGPARAM("Border"));
79*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_BACKGROUNDCOLOR(RTL_CONSTASCII_USTRINGPARAM("BackgroundColor"));
80*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_TEXTCOLOR(RTL_CONSTASCII_USTRINGPARAM("TextColor"));
81*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_MULTILINE(RTL_CONSTASCII_USTRINGPARAM("MultiLine"));
82*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_ALIGN(RTL_CONSTASCII_USTRINGPARAM("Align"));
83*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_FONT(RTL_CONSTASCII_USTRINGPARAM("FontDescriptor"));
84*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_MAXTEXTLEN(RTL_CONSTASCII_USTRINGPARAM("MaxTextLen"));
85*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_TARGET_URL(RTL_CONSTASCII_USTRINGPARAM("TargetURL"));
86*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_STATE(RTL_CONSTASCII_USTRINGPARAM("State"));
87*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_REFVALUE(RTL_CONSTASCII_USTRINGPARAM("RefValue"));
88*cdf0e10cSrcweir     static const ::rtl::OUString FM_PROP_DROPDOWN(RTL_CONSTASCII_USTRINGPARAM("Dropdown"));
89*cdf0e10cSrcweir     static const ::rtl::OUString FM_SUN_COMPONENT_FILECONTROL(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.FileControl"));
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     namespace
92*cdf0e10cSrcweir     {
93*cdf0e10cSrcweir         //--------------------------------------------------------------------
94*cdf0e10cSrcweir         /** determines the FormComponentType of a form control
95*cdf0e10cSrcweir         */
96*cdf0e10cSrcweir         sal_Int16 classifyFormControl( const Reference< XPropertySet >& _rxModel ) SAL_THROW(( Exception ))
97*cdf0e10cSrcweir         {
98*cdf0e10cSrcweir             sal_Int16 nControlType = FormComponentType::CONTROL;
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir             Reference< XPropertySetInfo > xPSI;
101*cdf0e10cSrcweir             if ( _rxModel.is() )
102*cdf0e10cSrcweir                 xPSI = _rxModel->getPropertySetInfo();
103*cdf0e10cSrcweir             if ( xPSI.is() && xPSI->hasPropertyByName( FM_PROP_CLASSID ) )
104*cdf0e10cSrcweir             {
105*cdf0e10cSrcweir                 OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_CLASSID ) >>= nControlType );
106*cdf0e10cSrcweir             }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir             return nControlType;
109*cdf0e10cSrcweir         }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	    //--------------------------------------------------------------------
112*cdf0e10cSrcweir         /** (default-)creates a PDF widget according to a given FormComponentType
113*cdf0e10cSrcweir         */
114*cdf0e10cSrcweir         ::vcl::PDFWriter::AnyWidget* createDefaultWidget( sal_Int16 _nFormComponentType )
115*cdf0e10cSrcweir         {
116*cdf0e10cSrcweir             switch ( _nFormComponentType )
117*cdf0e10cSrcweir             {
118*cdf0e10cSrcweir             case FormComponentType::COMMANDBUTTON:
119*cdf0e10cSrcweir                 return new ::vcl::PDFWriter::PushButtonWidget;
120*cdf0e10cSrcweir             case FormComponentType::CHECKBOX:
121*cdf0e10cSrcweir                 return new ::vcl::PDFWriter::CheckBoxWidget;
122*cdf0e10cSrcweir             case FormComponentType::RADIOBUTTON:
123*cdf0e10cSrcweir                 return new ::vcl::PDFWriter::RadioButtonWidget;
124*cdf0e10cSrcweir             case FormComponentType::LISTBOX:
125*cdf0e10cSrcweir                 return new ::vcl::PDFWriter::ListBoxWidget;
126*cdf0e10cSrcweir             case FormComponentType::COMBOBOX:
127*cdf0e10cSrcweir                 return new ::vcl::PDFWriter::ComboBoxWidget;
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir             case FormComponentType::TEXTFIELD:
130*cdf0e10cSrcweir             case FormComponentType::FILECONTROL:
131*cdf0e10cSrcweir             case FormComponentType::DATEFIELD:
132*cdf0e10cSrcweir             case FormComponentType::TIMEFIELD:
133*cdf0e10cSrcweir             case FormComponentType::NUMERICFIELD:
134*cdf0e10cSrcweir             case FormComponentType::CURRENCYFIELD:
135*cdf0e10cSrcweir             case FormComponentType::PATTERNFIELD:
136*cdf0e10cSrcweir                 return new ::vcl::PDFWriter::EditWidget;
137*cdf0e10cSrcweir             }
138*cdf0e10cSrcweir             return NULL;
139*cdf0e10cSrcweir         }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 	    //--------------------------------------------------------------------
142*cdf0e10cSrcweir         /** determines a unique number for the radio group which the given radio
143*cdf0e10cSrcweir             button model belongs to
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir             The number is guaranteed to be
146*cdf0e10cSrcweir             <ul><li>unique within the document in which the button lives</li>
147*cdf0e10cSrcweir                 <li>the same for subsequent calls with other radio button models,
148*cdf0e10cSrcweir                     which live in the same document, and belong to the same group</li>
149*cdf0e10cSrcweir             </ul>
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir             @precond
152*cdf0e10cSrcweir                 the model must be part of the form component hierarchy in a document
153*cdf0e10cSrcweir         */
154*cdf0e10cSrcweir         sal_Int32 determineRadioGroupId( const Reference< XPropertySet >& _rxRadioModel ) SAL_THROW((Exception))
155*cdf0e10cSrcweir         {
156*cdf0e10cSrcweir             OSL_ENSURE( classifyFormControl( _rxRadioModel ) == FormComponentType::RADIOBUTTON,
157*cdf0e10cSrcweir                 "determineRadioGroupId: this *is* no radio button model!" );
158*cdf0e10cSrcweir             // The fact that radio button groups need to be unique within the complete
159*cdf0e10cSrcweir             // host document makes it somewhat difficult ...
160*cdf0e10cSrcweir             // Problem is that two form radio buttons belong to the same group if
161*cdf0e10cSrcweir             // - they have the same parent
162*cdf0e10cSrcweir             // - AND they have the same name
163*cdf0e10cSrcweir             // This implies that we need some knowledge about (potentially) *all* radio button
164*cdf0e10cSrcweir             // groups in the document.
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir             // get the root-level container
167*cdf0e10cSrcweir             Reference< XChild > xChild( _rxRadioModel, UNO_QUERY );
168*cdf0e10cSrcweir             Reference< XForm > xParentForm( xChild.is() ? xChild->getParent() : Reference< XInterface >(), UNO_QUERY );
169*cdf0e10cSrcweir             OSL_ENSURE( xParentForm.is(), "determineRadioGroupId: no parent form -> group id!" );
170*cdf0e10cSrcweir             if ( !xParentForm.is() )
171*cdf0e10cSrcweir                 return -1;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir             while ( xParentForm.is() )
174*cdf0e10cSrcweir             {
175*cdf0e10cSrcweir                 xChild = xParentForm.get();
176*cdf0e10cSrcweir                 xParentForm = xParentForm.query( xChild->getParent() );
177*cdf0e10cSrcweir             }
178*cdf0e10cSrcweir             Reference< XIndexAccess > xRoot( xChild->getParent(), UNO_QUERY );
179*cdf0e10cSrcweir             OSL_ENSURE( xRoot.is(), "determineRadioGroupId: unable to determine the root of the form component hierarchy!" );
180*cdf0e10cSrcweir             if ( !xRoot.is() )
181*cdf0e10cSrcweir                 return -1;
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir             // count the leafs in the hierarchy, until we encounter radio button
184*cdf0e10cSrcweir             ::std::vector< Reference< XIndexAccess > > aAncestors;
185*cdf0e10cSrcweir             ::std::vector< sal_Int32 >                 aPath;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir             Reference< XInterface > xNormalizedLookup( _rxRadioModel, UNO_QUERY );
188*cdf0e10cSrcweir             ::rtl::OUString sRadioGroupName;
189*cdf0e10cSrcweir             OSL_VERIFY( _rxRadioModel->getPropertyValue( FM_PROP_NAME ) >>= sRadioGroupName );
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir             Reference< XIndexAccess > xCurrentContainer( xRoot );
192*cdf0e10cSrcweir             sal_Int32 nStartWithChild = 0;
193*cdf0e10cSrcweir             sal_Int32 nGroupsEncountered = 0;
194*cdf0e10cSrcweir             do
195*cdf0e10cSrcweir             {
196*cdf0e10cSrcweir                 Reference< XNameAccess > xElementNameAccess( xCurrentContainer, UNO_QUERY );
197*cdf0e10cSrcweir                 OSL_ENSURE( xElementNameAccess.is(), "determineRadioGroupId: no name container?" );
198*cdf0e10cSrcweir                 if ( !xElementNameAccess.is() )
199*cdf0e10cSrcweir                     return -1;
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir                 if ( nStartWithChild == 0 )
202*cdf0e10cSrcweir                 {   // we encounter this container the first time. In particular, we did not
203*cdf0e10cSrcweir                     // just step up
204*cdf0e10cSrcweir                     nGroupsEncountered += xElementNameAccess->getElementNames().getLength();
205*cdf0e10cSrcweir                         // this is way too much: Not all of the elements in the current container
206*cdf0e10cSrcweir                         // may form groups, especially if they're forms. But anyway, this number is
207*cdf0e10cSrcweir                         // sufficient for our purpose. Finally, the container contains *at most*
208*cdf0e10cSrcweir                         // that much groups
209*cdf0e10cSrcweir                 }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir                 sal_Int32 nCount = xCurrentContainer->getCount();
212*cdf0e10cSrcweir                 sal_Int32 i;
213*cdf0e10cSrcweir                 for ( i = nStartWithChild; i < nCount; ++i )
214*cdf0e10cSrcweir                 {
215*cdf0e10cSrcweir                     Reference< XInterface > xElement( xCurrentContainer->getByIndex( i ), UNO_QUERY );
216*cdf0e10cSrcweir                     if ( !xElement.is() )
217*cdf0e10cSrcweir                     {
218*cdf0e10cSrcweir                         OSL_ENSURE( sal_False, "determineRadioGroupId: very suspicious!" );
219*cdf0e10cSrcweir                         continue;
220*cdf0e10cSrcweir                     }
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir                     Reference< XIndexAccess > xNewContainer( xElement, UNO_QUERY );
223*cdf0e10cSrcweir                     if ( xNewContainer.is() )
224*cdf0e10cSrcweir                     {
225*cdf0e10cSrcweir                         // step down the hierarchy
226*cdf0e10cSrcweir                         aAncestors.push_back( xCurrentContainer );
227*cdf0e10cSrcweir                         xCurrentContainer = xNewContainer;
228*cdf0e10cSrcweir                         aPath.push_back( i );
229*cdf0e10cSrcweir                         nStartWithChild = 0;
230*cdf0e10cSrcweir                         break;
231*cdf0e10cSrcweir                             // out of the inner loop, but continue with the outer loop
232*cdf0e10cSrcweir                     }
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir                     if ( xElement.get() == xNormalizedLookup.get() )
235*cdf0e10cSrcweir                     {
236*cdf0e10cSrcweir                         // look up the name of the radio group in the list of all element names
237*cdf0e10cSrcweir                         Sequence< ::rtl::OUString > aElementNames( xElementNameAccess->getElementNames() );
238*cdf0e10cSrcweir                         const ::rtl::OUString* pElementNames = aElementNames.getConstArray();
239*cdf0e10cSrcweir                         const ::rtl::OUString* pElementNamesEnd = pElementNames + aElementNames.getLength();
240*cdf0e10cSrcweir                         while ( pElementNames != pElementNamesEnd )
241*cdf0e10cSrcweir                         {
242*cdf0e10cSrcweir                             if ( *pElementNames == sRadioGroupName )
243*cdf0e10cSrcweir                             {
244*cdf0e10cSrcweir                                 sal_Int32 nLocalGroupIndex = pElementNames - aElementNames.getConstArray();
245*cdf0e10cSrcweir                                 OSL_ENSURE( nLocalGroupIndex < xElementNameAccess->getElementNames().getLength(),
246*cdf0e10cSrcweir                                     "determineRadioGroupId: inconsistency!" );
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir                                 sal_Int32 nGlobalGroupId = nGroupsEncountered - xElementNameAccess->getElementNames().getLength() + nLocalGroupIndex;
249*cdf0e10cSrcweir                                 return nGlobalGroupId;
250*cdf0e10cSrcweir                             }
251*cdf0e10cSrcweir                             ++pElementNames;
252*cdf0e10cSrcweir                         }
253*cdf0e10cSrcweir                         OSL_ENSURE( sal_False, "determineRadioGroupId: did not find the radios element name!" );
254*cdf0e10cSrcweir                     }
255*cdf0e10cSrcweir                 }
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir                 if ( !( i < nCount ) )
258*cdf0e10cSrcweir                 {
259*cdf0e10cSrcweir                     // the loop terminated because there were no more elements
260*cdf0e10cSrcweir                     // -> step up, if possible
261*cdf0e10cSrcweir                     if ( aAncestors.empty() )
262*cdf0e10cSrcweir                         break;
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir                     xCurrentContainer = aAncestors.back(); aAncestors.pop_back();
265*cdf0e10cSrcweir                     nStartWithChild = aPath.back() + 1; aPath.pop_back();
266*cdf0e10cSrcweir                 }
267*cdf0e10cSrcweir             }
268*cdf0e10cSrcweir             while ( true );
269*cdf0e10cSrcweir             return -1;
270*cdf0e10cSrcweir         }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir         //--------------------------------------------------------------------
273*cdf0e10cSrcweir         /** copies a StringItemList to a PDF widget's list
274*cdf0e10cSrcweir         */
275*cdf0e10cSrcweir         void getStringItemVector( const Reference< XPropertySet >& _rxModel, ::std::vector< ::rtl::OUString >& _rVector )
276*cdf0e10cSrcweir         {
277*cdf0e10cSrcweir             Sequence< ::rtl::OUString > aListEntries;
278*cdf0e10cSrcweir             OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_STRINGITEMLIST ) >>= aListEntries );
279*cdf0e10cSrcweir             ::std::copy( aListEntries.getConstArray(), aListEntries.getConstArray() + aListEntries.getLength(),
280*cdf0e10cSrcweir                 ::std::back_insert_iterator< ::std::vector< ::rtl::OUString > >( _rVector ) );
281*cdf0e10cSrcweir         }
282*cdf0e10cSrcweir     }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 	//--------------------------------------------------------------------
285*cdf0e10cSrcweir     /** creates a PDF compatible control descriptor for the given control
286*cdf0e10cSrcweir     */
287*cdf0e10cSrcweir     void TOOLKIT_DLLPUBLIC describePDFControl( const Reference< XControl >& _rxControl,
288*cdf0e10cSrcweir         ::std::auto_ptr< ::vcl::PDFWriter::AnyWidget >& _rpDescriptor, ::vcl::PDFExtOutDevData& i_pdfExportData ) SAL_THROW(())
289*cdf0e10cSrcweir     {
290*cdf0e10cSrcweir         _rpDescriptor.reset( NULL );
291*cdf0e10cSrcweir         OSL_ENSURE( _rxControl.is(), "describePDFControl: invalid (NULL) control!" );
292*cdf0e10cSrcweir         if ( !_rxControl.is() )
293*cdf0e10cSrcweir             return;
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir         try
296*cdf0e10cSrcweir         {
297*cdf0e10cSrcweir             Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY );
298*cdf0e10cSrcweir             sal_Int16 nControlType = classifyFormControl( xModelProps );
299*cdf0e10cSrcweir             _rpDescriptor.reset( createDefaultWidget( nControlType ) );
300*cdf0e10cSrcweir             if ( !_rpDescriptor.get() )
301*cdf0e10cSrcweir                 // no PDF widget available for this
302*cdf0e10cSrcweir                 return;
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir             Reference< XPropertySetInfo > xPSI( xModelProps->getPropertySetInfo() );
305*cdf0e10cSrcweir             Reference< XServiceInfo > xSI( xModelProps, UNO_QUERY );
306*cdf0e10cSrcweir             OSL_ENSURE( xSI.is(), "describePDFControl: no service info!" );
307*cdf0e10cSrcweir                 // if we survived classifyFormControl, then it's a real form control, and they all have
308*cdf0e10cSrcweir                 // service infos
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir             // ================================
311*cdf0e10cSrcweir             // set the common widget properties
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir             // --------------------------------
314*cdf0e10cSrcweir             // Name, Description, Text
315*cdf0e10cSrcweir             OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_NAME ) >>= _rpDescriptor->Name );
316*cdf0e10cSrcweir             OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_HELPTEXT ) >>= _rpDescriptor->Description );
317*cdf0e10cSrcweir             Any aText;
318*cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( FM_PROP_TEXT ) )
319*cdf0e10cSrcweir                 aText = xModelProps->getPropertyValue( FM_PROP_TEXT );
320*cdf0e10cSrcweir             else if ( xPSI->hasPropertyByName( FM_PROP_LABEL ) )
321*cdf0e10cSrcweir                 aText = xModelProps->getPropertyValue( FM_PROP_LABEL );
322*cdf0e10cSrcweir             if ( aText.hasValue() )
323*cdf0e10cSrcweir                 OSL_VERIFY( aText >>= _rpDescriptor->Text );
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir             // --------------------------------
326*cdf0e10cSrcweir             // readonly
327*cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( FM_PROP_READONLY ) )
328*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_READONLY ) >>= _rpDescriptor->ReadOnly );
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir             // --------------------------------
331*cdf0e10cSrcweir             // border
332*cdf0e10cSrcweir             {
333*cdf0e10cSrcweir                 if ( xPSI->hasPropertyByName( FM_PROP_BORDER ) )
334*cdf0e10cSrcweir                 {
335*cdf0e10cSrcweir                     sal_Int16 nBorderType = 0;
336*cdf0e10cSrcweir                     OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_BORDER ) >>= nBorderType );
337*cdf0e10cSrcweir                     _rpDescriptor->Border = ( nBorderType != 0 );
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir                     ::rtl::OUString sBorderColorPropertyName( RTL_CONSTASCII_USTRINGPARAM( "BorderColor" ) );
340*cdf0e10cSrcweir                     if ( xPSI->hasPropertyByName( sBorderColorPropertyName ) )
341*cdf0e10cSrcweir                     {
342*cdf0e10cSrcweir                         sal_Int32 nBoderColor = COL_TRANSPARENT;
343*cdf0e10cSrcweir                         if ( xModelProps->getPropertyValue( sBorderColorPropertyName ) >>= nBoderColor )
344*cdf0e10cSrcweir                             _rpDescriptor->BorderColor = Color( nBoderColor );
345*cdf0e10cSrcweir                         else
346*cdf0e10cSrcweir                             _rpDescriptor->BorderColor = Color( COL_BLACK );
347*cdf0e10cSrcweir                     }
348*cdf0e10cSrcweir                 }
349*cdf0e10cSrcweir             }
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir             // --------------------------------
352*cdf0e10cSrcweir             // background color
353*cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( FM_PROP_BACKGROUNDCOLOR ) )
354*cdf0e10cSrcweir             {
355*cdf0e10cSrcweir                 sal_Int32 nBackColor = COL_TRANSPARENT;
356*cdf0e10cSrcweir                 xModelProps->getPropertyValue( FM_PROP_BACKGROUNDCOLOR ) >>= nBackColor;
357*cdf0e10cSrcweir                 _rpDescriptor->Background = true;
358*cdf0e10cSrcweir                 _rpDescriptor->BackgroundColor = Color( nBackColor );
359*cdf0e10cSrcweir             }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir             // --------------------------------
362*cdf0e10cSrcweir             // text color
363*cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( FM_PROP_TEXTCOLOR ) )
364*cdf0e10cSrcweir             {
365*cdf0e10cSrcweir                 sal_Int32 nTextColor = COL_TRANSPARENT;
366*cdf0e10cSrcweir                 xModelProps->getPropertyValue( FM_PROP_TEXTCOLOR ) >>= nTextColor;
367*cdf0e10cSrcweir                 _rpDescriptor->TextColor = Color( nTextColor );
368*cdf0e10cSrcweir             }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir             // --------------------------------
371*cdf0e10cSrcweir             // text style
372*cdf0e10cSrcweir             _rpDescriptor->TextStyle = 0;
373*cdf0e10cSrcweir             // ............................
374*cdf0e10cSrcweir             // multi line and word break
375*cdf0e10cSrcweir             // The MultiLine property of the control is mapped to both the "MULTILINE" and
376*cdf0e10cSrcweir             // "WORDBREAK" style flags
377*cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( FM_PROP_MULTILINE ) )
378*cdf0e10cSrcweir             {
379*cdf0e10cSrcweir                 sal_Bool bMultiLine = sal_False;
380*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_MULTILINE ) >>= bMultiLine );
381*cdf0e10cSrcweir                 if ( bMultiLine )
382*cdf0e10cSrcweir                     _rpDescriptor->TextStyle |= TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK;
383*cdf0e10cSrcweir             }
384*cdf0e10cSrcweir             // ............................
385*cdf0e10cSrcweir             // horizontal alignment
386*cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( FM_PROP_ALIGN ) )
387*cdf0e10cSrcweir             {
388*cdf0e10cSrcweir                 sal_Int16 nAlign = awt::TextAlign::LEFT;
389*cdf0e10cSrcweir                 xModelProps->getPropertyValue( FM_PROP_ALIGN ) >>= nAlign;
390*cdf0e10cSrcweir                 // TODO: when the property is VOID - are there situations/UIs where this
391*cdf0e10cSrcweir                 // means something else than LEFT?
392*cdf0e10cSrcweir                 switch ( nAlign )
393*cdf0e10cSrcweir                 {
394*cdf0e10cSrcweir                 case awt::TextAlign::LEFT:  _rpDescriptor->TextStyle |= TEXT_DRAW_LEFT; break;
395*cdf0e10cSrcweir                 case awt::TextAlign::CENTER:  _rpDescriptor->TextStyle |= TEXT_DRAW_CENTER; break;
396*cdf0e10cSrcweir                 case awt::TextAlign::RIGHT:  _rpDescriptor->TextStyle |= TEXT_DRAW_RIGHT; break;
397*cdf0e10cSrcweir                 default:
398*cdf0e10cSrcweir                     OSL_ENSURE( sal_False, "describePDFControl: invalid text align!" );
399*cdf0e10cSrcweir                 }
400*cdf0e10cSrcweir             }
401*cdf0e10cSrcweir             // ............................
402*cdf0e10cSrcweir             // vertical alignment
403*cdf0e10cSrcweir             {
404*cdf0e10cSrcweir                 ::rtl::OUString sVertAlignPropertyName( RTL_CONSTASCII_USTRINGPARAM( "VerticalAlign" ) );
405*cdf0e10cSrcweir                 if ( xPSI->hasPropertyByName( sVertAlignPropertyName ) )
406*cdf0e10cSrcweir                 {
407*cdf0e10cSrcweir                     sal_Int16 nAlign = VerticalAlignment_MIDDLE;
408*cdf0e10cSrcweir                     xModelProps->getPropertyValue( sVertAlignPropertyName ) >>= nAlign;
409*cdf0e10cSrcweir                     switch ( nAlign )
410*cdf0e10cSrcweir                     {
411*cdf0e10cSrcweir                     case VerticalAlignment_TOP:  _rpDescriptor->TextStyle |= TEXT_DRAW_TOP; break;
412*cdf0e10cSrcweir                     case VerticalAlignment_MIDDLE:  _rpDescriptor->TextStyle |= TEXT_DRAW_VCENTER; break;
413*cdf0e10cSrcweir                     case VerticalAlignment_BOTTOM:  _rpDescriptor->TextStyle |= TEXT_DRAW_BOTTOM; break;
414*cdf0e10cSrcweir                     default:
415*cdf0e10cSrcweir                         OSL_ENSURE( sal_False, "describePDFControl: invalid vertical text align!" );
416*cdf0e10cSrcweir                     }
417*cdf0e10cSrcweir                 }
418*cdf0e10cSrcweir             }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir             // font
421*cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( FM_PROP_FONT ) )
422*cdf0e10cSrcweir             {
423*cdf0e10cSrcweir                 FontDescriptor aUNOFont;
424*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_FONT ) >>= aUNOFont );
425*cdf0e10cSrcweir                 _rpDescriptor->TextFont = VCLUnoHelper::CreateFont( aUNOFont, Font() );
426*cdf0e10cSrcweir             }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir             // tab order
429*cdf0e10cSrcweir             rtl::OUString aTabIndexString( RTL_CONSTASCII_USTRINGPARAM( "TabIndex" ) );
430*cdf0e10cSrcweir             if ( xPSI->hasPropertyByName( aTabIndexString ) )
431*cdf0e10cSrcweir             {
432*cdf0e10cSrcweir                 sal_Int16 nIndex = -1;
433*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( aTabIndexString ) >>= nIndex );
434*cdf0e10cSrcweir                 _rpDescriptor->TabOrder = nIndex;
435*cdf0e10cSrcweir             }
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir             // ================================
438*cdf0e10cSrcweir             // special widget properties
439*cdf0e10cSrcweir             // --------------------------------
440*cdf0e10cSrcweir             // edits
441*cdf0e10cSrcweir             if ( _rpDescriptor->getType() == ::vcl::PDFWriter::Edit )
442*cdf0e10cSrcweir             {
443*cdf0e10cSrcweir                 ::vcl::PDFWriter::EditWidget* pEditWidget = static_cast< ::vcl::PDFWriter::EditWidget* >( _rpDescriptor.get() );
444*cdf0e10cSrcweir                 // ............................
445*cdf0e10cSrcweir                 // multiline (already flagged in the TextStyle)
446*cdf0e10cSrcweir                 pEditWidget->MultiLine = ( _rpDescriptor->TextStyle & TEXT_DRAW_MULTILINE ) != 0;
447*cdf0e10cSrcweir                 // ............................
448*cdf0e10cSrcweir                 // password input
449*cdf0e10cSrcweir                 ::rtl::OUString sEchoCharPropName( RTL_CONSTASCII_USTRINGPARAM( "EchoChar" ) );
450*cdf0e10cSrcweir                 if ( xPSI->hasPropertyByName( sEchoCharPropName ) )
451*cdf0e10cSrcweir                 {
452*cdf0e10cSrcweir                     sal_Int16 nEchoChar = 0;
453*cdf0e10cSrcweir                     if ( ( xModelProps->getPropertyValue( sEchoCharPropName ) >>= nEchoChar ) && ( nEchoChar != 0 ) )
454*cdf0e10cSrcweir                         pEditWidget->Password = true;
455*cdf0e10cSrcweir                 }
456*cdf0e10cSrcweir                 // ............................
457*cdf0e10cSrcweir                 // file select
458*cdf0e10cSrcweir                 if ( xSI->supportsService( FM_SUN_COMPONENT_FILECONTROL ) )
459*cdf0e10cSrcweir                     pEditWidget->FileSelect = true;
460*cdf0e10cSrcweir                 // ............................
461*cdf0e10cSrcweir                 // maximum text length
462*cdf0e10cSrcweir                 if ( xPSI->hasPropertyByName( FM_PROP_MAXTEXTLEN ) )
463*cdf0e10cSrcweir                 {
464*cdf0e10cSrcweir                     sal_Int16 nMaxTextLength = 0;
465*cdf0e10cSrcweir                     OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_MAXTEXTLEN ) >>= nMaxTextLength );
466*cdf0e10cSrcweir                     if ( nMaxTextLength <= 0 )
467*cdf0e10cSrcweir                         // "-1" has a special meaning for database-bound controls
468*cdf0e10cSrcweir                         nMaxTextLength = 0;
469*cdf0e10cSrcweir                     pEditWidget->MaxLen = nMaxTextLength;
470*cdf0e10cSrcweir                 }
471*cdf0e10cSrcweir             }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir             // --------------------------------
474*cdf0e10cSrcweir             // buttons
475*cdf0e10cSrcweir             if ( _rpDescriptor->getType() == ::vcl::PDFWriter::PushButton )
476*cdf0e10cSrcweir             {
477*cdf0e10cSrcweir                 ::vcl::PDFWriter::PushButtonWidget* pButtonWidget = static_cast< ::vcl::PDFWriter::PushButtonWidget* >( _rpDescriptor.get() );
478*cdf0e10cSrcweir                 FormButtonType eButtonType = FormButtonType_PUSH;
479*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) ) ) >>= eButtonType );
480*cdf0e10cSrcweir                 if ( eButtonType == FormButtonType_SUBMIT )
481*cdf0e10cSrcweir                 {
482*cdf0e10cSrcweir                     // if a button is a submit button, then it uses the URL at it's parent form
483*cdf0e10cSrcweir                     Reference< XChild > xChild( xModelProps, UNO_QUERY );
484*cdf0e10cSrcweir                     Reference < XPropertySet > xParentProps;
485*cdf0e10cSrcweir                     if ( xChild.is() )
486*cdf0e10cSrcweir                         xParentProps = xParentProps.query( xChild->getParent() );
487*cdf0e10cSrcweir                     if ( xParentProps.is() )
488*cdf0e10cSrcweir                     {
489*cdf0e10cSrcweir                         Reference< XServiceInfo > xParentSI( xParentProps, UNO_QUERY );
490*cdf0e10cSrcweir                         if ( xParentSI.is() && xParentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.HTMLForm" ) ) ) )
491*cdf0e10cSrcweir                         {
492*cdf0e10cSrcweir                             OSL_VERIFY( xParentProps->getPropertyValue( FM_PROP_TARGET_URL ) >>= pButtonWidget->URL );
493*cdf0e10cSrcweir                             pButtonWidget->Submit = true;
494*cdf0e10cSrcweir                             FormSubmitMethod eMethod = FormSubmitMethod_POST;
495*cdf0e10cSrcweir                             OSL_VERIFY( xParentProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SubmitMethod" ) ) ) >>= eMethod );
496*cdf0e10cSrcweir                             pButtonWidget->SubmitGet = (eMethod == FormSubmitMethod_GET);
497*cdf0e10cSrcweir                         }
498*cdf0e10cSrcweir                     }
499*cdf0e10cSrcweir                 }
500*cdf0e10cSrcweir                 else if ( eButtonType == FormButtonType_URL )
501*cdf0e10cSrcweir                 {
502*cdf0e10cSrcweir                     ::rtl::OUString sURL;
503*cdf0e10cSrcweir                     OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_TARGET_URL ) >>= sURL );
504*cdf0e10cSrcweir                     const bool bDocumentLocalTarget = ( sURL.getLength() > 0 ) && ( sURL.getStr()[0] == '#' );
505*cdf0e10cSrcweir                     if ( bDocumentLocalTarget )
506*cdf0e10cSrcweir                     {
507*cdf0e10cSrcweir                         const ::rtl::OUString sDestinationName( sURL.copy(1) );
508*cdf0e10cSrcweir                         // Register the destination for for future handling ...
509*cdf0e10cSrcweir                         pButtonWidget->Dest = i_pdfExportData.RegisterDest();
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir                         // and put it into the bookmarks, to ensure the future handling really happens
512*cdf0e10cSrcweir                         ::std::vector< ::vcl::PDFExtOutDevBookmarkEntry >& rBookmarks( i_pdfExportData.GetBookmarks() );
513*cdf0e10cSrcweir                         ::vcl::PDFExtOutDevBookmarkEntry aBookmark;
514*cdf0e10cSrcweir                         aBookmark.nDestId = pButtonWidget->Dest;
515*cdf0e10cSrcweir                         aBookmark.aBookmark = sURL;
516*cdf0e10cSrcweir                         rBookmarks.push_back( aBookmark );
517*cdf0e10cSrcweir                     }
518*cdf0e10cSrcweir                     else
519*cdf0e10cSrcweir                         pButtonWidget->URL = sURL;
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir                     pButtonWidget->Submit = false;
522*cdf0e10cSrcweir                 }
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir                // TODO:
525*cdf0e10cSrcweir                 // In PDF files, buttons are either reset, url or submit buttons. So if we have a simple PUSH button
526*cdf0e10cSrcweir                 // in a document, then this means that we do not export a SubmitToURL, which means that in PDF,
527*cdf0e10cSrcweir                 // the button is used as reset button.
528*cdf0e10cSrcweir                 // Is this desired? If no, we would have to reset _rpDescriptor to NULL here, in case eButtonType
529*cdf0e10cSrcweir                 // != FormButtonType_SUBMIT && != FormButtonType_RESET
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir                 // the PDF exporter defaults the text style, if 0. To prevent this, we have to transfer the UNO
532*cdf0e10cSrcweir                 // defaults to the PDF widget
533*cdf0e10cSrcweir                 if ( !pButtonWidget->TextStyle )
534*cdf0e10cSrcweir                     pButtonWidget->TextStyle = TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER;
535*cdf0e10cSrcweir             }
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir             // --------------------------------
538*cdf0e10cSrcweir             // check boxes
539*cdf0e10cSrcweir             if ( _rpDescriptor->getType() == ::vcl::PDFWriter::CheckBox )
540*cdf0e10cSrcweir             {
541*cdf0e10cSrcweir                 ::vcl::PDFWriter::CheckBoxWidget* pCheckBoxWidget = static_cast< ::vcl::PDFWriter::CheckBoxWidget* >( _rpDescriptor.get() );
542*cdf0e10cSrcweir                 sal_Int16 nState = 0;
543*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_STATE ) >>= nState );
544*cdf0e10cSrcweir                 pCheckBoxWidget->Checked = ( nState != 0 );
545*cdf0e10cSrcweir             }
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir             // --------------------------------
548*cdf0e10cSrcweir             // radio buttons
549*cdf0e10cSrcweir             if ( _rpDescriptor->getType() == ::vcl::PDFWriter::RadioButton )
550*cdf0e10cSrcweir             {
551*cdf0e10cSrcweir                 ::vcl::PDFWriter::RadioButtonWidget* pRadioWidget = static_cast< ::vcl::PDFWriter::RadioButtonWidget* >( _rpDescriptor.get() );
552*cdf0e10cSrcweir                 sal_Int16 nState = 0;
553*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_STATE ) >>= nState );
554*cdf0e10cSrcweir                 pRadioWidget->Selected = ( nState != 0 );
555*cdf0e10cSrcweir                 pRadioWidget->RadioGroup = determineRadioGroupId( xModelProps );
556*cdf0e10cSrcweir                 try
557*cdf0e10cSrcweir                 {
558*cdf0e10cSrcweir                     xModelProps->getPropertyValue( FM_PROP_REFVALUE ) >>= pRadioWidget->OnValue;
559*cdf0e10cSrcweir                 }
560*cdf0e10cSrcweir                 catch(...)
561*cdf0e10cSrcweir                 {
562*cdf0e10cSrcweir                     pRadioWidget->OnValue = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "On" ) );
563*cdf0e10cSrcweir                 }
564*cdf0e10cSrcweir             }
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir             // --------------------------------
567*cdf0e10cSrcweir             // list boxes
568*cdf0e10cSrcweir             if ( _rpDescriptor->getType() == ::vcl::PDFWriter::ListBox )
569*cdf0e10cSrcweir             {
570*cdf0e10cSrcweir                 ::vcl::PDFWriter::ListBoxWidget* pListWidget = static_cast< ::vcl::PDFWriter::ListBoxWidget* >( _rpDescriptor.get() );
571*cdf0e10cSrcweir                 // ............................
572*cdf0e10cSrcweir                 // drop down
573*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_DROPDOWN ) >>= pListWidget->DropDown );
574*cdf0e10cSrcweir                 // ............................
575*cdf0e10cSrcweir                 // multi selection
576*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiSelection" ) ) ) >>= pListWidget->MultiSelect );
577*cdf0e10cSrcweir                 // ............................
578*cdf0e10cSrcweir                 // entries
579*cdf0e10cSrcweir                 getStringItemVector( xModelProps, pListWidget->Entries );
580*cdf0e10cSrcweir                 // since we explicitly list the entries in the order in which they appear, they should not be
581*cdf0e10cSrcweir                 // resorted by the PDF viewer
582*cdf0e10cSrcweir                 pListWidget->Sort = false;
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir                 // get selected items
585*cdf0e10cSrcweir                 Sequence< sal_Int16 > aSelectIndices;
586*cdf0e10cSrcweir                 OSL_VERIFY( xModelProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedItems" ) ) ) >>= aSelectIndices );
587*cdf0e10cSrcweir                 if( aSelectIndices.getLength() > 0 )
588*cdf0e10cSrcweir                 {
589*cdf0e10cSrcweir                     pListWidget->SelectedEntries.resize( 0 );
590*cdf0e10cSrcweir                     for( sal_Int32 i = 0; i < aSelectIndices.getLength(); i++ )
591*cdf0e10cSrcweir                     {
592*cdf0e10cSrcweir                         sal_Int16 nIndex = aSelectIndices.getConstArray()[i];
593*cdf0e10cSrcweir                         if( nIndex >= 0 && nIndex < (sal_Int16)pListWidget->Entries.size() )
594*cdf0e10cSrcweir                             pListWidget->SelectedEntries.push_back( nIndex );
595*cdf0e10cSrcweir                     }
596*cdf0e10cSrcweir                 }
597*cdf0e10cSrcweir             }
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir             // --------------------------------
600*cdf0e10cSrcweir             // combo boxes
601*cdf0e10cSrcweir             if ( _rpDescriptor->getType() == ::vcl::PDFWriter::ComboBox )
602*cdf0e10cSrcweir             {
603*cdf0e10cSrcweir                 ::vcl::PDFWriter::ComboBoxWidget* pComboWidget = static_cast< ::vcl::PDFWriter::ComboBoxWidget* >( _rpDescriptor.get() );
604*cdf0e10cSrcweir                 // ............................
605*cdf0e10cSrcweir                 // entries
606*cdf0e10cSrcweir                 getStringItemVector( xModelProps, pComboWidget->Entries );
607*cdf0e10cSrcweir                 // same reasoning as above
608*cdf0e10cSrcweir                 pComboWidget->Sort = false;
609*cdf0e10cSrcweir             }
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir             // ================================
612*cdf0e10cSrcweir             // some post-processing
613*cdf0e10cSrcweir             // --------------------------------
614*cdf0e10cSrcweir             // text line ends
615*cdf0e10cSrcweir             // some controls may (always or dependent on other settings) return UNIX line ends
616*cdf0e10cSrcweir             String aConverter( _rpDescriptor->Text );
617*cdf0e10cSrcweir             _rpDescriptor->Text = aConverter.ConvertLineEnd( LINEEND_CRLF );
618*cdf0e10cSrcweir         }
619*cdf0e10cSrcweir         catch( const Exception& )
620*cdf0e10cSrcweir         {
621*cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
622*cdf0e10cSrcweir         }
623*cdf0e10cSrcweir     }
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir //........................................................................
626*cdf0e10cSrcweir } // namespace toolkitform
627*cdf0e10cSrcweir //........................................................................
628