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