xref: /AOO41X/main/oox/source/ole/axcontrol.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 #include "oox/ole/axcontrol.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/awt/FontStrikeout.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/awt/ImagePosition.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/awt/ImageScaleMode.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/awt/ScrollBarOrientation.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/awt/VisualEffect.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/awt/XControlModel.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/form/XFormComponent.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/form/XFormsSupplier.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/form/binding/XBindableValue.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntrySink.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/form/binding/XListEntrySource.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/form/binding/XValueBinding.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
53*cdf0e10cSrcweir #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
54*cdf0e10cSrcweir #include <com/sun/star/style/VerticalAlignment.hpp>
55*cdf0e10cSrcweir #include <com/sun/star/table/CellAddress.hpp>
56*cdf0e10cSrcweir #include <com/sun/star/table/CellRangeAddress.hpp>
57*cdf0e10cSrcweir #include <rtl/tencinfo.h>
58*cdf0e10cSrcweir #include "oox/helper/attributelist.hxx"
59*cdf0e10cSrcweir #include "oox/helper/binaryinputstream.hxx"
60*cdf0e10cSrcweir #include "oox/helper/containerhelper.hxx"
61*cdf0e10cSrcweir #include "oox/helper/graphichelper.hxx"
62*cdf0e10cSrcweir #include "oox/helper/propertymap.hxx"
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir namespace oox {
65*cdf0e10cSrcweir namespace ole {
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir // ============================================================================
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir using namespace ::com::sun::star::awt;
70*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
71*cdf0e10cSrcweir using namespace ::com::sun::star::container;
72*cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
73*cdf0e10cSrcweir using namespace ::com::sun::star::form;
74*cdf0e10cSrcweir using namespace ::com::sun::star::form::binding;
75*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
76*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
77*cdf0e10cSrcweir using namespace ::com::sun::star::sheet;
78*cdf0e10cSrcweir using namespace ::com::sun::star::style;
79*cdf0e10cSrcweir using namespace ::com::sun::star::table;
80*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir using ::rtl::OUString;
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir // ============================================================================
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir namespace {
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir const sal_uInt32 COMCTL_ID_SIZE             = 0x12344321;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir const sal_uInt32 COMCTL_ID_COMMONDATA       = 0xABCDEF01;
91*cdf0e10cSrcweir const sal_uInt32 COMCTL_COMMON_FLATBORDER   = 0x00000001;
92*cdf0e10cSrcweir const sal_uInt32 COMCTL_COMMON_ENABLED      = 0x00000002;
93*cdf0e10cSrcweir const sal_uInt32 COMCTL_COMMON_3DBORDER     = 0x00000004;
94*cdf0e10cSrcweir const sal_uInt32 COMCTL_COMMON_OLEDROPMAN   = 0x00002000;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir const sal_uInt32 COMCTL_ID_COMPLEXDATA      = 0xBDECDE1F;
97*cdf0e10cSrcweir const sal_uInt32 COMCTL_COMPLEX_FONT        = 0x00000001;
98*cdf0e10cSrcweir const sal_uInt32 COMCTL_COMPLEX_MOUSEICON   = 0x00000002;
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir const sal_uInt32 COMCTL_ID_SCROLLBAR_60     = 0x99470A83;
101*cdf0e10cSrcweir const sal_uInt32 COMCTL_SCROLLBAR_HOR       = 0x00000010;
102*cdf0e10cSrcweir const sal_Int32 COMCTL_SCROLLBAR_3D         = 0;
103*cdf0e10cSrcweir const sal_Int32 COMCTL_SCROLLBAR_FLAT       = 1;
104*cdf0e10cSrcweir const sal_Int32 COMCTL_SCROLLBAR_TRACK3D    = 2;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir const sal_uInt32 COMCTL_ID_PROGRESSBAR_50   = 0xE6E17E84;
107*cdf0e10cSrcweir const sal_uInt32 COMCTL_ID_PROGRESSBAR_60   = 0x97AB8A01;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir // ----------------------------------------------------------------------------
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir const sal_uInt32 AX_CMDBUTTON_DEFFLAGS      = 0x0000001B;
112*cdf0e10cSrcweir const sal_uInt32 AX_LABEL_DEFFLAGS          = 0x0080001B;
113*cdf0e10cSrcweir const sal_uInt32 AX_IMAGE_DEFFLAGS          = 0x0000001B;
114*cdf0e10cSrcweir const sal_uInt32 AX_MORPHDATA_DEFFLAGS      = 0x2C80081B;
115*cdf0e10cSrcweir const sal_uInt32 AX_SPINBUTTON_DEFFLAGS     = 0x0000001B;
116*cdf0e10cSrcweir const sal_uInt32 AX_SCROLLBAR_DEFFLAGS      = 0x0000001B;
117*cdf0e10cSrcweir const sal_uInt32 AX_TABSTRIP_DEFFLAGS       = 0x0000001B;
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir const sal_uInt16 AX_POS_TOPLEFT             = 0;
120*cdf0e10cSrcweir const sal_uInt16 AX_POS_TOP                 = 1;
121*cdf0e10cSrcweir const sal_uInt16 AX_POS_TOPRIGHT            = 2;
122*cdf0e10cSrcweir const sal_uInt16 AX_POS_LEFT                = 3;
123*cdf0e10cSrcweir const sal_uInt16 AX_POS_CENTER              = 4;
124*cdf0e10cSrcweir const sal_uInt16 AX_POS_RIGHT               = 5;
125*cdf0e10cSrcweir const sal_uInt16 AX_POS_BOTTOMLEFT          = 6;
126*cdf0e10cSrcweir const sal_uInt16 AX_POS_BOTTOM              = 7;
127*cdf0e10cSrcweir const sal_uInt16 AX_POS_BOTTOMRIGHT         = 8;
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir #define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image)
130*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_LEFTTOP          = AX_PICPOS_IMPL( TOPRIGHT,    TOPLEFT );
131*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_LEFTCENTER       = AX_PICPOS_IMPL( RIGHT,       LEFT );
132*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_LEFTBOTTOM       = AX_PICPOS_IMPL( BOTTOMRIGHT, BOTTOMLEFT );
133*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_RIGHTTOP         = AX_PICPOS_IMPL( TOPLEFT,     TOPRIGHT );
134*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_RIGHTCENTER      = AX_PICPOS_IMPL( LEFT,        RIGHT );
135*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_RIGHTBOTTOM      = AX_PICPOS_IMPL( BOTTOMLEFT,  BOTTOMRIGHT );
136*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_ABOVELEFT        = AX_PICPOS_IMPL( BOTTOMLEFT,  TOPLEFT );
137*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_ABOVECENTER      = AX_PICPOS_IMPL( BOTTOM,      TOP  );
138*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_ABOVERIGHT       = AX_PICPOS_IMPL( BOTTOMRIGHT, TOPRIGHT );
139*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_BELOWLEFT        = AX_PICPOS_IMPL( TOPLEFT,     BOTTOMLEFT );
140*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_BELOWCENTER      = AX_PICPOS_IMPL( TOP,         BOTTOM );
141*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_BELOWRIGHT       = AX_PICPOS_IMPL( TOPRIGHT,    BOTTOMRIGHT );
142*cdf0e10cSrcweir const sal_uInt32 AX_PICPOS_CENTER           = AX_PICPOS_IMPL( CENTER,      CENTER  );
143*cdf0e10cSrcweir #undef AX_PICPOS_IMPL
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir const sal_Int32 AX_MATCHENTRY_FIRSTLETTER   = 0;
146*cdf0e10cSrcweir const sal_Int32 AX_MATCHENTRY_COMPLETE      = 1;
147*cdf0e10cSrcweir const sal_Int32 AX_MATCHENTRY_NONE          = 2;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir const sal_Int32 AX_ORIENTATION_AUTO         = -1;
150*cdf0e10cSrcweir const sal_Int32 AX_ORIENTATION_VERTICAL     = 0;
151*cdf0e10cSrcweir const sal_Int32 AX_ORIENTATION_HORIZONTAL   = 1;
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir const sal_Int32 AX_PROPTHUMB_ON             = -1;
154*cdf0e10cSrcweir const sal_Int32 AX_PROPTHUMB_OFF            = 0;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir const sal_uInt32 AX_TABSTRIP_TABS           = 0;
157*cdf0e10cSrcweir const sal_uInt32 AX_TABSTRIP_BUTTONS        = 1;
158*cdf0e10cSrcweir const sal_uInt32 AX_TABSTRIP_NONE           = 2;
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir const sal_uInt32 AX_CONTAINER_ENABLED       = 0x00000004;
161*cdf0e10cSrcweir const sal_uInt32 AX_CONTAINER_HASDESIGNEXT  = 0x00004000;
162*cdf0e10cSrcweir const sal_uInt32 AX_CONTAINER_NOCLASSTABLE  = 0x00008000;
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir const sal_uInt32 AX_CONTAINER_DEFFLAGS      = 0x00000004;
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_DEFWIDTH       = 4000;
167*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_DEFHEIGHT      = 3000;
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_CYCLEALL       = 0;
170*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_CYCLECURRENT   = 2;
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_SCR_NONE       = 0x00;
173*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_SCR_HOR        = 0x01;
174*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_SCR_VER        = 0x02;
175*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_SCR_KEEP_HOR   = 0x04;
176*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_SCR_KEEP_VER   = 0x08;
177*cdf0e10cSrcweir const sal_Int32 AX_CONTAINER_SCR_SHOW_LEFT  = 0x10;
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir // ----------------------------------------------------------------------------
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir const sal_Int16 API_BORDER_NONE             = 0;
182*cdf0e10cSrcweir const sal_Int16 API_BORDER_SUNKEN           = 1;
183*cdf0e10cSrcweir const sal_Int16 API_BORDER_FLAT             = 2;
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir const sal_Int16 API_STATE_UNCHECKED         = 0;
186*cdf0e10cSrcweir const sal_Int16 API_STATE_CHECKED           = 1;
187*cdf0e10cSrcweir const sal_Int16 API_STATE_DONTKNOW          = 2;
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir // ----------------------------------------------------------------------------
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir /** Tries to extract a range address from a defined name. */
192*cdf0e10cSrcweir bool lclExtractRangeFromName( CellRangeAddress& orRangeAddr, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     try
195*cdf0e10cSrcweir     {
196*cdf0e10cSrcweir         PropertySet aPropSet( rxDocModel );
197*cdf0e10cSrcweir         Reference< XNameAccess > xRangesNA( aPropSet.getAnyProperty( PROP_NamedRanges ), UNO_QUERY_THROW );
198*cdf0e10cSrcweir         Reference< XCellRangeReferrer > xReferrer( xRangesNA->getByName( rAddressString ), UNO_QUERY_THROW );
199*cdf0e10cSrcweir         Reference< XCellRangeAddressable > xAddressable( xReferrer->getReferredCells(), UNO_QUERY_THROW );
200*cdf0e10cSrcweir         orRangeAddr = xAddressable->getRangeAddress();
201*cdf0e10cSrcweir         return true;
202*cdf0e10cSrcweir     }
203*cdf0e10cSrcweir     catch( Exception& )
204*cdf0e10cSrcweir     {
205*cdf0e10cSrcweir     }
206*cdf0e10cSrcweir     return false;
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir bool lclExtractAddressFromName( CellAddress& orAddress, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir     CellRangeAddress aRangeAddr;
212*cdf0e10cSrcweir     if( lclExtractRangeFromName( aRangeAddr, rxDocModel, rAddressString ) &&
213*cdf0e10cSrcweir         (aRangeAddr.StartColumn == aRangeAddr.EndColumn) &&
214*cdf0e10cSrcweir         (aRangeAddr.StartRow == aRangeAddr.EndRow) )
215*cdf0e10cSrcweir     {
216*cdf0e10cSrcweir         orAddress.Sheet = aRangeAddr.Sheet;
217*cdf0e10cSrcweir         orAddress.Column = aRangeAddr.StartColumn;
218*cdf0e10cSrcweir         orAddress.Row = aRangeAddr.StartRow;
219*cdf0e10cSrcweir         return true;
220*cdf0e10cSrcweir     }
221*cdf0e10cSrcweir     return false;
222*cdf0e10cSrcweir }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir void lclPrepareConverter( PropertySet& rConverter, const Reference< XModel >& rxDocModel,
225*cdf0e10cSrcweir         const OUString& rAddressString, sal_Int32 nRefSheet, bool bRange )
226*cdf0e10cSrcweir {
227*cdf0e10cSrcweir     if( !rConverter.is() ) try
228*cdf0e10cSrcweir     {
229*cdf0e10cSrcweir         Reference< XMultiServiceFactory > xModelFactory( rxDocModel, UNO_QUERY_THROW );
230*cdf0e10cSrcweir         OUString aServiceName = bRange ?
231*cdf0e10cSrcweir             CREATE_OUSTRING( "com.sun.star.table.CellRangeAddressConversion" ) :
232*cdf0e10cSrcweir             CREATE_OUSTRING( "com.sun.star.table.CellAddressConversion" );
233*cdf0e10cSrcweir         rConverter.set( xModelFactory->createInstance( aServiceName ) );
234*cdf0e10cSrcweir     }
235*cdf0e10cSrcweir     catch( Exception& )
236*cdf0e10cSrcweir     {
237*cdf0e10cSrcweir     }
238*cdf0e10cSrcweir     rConverter.setProperty( PROP_XLA1Representation, rAddressString );
239*cdf0e10cSrcweir     rConverter.setProperty( PROP_ReferenceSheet, nRefSheet );
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir } // namespace
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir // ============================================================================
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir ControlConverter::ControlConverter( const Reference< XModel >& rxDocModel,
247*cdf0e10cSrcweir         const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
248*cdf0e10cSrcweir     mxDocModel( rxDocModel ),
249*cdf0e10cSrcweir     mrGraphicHelper( rGraphicHelper ),
250*cdf0e10cSrcweir     mbDefaultColorBgr( bDefaultColorBgr )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir     OSL_ENSURE( mxDocModel.is(), "ControlConverter::ControlConverter - missing document model" );
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir ControlConverter::~ControlConverter()
256*cdf0e10cSrcweir {
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir // Generic conversion ---------------------------------------------------------
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const
262*cdf0e10cSrcweir {
263*cdf0e10cSrcweir     // position is given in 1/100 mm, UNO needs AppFont units
264*cdf0e10cSrcweir     Point aAppFontPos = mrGraphicHelper.convertHmmToAppFont( Point( rPos.first, rPos.second ) );
265*cdf0e10cSrcweir     rPropMap.setProperty( PROP_PositionX, aAppFontPos.X );
266*cdf0e10cSrcweir     rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y );
267*cdf0e10cSrcweir }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const
270*cdf0e10cSrcweir {
271*cdf0e10cSrcweir     // size is given in 1/100 mm, UNO needs AppFont units
272*cdf0e10cSrcweir     Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( Size( rSize.first, rSize.second ) );
273*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Width, aAppFontSize.Width );
274*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Height, aAppFontSize.Height );
275*cdf0e10cSrcweir }
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir     rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) );
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir     if( rPicData.hasElements() )
285*cdf0e10cSrcweir     {
286*cdf0e10cSrcweir         OUString aGraphicUrl = mrGraphicHelper.importGraphicObject( rPicData );
287*cdf0e10cSrcweir         if( aGraphicUrl.getLength() > 0 )
288*cdf0e10cSrcweir             rPropMap.setProperty( PROP_ImageURL, aGraphicUrl );
289*cdf0e10cSrcweir     }
290*cdf0e10cSrcweir }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizontal ) const
293*cdf0e10cSrcweir {
294*cdf0e10cSrcweir     sal_Int32 nScrollOrient = bHorizontal ? ScrollBarOrientation::HORIZONTAL : ScrollBarOrientation::VERTICAL;
295*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Orientation, nScrollOrient );
296*cdf0e10cSrcweir }
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir void ControlConverter::convertVerticalAlign( PropertyMap& rPropMap, sal_Int32 nVerticalAlign ) const
299*cdf0e10cSrcweir {
300*cdf0e10cSrcweir     VerticalAlignment eAlign = VerticalAlignment_TOP;
301*cdf0e10cSrcweir     switch( nVerticalAlign )
302*cdf0e10cSrcweir     {
303*cdf0e10cSrcweir         case XML_Top:       eAlign = VerticalAlignment_TOP;     break;
304*cdf0e10cSrcweir         case XML_Center:    eAlign = VerticalAlignment_MIDDLE;  break;
305*cdf0e10cSrcweir         case XML_Bottom:    eAlign = VerticalAlignment_BOTTOM;  break;
306*cdf0e10cSrcweir     }
307*cdf0e10cSrcweir     rPropMap.setProperty( PROP_VerticalAlign, eAlign );
308*cdf0e10cSrcweir }
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir void ControlConverter::convertScrollBar( PropertyMap& rPropMap,
311*cdf0e10cSrcweir         sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
312*cdf0e10cSrcweir         sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const
313*cdf0e10cSrcweir {
314*cdf0e10cSrcweir     rPropMap.setProperty( PROP_ScrollValueMin, ::std::min( nMin, nMax ) );
315*cdf0e10cSrcweir     rPropMap.setProperty( PROP_ScrollValueMax, ::std::max( nMin, nMax ) );
316*cdf0e10cSrcweir     rPropMap.setProperty( PROP_LineIncrement, nSmallChange );
317*cdf0e10cSrcweir     rPropMap.setProperty( PROP_BlockIncrement, nLargeChange );
318*cdf0e10cSrcweir     rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition );
319*cdf0e10cSrcweir }
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlModel,
322*cdf0e10cSrcweir         const OUString& rCtrlSource, const OUString& rRowSource, sal_Int32 nRefSheet ) const
323*cdf0e10cSrcweir {
324*cdf0e10cSrcweir     // value binding
325*cdf0e10cSrcweir     if( rCtrlSource.getLength() > 0 ) try
326*cdf0e10cSrcweir     {
327*cdf0e10cSrcweir         // first check if the XBindableValue interface is supported
328*cdf0e10cSrcweir         Reference< XBindableValue > xBindable( rxCtrlModel, UNO_QUERY_THROW );
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir         // convert address string to cell address struct
331*cdf0e10cSrcweir         CellAddress aAddress;
332*cdf0e10cSrcweir         if( !lclExtractAddressFromName( aAddress, mxDocModel, rCtrlSource ) )
333*cdf0e10cSrcweir         {
334*cdf0e10cSrcweir             lclPrepareConverter( maAddressConverter, mxDocModel, rCtrlSource, nRefSheet, false );
335*cdf0e10cSrcweir             if( !maAddressConverter.getProperty( aAddress, PROP_Address ) )
336*cdf0e10cSrcweir                 throw RuntimeException();
337*cdf0e10cSrcweir         }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir         // create argument sequence
340*cdf0e10cSrcweir         NamedValue aValue;
341*cdf0e10cSrcweir         aValue.Name = CREATE_OUSTRING( "BoundCell" );
342*cdf0e10cSrcweir         aValue.Value <<= aAddress;
343*cdf0e10cSrcweir         Sequence< Any > aArgs( 1 );
344*cdf0e10cSrcweir         aArgs[ 0 ] <<= aValue;
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir         // create the CellValueBinding instance and set at the control model
347*cdf0e10cSrcweir         Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
348*cdf0e10cSrcweir         Reference< XValueBinding > xBinding( xModelFactory->createInstanceWithArguments(
349*cdf0e10cSrcweir             CREATE_OUSTRING( "com.sun.star.table.CellValueBinding" ), aArgs ), UNO_QUERY_THROW );
350*cdf0e10cSrcweir         xBindable->setValueBinding( xBinding );
351*cdf0e10cSrcweir     }
352*cdf0e10cSrcweir     catch( Exception& )
353*cdf0e10cSrcweir     {
354*cdf0e10cSrcweir     }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     // list entry source
357*cdf0e10cSrcweir     if( rRowSource.getLength() > 0 ) try
358*cdf0e10cSrcweir     {
359*cdf0e10cSrcweir         // first check if the XListEntrySink interface is supported
360*cdf0e10cSrcweir         Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir         // convert address string to cell range address struct
363*cdf0e10cSrcweir         CellRangeAddress aRangeAddr;
364*cdf0e10cSrcweir         if( !lclExtractRangeFromName( aRangeAddr, mxDocModel, rRowSource ) )
365*cdf0e10cSrcweir         {
366*cdf0e10cSrcweir             lclPrepareConverter( maRangeConverter, mxDocModel, rRowSource, nRefSheet, true );
367*cdf0e10cSrcweir             if( !maRangeConverter.getProperty( aRangeAddr, PROP_Address ) )
368*cdf0e10cSrcweir                 throw RuntimeException();
369*cdf0e10cSrcweir         }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir         // create argument sequence
372*cdf0e10cSrcweir         NamedValue aValue;
373*cdf0e10cSrcweir         aValue.Name = CREATE_OUSTRING( "CellRange" );
374*cdf0e10cSrcweir         aValue.Value <<= aRangeAddr;
375*cdf0e10cSrcweir         Sequence< Any > aArgs( 1 );
376*cdf0e10cSrcweir         aArgs[ 0 ] <<= aValue;
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir         // create the EntrySource instance and set at the control model
379*cdf0e10cSrcweir         Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
380*cdf0e10cSrcweir         Reference< XListEntrySource > xEntrySource( xModelFactory->createInstanceWithArguments(
381*cdf0e10cSrcweir             CREATE_OUSTRING( "com.sun.star.table.CellRangeListSource"  ), aArgs ), UNO_QUERY_THROW );
382*cdf0e10cSrcweir         xEntrySink->setListEntrySource( xEntrySource );
383*cdf0e10cSrcweir     }
384*cdf0e10cSrcweir     catch( Exception& )
385*cdf0e10cSrcweir     {
386*cdf0e10cSrcweir     }
387*cdf0e10cSrcweir }
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir // ActiveX (Forms 2.0) specific conversion ------------------------------------
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir void ControlConverter::convertAxBackground( PropertyMap& rPropMap,
392*cdf0e10cSrcweir         sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) const
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir     bool bOpaque = getFlag( nFlags, AX_FLAGS_OPAQUE );
395*cdf0e10cSrcweir     switch( eTranspMode )
396*cdf0e10cSrcweir     {
397*cdf0e10cSrcweir         case API_TRANSPARENCY_NOTSUPPORTED:
398*cdf0e10cSrcweir             // fake transparency by using system window background if needed
399*cdf0e10cSrcweir             convertColor( rPropMap, PROP_BackgroundColor, bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK );
400*cdf0e10cSrcweir         break;
401*cdf0e10cSrcweir         case API_TRANSPARENCY_PAINTTRANSPARENT:
402*cdf0e10cSrcweir             rPropMap.setProperty( PROP_PaintTransparent, !bOpaque );
403*cdf0e10cSrcweir             // run-through intended!
404*cdf0e10cSrcweir         case API_TRANSPARENCY_VOID:
405*cdf0e10cSrcweir             // keep transparency by leaving the (void) default property value
406*cdf0e10cSrcweir             if( bOpaque )
407*cdf0e10cSrcweir                 convertColor( rPropMap, PROP_BackgroundColor, nBackColor );
408*cdf0e10cSrcweir         break;
409*cdf0e10cSrcweir     }
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir void ControlConverter::convertAxBorder( PropertyMap& rPropMap,
413*cdf0e10cSrcweir         sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) const
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir     sal_Int16 nBorder = (nBorderStyle == AX_BORDERSTYLE_SINGLE) ? API_BORDER_FLAT :
416*cdf0e10cSrcweir         ((nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? API_BORDER_NONE : API_BORDER_SUNKEN);
417*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Border, nBorder );
418*cdf0e10cSrcweir     convertColor( rPropMap, PROP_BorderColor, nBorderColor );
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect ) const
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir     sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? VisualEffect::FLAT : VisualEffect::LOOK3D;
424*cdf0e10cSrcweir     rPropMap.setProperty( PROP_VisualEffect, nVisualEffect );
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const
428*cdf0e10cSrcweir {
429*cdf0e10cSrcweir     // the picture
430*cdf0e10cSrcweir     convertPicture( rPropMap, rPicData );
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir     // picture position
433*cdf0e10cSrcweir     sal_Int16 nImagePos = ImagePosition::LeftCenter;
434*cdf0e10cSrcweir     switch( nPicPos )
435*cdf0e10cSrcweir     {
436*cdf0e10cSrcweir         case AX_PICPOS_LEFTTOP:     nImagePos = ImagePosition::LeftTop;     break;
437*cdf0e10cSrcweir         case AX_PICPOS_LEFTCENTER:  nImagePos = ImagePosition::LeftCenter;  break;
438*cdf0e10cSrcweir         case AX_PICPOS_LEFTBOTTOM:  nImagePos = ImagePosition::LeftBottom;  break;
439*cdf0e10cSrcweir         case AX_PICPOS_RIGHTTOP:    nImagePos = ImagePosition::RightTop;    break;
440*cdf0e10cSrcweir         case AX_PICPOS_RIGHTCENTER: nImagePos = ImagePosition::RightCenter; break;
441*cdf0e10cSrcweir         case AX_PICPOS_RIGHTBOTTOM: nImagePos = ImagePosition::RightBottom; break;
442*cdf0e10cSrcweir         case AX_PICPOS_ABOVELEFT:   nImagePos = ImagePosition::AboveLeft;   break;
443*cdf0e10cSrcweir         case AX_PICPOS_ABOVECENTER: nImagePos = ImagePosition::AboveCenter; break;
444*cdf0e10cSrcweir         case AX_PICPOS_ABOVERIGHT:  nImagePos = ImagePosition::AboveRight;  break;
445*cdf0e10cSrcweir         case AX_PICPOS_BELOWLEFT:   nImagePos = ImagePosition::BelowLeft;   break;
446*cdf0e10cSrcweir         case AX_PICPOS_BELOWCENTER: nImagePos = ImagePosition::BelowCenter; break;
447*cdf0e10cSrcweir         case AX_PICPOS_BELOWRIGHT:  nImagePos = ImagePosition::BelowRight;  break;
448*cdf0e10cSrcweir         case AX_PICPOS_CENTER:      nImagePos = ImagePosition::Centered;    break;
449*cdf0e10cSrcweir         default:    OSL_ENSURE( false, "ControlConverter::convertAxPicture - unknown picture position" );
450*cdf0e10cSrcweir     }
451*cdf0e10cSrcweir     rPropMap.setProperty( PROP_ImagePosition, nImagePos );
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData,
455*cdf0e10cSrcweir         sal_Int32 nPicSizeMode, sal_Int32 /*nPicAlign*/, bool /*bPicTiling*/ ) const
456*cdf0e10cSrcweir {
457*cdf0e10cSrcweir     // the picture
458*cdf0e10cSrcweir     convertPicture( rPropMap, rPicData );
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir     // picture scale mode
461*cdf0e10cSrcweir     sal_Int16 nScaleMode = ImageScaleMode::None;
462*cdf0e10cSrcweir     switch( nPicSizeMode )
463*cdf0e10cSrcweir     {
464*cdf0e10cSrcweir         case AX_PICSIZE_CLIP:       nScaleMode = ImageScaleMode::None;          break;
465*cdf0e10cSrcweir         case AX_PICSIZE_STRETCH:    nScaleMode = ImageScaleMode::Anisotropic;   break;
466*cdf0e10cSrcweir         case AX_PICSIZE_ZOOM:       nScaleMode = ImageScaleMode::Isotropic;     break;
467*cdf0e10cSrcweir         default:    OSL_ENSURE( false, "ControlConverter::convertAxPicture - unknown picture size mode" );
468*cdf0e10cSrcweir     }
469*cdf0e10cSrcweir     rPropMap.setProperty( PROP_ScaleMode, nScaleMode );
470*cdf0e10cSrcweir }
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir void ControlConverter::convertAxState( PropertyMap& rPropMap,
473*cdf0e10cSrcweir         const OUString& rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel ) const
474*cdf0e10cSrcweir {
475*cdf0e10cSrcweir     bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN;
476*cdf0e10cSrcweir     bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir     // state
479*cdf0e10cSrcweir     sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED;
480*cdf0e10cSrcweir     if( rValue.getLength() == 1 ) switch( rValue[ 0 ] )
481*cdf0e10cSrcweir     {
482*cdf0e10cSrcweir         case '0':   nState = API_STATE_UNCHECKED;   break;
483*cdf0e10cSrcweir         case '1':   nState = API_STATE_CHECKED;     break;
484*cdf0e10cSrcweir         // any other string (also empty) means 'dontknow'
485*cdf0e10cSrcweir     }
486*cdf0e10cSrcweir     sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState;
487*cdf0e10cSrcweir     if( bBooleanState )
488*cdf0e10cSrcweir         rPropMap.setProperty( nPropId, nState != API_STATE_UNCHECKED );
489*cdf0e10cSrcweir     else
490*cdf0e10cSrcweir         rPropMap.setProperty( nPropId, nState );
491*cdf0e10cSrcweir 
492*cdf0e10cSrcweir     // tristate
493*cdf0e10cSrcweir     if( bSupportsTriState )
494*cdf0e10cSrcweir         rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELCTION_MULTI );
495*cdf0e10cSrcweir }
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir void ControlConverter::convertAxOrientation( PropertyMap& rPropMap,
498*cdf0e10cSrcweir         const AxPairData& rSize, sal_Int32 nOrientation ) const
499*cdf0e10cSrcweir {
500*cdf0e10cSrcweir     bool bHorizontal = true;
501*cdf0e10cSrcweir     switch( nOrientation )
502*cdf0e10cSrcweir     {
503*cdf0e10cSrcweir         case AX_ORIENTATION_AUTO:       bHorizontal = rSize.first > rSize.second;   break;
504*cdf0e10cSrcweir         case AX_ORIENTATION_VERTICAL:   bHorizontal = false;                        break;
505*cdf0e10cSrcweir         case AX_ORIENTATION_HORIZONTAL: bHorizontal = true;                         break;
506*cdf0e10cSrcweir         default:    OSL_ENSURE( false, "ControlConverter::convertAxOrientation - unknown orientation" );
507*cdf0e10cSrcweir     }
508*cdf0e10cSrcweir     convertOrientation( rPropMap, bHorizontal );
509*cdf0e10cSrcweir }
510*cdf0e10cSrcweir 
511*cdf0e10cSrcweir // ============================================================================
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir ControlModelBase::ControlModelBase() :
514*cdf0e10cSrcweir     maSize( 0, 0 ),
515*cdf0e10cSrcweir     mbAwtModel( false )
516*cdf0e10cSrcweir {
517*cdf0e10cSrcweir }
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir ControlModelBase::~ControlModelBase()
520*cdf0e10cSrcweir {
521*cdf0e10cSrcweir }
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir OUString ControlModelBase::getServiceName() const
524*cdf0e10cSrcweir {
525*cdf0e10cSrcweir     ApiControlType eCtrlType = getControlType();
526*cdf0e10cSrcweir     if( mbAwtModel ) switch( eCtrlType )
527*cdf0e10cSrcweir     {
528*cdf0e10cSrcweir         case API_CONTROL_BUTTON:        return CREATE_OUSTRING( "com.sun.star.awt.UnoControlButtonModel" );
529*cdf0e10cSrcweir         case API_CONTROL_FIXEDTEXT:     return CREATE_OUSTRING( "com.sun.star.awt.UnoControlFixedTextModel" );
530*cdf0e10cSrcweir         case API_CONTROL_IMAGE:         return CREATE_OUSTRING( "com.sun.star.awt.UnoControlImageControlModel" );
531*cdf0e10cSrcweir         case API_CONTROL_CHECKBOX:      return CREATE_OUSTRING( "com.sun.star.awt.UnoControlCheckBoxModel" );
532*cdf0e10cSrcweir         case API_CONTROL_RADIOBUTTON:   return CREATE_OUSTRING( "com.sun.star.awt.UnoControlRadioButtonModel" );
533*cdf0e10cSrcweir         case API_CONTROL_EDIT:          return CREATE_OUSTRING( "com.sun.star.awt.UnoControlEditModel" );
534*cdf0e10cSrcweir         case API_CONTROL_NUMERIC:       return CREATE_OUSTRING( "com.sun.star.awt.UnoControlNumericFieldModel" );
535*cdf0e10cSrcweir         case API_CONTROL_LISTBOX:       return CREATE_OUSTRING( "com.sun.star.awt.UnoControlListBoxModel" );
536*cdf0e10cSrcweir         case API_CONTROL_COMBOBOX:      return CREATE_OUSTRING( "com.sun.star.awt.UnoControlComboBoxModel" );
537*cdf0e10cSrcweir         case API_CONTROL_SPINBUTTON:    return CREATE_OUSTRING( "com.sun.star.awt.UnoControlSpinButtonModel" );
538*cdf0e10cSrcweir         case API_CONTROL_SCROLLBAR:     return CREATE_OUSTRING( "com.sun.star.awt.UnoControlScrollBarModel" );
539*cdf0e10cSrcweir         case API_CONTROL_PROGRESSBAR:   return CREATE_OUSTRING( "com.sun.star.awt.UnoControlProgressBarModel" );
540*cdf0e10cSrcweir         case API_CONTROL_GROUPBOX:      return CREATE_OUSTRING( "com.sun.star.awt.UnoControlGroupBoxModel" );
541*cdf0e10cSrcweir         case API_CONTROL_DIALOG:        return CREATE_OUSTRING( "com.sun.star.awt.UnoControlDialogModel" );
542*cdf0e10cSrcweir         default:    OSL_ENSURE( false, "ControlModelBase::getServiceName - no AWT model service supported" );
543*cdf0e10cSrcweir     }
544*cdf0e10cSrcweir     else switch( eCtrlType )
545*cdf0e10cSrcweir     {
546*cdf0e10cSrcweir         case API_CONTROL_BUTTON:        return CREATE_OUSTRING( "com.sun.star.form.component.CommandButton" );
547*cdf0e10cSrcweir         case API_CONTROL_FIXEDTEXT:     return CREATE_OUSTRING( "com.sun.star.form.component.FixedText" );
548*cdf0e10cSrcweir         case API_CONTROL_IMAGE:         return CREATE_OUSTRING( "com.sun.star.form.component.DatabaseImageControl" );
549*cdf0e10cSrcweir         case API_CONTROL_CHECKBOX:      return CREATE_OUSTRING( "com.sun.star.form.component.CheckBox" );
550*cdf0e10cSrcweir         case API_CONTROL_RADIOBUTTON:   return CREATE_OUSTRING( "com.sun.star.form.component.RadioButton" );
551*cdf0e10cSrcweir         case API_CONTROL_EDIT:          return CREATE_OUSTRING( "com.sun.star.form.component.TextField" );
552*cdf0e10cSrcweir         case API_CONTROL_NUMERIC:       return CREATE_OUSTRING( "com.sun.star.form.component.NumericField" );
553*cdf0e10cSrcweir         case API_CONTROL_LISTBOX:       return CREATE_OUSTRING( "com.sun.star.form.component.ListBox" );
554*cdf0e10cSrcweir         case API_CONTROL_COMBOBOX:      return CREATE_OUSTRING( "com.sun.star.form.component.ComboBox" );
555*cdf0e10cSrcweir         case API_CONTROL_SPINBUTTON:    return CREATE_OUSTRING( "com.sun.star.form.component.SpinButton" );
556*cdf0e10cSrcweir         case API_CONTROL_SCROLLBAR:     return CREATE_OUSTRING( "com.sun.star.form.component.ScrollBar" );
557*cdf0e10cSrcweir         case API_CONTROL_GROUPBOX:      return CREATE_OUSTRING( "com.sun.star.form.component.GroupBox" );
558*cdf0e10cSrcweir         default:    OSL_ENSURE( false, "ControlModelBase::getServiceName - no form component service supported" );
559*cdf0e10cSrcweir     }
560*cdf0e10cSrcweir     return OUString();
561*cdf0e10cSrcweir }
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir void ControlModelBase::importProperty( sal_Int32 /*nPropId*/, const OUString& /*rValue*/ )
564*cdf0e10cSrcweir {
565*cdf0e10cSrcweir }
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir void ControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ )
568*cdf0e10cSrcweir {
569*cdf0e10cSrcweir }
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const ControlConverter& /*rConv*/ ) const
572*cdf0e10cSrcweir {
573*cdf0e10cSrcweir }
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const
576*cdf0e10cSrcweir {
577*cdf0e10cSrcweir     rConv.convertSize( rPropMap, maSize );
578*cdf0e10cSrcweir }
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir // ============================================================================
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6,
583*cdf0e10cSrcweir         sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) :
584*cdf0e10cSrcweir     maFontData( CREATE_OUSTRING( "Tahoma" ), 82500 ),
585*cdf0e10cSrcweir     mnFlags( 0 ),
586*cdf0e10cSrcweir     mnVersion( nVersion ),
587*cdf0e10cSrcweir     mnDataPartId5( nDataPartId5 ),
588*cdf0e10cSrcweir     mnDataPartId6( nDataPartId6 ),
589*cdf0e10cSrcweir     mbCommonPart( bCommonPart ),
590*cdf0e10cSrcweir     mbComplexPart( bComplexPart )
591*cdf0e10cSrcweir {
592*cdf0e10cSrcweir }
593*cdf0e10cSrcweir 
594*cdf0e10cSrcweir bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm )
595*cdf0e10cSrcweir {
596*cdf0e10cSrcweir     // read initial size part and header of the control data part
597*cdf0e10cSrcweir     if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) )
598*cdf0e10cSrcweir     {
599*cdf0e10cSrcweir         // if flags part exists, the first int32 of the data part contains its size
600*cdf0e10cSrcweir         sal_uInt32 nCommonPartSize = mbCommonPart ? rInStrm.readuInt32() : 0;
601*cdf0e10cSrcweir         // implementations must read the exact amount of data, stream must point to its end afterwards
602*cdf0e10cSrcweir         importControlData( rInStrm );
603*cdf0e10cSrcweir         // read following parts
604*cdf0e10cSrcweir         if( !rInStrm.isEof() &&
605*cdf0e10cSrcweir             (!mbCommonPart || importCommonPart( rInStrm, nCommonPartSize )) &&
606*cdf0e10cSrcweir             (!mbComplexPart || importComplexPart( rInStrm )) )
607*cdf0e10cSrcweir         {
608*cdf0e10cSrcweir             return !rInStrm.isEof();
609*cdf0e10cSrcweir         }
610*cdf0e10cSrcweir     }
611*cdf0e10cSrcweir     return false;
612*cdf0e10cSrcweir }
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir void ComCtlModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
615*cdf0e10cSrcweir {
616*cdf0e10cSrcweir     if( mbCommonPart )
617*cdf0e10cSrcweir         rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, COMCTL_COMMON_ENABLED ) );
618*cdf0e10cSrcweir     ControlModelBase::convertProperties( rPropMap, rConv );
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir void ComCtlModelBase::importCommonExtraData( BinaryInputStream& /*rInStrm*/ )
622*cdf0e10cSrcweir {
623*cdf0e10cSrcweir }
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir void ComCtlModelBase::importCommonTrailingData( BinaryInputStream& /*rInStrm*/ )
626*cdf0e10cSrcweir {
627*cdf0e10cSrcweir }
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir sal_uInt32 ComCtlModelBase::getDataPartId() const
630*cdf0e10cSrcweir {
631*cdf0e10cSrcweir     switch( mnVersion )
632*cdf0e10cSrcweir     {
633*cdf0e10cSrcweir         case COMCTL_VERSION_50: return mnDataPartId5;
634*cdf0e10cSrcweir         case COMCTL_VERSION_60: return mnDataPartId6;
635*cdf0e10cSrcweir     }
636*cdf0e10cSrcweir     OSL_ENSURE( false, "ComCtlObjectBase::getDataPartId - unxpected version" );
637*cdf0e10cSrcweir     return SAL_MAX_UINT32;
638*cdf0e10cSrcweir }
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
641*cdf0e10cSrcweir {
642*cdf0e10cSrcweir     // no idea if all this is correct...
643*cdf0e10cSrcweir     sal_uInt32 nPartId;
644*cdf0e10cSrcweir     sal_uInt16 nMajor, nMinor;
645*cdf0e10cSrcweir     rInStrm >> nPartId >> nMinor >> nMajor;
646*cdf0e10cSrcweir     bool bPartId = nPartId == nExpPartId;
647*cdf0e10cSrcweir     OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" );
648*cdf0e10cSrcweir     bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
649*cdf0e10cSrcweir     OSL_ENSURE( bVersion, "ComCtlObjectBase::readPartHeader - unexpected part version" );
650*cdf0e10cSrcweir     return !rInStrm.isEof() && bPartId && bVersion;
651*cdf0e10cSrcweir }
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm )
654*cdf0e10cSrcweir {
655*cdf0e10cSrcweir     if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) )
656*cdf0e10cSrcweir     {
657*cdf0e10cSrcweir         rInStrm >> maSize.first >> maSize.second;
658*cdf0e10cSrcweir         return !rInStrm.isEof();
659*cdf0e10cSrcweir     }
660*cdf0e10cSrcweir     return false;
661*cdf0e10cSrcweir }
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize )
664*cdf0e10cSrcweir {
665*cdf0e10cSrcweir     sal_Int64 nEndPos = rInStrm.tell() + nPartSize;
666*cdf0e10cSrcweir     if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) )
667*cdf0e10cSrcweir     {
668*cdf0e10cSrcweir         rInStrm.skip( 4 );
669*cdf0e10cSrcweir         rInStrm >> mnFlags;
670*cdf0e10cSrcweir         // implementations may read less than the exact amount of data
671*cdf0e10cSrcweir         importCommonExtraData( rInStrm );
672*cdf0e10cSrcweir         rInStrm.seek( nEndPos );
673*cdf0e10cSrcweir         // implementations must read the exact amount of data, stream must point to its end afterwards
674*cdf0e10cSrcweir         importCommonTrailingData( rInStrm );
675*cdf0e10cSrcweir         return !rInStrm.isEof();
676*cdf0e10cSrcweir     }
677*cdf0e10cSrcweir     return false;
678*cdf0e10cSrcweir }
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm )
681*cdf0e10cSrcweir {
682*cdf0e10cSrcweir     if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) )
683*cdf0e10cSrcweir     {
684*cdf0e10cSrcweir         sal_uInt32 nContFlags;
685*cdf0e10cSrcweir         rInStrm >> nContFlags;
686*cdf0e10cSrcweir         bool bReadOk =
687*cdf0e10cSrcweir             (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) &&
688*cdf0e10cSrcweir             (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm, true ));
689*cdf0e10cSrcweir         return bReadOk && !rInStrm.isEof();
690*cdf0e10cSrcweir     }
691*cdf0e10cSrcweir     return false;
692*cdf0e10cSrcweir }
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir // ============================================================================
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion ) :
697*cdf0e10cSrcweir     ComCtlModelBase( SAL_MAX_UINT32, COMCTL_ID_SCROLLBAR_60, nVersion, true, true ),
698*cdf0e10cSrcweir     mnScrollBarFlags( 0x00000011 ),
699*cdf0e10cSrcweir     mnLargeChange( 1 ),
700*cdf0e10cSrcweir     mnSmallChange( 1 ),
701*cdf0e10cSrcweir     mnMin( 0 ),
702*cdf0e10cSrcweir     mnMax( 32767 ),
703*cdf0e10cSrcweir     mnPosition( 0 )
704*cdf0e10cSrcweir {
705*cdf0e10cSrcweir }
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir ApiControlType ComCtlScrollBarModel::getControlType() const
708*cdf0e10cSrcweir {
709*cdf0e10cSrcweir     return API_CONTROL_SCROLLBAR;
710*cdf0e10cSrcweir }
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
713*cdf0e10cSrcweir {
714*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
715*cdf0e10cSrcweir     rConv.convertOrientation( rPropMap, getFlag( mnScrollBarFlags, COMCTL_SCROLLBAR_HOR ) );
716*cdf0e10cSrcweir     rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
717*cdf0e10cSrcweir     ComCtlModelBase::convertProperties( rPropMap, rConv );
718*cdf0e10cSrcweir }
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm )
721*cdf0e10cSrcweir {
722*cdf0e10cSrcweir     rInStrm >> mnScrollBarFlags >> mnLargeChange >> mnSmallChange >> mnMin >> mnMax >> mnPosition;
723*cdf0e10cSrcweir }
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir // ============================================================================
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) :
728*cdf0e10cSrcweir     ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50, COMCTL_ID_PROGRESSBAR_60, nVersion, true, true ),
729*cdf0e10cSrcweir     mfMin( 0.0 ),
730*cdf0e10cSrcweir     mfMax( 100.0 ),
731*cdf0e10cSrcweir     mnVertical( 0 ),
732*cdf0e10cSrcweir     mnSmooth( 0 )
733*cdf0e10cSrcweir {
734*cdf0e10cSrcweir }
735*cdf0e10cSrcweir 
736*cdf0e10cSrcweir ApiControlType ComCtlProgressBarModel::getControlType() const
737*cdf0e10cSrcweir {
738*cdf0e10cSrcweir     return API_CONTROL_PROGRESSBAR;
739*cdf0e10cSrcweir }
740*cdf0e10cSrcweir 
741*cdf0e10cSrcweir void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
742*cdf0e10cSrcweir {
743*cdf0e10cSrcweir     sal_uInt16 nBorder = getFlag( mnFlags, COMCTL_COMMON_3DBORDER ) ? API_BORDER_SUNKEN :
744*cdf0e10cSrcweir         (getFlag( mnFlags, COMCTL_COMMON_FLATBORDER ) ? API_BORDER_FLAT : API_BORDER_NONE);
745*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Border, nBorder );
746*cdf0e10cSrcweir     rPropMap.setProperty( PROP_ProgressValueMin, getLimitedValue< sal_Int32, double >( ::std::min( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
747*cdf0e10cSrcweir     rPropMap.setProperty( PROP_ProgressValueMax, getLimitedValue< sal_Int32, double >( ::std::max( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
748*cdf0e10cSrcweir     // ComCtl model does not provide current value?
749*cdf0e10cSrcweir     ComCtlModelBase::convertProperties( rPropMap, rConv );
750*cdf0e10cSrcweir }
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm )
753*cdf0e10cSrcweir {
754*cdf0e10cSrcweir     rInStrm >> mfMin >> mfMax;
755*cdf0e10cSrcweir     if( mnVersion == COMCTL_VERSION_60 )
756*cdf0e10cSrcweir         rInStrm >> mnVertical >> mnSmooth;
757*cdf0e10cSrcweir }
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir // ============================================================================
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir AxControlModelBase::AxControlModelBase()
762*cdf0e10cSrcweir {
763*cdf0e10cSrcweir }
764*cdf0e10cSrcweir 
765*cdf0e10cSrcweir void AxControlModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
766*cdf0e10cSrcweir {
767*cdf0e10cSrcweir     switch( nPropId )
768*cdf0e10cSrcweir     {
769*cdf0e10cSrcweir         // size of the control shape: format is "width;height"
770*cdf0e10cSrcweir         case XML_Size:
771*cdf0e10cSrcweir         {
772*cdf0e10cSrcweir             sal_Int32 nSepPos = rValue.indexOf( ';' );
773*cdf0e10cSrcweir             OSL_ENSURE( nSepPos >= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" );
774*cdf0e10cSrcweir             if( nSepPos >= 0 )
775*cdf0e10cSrcweir             {
776*cdf0e10cSrcweir                 maSize.first = rValue.copy( 0, nSepPos ).toInt32();
777*cdf0e10cSrcweir                 maSize.second = rValue.copy( nSepPos + 1 ).toInt32();
778*cdf0e10cSrcweir             }
779*cdf0e10cSrcweir         }
780*cdf0e10cSrcweir         break;
781*cdf0e10cSrcweir     }
782*cdf0e10cSrcweir }
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir // ============================================================================
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir AxFontDataModel::AxFontDataModel( bool bSupportsAlign ) :
787*cdf0e10cSrcweir     mbSupportsAlign( bSupportsAlign )
788*cdf0e10cSrcweir {
789*cdf0e10cSrcweir }
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
792*cdf0e10cSrcweir {
793*cdf0e10cSrcweir     switch( nPropId )
794*cdf0e10cSrcweir     {
795*cdf0e10cSrcweir         case XML_FontName:          maFontData.maFontName = rValue;                                             break;
796*cdf0e10cSrcweir         case XML_FontEffects:       maFontData.mnFontEffects = AttributeConversion::decodeUnsigned( rValue );   break;
797*cdf0e10cSrcweir         case XML_FontHeight:        maFontData.mnFontHeight = AttributeConversion::decodeInteger( rValue );     break;
798*cdf0e10cSrcweir         case XML_FontCharSet:       maFontData.mnFontCharSet = AttributeConversion::decodeInteger( rValue );    break;
799*cdf0e10cSrcweir         case XML_ParagraphAlign:    maFontData.mnHorAlign = AttributeConversion::decodeInteger( rValue );       break;
800*cdf0e10cSrcweir         default:                    AxControlModelBase::importProperty( nPropId, rValue );
801*cdf0e10cSrcweir     }
802*cdf0e10cSrcweir }
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm )
805*cdf0e10cSrcweir {
806*cdf0e10cSrcweir     return maFontData.importBinaryModel( rInStrm );
807*cdf0e10cSrcweir }
808*cdf0e10cSrcweir 
809*cdf0e10cSrcweir void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
810*cdf0e10cSrcweir {
811*cdf0e10cSrcweir     // font name
812*cdf0e10cSrcweir     if( maFontData.maFontName.getLength() > 0 )
813*cdf0e10cSrcweir         rPropMap.setProperty( PROP_FontName, maFontData.maFontName );
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir     // font effects
816*cdf0e10cSrcweir     rPropMap.setProperty( PROP_FontWeight, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_BOLD, FontWeight::BOLD, FontWeight::NORMAL ) );
817*cdf0e10cSrcweir     rPropMap.setProperty( PROP_FontSlant, getFlagValue< sal_Int16 >( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, FontSlant_ITALIC, FontSlant_NONE ) );
818*cdf0e10cSrcweir     rPropMap.setProperty( PROP_FontUnderline, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, maFontData.mbDblUnderline ? FontUnderline::DOUBLE : FontUnderline::SINGLE, FontUnderline::NONE ) );
819*cdf0e10cSrcweir     rPropMap.setProperty( PROP_FontStrikeout, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, FontStrikeout::SINGLE, FontStrikeout::NONE ) );
820*cdf0e10cSrcweir     rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() );
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir     // font character set
823*cdf0e10cSrcweir     rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
824*cdf0e10cSrcweir     if( (0 <= maFontData.mnFontCharSet) && (maFontData.mnFontCharSet <= SAL_MAX_UINT8) )
825*cdf0e10cSrcweir         eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maFontData.mnFontCharSet ) );
826*cdf0e10cSrcweir     if( eFontEnc != RTL_TEXTENCODING_DONTKNOW )
827*cdf0e10cSrcweir         rPropMap.setProperty( PROP_FontCharset, static_cast< sal_Int16 >( eFontEnc ) );
828*cdf0e10cSrcweir 
829*cdf0e10cSrcweir     // text alignment
830*cdf0e10cSrcweir     if( mbSupportsAlign )
831*cdf0e10cSrcweir     {
832*cdf0e10cSrcweir         sal_Int32 nAlign = TextAlign::LEFT;
833*cdf0e10cSrcweir         switch( maFontData.mnHorAlign )
834*cdf0e10cSrcweir         {
835*cdf0e10cSrcweir             case AX_FONTDATA_LEFT:      nAlign = TextAlign::LEFT;   break;
836*cdf0e10cSrcweir             case AX_FONTDATA_RIGHT:     nAlign = TextAlign::RIGHT;  break;
837*cdf0e10cSrcweir             case AX_FONTDATA_CENTER:    nAlign = TextAlign::CENTER; break;
838*cdf0e10cSrcweir             default:    OSL_ENSURE( false, "AxFontDataModel::convertProperties - unknown text alignment" );
839*cdf0e10cSrcweir         }
840*cdf0e10cSrcweir         // form controls expect short value
841*cdf0e10cSrcweir         rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) );
842*cdf0e10cSrcweir     }
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir     // process base class properties
845*cdf0e10cSrcweir     AxControlModelBase::convertProperties( rPropMap, rConv );
846*cdf0e10cSrcweir }
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir // ============================================================================
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir AxCommandButtonModel::AxCommandButtonModel() :
851*cdf0e10cSrcweir     mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
852*cdf0e10cSrcweir     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
853*cdf0e10cSrcweir     mnFlags( AX_CMDBUTTON_DEFFLAGS ),
854*cdf0e10cSrcweir     mnPicturePos( AX_PICPOS_ABOVECENTER ),
855*cdf0e10cSrcweir     mnVerticalAlign( XML_Center ),
856*cdf0e10cSrcweir     mbFocusOnClick( true )
857*cdf0e10cSrcweir {
858*cdf0e10cSrcweir }
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir void AxCommandButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
861*cdf0e10cSrcweir {
862*cdf0e10cSrcweir     switch( nPropId )
863*cdf0e10cSrcweir     {
864*cdf0e10cSrcweir         case XML_Caption:               maCaption = rValue;                                                 break;
865*cdf0e10cSrcweir         case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );        break;
866*cdf0e10cSrcweir         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );        break;
867*cdf0e10cSrcweir         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );            break;
868*cdf0e10cSrcweir         case XML_PicturePosition:       mnPicturePos = AttributeConversion::decodeUnsigned( rValue );       break;
869*cdf0e10cSrcweir         case XML_TakeFocusOnClick:      mbFocusOnClick = AttributeConversion::decodeInteger( rValue ) != 0; break;
870*cdf0e10cSrcweir         default:                        AxFontDataModel::importProperty( nPropId, rValue );
871*cdf0e10cSrcweir     }
872*cdf0e10cSrcweir }
873*cdf0e10cSrcweir 
874*cdf0e10cSrcweir void AxCommandButtonModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
875*cdf0e10cSrcweir {
876*cdf0e10cSrcweir     switch( nPropId )
877*cdf0e10cSrcweir     {
878*cdf0e10cSrcweir         case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm, true );    break;
879*cdf0e10cSrcweir         default:            AxFontDataModel::importPictureData( nPropId, rInStrm );
880*cdf0e10cSrcweir     }
881*cdf0e10cSrcweir }
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
884*cdf0e10cSrcweir {
885*cdf0e10cSrcweir     AxBinaryPropertyReader aReader( rInStrm );
886*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
887*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
888*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnFlags );
889*cdf0e10cSrcweir     aReader.readStringProperty( maCaption );
890*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
891*cdf0e10cSrcweir     aReader.readPairProperty( maSize );
892*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
893*cdf0e10cSrcweir     aReader.readPictureProperty( maPictureData );
894*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt16 >(); // accelerator
895*cdf0e10cSrcweir     aReader.readBoolProperty( mbFocusOnClick, true ); // binary flag means "do not take focus"
896*cdf0e10cSrcweir     aReader.skipPictureProperty(); // mouse icon
897*cdf0e10cSrcweir     return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
898*cdf0e10cSrcweir }
899*cdf0e10cSrcweir 
900*cdf0e10cSrcweir ApiControlType AxCommandButtonModel::getControlType() const
901*cdf0e10cSrcweir {
902*cdf0e10cSrcweir     return API_CONTROL_BUTTON;
903*cdf0e10cSrcweir }
904*cdf0e10cSrcweir 
905*cdf0e10cSrcweir void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
906*cdf0e10cSrcweir {
907*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Label, maCaption );
908*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
909*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
910*cdf0e10cSrcweir     rPropMap.setProperty( PROP_FocusOnClick, mbFocusOnClick );
911*cdf0e10cSrcweir     rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
912*cdf0e10cSrcweir     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
913*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
914*cdf0e10cSrcweir     rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
915*cdf0e10cSrcweir     AxFontDataModel::convertProperties( rPropMap, rConv );
916*cdf0e10cSrcweir }
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir // ============================================================================
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir AxLabelModel::AxLabelModel() :
921*cdf0e10cSrcweir     mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
922*cdf0e10cSrcweir     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
923*cdf0e10cSrcweir     mnFlags( AX_LABEL_DEFFLAGS ),
924*cdf0e10cSrcweir     mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
925*cdf0e10cSrcweir     mnBorderStyle( AX_BORDERSTYLE_NONE ),
926*cdf0e10cSrcweir     mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
927*cdf0e10cSrcweir     mnVerticalAlign( XML_Top )
928*cdf0e10cSrcweir {
929*cdf0e10cSrcweir }
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
932*cdf0e10cSrcweir {
933*cdf0e10cSrcweir     switch( nPropId )
934*cdf0e10cSrcweir     {
935*cdf0e10cSrcweir         case XML_Caption:               maCaption = rValue;                                             break;
936*cdf0e10cSrcweir         case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );    break;
937*cdf0e10cSrcweir         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
938*cdf0e10cSrcweir         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
939*cdf0e10cSrcweir         case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );  break;
940*cdf0e10cSrcweir         case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );   break;
941*cdf0e10cSrcweir         case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
942*cdf0e10cSrcweir         default:                        AxFontDataModel::importProperty( nPropId, rValue );
943*cdf0e10cSrcweir     }
944*cdf0e10cSrcweir }
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm )
947*cdf0e10cSrcweir {
948*cdf0e10cSrcweir     AxBinaryPropertyReader aReader( rInStrm );
949*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
950*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
951*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnFlags );
952*cdf0e10cSrcweir     aReader.readStringProperty( maCaption );
953*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // picture position
954*cdf0e10cSrcweir     aReader.readPairProperty( maSize );
955*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
956*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
957*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt16 >( mnBorderStyle );
958*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt16 >( mnSpecialEffect );
959*cdf0e10cSrcweir     aReader.skipPictureProperty(); // picture
960*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt16 >(); // accelerator
961*cdf0e10cSrcweir     aReader.skipPictureProperty(); // mouse icon
962*cdf0e10cSrcweir     return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
963*cdf0e10cSrcweir }
964*cdf0e10cSrcweir 
965*cdf0e10cSrcweir ApiControlType AxLabelModel::getControlType() const
966*cdf0e10cSrcweir {
967*cdf0e10cSrcweir     return API_CONTROL_FIXEDTEXT;
968*cdf0e10cSrcweir }
969*cdf0e10cSrcweir 
970*cdf0e10cSrcweir void AxLabelModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
971*cdf0e10cSrcweir {
972*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Label, maCaption );
973*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
974*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
975*cdf0e10cSrcweir     rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
976*cdf0e10cSrcweir     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
977*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
978*cdf0e10cSrcweir     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
979*cdf0e10cSrcweir     AxFontDataModel::convertProperties( rPropMap, rConv );
980*cdf0e10cSrcweir }
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir // ============================================================================
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir AxImageModel::AxImageModel() :
985*cdf0e10cSrcweir     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
986*cdf0e10cSrcweir     mnFlags( AX_IMAGE_DEFFLAGS ),
987*cdf0e10cSrcweir     mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
988*cdf0e10cSrcweir     mnBorderStyle( AX_BORDERSTYLE_SINGLE ),
989*cdf0e10cSrcweir     mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
990*cdf0e10cSrcweir     mnPicSizeMode( AX_PICSIZE_CLIP ),
991*cdf0e10cSrcweir     mnPicAlign( AX_PICALIGN_CENTER ),
992*cdf0e10cSrcweir     mbPicTiling( false )
993*cdf0e10cSrcweir {
994*cdf0e10cSrcweir }
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir void AxImageModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
997*cdf0e10cSrcweir {
998*cdf0e10cSrcweir     switch( nPropId )
999*cdf0e10cSrcweir     {
1000*cdf0e10cSrcweir         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );      break;
1001*cdf0e10cSrcweir         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );          break;
1002*cdf0e10cSrcweir         case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );    break;
1003*cdf0e10cSrcweir         case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );     break;
1004*cdf0e10cSrcweir         case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue );   break;
1005*cdf0e10cSrcweir         case XML_SizeMode:              mnPicSizeMode = AttributeConversion::decodeInteger( rValue );     break;
1006*cdf0e10cSrcweir         case XML_PictureAlignment:      mnPicAlign = AttributeConversion::decodeInteger( rValue );        break;
1007*cdf0e10cSrcweir         case XML_PictureTiling:         mbPicTiling = AttributeConversion::decodeInteger( rValue ) != 0;  break;
1008*cdf0e10cSrcweir         default:                        AxControlModelBase::importProperty( nPropId, rValue );
1009*cdf0e10cSrcweir     }
1010*cdf0e10cSrcweir }
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir void AxImageModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1013*cdf0e10cSrcweir {
1014*cdf0e10cSrcweir     switch( nPropId )
1015*cdf0e10cSrcweir     {
1016*cdf0e10cSrcweir         case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm, true );    break;
1017*cdf0e10cSrcweir         default:            AxControlModelBase::importPictureData( nPropId, rInStrm );
1018*cdf0e10cSrcweir     }
1019*cdf0e10cSrcweir }
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm )
1022*cdf0e10cSrcweir {
1023*cdf0e10cSrcweir     AxBinaryPropertyReader aReader( rInStrm );
1024*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1025*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1026*cdf0e10cSrcweir     aReader.skipBoolProperty(); // auto-size
1027*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1028*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1029*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1030*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1031*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
1032*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
1033*cdf0e10cSrcweir     aReader.readPairProperty( maSize );
1034*cdf0e10cSrcweir     aReader.readPictureProperty( maPictureData );
1035*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
1036*cdf0e10cSrcweir     aReader.readBoolProperty( mbPicTiling );
1037*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnFlags );
1038*cdf0e10cSrcweir     aReader.skipPictureProperty(); // mouse icon
1039*cdf0e10cSrcweir     return aReader.finalizeImport();
1040*cdf0e10cSrcweir }
1041*cdf0e10cSrcweir 
1042*cdf0e10cSrcweir ApiControlType AxImageModel::getControlType() const
1043*cdf0e10cSrcweir {
1044*cdf0e10cSrcweir     return API_CONTROL_IMAGE;
1045*cdf0e10cSrcweir }
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir void AxImageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1048*cdf0e10cSrcweir {
1049*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1050*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1051*cdf0e10cSrcweir     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1052*cdf0e10cSrcweir     rConv.convertAxPicture( rPropMap, maPictureData, mnPicSizeMode, mnPicAlign, mbPicTiling );
1053*cdf0e10cSrcweir     AxControlModelBase::convertProperties( rPropMap, rConv );
1054*cdf0e10cSrcweir }
1055*cdf0e10cSrcweir 
1056*cdf0e10cSrcweir // ============================================================================
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir AxMorphDataModelBase::AxMorphDataModelBase() :
1059*cdf0e10cSrcweir     mnTextColor( AX_SYSCOLOR_WINDOWTEXT ),
1060*cdf0e10cSrcweir     mnBackColor( AX_SYSCOLOR_WINDOWBACK ),
1061*cdf0e10cSrcweir     mnFlags( AX_MORPHDATA_DEFFLAGS ),
1062*cdf0e10cSrcweir     mnPicturePos( AX_PICPOS_ABOVECENTER ),
1063*cdf0e10cSrcweir     mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1064*cdf0e10cSrcweir     mnBorderStyle( AX_BORDERSTYLE_NONE ),
1065*cdf0e10cSrcweir     mnSpecialEffect( AX_SPECIALEFFECT_SUNKEN ),
1066*cdf0e10cSrcweir     mnDisplayStyle( AX_DISPLAYSTYLE_TEXT ),
1067*cdf0e10cSrcweir     mnMultiSelect( AX_SELCTION_SINGLE ),
1068*cdf0e10cSrcweir     mnScrollBars( AX_SCROLLBAR_NONE ),
1069*cdf0e10cSrcweir     mnMatchEntry( AX_MATCHENTRY_NONE ),
1070*cdf0e10cSrcweir     mnShowDropButton( AX_SHOWDROPBUTTON_NEVER ),
1071*cdf0e10cSrcweir     mnMaxLength( 0 ),
1072*cdf0e10cSrcweir     mnPasswordChar( 0 ),
1073*cdf0e10cSrcweir     mnListRows( 8 ),
1074*cdf0e10cSrcweir     mnVerticalAlign( XML_Center )
1075*cdf0e10cSrcweir {
1076*cdf0e10cSrcweir }
1077*cdf0e10cSrcweir 
1078*cdf0e10cSrcweir void AxMorphDataModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
1079*cdf0e10cSrcweir {
1080*cdf0e10cSrcweir     switch( nPropId )
1081*cdf0e10cSrcweir     {
1082*cdf0e10cSrcweir         case XML_Caption:               maCaption = rValue;                                             break;
1083*cdf0e10cSrcweir         case XML_Value:                 maValue = rValue;                                               break;
1084*cdf0e10cSrcweir         case XML_GroupName:             maGroupName = rValue;                                           break;
1085*cdf0e10cSrcweir         case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );    break;
1086*cdf0e10cSrcweir         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
1087*cdf0e10cSrcweir         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
1088*cdf0e10cSrcweir         case XML_PicturePosition:       mnPicturePos = AttributeConversion::decodeUnsigned( rValue );   break;
1089*cdf0e10cSrcweir         case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );  break;
1090*cdf0e10cSrcweir         case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );   break;
1091*cdf0e10cSrcweir         case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1092*cdf0e10cSrcweir         case XML_DisplayStyle:          mnDisplayStyle = AttributeConversion::decodeInteger( rValue );  break;
1093*cdf0e10cSrcweir         case XML_MultiSelect:           mnMultiSelect = AttributeConversion::decodeInteger( rValue );   break;
1094*cdf0e10cSrcweir         case XML_ScrollBars:            mnScrollBars = AttributeConversion::decodeInteger( rValue );    break;
1095*cdf0e10cSrcweir         case XML_MatchEntry:            mnMatchEntry = AttributeConversion::decodeInteger( rValue );    break;
1096*cdf0e10cSrcweir         case XML_ShowDropButtonWhen:    mnShowDropButton = AttributeConversion::decodeInteger( rValue );break;
1097*cdf0e10cSrcweir         case XML_MaxLength:             mnMaxLength = AttributeConversion::decodeInteger( rValue );     break;
1098*cdf0e10cSrcweir         case XML_PasswordChar:          mnPasswordChar = AttributeConversion::decodeInteger( rValue );  break;
1099*cdf0e10cSrcweir         case XML_ListRows:              mnListRows = AttributeConversion::decodeInteger( rValue );      break;
1100*cdf0e10cSrcweir         default:                        AxFontDataModel::importProperty( nPropId, rValue );
1101*cdf0e10cSrcweir     }
1102*cdf0e10cSrcweir }
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1105*cdf0e10cSrcweir {
1106*cdf0e10cSrcweir     switch( nPropId )
1107*cdf0e10cSrcweir     {
1108*cdf0e10cSrcweir         case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm, true );    break;
1109*cdf0e10cSrcweir         default:            AxFontDataModel::importPictureData( nPropId, rInStrm );
1110*cdf0e10cSrcweir     }
1111*cdf0e10cSrcweir }
1112*cdf0e10cSrcweir 
1113*cdf0e10cSrcweir bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm )
1114*cdf0e10cSrcweir {
1115*cdf0e10cSrcweir     AxBinaryPropertyReader aReader( rInStrm, true );
1116*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnFlags );
1117*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1118*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1119*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnMaxLength );
1120*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1121*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
1122*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnDisplayStyle );
1123*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1124*cdf0e10cSrcweir     aReader.readPairProperty( maSize );
1125*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt16 >( mnPasswordChar );
1126*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // list width
1127*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt16 >(); // bound column
1128*cdf0e10cSrcweir     aReader.skipIntProperty< sal_Int16 >(); // text column
1129*cdf0e10cSrcweir     aReader.skipIntProperty< sal_Int16 >(); // column count
1130*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt16 >( mnListRows );
1131*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt16 >(); // column info count
1132*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnMatchEntry );
1133*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // list style
1134*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnShowDropButton );
1135*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1136*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // drop down style
1137*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnMultiSelect );
1138*cdf0e10cSrcweir     aReader.readStringProperty( maValue );
1139*cdf0e10cSrcweir     aReader.readStringProperty( maCaption );
1140*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
1141*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1142*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnSpecialEffect );
1143*cdf0e10cSrcweir     aReader.skipPictureProperty(); // mouse icon
1144*cdf0e10cSrcweir     aReader.readPictureProperty( maPictureData );
1145*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1146*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1147*cdf0e10cSrcweir     aReader.skipBoolProperty();
1148*cdf0e10cSrcweir     aReader.readStringProperty( maGroupName );
1149*cdf0e10cSrcweir     return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1150*cdf0e10cSrcweir }
1151*cdf0e10cSrcweir 
1152*cdf0e10cSrcweir void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1153*cdf0e10cSrcweir {
1154*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1155*cdf0e10cSrcweir     rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1156*cdf0e10cSrcweir     AxFontDataModel::convertProperties( rPropMap, rConv );
1157*cdf0e10cSrcweir }
1158*cdf0e10cSrcweir 
1159*cdf0e10cSrcweir // ============================================================================
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir AxToggleButtonModel::AxToggleButtonModel()
1162*cdf0e10cSrcweir {
1163*cdf0e10cSrcweir     mnDisplayStyle = AX_DISPLAYSTYLE_TOGGLE;
1164*cdf0e10cSrcweir }
1165*cdf0e10cSrcweir 
1166*cdf0e10cSrcweir ApiControlType AxToggleButtonModel::getControlType() const
1167*cdf0e10cSrcweir {
1168*cdf0e10cSrcweir     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getControlType - invalid control type" );
1169*cdf0e10cSrcweir     return API_CONTROL_BUTTON;
1170*cdf0e10cSrcweir }
1171*cdf0e10cSrcweir 
1172*cdf0e10cSrcweir void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1173*cdf0e10cSrcweir {
1174*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Label, maCaption );
1175*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1176*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Toggle, true );
1177*cdf0e10cSrcweir     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
1178*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
1179*cdf0e10cSrcweir     rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1180*cdf0e10cSrcweir     rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1181*cdf0e10cSrcweir     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1182*cdf0e10cSrcweir }
1183*cdf0e10cSrcweir 
1184*cdf0e10cSrcweir // ============================================================================
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir AxCheckBoxModel::AxCheckBoxModel()
1187*cdf0e10cSrcweir {
1188*cdf0e10cSrcweir     mnDisplayStyle = AX_DISPLAYSTYLE_CHECKBOX;
1189*cdf0e10cSrcweir }
1190*cdf0e10cSrcweir 
1191*cdf0e10cSrcweir ApiControlType AxCheckBoxModel::getControlType() const
1192*cdf0e10cSrcweir {
1193*cdf0e10cSrcweir     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getControlType - invalid control type" );
1194*cdf0e10cSrcweir     return API_CONTROL_CHECKBOX;
1195*cdf0e10cSrcweir }
1196*cdf0e10cSrcweir 
1197*cdf0e10cSrcweir void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1198*cdf0e10cSrcweir {
1199*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Label, maCaption );
1200*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1201*cdf0e10cSrcweir     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
1202*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1203*cdf0e10cSrcweir     rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect );
1204*cdf0e10cSrcweir     rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1205*cdf0e10cSrcweir     rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE, mbAwtModel );
1206*cdf0e10cSrcweir     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1207*cdf0e10cSrcweir }
1208*cdf0e10cSrcweir 
1209*cdf0e10cSrcweir // ============================================================================
1210*cdf0e10cSrcweir 
1211*cdf0e10cSrcweir AxOptionButtonModel::AxOptionButtonModel()
1212*cdf0e10cSrcweir {
1213*cdf0e10cSrcweir     mnDisplayStyle = AX_DISPLAYSTYLE_OPTBUTTON;
1214*cdf0e10cSrcweir }
1215*cdf0e10cSrcweir 
1216*cdf0e10cSrcweir ApiControlType AxOptionButtonModel::getControlType() const
1217*cdf0e10cSrcweir {
1218*cdf0e10cSrcweir     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getControlType - invalid control type" );
1219*cdf0e10cSrcweir     return API_CONTROL_RADIOBUTTON;
1220*cdf0e10cSrcweir }
1221*cdf0e10cSrcweir 
1222*cdf0e10cSrcweir void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1223*cdf0e10cSrcweir {
1224*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Label, maCaption );
1225*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1226*cdf0e10cSrcweir     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
1227*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1228*cdf0e10cSrcweir     rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect );
1229*cdf0e10cSrcweir     rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1230*cdf0e10cSrcweir     rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT, mbAwtModel );
1231*cdf0e10cSrcweir     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1232*cdf0e10cSrcweir }
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir // ============================================================================
1235*cdf0e10cSrcweir 
1236*cdf0e10cSrcweir AxTextBoxModel::AxTextBoxModel()
1237*cdf0e10cSrcweir {
1238*cdf0e10cSrcweir     mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1239*cdf0e10cSrcweir }
1240*cdf0e10cSrcweir 
1241*cdf0e10cSrcweir ApiControlType AxTextBoxModel::getControlType() const
1242*cdf0e10cSrcweir {
1243*cdf0e10cSrcweir     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getControlType - invalid control type" );
1244*cdf0e10cSrcweir     return API_CONTROL_EDIT;
1245*cdf0e10cSrcweir }
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1248*cdf0e10cSrcweir {
1249*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_MULTILINE ) );
1250*cdf0e10cSrcweir     rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1251*cdf0e10cSrcweir     rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1252*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1253*cdf0e10cSrcweir     if( (0 < mnPasswordChar) && (mnPasswordChar <= SAL_MAX_INT16) )
1254*cdf0e10cSrcweir         rPropMap.setProperty( PROP_EchoChar, static_cast< sal_Int16 >( mnPasswordChar ) );
1255*cdf0e10cSrcweir     rPropMap.setProperty( PROP_HScroll, getFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL ) );
1256*cdf0e10cSrcweir     rPropMap.setProperty( PROP_VScroll, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1257*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1258*cdf0e10cSrcweir     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1259*cdf0e10cSrcweir     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1260*cdf0e10cSrcweir }
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir // ============================================================================
1263*cdf0e10cSrcweir 
1264*cdf0e10cSrcweir AxNumericFieldModel::AxNumericFieldModel()
1265*cdf0e10cSrcweir {
1266*cdf0e10cSrcweir     mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1267*cdf0e10cSrcweir }
1268*cdf0e10cSrcweir 
1269*cdf0e10cSrcweir ApiControlType AxNumericFieldModel::getControlType() const
1270*cdf0e10cSrcweir {
1271*cdf0e10cSrcweir     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxNumericFieldModel::getControlType - invalid control type" );
1272*cdf0e10cSrcweir     return API_CONTROL_NUMERIC;
1273*cdf0e10cSrcweir }
1274*cdf0e10cSrcweir 
1275*cdf0e10cSrcweir void AxNumericFieldModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1276*cdf0e10cSrcweir {
1277*cdf0e10cSrcweir     rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1278*cdf0e10cSrcweir     // TODO: OUString::toDouble() does not handle local decimal separator
1279*cdf0e10cSrcweir     rPropMap.setProperty( mbAwtModel ? PROP_Value : PROP_DefaultValue, maValue.toDouble() );
1280*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Spin, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1281*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Repeat, true );
1282*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1283*cdf0e10cSrcweir     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1284*cdf0e10cSrcweir     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1285*cdf0e10cSrcweir }
1286*cdf0e10cSrcweir 
1287*cdf0e10cSrcweir // ============================================================================
1288*cdf0e10cSrcweir 
1289*cdf0e10cSrcweir AxListBoxModel::AxListBoxModel()
1290*cdf0e10cSrcweir {
1291*cdf0e10cSrcweir     mnDisplayStyle = AX_DISPLAYSTYLE_LISTBOX;
1292*cdf0e10cSrcweir }
1293*cdf0e10cSrcweir 
1294*cdf0e10cSrcweir ApiControlType AxListBoxModel::getControlType() const
1295*cdf0e10cSrcweir {
1296*cdf0e10cSrcweir     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getControlType - invalid control type" );
1297*cdf0e10cSrcweir     return API_CONTROL_LISTBOX;
1298*cdf0e10cSrcweir }
1299*cdf0e10cSrcweir 
1300*cdf0e10cSrcweir void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1301*cdf0e10cSrcweir {
1302*cdf0e10cSrcweir     bool bMultiSelect = (mnMultiSelect == AX_SELCTION_MULTI) || (mnMultiSelect == AX_SELCTION_EXTENDED);
1303*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MultiSelection, bMultiSelect );
1304*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Dropdown, false );
1305*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1306*cdf0e10cSrcweir     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1307*cdf0e10cSrcweir     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1308*cdf0e10cSrcweir }
1309*cdf0e10cSrcweir 
1310*cdf0e10cSrcweir // ============================================================================
1311*cdf0e10cSrcweir 
1312*cdf0e10cSrcweir AxComboBoxModel::AxComboBoxModel()
1313*cdf0e10cSrcweir {
1314*cdf0e10cSrcweir     mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
1315*cdf0e10cSrcweir }
1316*cdf0e10cSrcweir 
1317*cdf0e10cSrcweir ApiControlType AxComboBoxModel::getControlType() const
1318*cdf0e10cSrcweir {
1319*cdf0e10cSrcweir     OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getControlType - invalid control type" );
1320*cdf0e10cSrcweir     return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? API_CONTROL_LISTBOX : API_CONTROL_COMBOBOX;
1321*cdf0e10cSrcweir }
1322*cdf0e10cSrcweir 
1323*cdf0e10cSrcweir void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1324*cdf0e10cSrcweir {
1325*cdf0e10cSrcweir     if( mnDisplayStyle != AX_DISPLAYSTYLE_DROPDOWN )
1326*cdf0e10cSrcweir     {
1327*cdf0e10cSrcweir         rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1328*cdf0e10cSrcweir         rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1329*cdf0e10cSrcweir         rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1330*cdf0e10cSrcweir         bool bAutoComplete = (mnMatchEntry == AX_MATCHENTRY_FIRSTLETTER) || (mnMatchEntry == AX_MATCHENTRY_COMPLETE);
1331*cdf0e10cSrcweir         rPropMap.setProperty( PROP_Autocomplete, bAutoComplete );
1332*cdf0e10cSrcweir     }
1333*cdf0e10cSrcweir     bool bShowDropdown = (mnShowDropButton == AX_SHOWDROPBUTTON_FOCUS) || (mnShowDropButton == AX_SHOWDROPBUTTON_ALWAYS);
1334*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Dropdown, bShowDropdown );
1335*cdf0e10cSrcweir     rPropMap.setProperty( PROP_LineCount, getLimitedValue< sal_Int16, sal_Int32 >( mnListRows, 1, SAL_MAX_INT16 ) );
1336*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1337*cdf0e10cSrcweir     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1338*cdf0e10cSrcweir     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1339*cdf0e10cSrcweir }
1340*cdf0e10cSrcweir 
1341*cdf0e10cSrcweir // ============================================================================
1342*cdf0e10cSrcweir 
1343*cdf0e10cSrcweir AxSpinButtonModel::AxSpinButtonModel() :
1344*cdf0e10cSrcweir     mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
1345*cdf0e10cSrcweir     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1346*cdf0e10cSrcweir     mnFlags( AX_SPINBUTTON_DEFFLAGS ),
1347*cdf0e10cSrcweir     mnOrientation( AX_ORIENTATION_AUTO ),
1348*cdf0e10cSrcweir     mnMin( 0 ),
1349*cdf0e10cSrcweir     mnMax( 100 ),
1350*cdf0e10cSrcweir     mnPosition( 0 ),
1351*cdf0e10cSrcweir     mnSmallChange( 1 ),
1352*cdf0e10cSrcweir     mnDelay( 50 )
1353*cdf0e10cSrcweir {
1354*cdf0e10cSrcweir }
1355*cdf0e10cSrcweir 
1356*cdf0e10cSrcweir ApiControlType AxSpinButtonModel::getControlType() const
1357*cdf0e10cSrcweir {
1358*cdf0e10cSrcweir     return API_CONTROL_SPINBUTTON;
1359*cdf0e10cSrcweir }
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1362*cdf0e10cSrcweir {
1363*cdf0e10cSrcweir     switch( nPropId )
1364*cdf0e10cSrcweir     {
1365*cdf0e10cSrcweir         case XML_ForeColor:             mnArrowColor = AttributeConversion::decodeUnsigned( rValue );   break;
1366*cdf0e10cSrcweir         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
1367*cdf0e10cSrcweir         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
1368*cdf0e10cSrcweir         case XML_Orientation:           mnOrientation = AttributeConversion::decodeInteger( rValue );   break;
1369*cdf0e10cSrcweir         case XML_Min:                   mnMin = AttributeConversion::decodeInteger( rValue );           break;
1370*cdf0e10cSrcweir         case XML_Max:                   mnMax = AttributeConversion::decodeInteger( rValue );           break;
1371*cdf0e10cSrcweir         case XML_Position:              mnPosition = AttributeConversion::decodeInteger( rValue );      break;
1372*cdf0e10cSrcweir         case XML_SmallChange:           mnSmallChange = AttributeConversion::decodeInteger( rValue );   break;
1373*cdf0e10cSrcweir         case XML_Delay:                 mnDelay = AttributeConversion::decodeInteger( rValue );         break;
1374*cdf0e10cSrcweir         default:                        AxControlModelBase::importProperty( nPropId, rValue );
1375*cdf0e10cSrcweir     }
1376*cdf0e10cSrcweir }
1377*cdf0e10cSrcweir 
1378*cdf0e10cSrcweir bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
1379*cdf0e10cSrcweir {
1380*cdf0e10cSrcweir     AxBinaryPropertyReader aReader( rInStrm );
1381*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
1382*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1383*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnFlags );
1384*cdf0e10cSrcweir     aReader.readPairProperty( maSize );
1385*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // unused
1386*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnMin );
1387*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnMax );
1388*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnPosition );
1389*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
1390*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // next enabled
1391*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnSmallChange );
1392*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnOrientation );
1393*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnDelay );
1394*cdf0e10cSrcweir     aReader.skipPictureProperty(); // mouse icon
1395*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1396*cdf0e10cSrcweir     return aReader.finalizeImport();
1397*cdf0e10cSrcweir }
1398*cdf0e10cSrcweir 
1399*cdf0e10cSrcweir void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1400*cdf0e10cSrcweir {
1401*cdf0e10cSrcweir     sal_Int32 nMin = ::std::min( mnMin, mnMax );
1402*cdf0e10cSrcweir     sal_Int32 nMax = ::std::max( mnMin, mnMax );
1403*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1404*cdf0e10cSrcweir     rPropMap.setProperty( PROP_SpinValueMin, nMin );
1405*cdf0e10cSrcweir     rPropMap.setProperty( PROP_SpinValueMax, nMax );
1406*cdf0e10cSrcweir     rPropMap.setProperty( PROP_SpinIncrement, mnSmallChange );
1407*cdf0e10cSrcweir     rPropMap.setProperty( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue, mnPosition );
1408*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Repeat, true );
1409*cdf0e10cSrcweir     rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
1410*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
1411*cdf0e10cSrcweir     rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
1412*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
1413*cdf0e10cSrcweir     rConv.convertAxOrientation( rPropMap, maSize, mnOrientation );
1414*cdf0e10cSrcweir     AxControlModelBase::convertProperties( rPropMap, rConv );
1415*cdf0e10cSrcweir }
1416*cdf0e10cSrcweir 
1417*cdf0e10cSrcweir // ============================================================================
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir AxScrollBarModel::AxScrollBarModel() :
1420*cdf0e10cSrcweir     mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
1421*cdf0e10cSrcweir     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1422*cdf0e10cSrcweir     mnFlags( AX_SCROLLBAR_DEFFLAGS ),
1423*cdf0e10cSrcweir     mnOrientation( AX_ORIENTATION_AUTO ),
1424*cdf0e10cSrcweir     mnPropThumb( AX_PROPTHUMB_ON ),
1425*cdf0e10cSrcweir     mnMin( 0 ),
1426*cdf0e10cSrcweir     mnMax( 32767 ),
1427*cdf0e10cSrcweir     mnPosition( 0 ),
1428*cdf0e10cSrcweir     mnSmallChange( 1 ),
1429*cdf0e10cSrcweir     mnLargeChange( 1 ),
1430*cdf0e10cSrcweir     mnDelay( 50 )
1431*cdf0e10cSrcweir {
1432*cdf0e10cSrcweir }
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir ApiControlType AxScrollBarModel::getControlType() const
1435*cdf0e10cSrcweir {
1436*cdf0e10cSrcweir     return API_CONTROL_SCROLLBAR;
1437*cdf0e10cSrcweir }
1438*cdf0e10cSrcweir 
1439*cdf0e10cSrcweir void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1440*cdf0e10cSrcweir {
1441*cdf0e10cSrcweir     switch( nPropId )
1442*cdf0e10cSrcweir     {
1443*cdf0e10cSrcweir         case XML_ForeColor:             mnArrowColor = AttributeConversion::decodeUnsigned( rValue );   break;
1444*cdf0e10cSrcweir         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
1445*cdf0e10cSrcweir         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
1446*cdf0e10cSrcweir         case XML_Orientation:           mnOrientation = AttributeConversion::decodeInteger( rValue );   break;
1447*cdf0e10cSrcweir         case XML_ProportionalThumb:     mnPropThumb = AttributeConversion::decodeInteger( rValue );     break;
1448*cdf0e10cSrcweir         case XML_Min:                   mnMin = AttributeConversion::decodeInteger( rValue );           break;
1449*cdf0e10cSrcweir         case XML_Max:                   mnMax = AttributeConversion::decodeInteger( rValue );           break;
1450*cdf0e10cSrcweir         case XML_Position:              mnPosition = AttributeConversion::decodeInteger( rValue );      break;
1451*cdf0e10cSrcweir         case XML_SmallChange:           mnSmallChange = AttributeConversion::decodeInteger( rValue );   break;
1452*cdf0e10cSrcweir         case XML_LargeChange:           mnLargeChange = AttributeConversion::decodeInteger( rValue );   break;
1453*cdf0e10cSrcweir         case XML_Delay:                 mnDelay = AttributeConversion::decodeInteger( rValue );         break;
1454*cdf0e10cSrcweir         default:                        AxControlModelBase::importProperty( nPropId, rValue );
1455*cdf0e10cSrcweir     }
1456*cdf0e10cSrcweir }
1457*cdf0e10cSrcweir 
1458*cdf0e10cSrcweir bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm )
1459*cdf0e10cSrcweir {
1460*cdf0e10cSrcweir     AxBinaryPropertyReader aReader( rInStrm );
1461*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
1462*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1463*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnFlags );
1464*cdf0e10cSrcweir     aReader.readPairProperty( maSize );
1465*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1466*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnMin );
1467*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnMax );
1468*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnPosition );
1469*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // unused
1470*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
1471*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // next enabled
1472*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnSmallChange );
1473*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnLargeChange );
1474*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnOrientation );
1475*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int16 >( mnPropThumb );
1476*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnDelay );
1477*cdf0e10cSrcweir     aReader.skipPictureProperty(); // mouse icon
1478*cdf0e10cSrcweir     return aReader.finalizeImport();
1479*cdf0e10cSrcweir }
1480*cdf0e10cSrcweir 
1481*cdf0e10cSrcweir void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1482*cdf0e10cSrcweir {
1483*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1484*cdf0e10cSrcweir     rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
1485*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
1486*cdf0e10cSrcweir     if( (mnPropThumb == AX_PROPTHUMB_ON) && (mnMin != mnMax) && (mnLargeChange > 0) )
1487*cdf0e10cSrcweir     {
1488*cdf0e10cSrcweir         // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int)
1489*cdf0e10cSrcweir         double fInterval = fabs( static_cast< double >( mnMax - mnMin ) );
1490*cdf0e10cSrcweir         sal_Int32 nThumbLen = getLimitedValue< sal_Int32, double >( (fInterval * mnLargeChange) / (fInterval + mnLargeChange), 1, SAL_MAX_INT32 );
1491*cdf0e10cSrcweir         rPropMap.setProperty( PROP_VisibleSize, nThumbLen );
1492*cdf0e10cSrcweir     }
1493*cdf0e10cSrcweir     rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
1494*cdf0e10cSrcweir     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
1495*cdf0e10cSrcweir     rConv.convertAxOrientation( rPropMap, maSize, mnOrientation );
1496*cdf0e10cSrcweir     rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
1497*cdf0e10cSrcweir     AxControlModelBase::convertProperties( rPropMap, rConv );
1498*cdf0e10cSrcweir }
1499*cdf0e10cSrcweir 
1500*cdf0e10cSrcweir // ============================================================================
1501*cdf0e10cSrcweir 
1502*cdf0e10cSrcweir AxTabStripModel::AxTabStripModel() :
1503*cdf0e10cSrcweir     AxFontDataModel( false ),   // no support for alignment properties
1504*cdf0e10cSrcweir     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1505*cdf0e10cSrcweir     mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
1506*cdf0e10cSrcweir     mnFlags( AX_TABSTRIP_DEFFLAGS ),
1507*cdf0e10cSrcweir     mnSelectedTab( -1 ),
1508*cdf0e10cSrcweir     mnTabStyle( AX_TABSTRIP_TABS ),
1509*cdf0e10cSrcweir     mnTabFlagCount( 0 )
1510*cdf0e10cSrcweir {
1511*cdf0e10cSrcweir }
1512*cdf0e10cSrcweir 
1513*cdf0e10cSrcweir bool AxTabStripModel::importBinaryModel( BinaryInputStream& rInStrm )
1514*cdf0e10cSrcweir {
1515*cdf0e10cSrcweir     AxBinaryPropertyReader aReader( rInStrm );
1516*cdf0e10cSrcweir     aReader.readIntProperty< sal_Int32 >( mnSelectedTab );
1517*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1518*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1519*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1520*cdf0e10cSrcweir     aReader.readPairProperty( maSize );
1521*cdf0e10cSrcweir     aReader.readStringArrayProperty( maCaptions );
1522*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1523*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1524*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // tab orientation
1525*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnTabStyle );
1526*cdf0e10cSrcweir     aReader.skipBoolProperty(); // multiple rows
1527*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // fixed width
1528*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // fixed height
1529*cdf0e10cSrcweir     aReader.skipBoolProperty(); // tooltips
1530*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1531*cdf0e10cSrcweir     aReader.skipStringArrayProperty(); // tooltip strings
1532*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1533*cdf0e10cSrcweir     aReader.skipStringArrayProperty(); // tab names
1534*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnFlags );
1535*cdf0e10cSrcweir     aReader.skipBoolProperty(); // new version
1536*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // tabs allocated
1537*cdf0e10cSrcweir     aReader.skipStringArrayProperty(); // tags
1538*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnTabFlagCount );
1539*cdf0e10cSrcweir     aReader.skipStringArrayProperty(); // accelerators
1540*cdf0e10cSrcweir     aReader.skipPictureProperty(); // mouse icon
1541*cdf0e10cSrcweir     return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1542*cdf0e10cSrcweir }
1543*cdf0e10cSrcweir 
1544*cdf0e10cSrcweir ApiControlType AxTabStripModel::getControlType() const
1545*cdf0e10cSrcweir {
1546*cdf0e10cSrcweir     return API_CONTROL_TABSTRIP;
1547*cdf0e10cSrcweir }
1548*cdf0e10cSrcweir 
1549*cdf0e10cSrcweir void AxTabStripModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1550*cdf0e10cSrcweir {
1551*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Decoration, mnTabStyle != AX_TABSTRIP_NONE );
1552*cdf0e10cSrcweir     rPropMap.setProperty( PROP_MultiPageValue, mnSelectedTab );
1553*cdf0e10cSrcweir     rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
1554*cdf0e10cSrcweir     AxFontDataModel::convertProperties( rPropMap, rConv );
1555*cdf0e10cSrcweir }
1556*cdf0e10cSrcweir 
1557*cdf0e10cSrcweir OUString AxTabStripModel::getCaption( sal_Int32 nIndex ) const
1558*cdf0e10cSrcweir {
1559*cdf0e10cSrcweir     return ContainerHelper::getVectorElement( maCaptions, nIndex, OUString() );
1560*cdf0e10cSrcweir }
1561*cdf0e10cSrcweir 
1562*cdf0e10cSrcweir // ============================================================================
1563*cdf0e10cSrcweir 
1564*cdf0e10cSrcweir AxContainerModelBase::AxContainerModelBase( bool bFontSupport ) :
1565*cdf0e10cSrcweir     AxFontDataModel( false ),   // no support for alignment properties
1566*cdf0e10cSrcweir     maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ),
1567*cdf0e10cSrcweir     maScrollPos( 0, 0 ),
1568*cdf0e10cSrcweir     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1569*cdf0e10cSrcweir     mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
1570*cdf0e10cSrcweir     mnFlags( AX_CONTAINER_DEFFLAGS ),
1571*cdf0e10cSrcweir     mnBorderColor( AX_SYSCOLOR_BUTTONTEXT ),
1572*cdf0e10cSrcweir     mnBorderStyle( AX_BORDERSTYLE_NONE ),
1573*cdf0e10cSrcweir     mnScrollBars( AX_CONTAINER_SCR_NONE ),
1574*cdf0e10cSrcweir     mnCycleType( AX_CONTAINER_CYCLEALL ),
1575*cdf0e10cSrcweir     mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1576*cdf0e10cSrcweir     mnPicAlign( AX_PICALIGN_CENTER ),
1577*cdf0e10cSrcweir     mnPicSizeMode( AX_PICSIZE_CLIP ),
1578*cdf0e10cSrcweir     mbPicTiling( false ),
1579*cdf0e10cSrcweir     mbFontSupport( bFontSupport )
1580*cdf0e10cSrcweir {
1581*cdf0e10cSrcweir     setAwtModelMode();
1582*cdf0e10cSrcweir     // different default size for frame
1583*cdf0e10cSrcweir     maSize = AxPairData( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT );
1584*cdf0e10cSrcweir }
1585*cdf0e10cSrcweir 
1586*cdf0e10cSrcweir void AxContainerModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
1587*cdf0e10cSrcweir {
1588*cdf0e10cSrcweir     if( nPropId == XML_Caption )
1589*cdf0e10cSrcweir         maCaption = rValue;
1590*cdf0e10cSrcweir }
1591*cdf0e10cSrcweir 
1592*cdf0e10cSrcweir bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm )
1593*cdf0e10cSrcweir {
1594*cdf0e10cSrcweir     AxBinaryPropertyReader aReader( rInStrm );
1595*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1596*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1597*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1598*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // next availbale control ID
1599*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1600*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1601*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnFlags );
1602*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1603*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1604*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
1605*cdf0e10cSrcweir     aReader.readPairProperty( maSize );
1606*cdf0e10cSrcweir     aReader.readPairProperty( maLogicalSize );
1607*cdf0e10cSrcweir     aReader.readPairProperty( maScrollPos );
1608*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // number of control groups
1609*cdf0e10cSrcweir     aReader.skipUndefinedProperty();
1610*cdf0e10cSrcweir     aReader.skipPictureProperty(); // mouse icon
1611*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnCycleType );
1612*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
1613*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1614*cdf0e10cSrcweir     aReader.readStringProperty( maCaption );
1615*cdf0e10cSrcweir     aReader.readFontProperty( maFontData );
1616*cdf0e10cSrcweir     aReader.readPictureProperty( maPictureData );
1617*cdf0e10cSrcweir     aReader.skipIntProperty< sal_Int32 >(); // zoom
1618*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
1619*cdf0e10cSrcweir     aReader.readBoolProperty( mbPicTiling );
1620*cdf0e10cSrcweir     aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
1621*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // shape cookie
1622*cdf0e10cSrcweir     aReader.skipIntProperty< sal_uInt32 >(); // draw buffer size
1623*cdf0e10cSrcweir     return aReader.finalizeImport();
1624*cdf0e10cSrcweir }
1625*cdf0e10cSrcweir 
1626*cdf0e10cSrcweir void AxContainerModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1627*cdf0e10cSrcweir {
1628*cdf0e10cSrcweir     if( mbFontSupport )
1629*cdf0e10cSrcweir     {
1630*cdf0e10cSrcweir         rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1631*cdf0e10cSrcweir         AxFontDataModel::convertProperties( rPropMap, rConv );
1632*cdf0e10cSrcweir     }
1633*cdf0e10cSrcweir }
1634*cdf0e10cSrcweir 
1635*cdf0e10cSrcweir bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable )
1636*cdf0e10cSrcweir {
1637*cdf0e10cSrcweir     bool bValid = true;
1638*cdf0e10cSrcweir     orClassTable.clear();
1639*cdf0e10cSrcweir     if( !getFlag( mnFlags, AX_CONTAINER_NOCLASSTABLE ) )
1640*cdf0e10cSrcweir     {
1641*cdf0e10cSrcweir         sal_uInt16 nCount = rInStrm.readuInt16();
1642*cdf0e10cSrcweir         for( sal_uInt16 nIndex = 0; bValid && (nIndex < nCount); ++nIndex )
1643*cdf0e10cSrcweir         {
1644*cdf0e10cSrcweir             orClassTable.push_back( OUString() );
1645*cdf0e10cSrcweir             AxBinaryPropertyReader aReader( rInStrm );
1646*cdf0e10cSrcweir             aReader.readGuidProperty( orClassTable.back() );
1647*cdf0e10cSrcweir             aReader.skipGuidProperty(); // source interface GUID
1648*cdf0e10cSrcweir             aReader.skipUndefinedProperty();
1649*cdf0e10cSrcweir             aReader.skipGuidProperty(); // default interface GUID
1650*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt32 >(); // class table and var flags
1651*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt32 >(); // method count
1652*cdf0e10cSrcweir             aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for linked cell access
1653*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt16 >(); // get function index for linked cell access
1654*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt16 >(); // put function index for linked cell access
1655*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt16 >(); // linked cell access property type
1656*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt16 >(); // get function index of value
1657*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt16 >(); // put function index of value
1658*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt16 >(); // value type
1659*cdf0e10cSrcweir             aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for source range access
1660*cdf0e10cSrcweir             aReader.skipIntProperty< sal_uInt16 >(); // get function index for source range access
1661*cdf0e10cSrcweir             bValid = aReader.finalizeImport();
1662*cdf0e10cSrcweir         }
1663*cdf0e10cSrcweir     }
1664*cdf0e10cSrcweir     return bValid;
1665*cdf0e10cSrcweir }
1666*cdf0e10cSrcweir 
1667*cdf0e10cSrcweir // ============================================================================
1668*cdf0e10cSrcweir 
1669*cdf0e10cSrcweir AxFrameModel::AxFrameModel() :
1670*cdf0e10cSrcweir     AxContainerModelBase( true )
1671*cdf0e10cSrcweir {
1672*cdf0e10cSrcweir }
1673*cdf0e10cSrcweir 
1674*cdf0e10cSrcweir ApiControlType AxFrameModel::getControlType() const
1675*cdf0e10cSrcweir {
1676*cdf0e10cSrcweir     return API_CONTROL_GROUPBOX;
1677*cdf0e10cSrcweir }
1678*cdf0e10cSrcweir 
1679*cdf0e10cSrcweir void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1680*cdf0e10cSrcweir {
1681*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Label, maCaption );
1682*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
1683*cdf0e10cSrcweir     AxContainerModelBase::convertProperties( rPropMap, rConv );
1684*cdf0e10cSrcweir }
1685*cdf0e10cSrcweir 
1686*cdf0e10cSrcweir // ============================================================================
1687*cdf0e10cSrcweir 
1688*cdf0e10cSrcweir AxFormPageModel::AxFormPageModel()
1689*cdf0e10cSrcweir {
1690*cdf0e10cSrcweir }
1691*cdf0e10cSrcweir 
1692*cdf0e10cSrcweir ApiControlType AxFormPageModel::getControlType() const
1693*cdf0e10cSrcweir {
1694*cdf0e10cSrcweir     return API_CONTROL_PAGE;
1695*cdf0e10cSrcweir }
1696*cdf0e10cSrcweir 
1697*cdf0e10cSrcweir void AxFormPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1698*cdf0e10cSrcweir {
1699*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Title, maCaption );
1700*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
1701*cdf0e10cSrcweir     rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
1702*cdf0e10cSrcweir     AxContainerModelBase::convertProperties( rPropMap, rConv );
1703*cdf0e10cSrcweir }
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir // ============================================================================
1706*cdf0e10cSrcweir 
1707*cdf0e10cSrcweir AxMultiPageModel::AxMultiPageModel()
1708*cdf0e10cSrcweir {
1709*cdf0e10cSrcweir }
1710*cdf0e10cSrcweir 
1711*cdf0e10cSrcweir ApiControlType AxMultiPageModel::getControlType() const
1712*cdf0e10cSrcweir {
1713*cdf0e10cSrcweir     return API_CONTROL_MULTIPAGE;
1714*cdf0e10cSrcweir }
1715*cdf0e10cSrcweir 
1716*cdf0e10cSrcweir void AxMultiPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1717*cdf0e10cSrcweir {
1718*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
1719*cdf0e10cSrcweir     if( mxTabStrip.get() )
1720*cdf0e10cSrcweir         mxTabStrip->convertProperties( rPropMap, rConv );
1721*cdf0e10cSrcweir     AxContainerModelBase::convertProperties( rPropMap, rConv );
1722*cdf0e10cSrcweir }
1723*cdf0e10cSrcweir 
1724*cdf0e10cSrcweir void AxMultiPageModel::setTabStripModel( const AxTabStripModelRef& rxTabStrip )
1725*cdf0e10cSrcweir {
1726*cdf0e10cSrcweir     mxTabStrip = rxTabStrip;
1727*cdf0e10cSrcweir }
1728*cdf0e10cSrcweir 
1729*cdf0e10cSrcweir // ============================================================================
1730*cdf0e10cSrcweir 
1731*cdf0e10cSrcweir AxUserFormModel::AxUserFormModel()
1732*cdf0e10cSrcweir {
1733*cdf0e10cSrcweir }
1734*cdf0e10cSrcweir 
1735*cdf0e10cSrcweir ApiControlType AxUserFormModel::getControlType() const
1736*cdf0e10cSrcweir {
1737*cdf0e10cSrcweir     return API_CONTROL_DIALOG;
1738*cdf0e10cSrcweir }
1739*cdf0e10cSrcweir 
1740*cdf0e10cSrcweir void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1741*cdf0e10cSrcweir {
1742*cdf0e10cSrcweir     rPropMap.setProperty( PROP_Title, maCaption );
1743*cdf0e10cSrcweir     rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
1744*cdf0e10cSrcweir     AxContainerModelBase::convertProperties( rPropMap, rConv );
1745*cdf0e10cSrcweir }
1746*cdf0e10cSrcweir 
1747*cdf0e10cSrcweir // ============================================================================
1748*cdf0e10cSrcweir 
1749*cdf0e10cSrcweir EmbeddedControl::EmbeddedControl( const OUString& rName ) :
1750*cdf0e10cSrcweir     maName( rName )
1751*cdf0e10cSrcweir {
1752*cdf0e10cSrcweir }
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir EmbeddedControl::~EmbeddedControl()
1755*cdf0e10cSrcweir {
1756*cdf0e10cSrcweir }
1757*cdf0e10cSrcweir 
1758*cdf0e10cSrcweir ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId )
1759*cdf0e10cSrcweir {
1760*cdf0e10cSrcweir     OUString aClassId = rClassId.toAsciiUpperCase();
1761*cdf0e10cSrcweir 
1762*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_COMMANDBUTTON ) )     return &createModel< AxCommandButtonModel >();
1763*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_LABEL ) )             return &createModel< AxLabelModel >();
1764*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_IMAGE ) )             return &createModel< AxImageModel >();
1765*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_TOGGLEBUTTON ) )      return &createModel< AxToggleButtonModel >();
1766*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_CHECKBOX ) )          return &createModel< AxCheckBoxModel >();
1767*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_OPTIONBUTTON ) )      return &createModel< AxOptionButtonModel >();
1768*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_TEXTBOX ) )           return &createModel< AxTextBoxModel >();
1769*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_LISTBOX ) )           return &createModel< AxListBoxModel >();
1770*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_COMBOBOX ) )          return &createModel< AxComboBoxModel >();
1771*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_SPINBUTTON ) )        return &createModel< AxSpinButtonModel >();
1772*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_SCROLLBAR ) )         return &createModel< AxScrollBarModel >();
1773*cdf0e10cSrcweir     if( aClassId.equalsAscii( AX_GUID_FRAME ) )             return &createModel< AxFrameModel >();
1774*cdf0e10cSrcweir     if( aClassId.equalsAscii( COMCTL_GUID_SCROLLBAR_60 ) )  return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 );
1775*cdf0e10cSrcweir 
1776*cdf0e10cSrcweir     mxModel.reset();
1777*cdf0e10cSrcweir     return 0;
1778*cdf0e10cSrcweir }
1779*cdf0e10cSrcweir 
1780*cdf0e10cSrcweir OUString EmbeddedControl::getServiceName() const
1781*cdf0e10cSrcweir {
1782*cdf0e10cSrcweir     return mxModel.get() ? mxModel->getServiceName() : OUString();
1783*cdf0e10cSrcweir }
1784*cdf0e10cSrcweir 
1785*cdf0e10cSrcweir bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const
1786*cdf0e10cSrcweir {
1787*cdf0e10cSrcweir     if( mxModel.get() && rxCtrlModel.is() && (maName.getLength() > 0) )
1788*cdf0e10cSrcweir     {
1789*cdf0e10cSrcweir         PropertyMap aPropMap;
1790*cdf0e10cSrcweir         aPropMap.setProperty( PROP_Name, maName );
1791*cdf0e10cSrcweir         mxModel->convertProperties( aPropMap, rConv );
1792*cdf0e10cSrcweir         PropertySet aPropSet( rxCtrlModel );
1793*cdf0e10cSrcweir         aPropSet.setProperties( aPropMap );
1794*cdf0e10cSrcweir         return true;
1795*cdf0e10cSrcweir     }
1796*cdf0e10cSrcweir     return false;
1797*cdf0e10cSrcweir }
1798*cdf0e10cSrcweir 
1799*cdf0e10cSrcweir // ============================================================================
1800*cdf0e10cSrcweir 
1801*cdf0e10cSrcweir EmbeddedForm::EmbeddedForm( const Reference< XModel >& rxDocModel,
1802*cdf0e10cSrcweir         const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
1803*cdf0e10cSrcweir     maControlConv( rxDocModel, rGraphicHelper, bDefaultColorBgr ),
1804*cdf0e10cSrcweir     mxModelFactory( rxDocModel, UNO_QUERY ),
1805*cdf0e10cSrcweir     mxFormsSupp( rxDrawPage, UNO_QUERY )
1806*cdf0e10cSrcweir {
1807*cdf0e10cSrcweir     OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );
1808*cdf0e10cSrcweir }
1809*cdf0e10cSrcweir 
1810*cdf0e10cSrcweir Reference< XControlModel > EmbeddedForm::convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex )
1811*cdf0e10cSrcweir {
1812*cdf0e10cSrcweir     if( mxModelFactory.is() && rControl.hasModel() ) try
1813*cdf0e10cSrcweir     {
1814*cdf0e10cSrcweir         // create the UNO control model
1815*cdf0e10cSrcweir         OUString aServiceName = rControl.getServiceName();
1816*cdf0e10cSrcweir         Reference< XFormComponent > xFormComp( mxModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW );
1817*cdf0e10cSrcweir         Reference< XControlModel > xCtrlModel( xFormComp, UNO_QUERY_THROW );
1818*cdf0e10cSrcweir 
1819*cdf0e10cSrcweir         // insert the control into the form
1820*cdf0e10cSrcweir         Reference< XIndexContainer > xFormIC( createXForm(), UNO_SET_THROW );
1821*cdf0e10cSrcweir         rnCtrlIndex = xFormIC->getCount();
1822*cdf0e10cSrcweir         xFormIC->insertByIndex( rnCtrlIndex, Any( xFormComp ) );
1823*cdf0e10cSrcweir 
1824*cdf0e10cSrcweir         // convert the control properties
1825*cdf0e10cSrcweir         if( rControl.convertProperties( xCtrlModel, maControlConv ) )
1826*cdf0e10cSrcweir             return xCtrlModel;
1827*cdf0e10cSrcweir     }
1828*cdf0e10cSrcweir     catch( Exception& )
1829*cdf0e10cSrcweir     {
1830*cdf0e10cSrcweir     }
1831*cdf0e10cSrcweir     return Reference< XControlModel >();
1832*cdf0e10cSrcweir }
1833*cdf0e10cSrcweir 
1834*cdf0e10cSrcweir Reference< XIndexContainer > EmbeddedForm::createXForm()
1835*cdf0e10cSrcweir {
1836*cdf0e10cSrcweir     if( mxFormsSupp.is() )
1837*cdf0e10cSrcweir     {
1838*cdf0e10cSrcweir         try
1839*cdf0e10cSrcweir         {
1840*cdf0e10cSrcweir             Reference< XNameContainer > xFormsNC( mxFormsSupp->getForms(), UNO_SET_THROW );
1841*cdf0e10cSrcweir             OUString aFormName = CREATE_OUSTRING( "Standard" );
1842*cdf0e10cSrcweir             if( xFormsNC->hasByName( aFormName ) )
1843*cdf0e10cSrcweir             {
1844*cdf0e10cSrcweir                 mxFormIC.set( xFormsNC->getByName( aFormName ), UNO_QUERY_THROW );
1845*cdf0e10cSrcweir             }
1846*cdf0e10cSrcweir             else if( mxModelFactory.is() )
1847*cdf0e10cSrcweir             {
1848*cdf0e10cSrcweir                 Reference< XForm > xForm( mxModelFactory->createInstance( CREATE_OUSTRING( "com.sun.star.form.component.Form" ) ), UNO_QUERY_THROW );
1849*cdf0e10cSrcweir                 xFormsNC->insertByName( aFormName, Any( xForm ) );
1850*cdf0e10cSrcweir                 mxFormIC.set( xForm, UNO_QUERY_THROW );
1851*cdf0e10cSrcweir             }
1852*cdf0e10cSrcweir         }
1853*cdf0e10cSrcweir         catch( Exception& )
1854*cdf0e10cSrcweir         {
1855*cdf0e10cSrcweir         }
1856*cdf0e10cSrcweir         // always clear the forms supplier to not try to create the form again
1857*cdf0e10cSrcweir         mxFormsSupp.clear();
1858*cdf0e10cSrcweir     }
1859*cdf0e10cSrcweir     return mxFormIC;
1860*cdf0e10cSrcweir }
1861*cdf0e10cSrcweir 
1862*cdf0e10cSrcweir // ============================================================================
1863*cdf0e10cSrcweir 
1864*cdf0e10cSrcweir } // namespace ole
1865*cdf0e10cSrcweir } // namespace oox
1866