Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/source/ole/axcontrol.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#include <oox/ole/axcontrol.hxx>
21
22
#include <com/sun/star/awt/FontSlant.hpp>
23
#include <com/sun/star/awt/FontStrikeout.hpp>
24
#include <com/sun/star/awt/FontUnderline.hpp>
25
#include <com/sun/star/awt/FontWeight.hpp>
26
#include <com/sun/star/awt/ImagePosition.hpp>
27
#include <com/sun/star/awt/ImageScaleMode.hpp>
28
#include <com/sun/star/awt/Point.hpp>
29
#include <com/sun/star/awt/ScrollBarOrientation.hpp>
30
#include <com/sun/star/awt/Size.hpp>
31
#include <com/sun/star/awt/TextAlign.hpp>
32
#include <com/sun/star/awt/VisualEffect.hpp>
33
#include <com/sun/star/awt/XControlModel.hpp>
34
#include <com/sun/star/beans/NamedValue.hpp>
35
#include <com/sun/star/beans/XPropertySet.hpp>
36
#include <com/sun/star/container/XIndexContainer.hpp>
37
#include <com/sun/star/drawing/XDrawPage.hpp>
38
#include <com/sun/star/form/XForm.hpp>
39
#include <com/sun/star/form/XFormComponent.hpp>
40
#include <com/sun/star/form/XFormsSupplier.hpp>
41
#include <com/sun/star/form/binding/XBindableValue.hpp>
42
#include <com/sun/star/form/binding/XListEntrySink.hpp>
43
#include <com/sun/star/form/binding/XListEntrySource.hpp>
44
#include <com/sun/star/form/binding/XValueBinding.hpp>
45
#include <com/sun/star/frame/XModel.hpp>
46
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
47
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
48
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
49
#include <com/sun/star/style/VerticalAlignment.hpp>
50
#include <com/sun/star/table/CellAddress.hpp>
51
#include <com/sun/star/table/CellRangeAddress.hpp>
52
#include <rtl/tencinfo.h>
53
#include <osl/diagnose.h>
54
#include <utility>
55
#include <vcl/font.hxx>
56
#include <vcl/outdev.hxx>
57
#include <vcl/settings.hxx>
58
#include <vcl/svapp.hxx>
59
#include <oox/helper/attributelist.hxx>
60
#include <oox/helper/binaryinputstream.hxx>
61
#include <oox/helper/graphichelper.hxx>
62
#include <oox/helper/propertymap.hxx>
63
#include <oox/ole/axbinarywriter.hxx>
64
#include <oox/token/properties.hxx>
65
#include <oox/token/tokens.hxx>
66
#include <comphelper/diagnose_ex.hxx>
67
#include <o3tl/string_view.hxx>
68
69
namespace oox::ole {
70
71
using namespace ::com::sun::star;
72
using namespace ::com::sun::star::awt;
73
using namespace ::com::sun::star::beans;
74
using namespace ::com::sun::star::container;
75
using namespace ::com::sun::star::drawing;
76
using namespace ::com::sun::star::form;
77
using namespace ::com::sun::star::form::binding;
78
using namespace ::com::sun::star::frame;
79
using namespace ::com::sun::star::lang;
80
using namespace ::com::sun::star::sheet;
81
using namespace ::com::sun::star::style;
82
using namespace ::com::sun::star::table;
83
using namespace ::com::sun::star::uno;
84
85
namespace {
86
87
const sal_uInt32 COMCTL_ID_SIZE             = 0x12344321;
88
89
const sal_uInt32 COMCTL_ID_COMMONDATA       = 0xABCDEF01;
90
const sal_uInt32 COMCTL_COMMON_FLATBORDER   = 0x00000001;
91
const sal_uInt32 COMCTL_COMMON_ENABLED      = 0x00000002;
92
const sal_uInt32 COMCTL_COMMON_3DBORDER     = 0x00000004;
93
94
const sal_uInt32 COMCTL_ID_COMPLEXDATA      = 0xBDECDE1F;
95
const sal_uInt32 COMCTL_COMPLEX_FONT        = 0x00000001;
96
const sal_uInt32 COMCTL_COMPLEX_MOUSEICON   = 0x00000002;
97
98
const sal_uInt32 COMCTL_ID_SCROLLBAR_60     = 0x99470A83;
99
const sal_uInt32 COMCTL_SCROLLBAR_HOR       = 0x00000010;
100
101
const sal_uInt32 COMCTL_ID_PROGRESSBAR_50   = 0xE6E17E84;
102
const sal_uInt32 COMCTL_ID_PROGRESSBAR_60   = 0x97AB8A01;
103
104
const sal_uInt32 AX_CMDBUTTON_DEFFLAGS      = 0x0000001B;
105
const sal_uInt32 AX_LABEL_DEFFLAGS          = 0x0080001B;
106
const sal_uInt32 AX_IMAGE_DEFFLAGS          = 0x0000001B;
107
const sal_uInt32 AX_MORPHDATA_DEFFLAGS      = 0x2C80081B;
108
const sal_uInt32 AX_SPINBUTTON_DEFFLAGS     = 0x0000001B;
109
const sal_uInt32 AX_SCROLLBAR_DEFFLAGS      = 0x0000001B;
110
111
const sal_uInt16 AX_POS_TOPLEFT             = 0;
112
const sal_uInt16 AX_POS_TOP                 = 1;
113
const sal_uInt16 AX_POS_TOPRIGHT            = 2;
114
const sal_uInt16 AX_POS_LEFT                = 3;
115
const sal_uInt16 AX_POS_CENTER              = 4;
116
const sal_uInt16 AX_POS_RIGHT               = 5;
117
const sal_uInt16 AX_POS_BOTTOMLEFT          = 6;
118
const sal_uInt16 AX_POS_BOTTOM              = 7;
119
const sal_uInt16 AX_POS_BOTTOMRIGHT         = 8;
120
121
#define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image)
122
const sal_uInt32 AX_PICPOS_LEFTTOP          = AX_PICPOS_IMPL( TOPRIGHT,    TOPLEFT );
123
const sal_uInt32 AX_PICPOS_LEFTCENTER       = AX_PICPOS_IMPL( RIGHT,       LEFT );
124
const sal_uInt32 AX_PICPOS_LEFTBOTTOM       = AX_PICPOS_IMPL( BOTTOMRIGHT, BOTTOMLEFT );
125
const sal_uInt32 AX_PICPOS_RIGHTTOP         = AX_PICPOS_IMPL( TOPLEFT,     TOPRIGHT );
126
const sal_uInt32 AX_PICPOS_RIGHTCENTER      = AX_PICPOS_IMPL( LEFT,        RIGHT );
127
const sal_uInt32 AX_PICPOS_RIGHTBOTTOM      = AX_PICPOS_IMPL( BOTTOMLEFT,  BOTTOMRIGHT );
128
const sal_uInt32 AX_PICPOS_ABOVELEFT        = AX_PICPOS_IMPL( BOTTOMLEFT,  TOPLEFT );
129
const sal_uInt32 AX_PICPOS_ABOVECENTER      = AX_PICPOS_IMPL( BOTTOM,      TOP  );
130
const sal_uInt32 AX_PICPOS_ABOVERIGHT       = AX_PICPOS_IMPL( BOTTOMRIGHT, TOPRIGHT );
131
const sal_uInt32 AX_PICPOS_BELOWLEFT        = AX_PICPOS_IMPL( TOPLEFT,     BOTTOMLEFT );
132
const sal_uInt32 AX_PICPOS_BELOWCENTER      = AX_PICPOS_IMPL( TOP,         BOTTOM );
133
const sal_uInt32 AX_PICPOS_BELOWRIGHT       = AX_PICPOS_IMPL( TOPRIGHT,    BOTTOMRIGHT );
134
const sal_uInt32 AX_PICPOS_CENTER           = AX_PICPOS_IMPL( CENTER,      CENTER  );
135
#undef AX_PICPOS_IMPL
136
137
const sal_Int32 AX_MATCHENTRY_FIRSTLETTER   = 0;
138
const sal_Int32 AX_MATCHENTRY_COMPLETE      = 1;
139
const sal_Int32 AX_MATCHENTRY_NONE          = 2;
140
141
const sal_Int32 AX_ORIENTATION_AUTO         = -1;
142
const sal_Int32 AX_ORIENTATION_VERTICAL     = 0;
143
const sal_Int32 AX_ORIENTATION_HORIZONTAL   = 1;
144
145
const sal_Int32 AX_PROPTHUMB_ON             = -1;
146
147
const sal_uInt32 AX_TABSTRIP_TABS           = 0;
148
const sal_uInt32 AX_TABSTRIP_NONE           = 2;
149
150
const sal_uInt32 AX_CONTAINER_ENABLED       = 0x00000004;
151
const sal_uInt32 AX_CONTAINER_NOCLASSTABLE  = 0x00008000;
152
153
const sal_uInt32 AX_CONTAINER_DEFFLAGS      = 0x00000004;
154
155
const sal_Int32 AX_CONTAINER_DEFWIDTH       = 4000;
156
const sal_Int32 AX_CONTAINER_DEFHEIGHT      = 3000;
157
158
const sal_Int32 AX_CONTAINER_CYCLEALL       = 0;
159
160
const sal_Int32 AX_CONTAINER_SCR_NONE       = 0x00;
161
162
const sal_Int16 API_BORDER_NONE             = 0;
163
const sal_Int16 API_BORDER_SUNKEN           = 1;
164
const sal_Int16 API_BORDER_FLAT             = 2;
165
166
const sal_Int16 API_STATE_UNCHECKED         = 0;
167
const sal_Int16 API_STATE_CHECKED           = 1;
168
const sal_Int16 API_STATE_DONTKNOW          = 2;
169
170
/** Tries to extract a range address from a defined name. */
171
bool lclExtractRangeFromName( CellRangeAddress& orRangeAddr, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
172
0
{
173
0
    try
174
0
    {
175
0
        PropertySet aPropSet( rxDocModel );
176
0
        Reference< XNameAccess > xRangesNA( aPropSet.getAnyProperty( PROP_NamedRanges ), UNO_QUERY_THROW );
177
0
        Reference< XCellRangeReferrer > xReferrer( xRangesNA->getByName( rAddressString ), UNO_QUERY_THROW );
178
0
        Reference< XCellRangeAddressable > xAddressable( xReferrer->getReferredCells(), UNO_QUERY_THROW );
179
0
        orRangeAddr = xAddressable->getRangeAddress();
180
0
        return true;
181
0
    }
182
0
    catch (const Exception&)
183
0
    {
184
0
        TOOLS_WARN_EXCEPTION("oox", "");
185
0
    }
186
0
    return false;
187
0
}
188
189
bool lclExtractAddressFromName( CellAddress& orAddress, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
190
0
{
191
0
    CellRangeAddress aRangeAddr;
192
0
    if( lclExtractRangeFromName( aRangeAddr, rxDocModel, rAddressString ) &&
193
0
        (aRangeAddr.StartColumn == aRangeAddr.EndColumn) &&
194
0
        (aRangeAddr.StartRow == aRangeAddr.EndRow) )
195
0
    {
196
0
        orAddress.Sheet = aRangeAddr.Sheet;
197
0
        orAddress.Column = aRangeAddr.StartColumn;
198
0
        orAddress.Row = aRangeAddr.StartRow;
199
0
        return true;
200
0
    }
201
0
    return false;
202
0
}
203
204
void lclPrepareConverter( PropertySet& rConverter, const Reference< XModel >& rxDocModel,
205
        const OUString& rAddressString, sal_Int32 nRefSheet, bool bRange )
206
0
{
207
0
    if( !rConverter.is() ) try
208
0
    {
209
0
        Reference< XMultiServiceFactory > xModelFactory( rxDocModel, UNO_QUERY_THROW );
210
0
        OUString aServiceName = bRange ?
211
0
            u"com.sun.star.table.CellRangeAddressConversion"_ustr :
212
0
            u"com.sun.star.table.CellAddressConversion"_ustr;
213
0
        rConverter.set( xModelFactory->createInstance( aServiceName ) );
214
0
    }
215
0
    catch (const Exception&)
216
0
    {
217
0
        TOOLS_WARN_EXCEPTION("oox", "");
218
0
    }
219
0
    rConverter.setProperty( PROP_XLA1Representation, rAddressString );
220
0
    rConverter.setProperty( PROP_ReferenceSheet, nRefSheet );
221
0
}
222
223
} // namespace
224
225
ControlConverter::ControlConverter( const Reference< XModel >& rxDocModel,
226
        const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
227
8.88k
    mxDocModel( rxDocModel ),
228
8.88k
    mrGraphicHelper( rGraphicHelper ),
229
8.88k
    mbDefaultColorBgr( bDefaultColorBgr )
230
8.88k
{
231
8.88k
    OSL_ENSURE( mxDocModel.is(), "ControlConverter::ControlConverter - missing document model" );
232
8.88k
}
233
234
ControlConverter::~ControlConverter()
235
8.88k
{
236
8.88k
}
237
238
// Generic conversion ---------------------------------------------------------
239
240
void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const
241
0
{
242
    // position is given in 1/100 mm, UNO needs AppFont units
243
0
    awt::Point aAppFontPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rPos.first, rPos.second ) );
244
0
    rPropMap.setProperty( PROP_PositionX, aAppFontPos.X );
245
0
    rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y );
246
0
}
247
248
void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const
249
0
{
250
    // size is given in 1/100 mm, UNO needs AppFont units
251
0
    awt::Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rSize.first, rSize.second ) );
252
0
    rPropMap.setProperty( PROP_Width, aAppFontSize.Width );
253
0
    rPropMap.setProperty( PROP_Height, aAppFontSize.Height );
254
0
}
255
256
void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const
257
0
{
258
0
    rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) );
259
0
}
260
261
void ControlConverter::convertToMSColor( PropertySet const & rPropSet, sal_Int32 nPropId, sal_uInt32& nOleColor, sal_uInt32 nDefault )
262
0
{
263
0
    sal_uInt32 nRGB = 0;
264
0
    if (rPropSet.getProperty( nRGB, nPropId ))
265
0
        nOleColor = OleHelper::encodeOleColor( nRGB );
266
0
    else
267
0
        nOleColor = nDefault;
268
0
}
269
void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const
270
0
{
271
0
    if( rPicData.hasElements() )
272
0
    {
273
0
        uno::Reference<graphic::XGraphic> xGraphic = mrGraphicHelper.importGraphic(rPicData);
274
0
        if (xGraphic.is())
275
0
            rPropMap.setProperty(PROP_Graphic, xGraphic);
276
0
    }
277
0
}
278
279
void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizontal )
280
0
{
281
0
    sal_Int32 nScrollOrient = bHorizontal ? ScrollBarOrientation::HORIZONTAL : ScrollBarOrientation::VERTICAL;
282
0
    rPropMap.setProperty( PROP_Orientation, nScrollOrient );
283
0
}
284
285
void ControlConverter::convertToMSOrientation( PropertySet const & rPropSet, bool& bHorizontal )
286
0
{
287
0
    sal_Int32 nScrollOrient = ScrollBarOrientation::HORIZONTAL;
288
0
    if ( rPropSet.getProperty( nScrollOrient, PROP_Orientation ) )
289
0
        bHorizontal = ( nScrollOrient == ScrollBarOrientation::HORIZONTAL );
290
0
}
291
292
void ControlConverter::convertVerticalAlign( PropertyMap& rPropMap, sal_Int32 nVerticalAlign )
293
0
{
294
0
    VerticalAlignment eAlign = VerticalAlignment_TOP;
295
0
    switch( nVerticalAlign )
296
0
    {
297
0
        case XML_Top:       eAlign = VerticalAlignment_TOP;     break;
298
0
        case XML_Center:    eAlign = VerticalAlignment_MIDDLE;  break;
299
0
        case XML_Bottom:    eAlign = VerticalAlignment_BOTTOM;  break;
300
0
    }
301
0
    rPropMap.setProperty( PROP_VerticalAlign, eAlign );
302
0
}
303
304
void ControlConverter::convertScrollabilitySettings( PropertyMap& rPropMap,
305
                                         const AxPairData& rScrollPos, const AxPairData& rScrollArea,
306
                                         sal_Int32 nScrollBars ) const
