update ooo310-m15
[ooovba.git] / svx / source / msfilter / msocximex.cxx
blobc7b10827ad00ab667a95bd211970964f82c74260
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: msocximex.cxx,v $
10 * $Revision: 1.38 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
35 #include <com/sun/star/uno/Any.h>
36 #include <com/sun/star/text/VertOrientation.hpp>
37 #include <com/sun/star/text/XText.hpp>
38 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HDL_
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #endif
41 #include <com/sun/star/text/TextContentAnchorType.hpp>
42 #include <com/sun/star/drawing/XShape.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/drawing/XDrawPage.hpp>
45 #include <com/sun/star/drawing/XShapes.hpp>
46 #include <com/sun/star/drawing/XControlShape.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <com/sun/star/container/XIndexContainer.hpp>
49 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
50 #include <com/sun/star/form/XFormsSupplier.hpp>
51 #include <com/sun/star/form/XForm.hpp>
52 #include <com/sun/star/form/binding/XBindableValue.hpp>
53 #include <com/sun/star/form/binding/XValueBinding.hpp>
54 #include <com/sun/star/form/binding/XListEntrySink.hpp>
55 #include <com/sun/star/form/binding/XListEntrySource.hpp>
56 #include <com/sun/star/form/FormComponentType.hpp>
57 #include <com/sun/star/awt/FontWeight.hpp>
58 #include <com/sun/star/awt/FontSlant.hpp>
59 #include <com/sun/star/awt/FontUnderline.hpp>
60 #include <com/sun/star/awt/FontStrikeout.hpp>
61 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
62 #include <com/sun/star/style/VerticalAlignment.hpp>
63 #include <comphelper/extract.hxx>
64 #include <com/sun/star/awt/XControlModel.hpp>
65 #include <com/sun/star/io/XInputStreamProvider.hpp>
66 #include <rtl/ustrbuf.hxx>
67 #include <vcl/svapp.hxx>
68 #include <sfx2/objsh.hxx>
69 #include <xmlscript/xmldlg_imexp.hxx>
70 #include <svx/msocximex.hxx>
72 #include <osl/file.hxx>
73 #include <unotools/ucbstreamhelper.hxx>
74 //#include <sfx2/docfile.hxx>
76 #include <com/sun/star/embed/XStorage.hpp>
77 #include <com/sun/star/embed/XTransactedObject.hpp>
78 #include <com/sun/star/embed/ElementModes.hpp>
80 #include <comphelper/processfactory.hxx> // shouldn't be needed
81 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
84 #include <algorithm>
85 #include <memory>
86 #include <com/sun/star/graphic/GraphicObject.hpp>
87 #include <com/sun/star/graphic/XGraphicProvider.hpp>
88 #include <com/sun/star/graphic/XGraphic.hpp>
89 #include <com/sun/star/io/XInputStream.hpp>
90 #include <comphelper/componentcontext.hxx>
91 #include <unotools/streamwrap.hxx>
93 #include <com/sun/star/beans/NamedValue.hpp>
94 #include <com/sun/star/table/XCellRange.hpp>
95 #include <com/sun/star/table/CellRangeAddress.hpp>
96 #include <com/sun/star/table/CellAddress.hpp>
97 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
98 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
99 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
100 #include <svtools/filterutils.hxx>
102 #ifndef C2S
103 #define C2S(cChar) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(cChar))
104 #endif
105 #ifndef C2U
106 #define C2U(cChar) rtl::OUString::createFromAscii(cChar)
107 #endif
109 using namespace ::com::sun::star;
110 #if 0
111 using namespace ::com::sun::star::uno;
112 using namespace ::com::sun::star::lang;
113 using namespace ::com::sun::star::beans;
114 using namespace ::com::sun::star::drawing;
115 using namespace ::com::sun::star::form;
116 using namespace ::com::sun::star::text;
117 using namespace ::com::sun::star::container;
118 #endif
119 using namespace ::rtl;
120 using namespace cppu;
123 #define WW8_ASCII2STR(s) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(s))
124 #define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
127 static char sWW8_form[] = "WW-Standard";
130 struct SortOrderByTabPos
132 bool operator()( const OCX_Control* a, const OCX_Control* b )
134 return a->mnTabPos < b->mnTabPos;
139 sal_uInt8 __READONLY_DATA OCX_Control::aObjInfo[4] = { 0x00, 0x12, 0x03, 0x00 };
141 long ReadAlign(SvStorageStream *pS, long nPos, int nAmount)
143 if (long nAlign = nPos % nAmount)
146 long nLen = nAmount - nAlign;
147 pS->SeekRel(nLen);
148 return nLen;
150 return 0;
153 // NP - Images in controls in OO2.0/SO8 exist as links, e.g. they are not part of the document so are
154 // referenced externally. On import from ms document try to save images for controls here.
155 // Images are stored in directory called temp in the user installation directory. Next version of OO/SO
156 // hopefully will address this issue and allow a choice e.g. images for controls to be stored as links
157 // or embeded in the document.
158 uno::Reference< graphic::XGraphicObject> lcl_readGraphicObject( SotStorageStream *pS )
160 uno::Reference< graphic::XGraphicObject > xGrfObj;
161 uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
162 if( xServiceManager.is() )
166 // use the GraphicProvider service to get the XGraphic
167 uno::Reference< graphic::XGraphicProvider > xGraphProvider(
168 xServiceManager->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.graphic.GraphicProvider" ) ), uno::UNO_QUERY );
169 if( xGraphProvider.is() )
171 uno::Reference< io::XInputStream > xStream( new utl::OInputStreamWrapper( *pS ) );
172 if( xStream.is() )
174 uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
175 aMediaProps[0].Name = ::rtl::OUString::createFromAscii( "InputStream" );
176 aMediaProps[0].Value <<= xStream;
177 uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps );
178 if( xGraphic.is() )
180 // create an XGraphicObject
181 ::comphelper::ComponentContext aContext( xServiceManager );
182 xGrfObj = graphic::GraphicObject::create( aContext.getUNOContext() );
183 xGrfObj->setGraphic(xGraphic);
188 catch( uno::Exception& )
192 return xGrfObj;
196 long WriteAlign(SvStorageStream *pS, int nAmount)
198 if (long nAlign = pS->Tell() % nAmount)
200 long nLen = nAmount - nAlign;
201 for (long i=0; i< nLen; ++i)
202 *pS << sal_uInt8(0x00);
203 return nLen;
205 return 0;
207 // string import/export =======================================================
208 /** #117832# import of form control names
209 * control name is located in stream ("\3OCXNAME")
210 * a strings in "\3OCXNAME" stream seem to be terminated by 4 trailing bytes of 0's.
211 * ====
212 * Note: If the string in the stream is overwritten by a shorter string
213 * some characters from the original string may remain, the new string however
214 * will still be terminated in the same way e.g. by 4 bytes with value 0.
217 bool writeOCXNAME( const OUString& sOCXName, SvStorageStream* pStream )
219 const sal_Unicode* buffer = sOCXName.getStr();
220 for ( sal_Int32 index=0; index < sOCXName.getLength(); index++ )
222 sal_uInt16 ch = static_cast< sal_uInt16 >( buffer[ index ] );
223 *pStream << ch;
225 // write
226 *pStream << sal_uInt32(0);
227 return ( SVSTREAM_OK == pStream->GetError() );
231 bool readOCXNAME( OUString& sCName, SvStorageStream* pStream )
234 * Read uniCode until no data or 0 encountered
236 OUStringBuffer buf(40);
239 sal_uInt16 ch = 0;
240 *pStream >> ch;
241 sal_Unicode uni = static_cast< sal_Unicode >( ch );
242 if ( uni == 0 )
244 break;
246 buf.append( &uni, 1 );
248 } while ( !pStream->IsEof() );
250 sCName = buf.makeStringAndClear();
251 return ( SVSTREAM_OK == pStream->GetError() );
255 /* #110435# (DR, 2003-11-12) ** Import of Unicode strings in form controls **
257 Strings may be stored either as compressed or uncompressed Unicode
258 character array. There are no encoded byte strings anywhere.
260 The string length field stores the length of the character array (not the
261 character count of the string) in the lower 31 bits, and the compression
262 state in the highest bit.
264 A set bit means the character array is compressed. This means all Unicode
265 characters are <=0xFF. Therefore the high bytes of all characters are left
266 out, and the character array size is equal to the string length.
268 A cleared bit means the character array is not compressed. The buffer
269 contains Little-Endian Unicode characters, and the resulting string length
270 is half the buffer size.
272 TODO: This implementation of the new string import is a hack to keep
273 msocximex.hxx unchanged. A better implementation would replace the char*
274 members of all classes by something more reasonable.
277 namespace {
279 const sal_uInt32 SVX_MSOCX_SIZEMASK = 0x7FFFFFFF; /// Mask for character buffer size.
280 const sal_uInt32 SVX_MSOCX_COMPRESSED = 0x80000000; /// 1 = compressed Unicode array.
283 /** Returns true, if the passed length field specifies a compressed character array.
285 inline bool lclIsCompressed( sal_uInt32 nLenFld )
287 return (nLenFld & SVX_MSOCX_COMPRESSED) != 0;
291 /** Extracts and returns the memory size of the character buffer.
292 @return Character buffer size (may differ from resulting string length!).
294 inline sal_uInt32 lclGetBufferSize( sal_uInt32 nLenFld )
296 return nLenFld & SVX_MSOCX_SIZEMASK;
300 // import ---------------------------------------------------------------------
302 /** Reads the character array of a string in a form control.
304 Creates a new character array containing the character data.
305 The length field must be read before and passed to this function.
306 Aligns stream position to multiple of 4 before.
308 @param rStrm
309 The input stream.
311 @param rpcCharArr
312 (out-param) Will point to the created character array,
313 or will be 0 if string is empty. The array is NOT null-terminated.
314 If the passed pointer points to an old existing array, it will be
315 deleted before. Caller must delete the returned array.
317 @param nLenFld
318 The corresponding string length field read somewhere before.
320 void lclReadCharArray( SvStorageStream& rStrm, char*& rpcCharArr, sal_uInt32 nLenFld, long nPos )
322 delete[] rpcCharArr;
323 rpcCharArr = 0;
324 sal_uInt32 nBufSize = lclGetBufferSize( nLenFld );
325 DBG_ASSERT( nBufSize <= 0xFFFF, "lclReadCharArray - possible read error: char array is too big" );
326 if( nBufSize && nBufSize <= 0xFFFF )
328 rpcCharArr = new char[ nBufSize ];
329 if( rpcCharArr )
331 ReadAlign( &rStrm, nPos, 4 );
332 rStrm.Read( rpcCharArr, nBufSize );
338 /** Creates an OUString from a character array created with lclReadCharArray().
340 The passed parameters must match, that means the length field must be the
341 same used to create the passed character array.
343 @param pcCharArr
344 The character array returned by lclReadCharArray(). May be compressed
345 or uncompressed, next parameter nLenFld will specify this.
347 @param nLenFld
348 MUST be the same string length field that has been passed to
349 lclReadCharArray() to create the character array in previous parameter
350 pcCharArr.
352 @return
353 An OUString containing the decoded string data. Will be empty if
354 pcCharArr is 0.
356 OUString lclCreateOUString( const char* pcCharArr, sal_uInt32 nLenFld )
358 sal_uInt32 nBufSize = lclGetBufferSize( nLenFld );
359 if( lclIsCompressed( nLenFld ) )
360 return svt::BinFilterUtils::CreateOUStringFromStringArray( pcCharArr, nBufSize );
362 return svt::BinFilterUtils::CreateOUStringFromUniStringArray( pcCharArr, nBufSize );
365 // export ---------------------------------------------------------------------
367 /** This class implements writing a character array from a Unicode string.
369 Usage:
370 1) Construct an instance, either directly with an OUString, or with an UNO
371 Any containing an OUString.
372 2) Check with HasData(), if there is something to write.
373 3) Write the string length field with WriteLenField() at the right place.
374 4) Write the encoded character array with WriteCharArray().
376 class SvxOcxString
378 public:
379 /** Constructs an empty string. String data may be set later by assignment. */
380 inline explicit SvxOcxString() : mnLenFld( 0 ) {}
381 /** Constructs the string from the passed OUString. */
382 inline explicit SvxOcxString( const OUString& rStr ) { Init( rStr ); }
383 /** Constructs the string from the passed UNO Any. */
384 inline explicit SvxOcxString( const uno::Any& rAny ) { Init( rAny ); }
386 /** Assigns the passed string to the object. */
387 inline SvxOcxString& operator=( const OUString& rStr ) { Init( rStr ); return *this; }
388 /** Assigns the string in the passed UNO Any to the object. */
389 inline SvxOcxString& operator=( const uno::Any& rAny ) { Init( rAny ); return *this; }
391 /** Returns true, if the string contains at least one character to write. */
392 inline bool HasData() const { return maString.getLength() > 0; }
394 /** Writes the encoded 32-bit string length field. Aligns stream position to mult. of 4 before. */
395 void WriteLenField( SvStorageStream& rStrm ) const;
396 /** Writes the encoded character array. Aligns stream position to mult. of 4 before. */
397 void WriteCharArray( SvStorageStream& rStrm ) const;
399 private:
400 inline void Init( const OUString& rStr ) { maString = rStr; Init(); }
401 void Init( const uno::Any& rAny );
402 void Init();
404 OUString maString; /// The initial string data.
405 sal_uInt32 mnLenFld; /// The encoded string length field.
408 void SvxOcxString::Init( const uno::Any& rAny )
410 if( !(rAny >>= maString) )
411 maString = OUString();
412 Init();
415 void SvxOcxString::Init()
417 mnLenFld = static_cast< sal_uInt32 >( maString.getLength() );
418 bool bCompr = true;
419 // try to find a character >= 0x100 -> character array will be stored uncompressed then
420 if( const sal_Unicode* pChar = maString.getStr() )
421 for( const sal_Unicode* pEnd = pChar + maString.getLength(); bCompr && (pChar < pEnd); ++pChar )
422 bCompr = (*pChar < 0x100);
423 if( bCompr )
424 mnLenFld |= SVX_MSOCX_COMPRESSED;
425 else
426 mnLenFld *= 2;
429 void SvxOcxString::WriteLenField( SvStorageStream& rStrm ) const
431 if( HasData() )
433 WriteAlign( &rStrm, 4);
434 rStrm << mnLenFld;
438 void SvxOcxString::WriteCharArray( SvStorageStream& rStrm ) const
440 if( HasData() )
442 const sal_Unicode* pChar = maString.getStr();
443 const sal_Unicode* pEnd = pChar + maString.getLength();
444 bool bCompr = lclIsCompressed( mnLenFld );
446 WriteAlign( &rStrm, 4);
447 for( ; pChar < pEnd; ++pChar )
449 // write compressed Unicode (not encoded bytestring), or Little-Endian Unicode
450 rStrm << static_cast< sal_uInt8 >( *pChar );
451 if( !bCompr )
452 rStrm << static_cast< sal_uInt8 >( *pChar >> 8 );
457 const sal_uInt16 USERFORM = (sal_uInt16)0xFF;
458 const sal_uInt16 STDCONTAINER = (sal_uInt16)0xFE;
460 const sal_uInt16 PAGE = (sal_uInt16)0x07;
462 const sal_uInt16 IMAGE = (sal_uInt16)0x0C;
463 const sal_uInt16 FRAME = (sal_uInt16)0x0E;
465 const sal_uInt16 SPINBUTTON = (sal_uInt16)0x10;
466 const sal_uInt16 CMDBUTTON = (sal_uInt16)0x11;
467 const sal_uInt16 TABSTRIP = (sal_uInt16)0x12;
469 const sal_uInt16 LABEL = (sal_uInt16)0x15;
471 const sal_uInt16 TEXTBOX = (sal_uInt16)0x17;
472 const sal_uInt16 LISTBOX = (sal_uInt16)0x18;
473 const sal_uInt16 COMBOBOX = (sal_uInt16)0x19;
474 const sal_uInt16 CHECKBOX = (sal_uInt16)0x1A;
476 const sal_uInt16 OPTIONBUTTON = (sal_uInt16)0x1B;
477 const sal_uInt16 TOGGLEBUTTON = (sal_uInt16)0x1C;
479 const sal_uInt16 SCROLLBAR = (sal_uInt16)0x2F;
481 const sal_uInt16 MULTIPAGE = (sal_uInt16)0x39;
482 // The IDs with bit 0x8000 set appear to be generated.
483 // It looks like these ID's are used with the non-toolbox [1]
484 // ActiveX controls that can be present in a Userform
485 // ( note: RefEdit seems to be an exception )
486 // In UserForm::Read just before the Container record starts
487 // you will notice there can be sometimes trailing records,
488 // it seems that these records have a 1:1 relationship with the non-toolbox
489 // controls present in the Userform. An id in the trailing record
490 // seems to identify the specific ActiveX control and an artificial nTypeIdent
491 // e.g. 0x8000, 0x8001 etc. is created so as to be able to associate
492 // the ActiveX control when referenced later
493 // [1] Such ActiveX controls are added via Tools/AddionalControls
494 // menu
496 // create a fixed set of those special id(s)
497 // ahem, we can only read one Progress bars at the moment so....
498 const sal_uInt16 PROGRESSBAR = (sal_uInt16)0x8000;
500 // A set of IDs from the trailing records mentioned above that seem to
501 // identify the following ActiveX controls
502 // Currently we only can process ( in a limited way ) the ProgressBar
503 // the other ID's are for reference ( & future )
505 // RefEdit control {00024512-0000-0000-c000-000000000046}
506 const sal_uInt8 aRefEditID[] =
508 0x12, 0x45, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
511 // Microsoft ProgressBar Control, version 6.0 {35053A22-8589-11D1-B16A-00C0F0283628}
512 const sal_uInt8 aProgressID[] =
514 0x22, 0x3a, 0x05, 0x35, 0x89, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
517 // Calendar Control 10.0
518 const sal_uInt8 aCalendarID[] =
520 0x2b, 0xc9, 0x27, 0x8e, 0x64, 0x12, 0x1c, 0x10, 0x8a, 0x2f, 0x04, 0x02, 0x24, 0x00, 0x9c, 0x02,
524 // Microsoft ImageComboxBox Control, version 6.0 {DD9DA666-8594-11D1-B16A-00C0F0283628}
525 const sal_uInt8 aImageComboID[] =
527 0x66, 0xa6, 0x9d, 0xdd, 0x94, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
530 // Microsoft ImageList Control, version 6.0 {2C247F23-8591-11D1-B16A-00C0F0283628}
531 const sal_uInt8 aImageListID[] =
533 0x23, 0x7f, 0x24, 0x2c, 0x91, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
536 // Microsoft Slider Control, version 6.0 {F08DF954-8592-11D1-B16A-00C0F0283628}
537 const sal_uInt8 aSliderID[] =
539 0x54, 0xf9, 0x8d, 0xf0, 0x92, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
542 // Microsoft StatusBar Control, version 6.0 {8E3867A3-8586-11D1-B16A-00C0F0283628}
543 const sal_uInt8 aStatusBarID[] =
545 0xa3, 0x67, 0x38, 0x8e, 0x86, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
548 // Microsoft Office Chart 10.0
549 const sal_uInt8 aChartSpaceID[] =
551 0x46, 0xe5, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
554 const sal_Int16 ActiveXIDLen = 0x10; // CLSID len
555 const sal_Int16 ActiveXIDBlockLen = 0x30; // the block len that contains the CLSID
557 bool lcl_handleActiveXControl( SvStorageStream *pS, sal_uInt16& nTypeID )
559 nTypeID = 0; // Illegal ActiveX ID
560 bool bRes = false;
561 sal_uInt16 nIdentifier, nFixedAreaLen;
562 *pS >> nIdentifier;
563 *pS >> nFixedAreaLen;
564 pS->SeekRel( ( nFixedAreaLen - ActiveXIDBlockLen ) );
565 sal_uInt8 aID[ ActiveXIDLen ];
566 if ( !pS->IsEof() )
568 pS->Read( aID, ActiveXIDLen );
569 pS->SeekRel( ActiveXIDBlockLen - ActiveXIDLen ); // read remainer of record
570 if ( memcmp( aID, aProgressID, ActiveXIDLen ) == 0 )
572 nTypeID = PROGRESSBAR;
573 OSL_TRACE("Found supported ***PROGRESSBAR*** ActiveX control");
574 bRes = true;
576 #if (OSL_DEBUG_LEVEL > 0)
577 // If we really want to process these more controls we should put them in
578 // a list or array and have a single loop testing each id. For the moment
579 // as we only can process PROGRESSBAR, not much point doing that until
580 // we add support for at least another activex control
582 else if ( memcmp( aID, aCalendarID, ActiveXIDLen ) == 0 )
583 OSL_TRACE("Found unsupported ***CALENDAR*** ActiveX control");
584 else if ( memcmp( aID, aRefEditID, ActiveXIDLen ) == 0 )
585 OSL_TRACE("Found unsupported ***REFEDIT*** ActiveX control");
586 else if ( memcmp( aID, aImageComboID, ActiveXIDLen ) == 0 )
587 OSL_TRACE("Found unsupported ***IMAGECOMBO*** ActiveX control");
588 else if ( memcmp( aID, aImageListID, ActiveXIDLen ) == 0 )
589 OSL_TRACE("Found unsupported ***IMAGELIST*** ActiveX control");
590 else if ( memcmp( aID, aChartSpaceID, ActiveXIDLen ) == 0 )
591 OSL_TRACE("Found unsupported ***CHARTSPACE*** ActiveX control");
592 else if ( memcmp( aID, aSliderID, ActiveXIDLen ) == 0 )
593 OSL_TRACE("Found unsupported ***SLIDER*** ActiveX control");
594 else if ( memcmp( aID, aStatusBarID, ActiveXIDLen ) == 0 )
595 OSL_TRACE("Found unsupported ***STATUSBAR*** ActiveX control");
596 #endif
597 else
599 OSL_TRACE("Unknown activeX ID !");
602 return bRes;
605 typedef std::vector< ContainerRecord > ContainerRecordList;
607 class ContainerRecReader
609 public:
611 virtual ~ContainerRecReader() {}
613 virtual bool Read( OCX_ContainerControl* pContainerControl, SvStorageStream *pS)
615 *pS >> nNoRecords;
616 *pS >> nTotalLen;
618 if ( isMultiPage )
620 if ( !handleMultiPageHdr( pS ) )
622 return false;
625 else
627 if ( !handleStandardHdr( pS ) )
629 return false;
633 records.clear();
634 for (sal_uInt32 nRecord = 0; nRecord < nNoRecords; ++nRecord)
636 // DR #134146# redo loading of FrameChild data
638 ContainerRecord rec;
640 // record header
641 sal_uInt16 nId, nSize;
642 *pS >> nId >> nSize;
643 sal_Size nStartPos = pS->Tell();
645 // content flags
646 sal_uInt32 nContentFlags;
647 *pS >> nContentFlags;
649 // length of control name
650 sal_uInt32 nNameLen = 0;
651 if( nContentFlags & 0x00000001 )
652 *pS >> nNameLen;
653 // length of control tag
654 sal_uInt32 nTagLen = 0;
655 if( nContentFlags & 0x00000002 )
656 *pS >> nTagLen;
657 // substorage id for frames
658 if( nContentFlags & 0x00000004 )
659 *pS >> rec.nSubStorageId;
660 // help-context id
661 if( nContentFlags & 0x00000008 )
662 pS->SeekRel( 4 );
663 // option flags
664 if( nContentFlags & 0x00000010 )
666 sal_uInt32 nBitFlags = 0;
667 *pS >> nBitFlags;
668 rec.bVisible = ( ( nBitFlags & 0x02 ) == 0x02 );
670 // substream size
671 if( nContentFlags & 0x00000020 )
672 *pS >> rec.nSubStreamLen;
673 // tabstop position
674 if( nContentFlags & 0x00000040 )
675 *pS >> rec.nTabPos;
676 // control type
677 if( nContentFlags & 0x00000080 )
678 *pS >> rec.nTypeIdent;
679 if( nContentFlags & 0x00000200 )
680 pS->SeekRel( 4 ); // Grouping?
681 // length of infotip
682 sal_uInt32 nTipLen = 0;
683 if( nContentFlags & 0x00000800 )
685 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
686 *pS >> nTipLen;
689 sal_uInt32 nCntrlIdLen = 0;
690 if( nContentFlags & 0x00001000 )
691 *pS >> nCntrlIdLen;
693 // length of control source name
694 sal_uInt32 nCtrlSrcLen = 0;
695 if( nContentFlags & 0x00002000 )
697 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
698 *pS >> nCtrlSrcLen;
701 // length of row source name
702 sal_uInt32 nRowSrcLen = 0;
703 if( nContentFlags & 0x00004000 )
705 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
706 *pS >> nRowSrcLen;
709 // control name
710 sal_Char* pName = 0;
711 sal_uInt32 nNameBufSize = lclGetBufferSize( nNameLen );
712 if( nNameBufSize > 0 )
714 pName = new char[ nNameBufSize ];
715 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
716 pS->Read( pName, nNameBufSize );
718 // control tag
719 sal_uInt32 nTagBufSize = lclGetBufferSize( nTagLen );
720 if( nTagBufSize > 0 )
722 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
723 pS->SeekRel( nTagBufSize );
726 // control position
727 if( nContentFlags & 0x00000100 )
729 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
730 *pS >> rec.nLeft >> rec.nTop;
733 // control infotip
734 sal_uInt32 nTipBufSize = lclGetBufferSize( nTipLen );
735 if( nTipBufSize > 0 )
737 std::auto_ptr< sal_Char > pTipName;
738 pTipName.reset( new sal_Char[ nTipBufSize ] );
739 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
740 pS->Read( pTipName.get(), nTipBufSize );
741 rec.controlTip = lclCreateOUString( pTipName.get(), nTipLen );
743 // control id
744 sal_uInt32 nCntrlIdSize = lclGetBufferSize( nCntrlIdLen );
745 if( nCntrlIdSize > 0 )
747 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
748 pS->SeekRel( nCntrlIdSize );
750 // control source name
751 sal_uInt32 nCtrlSrcBufSize = lclGetBufferSize( nCtrlSrcLen );
752 if( nCtrlSrcBufSize > 0 )
754 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
755 std::auto_ptr< sal_Char > pCtrlSrcName;
756 pCtrlSrcName.reset( new sal_Char[ nCtrlSrcBufSize ] );
757 pS->Read( pCtrlSrcName.get(), nCtrlSrcBufSize );
758 rec.sCtrlSource = lclCreateOUString( pCtrlSrcName.get(), nCtrlSrcLen );
759 OSL_TRACE("*** *** *** ControlSourceName -> %s ", rtl::OUStringToOString( rec.sCtrlSource, RTL_TEXTENCODING_UTF8 ).getStr() );
761 // row source name
762 sal_uInt32 nRowSrcBufSize = lclGetBufferSize( nRowSrcLen );
763 if( nRowSrcBufSize > 0 )
765 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
766 std::auto_ptr< sal_Char > pRowSrcName;
767 pRowSrcName.reset( new sal_Char[ nRowSrcBufSize ] );
768 pS->Read( pRowSrcName.get(), nRowSrcBufSize );
769 rec.sRowSource = lclCreateOUString( pRowSrcName.get(), nRowSrcLen );
770 OSL_TRACE("*** *** *** RowSourceName -> %s ", rtl::OUStringToOString( rec.sRowSource, RTL_TEXTENCODING_UTF8 ).getStr() );
773 // seek to end of data
774 pS->Seek( nStartPos + nSize );
776 rec.cName = lclCreateOUString(pName, nNameLen);
777 delete[] pName;
779 OCX_Control* pControl = NULL;
780 if( pContainerControl->createFromContainerRecord( rec, pControl ) &&
781 pControl )
783 // propagate doc shell from parent
784 pControl->pDocSh = pContainerControl->pDocSh;
785 pContainerControl->ProcessControl( pControl, pS, rec );
787 else if ( rec.nTypeIdent & 0x8000 )
789 // Skip ActiveX Controls we can't import
790 SotStorageStreamRef oStream = pContainerControl->getContainedControlsStream();
791 ULONG nStrmPos = oStream->Tell();
792 oStream->Seek( nStrmPos + rec.nSubStreamLen );
794 else
796 DBG_ERROR("Terminating import, unexpected error");
797 return false;
800 return true;
803 protected:
804 ContainerRecReader() : isMultiPage(false){}
805 bool isMultiPage;
806 sal_uInt32 nNoRecords;
807 sal_uInt32 nTotalLen;
809 private:
810 bool handleStandardHdr( SvStorageStream* pS )
812 sal_uInt8 aUnknown11[4];
813 pS->Read(aUnknown11, sizeof(aUnknown11));
814 // discovered a dialog with value of 0xFF for aUnknown11
815 // needed an extra 4 bytes to offset correctly into the control
816 // records. Valid test or coincidence ?
817 if ( aUnknown11[1] == 0xFF )
818 pS->Read( aUnknown11, sizeof(aUnknown11));
819 return true;
822 bool handleMultiPageHdr( SvStorageStream* pS )
824 sal_uInt32 nUnknown_32b; // unknown 32 bit structure, flags ?
825 sal_uInt16 nUnknown_16b; // unknown 16 bit structure
826 sal_uInt16 nMysteryLen; // lenght of unknown sub record
828 *pS >> nUnknown_32b;
829 *pS >> nUnknown_16b;
830 *pS >> nMysteryLen;
832 pS->SeekRel( nMysteryLen );
833 return true;
835 ContainerRecordList records;
838 class StdContainerRecReader : public ContainerRecReader
840 public:
841 StdContainerRecReader(){}
844 class MultiPageContainerRecReader : public ContainerRecReader
846 public:
847 MultiPageContainerRecReader()
849 // NP ( 27-01-05 )
850 // Strictly speaking this approach shouldn't be necessary.
851 // It should be possible to have a common routine read the
852 // container record array and by examining the flags present in
853 // the record to determine we expect to read or not.
854 // In this case for a MultPage control there is no Top or Left
855 // values in the control record array, however time contraints
856 // and associated risk prevent further investigation of this
857 // at the moment.
858 // similar situation exists for the start of the container record
859 // which in the case of the MultiPage is different from
860 // UserForm & Frame ( the other containers )
862 isMultiPage = true; // tell the base class skip
866 class ContainerRecordReaderFac
868 public:
869 static ContainerRecReader* instance( sal_uInt32 containerType )
871 switch( containerType )
873 case PAGE:
874 case FRAME:
875 case USERFORM:
876 case STDCONTAINER:
877 return new StdContainerRecReader();
878 case MULTIPAGE:
879 return new MultiPageContainerRecReader();
880 default:
881 DBG_ERROR("Illegal container type for factory");
882 return NULL;
885 private:
886 ContainerRecordReaderFac();
889 } // namespace
891 // ============================================================================
893 class OCX_UserFormLabel : public OCX_Label
895 public:
896 OCX_UserFormLabel(OCX_Control* pParent ) : OCX_Label( pParent )
898 mnForeColor = 0x80000012L;
899 mnBackColor = 0x8000000FL;
904 sal_uInt16 OCX_Control::nStandardId(0x0200);
905 sal_uInt16 OCX_FontData::nStandardId(0x0200);
907 sal_uInt32 OCX_Control::pColor[25] = {
908 0xC0C0C0, 0x008080, 0x000080, 0x808080, 0xC0C0C0, 0xFFFFFF, 0x000000,
909 0x000000, 0x000000, 0xFFFFFF, 0xC0C0C0, 0xC0C0C0, 0x808080, 0x000080,
910 0xFFFFFF, 0xC0C0C0, 0x808080, 0x808080, 0x000000, 0xC0C0C0, 0xFFFFFF,
911 0x000000, 0xC0C0C0, 0x000000, 0xFFFFC0 };
913 void OCX_Control::FillSystemColors()
915 // overwrite the predefined colors with available system colors
916 const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
918 pColor[ 0x00 ] = rSett.GetFaceColor().GetColor();
919 pColor[ 0x01 ] = rSett.GetWorkspaceColor().GetColor();
920 pColor[ 0x02 ] = rSett.GetActiveColor().GetColor();
921 pColor[ 0x03 ] = rSett.GetDeactiveColor().GetColor();
922 pColor[ 0x04 ] = rSett.GetMenuBarColor().GetColor();
923 pColor[ 0x05 ] = rSett.GetWindowColor().GetColor();
924 pColor[ 0x07 ] = rSett.GetMenuTextColor().GetColor();
925 pColor[ 0x08 ] = rSett.GetWindowTextColor().GetColor();
926 pColor[ 0x09 ] = rSett.GetActiveTextColor().GetColor();
927 pColor[ 0x0A ] = rSett.GetActiveBorderColor().GetColor();
928 pColor[ 0x0B ] = rSett.GetDeactiveBorderColor().GetColor();
929 pColor[ 0x0C ] = rSett.GetWorkspaceColor().GetColor();
930 pColor[ 0x0D ] = rSett.GetHighlightColor().GetColor();
931 pColor[ 0x0E ] = rSett.GetHighlightTextColor().GetColor();
932 pColor[ 0x0F ] = rSett.GetFaceColor().GetColor();
933 pColor[ 0x10 ] = rSett.GetShadowColor().GetColor();
934 pColor[ 0x12 ] = rSett.GetButtonTextColor().GetColor();
935 pColor[ 0x13 ] = rSett.GetDeactiveTextColor().GetColor();
936 pColor[ 0x14 ] = rSett.GetHighlightColor().GetColor();
937 pColor[ 0x15 ] = rSett.GetDarkShadowColor().GetColor();
938 pColor[ 0x16 ] = rSett.GetShadowColor().GetColor();
939 pColor[ 0x17 ] = rSett.GetHelpTextColor().GetColor();
940 pColor[ 0x18 ] = rSett.GetHelpColor().GetColor();
943 sal_uInt32 OCX_Control::ImportColor(sal_uInt32 nColor) const
945 sal_uInt8 nUpper = (sal_uInt8)( nColor >> 24 );
946 if (nUpper & 0x80) //Palette color, should be switch on bottom 24 bits
948 /*Might as well use my systems ones in the absence of any other ideas*/
949 nColor = nColor&0x00FFFFFF;
950 DBG_ASSERT (nColor <= 24,"Unknown Palette Index");
951 if (nColor > 24)
952 nColor = 0xFFFFFF;
953 else
954 nColor = pColor[nColor];
956 else
958 //Stored in bgr! rather than rgb
959 nColor = SwapColor(nColor);
961 return nColor;
964 sal_Int16 OCX_FontData::ImportAlign(sal_uInt8 _nJustification) const
966 sal_Int16 nRet;
967 switch (_nJustification)
969 default:
970 case 1:
971 nRet = 0;
972 break;
973 case 2:
974 nRet = 2;
975 break;
976 case 3:
977 nRet = 1;
978 break;
980 return nRet;
983 sal_uInt8 OCX_FontData::ExportAlign(sal_Int16 nAlign) const
985 sal_Int8 nRet;
986 switch (nAlign)
988 default:
989 case 0:
990 nRet = 1;
991 break;
992 case 2:
993 nRet = 2;
994 break;
995 case 1:
996 nRet = 3;
997 break;
999 return nRet;
1002 sal_uInt32 OCX_Control::SwapColor(sal_uInt32 nColor) const
1004 sal_uInt8
1005 r(static_cast<sal_uInt8>(nColor&0xFF)),
1006 g(static_cast<sal_uInt8>(((nColor)>>8)&0xFF)),
1007 b(static_cast<sal_uInt8>((nColor>>16)&0xFF));
1008 nColor = (r<<16) + (g<<8) + b;
1009 return nColor;
1012 sal_uInt32 OCX_Control::ExportColor(sal_uInt32 nColor) const
1014 sal_uInt8 nUpper = (sal_uInt8)( nColor >> 24 );
1015 if (nUpper & 0x80) //Palette color, should be switch on bottom 24 bits
1017 /*Might as well use my systems ones in the absence of any other ideas*/
1018 nColor = nColor&0x00FFFFFF;
1019 DBG_ASSERT (nColor <= 24,"Unknown Palette Index");
1020 if (nColor > 24)
1021 nColor = 0xFFFFFF;
1022 else
1023 nColor = pColor[nColor];
1026 //Stored in bgr! rather than rgb
1027 nColor = SwapColor(nColor);
1028 return nColor;
1031 sal_Bool OCX_Control::Import(
1032 const uno::Reference< lang::XMultiServiceFactory > &rServiceFactory,
1033 uno::Reference< form::XFormComponent > &rFComp, awt::Size &rSz)
1036 if(msFormType.getLength() == 0)
1037 return sal_False;
1039 rSz.Width = nWidth;
1040 rSz.Height = nHeight;
1042 uno::Reference<uno::XInterface> xCreate =
1043 rServiceFactory->createInstance(msFormType);
1044 if (!xCreate.is())
1045 return sal_False;
1047 rFComp = uno::Reference<form::XFormComponent>(xCreate,uno::UNO_QUERY);
1048 if (!rFComp.is())
1049 return sal_False;
1050 uno::Reference<beans::XPropertySet> xPropSet(xCreate,uno::UNO_QUERY);
1051 if (!xPropSet.is())
1052 return sal_False;
1053 return Import(xPropSet);
1056 sal_Bool OCX_Control::Import(uno::Reference<container::XNameContainer> &rDialog
1059 uno::Reference<beans::XPropertySet > xDlgProps( rDialog, uno::UNO_QUERY);
1062 uno::Reference<lang::XMultiServiceFactory>
1063 xFactory(rDialog, uno::UNO_QUERY);
1065 uno::Reference<uno::XInterface> xCreate =
1066 xFactory->createInstance(msDialogType);
1067 if (!xCreate.is())
1068 return sal_False;
1070 uno::Reference<awt::XControlModel> xModel(xCreate, uno::UNO_QUERY);
1071 if (!xModel.is())
1072 return sal_False;
1074 sal_Bool bVBA = sal_False;
1075 /* #147900# sometimes insertion of a control fails due to existing name,
1076 do not break entire form import then... */
1079 rDialog->insertByName(sName, uno::makeAny(xModel));
1080 if ( xDlgProps.is() )
1081 xDlgProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("VBAForm") ) ) >>= bVBA;
1084 catch( uno::Exception& )
1086 DBG_ERRORFILE(
1087 ByteString( "OCX_Control::Import - cannot insert control \"" ).
1088 Append( ByteString( sName, RTL_TEXTENCODING_UTF8 ) ).
1089 Append( '"' ).GetBuffer() );
1092 uno::Reference<beans::XPropertySet> xPropSet(xCreate, uno::UNO_QUERY);
1093 if (!xPropSet.is())
1094 return sal_False;
1096 if (!Import(xPropSet))
1097 return sal_False;
1099 uno::Any aTmp;
1100 sal_Int32 nFactor = 3528;
1102 if ( !bVBA )
1104 aTmp <<= sal_Int32((mnLeft * 2) / 100);
1105 xPropSet->setPropertyValue(WW8_ASCII2STR("PositionX"), aTmp);
1106 aTmp <<= sal_Int32((mnTop * 2) / 100);
1107 xPropSet->setPropertyValue(WW8_ASCII2STR("PositionY"), aTmp);
1108 aTmp <<= sal_Int32((nWidth * 2) / 100);
1109 xPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
1110 aTmp <<= sal_Int32((nHeight * 2) / 100);
1111 xPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
1113 else
1115 aTmp <<= sal_Int32(mnLeft); // 100thmm
1116 xPropSet->setPropertyValue(WW8_ASCII2STR("PositionX"), aTmp);
1117 aTmp <<= sal_Int32(mnTop); //100th mm
1118 xPropSet->setPropertyValue(WW8_ASCII2STR("PositionY"), aTmp);
1119 aTmp <<= sal_Int32(nWidth); // 100thmm
1120 xPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
1121 aTmp <<= sal_Int32(nHeight); //100th mm
1122 xPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
1124 if ( msToolTip.Len() > 0 )
1126 uno::Any aTmp(&msToolTip,getCppuType((OUString *)0));
1127 xPropSet->setPropertyValue(WW8_ASCII2STR("HelpText"), aTmp);
1130 if ( mnStep )
1132 aTmp <<= mnStep;
1133 xPropSet->setPropertyValue(WW8_ASCII2STR("Step"), aTmp);
1138 xPropSet->setPropertyValue(WW8_ASCII2STR("EnableVisible"), uno::makeAny( mbVisible ) );
1140 catch( uno::Exception& )
1143 return sal_True;
1146 sal_Int16 OCX_Control::ImportBorder(sal_uInt16 nSpecialEffect,
1147 sal_uInt16 nBorderStyle) const
1149 if ((nSpecialEffect == 0) && (nBorderStyle == 0))
1150 return 0; //No Border
1151 else if ((nSpecialEffect == 0) && (nBorderStyle == 1))
1152 return 2; //Flat Border
1153 return 1; //3D Border
1156 sal_uInt8 OCX_Control::ExportBorder(sal_uInt16 nBorder,sal_uInt8 &rBorderStyle)
1157 const
1159 sal_uInt8 nRet;
1160 switch(nBorder)
1162 case 0:
1163 nRet = rBorderStyle = 0;
1164 break;
1165 default:
1166 case 1:
1167 nRet = 2;
1168 rBorderStyle = 0;
1169 break;
1170 case 2:
1171 nRet = 0;
1172 rBorderStyle = 1;
1173 break;
1175 return nRet;
1178 sal_Int16 OCX_Control::ImportSpecEffect( sal_uInt8 nSpecialEffect ) const
1180 return (nSpecialEffect == 0) ? 2 : 1;
1183 sal_uInt8 OCX_Control::ExportSpecEffect( sal_Int16 nApiEffect ) const
1185 return (nApiEffect == 2) ? 0 : 2;
1188 sal_Bool OCX_Control::ReadFontData(SvStorageStream *pS)
1190 return aFontData.Read(pS);
1194 const uno::Reference< drawing::XDrawPage >&
1195 SvxMSConvertOCXControls::GetDrawPage()
1197 if( !xDrawPage.is() && pDocSh )
1199 uno::Reference< drawing::XDrawPageSupplier > xTxtDoc(pDocSh->GetModel(),
1200 uno::UNO_QUERY);
1201 DBG_ASSERT(xTxtDoc.is(),"XDrawPageSupplier nicht vom XModel erhalten");
1202 xDrawPage = xTxtDoc->getDrawPage();
1203 DBG_ASSERT( xDrawPage.is(), "XDrawPage nicht erhalten" );
1206 return xDrawPage;
1210 const uno::Reference< lang::XMultiServiceFactory >&
1211 SvxMSConvertOCXControls::GetServiceFactory()
1213 if( !xServiceFactory.is() && pDocSh )
1215 xServiceFactory = uno::Reference< lang::XMultiServiceFactory >
1216 (pDocSh->GetBaseModel(), uno::UNO_QUERY);
1217 DBG_ASSERT( xServiceFactory.is(),
1218 "XMultiServiceFactory nicht vom Model erhalten" );
1221 return xServiceFactory;
1224 const uno::Reference< drawing::XShapes >& SvxMSConvertOCXControls::GetShapes()
1226 if( !xShapes.is() )
1228 GetDrawPage();
1229 if( xDrawPage.is() )
1232 xShapes = uno::Reference< drawing::XShapes >(xDrawPage,
1233 uno::UNO_QUERY);
1234 DBG_ASSERT( xShapes.is(), "XShapes nicht vom XDrawPage erhalten" );
1237 return xShapes;
1240 const uno::Reference< container::XIndexContainer >&
1241 SvxMSConvertOCXControls::GetFormComps()
1243 if( !xFormComps.is() )
1245 GetDrawPage();
1246 if( xDrawPage.is() )
1248 uno::Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage,
1249 uno::UNO_QUERY );
1250 DBG_ASSERT( xFormsSupplier.is(),
1251 "XFormsSupplier nicht vom XDrawPage erhalten" );
1253 uno::Reference< container::XNameContainer > xNameCont =
1254 xFormsSupplier->getForms();
1256 // Das Formular bekommt einen Namen wie "WW-Standard[n]" und
1257 // wird in jedem Fall neu angelegt.
1258 UniString sName( sWW8_form, RTL_TEXTENCODING_MS_1252 );
1259 sal_uInt16 n = 0;
1261 while( xNameCont->hasByName( sName ) )
1263 sName.AssignAscii( sWW8_form );
1264 sName += String::CreateFromInt32( ++n );
1267 const uno::Reference< lang::XMultiServiceFactory > &rServiceFactory
1268 = GetServiceFactory();
1269 if( !rServiceFactory.is() )
1270 return xFormComps;
1272 uno::Reference< uno::XInterface > xCreate =
1273 rServiceFactory->createInstance(WW8_ASCII2STR(
1274 "com.sun.star.form.component.Form"));
1275 if( xCreate.is() )
1277 uno::Reference< beans::XPropertySet > xFormPropSet( xCreate,
1278 uno::UNO_QUERY );
1280 uno::Any aTmp(&sName,getCppuType((OUString *)0));
1281 xFormPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
1283 uno::Reference< form::XForm > xForm( xCreate, uno::UNO_QUERY );
1284 DBG_ASSERT(xForm.is(), "keine Form?");
1286 uno::Reference< container::XIndexContainer > xForms( xNameCont,
1287 uno::UNO_QUERY );
1288 DBG_ASSERT( xForms.is(), "XForms nicht erhalten" );
1290 aTmp.setValue( &xForm,
1291 ::getCppuType((uno::Reference < form::XForm >*)0));
1292 xForms->insertByIndex( xForms->getCount(), aTmp );
1294 xFormComps = uno::Reference< container::XIndexContainer >
1295 (xCreate, uno::UNO_QUERY);
1300 return xFormComps;
1303 sal_Bool OCX_CommandButton::Import( com::sun::star::uno::Reference<
1304 com::sun::star::beans::XPropertySet> &rPropSet)
1306 uno::Any aTmp(&sName,getCppuType((OUString *)0));
1307 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
1309 aTmp <<= ImportColor(mnForeColor);
1310 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
1312 // fake transparent push button by setting window background color
1313 if( !fBackStyle )
1314 mnBackColor = 0x80000005;
1315 aTmp <<= ImportColor(mnBackColor);
1316 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
1318 sal_Bool bTemp;
1319 if ((!(fEnabled)) || (fLocked))
1320 bTemp = sal_False;
1321 else
1322 bTemp = sal_True;
1323 aTmp = bool2any(bTemp);
1325 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
1327 bTemp = fWordWrap != 0;
1328 aTmp = bool2any(bTemp);
1329 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
1331 if (pCaption)
1333 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
1334 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
1337 aTmp = bool2any( mbTakeFocus );
1338 rPropSet->setPropertyValue( WW8_ASCII2STR( "FocusOnClick" ), aTmp );
1340 aFontData.Import(rPropSet);
1342 if ( sImageUrl.getLength() )
1344 aTmp <<= sImageUrl;
1345 rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
1347 return sal_True;
1350 sal_Bool OCX_GroupBox::Export(SvStorageRef& /* rObj */,
1351 const uno::Reference< beans::XPropertySet >& /* rPropSet */,
1352 const awt::Size& /* rSize */ )
1354 sal_Bool bRet=sal_True;
1355 return bRet;
1358 sal_Bool OCX_GroupBox::WriteContents(SvStorageStreamRef& /* rObj */,
1359 const uno::Reference< beans::XPropertySet >& /* rPropSet */,
1360 const awt::Size& /* rSize */)
1362 sal_Bool bRet=sal_True;
1363 return bRet;
1366 sal_Bool OCX_CommandButton::WriteContents(SvStorageStreamRef& rContents,
1367 const uno::Reference< beans::XPropertySet >& rPropSet,
1368 const awt::Size& rSize )
1370 sal_Bool bRet=sal_True;
1372 sal_uInt32 nOldPos = rContents->Tell();
1373 rContents->SeekRel(8);
1375 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
1376 if (aTmp.hasValue())
1377 aTmp >>= mnForeColor;
1378 *rContents << ExportColor(mnForeColor);
1380 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1381 if (aTmp.hasValue())
1382 aTmp >>= mnBackColor;
1383 *rContents << ExportColor(mnBackColor);
1385 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
1386 fEnabled = any2bool(aTmp);
1387 sal_uInt8 nTemp=0;//fEnabled;
1388 if (fEnabled)
1389 nTemp |= 0x02;
1390 if (fBackStyle)
1391 nTemp |= 0x08;
1392 *rContents << nTemp;
1393 *rContents << sal_uInt8(0x00);
1395 nTemp = 0;
1396 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
1397 fWordWrap = any2bool(aTmp);
1398 if (fWordWrap)
1399 nTemp |= 0x80;
1400 *rContents << nTemp;
1401 *rContents << sal_uInt8(0x00);
1403 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
1404 aCaption.WriteLenField( *rContents );
1405 aCaption.WriteCharArray( *rContents );
1407 WriteAlign(rContents,4);
1409 *rContents << rSize.Width;
1410 *rContents << rSize.Height;
1412 // "take focus on click" is directly in content flags, not in option field...
1413 mbTakeFocus = any2bool( rPropSet->getPropertyValue( WW8_ASCII2STR( "FocusOnClick" ) ) );
1415 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
1417 bRet = aFontData.Export(rContents,rPropSet);
1419 rContents->Seek(nOldPos);
1420 *rContents << nStandardId;
1421 *rContents << nFixedAreaLen;
1423 sal_uInt8 nTmp = 0x27;
1424 if (aCaption.HasData())
1425 nTmp |= 0x08;
1426 *rContents << nTmp;
1427 nTmp = 0x00;
1428 if( !mbTakeFocus ) // flag is set, if option is off
1429 nTmp |= 0x02;
1430 *rContents << nTmp;
1431 *rContents << sal_uInt8(0x00);
1432 *rContents << sal_uInt8(0x00);
1434 DBG_ASSERT((rContents.Is() && (SVSTREAM_OK==rContents->GetError())),"damn");
1435 return bRet;
1440 sal_Bool OCX_CommandButton::Export(SvStorageRef &rObj,
1441 const uno::Reference< beans::XPropertySet > &rPropSet,
1442 const awt::Size &rSize)
1444 static sal_uInt8 __READONLY_DATA aCompObj[] = {
1445 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1446 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1447 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1448 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1449 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1450 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1451 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1452 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1453 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1454 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1455 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1456 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1457 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1458 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1459 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1460 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1464 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
1465 xStor->Write(aCompObj,sizeof(aCompObj));
1466 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
1470 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
1471 xStor3->Write(aObjInfo,sizeof(aObjInfo));
1472 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
1475 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
1476 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x6D, 0x00,
1477 0x61, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x42, 0x00,
1478 0x75, 0x00, 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00,
1479 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1483 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
1484 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
1485 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
1488 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
1490 return WriteContents(xContents,rPropSet,rSize);
1493 sal_Bool OCX_ImageButton::WriteContents(SvStorageStreamRef &rContents,
1494 const uno::Reference< beans::XPropertySet > &rPropSet,
1495 const awt::Size &rSize)
1497 sal_Bool bRet=sal_True;
1499 sal_uInt32 nOldPos = rContents->Tell();
1500 rContents->SeekRel(8);
1502 uno::Any aTmp=rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1503 if (aTmp.hasValue())
1504 aTmp >>= mnBackColor;
1505 *rContents << ExportColor(mnBackColor);
1507 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
1508 fEnabled = any2bool(aTmp);
1509 sal_uInt8 nTemp=0;//fEnabled;
1510 if (fEnabled)
1511 nTemp |= 0x02;
1512 *rContents << nTemp;
1513 *rContents << sal_uInt8(0x00);
1514 *rContents << sal_uInt8(0x00);
1515 *rContents << sal_uInt8(0x00);
1517 WriteAlign(rContents,4);
1519 *rContents << rSize.Width;
1520 *rContents << rSize.Height;
1522 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
1524 bRet = aFontData.Export(rContents,rPropSet);
1526 rContents->Seek(nOldPos);
1527 *rContents << nStandardId;
1528 *rContents << nFixedAreaLen;
1530 sal_uInt8 nTmp = 0x26;
1531 *rContents << nTmp;
1532 *rContents << sal_uInt8(0x00);
1533 *rContents << sal_uInt8(0x00);
1534 *rContents << sal_uInt8(0x00);
1536 DBG_ASSERT((rContents.Is() && (SVSTREAM_OK==rContents->GetError())),"damn");
1537 return bRet;
1542 sal_Bool OCX_ImageButton::Export(SvStorageRef &rObj,
1543 const uno::Reference< beans::XPropertySet > &rPropSet,
1544 const awt::Size &rSize)
1546 static sal_uInt8 __READONLY_DATA aCompObj[] = {
1547 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1548 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1549 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1550 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1551 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1552 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1553 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1554 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1555 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1556 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1557 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1558 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1559 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1560 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1561 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1562 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1566 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
1567 xStor->Write(aCompObj,sizeof(aCompObj));
1568 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
1572 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
1573 xStor3->Write(aObjInfo,sizeof(aObjInfo));
1574 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
1577 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
1578 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x6D, 0x00,
1579 0x61, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x42, 0x00,
1580 0x75, 0x00, 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00,
1581 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1585 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
1586 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
1587 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
1590 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
1591 return WriteContents(xContents,rPropSet,rSize);
1594 bool lcl_isNamedRange( const rtl::OUString& sAddress, uno::Reference< frame::XModel >& xModel, table::CellRangeAddress& aAddress )
1596 bool bRes = false;
1597 const static rtl::OUString sNamedRanges( RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
1598 uno::Reference< sheet::XCellRangeReferrer > xReferrer;
1601 uno::Reference< beans::XPropertySet > xPropSet( xModel, uno::UNO_QUERY_THROW );
1602 uno::Reference< container::XNameAccess > xNamed( xPropSet->getPropertyValue( sNamedRanges ), uno::UNO_QUERY_THROW );
1603 xReferrer.set ( xNamed->getByName( sAddress ), uno::UNO_QUERY );
1605 catch( uno::Exception& /*e*/ )
1607 // do nothing
1609 if ( xReferrer.is() )
1611 uno::Reference< sheet::XCellRangeAddressable > xRangeAddressable( xReferrer->getReferredCells(), uno::UNO_QUERY );
1612 if ( xRangeAddressable.is() )
1614 aAddress = xRangeAddressable->getRangeAddress();
1615 bRes = true;
1618 return bRes;
1621 void lcl_ApplyListSourceAndBindableStuff( uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& rPropSet, const rtl::OUString& rsCtrlSource, const rtl::OUString& rsRowSource )
1623 // XBindable etc.
1624 uno::Reference< lang::XMultiServiceFactory > xFac;
1625 if ( xModel.is() )
1626 xFac.set( xModel, uno::UNO_QUERY );
1627 uno::Reference< form::binding::XBindableValue > xBindable( rPropSet, uno::UNO_QUERY );
1628 if ( xFac.is() && rsCtrlSource.getLength() && xBindable.is() )
1631 // OOo address structures
1632 // RefCell - convert from XL
1633 // pretend we converted the imported string address into the
1634 // appropriate address structure
1635 uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( C2U( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY );
1636 table::CellAddress aAddress;
1637 if ( xConvertor.is() )
1639 // we need this service to properly convert XL notation also
1640 // Should be easy to extend
1641 xConvertor->setPropertyValue( C2U( "XL_A1_Representation" ), uno::makeAny( rsCtrlSource ) );
1642 xConvertor->getPropertyValue( C2U( "Address" ) ) >>= aAddress;
1645 beans::NamedValue aArg1;
1646 aArg1.Name = C2U("BoundCell");
1647 aArg1.Value <<= aAddress;
1649 uno::Sequence< uno::Any > aArgs(1);
1650 aArgs[ 0 ] <<= aArg1;
1652 uno::Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( C2U("com.sun.star.table.CellValueBinding" ), aArgs ), uno::UNO_QUERY );
1653 xBindable->setValueBinding( xBinding );
1655 uno::Reference< form::binding::XListEntrySink > xListEntrySink( rPropSet, uno::UNO_QUERY );
1656 if ( xFac.is() && rsRowSource.getLength() && xListEntrySink.is() )
1659 // OOo address structures
1660 // RefCell - convert from XL
1661 // pretend we converted the imported string address into the
1662 // appropriate address structure
1663 uno::Reference< beans::XPropertySet > xConvertor( xFac->createInstance( C2U( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY );
1664 table::CellRangeAddress aAddress;
1665 if ( xConvertor.is() )
1667 if ( !lcl_isNamedRange( rsRowSource, xModel, aAddress ) )
1669 // we need this service to properly convert XL notation also
1670 // Should be easy to extend
1671 xConvertor->setPropertyValue( C2U( "XL_A1_Representation" ), uno::makeAny( rsRowSource ) );
1672 xConvertor->getPropertyValue( C2U( "Address" ) ) >>= aAddress;
1676 beans::NamedValue aArg1;
1677 aArg1.Name = C2U("CellRange");
1678 aArg1.Value <<= aAddress;
1680 uno::Sequence< uno::Any > aArgs(1);
1681 aArgs[ 0 ] <<= aArg1;
1683 uno::Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( C2U("com.sun.star.table.CellRangeListSource" ), aArgs ), uno::UNO_QUERY );
1684 xListEntrySink->setListEntrySource( xSource );
1688 sal_Bool OCX_OptionButton::Import(com::sun::star::uno::Reference<
1689 com::sun::star::beans::XPropertySet> &rPropSet)
1691 uno::Any aTmp(&sName,getCppuType((OUString *)0));
1692 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
1694 // background color: fBackStyle==0 -> transparent
1695 if( fBackStyle )
1696 aTmp <<= ImportColor(mnBackColor);
1697 else
1698 aTmp = uno::Any();
1699 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
1701 sal_Bool bTemp;
1702 if ((!(fEnabled)) || (fLocked))
1703 bTemp = sal_False;
1704 else
1705 bTemp = sal_True;
1706 aTmp = bool2any(bTemp);
1707 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
1709 bTemp = fWordWrap != 0;
1710 aTmp = bool2any(bTemp);
1711 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
1713 aTmp <<= ImportColor(mnForeColor);
1714 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
1716 aTmp <<= ImportSpecEffect( nSpecialEffect );
1717 rPropSet->setPropertyValue( WW8_ASCII2STR("VisualEffect"), aTmp);
1719 if (pValue)
1721 INT16 nTmp = pValue[0]-0x30;
1722 aTmp <<= nTmp;
1723 if (!bSetInDialog)
1724 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
1725 else
1727 // dialog ( but we might be using the form model )
1728 if ( rPropSet->getPropertySetInfo()->hasPropertyByName( WW8_ASCII2STR("DefaultState") ) )
1729 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
1730 else
1731 rPropSet->setPropertyValue( WW8_ASCII2STR("State"), aTmp);
1734 // If this is a dialog control then we need to set a groupname *always*
1735 rtl::OUString sGroupName = lclCreateOUString( pGroupName, nGroupNameLen );
1736 if ( GetInDialog() ) // Userform/Dialog
1738 // By default groupnames are not set in Excel, it's not unusual to have
1739 // a number of groups of radiobuttons located inside frame ( or other container
1740 // controls ) where there is *no* specific groupname set for the radiobuttons.
1741 // But... there is implicit grouping for radio buttons in seperate containers
1742 // e.g. radio buttons in a frame are by default in the same group.
1743 // Unfortunately in openoffice there are no containers below the dialog itself :-(
1744 // To ensure correct grouping for imported radiobuttons either with no groupname
1745 // or identical groupnames that are in separate containers we *must* ensure
1746 // that a suitable groupname is applied.
1747 // Because controlNames are unique even across different containers we can use the
1748 // controls container (e.g. parent) name as a prefix for a group name
1749 rtl::OUString sParentName = msParentName;
1750 sGroupName = sParentName.concat( C2U( ":" ) ).concat( sGroupName );
1752 if ( sGroupName.getLength() == 0 )
1753 sGroupName = rtl::OUString::createFromAscii("DefaultGroup");
1754 OSL_TRACE("RadioButton %s has groupname %s",
1755 rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sGroupName, RTL_TEXTENCODING_UTF8 ).getStr() );
1758 aTmp <<= sGroupName;
1759 rPropSet->setPropertyValue( WW8_ASCII2STR("GroupName"), aTmp);
1761 catch( uno::Exception& )
1765 if (pCaption)
1767 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
1768 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
1771 // #i40279# always centered vertically
1772 aTmp <<= ::com::sun::star::style::VerticalAlignment_MIDDLE;
1773 rPropSet->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp );
1775 uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
1776 lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
1777 if ( sImageUrl.getLength() )
1779 aTmp <<= sImageUrl;
1780 rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
1783 aFontData.Import(rPropSet);
1784 return sal_True;
1787 sal_Bool OCX_OptionButton::WriteContents(SvStorageStreamRef &rContents,
1788 const uno::Reference< beans::XPropertySet > &rPropSet,
1789 const awt::Size &rSize)
1791 sal_Bool bRet=sal_True;
1793 sal_uInt32 nOldPos = rContents->Tell();
1794 rContents->SeekRel(12);
1796 pBlockFlags[0] = 0;
1797 pBlockFlags[1] = 0x01;
1798 pBlockFlags[2] = 0;
1799 pBlockFlags[3] = 0x80;
1800 pBlockFlags[4] = 0;
1801 pBlockFlags[5] = 0;
1802 pBlockFlags[6] = 0;
1803 pBlockFlags[7] = 0;
1805 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
1806 fEnabled = any2bool(aTmp);
1808 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1809 if (aTmp.hasValue())
1810 aTmp >>= mnBackColor;
1811 else
1812 fBackStyle = 0;
1814 sal_uInt8 nTemp=0;//=fEnabled;
1815 if (fEnabled)
1816 nTemp |= 0x02;
1817 if (fBackStyle)
1818 nTemp |= 0x08;
1819 *rContents << nTemp;
1820 pBlockFlags[0] |= 0x01;
1821 *rContents << sal_uInt8(0x00);
1822 nTemp = 0;
1823 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
1824 fWordWrap = any2bool(aTmp);
1825 if (fWordWrap)
1826 nTemp |= 0x80;
1827 *rContents << nTemp;
1828 *rContents << sal_uInt8(0x00);
1830 *rContents << ExportColor(mnBackColor);
1831 pBlockFlags[0] |= 0x02;
1833 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
1834 if (aTmp.hasValue())
1835 aTmp >>= mnForeColor;
1836 *rContents << ExportColor(mnForeColor);
1837 pBlockFlags[0] |= 0x04;
1839 nStyle = 5;
1840 *rContents << nStyle;
1841 pBlockFlags[0] |= 0x40;
1843 WriteAlign(rContents,4);
1844 nValueLen = 1|SVX_MSOCX_COMPRESSED;
1845 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultState"));
1846 sal_Int16 nDefault = sal_Int16();
1847 aTmp >>= nDefault;
1848 *rContents << nValueLen;
1849 pBlockFlags[2] |= 0x40;
1852 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
1853 if (aCaption.HasData())
1854 pBlockFlags[2] |= 0x80;
1855 aCaption.WriteLenField( *rContents );
1857 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("VisualEffect"));
1858 if (aTmp.hasValue())
1860 sal_Int16 nApiSpecEffect = sal_Int16();
1861 aTmp >>= nApiSpecEffect;
1862 nSpecialEffect = ExportSpecEffect( nApiSpecEffect );
1864 *rContents << nSpecialEffect;
1865 pBlockFlags[3] |= 0x04;
1867 WriteAlign(rContents,4);
1868 *rContents << rSize.Width;
1869 *rContents << rSize.Height;
1871 nDefault += 0x30;
1872 *rContents << sal_uInt8(nDefault);
1873 *rContents << sal_uInt8(0x00);
1875 aCaption.WriteCharArray( *rContents );
1877 WriteAlign(rContents,4);
1878 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
1879 bRet = aFontData.Export(rContents,rPropSet);
1881 rContents->Seek(nOldPos);
1882 *rContents << nStandardId;
1883 *rContents << nFixedAreaLen;
1885 *rContents << pBlockFlags[0];
1886 *rContents << pBlockFlags[1];
1887 *rContents << pBlockFlags[2];
1888 *rContents << pBlockFlags[3];
1889 *rContents << pBlockFlags[4];
1890 *rContents << pBlockFlags[5];
1891 *rContents << pBlockFlags[6];
1892 *rContents << pBlockFlags[7];
1894 DBG_ASSERT((rContents.Is() &&
1895 (SVSTREAM_OK==rContents->GetError())),"damn");
1896 return bRet;
1901 sal_Bool OCX_OptionButton::Export(SvStorageRef &rObj,
1902 const uno::Reference< beans::XPropertySet > &rPropSet,
1903 const awt::Size &rSize)
1905 static sal_uInt8 __READONLY_DATA aCompObj[] = {
1906 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1907 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1908 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1909 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1910 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1911 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1912 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1913 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1914 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1915 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1916 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1917 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1918 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1919 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1920 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1921 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1925 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
1926 xStor->Write(aCompObj,sizeof(aCompObj));
1927 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
1931 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
1932 xStor3->Write(aObjInfo,sizeof(aObjInfo));
1933 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
1936 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
1937 0x4F, 0x00, 0x70, 0x00, 0x74, 0x00, 0x69, 0x00,
1938 0x6F, 0x00, 0x6E, 0x00, 0x42, 0x00, 0x75, 0x00,
1939 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x6E, 0x00,
1940 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1944 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
1945 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
1946 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
1949 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
1950 return WriteContents(xContents, rPropSet, rSize);
1954 sal_Bool OCX_TextBox::Import(com::sun::star::uno::Reference<
1955 com::sun::star::beans::XPropertySet> &rPropSet)
1957 uno::Any aTmp(&sName,getCppuType((OUString *)0));
1958 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
1960 aTmp = bool2any( fEnabled != 0 );
1961 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
1963 aTmp = bool2any( fLocked != 0 );
1964 rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
1966 aTmp = bool2any( fHideSelection != 0 );
1967 rPropSet->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp);
1969 aTmp <<= ImportColor(mnForeColor);
1970 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
1972 aTmp <<= ImportColor(mnBackColor);
1973 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
1975 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
1976 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
1978 aTmp <<= ImportColor( nBorderColor );
1979 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
1981 aTmp = bool2any( fMultiLine != 0 );
1982 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
1984 sal_uInt16 nTmp = static_cast<sal_uInt16>(nMaxLength);
1985 aTmp <<= nTmp;
1986 rPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);
1989 sal_Bool bTemp1,bTemp2;
1990 uno::Any aBarsH,aBarsV;
1991 switch(nScrollBars)
1993 case 1:
1994 bTemp1 = sal_True;
1995 bTemp2 = sal_False;
1996 break;
1997 case 2:
1998 bTemp1 = sal_False;
1999 bTemp2 = sal_True;
2000 break;
2001 case 3:
2002 bTemp1 = sal_True;
2003 bTemp2 = sal_True;
2004 break;
2005 case 0:
2006 default:
2007 bTemp1 = sal_False;
2008 bTemp2 = sal_False;
2009 break;
2012 aBarsH = bool2any(bTemp1);
2013 aBarsV = bool2any(bTemp2);
2014 rPropSet->setPropertyValue( WW8_ASCII2STR("HScroll"), aBarsH);
2015 rPropSet->setPropertyValue( WW8_ASCII2STR("VScroll"), aBarsV);
2017 nTmp = nPasswordChar;
2018 aTmp <<= nTmp;
2019 rPropSet->setPropertyValue( WW8_ASCII2STR("EchoChar"), aTmp);
2021 if (pValue)
2023 aTmp <<= lclCreateOUString( pValue, nValueLen );
2024 // DefaultText seems to no longer be in UnoEditControlModel
2025 if ( bSetInDialog )
2027 rPropSet->setPropertyValue( WW8_ASCII2STR("Text"), aTmp);
2029 else
2031 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
2035 aFontData.Import(rPropSet);
2036 return sal_True;
2039 sal_Bool OCX_TextBox::WriteContents(SvStorageStreamRef &rContents,
2040 const uno::Reference< beans::XPropertySet > &rPropSet,
2041 const awt::Size &rSize)
2043 sal_Bool bRet=sal_True;
2044 sal_uInt32 nOldPos = rContents->Tell();
2045 rContents->SeekRel(12);
2047 pBlockFlags[0] = 0;
2048 pBlockFlags[1] = 0x01;
2049 pBlockFlags[2] = 0x00;
2050 pBlockFlags[3] = 0x80;
2051 pBlockFlags[4] = 0;
2052 pBlockFlags[5] = 0;
2053 pBlockFlags[6] = 0;
2054 pBlockFlags[7] = 0;
2057 sal_uInt8 nTemp=0x19;
2058 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2059 fEnabled = any2bool(aTmp);
2060 if (fEnabled)
2061 nTemp |= 0x02;
2063 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2064 fLocked = any2bool(aTmp);
2065 if (fLocked)
2066 nTemp |= 0x04;
2068 *rContents << nTemp;
2069 pBlockFlags[0] |= 0x01;
2070 *rContents << sal_uInt8(0x48);
2071 *rContents << sal_uInt8(0x80);
2073 fMultiLine = any2bool(rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine")));
2074 fHideSelection = any2bool(rPropSet->getPropertyValue(WW8_ASCII2STR("HideInactiveSelection")));
2075 nTemp = 0x0C;
2076 if (fMultiLine)
2077 nTemp |= 0x80;
2078 if( fHideSelection )
2079 nTemp |= 0x20;
2080 *rContents << nTemp;
2082 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2083 if (aTmp.hasValue())
2084 aTmp >>= mnBackColor;
2085 *rContents << ExportColor(mnBackColor);
2086 pBlockFlags[0] |= 0x02;
2088 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2089 if (aTmp.hasValue())
2090 aTmp >>= mnForeColor;
2091 *rContents << ExportColor(mnForeColor);
2092 pBlockFlags[0] |= 0x04;
2094 aTmp = rPropSet->getPropertyValue( WW8_ASCII2STR("MaxTextLen"));
2095 aTmp >>= nMaxLength;
2096 *rContents << nMaxLength;
2097 pBlockFlags[0] |= 0x08;
2099 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
2100 sal_Int16 nBorder = sal_Int16();
2101 aTmp >>= nBorder;
2102 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
2103 *rContents << nBorderStyle;
2104 pBlockFlags[0] |= 0x10;
2106 aTmp = rPropSet->getPropertyValue( WW8_ASCII2STR("HScroll"));
2107 sal_Bool bTemp1 = any2bool(aTmp);
2108 aTmp = rPropSet->getPropertyValue( WW8_ASCII2STR("VScroll"));
2109 sal_Bool bTemp2 = any2bool(aTmp);
2110 if (!bTemp1 && !bTemp2)
2111 nScrollBars =0;
2112 else if (bTemp1 && bTemp2)
2113 nScrollBars = 3;
2114 else if (!bTemp1 && bTemp2)
2115 nScrollBars = 2;
2116 else
2117 nScrollBars = 1;
2118 *rContents << nScrollBars;
2119 pBlockFlags[0] |= 0x20;
2121 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("EchoChar"));
2122 sal_uInt16 nTmp = sal_uInt16();
2123 aTmp >>= nTmp;
2124 nPasswordChar = static_cast<sal_uInt8>(nTmp);
2125 *rContents << nPasswordChar;
2126 pBlockFlags[1] |= 0x02;
2128 SvxOcxString aValue( rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2129 aValue.WriteLenField( *rContents );
2130 if (aValue.HasData())
2131 pBlockFlags[2] |= 0x40;
2133 WriteAlign(rContents,4);
2134 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2135 if (aTmp.hasValue())
2136 aTmp >>= nBorderColor;
2137 *rContents << ExportColor(nBorderColor);
2138 pBlockFlags[3] |= 0x02;
2140 *rContents << nSpecialEffect;
2141 pBlockFlags[3] |= 0x04;
2143 WriteAlign(rContents,4);
2144 *rContents << rSize.Width;
2145 *rContents << rSize.Height;
2147 aValue.WriteCharArray( *rContents );
2149 WriteAlign(rContents,4);
2151 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2153 bRet = aFontData.Export(rContents,rPropSet);
2155 rContents->Seek(nOldPos);
2156 *rContents << nStandardId;
2157 *rContents << nFixedAreaLen;
2159 *rContents << pBlockFlags[0];
2160 *rContents << pBlockFlags[1];
2161 *rContents << pBlockFlags[2];
2162 *rContents << pBlockFlags[3];
2163 *rContents << pBlockFlags[4];
2164 *rContents << pBlockFlags[5];
2165 *rContents << pBlockFlags[6];
2166 *rContents << pBlockFlags[7];
2168 DBG_ASSERT((rContents.Is() &&
2169 (SVSTREAM_OK == rContents->GetError())),"damn");
2170 return bRet;
2174 sal_Bool OCX_TextBox::Export(SvStorageRef &rObj,
2175 const uno::Reference< beans::XPropertySet > &rPropSet,
2176 const awt::Size &rSize)
2178 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2179 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2180 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
2181 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2182 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
2183 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2184 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2185 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
2186 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
2187 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
2188 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
2189 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
2190 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
2191 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
2192 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2193 0x00, 0x00, 0x00, 0x00
2197 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2198 xStor->Write(aCompObj,sizeof(aCompObj));
2199 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2203 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2204 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2205 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2208 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2209 0x54, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00,
2210 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
2211 0x00, 0x00, 0x00, 0x00
2215 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2216 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2217 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2220 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2221 return WriteContents(xContents, rPropSet, rSize);
2224 sal_Bool OCX_FieldControl::WriteContents(SvStorageStreamRef &rContents,
2225 const uno::Reference< beans::XPropertySet > &rPropSet,
2226 const awt::Size &rSize)
2228 sal_Bool bRet=sal_True;
2229 sal_uInt32 nOldPos = rContents->Tell();
2230 rContents->SeekRel(12);
2232 pBlockFlags[0] = 0;
2233 pBlockFlags[1] = 0x01;
2234 pBlockFlags[2] = 0x00;
2235 pBlockFlags[3] = 0x80;
2236 pBlockFlags[4] = 0;
2237 pBlockFlags[5] = 0;
2238 pBlockFlags[6] = 0;
2239 pBlockFlags[7] = 0;
2242 sal_uInt8 nTemp=0x19;
2243 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2244 fEnabled = any2bool(aTmp);
2245 if (fEnabled)
2246 nTemp |= 0x02;
2248 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2249 fLocked = any2bool(aTmp);
2250 if (fLocked)
2251 nTemp |= 0x04;
2253 *rContents << nTemp;
2254 pBlockFlags[0] |= 0x01;
2255 *rContents << sal_uInt8(0x48);
2256 *rContents << sal_uInt8(0x80);
2258 nTemp = 0x2C;
2259 *rContents << nTemp;
2261 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2262 if (aTmp.hasValue())
2263 aTmp >>= mnBackColor;
2264 *rContents << ExportColor(mnBackColor);
2265 pBlockFlags[0] |= 0x02;
2267 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2268 if (aTmp.hasValue())
2269 aTmp >>= mnForeColor;
2270 *rContents << ExportColor(mnForeColor);
2271 pBlockFlags[0] |= 0x04;
2273 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
2274 sal_Int16 nBorder = sal_Int16();
2275 aTmp >>= nBorder;
2276 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
2277 *rContents << nBorderStyle;
2278 pBlockFlags[0] |= 0x10;
2280 #if 0 //Each control has a different Value format, and how to convert each to text has to be found out
2281 SvxOcxString aValue( rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2282 aValue.WriteLenField( *rContents );
2283 if (aValue.HasData())
2284 pBlockFlags[2] |= 0x40;
2285 #endif
2287 *rContents << nSpecialEffect;
2288 pBlockFlags[3] |= 0x04;
2290 WriteAlign(rContents,4);
2291 *rContents << rSize.Width;
2292 *rContents << rSize.Height;
2294 #if 0
2295 aValue.WriteCharArray( *rContents );
2296 #endif
2298 WriteAlign(rContents,4);
2300 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2302 bRet = aFontData.Export(rContents,rPropSet);
2304 rContents->Seek(nOldPos);
2305 *rContents << nStandardId;
2306 *rContents << nFixedAreaLen;
2308 *rContents << pBlockFlags[0];
2309 *rContents << pBlockFlags[1];
2310 *rContents << pBlockFlags[2];
2311 *rContents << pBlockFlags[3];
2312 *rContents << pBlockFlags[4];
2313 *rContents << pBlockFlags[5];
2314 *rContents << pBlockFlags[6];
2315 *rContents << pBlockFlags[7];
2317 DBG_ASSERT((rContents.Is() &&
2318 (SVSTREAM_OK==rContents->GetError())),"damn");
2319 return bRet;
2322 sal_Bool OCX_FieldControl::Export(SvStorageRef &rObj,
2323 const uno::Reference< beans::XPropertySet > &rPropSet,
2324 const awt::Size &rSize)
2326 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2327 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2328 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
2329 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2330 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
2331 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2332 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2333 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
2334 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
2335 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
2336 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
2337 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
2338 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
2339 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
2340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2341 0x00, 0x00, 0x00, 0x00
2345 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2346 xStor->Write(aCompObj,sizeof(aCompObj));
2347 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2351 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2352 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2353 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2356 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2357 0x54, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00,
2358 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
2359 0x00, 0x00, 0x00, 0x00
2363 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2364 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2365 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2368 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2369 return WriteContents(xContents, rPropSet, rSize);
2374 sal_Bool OCX_ToggleButton::Import(com::sun::star::uno::Reference<
2375 com::sun::star::beans::XPropertySet> &rPropSet)
2377 uno::Any aTmp(&sName,getCppuType((OUString *)0));
2378 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
2380 aTmp = bool2any(true);
2381 rPropSet->setPropertyValue( WW8_ASCII2STR("Toggle"), aTmp );
2383 sal_Bool bTemp;
2384 if ((!(fEnabled)) || (fLocked))
2385 bTemp = sal_False;
2386 else
2387 bTemp = sal_True;
2388 aTmp = bool2any(bTemp);
2389 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
2391 bTemp = fWordWrap != 0;
2392 aTmp = bool2any(bTemp);
2393 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
2395 aTmp <<= ImportColor(mnForeColor);
2396 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
2398 // fake transparent toggle button by setting window background color
2399 if( !fBackStyle )
2400 mnBackColor = 0x80000005;
2401 aTmp <<= ImportColor(mnBackColor);
2402 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
2404 if (pValue)
2406 INT16 nTmp=pValue[0]-0x30;
2407 aTmp <<= nTmp;
2408 rPropSet->setPropertyValue( WW8_ASCII2STR("State"), aTmp);
2411 if (pCaption)
2413 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
2414 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
2417 aFontData.Import(rPropSet);
2419 if ( sImageUrl.getLength() )
2421 aTmp <<= sImageUrl;
2422 rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
2424 return sal_True;
2427 sal_Bool OCX_ToggleButton::Export(
2428 SvStorageRef &rObj, const uno::Reference< beans::XPropertySet> &rPropSet,
2429 const awt::Size& rSize )
2431 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2432 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2433 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
2434 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2435 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
2436 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2437 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2438 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
2439 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
2440 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
2441 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
2442 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
2443 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
2444 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
2445 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2446 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2447 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2451 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2452 xStor->Write(aCompObj,sizeof(aCompObj));
2453 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2457 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2458 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2459 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2462 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2463 0x54, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x67, 0x00,
2464 0x6C, 0x00, 0x65, 0x00, 0x42, 0x00, 0x75, 0x00,
2465 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x6E, 0x00,
2466 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
2470 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2471 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2472 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2475 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2477 return WriteContents(xContents,rPropSet,rSize);
2480 sal_Bool OCX_ToggleButton::WriteContents(SvStorageStreamRef &rContents,
2481 const uno::Reference< beans::XPropertySet > &rPropSet,
2482 const awt::Size &rSize)
2484 sal_Bool bRet=sal_True;
2485 sal_uInt32 nOldPos = rContents->Tell();
2486 rContents->SeekRel(12);
2488 pBlockFlags[0] = 0;
2489 pBlockFlags[1] = 0x01;
2490 pBlockFlags[2] = 0;
2491 pBlockFlags[3] = 0x80;
2492 pBlockFlags[4] = 0;
2493 pBlockFlags[5] = 0;
2494 pBlockFlags[6] = 0;
2495 pBlockFlags[7] = 0;
2497 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2498 fEnabled = any2bool(aTmp);
2500 sal_uInt8 nTemp=fEnabled;
2501 if (fEnabled)
2502 nTemp = nTemp << 1;
2503 if (fBackStyle)
2504 nTemp |= 0x08;
2505 *rContents << nTemp;
2506 pBlockFlags[0] |= 0x01;
2507 *rContents << sal_uInt8(0x00);
2508 nTemp = 0;
2509 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
2510 fWordWrap = any2bool(aTmp);
2511 if (fWordWrap)
2512 nTemp |= 0x80;
2513 *rContents << nTemp;
2514 *rContents << sal_uInt8(0x00);
2516 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2517 if (aTmp.hasValue())
2518 aTmp >>= mnBackColor;
2519 *rContents << ExportColor(mnBackColor);
2520 pBlockFlags[0] |= 0x02;
2522 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2523 if (aTmp.hasValue())
2524 aTmp >>= mnForeColor;
2525 *rContents << ExportColor(mnForeColor);
2526 pBlockFlags[0] |= 0x04;
2528 nStyle = 6;
2529 *rContents << nStyle;
2530 pBlockFlags[0] |= 0x40;
2532 WriteAlign(rContents,4);
2533 nValueLen = 1|SVX_MSOCX_COMPRESSED;
2534 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("State"));
2535 sal_Int16 nDefault = sal_Int16();
2536 aTmp >>= nDefault;
2537 *rContents << nValueLen;
2538 pBlockFlags[2] |= 0x40;
2540 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
2541 aCaption.WriteLenField( *rContents );
2542 if (aCaption.HasData())
2543 pBlockFlags[2] |= 0x80;
2545 WriteAlign(rContents,4);
2546 *rContents << rSize.Width;
2547 *rContents << rSize.Height;
2549 nDefault += 0x30;
2550 *rContents << sal_uInt8(nDefault);
2551 *rContents << sal_uInt8(0x00);
2553 aCaption.WriteCharArray( *rContents );
2555 WriteAlign(rContents,4);
2556 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2557 bRet = aFontData.Export(rContents,rPropSet);
2558 rContents->Seek(nOldPos);
2559 *rContents << nStandardId;
2560 *rContents << nFixedAreaLen;
2562 *rContents << pBlockFlags[0];
2563 *rContents << pBlockFlags[1];
2564 *rContents << pBlockFlags[2];
2565 *rContents << pBlockFlags[3];
2566 *rContents << pBlockFlags[4];
2567 *rContents << pBlockFlags[5];
2568 *rContents << pBlockFlags[6];
2569 *rContents << pBlockFlags[7];
2571 DBG_ASSERT((rContents.Is() &&
2572 (SVSTREAM_OK==rContents->GetError())),"damn");
2573 return bRet;
2576 sal_Bool OCX_Label::Import(uno::Reference< beans::XPropertySet > &rPropSet)
2578 uno::Any aTmp(&sName,getCppuType((OUString *)0));
2579 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
2581 sal_Bool bTemp;
2582 if ((!(fEnabled)) || (fLocked))
2583 bTemp = sal_False;
2584 else
2585 bTemp = sal_True;
2586 aTmp = bool2any(bTemp);
2587 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
2589 aTmp <<= ImportColor(mnForeColor);
2590 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
2592 // background color: fBackStyle==0 -> transparent
2593 if( fBackStyle )
2595 aTmp <<= ImportColor(mnBackColor);
2597 else
2599 // try fake transparent by using parents backColor
2600 if ( bSetInDialog && mpParent != NULL )
2602 aTmp <<= ImportColor( mpParent->mnBackColor );
2604 else
2606 aTmp = uno::Any(); // use SO default
2609 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
2611 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
2612 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
2614 aTmp <<= ImportColor( nBorderColor );
2615 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
2617 bTemp=fWordWrap;
2618 aTmp = bool2any(bTemp);
2619 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
2621 if (pCaption)
2623 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
2624 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
2627 aFontData.Import(rPropSet);
2628 return sal_True;
2631 sal_Bool OCX_ComboBox::Import(com::sun::star::uno::Reference<
2632 com::sun::star::beans::XPropertySet> &rPropSet)
2635 uno::Any aTmp(&sName,getCppuType((OUString *)0));
2636 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
2638 aTmp = bool2any(fEnabled != 0);
2639 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
2641 aTmp = bool2any(fLocked != 0);
2642 rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
2644 aTmp = bool2any( nDropButtonStyle != 0 );
2645 rPropSet->setPropertyValue( WW8_ASCII2STR("Dropdown"), aTmp);
2647 aTmp = bool2any( fHideSelection != 0 );
2648 rPropSet->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp);
2650 aTmp <<= ImportColor(mnForeColor);
2651 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
2653 if (pValue)
2655 aTmp <<= lclCreateOUString( pValue, nValueLen );
2656 if ( bSetInDialog )
2658 rPropSet->setPropertyValue( WW8_ASCII2STR("Text"), aTmp);
2660 else
2662 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
2666 aTmp <<= ImportColor(mnBackColor);
2667 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
2669 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
2670 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
2672 aTmp <<= ImportColor( nBorderColor );
2673 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
2675 sal_Int16 nTmp=static_cast<sal_Int16>(nMaxLength);
2676 aTmp <<= nTmp;
2677 rPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);
2679 aFontData.Import(rPropSet);
2680 uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
2681 lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
2682 return sal_True;
2685 sal_Bool OCX_ComboBox::WriteContents(SvStorageStreamRef &rContents,
2686 const uno::Reference< beans::XPropertySet > &rPropSet,
2687 const awt::Size &rSize)
2689 sal_Bool bRet=sal_True;
2690 sal_uInt32 nOldPos = rContents->Tell();
2691 rContents->SeekRel(12);
2693 pBlockFlags[0] = 0;
2694 pBlockFlags[1] = 0x01;
2695 pBlockFlags[2] = 0x00;
2696 pBlockFlags[3] = 0x80;
2697 pBlockFlags[4] = 0;
2698 pBlockFlags[5] = 0;
2699 pBlockFlags[6] = 0;
2700 pBlockFlags[7] = 0;
2703 sal_uInt8 nTemp=0x19;//fEnabled;
2704 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2705 fEnabled = any2bool(aTmp);
2706 if (fEnabled)
2707 nTemp |= 0x02;
2709 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2710 fLocked = any2bool(aTmp);
2711 if (fLocked)
2712 nTemp |= 0x04;
2714 *rContents << nTemp;
2715 pBlockFlags[0] |= 0x01;
2716 *rContents << sal_uInt8(0x48);
2717 *rContents << sal_uInt8(0x80);
2719 nTemp = 0x0C;
2720 fHideSelection = any2bool(rPropSet->getPropertyValue(WW8_ASCII2STR("HideInactiveSelection")));
2721 if( fHideSelection )
2722 nTemp |= 0x20;
2723 *rContents << nTemp;
2725 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2726 if (aTmp.hasValue())
2727 aTmp >>= mnBackColor;
2728 *rContents << ExportColor(mnBackColor);
2729 pBlockFlags[0] |= 0x02;
2731 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2732 if (aTmp.hasValue())
2733 aTmp >>= mnForeColor;
2734 *rContents << ExportColor(mnForeColor);
2735 pBlockFlags[0] |= 0x04;
2737 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
2738 sal_Int16 nBorder = sal_Int16();
2739 aTmp >>= nBorder;
2740 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
2741 *rContents << nBorderStyle;
2742 pBlockFlags[0] |= 0x10;
2744 nStyle = 3;
2745 *rContents << nStyle;
2746 pBlockFlags[0] |= 0x40;
2748 WriteAlign(rContents,2);
2750 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("LineCount"));
2751 aTmp >>= nListRows;
2752 *rContents << nListRows;
2753 pBlockFlags[1] |= 0x40;
2755 *rContents << sal_uInt8(1); //DefaultSelected One
2756 pBlockFlags[2] |= 0x01;
2758 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Dropdown"));
2759 nDropButtonStyle = any2bool(aTmp);
2760 if (nDropButtonStyle)
2761 nDropButtonStyle=0x02;
2762 *rContents << nDropButtonStyle;
2763 pBlockFlags[2] |= 0x04;
2765 SvxOcxString aValue( rPropSet->getPropertyValue(WW8_ASCII2STR("Text")) );
2766 aValue.WriteLenField( *rContents );
2767 if (aValue.HasData())
2768 pBlockFlags[2] |= 0x40;
2770 WriteAlign(rContents,4);
2771 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2772 if (aTmp.hasValue())
2773 aTmp >>= nBorderColor;
2774 *rContents << ExportColor(nBorderColor);
2775 pBlockFlags[3] |= 0x02;
2777 *rContents << nSpecialEffect;
2778 pBlockFlags[3] |= 0x04;
2780 WriteAlign(rContents,4);
2781 *rContents << rSize.Width;
2782 *rContents << rSize.Height;
2784 aValue.WriteCharArray( *rContents );
2786 WriteAlign(rContents,4);
2788 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2790 bRet = aFontData.Export(rContents,rPropSet);
2792 rContents->Seek(nOldPos);
2793 *rContents << nStandardId;
2794 *rContents << nFixedAreaLen;
2796 *rContents << pBlockFlags[0];
2797 *rContents << pBlockFlags[1];
2798 *rContents << pBlockFlags[2];
2799 *rContents << pBlockFlags[3];
2800 *rContents << pBlockFlags[4];
2801 *rContents << pBlockFlags[5];
2802 *rContents << pBlockFlags[6];
2803 *rContents << pBlockFlags[7];
2805 DBG_ASSERT((rContents.Is() &&
2806 (SVSTREAM_OK==rContents->GetError())),"damn");
2807 return bRet;
2811 sal_Bool OCX_ComboBox::Export(SvStorageRef &rObj,
2812 const uno::Reference< beans::XPropertySet > &rPropSet,
2813 const awt::Size &rSize)
2815 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2816 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2817 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2818 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2819 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2820 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2821 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2822 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2823 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2824 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2825 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2826 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2827 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2828 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2829 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2830 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2834 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2835 xStor->Write(aCompObj,sizeof(aCompObj));
2836 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2840 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2841 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2842 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2845 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2846 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x62, 0x00,
2847 0x6F, 0x00, 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00,
2848 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
2852 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2853 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2854 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2857 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2858 return WriteContents(xContents, rPropSet, rSize);
2863 sal_Bool OCX_ListBox::Import(com::sun::star::uno::Reference<
2864 com::sun::star::beans::XPropertySet> &rPropSet)
2867 uno::Any aTmp(&sName,getCppuType((OUString *)0));
2868 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
2870 sal_Bool bTmp=fEnabled;
2871 aTmp = bool2any(bTmp);
2872 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
2874 bTmp=fLocked;
2875 aTmp = bool2any(bTmp);
2876 rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
2878 aTmp <<= ImportColor(mnForeColor);
2879 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
2881 sal_Bool bTemp = nMultiState;
2882 aTmp = bool2any(bTemp);
2883 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiSelection"), aTmp);
2885 #if 0 //Don't delete this for now until I figure out if I can make this
2886 if (pValue)
2888 aTmp <<= lclCreateOUString( pValue, nValueLen );
2889 xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
2891 #endif
2893 aTmp <<= ImportColor(mnBackColor);
2894 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
2896 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
2897 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
2899 aTmp <<= ImportColor( nBorderColor );
2900 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
2901 uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
2902 lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
2903 aFontData.Import(rPropSet);
2904 return sal_True;
2907 sal_Bool OCX_ListBox::WriteContents(SvStorageStreamRef &rContents,
2908 const uno::Reference< beans::XPropertySet > &rPropSet,
2909 const awt::Size &rSize)
2911 sal_Bool bRet=sal_True;
2912 sal_uInt32 nOldPos = rContents->Tell();
2913 rContents->SeekRel(12);
2915 pBlockFlags[0] = 0;
2916 pBlockFlags[1] = 0x01;
2917 pBlockFlags[2] = 0x01;
2918 pBlockFlags[3] = 0x80;
2919 pBlockFlags[4] = 0;
2920 pBlockFlags[5] = 0;
2921 pBlockFlags[6] = 0;
2922 pBlockFlags[7] = 0;
2924 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2925 fEnabled = any2bool(aTmp);
2926 sal_uInt8 nTemp=fEnabled;
2927 if (fEnabled)
2928 nTemp = nTemp << 1;
2930 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2931 fLocked = any2bool(aTmp);
2932 if (fLocked)
2933 nTemp |= 0x04;
2935 *rContents << nTemp;
2936 pBlockFlags[0] |= 0x01;
2937 *rContents << sal_uInt8(0x00);
2938 *rContents << sal_uInt8(0x00);
2939 *rContents << sal_uInt8(0x00);
2941 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2942 if (aTmp.hasValue())
2943 aTmp >>= mnBackColor;
2944 *rContents << ExportColor(mnBackColor);
2945 pBlockFlags[0] |= 0x02;
2947 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2948 if (aTmp.hasValue())
2949 aTmp >>= mnForeColor;
2950 *rContents << ExportColor(mnForeColor);
2951 pBlockFlags[0] |= 0x04;
2953 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
2954 sal_Int16 nBorder = sal_Int16();
2955 aTmp >>= nBorder;
2956 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
2957 WriteAlign(rContents,2);
2958 *rContents << nBorderStyle;
2959 pBlockFlags[0] |= 0x10;
2961 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiSelection"));
2962 nMultiState = any2bool(aTmp);
2964 if (nMultiState)
2966 *rContents << nMultiState;
2967 pBlockFlags[0] |= 0x20;
2970 nStyle = 2;
2971 *rContents << nStyle;
2972 pBlockFlags[0] |= 0x40;
2975 WriteAlign(rContents,4);
2977 #if 0
2978 SvxOcxString aValue( rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2979 aValue.WriteLenField( *rContents );
2980 if (aValue.HasData())
2981 pBlockFlags[2] |= 0x40;
2983 WriteAlign(rContents,4);
2984 #endif
2986 WriteAlign(rContents,4);
2987 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2988 if (aTmp.hasValue())
2989 aTmp >>= nBorderColor;
2990 *rContents << ExportColor(nBorderColor);
2991 pBlockFlags[3] |= 0x02;
2993 *rContents << nSpecialEffect;
2994 pBlockFlags[3] |= 0x04;
2996 WriteAlign(rContents,4);
2997 *rContents << rSize.Width;
2998 *rContents << rSize.Height;
3000 #if 0
3001 aValue.WriteCharArray( *rContents );
3002 #endif
3004 WriteAlign(rContents,4);
3006 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
3008 bRet = aFontData.Export(rContents,rPropSet);
3010 rContents->Seek(nOldPos);
3011 *rContents << nStandardId;
3012 *rContents << nFixedAreaLen;
3014 *rContents << pBlockFlags[0];
3015 *rContents << pBlockFlags[1];
3016 *rContents << pBlockFlags[2];
3017 *rContents << pBlockFlags[3];
3018 *rContents << pBlockFlags[4];
3019 *rContents << pBlockFlags[5];
3020 *rContents << pBlockFlags[6];
3021 *rContents << pBlockFlags[7];
3023 DBG_ASSERT((rContents.Is() &&
3024 (SVSTREAM_OK==rContents->GetError())),"damn");
3025 return bRet;
3028 sal_Bool OCX_ListBox::Export(SvStorageRef &rObj,
3029 const uno::Reference< beans::XPropertySet > &rPropSet,
3030 const awt::Size &rSize)
3032 static sal_uInt8 __READONLY_DATA aCompObj[] = {
3033 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
3034 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
3035 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
3036 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
3037 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
3038 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
3039 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
3040 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
3041 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
3042 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
3043 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
3044 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
3045 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
3046 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3047 0x00, 0x00, 0x00, 0x00
3051 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
3052 xStor->Write(aCompObj,sizeof(aCompObj));
3053 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
3057 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
3058 xStor3->Write(aObjInfo,sizeof(aObjInfo));
3059 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
3062 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
3063 0x4C, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00,
3064 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
3065 0x00, 0x00, 0x00, 0x00
3069 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
3070 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
3071 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
3074 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
3075 return WriteContents(xContents, rPropSet, rSize);
3078 sal_Bool OCX_Control::Read(SvStorageStream *pS)
3080 sal_uInt16 nIdentifier, nFixedAreaLen;
3081 *pS >> nIdentifier;
3082 DBG_ASSERT(nStandardId==nIdentifier,
3083 "A control that has a different identifier");
3084 *pS >> nFixedAreaLen;
3085 pS->SeekRel(nFixedAreaLen);
3086 return true;
3089 sal_Bool OCX_ModernControl::Read(SvStorageStream *pS)
3091 long nStart = pS->Tell();
3092 *pS >> nIdentifier;
3093 DBG_ASSERT(nIdentifier==nStandardId,
3094 "A control that has a different identifier");
3095 *pS >> nFixedAreaLen;
3096 pS->Read(pBlockFlags,8);
3098 if (pBlockFlags[0] & 0x01)
3100 sal_uInt8 nTemp;
3101 *pS >> nTemp;
3103 fEnabled = (nTemp & 0x02) >> 1;
3104 fLocked = (nTemp & 0x04) >> 2;
3105 fBackStyle = (nTemp & 0x08) >> 3;
3107 *pS >> nTemp;
3109 fColumnHeads = (nTemp & 0x04) >> 2;
3110 fIntegralHeight = (nTemp & 0x08) >> 3;
3111 fMatchRequired = (nTemp & 0x10) >> 4;
3112 fAlignment = (nTemp & 0x20) >> 5;
3114 *pS >> nTemp;
3116 fDragBehaviour = (nTemp & 0x08) >> 3;
3117 fEnterKeyBehaviour = (nTemp & 0x10) >> 4;
3118 fEnterFieldBehaviour = (nTemp & 0x20) >> 5;
3119 fTabKeyBehaviour = (nTemp & 0x40) >> 6;
3120 fWordWrap = (nTemp & 0x80) >> 7;
3122 *pS >> nTemp;
3123 fSelectionMargin = (nTemp & 0x04) >> 2;
3124 fAutoWordSelect = (nTemp & 0x08) >> 3;
3125 fAutoSize = (nTemp & 0x10) >> 4;
3126 fHideSelection = (nTemp & 0x20) >> 5;
3127 fAutoTab = (nTemp & 0x40) >> 6;
3128 fMultiLine = (nTemp & 0x80) >> 7;
3132 /*If any of these are set they follow eachother in this order one after
3133 another padded out to the next U32 boundary with 0's
3134 U8 can abut each other U16 must start on a U16 boundary and are padded to
3135 that with 0's. A standardish word alignment structure*/
3137 if (pBlockFlags[0] & 0x02)
3138 *pS >> mnBackColor;
3139 if (pBlockFlags[0] & 0x04)
3140 *pS >> mnForeColor;
3141 if (pBlockFlags[0] & 0x08)
3142 *pS >> nMaxLength;
3144 if (pBlockFlags[0] & 0x10)
3145 *pS >> nBorderStyle;
3146 if (pBlockFlags[0] & 0x20)
3147 *pS >> nScrollBars;
3148 if (pBlockFlags[0] & 0x40)
3149 *pS >> nStyle;// (UI 0 == Data 3, UI 2 = Data 7)
3150 if (pBlockFlags[0] & 0x80)
3151 *pS >> nMousePointer;
3153 if (pBlockFlags[1] & 0x02)
3154 *pS >> nPasswordChar; //HUH ??? always 0 ??? not sure maybe just padding
3156 if (pBlockFlags[1] & 0x04)
3158 ReadAlign(pS, pS->Tell() - nStart, 4);
3159 *pS >> nListWidth;
3162 if (pBlockFlags[1] & 0x08)
3164 ReadAlign(pS, pS->Tell() - nStart, 2);
3165 *pS >> nBoundColumn;
3167 if (pBlockFlags[1] & 0x10)
3169 ReadAlign(pS, pS->Tell() - nStart, 2);
3170 *pS >> nTextColumn;
3172 if (pBlockFlags[1] & 0x20)
3174 ReadAlign(pS, pS->Tell() - nStart, 2);
3175 *pS >> nColumnCount;
3177 if (pBlockFlags[1] & 0x40)
3179 ReadAlign(pS, pS->Tell() - nStart, 2);
3180 *pS >> nListRows;
3182 if (pBlockFlags[1] & 0x80)
3184 ReadAlign(pS, pS->Tell() - nStart, 2);
3185 *pS >> nUnknown8; //something to do with ColumnWidths
3187 if (pBlockFlags[2] & 0x01)
3188 *pS >> nMatchEntry;
3189 if (pBlockFlags[2] & 0x02)
3190 *pS >> nListStyle;
3191 if (pBlockFlags[2] & 0x04)
3192 *pS >> nShowDropButtonWhen;
3193 if (pBlockFlags[2] & 0x10)
3194 *pS >> nDropButtonStyle;
3195 if (pBlockFlags[2] & 0x20)
3196 *pS >> nMultiState;
3198 bool bValue = (pBlockFlags[2] & 0x40) != 0;
3199 if (bValue)
3201 ReadAlign(pS, pS->Tell() - nStart, 4);
3202 *pS >> nValueLen;
3204 bool bCaption = (pBlockFlags[2] & 0x80) != 0;
3205 if (bCaption)
3207 ReadAlign(pS, pS->Tell() - nStart, 4);
3208 *pS >> nCaptionLen;
3210 if (pBlockFlags[3] & 0x01)
3212 ReadAlign(pS, pS->Tell() - nStart, 4);
3213 *pS >> nHorzPos;
3214 *pS >> nVertPos;
3216 if (pBlockFlags[3] & 0x02)
3218 ReadAlign(pS, pS->Tell() - nStart, 4);
3219 *pS >> nBorderColor;
3221 if (pBlockFlags[3] & 0x04)
3223 ReadAlign(pS, pS->Tell() - nStart, 4); // NEW
3224 *pS >> nSpecialEffect;
3225 pS->SeekRel( 3 ); // special effect is 32bit, not 8bit
3227 if (pBlockFlags[3] & 0x08)
3229 ReadAlign(pS, pS->Tell() - nStart, 2);
3230 *pS >> nIcon;
3231 DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
3233 if (pBlockFlags[3] & 0x10)
3235 ReadAlign(pS, pS->Tell() - nStart, 2);
3236 *pS >> nPicture;
3237 DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
3239 if (pBlockFlags[3] & 0x20)
3240 *pS >> nAccelerator;
3242 if (pBlockFlags[3] & 0x80)
3243 *pS >> nUnknown9;
3245 bool bGroupName = (pBlockFlags[4] & 0x01) != 0;
3246 if (bGroupName)
3248 ReadAlign(pS, pS->Tell() - nStart, 4);
3249 *pS >> nGroupNameLen;
3252 //End
3254 ReadAlign(pS, pS->Tell() - nStart, 4);
3255 *pS >> nWidth;
3256 *pS >> nHeight;
3258 if (bValue)
3259 lclReadCharArray( *pS, pValue, nValueLen, pS->Tell() - nStart);
3261 if (bCaption)
3262 lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
3264 if (bGroupName)
3265 lclReadCharArray( *pS, pGroupName, nGroupNameLen, pS->Tell() - nStart);
3267 ReadAlign(pS, pS->Tell() - nStart, 4);
3268 if (nIcon)
3270 pS->Read(pIconHeader,20);
3271 *pS >> nIconLen;
3272 pIcon = new sal_uInt8[nIconLen];
3273 pS->Read(pIcon,nIconLen);
3276 if (nPicture)
3278 pS->Read(pPictureHeader,20);
3279 *pS >> nPictureLen;
3280 long imagePos = pS->Tell();
3281 mxGrfObj = lcl_readGraphicObject( pS );
3282 if( mxGrfObj.is() )
3284 sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
3285 sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
3287 // make sure the stream position should be pointing after the image
3288 pS->Seek( imagePos + nPictureLen );
3291 return sal_True;
3295 sal_Bool OCX_CommandButton::Read(SvStorageStream *pS)
3297 long nStart = pS->Tell();
3298 *pS >> nIdentifier;
3299 DBG_ASSERT(nStandardId==nIdentifier,
3300 "A control that has a different identifier");
3301 *pS >> nFixedAreaLen;
3302 pS->Read(pBlockFlags,4);
3305 if (pBlockFlags[0] & 0x01)
3306 *pS >> mnForeColor;
3307 if (pBlockFlags[0] & 0x02)
3308 *pS >> mnBackColor;
3310 if (pBlockFlags[0] & 0x04)
3312 sal_uInt8 nTemp;
3313 *pS >> nTemp;
3314 fEnabled = (nTemp&0x02)>>1;
3315 fLocked = (nTemp&0x04)>>2;
3316 fBackStyle = (nTemp&0x08)>>3;
3317 *pS >> nTemp;
3318 *pS >> nTemp;
3319 fWordWrap = (nTemp&0x80)>>7;
3320 *pS >> nTemp;
3321 fAutoSize = (nTemp&0x10)>>4;
3324 bool bCaption = (pBlockFlags[0] & 0x08) != 0;
3325 if (bCaption)
3327 *pS >> nCaptionLen;
3329 if (pBlockFlags[0] & 0x10) /*Picture Position, a strange mechanism here*/
3331 *pS >> nVertPos;
3332 *pS >> nHorzPos;
3335 if (pBlockFlags[0] & 0x40) /*MousePointer*/
3336 *pS >> nMousePointer;
3338 if (pBlockFlags[0] & 0x80)
3340 ReadAlign(pS, pS->Tell() - nStart, 2);
3341 *pS >> nPicture;
3344 if (pBlockFlags[1] & 0x01)
3346 ReadAlign(pS, pS->Tell() - nStart, 2);
3347 *pS >> nAccelerator;
3350 // "take focus on click" is directly in content flags, not in option field...
3351 mbTakeFocus = (pBlockFlags[1] & 0x02) == 0; // option is on, if flag is not set
3353 if (pBlockFlags[1] & 0x04)
3355 ReadAlign(pS, pS->Tell() - nStart, 2);
3356 *pS >> nIcon;
3359 if (bCaption)
3360 lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
3362 ReadAlign(pS, pS->Tell() - nStart, 4);
3363 *pS >> nWidth;
3364 *pS >> nHeight;
3366 if (nIcon)
3368 pS->Read(pIconHeader,20);
3369 *pS >> nIconLen;
3370 pIcon = new sal_uInt8[nIconLen];
3371 pS->Read(pIcon,nIconLen);
3374 if (nPicture)
3376 pS->Read(pPictureHeader,20);
3377 *pS >> nPictureLen;
3378 long imagePos = pS->Tell();
3379 mxGrfObj = lcl_readGraphicObject( pS );
3380 if( mxGrfObj.is() )
3382 sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
3383 sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
3385 // make sure the stream position should be pointing after the image
3386 pS->Seek( imagePos + nPictureLen );
3389 return sal_True;
3392 sal_Bool OCX_Label::Read(SvStorageStream *pS)
3394 long nStart = pS->Tell();
3395 *pS >> nIdentifier;
3396 DBG_ASSERT(nStandardId==nIdentifier,
3397 "A control that has a different identifier");
3398 *pS >> nFixedAreaLen;
3399 pS->Read(pBlockFlags,4);
3402 if (pBlockFlags[0] & 0x01)
3403 *pS >> mnForeColor;
3404 if (pBlockFlags[0] & 0x02)
3405 *pS >> mnBackColor;
3408 if (pBlockFlags[0] & 0x04)
3410 sal_uInt8 nTemp;
3411 *pS >> nTemp;
3412 fEnabled = (nTemp&0x02)>>1;
3413 fLocked = (nTemp&0x04)>>2;
3414 fBackStyle = (nTemp&0x08)>>3;
3415 *pS >> nTemp;
3416 *pS >> nTemp;
3417 fWordWrap = (nTemp&0x80)>>7;
3418 *pS >> nTemp;
3419 fAutoSize = (nTemp&0x10)>>4;
3421 bool bCaption = (pBlockFlags[0] & 0x08) != 0;
3422 if (bCaption)
3423 *pS >> nCaptionLen;
3425 if (pBlockFlags[0] & 0x10)
3427 *pS >> nVertPos;
3428 *pS >> nHorzPos;
3431 if (pBlockFlags[0] & 0x40)
3432 *pS >> nMousePointer;
3434 if (pBlockFlags[0] & 0x80)
3436 ReadAlign(pS,pS->Tell() - nStart, 4);
3437 *pS >> nBorderColor;
3440 if (pBlockFlags[1] & 0x01)
3442 ReadAlign(pS, pS->Tell() - nStart, 2);
3443 *pS >> nBorderStyle;
3446 if (pBlockFlags[1] & 0x02)
3448 ReadAlign(pS, pS->Tell() - nStart, 2);
3449 *pS >> nSpecialEffect;
3452 if (pBlockFlags[1] & 0x04)
3454 ReadAlign(pS, pS->Tell() - nStart, 2);
3455 *pS >> nPicture;
3458 if (pBlockFlags[1] & 0x08)
3460 ReadAlign(pS, pS->Tell() - nStart, 2);
3461 *pS >> nAccelerator;
3464 if (pBlockFlags[1] & 0x10)
3466 ReadAlign(pS, pS->Tell() - nStart, 2);
3467 *pS >> nIcon;
3470 if (bCaption)
3471 lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
3473 ReadAlign(pS, pS->Tell() - nStart, 4);
3474 *pS >> nWidth;
3475 *pS >> nHeight;
3477 if (nPicture)
3479 pS->Read(pPictureHeader,20);
3480 *pS >> nPictureLen;
3481 pPicture = new sal_uInt8[nPictureLen];
3482 pS->Read(pPicture,nPictureLen);
3484 if (nIcon)
3486 pS->Read(pIconHeader,20);
3487 *pS >> nIconLen;
3488 pIcon = new sal_uInt8[nIconLen];
3489 pS->Read(pIcon,nIconLen);
3492 return sal_True;
3495 TypeName::TypeName(sal_Char *pName, sal_uInt32 nStoreId, sal_uInt32 nLen, sal_uInt16 nType, sal_Int32 nLeft,
3496 sal_Int32 nTop)
3497 : msName(lclCreateOUString(pName, nLen)), mnType(nType), mnLeft(nLeft),
3498 mnTop(nTop),mnStoreId(nStoreId)
3502 OCX_ContainerControl::OCX_ContainerControl( SotStorageRef& parent,
3503 const ::rtl::OUString& storageName,
3504 const ::rtl::OUString& sN,
3505 const uno::Reference< container::XNameContainer > &rParent,
3506 OCX_Control* pParent ) :
3507 OCX_Control(sN, pParent), mxParent(rParent), nNoRecords(0), nTotalLen(0), containerType( STDCONTAINER )
3510 mContainerStorage = parent->OpenSotStorage(storageName,
3511 STREAM_READWRITE |
3512 STREAM_NOCREATE |
3513 STREAM_SHARE_DENYALL);
3514 mContainerStream = mContainerStorage->OpenSotStream(
3515 String(RTL_CONSTASCII_STRINGPARAM("f"),
3516 RTL_TEXTENCODING_MS_1252),
3517 STREAM_STD_READ | STREAM_NOCREATE);
3518 mContainedControlsStream = mContainerStorage->OpenSotStream( String(RTL_CONSTASCII_STRINGPARAM("o"),
3519 RTL_TEXTENCODING_MS_1252),
3520 STREAM_STD_READ | STREAM_NOCREATE);
3522 OCX_ContainerControl::~OCX_ContainerControl()
3524 CtrlIterator aEnd = mpControls.end();
3525 for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
3527 delete *aIter;
3531 // Really import should receive the parent e.g. a Userform, Frame or Multi Page
3532 // and call import on its containees with itself ( up-called from
3533 // the base class ) but... the reality is we have no containment model
3534 // so we make sure rPropSet is always the parent Dialog
3536 sal_Bool OCX_ContainerControl::Import(uno::Reference<beans::XPropertySet>& /* rProps */ )
3538 if ( !mxParent.is() )
3540 return sal_False;
3542 CtrlIterator aEnd = mpControls.end();
3543 // int count = 0;
3544 for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
3546 if ( !(*aIter)->Import( mxParent ) )
3548 return sal_False;
3551 return sal_True;
3554 OUString OCX_ContainerControl::createSubStreamName( const sal_uInt32& subStorageId )
3556 static OUString sI = OUString::createFromAscii("i");
3557 static OUString sZero = OUString::createFromAscii( "0" );
3558 OUStringBuffer buf( 6 );
3559 buf.append( sI );
3560 // for subStorage id < 10 stream name has leading '0'
3561 // eg "i07"
3562 if ( subStorageId < 10 )
3564 buf.append( sZero );
3566 buf.append( OUString::valueOf( (sal_Int32)subStorageId ) );
3567 return buf.makeStringAndClear();
3571 bool OCX_ContainerControl::createFromContainerRecord( ContainerRecord& record, OCX_Control*& pControl )
3573 pControl = NULL;
3574 if ( record.nTypeIdent & 0x8000 )
3576 std::hash_map<sal_uInt16, sal_uInt16>::iterator it = mActiveXIDMap.find( record.nTypeIdent );
3577 if ( it == mActiveXIDMap.end() )
3578 return false;
3579 // replace the generated id with our hardcoded one
3580 record.nTypeIdent = it->second;
3582 switch ( record.nTypeIdent)
3584 case CMDBUTTON:
3585 pControl = new OCX_CommandButton;
3586 break;
3587 case LABEL:
3588 pControl = new OCX_UserFormLabel(this);
3589 break;
3590 case TEXTBOX:
3591 pControl = new OCX_TextBox;
3592 break;
3593 case LISTBOX:
3594 pControl = new OCX_ListBox;
3595 break;
3596 case COMBOBOX:
3597 pControl = new OCX_ComboBox;
3598 break;
3599 case CHECKBOX:
3600 pControl = new OCX_CheckBox;
3601 break;
3602 case OPTIONBUTTON:
3603 pControl = new OCX_OptionButton;
3604 break;
3605 case TOGGLEBUTTON:
3606 pControl = new OCX_ToggleButton;
3607 break;
3608 case IMAGE: //Image
3610 pControl = new OCX_Image;
3611 break;
3613 case PAGE: // Page
3615 OUString sMSStore = createSubStreamName( record.nSubStorageId );
3616 pControl = new OCX_Page(mContainerStorage, sMSStore,
3617 record.cName, mxParent, this);
3618 break;
3620 case MULTIPAGE: // MultiPage
3622 OUString sMSStore = createSubStreamName( record.nSubStorageId );
3623 pControl = new OCX_MultiPage( mContainerStorage, sMSStore,
3624 record.cName, mxParent, this);
3625 break;
3627 case FRAME: //Frame
3629 OUString sFrameStore = createSubStreamName( record.nSubStorageId );
3630 pControl = new OCX_Frame(mContainerStorage, sFrameStore,
3631 record.cName, mxParent, this);
3633 break;
3635 case SPINBUTTON: //SpinButton
3637 pControl = new OCX_SpinButton;
3638 break;
3640 case TABSTRIP: //TabStrip
3642 pControl = new OCX_TabStrip;
3643 break;
3645 case SCROLLBAR: //ScrollBar
3646 pControl = new OCX_ScrollBar;
3647 break;
3648 case PROGRESSBAR: //ProgressBar Active X control
3649 pControl = new OCX_ProgressBar;
3650 break;
3651 default:
3652 OSL_TRACE( "**** Unknown control 0x%x", record.nTypeIdent );
3653 DBG_ERROR( "Unknown control");
3654 return false;
3656 pControl->sName = record.cName;
3657 return true;
3661 void addSeperator( std::vector< OCX_Control* >& dest )
3663 OCX_Control* seperator = new OCX_CommandButton;
3664 seperator->SetInDialog(true);
3665 seperator->sName = C2S("GroupSeperator");
3666 dest.push_back( seperator );
3669 void addRButtons( std::vector< OCX_Control* >& src,
3670 std::vector< OCX_Control* >& dest,
3671 bool addGroupSeperator )
3673 if ( addGroupSeperator )
3675 addSeperator( dest );
3678 for ( CtrlIterator rbIter = src.begin(); rbIter != src.end(); ++rbIter )
3680 dest.push_back( *rbIter );
3684 void OCX_ContainerControl::ProcessControl(OCX_Control* pControl,SvStorageStream* /* pS */, ContainerRecord& rec )
3686 SotStorageStreamRef oStream = mContainedControlsStream;
3688 // can insert into OO Dialog (e.g is this a supported dialog control)??
3689 if ( rec.nTypeIdent == TABSTRIP )
3691 // skip the record in the stream, discard the control
3692 oStream->SeekRel( rec.nSubStreamLen );
3693 delete pControl;
3695 else
3697 // A container control needs to read the f stream in
3698 // the folder ( substorage ) associated with this control
3699 switch ( rec.nTypeIdent )
3701 case FRAME:
3702 case MULTIPAGE:
3703 case PAGE:
3705 OCX_ContainerControl* pContainer =
3706 static_cast< OCX_ContainerControl* >( pControl );
3707 oStream = pContainer->getContainerStream();
3708 break;
3710 case LISTBOX:
3711 case OPTIONBUTTON:
3712 case COMBOBOX:
3713 case SPINBUTTON:
3714 case SCROLLBAR:
3716 pControl->msCtrlSource = rec.sCtrlSource;
3717 pControl->msRowSource = rec.sRowSource;
3720 pControl->sName = rec.cName;
3721 pControl->msToolTip = rec.controlTip;
3722 // Position of controls is relative to the container
3723 pControl->mnTop = rec.nTop + mnTop;
3724 pControl->mnLeft = rec.nLeft + mnLeft;
3725 // MS tabIndex, pretty useless in OpenOffice land
3726 // as tab indexes in MS are relative to parent container.
3727 // However we need this value in order to set
3728 // OpenOffice tab indices in a sensible way to
3729 // reflect the ms tabbing from orig MS UserForm, see below
3730 pControl->mnTabPos = rec.nTabPos;
3731 pControl->SetInDialog(true);
3732 pControl->mbVisible = rec.bVisible;
3733 if ( mnStep )
3735 // If the container has a step then it should be
3736 // applied to all containees
3737 pControl->mnStep = mnStep;
3739 pControl->msParentName = sName;
3741 // #117490# DR: container records provide size of substream, use it here...
3743 // remember initial position to set correct stream position
3744 ULONG nStrmPos = oStream->Tell();
3745 // import control, may return with invalid stream position
3746 pControl->FullRead(oStream);
3747 // set stream to position behind substream of this control
3748 oStream->Seek( nStrmPos + rec.nSubStreamLen );
3750 mpControls.push_back( pControl );
3754 sal_Bool OCX_ContainerControl::Read(SvStorageStream *pS)
3757 if ( mpParent )
3759 mnBackColor = mpParent->mnBackColor;
3762 std::auto_ptr< ContainerRecReader > reader (
3763 ContainerRecordReaderFac::instance( containerType ) );
3765 reader->Read( this, pS );
3766 // Need to honour the MS Tab Indexes. However MS tab indexes are
3767 // relative to parent, this hack sorts the controls in each container
3768 // based on the ms tab indexes. When import is called we create the
3769 // controls in Open/Star office based on the order of the tab indexes,
3770 // this ensures that the default tab index created by Star/Open office
3771 // reflects the "flattened" ms tab order.
3772 ::std::sort( mpControls.begin(), mpControls.end(), SortOrderByTabPos() );
3773 return true;
3776 OCX_MultiPage::OCX_MultiPage( SotStorageRef& parent,
3777 const ::rtl::OUString& storageName,
3778 const ::rtl::OUString& sN,
3779 const uno::Reference< container::XNameContainer > &rDialog,
3780 OCX_Control* pParent):
3781 OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ), fUnknown1(0), fEnabled(1),
3782 fLocked(0), fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0),
3783 nVertPos(1), nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3784 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
3785 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
3786 bPictureTiling(FALSE), nAccelerator(0), nIcon(0), pCaption(0),
3787 nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
3788 pPicture(0)
3790 //msDialogType = C2U("NotSupported");
3791 msDialogType = C2U("com.sun.star.awt.UnoMultiPageModel");
3792 mnForeColor = 0x80000012L,
3793 mnBackColor = 0x8000000FL;
3794 bSetInDialog = true;// UserForm control only
3795 aFontData.SetHasAlign(TRUE);
3796 containerType = MULTIPAGE;
3797 mnCurrentPageStep = 0;
3800 void OCX_MultiPage::ProcessControl(OCX_Control* pControl, SvStorageStream* /* pS */, ContainerRecord& rec )
3802 SotStorageStreamRef oStream = mContainedControlsStream;
3804 OCX_Page *pPage = NULL;
3805 if ( rec.nTypeIdent == PAGE )
3806 pPage = static_cast< OCX_Page* >( pControl );
3807 if ( pPage != NULL )
3809 pPage->mnStep = ++mnCurrentPageStep;
3811 pPage->mnTop = mnTop;// move these to Page::import ?
3812 pPage->mnLeft = mnLeft;
3813 pPage->mnBackColor = mnBackColor;
3815 oStream = pPage->getContainerStream();;
3816 // Position of controls is relative to pos of this MuliPage
3817 // Control
3818 pPage->FullRead( oStream );
3820 mpControls.push_back( pPage );
3822 else
3824 OSL_TRACE("!!!! Unsupported Control 0x%x ", rec.nTypeIdent);
3825 DBG_ERROR("MultiPage error expected Page control");
3830 sal_Bool OCX_MultiPage::Read(SvStorageStream *pS)
3832 // Unlike the other containers e.g. UserForm & Frame
3833 // the o stream is does not contain info for the contained controls
3834 // ( e.g. the pages themselves ) but seems to be for the MultiPage
3835 // itself - need to check this in more detail
3837 // For the moment skip read of the MultiPage specific properties
3838 // not much point reading these as we can't display the multi page
3839 // control or in fact any sort of tabbed layout, best we can do is
3840 // import just the contained controls of the individual pages
3841 // Note: the record skipped below ( does not contain the expected
3842 // info on this control, that seems to be contained in the o stream,
3843 // see comment above)
3844 OCX_Control skip(C2S("Dummy"));
3845 skip.Read( pS );
3846 mnCurrentPageStep = mnStep; //( set step of of pages relative to step
3847 //of this MultiPage ( e.g. emulate containment )
3848 return OCX_ContainerControl::Read(pS);
3852 sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
3853 com::sun::star::beans::XPropertySet> &rPropSet)
3855 OCX_ContainerControl::Import( rPropSet );
3856 return sal_True;
3859 sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
3860 com::sun::star::container::XNameContainer>
3861 &rDialog)
3863 uno::Reference<beans::XPropertySet> xPropSet( rDialog, uno::UNO_QUERY );
3865 // Although MultiPage is not represeted by a "real" control we still
3866 // need to propagate the backcolor of this logical parent
3867 // ( the dialog or Frame or whatever ) to the children of this control.
3868 // For example the controls contained in the Page of a
3869 // MultiPage control use the parents backcolor ( e,g,
3870 // Pages backcolor ) when trying to fake transparency
3871 mnBackColor = mpParent->mnBackColor;
3873 if ( xPropSet.is() )
3875 uno::Reference<lang::XMultiServiceFactory>
3876 xFactory(rDialog, uno::UNO_QUERY);
3877 OSL_TRACE("** MultiPage creating control %s", rtl::OUStringToOString( msDialogType, RTL_TEXTENCODING_UTF8 ).getStr() );
3878 uno::Reference<uno::XInterface> xCreate = xFactory->createInstance(msDialogType);
3879 if (!xCreate.is())
3880 return sal_False;
3882 uno::Reference<awt::XControlModel> xModel(xCreate, uno::UNO_QUERY);
3883 if (!xModel.is())
3884 return sal_False;
3888 // we should just call MultiPage::Import( XPropertySet )
3889 OSL_TRACE("********* MULTIPAGE cName %s", rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
3890 uno::Any aTmp(&sName,getCppuType((OUString *)0));
3891 uno::Reference<beans::XPropertySet> xPrps(xModel, uno::UNO_QUERY);
3892 xPrps->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
3893 aTmp = uno::makeAny( mnCurrentPageStep );
3894 xPrps->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp );
3895 // default current page to 0 ( #FIXME, we need to read this value )
3896 aTmp = uno::makeAny( sal_Int32(0) );
3897 xPrps->setPropertyValue( WW8_ASCII2STR("ProgressValue"), aTmp );
3898 OSL_TRACE("********* MULTIPAGE vomitted out properties");
3900 // Calls import on contained controls
3901 rDialog->insertByName(sName, uno::makeAny(xModel));
3902 OSL_TRACE("*** inserted ***");
3904 catch( uno::Exception& )
3906 DBG_ERRORFILE(
3907 ByteString( "OCX_Control::Import - cannot insert control \"" ).
3908 Append( ByteString( sName, RTL_TEXTENCODING_UTF8 ) ).
3909 Append( '"' ).GetBuffer() );
3912 // Calls import on contained pages
3913 return OCX_ContainerControl::Import( xPropSet );
3915 OSL_TRACE("*** Major problem, no dialog to add controls to ");
3916 DBG_ERROR(" Major problem, no dialog to add controls to ");
3917 return false;
3922 OCX_Page::OCX_Page( SotStorageRef& parent,
3923 const ::rtl::OUString& storageName,
3924 const ::rtl::OUString& sN,
3925 const uno::Reference< container::XNameContainer > &rDialog,
3926 OCX_Control* pParent):
3927 OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ),
3928 fUnknown1(0), fEnabled(1), fLocked(0),
3929 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
3930 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3931 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
3932 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
3933 bPictureTiling(FALSE), nAccelerator(0), nIcon(0), pCaption(0),
3934 nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
3935 pPicture(0)
3937 msDialogType = C2U("NotSupported");
3938 mnForeColor = 0x80000012,
3939 mnBackColor = 0x8000000F,
3940 bSetInDialog = true;// UserForm control only
3941 aFontData.SetHasAlign(TRUE);
3945 sal_Bool OCX_Page::Read(SvStorageStream *pS)
3947 long nStart = pS->Tell();
3948 *pS >> nIdentifier;
3949 DBG_ASSERT(0x400==nIdentifier,
3950 "A control that has a different identifier");
3951 *pS >> nFixedAreaLen;
3952 pS->Read(pBlockFlags,4);
3954 pS->SeekRel( nFixedAreaLen - sizeof( pBlockFlags ) );
3956 ReadAlign( pS, pS->Tell() - nStart, 4);
3958 if (pBlockFlags[2] & 0x10)
3960 //Font Stuff..
3961 pS->SeekRel(0x1a);
3962 sal_uInt8 nFontLen;
3963 *pS >> nFontLen;
3964 pS->SeekRel(nFontLen);
3966 return OCX_ContainerControl::Read(pS);
3970 sal_Bool OCX_Page::Import(com::sun::star::uno::Reference<
3971 com::sun::star::container::XNameContainer>
3972 &rDialog)
3975 uno::Reference<beans::XPropertySet> xPropSet( rDialog, uno::UNO_QUERY );
3976 if ( xPropSet.is() )
3978 // apply Step to contained controls
3979 CtrlIterator aEnd = mpControls.end();
3980 for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
3982 (*aIter)->mnStep = mnStep;
3984 // Calls import on contained pages
3985 return OCX_ContainerControl::Import( xPropSet );
3987 OSL_TRACE("*** Major problem, no dialog to add controls to ");
3988 DBG_ERROR("*** Major problem, no dialog to add controls to ");
3989 return sal_False;
3992 OCX_Frame::OCX_Frame( SotStorageRef& parent,
3993 const ::rtl::OUString& storageName,
3994 const ::rtl::OUString& sN,
3995 const uno::Reference< container::XNameContainer > &rDialog, OCX_Control* pParent):
3996 OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ),fUnknown1(0),fEnabled(1), fLocked(0),
3997 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
3998 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3999 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
4000 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
4001 bPictureTiling(FALSE), nAccelerator(0), nIcon(0), pCaption(0),
4002 nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0),
4003 pPicture(0)
4005 msDialogType = C2U("com.sun.star.awt.UnoControlGroupBoxModel");
4006 mnForeColor = 0x80000012;
4007 mnBackColor = 0x8000000F;
4008 bSetInDialog = true;// UserForm control only
4009 aFontData.SetHasAlign(TRUE);
4013 sal_Bool OCX_Frame::Read(SvStorageStream *pS)
4015 long nStart = pS->Tell();
4016 *pS >> nIdentifier;
4017 DBG_ASSERT(0x400==nIdentifier,
4018 "A control that has a different identifier");
4019 *pS >> nFixedAreaLen;
4020 pS->Read(pBlockFlags,4);
4022 if (pBlockFlags[0] & 0x01)
4024 DBG_ASSERT(!this, "ARSE");
4026 if (pBlockFlags[0] & 0x02)
4027 *pS >> mnBackColor;
4028 if (pBlockFlags[0] & 0x04)
4029 *pS >> mnForeColor;
4030 if (pBlockFlags[0] & 0x08)
4031 *pS >> fUnknown1;
4032 if (pBlockFlags[0] & 0x40)
4034 sal_uInt8 nTemp;
4035 *pS >> nTemp;
4036 fEnabled = (nTemp&0x04)>>2;
4037 fBackStyle = (nTemp&0x08)>>3;
4038 *pS >> nTemp;
4039 *pS >> nTemp;
4040 fWordWrap = (nTemp&0x80)>>7;
4041 *pS >> nTemp;
4042 fAutoSize = (nTemp&0x10)>>4;
4044 if (pBlockFlags[0] & 0x80)
4046 *pS >> nBorderStyle;
4049 ReadAlign(pS, pS->Tell() - nStart, 4);
4051 if (pBlockFlags[1] & 0x01)
4052 *pS >> nMousePointer;
4053 if (pBlockFlags[1] & 0x02)
4054 *pS >> nKeepScrollBarsVisible;
4055 if (pBlockFlags[1] & 0x20)
4056 *pS >> fUnknown1; // another unknown 32 bit ( or is 8 or 16 bit with padding ? )
4058 if (pBlockFlags[1] & 0x80)
4060 ReadAlign(pS, pS->Tell() - nStart, 2);
4061 *pS >> nIcon;
4062 DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
4065 bool bCaption = false;
4067 if (pBlockFlags[2] & 0x01)
4068 *pS >> nCycle;
4069 if (pBlockFlags[2] & 0x02)
4070 *pS >> nSpecialEffect;
4072 if (pBlockFlags[2] & 0x04)
4074 ReadAlign(pS, pS->Tell() - nStart, 4);
4075 *pS >> nBorderColor;
4078 if (pBlockFlags[2] & 0x08)
4080 ReadAlign(pS, pS->Tell() - nStart, 4);
4081 *pS >> nCaptionLen;
4082 bCaption = true;
4085 if (pBlockFlags[2] & 0x10)
4087 ReadAlign(pS, pS->Tell() - nStart, 2);
4088 sal_uInt16 nNoIdea;
4089 *pS >> nNoIdea;
4090 DBG_ASSERT(nNoIdea == 0xFFFF, "Expected 0xFFFF, (related to font ?)");
4093 if (pBlockFlags[2] & 0x20)
4095 ReadAlign(pS, pS->Tell() - nStart, 2);
4096 *pS >> nPicture;
4097 DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
4100 if (pBlockFlags[2] & 0x80)
4101 *pS >> nPictureAlignment;
4103 if (pBlockFlags[3] & 0x01)
4104 bPictureTiling = true;
4106 if (pBlockFlags[3] & 0x02)
4107 *pS >> nPictureSizeMode;
4109 if (pBlockFlags[3] & 0x04)
4111 ReadAlign(pS, pS->Tell() - nStart, 4);
4112 *pS >> fUnknown8;
4115 if (pBlockFlags[3] & 0x08)
4117 ReadAlign(pS, pS->Tell() - nStart, 4);
4118 *pS >> fUnknown9;
4121 ReadAlign(pS, pS->Tell() - nStart, 4);
4122 *pS >> nWidth;
4123 *pS >> nHeight;
4124 *pS >> nScrollWidth;
4125 *pS >> nScrollHeight;
4127 if (pBlockFlags[1] & 0x10)
4129 *pS >> nScrollLeft;
4130 *pS >> nScrollTop;
4133 if ( bCaption )
4135 lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
4138 OUString tempCaption = lclCreateOUString( pCaption, nCaptionLen );
4140 if (nIcon)
4142 pS->Read(pIconHeader,20);
4143 *pS >> nIconLen;
4144 pIcon = new sal_uInt8[nIconLen];
4145 pS->Read(pIcon,nIconLen);
4148 if (nPicture)
4150 pS->Read(pPictureHeader,20);
4151 *pS >> nPictureLen;
4152 pPicture = new sal_uInt8[nPictureLen];
4153 pS->Read(pPicture,nPictureLen);
4156 ReadAlign( pS, pS->Tell() - nStart, 4);
4158 if (pBlockFlags[2] & 0x10)
4160 //Font Stuff..
4161 pS->SeekRel(0x1a);
4162 sal_uInt8 nFontLen;
4163 *pS >> nFontLen;
4164 pS->SeekRel(nFontLen);
4167 return OCX_ContainerControl::Read( pS );
4170 sal_Bool OCX_Frame::Import(com::sun::star::uno::Reference<
4171 com::sun::star::beans::XPropertySet> &rPropSet)
4173 uno::Any aTmp(&sName,getCppuType((OUString *)0));
4174 rPropSet->setPropertyValue(
4175 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
4176 if ( pCaption )
4178 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
4179 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
4182 // Calls import on contained controls
4183 OCX_ContainerControl::Import( rPropSet );
4184 return sal_True;
4186 OCX_UserForm::OCX_UserForm( SotStorageRef& parent,
4187 const OUString& storageName,
4188 const OUString& sN,
4189 const ::uno::Reference< container::XNameContainer > &rDialog,
4190 const ::uno::Reference< lang::XMultiServiceFactory >& rMsf):
4191 OCX_ContainerControl(parent, storageName, sN, rDialog),
4192 nChildrenA(0), fEnabled(1), fLocked(0),
4193 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
4194 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012), nChildrenB(0),
4195 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
4196 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
4197 bPictureTiling(FALSE), nAccelerator(0), nIcon(0), pCaption(0),
4198 nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0)
4200 mnForeColor = 0x80000012;
4201 mnBackColor = 0x8000000F;
4202 uno::Reference< beans::XPropertySet> xProps( rMsf, uno::UNO_QUERY);
4203 if ( xProps.is() )
4205 xProps->getPropertyValue(C2S("DefaultContext")) >>= mxCtx;
4207 aFontData.SetHasAlign(TRUE);
4209 sal_Bool OCX_UserForm::Read(SvStorageStream *pS)
4211 long nStart = pS->Tell();
4212 *pS >> nIdentifier;
4213 DBG_ASSERT(0x400==nIdentifier,
4214 "A control that has a different identifier");
4215 *pS >> nFixedAreaLen;
4216 pS->Read(pBlockFlags,4);
4218 if (pBlockFlags[0] & 0x01)
4220 DBG_ASSERT(!this, "ARSE");
4222 if (pBlockFlags[0] & 0x02)
4223 *pS >> mnBackColor;
4224 if (pBlockFlags[0] & 0x04)
4225 *pS >> mnForeColor;
4226 if (pBlockFlags[0] & 0x08)
4227 *pS >> nChildrenA;
4228 if (pBlockFlags[0] & 0x40)
4230 sal_uInt8 nTemp;
4231 *pS >> nTemp;
4232 fEnabled = (nTemp&0x04)>>2;
4233 fBackStyle = (nTemp&0x08)>>3;
4234 *pS >> nTemp;
4235 *pS >> nTemp;
4236 fWordWrap = (nTemp&0x80)>>7;
4237 *pS >> nTemp;
4238 fAutoSize = (nTemp&0x10)>>4;
4240 if (pBlockFlags[0] & 0x80)
4242 ReadAlign(pS, pS->Tell() - nStart, 4);
4243 *pS >> nBorderStyle;
4245 #if 0
4246 sal_uInt16 nFixedOrAlign;
4247 *pS >> nFixedOrAlign;
4248 #endif
4249 if (pBlockFlags[1] & 0x01)
4250 *pS >> nMousePointer;
4251 if (pBlockFlags[1] & 0x02)
4252 *pS >> nKeepScrollBarsVisible;
4253 if (pBlockFlags[1] & 0x20)
4255 sal_uInt32 nUnknown32;
4256 *pS >> nUnknown32;
4258 if (pBlockFlags[1] & 0x80)
4260 ReadAlign(pS, pS->Tell() - nStart, 2);
4261 *pS >> nIcon;
4262 DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
4264 if (pBlockFlags[2] & 0x01)
4265 *pS >> nCycle;
4266 if (pBlockFlags[2] & 0x02)
4267 *pS >> nSpecialEffect;
4269 if (pBlockFlags[2] & 0x04)
4271 ReadAlign(pS, pS->Tell() - nStart, 4);
4272 *pS >> nBorderColor;
4275 if (pBlockFlags[2] & 0x10)
4277 ReadAlign(pS, pS->Tell() - nStart, 2);
4278 sal_uInt16 nNoIdea;
4279 *pS >> nNoIdea;
4280 DBG_ASSERT(nNoIdea == 0xFFFF, "Expected 0xFFFF, (related to font ?)");
4283 if (pBlockFlags[2] & 0x20)
4285 ReadAlign(pS, pS->Tell() - nStart, 2);
4286 *pS >> nPicture;
4287 DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
4290 if (pBlockFlags[2] & 0x80)
4291 *pS >> nPictureAlignment;
4293 if (pBlockFlags[3] & 0x01)
4294 bPictureTiling = true;
4296 if (pBlockFlags[3] & 0x02)
4297 *pS >> nPictureSizeMode;
4299 if (pBlockFlags[3] & 0x04)
4301 ReadAlign(pS, pS->Tell() - nStart, 4);
4302 *pS >> nChildrenB;
4305 ReadAlign(pS, pS->Tell() - nStart, 4);
4306 *pS >> nDrawBuffer;
4308 ReadAlign(pS, pS->Tell() - nStart, 4);
4309 *pS >> nWidth;
4310 *pS >> nHeight;
4311 *pS >> nScrollWidth;
4312 *pS >> nScrollHeight;
4314 if (pBlockFlags[1] & 0x10)
4316 *pS >> nScrollLeft;
4317 *pS >> nScrollTop;
4320 if (nIcon)
4322 pS->Read(pIconHeader,20);
4323 *pS >> nIconLen;
4324 pIcon = new sal_uInt8[nIconLen];
4325 pS->Read(pIcon,nIconLen);
4328 ReadAlign( pS, pS->Tell() - nStart, 4);
4329 if (pBlockFlags[2] & 0x10)
4331 //Font Stuff..
4332 pS->SeekRel(0x1a);
4333 sal_uInt8 nFontLen;
4334 *pS >> nFontLen;
4335 pS->SeekRel(nFontLen);
4337 if (nPicture)
4339 pS->Read(pPictureHeader,20);
4340 *pS >> nPictureLen;
4341 long imagePos = pS->Tell();
4342 // great embedded object
4343 mxGrfObj = lcl_readGraphicObject( pS );
4344 if( mxGrfObj.is() )
4346 sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
4347 sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
4349 // make sure the stream position should be pointing after the image.
4350 pS->Seek( imagePos + nPictureLen );
4353 sal_Int16 numTrailingRecs = 0;
4354 *pS >> numTrailingRecs;
4355 // seems to be no. of trailing records,
4356 // before container record starts proper
4357 // ( unknown what these trailing records are for)
4358 if ( numTrailingRecs )
4360 for ( sal_Int16 i = 0 ; numTrailingRecs ; --numTrailingRecs, ++i )
4362 sal_uInt16 nTypeID = 0;
4363 if ( lcl_handleActiveXControl( pS, nTypeID ) )
4365 if ( nTypeID & 0x8000 ) // valid ActiveXID
4366 mActiveXIDMap[ ( i | 0x8000 ) ] = nTypeID;
4370 return OCX_ContainerControl::Read( pS );
4373 sal_Bool OCX_UserForm::Import(
4374 uno::Reference<container::XNameContainer> &rLib )
4376 uno::Reference<beans::XPropertySet>
4377 xDialogPropSet(mxParent, uno::UNO_QUERY);
4378 if ( !xDialogPropSet.is() )
4379 return sal_False;
4380 uno::Any aTmp(&sName,getCppuType((OUString *)0));
4381 xDialogPropSet->setPropertyValue(
4382 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
4383 xDialogPropSet->setPropertyValue(
4384 OUString(RTL_CONSTASCII_USTRINGPARAM("Title")), aTmp);
4385 aTmp <<= ImportColor(mnBackColor);
4386 xDialogPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
4387 sal_Bool bVBA = sal_False;
4388 // Ok we are importing xls but maybe we aren't in VBA mode
4389 // if we are not in VBA mode then we should import sizes etc. ( as before )
4392 xDialogPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("VBAForm") ) ) >>= bVBA;
4394 catch( uno::Exception& e )
4397 sal_Int32 nFactor( 3528 );
4398 if ( !bVBA )
4400 aTmp <<= sal_Int32((nWidth * 2) / 100);
4401 xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
4402 aTmp <<= sal_Int32((nHeight * 2) / 100);
4403 xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
4405 else
4407 aTmp <<= sal_Int32( nWidth + 160 ); // 100thmm
4408 xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
4409 aTmp <<= sal_Int32(nHeight + 662 - 714); //100th mm
4410 xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
4414 uno::Reference<beans::XPropertySet> xPropSet( mxParent, uno::UNO_QUERY );
4415 OCX_ContainerControl::Import( xPropSet );
4417 uno::Reference<io::XInputStreamProvider> xSource =
4418 xmlscript::exportDialogModel(mxParent, mxCtx, pDocSh->GetModel() );
4419 uno::Any aSourceAny(uno::makeAny(xSource));
4420 if (rLib->hasByName(sName))
4421 rLib->replaceByName(sName, aSourceAny);
4422 else
4423 rLib->insertByName(sName, aSourceAny);
4425 if ( sImageUrl.getLength() )
4427 aTmp <<= sImageUrl;
4430 xDialogPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
4432 catch( uno::Exception& )
4434 OSL_TRACE("OCX_UserForm::Import, Image fails to import");
4437 return sal_True;
4440 sal_Bool OCX_Label::WriteContents(SvStorageStreamRef &rContents,
4441 const uno::Reference< beans::XPropertySet > &rPropSet,
4442 const awt::Size &rSize)
4444 sal_Bool bRet = sal_True;
4445 sal_uInt32 nOldPos = rContents->Tell();
4446 rContents->SeekRel(8);
4447 pBlockFlags[0] = 0x20;
4448 pBlockFlags[1] = 0;
4449 pBlockFlags[2] = 0;
4450 pBlockFlags[3] = 0;
4452 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
4453 if (aTmp.hasValue())
4454 aTmp >>= mnForeColor;
4455 *rContents << ExportColor(mnForeColor);
4456 pBlockFlags[0] |= 0x01;
4458 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
4459 if (aTmp.hasValue())
4460 aTmp >>= mnBackColor;
4461 *rContents << ExportColor(mnBackColor);
4462 pBlockFlags[0] |= 0x02;
4464 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
4465 fEnabled = any2bool(aTmp);
4466 sal_uInt8 nTemp=fEnabled;
4467 if (fEnabled)
4468 nTemp = nTemp << 1;
4469 *rContents << nTemp;
4470 *rContents << sal_uInt8(0x00);
4472 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
4473 fWordWrap = any2bool(aTmp);
4474 nTemp=fWordWrap;
4475 nTemp = nTemp << 7;
4476 *rContents << nTemp;
4477 *rContents << sal_uInt8(0x00);
4478 pBlockFlags[0] |= 0x04;
4480 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
4481 aCaption.WriteLenField( *rContents );
4482 if (aCaption.HasData())
4483 pBlockFlags[0] |= 0x08;
4485 WriteAlign(rContents,4);
4486 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BorderColor"));
4487 if (aTmp.hasValue())
4488 aTmp >>= nBorderColor;
4489 *rContents << ExportColor(nBorderColor);
4490 pBlockFlags[0] |= 0x80;
4492 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
4493 sal_Int16 nBorder = sal_Int16();
4494 aTmp >>= nBorder;
4495 sal_uInt8 nNewBorder;
4496 nSpecialEffect = ExportBorder(nBorder,nNewBorder);
4497 nBorderStyle = nNewBorder;
4498 *rContents << nBorderStyle;
4499 pBlockFlags[1] |= 0x01;
4500 *rContents << nSpecialEffect;
4501 pBlockFlags[1] |= 0x02;
4503 aCaption.WriteCharArray( *rContents );
4505 WriteAlign(rContents,4);
4506 *rContents << rSize.Width;
4507 *rContents << rSize.Height;
4508 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
4510 bRet = aFontData.Export(rContents,rPropSet);
4512 rContents->Seek(nOldPos);
4513 *rContents << nStandardId;
4514 *rContents << nFixedAreaLen;
4516 *rContents << pBlockFlags[0];
4517 *rContents << pBlockFlags[1];
4518 *rContents << pBlockFlags[2];
4519 *rContents << pBlockFlags[3];
4521 DBG_ASSERT((rContents.Is() &&
4522 (SVSTREAM_OK==rContents->GetError())),"damn");
4523 return bRet;
4528 sal_Bool OCX_Label::Export(SvStorageRef &rObj,
4529 const uno::Reference< beans::XPropertySet > &rPropSet,
4530 const awt::Size &rSize)
4532 static sal_uInt8 __READONLY_DATA aCompObj[] = {
4533 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
4534 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
4535 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
4536 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
4537 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
4538 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
4539 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
4540 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
4541 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
4542 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
4543 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
4544 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
4545 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
4546 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
4550 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
4551 xStor->Write(aCompObj,sizeof(aCompObj));
4552 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
4556 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
4557 xStor3->Write(aObjInfo,sizeof(aObjInfo));
4558 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
4561 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
4562 0x4C, 0x00, 0x61, 0x00, 0x62, 0x00, 0x65, 0x00,
4563 0x6C, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
4567 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
4568 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
4569 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
4572 static sal_uInt8 __READONLY_DATA aTest[] = {
4573 0x00, 0x02, 0x20, 0x00, 0x2B, 0x00, 0x00, 0x00,
4574 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00,
4575 0x06, 0x00, 0x00, 0x80, 0x4C, 0x61, 0x62, 0x65,
4576 0x6C, 0x31, 0x18, 0x00, 0xEC, 0x09, 0x00, 0x00,
4577 0x7B, 0x02, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00,
4578 0x35, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x80,
4579 0xC3, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
4580 0x54, 0x69, 0x6D, 0x65, 0x73, 0x20, 0x4E, 0x65,
4581 0x77, 0x20, 0x52, 0x6F, 0x6D, 0x61, 0x6E, 0x00,
4584 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
4585 return WriteContents(xContents, rPropSet, rSize);
4588 typedef OCX_Control *(*FNCreate)();
4591 struct OCX_map
4593 FNCreate pCreate;
4594 const char *sId;
4595 sal_Int16 nId;
4596 const char *sName;
4599 OCX_map aOCXTab[] =
4601 // Command button MUST be at index 0
4602 {&OCX_CommandButton::Create,"D7053240-CE69-11CD-a777-00dd01143c57",
4603 form::FormComponentType::COMMANDBUTTON,"CommandButton"},
4604 // Toggle button MUST be at index 1
4605 {&OCX_ToggleButton::Create,"8BD21D60-EC42-11CE-9e0d-00aa006002f3",
4606 form::FormComponentType::COMMANDBUTTON,"ToggleButton"},
4607 {&OCX_Label::Create, "978C9E23-D4B0-11CE-bf2d-00aa003f40d0",
4608 form::FormComponentType::FIXEDTEXT,"Label"},
4609 {&OCX_TextBox::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4610 form::FormComponentType::TEXTFIELD,"TextBox"},
4611 {&OCX_ListBox::Create,"8BD21D20-EC42-11CE-9e0d-00aa006002f3",
4612 form::FormComponentType::LISTBOX,"ListBox"},
4613 {&OCX_ComboBox::Create,"8BD21D30-EC42-11CE-9e0d-00aa006002f3",
4614 form::FormComponentType::COMBOBOX,"ComboBox"},
4615 {&OCX_CheckBox::Create,"8BD21D40-EC42-11CE-9e0d-00aa006002f3",
4616 form::FormComponentType::CHECKBOX,"CheckBox"},
4617 {&OCX_OptionButton::Create,"8BD21D50-EC42-11CE-9e0d-00aa006002f3",
4618 form::FormComponentType::RADIOBUTTON,"OptionButton"},
4619 {&OCX_Image::Create,"4C599241-6926-101B-9992-00000b65c6f9",
4620 form::FormComponentType::IMAGECONTROL,"Image"},
4621 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4622 form::FormComponentType::DATEFIELD,"TextBox"},
4623 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4624 form::FormComponentType::TIMEFIELD,"TextBox"},
4625 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4626 form::FormComponentType::NUMERICFIELD,"TextBox"},
4627 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4628 form::FormComponentType::CURRENCYFIELD,"TextBox"},
4629 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4630 form::FormComponentType::PATTERNFIELD,"TextBox"},
4631 #if 0
4632 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4633 form::FormComponentType::FORMULAFIELD,"TextBox"},
4634 #endif
4635 {&OCX_ImageButton::Create,"D7053240-CE69-11CD-a777-00dd01143c57",
4636 form::FormComponentType::IMAGEBUTTON,"CommandButton"},
4637 {&OCX_SpinButton::Create,"79176FB0-B7F2-11CE-97ef-00aa006d2776",
4638 form::FormComponentType::SPINBUTTON,"SpinButton"},
4639 {&OCX_ScrollBar::Create,"DFD181E0-5E2F-11CE-a449-00aa004a803d",
4640 form::FormComponentType::SCROLLBAR,"ScrollBar"},
4641 {&OCX_GroupBox::Create,"",
4642 form::FormComponentType::GROUPBOX,""},
4643 {&OCX_ProgressBar::Create,"", form::FormComponentType::CONTROL,""},
4644 {&HTML_TextBox::Create,"5512D11A-5CC6-11CF-8d67-00aa00bdce1d", form::FormComponentType::TEXTFIELD,"TextBox"},
4645 {&HTML_TextBox::Create,"5512D124-5CC6-11CF-8d67-00aa00bdce1d", form::FormComponentType::TEXTFIELD,"TextBox"}
4648 const int NO_OCX = sizeof( aOCXTab ) / sizeof( *aOCXTab );
4650 SvxMSConvertOCXControls::SvxMSConvertOCXControls(SfxObjectShell *pDSh, SwPaM *pP) :
4651 pDocSh(pDSh), pPaM(pP), nEdit(0), nCheckbox(0)
4653 DBG_ASSERT( pDocSh, "No DocShell, Cannot do Controls" );
4654 OCX_Control::FillSystemColors();
4657 SvxMSConvertOCXControls::~SvxMSConvertOCXControls()
4661 OCX_Control * SvxMSConvertOCXControls::OCX_Factory(const String &sName)
4663 for (int i=0;i<NO_OCX;i++)
4665 if ( sName.EqualsIgnoreCaseAscii( aOCXTab[i].sId ))
4666 return(aOCXTab[i].pCreate());
4668 return(NULL);
4671 OCX_Control * SvxMSConvertOCXControls::OCX_Factory(
4672 const uno::Reference< awt::XControlModel > &rControlModel,
4673 String &rId, String &rName)
4675 rName.Erase();
4676 rId.Erase();
4678 uno::Reference< beans::XPropertySet > xPropSet(
4679 rControlModel,uno::UNO_QUERY);
4681 uno::Any aTmp = xPropSet->getPropertyValue(
4682 OUString::createFromAscii("ClassId"));
4683 sal_Int16 nClassId = *(sal_Int16*) aTmp.getValue();
4685 //Begin nasty hack
4687 There is a truly horrible thing with EditControls and FormattedField
4688 Controls, they both pretend to have an EDITBOX ClassId for compability
4689 reasons, at some stage in the future hopefully there will be a proper
4690 FormulaField ClassId rather than this piggybacking two controls onto the
4691 same ClassId, when this happens uncomment the FORMULAFIELD in the OCX_Tab
4692 and delete this block, cmc.
4694 And also the nClassId for ImageControls is being reported as "CONTROL"
4695 rather than IMAGECONTROL
4697 if (nClassId == form::FormComponentType::TEXTFIELD)
4699 uno::Reference< lang::XServiceInfo > xInfo(rControlModel,
4700 uno::UNO_QUERY);
4701 if (xInfo->
4702 supportsService(OUString::createFromAscii(
4703 "com.sun.star.form.component.FormattedField")))
4705 rId.AppendAscii("8BD21D10-EC42-11CE-9e0d-00aa006002f3");
4706 rName.AppendAscii("TextBox");
4707 return new OCX_FieldControl;
4710 else if (nClassId == form::FormComponentType::CONTROL)
4712 uno::Reference< lang::XServiceInfo > xInfo(rControlModel,
4713 uno::UNO_QUERY);
4714 if (xInfo->
4715 supportsService(OUString::createFromAscii(
4716 "com.sun.star.form.component.ImageControl")))
4717 nClassId = form::FormComponentType::IMAGECONTROL;
4719 //End nasty hack
4721 const OCX_map* pEntry = 0;
4723 // distinguish between push button and toggle button
4724 if( nClassId == form::FormComponentType::COMMANDBUTTON )
4726 pEntry = any2bool(xPropSet->getPropertyValue(WW8_ASCII2STR("Toggle"))) ?
4727 (aOCXTab + 1) : aOCXTab;
4729 else
4731 for( int i = 2; (i < NO_OCX) && !pEntry; ++i )
4732 if( nClassId == aOCXTab[ i ].nId )
4733 pEntry = aOCXTab + i;
4736 if( pEntry )
4738 rId.AppendAscii( pEntry->sId );
4739 rName.AppendAscii( pEntry->sName );
4740 return pEntry->pCreate();
4743 return 0;
4747 sal_Bool SvxMSConvertOCXControls::ReadOCXStream( SvStorageRef& rSrc1,
4748 uno::Reference < drawing::XShape > *pShapeRef,BOOL bFloatingCtrl)
4751 SvStorageStreamRef xCrash = rSrc1->OpenSotStream( WW8_ASCII2STR("contents") );
4752 sal_Bool bRet=sal_False;
4754 SvStorageStreamRef xSrc2 = rSrc1->OpenSotStream( WW8_ASCII2STR("\3OCXNAME") );
4755 SvStorageStream* pSt = xSrc2;
4756 pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
4758 /* #117832# import control name */
4759 OUString controlName;
4760 bool hasCName = readOCXNAME( controlName, pSt );
4762 xSrc2 = rSrc1->OpenSotStream( WW8_ASCII2STR("contents") );
4763 pSt = xSrc2;
4764 pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
4766 /*Get Class Id of this object, see if it is one of the types
4767 *that this importer can handle, call the appropiate handler
4768 to read that control, and call the appropiate handler to
4769 insert that control
4772 SvGlobalName aTest = rSrc1->GetClassName();
4773 OCX_Control *pObj = OCX_Factory(aTest.GetHexName());
4774 if (pObj)
4776 pObj->pDocSh = pDocSh;
4777 /* #117832# set imported control name */
4778 if ( hasCName )
4780 pObj->sName = controlName;
4782 com::sun::star::awt::Size aSz;
4783 uno::Reference< form::XFormComponent > xFComp;
4784 const uno::Reference< lang::XMultiServiceFactory > & rServiceFactory =
4785 GetServiceFactory();
4786 if(!rServiceFactory.is())
4787 return(sal_False);
4788 bRet = pObj->FullRead(pSt);
4789 if(bRet)
4790 if (pObj->Import(rServiceFactory,xFComp,aSz))
4791 bRet = InsertControl( xFComp, aSz,pShapeRef,bFloatingCtrl);
4792 delete pObj;
4794 return bRet;
4798 sal_Bool SvxMSConvertOCXControls::ReadOCXExcelKludgeStream(
4799 SvStorageStreamRef& rSrc1, uno::Reference < drawing::XShape > *
4800 pShapeRef,BOOL bFloatingCtrl)
4802 sal_Bool bRet=sal_False;
4803 /*Get Class Id of this object, see if it is one of the types
4804 *that this importer can handle, call the appropiate handler
4805 to read that control, and call the appropiate handler to
4806 insert that control
4808 /*The Excel Kludge is to concatenate a class id with a contents
4809 * stream, and then concatenate all the controls together,
4810 * This means that you should have the cnts stream wound to the
4811 * correct location before passing the control stream in here*/
4812 SvStream *pSt = rSrc1;
4813 pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
4814 SvGlobalName aTest;
4815 *pSt >> aTest;
4816 OCX_Control *pObj = OCX_Factory(aTest.GetHexName());
4817 if (pObj)
4820 com::sun::star::awt::Size aSz;
4821 uno::Reference< form::XFormComponent > xFComp;
4822 const uno::Reference< lang::XMultiServiceFactory > & rServiceFactory =
4823 GetServiceFactory();
4824 if(!rServiceFactory.is())
4825 return(sal_False);
4826 bRet = pObj->FullRead(rSrc1);
4827 if(bRet)
4828 if (pObj->Import(rServiceFactory,xFComp,aSz))
4829 bRet = InsertControl( xFComp, aSz,pShapeRef,bFloatingCtrl);
4830 delete pObj;
4832 return bRet;
4836 sal_Bool SvxMSConvertOCXControls::WriteOCXStream( SvStorageRef& rSrc1,
4837 const uno::Reference< awt::XControlModel > &rControlModel,
4838 const awt::Size &rSize, String &rName)
4840 sal_Bool bRet=sal_False;
4842 DBG_ASSERT( rControlModel.is(), "UNO-Control missing Model, panic!" );
4843 if( !rControlModel.is() )
4844 return sal_False;
4846 #if 0
4847 uno::Any aTmp = xPropSet->getPropertyValue(
4848 OUString::createFromAscii("ClassId"));
4849 sal_Int16 nClassId = *(sal_Int16*) aTmp.getValue();
4850 #endif
4852 String sId;
4853 OCX_Control *pObj = OCX_Factory(rControlModel,sId,rName);
4854 if (pObj != NULL)
4856 uno::Reference<beans::XPropertySet> xPropSet(rControlModel,
4857 uno::UNO_QUERY);
4859 /* #117832# - also enable export of control name */
4860 OUString sCName;
4861 xPropSet->getPropertyValue(C2S("Name")) >>= sCName;
4862 pObj->sName = sCName;
4864 SvGlobalName aName;
4865 aName.MakeId(sId);
4866 String sFullName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
4867 "Microsoft Forms 2.0 ")));
4868 sFullName.Append(rName);
4869 rSrc1->SetClass(aName,0x5C,sFullName);
4870 // ^^^^, this pathetic 0x5c is the magic number
4871 // which the lack of originally blocked the implementation of
4872 // the controls export
4873 // cmc
4875 bRet = pObj->Export(rSrc1,xPropSet,rSize);
4876 SvStorageStreamRef xStor2( rSrc1->OpenSotStream( WW8_ASCII2STR("\3OCXNAME")));
4877 /* #117832# - also enable export of control name */
4878 writeOCXNAME( sCName, xStor2 );
4879 delete pObj;
4881 return bRet;
4885 //I think this should work for excel documents, create the "Ctls" stream
4886 //and give it here as rContents, we'll append out streams ole id and
4887 //contents here and that appears to be what Excel is doing
4888 sal_Bool SvxMSConvertOCXControls::WriteOCXExcelKludgeStream(
4889 SvStorageStreamRef& rContents,
4890 const uno::Reference< awt::XControlModel > &rControlModel,
4891 const awt::Size &rSize, String &rName)
4893 sal_Bool bRet=sal_False;
4895 DBG_ASSERT( rControlModel.is(), "UNO-Control missing Model, panic!" );
4896 if( !rControlModel.is() )
4897 return sal_False;
4899 String sId;
4900 OCX_Control *pObj = OCX_Factory(rControlModel,sId,rName);
4901 if (pObj != NULL)
4903 uno::Reference<beans::XPropertySet> xPropSet(rControlModel,
4904 uno::UNO_QUERY);
4906 SvGlobalName aName;
4907 aName.MakeId(sId);
4908 String sFullName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
4909 "Microsoft Forms 2.0 ")));
4910 sFullName.Append(rName);
4911 SvStream *pS=rContents;
4912 *pS << aName;
4913 bRet = pObj->WriteContents(rContents,xPropSet,rSize);
4914 delete pObj;
4915 // export needs correct stream position
4916 rContents->Seek( STREAM_SEEK_TO_END );
4918 return bRet;
4927 sal_Bool OCX_CheckBox::Import(com::sun::star::uno::Reference<
4928 com::sun::star::beans::XPropertySet> &rPropSet)
4930 uno::Any aTmp(&sName,getCppuType((OUString *)0));
4931 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
4933 // background color: fBackStyle==0 -> transparent
4934 if( fBackStyle )
4935 aTmp <<= ImportColor(mnBackColor);
4936 else
4937 aTmp = uno::Any();
4938 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
4940 sal_Bool bTemp;
4941 if ((!(fEnabled)) || (fLocked))
4942 bTemp = sal_False;
4943 else
4944 bTemp = sal_True;
4945 aTmp = bool2any(bTemp);
4946 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
4948 bTemp = fWordWrap != 0;
4949 aTmp = bool2any(bTemp);
4950 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
4952 aTmp <<= ImportColor(mnForeColor);
4953 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
4955 bTemp = nMultiState;
4956 aTmp = bool2any(bTemp);
4957 rPropSet->setPropertyValue( WW8_ASCII2STR("TriState"), aTmp);
4959 aTmp <<= ImportSpecEffect( nSpecialEffect );
4960 rPropSet->setPropertyValue( WW8_ASCII2STR("VisualEffect"), aTmp);
4962 if (pValue)
4964 INT16 nTmp=pValue[0]-0x30;
4965 aTmp <<= nTmp;
4966 if ( !bSetInDialog )
4967 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
4968 else
4969 rPropSet->setPropertyValue( WW8_ASCII2STR("State"), aTmp);
4972 if (pCaption)
4974 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
4975 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
4978 // #i40279# always centered vertically
4979 aTmp <<= ::com::sun::star::style::VerticalAlignment_MIDDLE;
4980 rPropSet->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp );
4982 aFontData.Import(rPropSet);
4983 return(sal_True);
4986 sal_Bool OCX_CheckBox::WriteContents(SvStorageStreamRef &rContents,
4987 const uno::Reference< beans::XPropertySet > &rPropSet,
4988 const awt::Size &rSize)
4991 sal_Bool bRet=sal_True;
4992 sal_uInt32 nOldPos = rContents->Tell();
4993 rContents->SeekRel(12);
4995 pBlockFlags[0] = 0;
4996 pBlockFlags[1] = 0x01;
4997 pBlockFlags[2] = 0;
4998 pBlockFlags[3] = 0x80;
4999 pBlockFlags[4] = 0;
5000 pBlockFlags[5] = 0;
5001 pBlockFlags[6] = 0;
5002 pBlockFlags[7] = 0;
5004 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
5005 fEnabled = any2bool(aTmp);
5007 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
5008 fBackStyle = aTmp.hasValue() ? 1 : 0;
5009 if (fBackStyle)
5010 aTmp >>= mnBackColor;
5012 sal_uInt8 nTemp=fEnabled;
5013 if (fEnabled)
5014 nTemp = nTemp << 1;
5015 if (fBackStyle)
5016 nTemp |= 0x08;
5017 *rContents << nTemp;
5018 pBlockFlags[0] |= 0x01;
5019 *rContents << sal_uInt8(0x00);
5020 nTemp = 0;
5021 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
5022 fWordWrap = any2bool(aTmp);
5023 if (fWordWrap)
5024 nTemp |= 0x80;
5025 *rContents << nTemp;
5026 *rContents << sal_uInt8(0x00);
5028 *rContents << ExportColor(mnBackColor);
5029 pBlockFlags[0] |= 0x02;
5031 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
5032 if (aTmp.hasValue())
5033 aTmp >>= mnForeColor;
5034 *rContents << ExportColor(mnForeColor);
5035 pBlockFlags[0] |= 0x04;
5037 nStyle = 4;
5038 *rContents << nStyle;
5039 pBlockFlags[0] |= 0x40;
5041 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TriState"));
5042 nMultiState = any2bool(aTmp);
5043 *rContents << nMultiState;
5044 pBlockFlags[2] |= 0x20;
5046 WriteAlign(rContents,4);
5047 nValueLen = 1|SVX_MSOCX_COMPRESSED;
5048 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultState"));
5049 sal_Int16 nDefault = sal_Int16();
5050 aTmp >>= nDefault;
5051 *rContents << nValueLen;
5052 pBlockFlags[2] |= 0x40;
5054 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
5055 aCaption.WriteLenField( *rContents );
5056 if (aCaption.HasData())
5057 pBlockFlags[2] |= 0x80;
5059 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("VisualEffect"));
5060 if (aTmp.hasValue())
5062 sal_Int16 nApiSpecEffect = sal_Int16();
5063 aTmp >>= nApiSpecEffect;
5064 nSpecialEffect = ExportSpecEffect( nApiSpecEffect );
5066 WriteAlign(rContents,4);
5067 *rContents << nSpecialEffect;
5068 pBlockFlags[3] |= 0x04;
5070 WriteAlign(rContents,4);
5071 *rContents << rSize.Width;
5072 *rContents << rSize.Height;
5074 nDefault += 0x30;
5075 *rContents << sal_uInt8(nDefault);
5076 *rContents << sal_uInt8(0x00);
5078 aCaption.WriteCharArray( *rContents );
5080 WriteAlign(rContents,4);
5081 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
5082 bRet = aFontData.Export(rContents,rPropSet);
5083 rContents->Seek(nOldPos);
5084 *rContents << nStandardId;
5085 *rContents << nFixedAreaLen;
5087 *rContents << pBlockFlags[0];
5088 *rContents << pBlockFlags[1];
5089 *rContents << pBlockFlags[2];
5090 *rContents << pBlockFlags[3];
5091 *rContents << pBlockFlags[4];
5092 *rContents << pBlockFlags[5];
5093 *rContents << pBlockFlags[6];
5094 *rContents << pBlockFlags[7];
5096 DBG_ASSERT((rContents.Is() &&
5097 (SVSTREAM_OK==rContents->GetError())),"damn");
5098 return bRet;
5102 sal_Bool OCX_CheckBox::Export(SvStorageRef &rObj,
5103 const uno::Reference< beans::XPropertySet > &rPropSet,
5104 const awt::Size &rSize)
5107 static sal_uInt8 __READONLY_DATA aCompObj[] = {
5108 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5109 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
5110 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
5111 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
5112 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5113 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5114 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
5115 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
5116 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
5117 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
5118 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
5119 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
5120 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
5121 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5122 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5126 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
5127 xStor->Write(aCompObj,sizeof(aCompObj));
5128 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
5132 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
5133 xStor3->Write(aObjInfo,sizeof(aObjInfo));
5134 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
5137 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
5138 0x43, 0x00, 0x68, 0x00, 0x65, 0x00, 0x63, 0x00,
5139 0x6B, 0x00, 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00,
5140 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
5143 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
5144 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
5145 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
5148 static sal_uInt8 __READONLY_DATA aTest[] = {
5149 0x00, 0x02, 0x34, 0x00, 0x46, 0x01, 0xC0, 0x80,
5150 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00,
5151 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5152 0x01, 0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x80,
5153 0xE2, 0x0E, 0x00, 0x00, 0x95, 0x02, 0x00, 0x00,
5154 0x30, 0x69, 0x1D, 0x00, 0x43, 0x68, 0x65, 0x63,
5155 0x6B, 0x42, 0x6F, 0x78, 0x31, 0x20, 0x52, 0x6F,
5156 0x00, 0x02, 0x20, 0x00, 0x35, 0x00, 0x00, 0x00,
5157 0x0F, 0x00, 0x00, 0x80, 0xC3, 0x00, 0x00, 0x00,
5158 0x00, 0x02, 0x00, 0x00, 0x54, 0x69, 0x6D, 0x65,
5159 0x73, 0x20, 0x4E, 0x65, 0x77, 0x20, 0x52, 0x6F,
5160 0x6D, 0x61, 0x6E, 0x00,
5163 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
5164 return WriteContents(xContents, rPropSet, rSize);
5168 sal_Bool OCX_FontData::Read(SvStorageStream *pS)
5170 long nStart = pS->Tell();
5171 *pS >> nIdentifier;
5172 *pS >> nFixedAreaLen;
5173 pS->Read(pBlockFlags,4);
5175 bool bFontName = (pBlockFlags[0] & 0x01) != 0;
5176 if (bFontName)
5177 *pS >> nFontNameLen;
5178 if (pBlockFlags[0] & 0x02)
5180 sal_uInt8 nTmp;
5181 *pS >> nTmp;
5182 fBold = nTmp & 0x01;
5183 fItalic = (nTmp & 0x02) >> 1;
5184 fUnderline = (nTmp & 0x04) >> 2;
5185 fStrike = (nTmp & 0x08) >> 3;
5186 fUnknown1 = (nTmp & 0xF0) >> 4;
5187 *pS >> nUnknown2;
5188 *pS >> nUnknown3;
5189 *pS >> nUnknown4;
5191 if (pBlockFlags[0] & 0x04)
5193 ReadAlign(pS, pS->Tell() - nStart, 4);
5194 *pS >> nFontSize;
5196 else
5197 nFontSize = 240;
5198 if (pBlockFlags[0] & 0x10)
5200 ReadAlign(pS, pS->Tell() - nStart, 2);
5201 *pS >> nLanguageID;
5203 if (pBlockFlags[0] & 0x40)
5205 *pS >> nJustification;
5207 if (pBlockFlags[0] & 0x80) // font weight before font name
5209 ReadAlign(pS, pS->Tell() - nStart, 2);
5210 *pS >> nFontWeight;
5213 if (bFontName)
5214 lclReadCharArray( *pS, pFontName, nFontNameLen, pS->Tell() - nStart);
5216 ReadAlign(pS, pS->Tell() - nStart, 4);
5217 return(TRUE);
5220 void OCX_FontData::Import(uno::Reference< beans::XPropertySet > &rPropSet)
5222 uno::Any aTmp;
5223 if (pFontName)
5225 aTmp <<= lclCreateOUString( pFontName, nFontNameLen );
5226 rPropSet->setPropertyValue( WW8_ASCII2STR("FontName"), aTmp);
5229 if (bHasAlign)
5231 sal_Int16 nAlign = ImportAlign(nJustification);
5232 aTmp <<= nAlign;
5233 rPropSet->setPropertyValue( WW8_ASCII2STR("Align"), aTmp);
5236 if (fBold)
5238 aTmp <<= awt::FontWeight::BOLD;
5239 rPropSet->setPropertyValue( WW8_ASCII2STR("FontWeight"), aTmp);
5242 if (fItalic)
5244 aTmp <<= (sal_Int16)awt::FontSlant_ITALIC;
5245 rPropSet->setPropertyValue( WW8_ASCII2STR("FontSlant"), aTmp);
5248 if (fUnderline)
5250 aTmp <<= awt::FontUnderline::SINGLE;
5251 rPropSet->setPropertyValue( WW8_ASCII2STR("FontUnderline"), aTmp);
5254 if (fStrike)
5256 aTmp <<= awt::FontStrikeout::SINGLE;
5257 rPropSet->setPropertyValue( WW8_ASCII2STR("FontStrikeout"), aTmp);
5260 // 2004-09-17: very strange way of storing font sizes...
5261 // 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135
5262 // 8pt->165, 9pt->180, 10pt->195, 11pt->225, ...
5263 aTmp <<= sal_Int16( (nFontSize <= 30) ? 1 : ((nFontSize + 10) / 20) );
5264 rPropSet->setPropertyValue( WW8_ASCII2STR("FontHeight"), aTmp);
5267 sal_Bool OCX_FontData::Export(SvStorageStreamRef &rContent,
5268 const uno::Reference< beans::XPropertySet > &rPropSet)
5270 sal_uInt8 nFlags=0x00;
5271 sal_uInt32 nOldPos = rContent->Tell();
5272 rContent->SeekRel(8);
5273 SvxOcxString aFontName;
5274 uno::Any aTmp;
5276 if (bHasFont)
5277 aFontName = rPropSet->getPropertyValue(WW8_ASCII2STR("FontName"));
5278 if (!aFontName.HasData())
5279 aFontName = OUString( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) );
5280 aFontName.WriteLenField( *rContent );
5281 nFlags |= 0x01;
5283 if (bHasFont)
5285 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("FontWeight"));
5286 float nBold = 0;
5287 aTmp >>= nBold;
5289 if (nBold >= 150)
5291 nFlags |= 0x02;
5292 sal_uInt8 nTmp=0x01;
5293 *rContent << nTmp;
5294 nTmp=0x00;
5295 *rContent << nTmp;
5296 *rContent << nTmp;
5297 *rContent << nTmp;
5300 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("FontHeight"));
5301 float nFontHeight = 0;
5302 aTmp >>= nFontHeight;
5303 if (nFontHeight)
5305 nFlags |= 0x04;
5306 // 2004-09-17: very strange way of storing font sizes:
5307 // 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135
5308 // 8pt->165, 9pt->180, 10pt->195, 11pt->225, ...
5309 nFontSize = (nFontHeight == 1) ? 30 : (static_cast<sal_uInt32>((nFontHeight*4+1)/3)*15);
5310 *rContent << nFontSize;
5313 if (bHasAlign)
5315 *rContent << sal_uInt16(0x0200);
5316 nFlags |= 0x10;
5318 nFlags |= 0x20; // ?
5320 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Align"));
5321 nFlags |= 0x40;
5322 sal_Int16 nAlign(0);
5323 if (aTmp.hasValue())
5324 aTmp >>= nAlign;
5325 nJustification = ExportAlign(nAlign);
5326 *rContent << nJustification;
5330 aFontName.WriteCharArray( *rContent );
5331 WriteAlign(rContent,4);
5333 sal_uInt16 nFixedAreaLn = static_cast<sal_uInt16>(rContent->Tell()-nOldPos-4);
5334 rContent->Seek(nOldPos);
5335 *rContent << nStandardId;
5336 *rContent << nFixedAreaLn;
5337 *rContent << nFlags;
5338 *rContent << sal_uInt8(0x00);
5339 *rContent << sal_uInt8(0x00);
5340 *rContent << sal_uInt8(0x00);
5342 WriteAlign(rContent,4);
5343 return sal_True;
5346 // Doesn't really read anything but just skips the
5347 // record.
5348 sal_Bool OCX_TabStrip::Read(SotStorageStream *pS)
5350 const long skipLen = 0x18;
5351 *pS >> nIdentifier;
5352 DBG_ASSERT(nStandardId==nIdentifier,
5353 "A control that has a different identifier");
5354 *pS >> nFixedAreaLen;
5356 pS->Read(pBlockFlags, sizeof(pBlockFlags));
5357 pS->SeekRel(skipLen);
5358 *pS >> nNumTabs;
5359 // skip to end of control
5360 pS->SeekRel(nFixedAreaLen - sizeof(pBlockFlags) - sizeof(nNumTabs) - skipLen );
5361 return sal_True;
5364 sal_Bool OCX_TabStrip::ReadFontData(SotStorageStream *pS)
5366 // Seems like there is a real font record followed by
5367 // a number of blank records ( e.g. nFixedAreaLen = 0 )
5368 // The number of trailing blank records is equal to the number of tabs
5369 OCX_Control::ReadFontData(pS);
5370 for ( sal_uInt16 index = 0; index < nNumTabs; index++ )
5372 OCX_Control::Read(pS); // read trailing records
5374 return sal_True;
5377 sal_Bool OCX_Image::Read(SotStorageStream *pS)
5379 ULONG nStart = pS->Tell();
5380 *pS >> nIdentifier;
5381 DBG_ASSERT(nStandardId==nIdentifier,
5382 "A control that has a different identifier");
5383 *pS >> nFixedAreaLen;
5385 pS->Read(pBlockFlags, sizeof(pBlockFlags));
5387 bool hasEmbeddedImage = false;
5389 if ( pBlockFlags[0] & 0x04 )
5391 bAutoSize = true;
5393 if ( pBlockFlags[0] & 0x08 )
5395 *pS >> nBorderColor;
5397 if ( pBlockFlags[0] & 0x10 )
5399 *pS >> mnBackColor;
5401 if ( pBlockFlags[0] & 0x20 )
5403 *pS >> nBorderStyle;
5405 if ( pBlockFlags[0] & 0x40 )
5407 *pS >> nMousePointer;
5409 if ( pBlockFlags[0] & 0x80 )
5411 *pS >> nPictureSizeMode;
5414 if ( pBlockFlags[ 1 ] & 0x1 )
5416 *pS >> nSpecialEffect;
5418 // investigate if valid also for formcontrols, although for controls
5419 // images themselves seem to come through from escher ( as shape, think
5420 // its probably a preview? )
5422 // np a bit of a guess ( until proved incorrect )
5423 if ( pBlockFlags[ 1 ] & 0x4 )
5425 ReadAlign(pS, pS->Tell() - nStart, 2);
5426 hasEmbeddedImage = true;
5427 sal_uInt16 unknown;
5428 *pS >> unknown;
5432 if ( pBlockFlags[ 1 ] & 0x8 )
5434 ReadAlign(pS, pS->Tell() - nStart, 2);
5435 *pS >> nPictureAlignment;
5438 if ( pBlockFlags[ 1 ] & 0x10 )
5440 bPictureTiling = true;
5442 if ( pBlockFlags[1] & 0x20 )
5444 ReadAlign(pS, pS->Tell() - nStart, 4);
5445 sal_uInt8 nTemp;
5446 *pS >> nTemp;
5447 fEnabled = (nTemp&0x02)>>1;
5448 fBackStyle = (nTemp&0x08)>>3;
5449 // padding?
5450 *pS >> nTemp;
5451 *pS >> nTemp;
5452 *pS >> nTemp;
5454 ReadAlign(pS, pS->Tell() - nStart, 4);
5455 *pS >> nWidth;
5456 *pS >> nHeight;
5458 if ( hasEmbeddedImage )
5460 //image follows this block
5461 //len of image is 0x14 relative to end of this block
5462 pS->Seek( pS->Tell() + 0x14 );
5464 sal_uInt32 nImageLen = 0;
5465 *pS >> nImageLen;
5467 long imagePos = pS->Tell();
5469 mxGrfObj = lcl_readGraphicObject( pS );
5470 if( mxGrfObj.is() )
5472 sImageUrl = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
5473 sImageUrl = sImageUrl + mxGrfObj->getUniqueID();
5475 // make sure the stream position should be pointing after the image
5476 pS->Seek( imagePos + nImageLen );
5478 return sal_True;
5481 sal_Bool OCX_Image::Import( uno::Reference< beans::XPropertySet > &rPropSet )
5483 uno::Any aTmp(&sName,getCppuType((OUString *)0));
5484 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
5486 if( fBackStyle )
5487 aTmp <<= ImportColor(mnBackColor);
5488 else
5489 aTmp = uno::Any();
5490 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
5492 sal_Bool bTemp;
5493 if (fEnabled)
5494 bTemp = sal_True;
5495 else
5496 bTemp = sal_False;
5497 aTmp = bool2any(bTemp);
5498 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
5499 if ( sImageUrl.getLength() )
5501 aTmp <<= sImageUrl;
5502 rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
5504 return sal_True;
5507 sal_Bool OCX_Image::WriteContents(SvStorageStreamRef &rContents,
5508 const uno::Reference< beans::XPropertySet > &rPropSet,
5509 const awt::Size &rSize)
5511 sal_Bool bRet=sal_True;
5512 sal_uInt32 nOldPos = rContents->Tell();
5513 rContents->SeekRel(8);
5515 pBlockFlags[0] = 0;
5516 pBlockFlags[1] = 0x02;
5517 pBlockFlags[2] = 0;
5518 pBlockFlags[3] = 0;
5520 uno::Any aTmp = rPropSet->getPropertyValue(
5521 WW8_ASCII2STR("BackgroundColor"));
5522 if (aTmp.hasValue())
5523 aTmp >>= mnBackColor;
5524 *rContents << ExportColor(mnBackColor);
5525 pBlockFlags[0] |= 0x10;
5528 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
5529 sal_Int16 nBorder = sal_Int16();
5530 aTmp >>= nBorder;
5531 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
5532 *rContents << nBorderStyle;
5533 pBlockFlags[0] |= 0x20;
5535 *rContents << nSpecialEffect;
5536 pBlockFlags[1] |= 0x01;
5538 WriteAlign(rContents,4);
5540 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
5541 fEnabled = any2bool(aTmp);
5542 if (fEnabled)
5544 sal_uInt8 nTemp = 0x19;
5545 *rContents << nTemp;
5546 pBlockFlags[1] |= 0x20;
5547 *rContents << sal_uInt8(0x00);
5548 *rContents << sal_uInt8(0x00);
5549 *rContents << sal_uInt8(0x00);
5552 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ImageURL"));
5553 // OUString *pStr = (OUString *)aTmp.getValue();
5554 /*Magically fetch that image and turn it into something that
5555 *we can store in ms controls, wmf,png,jpg are almost certainly
5556 *the options we have for export...*/
5558 WriteAlign(rContents,4);
5559 *rContents << rSize.Width;
5560 *rContents << rSize.Height;
5562 WriteAlign(rContents,4);
5563 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
5565 rContents->Seek(nOldPos);
5566 *rContents << nStandardId;
5567 *rContents << nFixedAreaLen;
5569 *rContents << pBlockFlags[0];
5570 *rContents << pBlockFlags[1];
5571 *rContents << pBlockFlags[2];
5572 *rContents << pBlockFlags[3];
5573 DBG_ASSERT((rContents.Is() &&
5574 (SVSTREAM_OK==rContents->GetError())),"damn");
5575 return bRet;
5579 sal_Bool OCX_Image::Export(SvStorageRef &rObj,
5580 const uno::Reference< beans::XPropertySet > &rPropSet,
5581 const awt::Size &rSize)
5583 static sal_uInt8 __READONLY_DATA aCompObj[] = {
5584 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5585 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
5586 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
5587 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
5588 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5589 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5590 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
5591 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
5592 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
5593 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
5594 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
5595 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
5596 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
5597 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5601 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
5602 xStor->Write(aCompObj,sizeof(aCompObj));
5603 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
5607 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
5608 xStor3->Write(aObjInfo,sizeof(aObjInfo));
5609 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
5612 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
5613 0x49, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x67, 0x00,
5614 0x65, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
5618 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
5619 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
5620 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
5623 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
5624 return WriteContents(xContents, rPropSet, rSize);
5627 // ============================================================================
5629 OCX_SpinButton::OCX_SpinButton() :
5630 OCX_Control( OUString( RTL_CONSTASCII_USTRINGPARAM( "SpinButton" ) ) ),
5631 mnBlockFlags( 0 ),
5632 mnValue( 0 ),
5633 mnMin( 0 ),
5634 mnMax( 100 ),
5635 mnSmallStep( 1 ),
5636 mnPageStep( 1 ),
5637 mnOrient( -1 ),
5638 mnDelay( 50 ),
5639 mbEnabled( true ),
5640 mbLocked( false ),
5641 mbPropThumb( true )
5643 msFormType = C2U("com.sun.star.form.component.SpinButton");
5644 msDialogType = C2U("com.sun.star.form.component.SpinButton");
5645 mnBackColor = 0x8000000F;
5646 mnForeColor = 0x80000012;
5649 OCX_Control* OCX_SpinButton::Create()
5651 return new OCX_SpinButton;
5654 sal_Bool OCX_SpinButton::Read( SvStorageStream *pS )
5656 if( !pS ) return sal_False;
5658 SvStream& rStrm = *pS;
5659 sal_uInt16 nId, nSize;
5660 sal_Int32 nIcon = 0;
5662 rStrm >> nId >> nSize >> mnBlockFlags;
5664 DBG_ASSERT( nStandardId == nId, "OCX_SpinButton::Read - unknown identifier" );
5666 if( mnBlockFlags & 0x00000001 ) rStrm >> mnForeColor;
5667 if( mnBlockFlags & 0x00000002 ) rStrm >> mnBackColor;
5668 if( mnBlockFlags & 0x00000004 )
5670 sal_Int32 nFlags;
5671 rStrm >> nFlags;
5672 mbEnabled = (nFlags & 0x00000002) != 0;
5673 mbLocked = (nFlags & 0x00000004) != 0;
5675 if( mnBlockFlags & 0x00000010 ) rStrm.SeekRel( 4 ); // mouse pointer
5676 if( mnBlockFlags & 0x00000020 ) rStrm >> mnMin;
5677 if( mnBlockFlags & 0x00000040 ) rStrm >> mnMax;
5678 if( mnBlockFlags & 0x00000080 ) rStrm >> mnValue;
5679 if( mnBlockFlags & 0x00000100 ) rStrm.SeekRel( 4 ); // unknown
5680 if( mnBlockFlags & 0x00000200 ) rStrm.SeekRel( 4 ); // unknown
5681 if( mnBlockFlags & 0x00000400 ) rStrm >> mnSmallStep;
5682 if( mnBlockFlags & 0x00000800 ) rStrm.SeekRel( 4 ); // unknown
5683 if( mnBlockFlags & 0x00001000 ) rStrm >> mnPageStep;
5684 if( mnBlockFlags & 0x00002000 ) rStrm >> mnOrient;
5685 if( mnBlockFlags & 0x00004000 )
5687 sal_Int32 nThumb;
5688 *pS >> nThumb;
5689 mbPropThumb = nThumb != 0;
5691 if( mnBlockFlags & 0x00008000 ) rStrm >> mnDelay;
5692 if( mnBlockFlags & 0x00010000 ) rStrm >> nIcon;
5693 if( mnBlockFlags & 0x00000008 ) rStrm >> nWidth >> nHeight;
5695 if( nIcon )
5697 sal_Int32 nIconSize;
5698 pS->SeekRel( 20 );
5699 *pS >> nIconSize;
5700 pS->SeekRel( nIconSize );
5703 return sal_True;
5706 sal_Bool OCX_SpinButton::ReadFontData( SvStorageStream* /* pS */ )
5708 // spin buttons and scroll bars do not support font data
5709 return sal_True;
5712 sal_Bool OCX_SpinButton::Import(com::sun::star::uno::Reference<
5713 com::sun::star::beans::XPropertySet> &rPropSet)
5715 if( (nWidth < 1) || (nHeight < 1) )
5716 return sal_False;
5718 uno::Any aTmp( &sName, getCppuType((OUString *)0) );
5719 rPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
5721 aTmp <<= ImportColor( mnForeColor );
5722 rPropSet->setPropertyValue( WW8_ASCII2STR("SymbolColor"), aTmp);
5724 aTmp <<= ImportColor( mnBackColor );
5725 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
5727 aTmp = bool2any( mbEnabled && !mbLocked );
5728 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
5730 aTmp <<= mnValue;
5731 if ( bSetInDialog )
5733 rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValue"), aTmp );
5735 else
5737 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultSpinValue"), aTmp );
5740 aTmp <<= mnMin;
5741 rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValueMin"), aTmp );
5743 aTmp <<= mnMax;
5744 rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValueMax"), aTmp );
5746 aTmp <<= mnSmallStep;
5747 rPropSet->setPropertyValue( WW8_ASCII2STR("SpinIncrement"), aTmp );
5749 namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
5750 switch( mnOrient )
5752 case 0: aTmp <<= AwtScrollOrient::VERTICAL; break;
5753 case 1: aTmp <<= AwtScrollOrient::HORIZONTAL; break;
5754 default: aTmp <<= (nWidth < nHeight) ? AwtScrollOrient::VERTICAL : AwtScrollOrient::HORIZONTAL;
5756 rPropSet->setPropertyValue( WW8_ASCII2STR("Orientation"), aTmp );
5758 aTmp = bool2any( true );
5759 rPropSet->setPropertyValue( WW8_ASCII2STR("Repeat"), aTmp );
5761 aTmp <<= mnDelay;
5762 rPropSet->setPropertyValue( WW8_ASCII2STR("RepeatDelay"), aTmp );
5764 aTmp <<= sal_Int16( 0 );
5765 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
5767 uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
5768 lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
5770 return sal_True;
5773 sal_Bool OCX_SpinButton::Export(
5774 SvStorageRef &rObj,
5775 const uno::Reference< beans::XPropertySet>& rPropSet,
5776 const awt::Size& rSize )
5778 static sal_uInt8 __READONLY_DATA aCompObj[] =
5780 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5781 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
5782 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
5783 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
5784 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5785 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5786 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
5787 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
5788 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
5789 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
5790 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
5791 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
5792 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
5793 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5794 0x00, 0x00
5798 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
5799 xStor->Write(aCompObj,sizeof(aCompObj));
5800 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
5804 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
5805 xStor3->Write(aObjInfo,sizeof(aObjInfo));
5806 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
5809 static sal_uInt8 __READONLY_DATA aOCXNAME[] =
5811 0x53, 0x00, 0x70, 0x00, 0x69, 0x00, 0x6E, 0x00,
5812 0x42, 0x00, 0x75, 0x00, 0x74, 0x00, 0x74, 0x00,
5813 0x6F, 0x00, 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00,
5814 0x00, 0x00
5818 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
5819 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
5820 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
5823 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
5824 return WriteContents(xContents, rPropSet, rSize);
5827 sal_Bool OCX_SpinButton::WriteContents(
5828 SvStorageStreamRef &rObj,
5829 const uno::Reference< beans::XPropertySet> &rPropSet,
5830 const awt::Size& rSize )
5832 if( !rObj.Is() )
5833 return sal_False;
5835 mnBlockFlags = 0x00000008;
5836 nWidth = rSize.Width;
5837 nHeight = rSize.Height;
5839 GetInt32Property( mnForeColor, rPropSet, WW8_ASCII2STR( "SymbolColor" ), 0x00000001 );
5840 GetInt32Property( mnBackColor, rPropSet, WW8_ASCII2STR( "BackgroundColor" ), 0x00000002 );
5841 GetBoolProperty( mbEnabled, rPropSet, WW8_ASCII2STR( "Enabled" ), 0x00000304 );
5842 GetInt32Property( mnMin, rPropSet, WW8_ASCII2STR( "SpinValueMin" ), 0x00000020 );
5843 GetInt32Property( mnMax, rPropSet, WW8_ASCII2STR( "SpinValueMax" ), 0x00000040 );
5844 GetInt32Property( mnValue, rPropSet, WW8_ASCII2STR( "SpinValue" ), 0x00000080 );
5845 GetInt32Property( mnSmallStep, rPropSet, WW8_ASCII2STR( "SpinIncrement" ), 0x00000800 );
5846 GetInt32Property( mnDelay, rPropSet, WW8_ASCII2STR( "RepeatDelay" ), 0x00008000 );
5848 namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
5849 sal_Int16 nApiOrient = sal_Int16();
5850 if( rPropSet->getPropertyValue( WW8_ASCII2STR( "Orientation" ) ) >>= nApiOrient )
5851 UpdateInt32Property( mnOrient, (nApiOrient == AwtScrollOrient::VERTICAL) ? 0 : 1, 0x00002000 );
5853 return WriteData( *rObj );
5856 void OCX_SpinButton::UpdateInt32Property(
5857 sal_Int32& rnCoreValue, sal_Int32 nNewValue, sal_Int32 nBlockFlag )
5859 if( nNewValue != rnCoreValue )
5861 rnCoreValue = nNewValue;
5862 mnBlockFlags |= nBlockFlag;
5866 void OCX_SpinButton::GetInt32Property(
5867 sal_Int32& rnCoreValue, const uno::Reference< beans::XPropertySet>& rxPropSet,
5868 const OUString& rPropName, sal_Int32 nBlockFlag )
5870 sal_Int32 nNewValue = 0;
5871 if( rxPropSet->getPropertyValue( rPropName ) >>= nNewValue )
5872 UpdateInt32Property( rnCoreValue, nNewValue, nBlockFlag );
5875 void OCX_SpinButton::UpdateBoolProperty(
5876 bool& rbCoreValue, bool bNewValue, sal_Int32 nBlockFlag )
5878 if( bNewValue != rbCoreValue )
5880 rbCoreValue = bNewValue;
5881 mnBlockFlags |= nBlockFlag;
5885 void OCX_SpinButton::GetBoolProperty(
5886 bool& rbCoreValue, const uno::Reference< beans::XPropertySet>& rxPropSet,
5887 const OUString& rPropName, sal_Int32 nBlockFlag )
5889 UpdateBoolProperty( rbCoreValue,
5890 any2bool( rxPropSet->getPropertyValue( rPropName ) ), nBlockFlag );
5893 sal_Bool OCX_SpinButton::WriteData( SvStream& rStrm ) const
5895 sal_Bool bRet = sal_True;
5896 ULONG nStartPos = rStrm.Tell();
5898 rStrm << sal_Int32( 0 ) << mnBlockFlags;
5900 if( mnBlockFlags & 0x00000001 ) rStrm << ExportColor( mnForeColor );
5901 if( mnBlockFlags & 0x00000002 ) rStrm << ExportColor( mnBackColor );
5902 if( mnBlockFlags & 0x00000004 )
5904 sal_Int32 nFlags = 0x00000019; // always set
5905 if( mbEnabled ) nFlags |= 0x00000002;
5906 if( mbLocked ) nFlags |= 0x00000004;
5907 rStrm << nFlags;
5909 if( mnBlockFlags & 0x00000020 ) rStrm << mnMin;
5910 if( mnBlockFlags & 0x00000040 ) rStrm << mnMax;
5911 if( mnBlockFlags & 0x00000080 ) rStrm << mnValue;
5912 if( mnBlockFlags & 0x00000100 ) rStrm << sal_Int32( 0 ); // unknown
5913 if( mnBlockFlags & 0x00000200 ) rStrm << sal_Int32( 0 ); // unknown
5914 if( mnBlockFlags & 0x00000400 ) rStrm << sal_Int32( 0 ); // unknown
5915 if( mnBlockFlags & 0x00000800 ) rStrm << mnSmallStep;
5916 if( mnBlockFlags & 0x00001000 ) rStrm << mnPageStep;
5917 if( mnBlockFlags & 0x00002000 ) rStrm << mnOrient;
5918 if( mnBlockFlags & 0x00004000 ) rStrm << sal_Int32( mbPropThumb ? 1 : 0 );
5919 if( mnBlockFlags & 0x00008000 ) rStrm << mnDelay;
5920 if( mnBlockFlags & 0x00000008 ) rStrm << nWidth << nHeight;
5922 sal_uInt16 nSize = static_cast< sal_uInt16 >( rStrm.Tell() - nStartPos - 4 );
5923 rStrm.Seek( nStartPos );
5924 rStrm << nStandardId << nSize;
5926 DBG_ASSERT( rStrm.GetError() == SVSTREAM_OK, "OCX_SpinButton::WriteData - error in stream" );
5927 return bRet;
5930 // ============================================================================
5932 OCX_ScrollBar::OCX_ScrollBar()
5934 sName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollBar" ) );
5935 mnMax = 32767;
5936 msFormType = C2U("com.sun.star.form.component.ScrollBar");
5937 msDialogType = C2U("com.sun.star.form.component.ScrollBar");
5941 OCX_Control* OCX_ScrollBar::Create()
5943 return new OCX_ScrollBar;
5946 sal_Bool OCX_ScrollBar::Import(com::sun::star::uno::Reference<
5947 com::sun::star::beans::XPropertySet> &rPropSet)
5949 if( (nWidth < 1) || (nHeight < 1) )
5950 return sal_False;
5952 uno::Any aTmp( &sName, getCppuType((OUString *)0) );
5953 rPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
5955 aTmp <<= ImportColor( mnForeColor );
5956 rPropSet->setPropertyValue( WW8_ASCII2STR("SymbolColor"), aTmp);
5958 aTmp <<= ImportColor( mnBackColor );
5959 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
5961 aTmp = bool2any( mbEnabled && !mbLocked );
5962 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
5964 aTmp <<= mnValue;
5965 if ( bSetInDialog )
5967 rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValue"), aTmp );
5969 else
5971 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultScrollValue"), aTmp );
5974 aTmp <<= mnMin;
5975 rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValueMin"), aTmp );
5977 aTmp <<= mnMax;
5978 rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValueMax"), aTmp );
5980 aTmp <<= mnSmallStep;
5981 rPropSet->setPropertyValue( WW8_ASCII2STR("LineIncrement"), aTmp );
5983 aTmp <<= mnPageStep;
5984 rPropSet->setPropertyValue( WW8_ASCII2STR("BlockIncrement"), aTmp );
5985 if( mbPropThumb && (mnPageStep > 0) )
5986 rPropSet->setPropertyValue( WW8_ASCII2STR("VisibleSize"), aTmp );
5988 namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
5989 switch( mnOrient )
5991 case 0: aTmp <<= AwtScrollOrient::VERTICAL; break;
5992 case 1: aTmp <<= AwtScrollOrient::HORIZONTAL; break;
5993 default: aTmp <<= (nWidth < nHeight) ? AwtScrollOrient::VERTICAL : AwtScrollOrient::HORIZONTAL;
5995 rPropSet->setPropertyValue( WW8_ASCII2STR("Orientation"), aTmp );
5997 aTmp <<= mnDelay;
5998 rPropSet->setPropertyValue( WW8_ASCII2STR("RepeatDelay"), aTmp );
6000 aTmp <<= sal_Int16( 0 );
6001 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
6003 uno::Reference< frame::XModel > xModel ( pDocSh ? pDocSh->GetModel() : NULL );
6004 lcl_ApplyListSourceAndBindableStuff( xModel, rPropSet, msCtrlSource, msRowSource );
6006 return sal_True;
6009 sal_Bool OCX_ScrollBar::Export(
6010 SvStorageRef &rObj,
6011 const uno::Reference< beans::XPropertySet>& rPropSet,
6012 const awt::Size& rSize )
6014 static sal_uInt8 __READONLY_DATA aCompObj[] =
6016 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
6017 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
6018 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
6019 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
6020 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
6021 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
6022 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
6023 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
6024 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
6025 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
6026 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
6027 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
6028 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
6029 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
6030 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
6034 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
6035 xStor->Write(aCompObj,sizeof(aCompObj));
6036 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
6040 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
6041 xStor3->Write(aObjInfo,sizeof(aObjInfo));
6042 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
6045 static sal_uInt8 __READONLY_DATA aOCXNAME[] =
6047 0x53, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6F, 0x00,
6048 0x6C, 0x00, 0x6C, 0x00, 0x42, 0x00, 0x61, 0x00,
6049 0x72, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
6053 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
6054 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
6055 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
6058 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
6059 return WriteContents(xContents, rPropSet, rSize);
6062 sal_Bool OCX_ScrollBar::WriteContents(
6063 SvStorageStreamRef &rObj,
6064 const uno::Reference< beans::XPropertySet> &rPropSet,
6065 const awt::Size& rSize )
6067 if( !rObj.Is() )
6068 return sal_False;
6070 mnBlockFlags = 0x00000008;
6071 nWidth = rSize.Width;
6072 nHeight = rSize.Height;
6074 GetInt32Property( mnForeColor, rPropSet, WW8_ASCII2STR( "SymbolColor" ), 0x00000001 );
6075 GetInt32Property( mnBackColor, rPropSet, WW8_ASCII2STR( "BackgroundColor" ), 0x00000002 );
6076 GetBoolProperty( mbEnabled, rPropSet, WW8_ASCII2STR( "Enabled" ), 0x00000304 );
6077 GetInt32Property( mnMin, rPropSet, WW8_ASCII2STR( "ScrollValueMin" ), 0x00000020 );
6078 GetInt32Property( mnMax, rPropSet, WW8_ASCII2STR( "ScrollValueMax" ), 0x00000040 );
6079 GetInt32Property( mnValue, rPropSet, WW8_ASCII2STR( "ScrollValue" ), 0x00000080 );
6080 GetInt32Property( mnSmallStep, rPropSet, WW8_ASCII2STR( "LineIncrement" ), 0x00000800 );
6081 GetInt32Property( mnPageStep, rPropSet, WW8_ASCII2STR( "BlockIncrement" ), 0x00001000 );
6082 GetInt32Property( mnDelay, rPropSet, WW8_ASCII2STR( "RepeatDelay" ), 0x00008000 );
6084 namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
6085 sal_Int16 nApiOrient = sal_Int16();
6086 if( rPropSet->getPropertyValue( WW8_ASCII2STR( "Orientation" ) ) >>= nApiOrient )
6087 UpdateInt32Property( mnOrient, (nApiOrient == AwtScrollOrient::VERTICAL) ? 0 : 1, 0x00002000 );
6089 UpdateBoolProperty( mbPropThumb, true, 0x00004000 );
6091 return WriteData( *rObj );
6094 OCX_ProgressBar::OCX_ProgressBar() :
6095 OCX_Control( OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressBar" ) ) ),
6096 nMin( 0 ),
6097 nMax( 0 ),
6098 bFixedSingle(true),
6099 bEnabled( true ),
6100 b3d( true )
6102 msDialogType = C2U("com.sun.star.awt.UnoControlProgressBarModel");
6103 bSetInDialog = true;
6106 sal_Bool OCX_ProgressBar::Read( SvStorageStream *pS )
6108 pS->SeekRel( 8 );
6109 *pS >> nWidth >> nHeight;
6110 pS->SeekRel( 12 );
6112 float fMin, fMax;
6113 *pS >> fMin >> fMax;
6114 nMin = static_cast< sal_Int32 >( fMin );
6115 nMax = static_cast< sal_Int32 >( fMax );
6116 bool bVisible = true;
6117 sal_uInt8 pUnknownFlags[4];
6118 pS->Read(pUnknownFlags,4);
6120 // complete guess, but we don't handle visible anyway
6121 if ( ( pUnknownFlags[2] & 0x8 ) && ( pUnknownFlags[2] & 0x2 ) )
6122 bVisible = false;
6124 sal_uInt32 nFlags;
6125 *pS >> nFlags;
6127 // seems these work out
6128 bFixedSingle = (nFlags & 0x01) != 0;
6129 bEnabled = (nFlags & 0x02) != 0;
6130 b3d = (nFlags & 0x04) != 0;
6132 return true;
6135 OCX_Control* OCX_ProgressBar::Create()
6137 return new OCX_ProgressBar;
6140 sal_Bool OCX_ProgressBar::Import(uno::Reference< beans::XPropertySet > &rPropSet)
6142 uno::Any aTmp(&sName,getCppuType((OUString *)0));
6143 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
6144 aTmp <<= nMax;
6145 rPropSet->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp );
6146 aTmp <<= nMin;
6147 rPropSet->setPropertyValue( WW8_ASCII2STR("ProgressValueMin"), aTmp );
6149 if ( !bEnabled )
6150 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), uno::makeAny( sal_False ) );
6151 return sal_True;
6153 // ============================================================================
6158 sal_Bool HTML_TextBox::Import(com::sun::star::uno::Reference<
6159 com::sun::star::beans::XPropertySet> &rPropSet)
6161 uno::Any aTmp(&sName,getCppuType((OUString *)0));
6162 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
6164 aTmp = bool2any( fEnabled != 0 );
6165 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
6167 aTmp = bool2any( fLocked != 0 );
6168 rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
6170 aTmp = bool2any( fHideSelection != 0 );
6171 rPropSet->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp);
6173 aTmp <<= ImportColor(mnForeColor);
6174 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
6176 aTmp <<= ImportColor(mnBackColor);
6177 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
6179 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
6180 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
6182 aTmp <<= ImportColor( nBorderColor );
6183 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
6185 aTmp = bool2any( fMultiLine != 0 );
6186 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
6188 sal_uInt16 nTmp = static_cast<sal_uInt16>(nMaxLength);
6189 aTmp <<= nTmp;
6190 rPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);
6193 sal_Bool bTemp1,bTemp2;
6194 uno::Any aBarsH,aBarsV;
6195 switch(nScrollBars)
6197 case 1:
6198 bTemp1 = sal_True;
6199 bTemp2 = sal_False;
6200 break;
6201 case 2:
6202 bTemp1 = sal_False;
6203 bTemp2 = sal_True;
6204 break;
6205 case 3:
6206 bTemp1 = sal_True;
6207 bTemp2 = sal_True;
6208 break;
6209 case 0:
6210 default:
6211 bTemp1 = sal_False;
6212 bTemp2 = sal_False;
6213 break;
6216 aBarsH = bool2any(bTemp1);
6217 aBarsV = bool2any(bTemp2);
6218 rPropSet->setPropertyValue( WW8_ASCII2STR("HScroll"), aBarsH);
6219 rPropSet->setPropertyValue( WW8_ASCII2STR("VScroll"), aBarsV);
6221 nTmp = nPasswordChar;
6222 aTmp <<= nTmp;
6223 rPropSet->setPropertyValue( WW8_ASCII2STR("EchoChar"), aTmp);
6225 if (pValue)
6227 aTmp <<= lclCreateOUString( pValue, nValueLen );
6228 // DefaultText seems to no longer be in UnoEditControlModel
6229 if ( bSetInDialog )
6231 rPropSet->setPropertyValue( WW8_ASCII2STR("Text"), aTmp);
6233 else
6235 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
6239 // aFontData.Import(rPropSet);
6240 return sal_True;
6243 sal_Bool HTML_TextBox::Read(SotStorageStream *pS)
6245 return sal_True;
6248 sal_Bool HTML_TextBox::ReadFontData(SotStorageStream *pS)
6250 return sal_True;
6254 /* vi:set tabstop=4 shiftwidth=4 expandtab: */