307
0
{
308
0
    awt::Size tmpSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rScrollArea.first, rScrollArea.second ) );
309
0
    awt::Point tmpPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rScrollPos.first, rScrollPos.second ) );
310
0
    rPropMap.setProperty( PROP_ScrollHeight, tmpSize.Height );
311
0
    rPropMap.setProperty( PROP_ScrollWidth, tmpSize.Width );
312
0
    rPropMap.setProperty( PROP_ScrollTop, tmpPos.Y );
313
0
    rPropMap.setProperty( PROP_ScrollLeft, tmpPos.X );
314
0
    rPropMap.setProperty( PROP_HScroll, ( nScrollBars & 0x1 ) == 0x1 );
315
0
    rPropMap.setProperty( PROP_VScroll, ( nScrollBars & 0x2 ) == 0x2 );
316
0
}
317
318
void ControlConverter::convertScrollBar( PropertyMap& rPropMap,
319
        sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
320
        sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel )
321
0
{
322
0
    rPropMap.setProperty( PROP_ScrollValueMin, ::std::min( nMin, nMax ) );
323
0
    rPropMap.setProperty( PROP_ScrollValueMax, ::std::max( nMin, nMax ) );
324
0
    rPropMap.setProperty( PROP_LineIncrement, nSmallChange );
325
0
    rPropMap.setProperty( PROP_BlockIncrement, nLargeChange );
326
0
    rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition );
327
0
}
328
329
void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlModel,
330
        const OUString& rCtrlSource, const OUString& rRowSource, sal_Int32 nRefSheet ) const
331
0
{
332
    // value binding
333
0
    if( !rCtrlSource.isEmpty() ) try
334
0
    {
335
        // first check if the XBindableValue interface is supported
336
0
        Reference< XBindableValue > xBindable( rxCtrlModel, UNO_QUERY_THROW );
337
338
        // convert address string to cell address struct
339
0
        CellAddress aAddress;
340
0
        if( !lclExtractAddressFromName( aAddress, mxDocModel, rCtrlSource ) )
341
0
        {
342
0
            lclPrepareConverter( maAddressConverter, mxDocModel, rCtrlSource, nRefSheet, false );
343
0
            if( !maAddressConverter.getProperty( aAddress, PROP_Address ) )
344
0
                throw RuntimeException();
345
0
        }
346
347
        // create argument sequence
348
0
        Sequence< Any > aArgs{ Any(NamedValue(u"BoundCell"_ustr, Any(aAddress))) };
349
350
        // create the CellValueBinding instance and set at the control model
351
0
        Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
352
0
        Reference< XValueBinding > xBinding( xModelFactory->createInstanceWithArguments( u"com.sun.star.table.CellValueBinding"_ustr, aArgs ), UNO_QUERY_THROW );
353
0
        xBindable->setValueBinding( xBinding );
354
0
    }
355
0
    catch (const Exception&)
356
0
    {
357
0
        TOOLS_WARN_EXCEPTION("oox", "");
358
0
    }
359
360
    // list entry source
361
0
    if( rRowSource.isEmpty() )
362
0
        return;
363
364
0
    try
365
0
    {
366
        // first check if the XListEntrySink interface is supported
367
0
        Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
368
369
        // convert address string to cell range address struct
370
0
        CellRangeAddress aRangeAddr;
371
0
        if( !lclExtractRangeFromName( aRangeAddr, mxDocModel, rRowSource ) )
372
0
        {
373
0
            lclPrepareConverter( maRangeConverter, mxDocModel, rRowSource, nRefSheet, true );
374
0
            if( !maRangeConverter.getProperty( aRangeAddr, PROP_Address ) )
375
0
                throw RuntimeException();
376
0
        }
377
378
        // create argument sequence
379
0
        Sequence< Any > aArgs{ Any(NamedValue(u"CellRange"_ustr, Any(aRangeAddr))) };
380
381
        // create the EntrySource instance and set at the control model
382
0
        Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
383
0
        Reference< XListEntrySource > xEntrySource( xModelFactory->createInstanceWithArguments(u"com.sun.star.table.CellRangeListSource"_ustr, aArgs ), UNO_QUERY_THROW );
384
0
        xEntrySink->setListEntrySource( xEntrySource );
385
0
    }
386
0
    catch (const Exception&)
387
0
    {
388
0
        TOOLS_WARN_EXCEPTION("oox", "");
389
0
    }
390
0
}
391
392
// ActiveX (Forms 2.0) specific conversion ------------------------------------
393
394
void ControlConverter::convertAxBackground( PropertyMap& rPropMap,
395
        sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) const
396
0
{
397
0
    bool bOpaque = getFlag( nFlags, AX_FLAGS_OPAQUE );
398
0
    switch( eTranspMode )
399
0
    {
400
0
        case ApiTransparencyMode::NotSupported:
401
            // fake transparency by using system window background if needed
402
0
            convertColor( rPropMap, PROP_BackgroundColor, bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK );
403
0
        break;
404
0
        case ApiTransparencyMode::Void:
405
            // keep transparency by leaving the (void) default property value
406
0
            if( bOpaque )
407
0
                convertColor( rPropMap, PROP_BackgroundColor, nBackColor );
408
0
        break;
409
0
    }
410
0
}
411
412
void ControlConverter::convertAxBorder( PropertyMap& rPropMap,
413
        sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) const
414
0
{
415
0
    sal_Int16 nBorder = (nBorderStyle == AX_BORDERSTYLE_SINGLE) ? API_BORDER_FLAT :
416
0
        ((nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? API_BORDER_NONE : API_BORDER_SUNKEN);
417
0
    rPropMap.setProperty( PROP_Border, nBorder );
418
0
    convertColor( rPropMap, PROP_BorderColor, nBorderColor );
419
0
}
420
421
void ControlConverter::convertToAxBorder( PropertySet const & rPropSet,
422
        sal_uInt32& nBorderColor, sal_Int32& nBorderStyle, sal_Int32& nSpecialEffect )
423
0
{
424
0
    sal_Int16 nBorder = API_BORDER_NONE;
425
0
    rPropSet.getProperty( nBorder, PROP_Border );
426
0
    nBorderStyle = AX_BORDERSTYLE_NONE;
427
0
    nSpecialEffect =  AX_SPECIALEFFECT_FLAT;
428
0
    switch ( nBorder )
429
0
    {
430
0
        case API_BORDER_FLAT:
431
0
            nBorderStyle = AX_BORDERSTYLE_SINGLE;
432
0
            break;
433
0
        case API_BORDER_SUNKEN:
434
0
            nSpecialEffect =  AX_SPECIALEFFECT_SUNKEN;
435
0
            break;
436
0
        case API_BORDER_NONE:
437
0
        default:
438
0
            break;
439
0
    }
440
0
    convertToMSColor( rPropSet, PROP_BorderColor, nBorderColor );
441
0
}
442
443
void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect )
444
0
{
445
0
    sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? VisualEffect::FLAT : VisualEffect::LOOK3D;
446
0
    rPropMap.setProperty( PROP_VisualEffect, nVisualEffect );
447
0
}
448
449
void ControlConverter::convertToAxVisualEffect( PropertySet const & rPropSet, sal_Int32& nSpecialEffect )
450
0
{
451
0
    sal_Int16 nVisualEffect = AX_SPECIALEFFECT_FLAT;
452
0
    rPropSet.getProperty( nVisualEffect, PROP_VisualEffect );
453
    // is this appropriate AX_SPECIALEFFECT_XXXX value ?
454
0
    if (nVisualEffect == VisualEffect::LOOK3D )
455
0
        nSpecialEffect = AX_SPECIALEFFECT_RAISED;
456
0
}
457
458
void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const
459
0
{
460
    // the picture
461
0
    convertPicture( rPropMap, rPicData );
462
463
    // picture position
464
0
    sal_Int16 nImagePos = ImagePosition::LeftCenter;
465
0
    switch( nPicPos )
466
0
    {
467
0
        case AX_PICPOS_LEFTTOP:     nImagePos = ImagePosition::LeftTop;     break;
468
0
        case AX_PICPOS_LEFTCENTER:  nImagePos = ImagePosition::LeftCenter;  break;
469
0
        case AX_PICPOS_LEFTBOTTOM:  nImagePos = ImagePosition::LeftBottom;  break;
470
0
        case AX_PICPOS_RIGHTTOP:    nImagePos = ImagePosition::RightTop;    break;
471
0
        case AX_PICPOS_RIGHTCENTER: nImagePos = ImagePosition::RightCenter; break;
472
0
        case AX_PICPOS_RIGHTBOTTOM: nImagePos = ImagePosition::RightBottom; break;
473
0
        case AX_PICPOS_ABOVELEFT:   nImagePos = ImagePosition::AboveLeft;   break;
474
0
        case AX_PICPOS_ABOVECENTER: nImagePos = ImagePosition::AboveCenter; break;
475
0
        case AX_PICPOS_ABOVERIGHT:  nImagePos = ImagePosition::AboveRight;  break;
476
0
        case AX_PICPOS_BELOWLEFT:   nImagePos = ImagePosition::BelowLeft;   break;
477
0
        case AX_PICPOS_BELOWCENTER: nImagePos = ImagePosition::BelowCenter; break;
478
0
        case AX_PICPOS_BELOWRIGHT:  nImagePos = ImagePosition::BelowRight;  break;
479
0
        case AX_PICPOS_CENTER:      nImagePos = ImagePosition::Centered;    break;
480
0
        default:    OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture position" );
481
0
    }
482
0
    rPropMap.setProperty( PROP_ImagePosition, nImagePos );
483
0
}
484
485
void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData,
486
        sal_Int32 nPicSizeMode ) const
487
0
{
488
    // the picture
489
0
    convertPicture( rPropMap, rPicData );
490
491
    // picture scale mode
492
0
    sal_Int16 nScaleMode = ImageScaleMode::NONE;
493
0
    switch( nPicSizeMode )
494
0
    {
495
0
        case AX_PICSIZE_CLIP:       nScaleMode = ImageScaleMode::NONE;          break;
496
0
        case AX_PICSIZE_STRETCH:    nScaleMode = ImageScaleMode::ANISOTROPIC;   break;
497
0
        case AX_PICSIZE_ZOOM:       nScaleMode = ImageScaleMode::ISOTROPIC;     break;
498
0
        default:    OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture size mode" );
499
0
    }
500
0
    rPropMap.setProperty( PROP_ScaleMode, nScaleMode );
501
0
}
502
503
void ControlConverter::convertAxState( PropertyMap& rPropMap,
504
        std::u16string_view rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel )
505
0
{
506
0
    bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN;
507
0
    bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
508
509
    // state
510
0
    sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED;
511
0
    if( rValue.size() == 1 ) switch( rValue[ 0 ] )
512
0
    {
513
0
        case '0':   nState = API_STATE_UNCHECKED;   break;
514
0
        case '1':   nState = API_STATE_CHECKED;     break;
515
        // any other string (also empty) means 'dontknow'
516
0
    }
517
0
    sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState;
518
0
    if( bBooleanState )
519
0
        rPropMap.setProperty( nPropId, nState != API_STATE_UNCHECKED );
520
0
    else
521
0
        rPropMap.setProperty( nPropId, nState );
522
523
    // tristate
524
0
    if( bSupportsTriState )
525
0
        rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELECTION_MULTI );
526
0
}
527
528
void ControlConverter::convertToAxState( PropertySet const & rPropSet,
529
        OUString& rValue, sal_Int32& nMultiSelect, ApiDefaultStateMode eDefStateMode )
530
0
{
531
0
    bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
532
533
0
    sal_Int16 nState = API_STATE_DONTKNOW;
534
535
    // need to use State for current state ( I think this is regardless of whether
536
    // control is awt or not )
537
0
    rPropSet.getProperty( nState, PROP_State );
538
539
0
    rValue.clear(); // empty e.g. 'don't know'
540
0
    if ( nState == API_STATE_UNCHECKED )
541
0
        rValue = "0";
542
0
    else if ( nState == API_STATE_CHECKED )
543
0
        rValue = "1";
544
545
    // tristate
546
0
    if( bSupportsTriState )
547
0
    {
548
0
        bool bTriStateEnabled = false;
549
0
        bool bPropertyExists = rPropSet.getProperty( bTriStateEnabled, PROP_TriState );
550
0
        if( bPropertyExists && bTriStateEnabled )
551
0
            nMultiSelect = AX_SELECTION_MULTI;
552
0
    }
553
0
}
554
555
void ControlConverter::convertAxOrientation( PropertyMap& rPropMap,
556
        const AxPairData& rSize, sal_Int32 nOrientation )
557
0
{
558
0
    bool bHorizontal = true;
559
0
    switch( nOrientation )
560
0
    {
561
0
        case AX_ORIENTATION_AUTO:       bHorizontal = rSize.first > rSize.second;   break;
562
0
        case AX_ORIENTATION_VERTICAL:   bHorizontal = false;                        break;
563
0
        case AX_ORIENTATION_HORIZONTAL: bHorizontal = true;                         break;
564
0
        default:    OSL_FAIL( "ControlConverter::convertAxOrientation - unknown orientation" );
565
0
    }
566
0
    convertOrientation( rPropMap, bHorizontal );
567
0
}
568
569
void ControlConverter::convertToAxOrientation( PropertySet const & rPropSet,
570
        sal_Int32& nOrientation )
571
0
{
572
0
    bool bHorizontal = true;
573
0
    convertToMSOrientation( rPropSet, bHorizontal );
574
575
0
    if ( bHorizontal )
576
0
        nOrientation = AX_ORIENTATION_HORIZONTAL;
577
0
    else
578
0
        nOrientation = AX_ORIENTATION_VERTICAL;
579
0
}
580
581
ControlModelBase::ControlModelBase() :
582
25
    maSize( 0, 0 ),
583
25
    mbAwtModel( false )
584
25
{
585
25
}
586
587
ControlModelBase::~ControlModelBase()
588
25
{
589
25
}
590
591
OUString ControlModelBase::getServiceName() const
592
25
{
593
25
    ApiControlType eCtrlType = getControlType();
594
25
    if( mbAwtModel ) switch( eCtrlType )
595
0
    {
596
0
        case API_CONTROL_BUTTON:        return u"com.sun.star.awt.UnoControlButtonModel"_ustr;
597
0
        case API_CONTROL_FIXEDTEXT:     return u"com.sun.star.awt.UnoControlFixedTextModel"_ustr;
598
0
        case API_CONTROL_IMAGE:         return u"com.sun.star.awt.UnoControlImageControlModel"_ustr;
599
0
        case API_CONTROL_CHECKBOX:      return u"com.sun.star.awt.UnoControlCheckBoxModel"_ustr;
600
0
        case API_CONTROL_RADIOBUTTON:   return u"com.sun.star.form.component.RadioButton"_ustr;
601
0
        case API_CONTROL_EDIT:          return u"com.sun.star.awt.UnoControlEditModel"_ustr;
602
0
        case API_CONTROL_NUMERIC:       return u"com.sun.star.awt.UnoControlNumericFieldModel"_ustr;
603
0
        case API_CONTROL_LISTBOX:       return u"com.sun.star.form.component.ListBox"_ustr;
604
0
        case API_CONTROL_COMBOBOX:      return u"com.sun.star.form.component.ComboBox"_ustr;
605
0
        case API_CONTROL_SPINBUTTON:    return u"com.sun.star.form.component.SpinButton"_ustr;
606
0
        case API_CONTROL_SCROLLBAR:     return u"com.sun.star.form.component.ScrollBar"_ustr;
607
0
        case API_CONTROL_PROGRESSBAR:   return u"com.sun.star.awt.UnoControlProgressBarModel"_ustr;
608
0
        case API_CONTROL_GROUPBOX:      return u"com.sun.star.form.component.GroupBox"_ustr;
609
0
        case API_CONTROL_FRAME:         return u"com.sun.star.awt.UnoFrameModel"_ustr;
610
0
        case API_CONTROL_PAGE:          return u"com.sun.star.awt.UnoPageModel"_ustr;
611
0
        case API_CONTROL_MULTIPAGE:     return u"com.sun.star.awt.UnoMultiPageModel"_ustr;
612
0
        case API_CONTROL_DIALOG:        return u"com.sun.star.awt.UnoControlDialogModel"_ustr;
613
0
        default:    OSL_FAIL( "ControlModelBase::getServiceName - no AWT model service supported" );
614
0
    }
615
25
    else switch( eCtrlType )
616
25
    {
617
10
        case API_CONTROL_BUTTON:        return u"com.sun.star.form.component.CommandButton"_ustr;
618
0
        case API_CONTROL_FIXEDTEXT:     return u"com.sun.star.form.component.FixedText"_ustr;
619
0
        case API_CONTROL_IMAGE:         return u"com.sun.star.form.component.DatabaseImageControl"_ustr;
620
2
        case API_CONTROL_CHECKBOX:      return u"com.sun.star.form.component.CheckBox"_ustr;
621
0
        case API_CONTROL_RADIOBUTTON:   return u"com.sun.star.form.component.RadioButton"_ustr;
622
8
        case API_CONTROL_EDIT:          return u"com.sun.star.form.component.TextField"_ustr;
623
0
        case API_CONTROL_NUMERIC:       return u"com.sun.star.form.component.NumericField"_ustr;
624
1
        case API_CONTROL_LISTBOX:       return u"com.sun.star.form.component.ListBox"_ustr;
625
0
        case API_CONTROL_COMBOBOX:      return u"com.sun.star.form.component.ComboBox"_ustr;
626
0
        case API_CONTROL_SPINBUTTON:    return u"com.sun.star.form.component.SpinButton"_ustr;
627
4
        case API_CONTROL_SCROLLBAR:     return u"com.sun.star.form.component.ScrollBar"_ustr;
628
0
        case API_CONTROL_GROUPBOX:      return u"com.sun.star.form.component.GroupBox"_ustr;
629
0
        default:    OSL_FAIL( "ControlModelBase::getServiceName - no form component service supported" );
630
25
    }
631
0
    return OUString();
632
25
}
633
634
void ControlModelBase::importProperty( sal_Int32 /*nPropId*/, const OUString& /*rValue*/ )
635
0
{
636
0
}
637
638
void ControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ )
639
0
{
640
0
}
641
642
void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const ControlConverter& /*rConv*/ ) const
643
0
{
644
0
}
645
646
void ControlModelBase::convertFromProperties( PropertySet& /*rPropMap*/, const ControlConverter& /*rConv*/ )
647
0
{
648
0
}
649
650
void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const
651
0
{
652
0
    rConv.convertSize( rPropMap, maSize );
653
0
}
654
655
ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6,
656
        sal_uInt16 nVersion ) :
657
0
    maFontData( u"Tahoma"_ustr, 82500 ),
658
0
    mnFlags( 0 ),
659
0
    mnVersion( nVersion ),
660
0
    mnDataPartId5( nDataPartId5 ),
661
0
    mnDataPartId6( nDataPartId6 ),
662
0
    mbCommonPart( true ),
663
0
    mbComplexPart( true )
664
0
{
665
0
}
666
667
bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm )
668
0
{
669
    // read initial size part and header of the control data part
670
0
    if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) )
671
0
    {
672
        // if flags part exists, the first int32 of the data part contains its size
673
0
        sal_uInt32 nCommonPartSize = 0;
674
0
        if (mbCommonPart)
675
0
            nCommonPartSize = rInStrm.readuInt32();
676
        // implementations must read the exact amount of data, stream must point to its end afterwards
677
0
        importControlData( rInStrm );
678
        // read following parts
679
0
        if( !rInStrm.isEof() &&
680
0
            (!mbCommonPart || importCommonPart( rInStrm, nCommonPartSize )) &&
681
0
            (!mbComplexPart || importComplexPart( rInStrm )) )
682
0
        {
683
0
            return !rInStrm.isEof();
684
0
        }
685
0
    }
686
0
    return false;
687
0
}
688
689
void ComCtlModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
690
0
{
691
0
    if( mbCommonPart )
692
0
        rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, COMCTL_COMMON_ENABLED ) );
693
0
    ControlModelBase::convertProperties( rPropMap, rConv );
694
0
}
695
696
sal_uInt32 ComCtlModelBase::getDataPartId() const
697
0
{
698
0
    switch( mnVersion )
699
0
    {
700
0
        case COMCTL_VERSION_50: return mnDataPartId5;
701
0
        case COMCTL_VERSION_60: return mnDataPartId6;
702
0
    }
703
0
    OSL_FAIL( "ComCtlObjectBase::getDataPartId - unexpected version" );
704
0
    return SAL_MAX_UINT32;
705
0
}
706
707
bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
708
0
{
709
    // no idea if all this is correct...
710
0
    sal_uInt32 nPartId = rInStrm.readuInt32();
711
0
    sal_uInt16 nMinor = rInStrm.readuInt16();
712
0
    sal_uInt16 nMajor = rInStrm.readuInt16();
713
0
    bool bPartId = nPartId == nExpPartId;
714
0
    OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" );
715
0
    bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
716
0
    OSL_ENSURE( bVersion, "ComCtlObjectBase::readPartHeader - unexpected part version" );
717
0
    return !rInStrm.isEof() && bPartId && bVersion;
718
0
}
719
720
bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm )
721
0
{
722
0
    if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) )
723
0
    {
724
0
        maSize.first = rInStrm.readInt32();
725
0
        maSize.second = rInStrm.readInt32();
726
0
        return !rInStrm.isEof();
727
0
    }
728
0
    return false;
729
0
}
730
731
bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize )
732
0
{
733
0
    sal_Int64 nEndPos = rInStrm.tell() + nPartSize;
734
0
    if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) )
735
0
    {
736
0
        rInStrm.skip( 4 );
737
0
        mnFlags = rInStrm.readuInt32();
738
0
        rInStrm.seek( nEndPos );
739
0
        return !rInStrm.isEof();
740
0
    }
741
0
    return false;
742
0
}
743
744
bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm )
745
0
{
746
0
    if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) )
747
0
    {
748
0
        sal_uInt32 nContFlags = rInStrm.readuInt32();
749
0
        bool bReadOk =
750
0
            (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) &&
751
0
            (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm ));
752
0
        return bReadOk && !rInStrm.isEof();
753
0
    }
754
0
    return false;
755
0
}
756
757
ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion ) :
758
0
    ComCtlModelBase( SAL_MAX_UINT32, COMCTL_ID_SCROLLBAR_60, nVersion ),
759
0
    mnScrollBarFlags( 0x00000011 ),
760
0
    mnLargeChange( 1 ),
761
0
    mnSmallChange( 1 ),
762
0
    mnMin( 0 ),
763
0
    mnMax( 32767 ),
764
0
    mnPosition( 0 )
765
0
{
766
0
}
767
768
ApiControlType ComCtlScrollBarModel::getControlType() const
769
0
{
770
0
    return API_CONTROL_SCROLLBAR;
771
0
}
772
773
void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
774
0
{
775
0
    rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
776
0
    ControlConverter::convertOrientation( rPropMap, getFlag( mnScrollBarFlags, COMCTL_SCROLLBAR_HOR ) );
777
0
    ControlConverter::convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
778
0
    ComCtlModelBase::convertProperties( rPropMap, rConv );
779
0
}
780
781
void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm )
782
0
{
783
0
    mnScrollBarFlags = rInStrm.readuInt32();
784
0
    mnLargeChange = rInStrm.readInt32();
785
0
    mnSmallChange = rInStrm.readInt32();
786
0
    mnMin = rInStrm.readInt32();
787
0
    mnMax = rInStrm.readInt32();
788
0
    mnPosition = rInStrm.readInt32();
789
0
}
790
791
ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) :
792
0
    ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50, COMCTL_ID_PROGRESSBAR_60, nVersion ),
793
0
    mfMin( 0.0 ),
794
0
    mfMax( 100.0 ),
795
0
    mnVertical( 0 ),
796
0
    mnSmooth( 0 )
797
0
{
798
0
}
799
800
ApiControlType ComCtlProgressBarModel::getControlType() const
801
0
{
802
0
    return API_CONTROL_PROGRESSBAR;
803
0
}
804
805
void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
806
0
{
807
0
    sal_uInt16 nBorder = getFlag( mnFlags, COMCTL_COMMON_3DBORDER ) ? API_BORDER_SUNKEN :
808
0
        (getFlag( mnFlags, COMCTL_COMMON_FLATBORDER ) ? API_BORDER_FLAT : API_BORDER_NONE);
809
0
    rPropMap.setProperty( PROP_Border, nBorder );
810
0
    rPropMap.setProperty( PROP_ProgressValueMin, getLimitedValue< sal_Int32, double >( ::std::min( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
811
0
    rPropMap.setProperty( PROP_ProgressValueMax, getLimitedValue< sal_Int32, double >( ::std::max( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
812
    // ComCtl model does not provide current value?
813
0
    ComCtlModelBase::convertProperties( rPropMap, rConv );
814
0
}
815
816
void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm )
817
0
{
818
0
    mfMin = rInStrm.readFloat();
819
0
    mfMax = rInStrm.readFloat();
820
0
    if( mnVersion == COMCTL_VERSION_60 )
821
0
    {
822
0
        mnVertical = rInStrm.readuInt16();
823
0
        mnSmooth = rInStrm.readuInt16();
824
0
    }
825
0
}
826
827
AxControlModelBase::AxControlModelBase()
828
25
{
829
25
}
830
831
void AxControlModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
832
0
{
833
0
    switch( nPropId )
834
0
    {
835
        // size of the control shape: format is "width;height"
836
0
        case XML_Size:
837
0
        {
838
0
            sal_Int32 nSepPos = rValue.indexOf( ';' );
839
0
            OSL_ENSURE( nSepPos >= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" );
840
0
            if( nSepPos >= 0 )
841
0
            {
842
0
                maSize.first = o3tl::toInt32(rValue.subView( 0, nSepPos ));
843
0
                maSize.second = o3tl::toInt32(rValue.subView( nSepPos + 1 ));
844
0
            }
845
0
        }
846
0
        break;
847
0
    }
848
0
}
849
850
AxFontDataModel::AxFontDataModel( bool bSupportsAlign ) :
851
21
    mbSupportsAlign( bSupportsAlign )
852
21
{
853
21
}
854
855
void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
856
0
{
857
0
    switch( nPropId )
858
0
    {
859
0
        case XML_FontName:          maFontData.maFontName = rValue;                                             break;
860
0
        case XML_FontEffects:
861
0
            maFontData.mnFontEffects = static_cast<AxFontFlags>(AttributeConversion::decodeUnsigned( rValue ));
862
0
            break;
863
0
        case XML_FontHeight:        maFontData.mnFontHeight = AttributeConversion::decodeInteger( rValue );     break;
864
0
        case XML_FontCharSet:       maFontData.mnFontCharSet = AttributeConversion::decodeInteger( rValue );    break;
865
0
        case XML_ParagraphAlign:
866
0
            maFontData.mnHorAlign = static_cast<AxHorizontalAlign>(AttributeConversion::decodeInteger( rValue ));
867
0
            break;
868
0
        default:                    AxControlModelBase::importProperty( nPropId, rValue );
869
0
    }
870
0
}
871
872
bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm )
873
18
{
874
18
    return maFontData.importBinaryModel( rInStrm );
875
18
}
876
877
void AxFontDataModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
878
0
{
879
0
    maFontData.exportBinaryModel( rOutStrm );
880
0
}
881
void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
882
0
{
883
    // font name
884
0
    if( !maFontData.maFontName.isEmpty() )
885
0
        rPropMap.setProperty( PROP_FontName, maFontData.maFontName );
886
887
    // font effects
888
0
    rPropMap.setProperty( PROP_FontWeight, maFontData.mnFontEffects & AxFontFlags::Bold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL );
889
0
    rPropMap.setProperty( PROP_FontSlant, maFontData.mnFontEffects & AxFontFlags::Italic ? FontSlant_ITALIC : FontSlant_NONE );
890
0
    if (maFontData.mnFontEffects & AxFontFlags::Underline)
891
0
        rPropMap.setProperty( PROP_FontUnderline, maFontData.mbDblUnderline ? awt::FontUnderline::DOUBLE : awt::FontUnderline::SINGLE );
892
0
    else
893
0
        rPropMap.setProperty( PROP_FontUnderline, awt::FontUnderline::NONE );
894
0
    rPropMap.setProperty( PROP_FontStrikeout, maFontData.mnFontEffects & AxFontFlags::Strikeout ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE );
895
0
    rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() );
896
897
    // font character set
898
0
    rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
899
0
    if( (0 <= maFontData.mnFontCharSet) && (maFontData.mnFontCharSet <= SAL_MAX_UINT8) )
900
0
        eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maFontData.mnFontCharSet ) );
901
0
    if( eFontEnc != RTL_TEXTENCODING_DONTKNOW )
902
0
        rPropMap.setProperty( PROP_FontCharset, static_cast< sal_Int16 >( eFontEnc ) );
903
904
    // text alignment
905
0
    if( mbSupportsAlign )
906
0
    {
907
0
        sal_Int32 nAlign = awt::TextAlign::LEFT;
908
0
        switch( maFontData.mnHorAlign )
909
0
        {
910
0
            case AxHorizontalAlign::Left:      nAlign = awt::TextAlign::LEFT;   break;
911
0
            case AxHorizontalAlign::Right:     nAlign = awt::TextAlign::RIGHT;  break;
912
0
            case AxHorizontalAlign::Center:    nAlign = awt::TextAlign::CENTER; break;
913
0
            default:    OSL_FAIL( "AxFontDataModel::convertProperties - unknown text alignment" );
914
0
        }
915
        // form controls expect short value
916
0
        rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) );
917
0
    }
918
919
    // process base class properties
920
0
    AxControlModelBase::convertProperties( rPropMap, rConv );
921
0
}
922
923
void AxFontDataModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& /*rConv */)
924
0
{
925
0
    rPropSet.getProperty( maFontData.maFontName, PROP_FontName );
926
0
    float fontWeight = float(0);
927
0
    if ( rPropSet.getProperty(fontWeight, PROP_FontWeight ) )
928
0
        setFlag( maFontData.mnFontEffects, AxFontFlags::Bold, ( fontWeight == awt::FontWeight::BOLD ) );
929
0
    FontSlant nSlant = FontSlant_NONE;
930
0
    if ( rPropSet.getProperty( nSlant, PROP_FontSlant ) )
931
0
        setFlag( maFontData.mnFontEffects, AxFontFlags::Italic, ( nSlant == FontSlant_ITALIC ) );
932
933
0
    sal_Int16 nUnderLine = awt::FontUnderline::NONE;
934
0
    if ( rPropSet.getProperty( nUnderLine, PROP_FontUnderline ) )
935
0
        setFlag( maFontData.mnFontEffects, AxFontFlags::Underline, nUnderLine != awt::FontUnderline::NONE && nUnderLine != awt::FontUnderline::DONTKNOW);
936
0
    sal_Int16 nStrikeout = awt::FontStrikeout::NONE ;
937
0
    if ( rPropSet.getProperty( nStrikeout, PROP_FontStrikeout ) )
938
0
        setFlag( maFontData.mnFontEffects, AxFontFlags::Strikeout, nStrikeout != awt::FontStrikeout::NONE && nStrikeout != awt::FontStrikeout::DONTKNOW);
939
940
0
    float fontHeight = 0.0;
941
0
    if ( rPropSet.getProperty( fontHeight, PROP_FontHeight ) )
942
0
    {
943
0
        if ( fontHeight == 0 )  // tdf#118684
944
0
        {
945
0
            vcl::Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
946
0
            fontHeight = static_cast< float >( aDefaultVCLFont.GetFontHeight() );
947
0
        }
948
0
        maFontData.setHeightPoints( static_cast< sal_Int16 >( fontHeight ) );
949
0
    }
950
951
    // TODO - handle textencoding
952
0
    sal_Int16 nAlign = 0;
953
0
    if ( rPropSet.getProperty( nAlign, PROP_Align ) )
954
0
    {
955
0
        switch ( nAlign )
956
0
        {
957
0
            case awt::TextAlign::LEFT: maFontData.mnHorAlign = AxHorizontalAlign::Left;   break;
958
0
            case awt::TextAlign::RIGHT: maFontData.mnHorAlign = AxHorizontalAlign::Right;  break;
959
0
            case awt::TextAlign::CENTER: maFontData.mnHorAlign = AxHorizontalAlign::Center; break;
960
0
            default:    OSL_FAIL( "AxFontDataModel::convertFromProperties - unknown text alignment" );
961
0
        }
962
0
    }
963
0
}
964
965
AxCommandButtonModel::AxCommandButtonModel() :
966
10
    mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
967
10
    mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
968
10
    mnFlags( AX_CMDBUTTON_DEFFLAGS ),
969
10
    mnPicturePos( AX_PICPOS_ABOVECENTER ),
970
10
    mnVerticalAlign( XML_Center ),
971
10
    mbFocusOnClick( true )
972
10
{
973
10
}
974
975
void AxCommandButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
976
0
{
977
0
    switch( nPropId )
978
0
    {
979
0
        case XML_Caption:               maCaption = rValue;                                                 break;
980
0
        case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );        break;
981
0
        case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );        break;
982
0
        case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );            break;
983
0
        case XML_PicturePosition:       mnPicturePos = AttributeConversion::decodeUnsigned( rValue );       break;
984
0
        case XML_TakeFocusOnClick:      mbFocusOnClick = AttributeConversion::decodeInteger( rValue ) != 0; break;
985
0
        default:                        AxFontDataModel::importProperty( nPropId, rValue );
986
0
    }
987
0
}
988
989
void AxCommandButtonModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
990
0
{
991
0
    switch( nPropId )
992
0
    {
993
0
        case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm );    break;
994
0
        default:            AxFontDataModel::importPictureData( nPropId, rInStrm );
995
0
    }
996
0
}
997
998
bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
999
10
{
1000
10
    AxBinaryPropertyReader aReader( rInStrm );
1001
10
    aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1002
10
    aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1003
10
    aReader.readIntProperty< sal_uInt32 >( mnFlags );
1004
10
    aReader.readStringProperty( maCaption );
1005
10
    aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
1006
10
    aReader.readPairProperty( maSize );
1007
10
    aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1008
10
    aReader.readPictureProperty( maPictureData );
1009
10
    aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1010
10
    aReader.readBoolProperty( mbFocusOnClick, true ); // binary flag means "do not take focus"
1011
10
    aReader.skipPictureProperty(); // mouse icon
1012
10
    return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1013
10
}
1014
1015
void AxCommandButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1016
0
{
1017
0
    AxBinaryPropertyWriter aWriter( rOutStrm );
1018
0
    aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1019
0
    if ( mnBackColor )
1020
0
        aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1021
0
    else
1022
0
        aWriter.skipProperty(); // default backcolour
1023
0
    aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1024
0
    aWriter.writeStringProperty( maCaption );
1025
0
    aWriter.skipProperty(); // pict pos
1026
0
    aWriter.writePairProperty( maSize );
1027
0
    aWriter.skipProperty(); // mouse pointer
1028
0
    aWriter.skipProperty(); // picture data
1029
0
    aWriter.skipProperty(); // accelerator
1030
0
    aWriter.writeBoolProperty( mbFocusOnClick ); // binary flag means "do not take focus"
1031
0
    aWriter.skipProperty(); // mouse icon
1032
0
    aWriter.finalizeExport();
1033
0
    AxFontDataModel::exportBinaryModel( rOutStrm );
1034
0
}
1035
1036
void AxCommandButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1037
0
{
1038
    // should be able to replace this hardcoded foo with
1039
    // proper export info from MS-OLEDS spec.
1040
0
    static sal_uInt8 const aCompObj[] = {
1041
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1042
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1043
0
        0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1044
0
        0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1045
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1046
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1047
0
        0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1048
0
        0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1049
0
        0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1050
0
        0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1051
0
        0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1052
0
        0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1053
0
        0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1054
0
        0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1055
0
        0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1056
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1057
0
    };
1058
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1059
0
}
1060
1061
ApiControlType AxCommandButtonModel::getControlType() const
1062
10
{
1063
10
    return API_CONTROL_BUTTON;
1064
10
}
1065
1066
void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1067
0
{
1068
0
    rPropMap.setProperty( PROP_Label, maCaption );
1069
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1070
0
    rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1071
0
    rPropMap.setProperty( PROP_FocusOnClick, mbFocusOnClick );
1072
0
    rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1073
0
    ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1074
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
1075
0
    rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1076
0
    AxFontDataModel::convertProperties( rPropMap, rConv );
1077
0
}
1078
1079
void AxCommandButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1080
0
{
1081
0
    (void)rPropSet.getProperty(maCaption, PROP_Label);
1082
0
    bool bRes = false;
1083
0
    if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
1084
0
        setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
1085
0
    if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
1086
0
        setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1087
0
    (void)rPropSet.getProperty(mbFocusOnClick, PROP_FocusOnClick);
1088
1089
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1090
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1091
1092
0
    AxFontDataModel::convertFromProperties( rPropSet, rConv );
1093
0
}
1094
1095
AxLabelModel::AxLabelModel() :
1096
0
    mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
1097
0
    mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1098
0
    mnFlags( AX_LABEL_DEFFLAGS ),
1099
0
    mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1100
0
    mnBorderStyle( AX_BORDERSTYLE_NONE ),
1101
0
    mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1102
0
    mnVerticalAlign( XML_Top )
1103
0
{
1104
0
}
1105
1106
void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1107
0
{
1108
0
    switch( nPropId )
1109
0
    {
1110
0
        case XML_Caption:               maCaption = rValue;                                             break;
1111
0
        case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );    break;
1112
0
        case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
1113
0
        case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
1114
0
        case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );  break;
1115
0
        case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );   break;
1116
0
        case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1117
0
        default:                        AxFontDataModel::importProperty( nPropId, rValue );
1118
0
    }
1119
0
}
1120
1121
bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm )
1122
0
{
1123
0
    AxBinaryPropertyReader aReader( rInStrm );
1124
0
    aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1125
0
    aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1126
0
    aReader.readIntProperty< sal_uInt32 >( mnFlags );
1127
0
    aReader.readStringProperty( maCaption );
1128
0
    aReader.skipIntProperty< sal_uInt32 >(); // picture position
1129
0
    aReader.readPairProperty( maSize );
1130
0
    aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1131
0
    aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1132
0
    aReader.readIntProperty< sal_uInt16 >( mnBorderStyle );
1133
0
    aReader.readIntProperty< sal_uInt16 >( mnSpecialEffect );
1134
0
    aReader.skipPictureProperty(); // picture
1135
0
    aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1136
0
    aReader.skipPictureProperty(); // mouse icon
1137
0
    return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1138
0
}
1139
1140
void AxLabelModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1141
0
{
1142
0
    AxBinaryPropertyWriter aWriter( rOutStrm );
1143
0
    aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1144
0
    if ( mnBackColor )
1145
0
        aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1146
0
    else
1147
        // if mnBackColor == 0 then it's the libreoffice default backcolour is
1148
        // the MSO Label default which is AX_SYSCOLOR_BUTTONFACE
1149
0
        aWriter.writeIntProperty< sal_uInt32 >( AX_SYSCOLOR_WINDOWBACK );
1150
0
    aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1151
0
    aWriter.writeStringProperty( maCaption );
1152
0
    aWriter.skipProperty(); // picture position
1153
0
    aWriter.writePairProperty( maSize );
1154
0
    aWriter.skipProperty(); // mouse pointer
1155
0
    aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1156
0
    aWriter.writeIntProperty< sal_uInt16 >( mnBorderStyle );
1157
0
    aWriter.writeIntProperty< sal_uInt16 >( mnSpecialEffect );
1158
0
    aWriter.skipProperty(); // picture
1159
0
    aWriter.skipProperty(); // accelerator
1160
0
    aWriter.skipProperty(); // mouse icon
1161
0
    aWriter.finalizeExport();
1162
0
    AxFontDataModel::exportBinaryModel( rOutStrm );
1163
0
}
1164
1165
void AxLabelModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1166
0
{
1167
0
    rPropSet.getProperty( maCaption, PROP_Label );
1168
0
    bool bRes = false;
1169
0
    if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
1170
0
        setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
1171
0
    if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
1172
0
        setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1173
1174
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1175
    // VerticalAlign doesn't seem to be read from binary
1176
1177
    // not sure about background color, how do we decide when to set
1178
    // AX_FLAGS_OPAQUE ?
1179
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor  );
1180
0
    ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1181
1182
0
    AxFontDataModel::convertFromProperties( rPropSet, rConv );
1183
0
}
1184
1185
void AxLabelModel::exportCompObj( BinaryOutputStream& rOutStream )
1186
0
{
1187
    // should be able to replace this hardcoded foo with
1188
    // proper export info from MS-OLEDS spec.
1189
0
    static sal_uInt8 const aCompObj[] = {
1190
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1191
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
1192
0
        0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
1193
0
        0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
1194
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1195
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1196
0
        0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
1197
0
        0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1198
0
        0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1199
0
        0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1200
0
        0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1201
0
        0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
1202
0
        0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1203
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1204
0
    };
1205
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1206
0
}
1207
1208
ApiControlType AxLabelModel::getControlType() const
1209
0
{
1210
0
    return API_CONTROL_FIXEDTEXT;
1211
0
}
1212
1213
void AxLabelModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1214
0
{
1215
0
    rPropMap.setProperty( PROP_Label, maCaption );
1216
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1217
0
    rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1218
0
    rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1219
0
    ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1220
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1221
0
    rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1222
0
    AxFontDataModel::convertProperties( rPropMap, rConv );
1223
0
}
1224
1225
AxImageModel::AxImageModel() :
1226
0
    mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1227
0
    mnFlags( AX_IMAGE_DEFFLAGS ),
1228
0
    mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1229
0
    mnBorderStyle( AX_BORDERSTYLE_SINGLE ),
1230
0
    mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1231
0
    mnPicSizeMode( AX_PICSIZE_CLIP ),
1232
0
    mnPicAlign( AX_PICALIGN_CENTER ),
1233
0
    mbPicTiling( false )
1234
0
{
1235
0
}
1236
1237
void AxImageModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1238
0
{
1239
0
    switch( nPropId )
1240
0
    {
1241
0
        case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );      break;
1242
0
        case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );          break;
1243
0
        case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );    break;
1244
0
        case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );     break;
1245
0
        case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue );   break;
1246
0
        case XML_SizeMode:              mnPicSizeMode = AttributeConversion::decodeInteger( rValue );     break;
1247
0
        case XML_PictureAlignment:      mnPicAlign = AttributeConversion::decodeInteger( rValue );        break;
1248
0
        case XML_PictureTiling:         mbPicTiling = AttributeConversion::decodeInteger( rValue ) != 0;  break;
1249
0
        default:                        AxControlModelBase::importProperty( nPropId, rValue );
1250
0
    }
1251
0
}
1252
1253
void AxImageModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1254
0
{
1255
0
    switch( nPropId )
1256
0
    {
1257
0
        case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm );    break;
1258
0
        default:            AxControlModelBase::importPictureData( nPropId, rInStrm );
1259
0
    }
1260
0
}
1261
1262
bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm )
1263
0
{
1264
0
    AxBinaryPropertyReader aReader( rInStrm );
1265
0
    aReader.skipUndefinedProperty();
1266
0
    aReader.skipUndefinedProperty();
1267
0
    aReader.skipBoolProperty(); // auto-size
1268
0
    aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1269
0
    aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1270
0
    aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1271
0
    aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1272
0
    aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
1273
0
    aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
1274
0
    aReader.readPairProperty( maSize );
1275
0
    aReader.readPictureProperty( maPictureData );
1276
0
    aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
1277
0
    aReader.readBoolProperty( mbPicTiling );
1278
0
    aReader.readIntProperty< sal_uInt32 >( mnFlags );
1279
0
    aReader.skipPictureProperty(); // mouse icon
1280
0
    return aReader.finalizeImport();
1281
0
}
1282
1283
void AxImageModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1284
0
{
1285
0
    AxBinaryPropertyWriter aWriter( rOutStrm );
1286
0
    aWriter.skipProperty(); //undefined
1287
0
    aWriter.skipProperty(); //undefined
1288
0
    aWriter.skipProperty(); //auto-size
1289
0
    aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1290
0
    if ( mnBackColor )
1291
0
        aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1292
0
    else
1293
0
        aWriter.skipProperty(); // default backcolour
1294
0
    aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
1295
0
    aWriter.skipProperty(); // mouse pointer
1296
0
    aWriter.writeIntProperty< sal_uInt8 >( mnPicSizeMode );
1297
0
    aWriter.writeIntProperty< sal_uInt8 >( mnSpecialEffect );
1298
0
    aWriter.writePairProperty( maSize );
1299
0
    aWriter.skipProperty(); //maPictureData );
1300
0
    aWriter.writeIntProperty< sal_uInt8 >( mnPicAlign );
1301
0
    aWriter.writeBoolProperty( mbPicTiling );
1302
0
    aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1303
0
    aWriter.skipProperty(); // mouse icon
1304
0
    aWriter.finalizeExport();
1305
0
}
1306
1307
void AxImageModel::exportCompObj( BinaryOutputStream& rOutStream )
1308
0
{
1309
    // should be able to replace this hardcoded foo with
1310
    // proper export info from MS-OLEDS spec.
1311
0
    static sal_uInt8 const aCompObj[] = {
1312
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1313
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
1314
0
        0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
1315
0
        0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
1316
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1317
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1318
0
        0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
1319
0
        0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1320
0
        0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1321
0
        0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1322
0
        0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1323
0
        0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
1324
0
        0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1325
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1326
0
    };
1327
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1328
0
}
1329
1330
ApiControlType AxImageModel::getControlType() const
1331
0
{
1332
0
    return API_CONTROL_IMAGE;
1333
0
}
1334
1335
void AxImageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1336
0
{
1337
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1338
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1339
0
    rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1340
0
    rConv.convertAxPicture( rPropMap, maPictureData, mnPicSizeMode );
1341
0
    AxControlModelBase::convertProperties( rPropMap, rConv );
1342
0
}
1343
1344
AxTabStripModel::AxTabStripModel() :
1345
0
    mnListIndex( 0 ),
1346
0
    mnTabStyle( 0 ),
1347
0
    mnTabData( 0 ),
1348
0
    mnVariousPropertyBits( 0 )
1349
0
{
1350
0
}
1351
1352
bool AxTabStripModel::importBinaryModel( BinaryInputStream& rInStrm )
1353
0
{
1354
    // not worth reading much here, basically we are interested
1355
    // in whether we have tabs, the width, the height and the
1356
    // captions, everything else we can pretty much discard ( for now )
1357
0
    AxBinaryPropertyReader aReader( rInStrm );
1358
0
    aReader.readIntProperty< sal_uInt32 >( mnListIndex ); // ListIndex
1359
0
    aReader.skipIntProperty< sal_uInt32 >(); // Backcolor
1360
0
    aReader.skipIntProperty< sal_uInt32 >(); // ForeColor
1361
0
    aReader.skipUndefinedProperty();
1362
0
    aReader.readPairProperty( maSize );
1363
0
    aReader.readArrayStringProperty( maItems );
1364
0
    aReader.skipIntProperty< sal_uInt8 >();  // MousePointer
1365
0
    aReader.skipUndefinedProperty();
1366
0
    aReader.skipIntProperty< sal_uInt32 >(); // TabOrientation
1367
0
    aReader.readIntProperty< sal_uInt32 >(mnTabStyle); // TabStyle
1368
0
    aReader.skipBoolProperty();              // MultiRow
1369
0
    aReader.skipIntProperty< sal_uInt32 >(); // TabFixedWidth
1370
0
    aReader.skipIntProperty< sal_uInt32 >(); // TabFixedHeight
1371
0
    aReader.skipBoolProperty();              // ToolTips
1372
0
    aReader.skipUndefinedProperty();
1373
0
    aReader.skipArrayStringProperty();  // ToolTip strings
1374
0
    aReader.skipUndefinedProperty();
1375
0
    aReader.readArrayStringProperty( maTabNames ); // Tab names
1376
0
    aReader.readIntProperty< sal_uInt32 >(mnVariousPropertyBits); // VariousPropertyBits
1377
0
    aReader.skipBoolProperty();// NewVersion
1378
0
    aReader.skipIntProperty< sal_uInt32 >(); // TabsAllocated
1379
0
    aReader.skipArrayStringProperty();  // Tags
1380
0
    aReader.readIntProperty<sal_uInt32 >(mnTabData);  // TabData
1381
0
    aReader.skipArrayStringProperty();  // Accelerators
1382
0
    aReader.skipPictureProperty(); // Mouse Icon
1383
0
    return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1384
0
}
1385
1386
ApiControlType AxTabStripModel::getControlType() const
1387
0
{
1388
0
    return API_CONTROL_TABSTRIP;
1389
0
}
1390
1391
AxMorphDataModelBase::AxMorphDataModelBase() :
1392
11
    mnTextColor( AX_SYSCOLOR_WINDOWTEXT ),
1393
11
    mnBackColor( AX_SYSCOLOR_WINDOWBACK ),
1394
11
    mnFlags( AX_MORPHDATA_DEFFLAGS ),
1395
11
    mnPicturePos( AX_PICPOS_ABOVECENTER ),
1396
11
    mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1397
11
    mnBorderStyle( AX_BORDERSTYLE_NONE ),
1398
11
    mnSpecialEffect( AX_SPECIALEFFECT_SUNKEN ),
1399
11
    mnDisplayStyle( AX_DISPLAYSTYLE_TEXT ),
1400
11
    mnMultiSelect( AX_SELECTION_SINGLE ),
1401
11
    mnScrollBars( AX_SCROLLBAR_NONE ),
1402
11
    mnMatchEntry( AX_MATCHENTRY_NONE ),
1403
11
    mnShowDropButton( AX_SHOWDROPBUTTON_NEVER ),
1404
11
    mnMaxLength( 0 ),
1405
11
    mnPasswordChar( 0 ),
1406
11
    mnListRows( 8 ),
1407
11
    mnVerticalAlign( XML_Center )
1408
11
{
1409
11
}
1410
1411
void AxMorphDataModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
1412
0
{
1413
0
    switch( nPropId )
1414
0
    {
1415
0
        case XML_Caption:               maCaption = rValue;                                             break;
1416
0
        case XML_Value:                 maValue = rValue;                                               break;
1417
0
        case XML_GroupName:             maGroupName = rValue;                                           break;
1418
0
        case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );    break;
1419
0
        case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
1420
0
        case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
1421
0
        case XML_PicturePosition:       mnPicturePos = AttributeConversion::decodeUnsigned( rValue );   break;
1422
0
        case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );  break;
1423
0
        case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );   break;
1424
0
        case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1425
0
        case XML_DisplayStyle:          mnDisplayStyle = AttributeConversion::decodeInteger( rValue );  break;
1426
0
        case XML_MultiSelect:           mnMultiSelect = AttributeConversion::decodeInteger( rValue );   break;
1427
0
        case XML_ScrollBars:            mnScrollBars = AttributeConversion::decodeInteger( rValue );    break;
1428
0
        case XML_MatchEntry:            mnMatchEntry = AttributeConversion::decodeInteger( rValue );    break;
1429
0
        case XML_ShowDropButtonWhen:    mnShowDropButton = AttributeConversion::decodeInteger( rValue );break;
1430
0
        case XML_MaxLength:             mnMaxLength = AttributeConversion::decodeInteger( rValue );     break;
1431
0
        case XML_PasswordChar:          mnPasswordChar = AttributeConversion::decodeInteger( rValue );  break;
1432
0
        case XML_ListRows:              mnListRows = AttributeConversion::decodeInteger( rValue );      break;
1433
0
        default:                        AxFontDataModel::importProperty( nPropId, rValue );
1434
0
    }
1435
0
}
1436
1437
void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1438
0
{
1439
0
    switch( nPropId )
1440
0
    {
1441
0
        case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm );    break;
1442
0
        default:            AxFontDataModel::importPictureData( nPropId, rInStrm );
1443
0
    }
1444
0
}
1445
1446
bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm )
1447
8
{
1448
8
    AxBinaryPropertyReader aReader( rInStrm, true );
1449
8
    aReader.readIntProperty< sal_uInt32 >( mnFlags );
1450
8
    aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1451
8
    aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1452
8
    aReader.readIntProperty< sal_Int32 >( mnMaxLength );
1453
8
    aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1454
8
    aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
1455
8
    aReader.readIntProperty< sal_uInt8 >( mnDisplayStyle );
1456
8
    aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1457
8
    aReader.readPairProperty( maSize );
1458
8
    aReader.readIntProperty< sal_uInt16 >( mnPasswordChar );
1459
8
    aReader.skipIntProperty< sal_uInt32 >(); // list width
1460
8
    aReader.skipIntProperty< sal_uInt16 >(); // bound column
1461
8
    aReader.skipIntProperty< sal_Int16 >(); // text column
1462
8
    aReader.skipIntProperty< sal_Int16 >(); // column count
1463
8
    aReader.readIntProperty< sal_uInt16 >( mnListRows );
1464
8
    aReader.skipIntProperty< sal_uInt16 >(); // column info count
1465
8
    aReader.readIntProperty< sal_uInt8 >( mnMatchEntry );
1466
8
    aReader.skipIntProperty< sal_uInt8 >(); // list style
1467
8
    aReader.readIntProperty< sal_uInt8 >( mnShowDropButton );
1468
8
    aReader.skipUndefinedProperty();
1469
8
    aReader.skipIntProperty< sal_uInt8 >(); // drop down style
1470
8
    aReader.readIntProperty< sal_uInt8 >( mnMultiSelect );
1471
8
    aReader.readStringProperty( maValue );
1472
8
    aReader.readStringProperty( maCaption );
1473
8
    aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
1474
8
    aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1475
8
    aReader.readIntProperty< sal_uInt32 >( mnSpecialEffect );
1476
8
    aReader.skipPictureProperty(); // mouse icon
1477
8
    aReader.readPictureProperty( maPictureData );
1478
8
    aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1479
8
    aReader.skipUndefinedProperty();
1480
8
    aReader.skipBoolProperty();
1481
8
    aReader.readStringProperty( maGroupName );
1482
8
    return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1483
8
}
1484
1485
void AxMorphDataModelBase::exportBinaryModel( BinaryOutputStream& rOutStrm )
1486
0
{
1487
0
    AxBinaryPropertyWriter aWriter( rOutStrm, true );
1488
0
    if ( mnFlags != AX_MORPHDATA_DEFFLAGS )
1489
0
        aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1490
0
    else
1491
0
        aWriter.skipProperty(); //mnFlags
1492
0
    if ( mnBackColor )
1493
0
        aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1494
0
    else
1495
0
        aWriter.skipProperty(); // default backcolour
1496
0
    aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1497
1498
    // only write if different from default
1499
0
    if ( ( ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX ) ) && mnMaxLength != 0 )
1500
0
        aWriter.writeIntProperty< sal_Int32 >( mnMaxLength );
1501
0
    else
1502
0
        aWriter.skipProperty(); //mnMaxLength
1503
0
    if ( ( ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) ) && mnBorderStyle != AX_BORDERSTYLE_NONE )
1504
0
        aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
1505
0
    else
1506
0
        aWriter.skipProperty(); //mnBorderStyle
1507
1508
0
    if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX || mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) && mnScrollBars != AX_SCROLLBAR_NONE )
1509
0
        aWriter.writeIntProperty< sal_uInt8 >( mnScrollBars );
1510
0
    else
1511
0
        aWriter.skipProperty(); //mnScrollBars
1512
0
    aWriter.writeIntProperty< sal_uInt8 >( mnDisplayStyle );
1513
0
    aWriter.skipProperty(); // mouse pointer
1514
0
    aWriter.writePairProperty( maSize );
1515
0
    if  ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT )
1516
0
        aWriter.writeIntProperty< sal_uInt16 >( mnPasswordChar );
1517
0
    else
1518
0
        aWriter.skipProperty(); // mnPasswordChar
1519
0
    aWriter.skipProperty(); // list width
1520
0
    aWriter.skipProperty(); // bound column
1521
0
    aWriter.skipProperty(); // text column
1522
0
    aWriter.skipProperty(); // column count
1523
0
    aWriter.skipProperty(); // mnListRows
1524
0
    aWriter.skipProperty(); // column info count
1525
0
    aWriter.skipProperty(); // mnMatchEntry
1526
0
    aWriter.skipProperty(); // list style
1527
0
    aWriter.skipProperty(); // mnShowDropButton );
1528
0
    aWriter.skipProperty();
1529
0
    aWriter.skipProperty(); // drop down style
1530
0
    if ( (mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX || mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX) && mnMultiSelect != AX_SELECTION_SINGLE )
1531
0
        aWriter.writeIntProperty< sal_uInt8 >( mnMultiSelect );
1532
    // although CheckBox, ListBox, OptionButton, ToggleButton are also supported
1533
    // they can only have the fileformat default
1534
0
    else
1535
0
        aWriter.skipProperty(); //mnMultiSelect
1536
0
    aWriter.writeStringProperty( maValue );
1537
1538
0
    if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE ) )
1539
0
        aWriter.writeStringProperty( maCaption );
1540
0
    else
1541
0
        aWriter.skipProperty(); // mnCaption
1542
0
    aWriter.skipProperty(); // mnPicturePos );
1543
0
    if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX || mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX ||  mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) && mnBorderColor != AX_SYSCOLOR_WINDOWFRAME )
1544
0
       aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1545
0
    else
1546
0
        aWriter.skipProperty(); // mnBorderColor
1547
0
    if (  mnSpecialEffect != AX_SPECIALEFFECT_SUNKEN  )
1548
0
        aWriter.writeIntProperty< sal_uInt32 >( mnSpecialEffect );
1549
0
    else
1550
0
        aWriter.skipProperty(); //mnSpecialEffect
1551
0
    aWriter.skipProperty(); // mouse icon
1552
0
    aWriter.skipProperty(); // maPictureData
1553
0
    aWriter.skipProperty(); // accelerator
1554
0
    aWriter.skipProperty(); // undefined
1555
0
    aWriter.writeBoolProperty(true); // must be 1 for morph
1556
0
    if ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON )
1557
0
        aWriter.writeStringProperty( maGroupName );
1558
0
    else
1559
0
        aWriter.skipProperty(); //maGroupName
1560
0
    aWriter.finalizeExport();
1561
0
    AxFontDataModel::exportBinaryModel( rOutStrm );
1562
0
}
1563
1564
void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1565
0
{
1566
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1567
0
    rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1568
0
    if ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON )
1569
0
    {
1570
        // If unspecified, radio buttons autoGroup in the same document/sheet
1571
        // NOTE: form controls should not autoGroup with ActiveX controls - see drawingfragment.cxx
1572
0
        OUString sGroupName = !maGroupName.isEmpty() ? maGroupName : u"autoGroup_"_ustr;
1573
0
        rPropMap.setProperty( PROP_GroupName, sGroupName );
1574
0
    }
1575
0
    AxFontDataModel::convertProperties( rPropMap, rConv );
1576
0
}
1577
1578
void AxMorphDataModelBase::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1579
0
{
1580
0
    if ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON )
1581
0
        rPropSet.getProperty( maGroupName, PROP_GroupName );
1582
0
    AxFontDataModel::convertFromProperties( rPropSet, rConv );
1583
0
}
1584
1585
AxToggleButtonModel::AxToggleButtonModel()
1586
0
{
1587
0
    mnDisplayStyle = AX_DISPLAYSTYLE_TOGGLE;
1588
0
}
1589
1590
ApiControlType AxToggleButtonModel::getControlType() const
1591
0
{
1592
0
    OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getControlType - invalid control type" );
1593
0
    return API_CONTROL_BUTTON;
1594
0
}
1595
1596
void AxToggleButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1597
0
{
1598
0
    rPropSet.getProperty( maCaption, PROP_Label );
1599
1600
0
    bool bRes = false;
1601
0
    if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
1602
0
        setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1603
1604
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1605
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1606
    // need to process the image if one exists
1607
0
    ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN );
1608
0
    AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1609
0
}
1610
1611
void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1612
0
{
1613
0
    rPropMap.setProperty( PROP_Label, maCaption );
1614
0
    rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1615
0
    rPropMap.setProperty( PROP_Toggle, true );
1616
0
    ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1617
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
1618
0
    rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1619
0
    ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1620
0
    AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1621
0
}
1622
1623
void AxToggleButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1624
0
{
1625
    // should be able to replace this hardcoded foo with
1626
    // proper export info from MS-OLEDS spec.
1627
0
    static sal_uInt8 const aCompObj[] = {
1628
0
            0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1629
0
            0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
1630
0
            0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1631
0
            0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1632
0
            0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1633
0
            0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1634
0
            0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
1635
0
            0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1636
0
            0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1637
0
            0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1638
0
            0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1639
0
            0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
1640
0
            0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
1641
0
            0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1642
0
            0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1643
0
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1644
0
    };
1645
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1646
0
}
1647
1648
AxCheckBoxModel::AxCheckBoxModel()
1649
2
{
1650
2
    mnDisplayStyle = AX_DISPLAYSTYLE_CHECKBOX;
1651
2
}
1652
1653
ApiControlType AxCheckBoxModel::getControlType() const
1654
2
{
1655
2
    OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getControlType - invalid control type" );
1656
2
    return API_CONTROL_CHECKBOX;
1657
2
}
1658
1659
void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1660
0
{
1661
0
    rPropMap.setProperty( PROP_Label, maCaption );
1662
0
    rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1663
0
    ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1664
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1665
0
    ControlConverter::convertAxVisualEffect( rPropMap, mnSpecialEffect );
1666
0
    rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1667
0
    ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE, mbAwtModel );
1668
0
    AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1669
0
}
1670
1671
void AxCheckBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1672
0
{
1673
0
    rPropSet.getProperty( maCaption, PROP_Label );
1674
1675
0
    bool bRes = false;
1676
0
    if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
1677
0
        setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1678
1679
0
    ControlConverter::convertToAxVisualEffect( rPropSet, mnSpecialEffect );
1680
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1681
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1682
    // need to process the image if one exists
1683
0
    ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE );
1684
0
    AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1685
0
}
1686
1687
void AxCheckBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1688
0
{
1689
    // should be able to replace this hardcoded foo with
1690
    // proper export info from MS-OLEDS spec.
1691
0
    static sal_uInt8 const aCompObj[] = {
1692
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1693
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
1694
0
        0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1695
0
        0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
1696
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1697
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1698
0
        0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
1699
0
        0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
1700
0
        0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
1701
0
        0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
1702
0
        0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
1703
0
        0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
1704
0
        0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1705
0
        0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1706
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1707
0
    };
1708
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1709
0
}
1710
1711
AxOptionButtonModel::AxOptionButtonModel()
1712
0
{
1713
0
    mnDisplayStyle = AX_DISPLAYSTYLE_OPTBUTTON;
1714
0
}
1715
1716
ApiControlType AxOptionButtonModel::getControlType() const
1717
0
{
1718
0
    OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getControlType - invalid control type" );
1719
0
    return API_CONTROL_RADIOBUTTON;
1720
0
}
1721
1722
void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1723
0
{
1724
0
    rPropMap.setProperty( PROP_Label, maCaption );
1725
0
    rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1726
0
    ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1727
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1728
0
    ControlConverter::convertAxVisualEffect( rPropMap, mnSpecialEffect );
1729
0
    rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1730
0
    ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT, mbAwtModel );
1731
0
    AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1732
0
}
1733
1734
void AxOptionButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1735
0
{
1736
0
    rPropSet.getProperty( maCaption, PROP_Label );
1737
1738
0
    bool bRes = false;
1739
0
    if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
1740
0
        setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1741
1742
0
    ControlConverter::convertToAxVisualEffect( rPropSet, mnSpecialEffect );
1743
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1744
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1745
    // need to process the image if one exists
1746
0
    ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN );
1747
0
    AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1748
0
}
1749
1750
void AxOptionButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1751
0
{
1752
    // should be able to replace this hardcoded foo with
1753
    // proper export info from MS-OLEDS spec.
1754
0
    static sal_uInt8 const aCompObj[] = {
1755
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1756
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1757
0
        0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1758
0
        0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1759
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1760
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1761
0
        0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1762
0
        0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1763
0
        0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1764
0
        0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1765
0
        0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1766
0
        0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1767
0
        0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1768
0
        0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1769
0
        0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1770
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1771
0
    };
1772
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1773
0
}
1774
1775
AxTextBoxModel::AxTextBoxModel()
1776
8
{
1777
8
    mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1778
8
}
1779
1780
ApiControlType AxTextBoxModel::getControlType() const
1781
8
{
1782
8
    OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getControlType - invalid control type" );
1783
8
    return API_CONTROL_EDIT;
1784
8
}
1785
1786
void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1787
0
{
1788
0
    if (getFlag( mnFlags, AX_FLAGS_MULTILINE ) && getFlag( mnFlags, AX_FLAGS_WORDWRAP ))
1789
0
        rPropMap.setProperty( PROP_MultiLine, true );
1790
0
    else
1791
0
        rPropMap.setProperty( PROP_MultiLine, false );
1792
0
    rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1793
0
    rPropMap.setProperty( PROP_ReadOnly, getFlag( mnFlags, AX_FLAGS_LOCKED ) );
1794
0
    rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1795
0
    rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1796
0
    if( (0 < mnPasswordChar) && (mnPasswordChar <= SAL_MAX_INT16) )
1797
0
        rPropMap.setProperty( PROP_EchoChar, static_cast< sal_Int16 >( mnPasswordChar ) );
1798
0
    rPropMap.setProperty( PROP_HScroll, getFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL ) );
1799
0
    rPropMap.setProperty( PROP_VScroll, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1800
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1801
0
    rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1802
0
    AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1803
0
}
1804
1805
void AxTextBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1806
0
{
1807
0
    bool bRes = false;
1808
0
    if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) ) {
1809
0
        setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1810
0
        setFlag( mnFlags, AX_FLAGS_MULTILINE, bRes );
1811
0
    }
1812
0
    if ( rPropSet.getProperty( bRes,  PROP_HideInactiveSelection ) )
1813
0
        setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1814
0
    if ( rPropSet.getProperty( bRes,  PROP_ReadOnly ) )
1815
0
        setFlag( mnFlags, AX_FLAGS_LOCKED, bRes );
1816
0
    rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1817
0
    if (maValue.isEmpty() && !mbAwtModel)
1818
        // No default value? Then try exporting the current one.
1819
0
        rPropSet.getProperty( maValue, PROP_Text);
1820
0
    sal_Int16 nTmp(0);
1821
0
    if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
1822
0
        mnMaxLength = nTmp;
1823
0
    if ( rPropSet.getProperty( nTmp, PROP_EchoChar ) )
1824
0
        mnPasswordChar = nTmp;
1825
0
    if ( rPropSet.getProperty( bRes,  PROP_HScroll ) )
1826
0
        setFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL, bRes );
1827
0
    if ( rPropSet.getProperty( bRes,  PROP_VScroll ) )
1828
0
        setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
1829
1830
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor, 0x80000005L );
1831
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1832
1833
0
    ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1834
0
    AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1835
0
}
1836
1837
void AxTextBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1838
0
{
1839
    // should be able to replace this hardcoded foo with
1840
    // proper export info from MS-OLEDS spec.
1841
0
    static sal_uInt8 const aCompObj[] = {
1842
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1843
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1844
0
        0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1845
0
        0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1846
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1847
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1848
0
        0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1849
0
        0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1850
0
        0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1851
0
        0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1852
0
        0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1853
0
        0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1854
0
        0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1855
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1856
0
        0x00, 0x00, 0x00, 0x00
1857
0
    };
1858
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1859
0
}
1860
1861
AxNumericFieldModel::AxNumericFieldModel()
1862
0
{
1863
0
    mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1864
0
}
1865
1866
ApiControlType AxNumericFieldModel::getControlType() const
1867
0
{
1868
0
    OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxNumericFieldModel::getControlType - invalid control type" );
1869
0
    return API_CONTROL_NUMERIC;
1870
0
}
1871
1872
void AxNumericFieldModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1873
0
{
1874
0
    rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1875
    // TODO: OUString::toDouble() does not handle local decimal separator
1876
0
    rPropMap.setProperty( mbAwtModel ? PROP_Value : PROP_DefaultValue, maValue.toDouble() );
1877
0
    rPropMap.setProperty( PROP_Spin, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1878
0
    rPropMap.setProperty( PROP_Repeat, true );
1879
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1880
0
    rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1881
0
    AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1882
0
}
1883
1884
void AxNumericFieldModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1885
0
{
1886
0
    bool bRes = false;
1887
0
    if ( rPropSet.getProperty( bRes,  PROP_HideInactiveSelection ) )
1888
0
        setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1889
0
    rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1890
0
    if ( rPropSet.getProperty( bRes,  PROP_Spin ) )
1891
0
        setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
1892
1893
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1894
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1895
1896
0
    ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1897
0
    AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1898
0
}
1899
1900
void AxNumericFieldModel::exportCompObj( BinaryOutputStream& rOutStream )
1901
0
{
1902
    // should be able to replace this hardcoded foo with
1903
    // proper export info from MS-OLEDS spec.
1904
0
    static sal_uInt8 const aCompObj[] = {
1905
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1906
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1907
0
        0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1908
0
        0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1909
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1910
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1911
0
        0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1912
0
        0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1913
0
        0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1914
0
        0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1915
0
        0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1916
0
        0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1917
0
        0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1918
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1919
0
        0x00, 0x00, 0x00, 0x00
1920
0
    };
1921
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1922
0
}
1923
1924
AxListBoxModel::AxListBoxModel()
1925
1
{
1926
1
    mnDisplayStyle = AX_DISPLAYSTYLE_LISTBOX;
1927
1
}
1928
1929
ApiControlType AxListBoxModel::getControlType() const
1930
1
{
1931
1
    OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getControlType - invalid control type" );
1932
1
    return API_CONTROL_LISTBOX;
1933
1
}
1934
1935
void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1936
0
{
1937
0
    bool bMultiSelect = (mnMultiSelect == AX_SELECTION_MULTI) || (mnMultiSelect == AX_SELECTION_EXTENDED);
1938
0
    rPropMap.setProperty( PROP_MultiSelection, bMultiSelect );
1939
0
    rPropMap.setProperty( PROP_Dropdown, false );
1940
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1941
0
    rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1942
0
    AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1943
0
}
1944
1945
void AxListBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1946
0
{
1947
0
    bool bRes = false;
1948
0
    if ( rPropSet.getProperty( bRes, PROP_MultiSelection ) )
1949
0
        ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1950
1951
0
    ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1952
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1953
0
    AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1954
0
}
1955
1956
void AxListBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1957
0
{
1958
    // should be able to replace this hardcoded foo with
1959
    // proper export info from MS-OLEDS spec.
1960
0
    static sal_uInt8 const aCompObj[] = {
1961
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1962
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
1963
0
        0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1964
0
        0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1965
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1966
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1967
0
        0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
1968
0
        0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1969
0
        0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1970
0
        0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1971
0
        0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1972
0
        0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
1973
0
        0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1974
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1975
0
        0x00, 0x00, 0x00, 0x00
1976
0
    };
1977
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1978
0
}
1979
1980
AxComboBoxModel::AxComboBoxModel()
1981
0
{
1982
0
    mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
1983
0
    mnFlags = 0x2c80481b;
1984
0
}
1985
1986
ApiControlType AxComboBoxModel::getControlType() const
1987
0
{
1988
0
    OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getControlType - invalid control type" );
1989
0
    return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? API_CONTROL_LISTBOX : API_CONTROL_COMBOBOX;
1990
0
}
1991
1992
void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1993
0
{
1994
0
    if( mnDisplayStyle != AX_DISPLAYSTYLE_DROPDOWN )
1995
0
    {
1996
0
        rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1997
0
        rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1998
0
        rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1999
0
        bool bAutoComplete = (mnMatchEntry == AX_MATCHENTRY_FIRSTLETTER) || (mnMatchEntry == AX_MATCHENTRY_COMPLETE);
2000
0
        rPropMap.setProperty( PROP_Autocomplete, bAutoComplete );
2001
0
    }
2002
0
    bool bShowDropdown = (mnShowDropButton == AX_SHOWDROPBUTTON_FOCUS) || (mnShowDropButton == AX_SHOWDROPBUTTON_ALWAYS);
2003
0
    rPropMap.setProperty( PROP_Dropdown, bShowDropdown );
2004
0
    rPropMap.setProperty( PROP_LineCount, getLimitedValue< sal_Int16, sal_Int32 >( mnListRows, 1, SAL_MAX_INT16 ) );
2005
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
2006
0
    rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
2007
0
    AxMorphDataModelBase::convertProperties( rPropMap, rConv );
2008
0
}
2009
2010
void AxComboBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
2011
0
{
2012
    // when would we have mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN ?
2013
    // #TODO check against msocximex
2014
0
    mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
2015
0
    bool bRes = false;
2016
2017
0
    if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
2018
0
        setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
2019
0
    rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
2020
2021
0
    sal_Int16 nTmp(0);
2022
0
    if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
2023
0
        mnMaxLength = nTmp;
2024
0
    if ( rPropSet.getProperty( bRes, PROP_Autocomplete ) )
2025
0
    {
2026
        // when to choose AX_MATCHENTRY_FIRSTLETTER ?
2027
        // #TODO check against msocximex
2028
0
        if ( bRes )
2029
0
            mnMatchEntry = AX_MATCHENTRY_COMPLETE;
2030
0
    }
2031
0
    if ( rPropSet.getProperty( bRes, PROP_Dropdown ) )
2032
0
    {
2033
0
        rPropSet.getProperty( mnListRows, PROP_LineCount );
2034
0
        if ( !mnListRows )
2035
0
            mnListRows = 1;
2036
0
    }
2037
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2038
0
    ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
2039
2040
0
    ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
2041
0
    AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
2042
0
}
2043
2044
void AxComboBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
2045
0
{
2046
    // should be able to replace this hardcoded foo with
2047
    // proper export info from MS-OLEDS spec.
2048
0
    static sal_uInt8 const aCompObj[] = {
2049
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2050
0
        0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2051
0
        0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2052
0
        0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2053
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2054
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2055
0
        0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2056
0
        0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2057
0
        0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2058
0
        0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2059
0
        0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2060
0
        0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2061
0
        0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2062
0
        0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2063
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2064
0
    };
2065
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2066
0
}
2067
2068
AxSpinButtonModel::AxSpinButtonModel() :
2069
0
    mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
2070
0
    mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2071
0
    mnFlags( AX_SPINBUTTON_DEFFLAGS ),
2072
0
    mnOrientation( AX_ORIENTATION_AUTO ),
2073
0
    mnMin( 0 ),
2074
0
    mnMax( 100 ),
2075
0
    mnPosition( 0 ),
2076
0
    mnSmallChange( 1 ),
2077
0
    mnDelay( 50 )
2078
0
{
2079
0
}
2080
2081
ApiControlType AxSpinButtonModel::getControlType() const
2082
0
{
2083
0
    return API_CONTROL_SPINBUTTON;
2084
0
}
2085
2086
void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
2087
0
{
2088
0
    switch( nPropId )
2089
0
    {
2090
0
        case XML_ForeColor:             mnArrowColor = AttributeConversion::decodeUnsigned( rValue );   break;
2091
0
        case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
2092
0
        case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
2093
0
        case XML_Orientation:           mnOrientation = AttributeConversion::decodeInteger( rValue );   break;
2094
0
        case XML_Min:                   mnMin = AttributeConversion::decodeInteger( rValue );           break;
2095
0
        case XML_Max:                   mnMax = AttributeConversion::decodeInteger( rValue );           break;
2096
0
        case XML_Position:              mnPosition = AttributeConversion::decodeInteger( rValue );      break;
2097
0
        case XML_SmallChange:           mnSmallChange = AttributeConversion::decodeInteger( rValue );   break;
2098
0
        case XML_Delay:                 mnDelay = AttributeConversion::decodeInteger( rValue );         break;
2099
0
        default:                        AxControlModelBase::importProperty( nPropId, rValue );
2100
0
    }
2101
0
}
2102
2103
bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
2104
0
{
2105
0
    AxBinaryPropertyReader aReader( rInStrm );
2106
0
    aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
2107
0
    aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2108
0
    aReader.readIntProperty< sal_uInt32 >( mnFlags );
2109
0
    aReader.readPairProperty( maSize );
2110
0
    aReader.skipIntProperty< sal_uInt32 >(); // unused
2111
0
    aReader.readIntProperty< sal_Int32 >( mnMin );
2112
0
    aReader.readIntProperty< sal_Int32 >( mnMax );
2113
0
    aReader.readIntProperty< sal_Int32 >( mnPosition );
2114
0
    aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
2115
0
    aReader.skipIntProperty< sal_uInt32 >(); // next enabled
2116
0
    aReader.readIntProperty< sal_Int32 >( mnSmallChange );
2117
0
    aReader.readIntProperty< sal_Int32 >( mnOrientation );
2118
0
    aReader.readIntProperty< sal_Int32 >( mnDelay );
2119
0
    aReader.skipPictureProperty(); // mouse icon
2120
0
    aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2121
0
    return aReader.finalizeImport();
2122
0
}
2123
2124
void AxSpinButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
2125
0
{
2126
0
    AxBinaryPropertyWriter aWriter( rOutStrm );
2127
0
    aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
2128
0
    if ( mnBackColor )
2129
0
        aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
2130
0
    else
2131
0
        aWriter.skipProperty(); // default backcolour
2132
0
    aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
2133
0
    aWriter.writePairProperty( maSize );
2134
0
    aWriter.skipProperty(); // unused
2135
0
    aWriter.writeIntProperty< sal_Int32 >( mnMin );
2136
0
    aWriter.writeIntProperty< sal_Int32 >( mnMax );
2137
0
    aWriter.writeIntProperty< sal_Int32 >( mnPosition );
2138
0
    aWriter.skipProperty(); // prev enabled
2139
0
    aWriter.skipProperty(); // next enabled
2140
0
    aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
2141
0
    aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
2142
0
    aWriter.writeIntProperty< sal_Int32 >( mnDelay );
2143
0
    aWriter.skipProperty(); // mouse icon
2144
0
    aWriter.skipProperty(); // mouse pointer
2145
2146
0
    aWriter.finalizeExport();
2147
0
}
2148
2149
void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2150
0
{
2151
0
    sal_Int32 nMin = ::std::min( mnMin, mnMax );
2152
0
    sal_Int32 nMax = ::std::max( mnMin, mnMax );
2153
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
2154
0
    rPropMap.setProperty( PROP_SpinValueMin, nMin );
2155
0
    rPropMap.setProperty( PROP_SpinValueMax, nMax );
2156
0
    rPropMap.setProperty( PROP_SpinIncrement, mnSmallChange );
2157
0
    rPropMap.setProperty( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue, mnPosition );
2158
0
    rPropMap.setProperty( PROP_Repeat, true );
2159
0
    rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
2160
0
    rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
2161
0
    rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
2162
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
2163
0
    ControlConverter::convertAxOrientation( rPropMap, maSize, mnOrientation );
2164
0
    AxControlModelBase::convertProperties( rPropMap, rConv );
2165
0
}
2166
2167
void AxSpinButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& )
2168
0
{
2169
0
    bool bRes = false;
2170
0
    if ( rPropSet.getProperty( bRes,  PROP_Enabled ) )
2171
0
        setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
2172
0
    rPropSet.getProperty( mnMin, PROP_SpinValueMin );
2173
0
    rPropSet.getProperty( mnMax, PROP_SpinValueMax );
2174
0
    rPropSet.getProperty( mnSmallChange, PROP_SpinIncrement );
2175
0
    rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue ) );
2176
0
    rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
2177
0
    ControlConverter::convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
2178
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2179
2180
0
    ControlConverter::convertToAxOrientation( rPropSet, mnOrientation );
2181
0
}
2182
2183
void AxSpinButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
2184
0
{
2185
    // should be able to replace this hardcoded foo with
2186
    // proper export info from MS-OLEDS spec.
2187
0
    static sal_uInt8 const aCompObj[] =
2188
0
    {
2189
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2190
0
        0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
2191
0
        0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
2192
0
        0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
2193
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2194
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2195
0
        0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
2196
0
        0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
2197
0
        0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
2198
0
        0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
2199
0
        0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
2200
0
        0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x70, 0x69,
2201
0
        0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
2202
0
        0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
2203
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2204
0
        0x00, 0x00
2205
0
    };
2206
2207
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2208
0
}
2209
2210
AxScrollBarModel::AxScrollBarModel() :
2211
4
    mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
2212
4
    mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2213
4
    mnFlags( AX_SCROLLBAR_DEFFLAGS ),
2214
4
    mnOrientation( AX_ORIENTATION_AUTO ),
2215
4
    mnPropThumb( AX_PROPTHUMB_ON ),
2216
4
    mnMin( 0 ),
2217
4
    mnMax( 32767 ),
2218
4
    mnPosition( 0 ),
2219
4
    mnSmallChange( 1 ),
2220
4
    mnLargeChange( 1 ),
2221
4
    mnDelay( 50 )
2222
4
{
2223
4
}
2224
2225
ApiControlType AxScrollBarModel::getControlType() const
2226
4
{
2227
4
    return API_CONTROL_SCROLLBAR;
2228
4
}
2229
2230
void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
2231
0
{
2232
0
    switch( nPropId )
2233
0
    {
2234
0
        case XML_ForeColor:             mnArrowColor = AttributeConversion::decodeUnsigned( rValue );   break;
2235
0
        case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
2236
0
        case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
2237
0
        case XML_Orientation:           mnOrientation = AttributeConversion::decodeInteger( rValue );   break;
2238
0
        case XML_ProportionalThumb:     mnPropThumb = AttributeConversion::decodeInteger( rValue );     break;
2239
0
        case XML_Min:                   mnMin = AttributeConversion::decodeInteger( rValue );           break;
2240
0
        case XML_Max:                   mnMax = AttributeConversion::decodeInteger( rValue );           break;
2241
0
        case XML_Position:              mnPosition = AttributeConversion::decodeInteger( rValue );      break;
2242
0
        case XML_SmallChange:           mnSmallChange = AttributeConversion::decodeInteger( rValue );   break;
2243
0
        case XML_LargeChange:           mnLargeChange = AttributeConversion::decodeInteger( rValue );   break;
2244
0
        case XML_Delay:                 mnDelay = AttributeConversion::decodeInteger( rValue );         break;
2245
0
        default:                        AxControlModelBase::importProperty( nPropId, rValue );
2246
0
    }
2247
0
}
2248
2249
bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm )
2250
0
{
2251
0
    AxBinaryPropertyReader aReader( rInStrm );
2252
0
    aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
2253
0
    aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2254
0
    aReader.readIntProperty< sal_uInt32 >( mnFlags );
2255
0
    aReader.readPairProperty( maSize );
2256
0
    aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2257
0
    aReader.readIntProperty< sal_Int32 >( mnMin );
2258
0
    aReader.readIntProperty< sal_Int32 >( mnMax );
2259
0
    aReader.readIntProperty< sal_Int32 >( mnPosition );
2260
0
    aReader.skipIntProperty< sal_uInt32 >(); // unused
2261
0
    aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
2262
0
    aReader.skipIntProperty< sal_uInt32 >(); // next enabled
2263
0
    aReader.readIntProperty< sal_Int32 >( mnSmallChange );
2264
0
    aReader.readIntProperty< sal_Int32 >( mnLargeChange );
2265
0
    aReader.readIntProperty< sal_Int32 >( mnOrientation );
2266
0
    aReader.readIntProperty< sal_Int16 >( mnPropThumb );
2267
0
    aReader.readIntProperty< sal_Int32 >( mnDelay );
2268
0
    aReader.skipPictureProperty(); // mouse icon
2269
0
    return aReader.finalizeImport();
2270
0
}
2271
2272
void AxScrollBarModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
2273
0
{
2274
0
    AxBinaryPropertyWriter aWriter( rOutStrm );
2275
0
    aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
2276
0
    if ( mnBackColor )
2277
0
        aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
2278
0
    else
2279
0
        aWriter.skipProperty(); // default backcolour
2280
0
    aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
2281
0
    aWriter.writePairProperty( maSize );
2282
0
    aWriter.skipProperty(); // mouse pointer
2283
0
    aWriter.writeIntProperty< sal_Int32 >( mnMin );
2284
0
    aWriter.writeIntProperty< sal_Int32 >( mnMax );
2285
0
    aWriter.writeIntProperty< sal_Int32 >( mnPosition );
2286
0
    aWriter.skipProperty(); // unused
2287
0
    aWriter.skipProperty(); // prev enabled
2288
0
    aWriter.skipProperty(); // next enabled
2289
0
    aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
2290
0
    aWriter.writeIntProperty< sal_Int32 >( mnLargeChange );
2291
0
    aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
2292
0
    aWriter.writeIntProperty< sal_Int16 >( mnPropThumb );
2293
0
    aWriter.writeIntProperty< sal_Int32 >( mnDelay );
2294
0
    aWriter.skipProperty(); // mouse icon
2295
0
    aWriter.finalizeExport();
2296
0
}
2297
2298
void AxScrollBarModel::exportCompObj( BinaryOutputStream& rOutStream )
2299
0
{
2300
    // should be able to replace this hardcoded foo with
2301
    // proper export info from MS-OLEDS spec.
2302
0
    static sal_uInt8 const aCompObj[] =
2303
0
    {
2304
0
        0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2305
0
        0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
2306
0
        0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
2307
0
        0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
2308
0
        0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2309
0
        0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2310
0
        0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
2311
0
        0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
2312
0
        0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
2313
0
        0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
2314
0
        0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
2315
0
        0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
2316
0
        0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
2317
0
        0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
2318
0
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2319
0
    };
2320
0
    rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2321
0
}
2322
2323
void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2324
0
{
2325
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
2326
0
    rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
2327
0
    rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
2328
0
    if( (mnPropThumb == AX_PROPTHUMB_ON) && (mnMin != mnMax) && (mnLargeChange > 0) )
2329
0
    {
2330
        // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int)
2331
0
        double fInterval = fabs( static_cast< double >( mnMax - mnMin ) );
2332
0
        sal_Int32 nThumbLen = getLimitedValue< sal_Int32, double >( (fInterval * mnLargeChange) / (fInterval + mnLargeChange), 1, SAL_MAX_INT32 );
2333
0
        rPropMap.setProperty( PROP_VisibleSize, nThumbLen );
2334
0
    }
2335
0
    rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
2336
0
    rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
2337
0
    ControlConverter::convertAxOrientation( rPropMap, maSize, mnOrientation );
2338
0
    ControlConverter::convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
2339
0
    AxControlModelBase::convertProperties( rPropMap, rConv );
2340
0
}
2341
2342
void AxScrollBarModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& )
2343
0
{
2344
0
    bool bRes = false;
2345
0
    if ( rPropSet.getProperty( bRes,  PROP_Enabled ) )
2346
0
        setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
2347
0
    rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
2348
0
    mnPropThumb = AX_PROPTHUMB_ON; // default
2349
0
    ControlConverter::convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
2350
0
    ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2351
0
    ControlConverter::convertToAxOrientation( rPropSet, mnOrientation );
2352
2353
0
    rPropSet.getProperty( mnMin, PROP_ScrollValueMin );
2354
0
    rPropSet.getProperty( mnMax, PROP_ScrollValueMax );
2355
0
    rPropSet.getProperty( mnSmallChange, PROP_LineIncrement );
2356
0
    rPropSet.getProperty( mnLargeChange, PROP_BlockIncrement );
2357
0
    rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue ) );
2358
2359
0
}
2360
2361
AxContainerModelBase::AxContainerModelBase( bool bFontSupport ) :
2362
0
    AxFontDataModel( false ),   // no support for alignment properties
2363
0
    maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ),
2364
0
    maScrollPos( 0, 0 ),
2365
0
    mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2366
0
    mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
2367
0
    mnFlags( AX_CONTAINER_DEFFLAGS ),
2368
0
    mnBorderColor( AX_SYSCOLOR_BUTTONTEXT ),
2369
0
    mnBorderStyle( AX_BORDERSTYLE_NONE ),
2370
0
    mnScrollBars( AX_CONTAINER_SCR_NONE ),
2371
0
    mnCycleType( AX_CONTAINER_CYCLEALL ),
2372
0
    mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
2373
0
    mnPicAlign( AX_PICALIGN_CENTER ),
2374
0
    mnPicSizeMode( AX_PICSIZE_CLIP ),
2375
0
    mbPicTiling( false ),
2376
0
    mbFontSupport( bFontSupport )
2377
0
{
2378
0
    setAwtModelMode();
2379
    // different default size for frame
2380
0
    maSize = AxPairData( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT );
2381
0
}
2382
2383
void AxContainerModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
2384
0
{
2385
0
    if( nPropId == XML_Caption )
2386
0
        maCaption = rValue;
2387
0
}
2388
2389
bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm )
2390
0
{
2391
0
    AxBinaryPropertyReader aReader( rInStrm );
2392
0
    aReader.skipUndefinedProperty();
2393
0
    aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2394
0
    aReader.readIntProperty< sal_uInt32 >( mnTextColor );
2395
0
    aReader.skipIntProperty< sal_uInt32 >(); // next available control ID
2396
0
    aReader.skipUndefinedProperty();
2397
0
    aReader.skipUndefinedProperty();
2398
0
    aReader.readIntProperty< sal_uInt32 >( mnFlags );
2399
0
    aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
2400
0
    aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2401
0
    aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
2402
0
    aReader.readPairProperty( maSize );
2403
0
    aReader.readPairProperty( maLogicalSize );
2404
0
    aReader.readPairProperty( maScrollPos );
2405
0
    aReader.skipIntProperty< sal_uInt32 >(); // number of control groups
2406
0
    aReader.skipUndefinedProperty();
2407
0
    aReader.skipPictureProperty(); // mouse icon
2408
0
    aReader.readIntProperty< sal_uInt8 >( mnCycleType );
2409
0
    aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
2410
0
    aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
2411
0
    aReader.readStringProperty( maCaption );
2412
0
    aReader.readFontProperty( maFontData );
2413
0
    aReader.readPictureProperty( maPictureData );
2414
0
    aReader.skipIntProperty< sal_Int32 >(); // zoom
2415
0
    aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
2416
0
    aReader.readBoolProperty( mbPicTiling );
2417
0
    aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
2418
0
    aReader.skipIntProperty< sal_uInt32 >(); // shape cookie
2419
0
    aReader.skipIntProperty< sal_uInt32 >(); // draw buffer size
2420
0
    return aReader.finalizeImport();
2421
0
}
2422
2423
void AxContainerModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2424
0
{
2425
0
    if( mbFontSupport )
2426
0
    {
2427
0
        rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
2428
0
        AxFontDataModel::convertProperties( rPropMap, rConv );
2429
0
    }
2430
0
}
2431
2432
bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable )
2433
0
{
2434
0
    bool bValid = true;
2435
0
    orClassTable.clear();
2436
0
    if( !getFlag( mnFlags, AX_CONTAINER_NOCLASSTABLE ) )
2437
0
    {
2438
0
        sal_uInt16 nCount = rInStrm.readuInt16();
2439
0
        for( sal_uInt16 nIndex = 0; bValid && (nIndex < nCount); ++nIndex )
2440
0
        {
2441
0
            orClassTable.emplace_back( );
2442
0
            AxBinaryPropertyReader aReader( rInStrm );
2443
0
            aReader.readGuidProperty( orClassTable.back() );
2444
0
            aReader.skipGuidProperty(); // source interface GUID
2445
0
            aReader.skipUndefinedProperty();
2446
0
            aReader.skipGuidProperty(); // default interface GUID
2447
0
            aReader.skipIntProperty< sal_uInt32 >(); // class table and var flags
2448
0
            aReader.skipIntProperty< sal_uInt32 >(); // method count
2449
0
            aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for linked cell access
2450
0
            aReader.skipIntProperty< sal_uInt16 >(); // get function index for linked cell access
2451
0
            aReader.skipIntProperty< sal_uInt16 >(); // put function index for linked cell access
2452
0
            aReader.skipIntProperty< sal_uInt16 >(); // linked cell access property type
2453
0
            aReader.skipIntProperty< sal_uInt16 >(); // get function index of value
2454
0
            aReader.skipIntProperty< sal_uInt16 >(); // put function index of value
2455
0
            aReader.skipIntProperty< sal_uInt16 >(); // value type
2456
0
            aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for source range access
2457
0
            aReader.skipIntProperty< sal_uInt16 >(); // get function index for source range access
2458
0
            bValid = aReader.finalizeImport();
2459
0
        }
2460
0
    }
2461
0
    return bValid;
2462
0
}
2463
2464
AxFrameModel::AxFrameModel() :
2465
0
    AxContainerModelBase( true )
2466
0
{
2467
0
}
2468
2469
ApiControlType AxFrameModel::getControlType() const
2470
0
{
2471
0
    return mbAwtModel ? API_CONTROL_FRAME : API_CONTROL_GROUPBOX;
2472
0
}
2473
2474
void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2475
0
{
2476
0
    rPropMap.setProperty( PROP_Label, maCaption );
2477
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2478
0
    AxContainerModelBase::convertProperties( rPropMap, rConv );
2479
0
}
2480
2481
AxPageModel::AxPageModel()
2482
0
{
2483
0
}
2484
2485
ApiControlType AxPageModel::getControlType() const
2486
0
{
2487
0
    return API_CONTROL_PAGE;
2488
0
}
2489
2490
void AxPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2491
0
{
2492
0
    rPropMap.setProperty( PROP_Title, maCaption );
2493
0
    rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2494
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2495
0
    AxContainerModelBase::convertProperties( rPropMap, rConv );
2496
0
}
2497
2498
AxMultiPageModel::AxMultiPageModel() :
2499
0
    mnActiveTab( 0 ),
2500
0
    mnTabStyle( AX_TABSTRIP_TABS )
2501
0
{
2502
0
}
2503
2504
ApiControlType AxMultiPageModel::getControlType() const
2505
0
{
2506
0
    return API_CONTROL_MULTIPAGE;
2507
0
}
2508
2509
void AxMultiPageModel::importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages )
2510
0
{
2511
    // PageProperties
2512
0
    for ( sal_Int32 nPage = 0; nPage < nPages; ++nPage )
2513
0
    {
2514
0
        AxBinaryPropertyReader aReader( rInStrm );
2515
0
        aReader.skipUndefinedProperty();
2516
0
        aReader.skipIntProperty< sal_uInt32 >(); // TransitionEffect
2517
0
        aReader.skipIntProperty< sal_uInt32 >(); // TransitionPeriod
2518
0
    }
2519
    // MultiPageProperties
2520
0
    AxBinaryPropertyReader aReader( rInStrm );
2521
0
    sal_uInt32 nPageCount = 0;
2522
0
    aReader.skipUndefinedProperty();
2523
0
    aReader.readIntProperty< sal_uInt32 >(nPageCount); // PageCount
2524
0
    aReader.skipIntProperty< sal_uInt32 >(); //ID
2525
2526
    // IDs
2527
0
    for ( sal_uInt32 count = 0; count < nPageCount; ++count )
2528
0
    {
2529
0
        mnIDs.push_back( rInStrm.readInt32() );
2530
0
    }
2531
0
}
2532
2533
void AxMultiPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2534
0
{
2535
0
    rPropMap.setProperty( PROP_Title, maCaption );
2536
0
    rPropMap.setProperty( PROP_MultiPageValue, mnActiveTab + 1);
2537
0
    rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2538
0
    rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2539
0
    rPropMap.setProperty( PROP_Decoration, mnTabStyle != AX_TABSTRIP_NONE );
2540
2541
0
    AxContainerModelBase::convertProperties( rPropMap, rConv );
2542
0
}
2543
2544
AxUserFormModel::AxUserFormModel()
2545
0
{
2546
0
}
2547
2548
ApiControlType AxUserFormModel::getControlType() const
2549
0
{
2550
0
    return API_CONTROL_DIALOG;
2551
0
}
2552
2553
void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2554
0
{
2555
0
    rPropMap.setProperty( PROP_Title, maCaption );
2556
0
    rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2557
0
    rConv.convertAxPicture( rPropMap, maPictureData, AX_PICPOS_CENTER  );
2558
0
    rConv.convertScrollabilitySettings( rPropMap, maScrollPos, maLogicalSize, mnScrollBars );
2559
0
    AxContainerModelBase::convertProperties( rPropMap, rConv );
2560
0
}
2561
2562
HtmlSelectModel::HtmlSelectModel()
2563
0
{
2564
0
}
2565
2566
bool
2567
HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
2568
0
{
2569
0
    if (rInStrm.size()<=0)
2570
0
        return true;
2571
2572
0
    OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
2573
2574
    // replace crlf with lf
2575
0
    OUString data = sStringContents.replaceAll( "\x0D\x0A" , "\x0A" );
2576
2577
0
    std::vector< OUString > listValues;
2578
0
    std::vector< sal_Int16 > selectedIndices;
2579
2580
    // Ultra hacky parser for the info
2581
0
    sal_Int32 nLineIdx {0};
2582
    // first line will tell us if multiselect is enabled
2583
0
    if (o3tl::getToken(data, 0, '\n', nLineIdx ) == u"<SELECT MULTIPLE")
2584
0
        mnMultiSelect = AX_SELECTION_MULTI;
2585
    // skip first and last lines, no data there
2586
0
    if (nLineIdx>0)
2587
0
    {
2588
0
        for (;;)
2589
0
        {
2590
0
            std::u16string_view sLine( o3tl::getToken(data, 0, '\n', nLineIdx ) );
2591
0
            if (nLineIdx<0)
2592
0
                break;  // skip last line
2593
2594
0
            if ( !sLine.empty() )
2595
0
            {
2596
0
                OUString displayValue( o3tl::getToken(sLine, 1, '>' ) );
2597
0
                if ( displayValue.getLength() )
2598
0
                {
2599
                    // Really we should be using a proper html parser
2600
                    // escaping some common bits to be escaped
2601
0
                    displayValue = displayValue.replaceAll( "&lt;", "<" );
2602
0
                    displayValue = displayValue.replaceAll( "&gt;", ">" );
2603
0
                    displayValue = displayValue.replaceAll( "&quot;", "\"" );
2604
0
                    displayValue = displayValue.replaceAll( "&amp;", "&" );
2605
0
                    listValues.push_back( displayValue );
2606
0
                    if( sLine.find( u"OPTION SELECTED" ) != std::u16string_view::npos )
2607
0
                        selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 );
2608
0
                }
2609
0
            }
2610
0
        }
2611
0
    }
2612
0
    if ( !listValues.empty() )
2613
0
    {
2614
0
        msListData.realloc( listValues.size() );
2615
0
        auto psListData = msListData.getArray();
2616
0
        sal_Int32 index = 0;
2617
0
        for (auto const& listValue : listValues)
2618
0
             psListData[ index++ ] = listValue;
2619
0
    }
2620
0
    if ( !selectedIndices.empty() )
2621
0
    {
2622
0
        msIndices.realloc( selectedIndices.size() );
2623
0
        auto psIndices = msIndices.getArray();
2624
0
        sal_Int32 index = 0;
2625
0
        for (auto const& selectedIndice : selectedIndices)
2626
0
             psIndices[ index++ ] = selectedIndice;
2627
0
    }
2628
0
    return true;
2629
0
}
2630
2631
void
2632
HtmlSelectModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2633
0
{
2634
0
   rPropMap.setProperty( PROP_StringItemList, msListData );
2635
0
   rPropMap.setProperty( PROP_SelectedItems, msIndices );
2636
0
   rPropMap.setProperty( PROP_Dropdown, true );
2637
0
   AxListBoxModel::convertProperties( rPropMap, rConv );
2638
0
}
2639
2640
HtmlTextBoxModel::HtmlTextBoxModel()
2641
0
{
2642
0
}
2643
2644
bool
2645
HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm )
2646
0
{
2647
#if OSL_DEBUG_LEVEL >= 2
2648
    OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
2649
    // in msocximex ( where this is ported from, it appears *nothing* is read
2650
    // from the control stream ), surely there is some useful info there ?
2651
    SAL_WARN("oox", "HtmlTextBoxModel::importBinaryModel - string contents of stream: " << sStringContents );
2652
#else
2653
0
    (void) rInStrm;
2654
0
#endif
2655
0
    return true;
2656
0
}
2657
2658
EmbeddedControl::EmbeddedControl( OUString aName ) :
2659
14.5k
    maName(std::move( aName ))
2660
14.5k
{
2661
14.5k
}
2662
2663
ControlModelBase* EmbeddedControl::createModelFromGuid( std::u16string_view rClassId )
2664
14.5k
{
2665
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_COMMANDBUTTON ) )     return &createModel< AxCommandButtonModel >();
2666
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_LABEL ) )             return &createModel< AxLabelModel >();
2667
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_IMAGE ) )             return &createModel< AxImageModel >();
2668
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_TOGGLEBUTTON ) )      return &createModel< AxToggleButtonModel >();
2669
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_CHECKBOX ) )          return &createModel< AxCheckBoxModel >();
2670
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_OPTIONBUTTON ) )      return &createModel< AxOptionButtonModel >();
2671
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_TEXTBOX ) )           return &createModel< AxTextBoxModel >();
2672
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_LISTBOX ) )           return &createModel< AxListBoxModel >();
2673
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_COMBOBOX ) )          return &createModel< AxComboBoxModel >();
2674
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_SPINBUTTON ) )        return &createModel< AxSpinButtonModel >();
2675
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_SCROLLBAR ) )         return &createModel< AxScrollBarModel >();
2676
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" AX_GUID_FRAME ) )             return &createModel< AxFrameModel >();
2677
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" COMCTL_GUID_SCROLLBAR_60 ) )  return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 );
2678
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" HTML_GUID_SELECT ) )  return &createModel< HtmlSelectModel >();
2679
14.5k
    if( o3tl::equalsIgnoreAsciiCase(rClassId,  u"" HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >();
2680
2681
14.5k
    mxModel.reset();
2682
14.5k
    return nullptr;
2683
14.5k
}
2684
2685
OUString EmbeddedControl::getServiceName() const
2686
25
{
2687
25
    return mxModel ? mxModel->getServiceName() : OUString();
2688
25
}
2689
2690
bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const
2691
0
{
2692
0
    if( mxModel && rxCtrlModel.is() && !maName.isEmpty() )
2693
0
    {
2694
0
        PropertyMap aPropMap;
2695
0
        aPropMap.setProperty( PROP_Name, maName );
2696
0
        try
2697
0
        {
2698
0
            aPropMap.setProperty( PROP_GenerateVbaEvents, true);
2699
0
        }
2700
0
        catch (const Exception&)
2701
0
        {
2702
0
            TOOLS_WARN_EXCEPTION("oox", "");
2703
0
        }
2704
0
        mxModel->convertProperties( aPropMap, rConv );
2705
0
        PropertySet aPropSet( rxCtrlModel );
2706
0
        aPropSet.setProperties( aPropMap );
2707
0
        return true;
2708
0
    }
2709
0
    return false;
2710
0
}
2711
2712
void EmbeddedControl::convertFromProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv )
2713
0
{
2714
0
    if( mxModel && rxCtrlModel.is() && !maName.isEmpty() )
2715
0
    {
2716
0
        PropertySet aPropSet( rxCtrlModel );
2717
0
        aPropSet.getProperty( maName, PROP_Name );
2718
0
        mxModel->convertFromProperties( aPropSet, rConv );
2719
0
    }
2720
0
}
2721
2722
EmbeddedForm::EmbeddedForm( const Reference< XModel >& rxDocModel,
2723
        const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper ) :
2724
18
    maControlConv( rxDocModel, rGraphicHelper, true/*bDefaultColorBgr*/ ),
2725
18
    mxModelFactory( rxDocModel, UNO_QUERY ),
2726
18
    mxFormsSupp( rxDrawPage, UNO_QUERY )
2727
18
{
2728
18
    OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );
2729
18
}
2730
2731
Reference< XControlModel > EmbeddedForm::convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex )
2732
26
{
2733
26
    Reference< XControlModel > xRet;
2734
26
    if( mxModelFactory.is() && rControl.hasModel() ) try
2735
25
    {
2736
        // create the UNO control model
2737
25
        OUString aServiceName = rControl.getServiceName();
2738
25
        Reference< XFormComponent > xFormComp( mxModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW );
2739
25
        Reference< XControlModel > xCtrlModel( xFormComp, UNO_QUERY_THROW );
2740
2741
        // convert the control properties
2742
25
        if( rControl.convertProperties( xCtrlModel, maControlConv ) )
2743
0
            xRet = std::move(xCtrlModel);
2744
        // insert the control into the form
2745
25
        Reference< XIndexContainer > xFormIC( createXForm(), UNO_SET_THROW );
2746
25
        rnCtrlIndex = xFormIC->getCount();
2747
25
        xFormIC->insertByIndex( rnCtrlIndex, Any( xFormComp ) );
2748
25
    }
2749
25
    catch (const Exception&)
2750
25
    {
2751
25
        TOOLS_WARN_EXCEPTION("oox", "exception creating Control");
2752
25
    }
2753
26
    return xRet;
2754
26
}
2755
2756
Reference< XIndexContainer > const & EmbeddedForm::createXForm()
2757
0
{
2758
0
    if( mxFormsSupp.is() )
2759
0
    {
2760
0
        try
2761
0
        {
2762
0
            Reference< XNameContainer > xFormsNC( mxFormsSupp->getForms(), UNO_SET_THROW );
2763
0
            OUString aFormName = u"Standard"_ustr;
2764
0
            if( xFormsNC->hasByName( aFormName ) )
2765
0
            {
2766
0
                mxFormIC.set( xFormsNC->getByName( aFormName ), UNO_QUERY_THROW );
2767
0
            }
2768
0
            else if( mxModelFactory.is() )
2769
0
            {
2770
0
                Reference< XForm > xForm( mxModelFactory->createInstance( u"com.sun.star.form.component.Form"_ustr ), UNO_QUERY_THROW );
2771
0
                xFormsNC->insertByName( aFormName, Any( xForm ) );
2772
0
                mxFormIC.set( xForm, UNO_QUERY_THROW );
2773
0
            }
2774
0
        }
2775
0
        catch (const Exception&)
2776
0
        {
2777
0
            TOOLS_WARN_EXCEPTION("oox", "exception creating Form");
2778
0
        }
2779
        // always clear the forms supplier to not try to create the form again
2780
0
        mxFormsSupp.clear();
2781
0
    }
2782
0
    return mxFormIC;
2783
0
}
2784
2785
} // namespace oox
2786
2787
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */