1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26
27 #include <com/sun/star/uno/Any.h>
28 #include <com/sun/star/text/VertOrientation.hpp>
29 #include <com/sun/star/text/XText.hpp>
30 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HDL_
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #endif
33 #include <com/sun/star/text/TextContentAnchorType.hpp>
34 #include <com/sun/star/drawing/XShape.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/drawing/XDrawPage.hpp>
37 #include <com/sun/star/drawing/XShapes.hpp>
38 #include <com/sun/star/drawing/XControlShape.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/container/XIndexContainer.hpp>
41 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
42 #include <com/sun/star/form/XFormsSupplier.hpp>
43 #include <com/sun/star/form/XForm.hpp>
44 #include <com/sun/star/form/FormComponentType.hpp>
45 #include <com/sun/star/awt/FontWeight.hpp>
46 #include <com/sun/star/awt/FontSlant.hpp>
47 #include <com/sun/star/awt/FontUnderline.hpp>
48 #include <com/sun/star/awt/FontStrikeout.hpp>
49 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
50 #include <com/sun/star/style/VerticalAlignment.hpp>
51 #include <comphelper/extract.hxx>
52 #include <com/sun/star/awt/XControlModel.hpp>
53 #include <com/sun/star/io/XInputStreamProvider.hpp>
54 #include <rtl/ustrbuf.hxx>
55 #include <vcl/svapp.hxx>
56 #include <sfx2/objsh.hxx>
57 #include <xmlscript/xmldlg_imexp.hxx>
58 #include <filter/msfilter/msocximex.hxx>
59 #include <osl/file.hxx>
60 #include <unotools/ucbstreamhelper.hxx>
61 #include <com/sun/star/embed/XStorage.hpp>
62 #include <com/sun/star/embed/XTransactedObject.hpp>
63 #include <com/sun/star/embed/ElementModes.hpp>
64 #include <comphelper/processfactory.hxx> // shouldn't be needed
65 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
66 #include <algorithm>
67 #include <memory>
68
69 #ifndef C2S
70 #define C2S(cChar) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(cChar))
71 #endif
72 #ifndef C2U
73 #define C2U(cChar) rtl::OUString::createFromAscii(cChar)
74 #endif
75
76 using namespace ::com::sun::star;
77 using namespace ::rtl;
78 using namespace cppu;
79
80
81 #define WW8_ASCII2STR(s) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(s))
82
83
84 static char sWW8_form[] = "WW-Standard";
85
86
87 struct SortOrderByTabPos
88 {
operator ()SortOrderByTabPos89 bool operator()( const OCX_Control* a, const OCX_Control* b )
90 {
91 return a->mnTabPos < b->mnTabPos;
92 }
93 };
94
95
96 sal_uInt8 __READONLY_DATA OCX_Control::aObjInfo[4] = { 0x00, 0x12, 0x03, 0x00 };
97
ReadAlign(SvStorageStream * pS,long nPos,int nAmount)98 long ReadAlign(SvStorageStream *pS, long nPos, int nAmount)
99 {
100 if (long nAlign = nPos % nAmount)
101 {
102
103 long nLen = nAmount - nAlign;
104 pS->SeekRel(nLen);
105 return nLen;
106 }
107 return 0;
108 }
109
110
111 // NP - Images in controls in OO2.0/SO8 exist as links, e.g. they are not part of the document so are
112 // referenced externally. On import from ms document try to save images for controls here.
113 // Images are stored in directory called temp in the user installation directory. Next version of OO/SO
114 // hopefully will address this issue and allow a choice e.g. images for controls to be stored as links
115 // or embedded in the document.
116
117 // [out]location path to the stream to where the image is to be stored,
118 // if same name exists in folder then this function calculates a new name
119 // [in] data raw bytes of image to be stored.
120 // [in] dataLen no. byte to be stored
121 //
122 // returns, true if successful
123
storePictureInFileSystem(OUString & location,sal_uInt8 * data,sal_uInt32 dataLen)124 bool storePictureInFileSystem( OUString& location, sal_uInt8* data, sal_uInt32 dataLen )
125 {
126 bool result = true;
127 OUString origPath = location;
128 try
129 {
130 uno::Reference<lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(),
131 uno::UNO_QUERY_THROW );
132 uno::Reference< com::sun::star::ucb::XSimpleFileAccess> xSFA( xMSF->createInstance(
133 OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess") ),
134 uno::UNO_QUERY_THROW );
135 OUString ext;
136 sal_Int32 index = 0;
137 while ( xSFA->exists( location ) )
138 {
139 ext = OUString::valueOf( ++index );
140 location = origPath + ext;
141 }
142
143 SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( location, STREAM_WRITE | STREAM_TRUNC );
144 if ( pStream )
145 {
146 pStream->Write(data, dataLen);
147 delete pStream;
148 }
149 else
150 {
151 result = false;
152 }
153 }
154 catch( uno::Exception& )
155 {
156 result = false;
157 }
158 return result;
159 }
160
161 // NP - Images in controls in OO2.0/SO8 exist as links, e.g. they are not part of the document so are
162 // referenced externally. On import from ms document try to save images from controls here so this
163 // at least a macro programmer has a chance to accessed them manually later. Next version of OO/SO
164 // hopefully will address this issue.
165 // Images will be stored in a top level folder in the document package, folder is named "MigratedImages"
166
167 // [in] pDocSh* the document shell.
168 // [in] name name of stream image to stored in.
169 // [in] data raw bytes of image to be stored.
170 // [in] dataLen no. byte to be stored
171
storePictureInDoc(SfxObjectShell * pDocSh,OUString & name,sal_uInt8 * data,sal_uInt32 dataLen)172 bool storePictureInDoc( SfxObjectShell* pDocSh, OUString& name, sal_uInt8* data, sal_uInt32 dataLen )
173 {
174 uno::Reference < embed::XStorage > xStor;
175 if (pDocSh)
176 {
177 xStor = pDocSh->GetStorage();
178 if( xStor.is() )
179 {
180 try
181 {
182 uno::Reference< embed::XStorage > xPictures = xStor->openStorageElement(
183 OUString( RTL_CONSTASCII_USTRINGPARAM( "MigratedImages" ) ),
184 embed::ElementModes::READWRITE );
185 uno::Reference< beans::XPropertySet > xPropSet( xPictures, uno::UNO_QUERY );
186
187 // Set media type of folder MigratedImages to something ( that is unknown ) so that
188 // it will get copied to exported OO/SO format after SaveAs
189 if ( xPropSet.is() )
190 {
191 OUString aMediaType = C2U("MigrationImages");
192 uno::Any a;
193 a <<= aMediaType;
194 xPropSet->setPropertyValue( C2U("MediaType"), a );
195 }
196
197 uno::Reference< io::XStream > xObjReplStr = xPictures->openStreamElement(
198 name,
199 embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
200 uno::Reference< io::XOutputStream > xOutStream( xObjReplStr->getOutputStream(), uno::UNO_QUERY_THROW );
201 uno::Sequence< sal_Int8 > imageBytes( (sal_Int8*)data, dataLen );
202 xOutStream->writeBytes( imageBytes );
203 xOutStream->closeOutput();
204
205 uno::Reference< embed::XTransactedObject > xTransact( xPictures, uno::UNO_QUERY );
206 if ( xTransact.is() )
207 {
208 xTransact->commit();
209 }
210 }
211 catch( uno::Exception& )
212 {
213 return false;
214 }
215
216 }
217 else
218 {
219 // no storage something wrong
220 return false;
221 }
222 }
223 else
224 {
225 //No doc shell
226 return false;
227 }
228 return true;
229 }
230
WriteAlign(SvStorageStream * pS,int nAmount)231 long WriteAlign(SvStorageStream *pS, int nAmount)
232 {
233 if (long nAlign = pS->Tell() % nAmount)
234 {
235 long nLen = nAmount - nAlign;
236 for (long i=0; i< nLen; ++i)
237 *pS << sal_uInt8(0x00);
238 return nLen;
239 }
240 return 0;
241 }
242 // string import/export =======================================================
243 /** #117832# import of form control names
244 * control name is located in stream ("\3OCXNAME")
245 * a strings in "\3OCXNAME" stream seem to be terminated by 4 trailing bytes of 0's.
246 * ====
247 * Note: If the string in the stream is overwritten by a shorter string
248 * some characters from the original string may remain, the new string however
249 * will still be terminated in the same way e.g. by 4 bytes with value 0.
250 */
251
writeOCXNAME(const OUString & sOCXName,SvStorageStream * pStream)252 bool writeOCXNAME( const OUString& sOCXName, SvStorageStream* pStream )
253 {
254 const sal_Unicode* buffer = sOCXName.getStr();
255 for ( sal_Int32 index=0; index < sOCXName.getLength(); index++ )
256 {
257 sal_uInt16 ch = static_cast< sal_uInt16 >( buffer[ index ] );
258 *pStream << ch;
259 }
260 // write
261 *pStream << sal_uInt32(0);
262 return ( SVSTREAM_OK == pStream->GetError() );
263
264 }
265
readOCXNAME(OUString & sCName,SvStorageStream * pStream)266 bool readOCXNAME( OUString& sCName, SvStorageStream* pStream )
267 {
268 /*
269 * Read uniCode until no data or 0 encountered
270 */
271 OUStringBuffer buf(40);
272 do
273 {
274 sal_uInt16 ch = 0;
275 *pStream >> ch;
276 sal_Unicode uni = static_cast< sal_Unicode >( ch );
277 if ( uni == 0 )
278 {
279 break;
280 }
281 buf.append( &uni, 1 );
282
283 } while ( !pStream->IsEof() );
284
285 sCName = buf.makeStringAndClear();
286 return ( SVSTREAM_OK == pStream->GetError() );
287 }
288
289
290 /* #110435# (DR, 2003-11-12) ** Import of Unicode strings in form controls **
291
292 Strings may be stored either as compressed or uncompressed Unicode
293 character array. There are no encoded byte strings anywhere.
294
295 The string length field stores the length of the character array (not the
296 character count of the string) in the lower 31 bits, and the compression
297 state in the highest bit.
298
299 A set bit means the character array is compressed. This means all Unicode
300 characters are <=0xFF. Therefore the high bytes of all characters are left
301 out, and the character array size is equal to the string length.
302
303 A cleared bit means the character array is not compressed. The buffer
304 contains Little-Endian Unicode characters, and the resulting string length
305 is half the buffer size.
306
307 TODO: This implementation of the new string import is a hack to keep
308 msocximex.hxx unchanged. A better implementation would replace the char*
309 members of all classes by something more reasonable.
310 */
311
312 namespace {
313
314 const sal_uInt32 SVX_MSOCX_SIZEMASK = 0x7FFFFFFF; /// Mask for character buffer size.
315 const sal_uInt32 SVX_MSOCX_COMPRESSED = 0x80000000; /// 1 = compressed Unicode array.
316
317
318 /** Returns true, if the passed length field specifies a compressed character array.
319 */
lclIsCompressed(sal_uInt32 nLenFld)320 inline bool lclIsCompressed( sal_uInt32 nLenFld )
321 {
322 return (nLenFld & SVX_MSOCX_COMPRESSED) != 0;
323 }
324
325
326 /** Extracts and returns the memory size of the character buffer.
327 @return Character buffer size (may differ from resulting string length!).
328 */
lclGetBufferSize(sal_uInt32 nLenFld)329 inline sal_uInt32 lclGetBufferSize( sal_uInt32 nLenFld )
330 {
331 return nLenFld & SVX_MSOCX_SIZEMASK;
332 }
333
334
335 // import ---------------------------------------------------------------------
336
337 /** Reads the character array of a string in a form control.
338
339 Creates a new character array containing the character data.
340 The length field must be read before and passed to this function.
341 Aligns stream position to multiple of 4 before.
342
343 @param rStrm
344 The input stream.
345
346 @param rpcCharArr
347 (out-param) Will point to the created character array,
348 or will be 0 if string is empty. The array is NOT null-terminated.
349 If the passed pointer points to an old existing array, it will be
350 deleted before. Caller must delete the returned array.
351
352 @param nLenFld
353 The corresponding string length field read somewhere before.
354 */
lclReadCharArray(SvStorageStream & rStrm,char * & rpcCharArr,sal_uInt32 nLenFld,long nPos)355 void lclReadCharArray( SvStorageStream& rStrm, char*& rpcCharArr, sal_uInt32 nLenFld, long nPos )
356 {
357 delete[] rpcCharArr;
358 rpcCharArr = 0;
359 sal_uInt32 nBufSize = lclGetBufferSize( nLenFld );
360 DBG_ASSERT( nBufSize <= 0xFFFF, "lclReadCharArray - possible read error: char array is too big" );
361 if( nBufSize && nBufSize <= 0xFFFF )
362 {
363 rpcCharArr = new char[ nBufSize ];
364 if( rpcCharArr )
365 {
366 ReadAlign( &rStrm, nPos, 4 );
367 rStrm.Read( rpcCharArr, nBufSize );
368 }
369 }
370 }
371
372
373 /** Creates an OUString from a character array created with lclReadCharArray().
374
375 The passed parameters must match, that means the length field must be the
376 same used to create the passed character array.
377
378 @param pcCharArr
379 The character array returned by lclReadCharArray(). May be compressed
380 or uncompressed, next parameter nLenFld will specify this.
381
382 @param nLenFld
383 MUST be the same string length field that has been passed to
384 lclReadCharArray() to create the character array in previous parameter
385 pcCharArr.
386
387 @return
388 An OUString containing the decoded string data. Will be empty if
389 pcCharArr is 0.
390 */
lclCreateOUString(const char * pcCharArr,sal_uInt32 nLenFld)391 OUString lclCreateOUString( const char* pcCharArr, sal_uInt32 nLenFld )
392 {
393 OUStringBuffer aBuffer;
394 sal_uInt32 nBufSize = lclGetBufferSize( nLenFld );
395 if( lclIsCompressed( nLenFld ) )
396 {
397 // buffer contains compressed Unicode, not encoded bytestring
398 sal_Int32 nStrLen = static_cast< sal_Int32 >( nBufSize );
399 aBuffer.setLength( nStrLen );
400 const char* pcCurrChar = pcCharArr;
401 for( sal_Int32 nChar = 0; nChar < nStrLen; ++nChar, ++pcCurrChar )
402 /* *pcCurrChar may contain negative values and therefore MUST be
403 casted to unsigned char, before assigned to a sal_Unicode. */
404 aBuffer.setCharAt( nChar, static_cast< unsigned char >( *pcCurrChar ) );
405 }
406 else
407 {
408 // buffer contains Little-Endian Unicode
409 sal_Int32 nStrLen = static_cast< sal_Int32 >( nBufSize ) / 2;
410 aBuffer.setLength( nStrLen );
411 const char* pcCurrChar = pcCharArr;
412 for( sal_Int32 nChar = 0; nChar < nStrLen; ++nChar )
413 {
414 /* *pcCurrChar may contain negative values and therefore MUST be
415 casted to unsigned char, before assigned to a sal_Unicode. */
416 sal_Unicode cChar = static_cast< unsigned char >( *pcCurrChar++ );
417 cChar |= (static_cast< unsigned char >( *pcCurrChar++ ) << 8);
418 aBuffer.setCharAt( nChar, cChar );
419 }
420 }
421 return aBuffer.makeStringAndClear();
422 }
423
424 // export ---------------------------------------------------------------------
425
426 /** This class implements writing a character array from a Unicode string.
427
428 Usage:
429 1) Construct an instance, either directly with an OUString, or with an UNO
430 Any containing an OUString.
431 2) Check with HasData(), if there is something to write.
432 3) Write the string length field with WriteLenField() at the right place.
433 4) Write the encoded character array with WriteCharArray().
434 */
435 class SvxOcxString
436 {
437 public:
438 /** Constructs an empty string. String data may be set later by assignment. */
SvxOcxString()439 inline explicit SvxOcxString() : mnLenFld( 0 ) {}
440 /** Constructs the string from the passed OUString. */
SvxOcxString(const OUString & rStr)441 inline explicit SvxOcxString( const OUString& rStr ) { Init( rStr ); }
442 /** Constructs the string from the passed UNO Any. */
SvxOcxString(const uno::Any & rAny)443 inline explicit SvxOcxString( const uno::Any& rAny ) { Init( rAny ); }
444
445 /** Assigns the passed string to the object. */
operator =(const OUString & rStr)446 inline SvxOcxString& operator=( const OUString& rStr ) { Init( rStr ); return *this; }
447 /** Assigns the string in the passed UNO Any to the object. */
operator =(const uno::Any & rAny)448 inline SvxOcxString& operator=( const uno::Any& rAny ) { Init( rAny ); return *this; }
449
450 /** Returns true, if the string contains at least one character to write. */
HasData() const451 inline bool HasData() const { return maString.getLength() > 0; }
452
453 /** Writes the encoded 32-bit string length field. Aligns stream position to mult. of 4 before. */
454 void WriteLenField( SvStorageStream& rStrm ) const;
455 /** Writes the encoded character array. Aligns stream position to mult. of 4 before. */
456 void WriteCharArray( SvStorageStream& rStrm ) const;
457
458 private:
Init(const OUString & rStr)459 inline void Init( const OUString& rStr ) { maString = rStr; Init(); }
460 void Init( const uno::Any& rAny );
461 void Init();
462
463 OUString maString; /// The initial string data.
464 sal_uInt32 mnLenFld; /// The encoded string length field.
465 };
466
Init(const uno::Any & rAny)467 void SvxOcxString::Init( const uno::Any& rAny )
468 {
469 if( !(rAny >>= maString) )
470 maString = OUString();
471 Init();
472 }
473
Init()474 void SvxOcxString::Init()
475 {
476 mnLenFld = static_cast< sal_uInt32 >( maString.getLength() );
477 bool bCompr = true;
478 // try to find a character >= 0x100 -> character array will be stored uncompressed then
479 if( const sal_Unicode* pChar = maString.getStr() )
480 for( const sal_Unicode* pEnd = pChar + maString.getLength(); bCompr && (pChar < pEnd); ++pChar )
481 bCompr = (*pChar < 0x100);
482 if( bCompr )
483 mnLenFld |= SVX_MSOCX_COMPRESSED;
484 else
485 mnLenFld *= 2;
486 }
487
WriteLenField(SvStorageStream & rStrm) const488 void SvxOcxString::WriteLenField( SvStorageStream& rStrm ) const
489 {
490 if( HasData() )
491 {
492 WriteAlign( &rStrm, 4);
493 rStrm << mnLenFld;
494 }
495 }
496
WriteCharArray(SvStorageStream & rStrm) const497 void SvxOcxString::WriteCharArray( SvStorageStream& rStrm ) const
498 {
499 if( HasData() )
500 {
501 const sal_Unicode* pChar = maString.getStr();
502 const sal_Unicode* pEnd = pChar + maString.getLength();
503 bool bCompr = lclIsCompressed( mnLenFld );
504
505 WriteAlign( &rStrm, 4);
506 for( ; pChar < pEnd; ++pChar )
507 {
508 // write compressed Unicode (not encoded bytestring), or Little-Endian Unicode
509 rStrm << static_cast< sal_uInt8 >( *pChar );
510 if( !bCompr )
511 rStrm << static_cast< sal_uInt8 >( *pChar >> 8 );
512 }
513 }
514 }
515
516 const sal_uInt16 USERFORM = (sal_uInt16)0xFF;
517 const sal_uInt16 STDCONTAINER = (sal_uInt16)0xFE;
518
519 const sal_uInt16 PAGE = (sal_uInt16)0x07;
520
521 const sal_uInt16 IMAGE = (sal_uInt16)0x0C;
522 const sal_uInt16 FRAME = (sal_uInt16)0x0E;
523
524 const sal_uInt16 SPINBUTTON = (sal_uInt16)0x10;
525 const sal_uInt16 CMDBUTTON = (sal_uInt16)0x11;
526 const sal_uInt16 TABSTRIP = (sal_uInt16)0x12;
527
528 const sal_uInt16 LABEL = (sal_uInt16)0x15;
529
530 const sal_uInt16 TEXTBOX = (sal_uInt16)0x17;
531 const sal_uInt16 LISTBOX = (sal_uInt16)0x18;
532 const sal_uInt16 COMBOBOX = (sal_uInt16)0x19;
533 const sal_uInt16 CHECKBOX = (sal_uInt16)0x1A;
534
535 const sal_uInt16 OPTIONBUTTON = (sal_uInt16)0x1B;
536 const sal_uInt16 TOGGLEBUTTON = (sal_uInt16)0x1C;
537
538 const sal_uInt16 SCROLLBAR = (sal_uInt16)0x2F;
539
540 const sal_uInt16 MULTIPAGE = (sal_uInt16)0x39;
541 const sal_uInt16 PROGRESSBAR = (sal_uInt16)0x8000;
542
543 typedef std::vector< ContainerRecord > ContainerRecordList;
544
545 class ContainerRecReader
546 {
547 public:
548
~ContainerRecReader()549 virtual ~ContainerRecReader() {}
550
Read(OCX_ContainerControl * pContainerControl,SvStorageStream * pS)551 virtual bool Read( OCX_ContainerControl* pContainerControl, SvStorageStream *pS)
552 {
553 *pS >> nNoRecords;
554 *pS >> nTotalLen;
555
556 if ( isMultiPage )
557 {
558 if ( !handleMultiPageHdr( pS ) )
559 {
560 return false;
561 }
562 }
563 else
564 {
565 if ( !handleStandardHdr( pS ) )
566 {
567 return false;
568 }
569 }
570
571 records.clear();
572 for (sal_uInt32 nRecord = 0; nRecord < nNoRecords; ++nRecord)
573 {
574 // DR #134146# redo loading of FrameChild data
575
576 ContainerRecord rec;
577
578 // record header
579 sal_uInt16 nId, nSize;
580 *pS >> nId >> nSize;
581 sal_Size nStartPos = pS->Tell();
582
583 // content flags
584 sal_uInt32 nContentFlags;
585 *pS >> nContentFlags;
586
587 // length of control name
588 sal_uInt32 nNameLen = 0;
589 if( nContentFlags & 0x00000001 )
590 *pS >> nNameLen;
591 // length of control tag
592 sal_uInt32 nTagLen = 0;
593 if( nContentFlags & 0x00000002 )
594 *pS >> nTagLen;
595 // substorage id for frames
596 if( nContentFlags & 0x00000004 )
597 *pS >> rec.nSubStorageId;
598 // help-context id
599 if( nContentFlags & 0x00000008 )
600 pS->SeekRel( 4 );
601 // option flags
602 if( nContentFlags & 0x00000010 )
603 {
604 sal_uInt32 nBitFlags = 0;
605 *pS >> nBitFlags;
606 rec.bVisible = ( ( nBitFlags & 0x02 ) == 0x02 );
607 }
608 // substream size
609 if( nContentFlags & 0x00000020 )
610 *pS >> rec.nSubStreamLen;
611 // tabstop position
612 if( nContentFlags & 0x00000040 )
613 *pS >> rec.nTabPos;
614 // control type
615 if( nContentFlags & 0x00000080 )
616 *pS >> rec.nTypeIdent;
617 // length of infotip
618 sal_uInt32 nTipLen = 0;
619 if( nContentFlags & 0x00000800 )
620 {
621 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
622 *pS >> nTipLen;
623 }
624
625 sal_uInt32 nCntrlIdLen = 0;
626 if( nContentFlags & 0x00001000 )
627 *pS >> nCntrlIdLen;
628
629 // length of control source name
630 sal_uInt32 nCtrlSrcLen = 0;
631 if( nContentFlags & 0x00002000 )
632 {
633 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
634 *pS >> nCtrlSrcLen;
635 }
636
637 // length of row source name
638 sal_uInt32 nRowSrcLen = 0;
639 if( nContentFlags & 0x00004000 )
640 {
641 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
642 *pS >> nRowSrcLen;
643 }
644
645 // control name
646 sal_Char* pName = 0;
647 sal_uInt32 nNameBufSize = lclGetBufferSize( nNameLen );
648 if( nNameBufSize > 0 )
649 {
650 pName = new char[ nNameBufSize ];
651 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
652 pS->Read( pName, nNameBufSize );
653 }
654 // control tag
655 sal_uInt32 nTagBufSize = lclGetBufferSize( nTagLen );
656 if( nTagBufSize > 0 )
657 {
658 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
659 pS->SeekRel( nTagBufSize );
660 }
661
662 // control position
663 if( nContentFlags & 0x00000100 )
664 {
665 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
666 *pS >> rec.nLeft >> rec.nTop;
667 }
668
669 // control infotip
670 sal_uInt32 nTipBufSize = lclGetBufferSize( nTipLen );
671 if( nTipBufSize > 0 )
672 {
673 std::auto_ptr< sal_Char > pTipName;
674 pTipName.reset( new sal_Char[ nTipBufSize ] );
675 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
676 pS->Read( pTipName.get(), nTipBufSize );
677 rec.controlTip = lclCreateOUString( pTipName.get(), nTipLen );
678 }
679 // control id
680 sal_uInt32 nCntrlIdSize = lclGetBufferSize( nCntrlIdLen );
681 if( nCntrlIdSize > 0 )
682 {
683 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
684 pS->SeekRel( nCntrlIdSize );
685 }
686 // control source name
687 sal_uInt32 nCtrlSrcBufSize = lclGetBufferSize( nCtrlSrcLen );
688 if( nCtrlSrcBufSize > 0 )
689 {
690 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
691 pS->SeekRel( nCtrlSrcBufSize );
692 }
693 // row source name
694 sal_uInt32 nRowSrcBufSize = lclGetBufferSize( nRowSrcLen );
695 if( nRowSrcBufSize > 0 )
696 {
697 ReadAlign( pS, pS->Tell() - nStartPos, 4 );
698 pS->SeekRel( nRowSrcBufSize );
699 }
700
701 // seek to end of data
702 pS->Seek( nStartPos + nSize );
703
704 rec.cName = lclCreateOUString(pName, nNameLen);
705 delete[] pName;
706
707 OCX_Control* pControl = NULL;
708 if( pContainerControl->createFromContainerRecord( rec, pControl ) &&
709 pControl )
710 {
711 // propagate doc shell from parent
712 pControl->pDocSh = pContainerControl->pDocSh;
713 pContainerControl->ProcessControl( pControl, pS, rec );
714 }
715 else
716 {
717 DBG_ERROR("Terminating import, unexpected error");
718 return false;
719 }
720 }
721 return true;
722 }
723
724 protected:
ContainerRecReader()725 ContainerRecReader() : isMultiPage(false){}
726 bool isMultiPage;
727 sal_uInt32 nNoRecords;
728 sal_uInt32 nTotalLen;
729
730 private:
handleStandardHdr(SvStorageStream * pS)731 bool handleStandardHdr( SvStorageStream* pS )
732 {
733 sal_uInt8 aUnknown11[4];
734 pS->Read(aUnknown11, sizeof(aUnknown11));
735 return true;
736 }
737
handleMultiPageHdr(SvStorageStream * pS)738 bool handleMultiPageHdr( SvStorageStream* pS )
739 {
740 sal_uInt32 nUnknown_32b; // unknown 32 bit structure, flags ?
741 sal_uInt16 nUnknown_16b; // unknown 16 bit structure
742 sal_uInt16 nMysteryLen; // length of unknown sub record
743
744 *pS >> nUnknown_32b;
745 *pS >> nUnknown_16b;
746 *pS >> nMysteryLen;
747
748 pS->SeekRel( nMysteryLen );
749 return true;
750 }
751 ContainerRecordList records;
752 };
753
754 class StdContainerRecReader : public ContainerRecReader
755 {
756 public:
StdContainerRecReader()757 StdContainerRecReader(){}
758 };
759
760 class MultiPageContainerRecReader : public ContainerRecReader
761 {
762 public:
MultiPageContainerRecReader()763 MultiPageContainerRecReader()
764 {
765 // NP ( 27-01-05 )
766 // Strictly speaking this approach shouldn't be necessary.
767 // It should be possible to have a common routine read the
768 // container record array and by examining the flags present in
769 // the record to determine we expect to read or not.
770 // In this case for a MultPage control there is no Top or Left
771 // values in the control record array, however time constraints
772 // and associated risk prevent further investigation of this
773 // at the moment.
774 // similar situation exists for the start of the container record
775 // which in the case of the MultiPage is different from
776 // UserForm & Frame ( the other containers )
777
778 isMultiPage = true; // tell the base class skip
779 }
780 };
781
782 class ContainerRecordReaderFac
783 {
784 public:
instance(sal_uInt32 containerType)785 static ContainerRecReader* instance( sal_uInt32 containerType )
786 {
787 switch( containerType )
788 {
789 case PAGE:
790 case FRAME:
791 case USERFORM:
792 case STDCONTAINER:
793 return new StdContainerRecReader();
794 case MULTIPAGE:
795 return new MultiPageContainerRecReader();
796 default:
797 DBG_ERROR("Illegal container type for factory");
798 return NULL;
799 }
800 }
801 private:
802 ContainerRecordReaderFac();
803 };
804
805 } // namespace
806
807 // ============================================================================
808
add(OCX_Control * pRB)809 void RBGroup::add(OCX_Control* pRB)
810 {
811 // The tab index for the group is calculated as
812 // the lowest tab index found in the list of RadioButtons
813 if ( pRB->mnTabPos < mRBGroupPos )
814 {
815 mRBGroupPos = pRB->mnTabPos;
816 CtrlIterator aEnd = mpControls.end();
817 for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
818 {
819 (*aIter)->mnTabPos = mRBGroupPos;
820 }
821 }
822 mpControls.push_back( pRB );
823 }
824
825 struct SortGroupByTabPos
826 {
operator ()SortGroupByTabPos827 bool operator()( const RBGroup* a, const RBGroup* b )
828 {
829 return a->tabPos() < b->tabPos();
830 }
831 };
832
RBGroupManager(String & defaultName)833 RBGroupManager::RBGroupManager( String& defaultName ):mSDefaultName( defaultName ),
834 numRadioButtons(0)
835 {
836 groupList.reserve( 8 ); // reserve far more than we expect
837 }
838
~RBGroupManager()839 RBGroupManager::~RBGroupManager()
840 {
841 for ( GroupIterator gIter=groupList.begin(); gIter!=groupList.end(); ++gIter )
842 {
843 delete( *gIter );
844 }
845 }
846
847 // Loose description of the method below ( I sure there is a better way to do
848 // this )
849 // In order to "fake" MS grouping behavior for OptionButtons the OptionButtons
850 // in the same group need to have consecutive tab indices ( regardless of the
851 // imported tab indices of the RadioButtons ). Additionally if two
852 // groups of OptionButtons end up having all consecutive indices they
853 // will be treated as a single group by OpenOffice. In this case
854 // a dummy seperator control needs to be inserted between the groups.
855 //
856 // This method returns a new list "destinationList" containing the controls
857 // passed in "sourceList" and the OptionButtons contained in the various
858 // Groups maintained by this class.
859 // Controls are ordered in the destination list by tab index.
860 // Each RadioButtonGroup has a tab index associated with it.
861 // ( Tab index of a RadioGroup is determined as the tab index of the
862 // OptionButton control with the lowest tab index in the group )
863
864
addRadioButton(OCX_OptionButton * pRButton)865 void RBGroupManager::addRadioButton( OCX_OptionButton* pRButton )
866 {
867 if ( pRButton )
868 {
869 OUString groupName = mSDefaultName;
870 if ( pRButton->nGroupNameLen )
871 {
872 groupName =
873 lclCreateOUString(pRButton->pGroupName,
874 pRButton->nGroupNameLen);
875 }
876 ++numRadioButtons;
877 RBGroupHash::iterator iter = rbGroups.find( groupName );
878 if ( iter != rbGroups.end() )
879 {
880 iter->second->controls().push_back( pRButton );
881 }
882 else
883 {
884 RBGroup* newGroup = new RBGroup(pRButton->mnTabPos);
885 newGroup->controls().push_back( pRButton );
886 rbGroups[ groupName ] = newGroup;
887 groupList.push_back( newGroup );
888 }
889
890 }
891 }
892
insertGroupsIntoControlList(const CtrlList & sourceList)893 CtrlList RBGroupManager::insertGroupsIntoControlList( const CtrlList& sourceList )
894 {
895 ::std::sort( groupList.begin(), groupList.end(), SortGroupByTabPos() );
896 std::vector<OCX_Control*> destinationList;
897 if ( groupList.size() )
898 {
899 destinationList.reserve( sourceList.size() + numRadioButtons );
900
901 GroupIterator groupEnd = groupList.end();
902 CtrlIteratorConst sourceEnd = sourceList.end();
903
904 size_t prevGroupListSize = 0;
905
906 CtrlIteratorConst containees = sourceList.begin();
907 GroupIterator groupIter=groupList.begin();
908 while ( containees != sourceEnd ||
909 groupIter != groupEnd )
910 {
911 bool addGroupSeperator = false;
912 if ( containees != sourceEnd )
913 {
914 if ( groupIter != groupEnd )
915 {
916 sal_Int16 groupTabPos = (*groupIter)->tabPos();
917 if ( (*containees)->mnTabPos >= groupTabPos )
918 {
919 if ( !(destinationList.size() >= prevGroupListSize ))
920 {
921 addGroupSeperator = true;
922 }
923 copyList( (*groupIter)->controls(), destinationList, addGroupSeperator );
924 ++groupIter;
925
926 prevGroupListSize = destinationList.size();
927 }
928 }
929 destinationList.push_back(*containees);
930 ++containees;
931 }
932 else
933 {
934 if ( groupIter != groupEnd )
935 {
936 if ( !(destinationList.size() > prevGroupListSize ))
937 {
938 addGroupSeperator = true;
939 }
940 copyList( (*groupIter)->controls(), destinationList, addGroupSeperator );
941 ++groupIter;
942 prevGroupListSize = destinationList.size();
943 }
944 }
945 }
946 }
947 else
948 {
949 destinationList = sourceList;
950 }
951 return destinationList;
952
953 }
954
955
addSeperator(std::vector<OCX_Control * > & dest)956 void RBGroupManager::addSeperator( std::vector< OCX_Control* >& dest )
957 {
958 OCX_Control* seperator = new OCX_CommandButton;
959 seperator->SetInDialog(true);
960 seperator->sName = C2S("GroupSeperator");
961 dest.push_back( seperator );
962 }
963
copyList(std::vector<OCX_Control * > & src,std::vector<OCX_Control * > & dest,bool addGroupSeperator)964 void RBGroupManager::copyList( std::vector< OCX_Control* >& src,
965 std::vector< OCX_Control* >& dest,
966 bool addGroupSeperator )
967 {
968 if ( addGroupSeperator )
969 {
970 addSeperator( dest );
971 }
972
973 for ( CtrlIterator rbIter = src.begin(); rbIter != src.end(); ++rbIter )
974 {
975 dest.push_back( *rbIter );
976 }
977 }
978
979 class OCX_UserFormLabel : public OCX_Label
980 {
981 public:
OCX_UserFormLabel(OCX_Control * pParent)982 OCX_UserFormLabel(OCX_Control* pParent ) : OCX_Label( pParent )
983 {
984 mnForeColor = 0x80000012L;
985 mnBackColor = 0x8000000FL;
986 }
987 };
988
989
990 sal_uInt16 OCX_Control::nStandardId(0x0200);
991 sal_uInt16 OCX_FontData::nStandardId(0x0200);
992
993 sal_uInt32 OCX_Control::pColor[25] = {
994 0xC0C0C0, 0x008080, 0x000080, 0x808080, 0xC0C0C0, 0xFFFFFF, 0x000000,
995 0x000000, 0x000000, 0xFFFFFF, 0xC0C0C0, 0xC0C0C0, 0x808080, 0x000080,
996 0xFFFFFF, 0xC0C0C0, 0x808080, 0x808080, 0x000000, 0xC0C0C0, 0xFFFFFF,
997 0x000000, 0xC0C0C0, 0x000000, 0xFFFFC0 };
998
FillSystemColors()999 void OCX_Control::FillSystemColors()
1000 {
1001 // overwrite the predefined colors with available system colors
1002 const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
1003
1004 pColor[ 0x00 ] = rSett.GetFaceColor().GetColor();
1005 pColor[ 0x01 ] = rSett.GetWorkspaceColor().GetColor();
1006 pColor[ 0x02 ] = rSett.GetActiveColor().GetColor();
1007 pColor[ 0x03 ] = rSett.GetDeactiveColor().GetColor();
1008 pColor[ 0x04 ] = rSett.GetMenuBarColor().GetColor();
1009 pColor[ 0x05 ] = rSett.GetWindowColor().GetColor();
1010 pColor[ 0x07 ] = rSett.GetMenuTextColor().GetColor();
1011 pColor[ 0x08 ] = rSett.GetWindowTextColor().GetColor();
1012 pColor[ 0x09 ] = rSett.GetActiveTextColor().GetColor();
1013 pColor[ 0x0A ] = rSett.GetActiveBorderColor().GetColor();
1014 pColor[ 0x0B ] = rSett.GetDeactiveBorderColor().GetColor();
1015 pColor[ 0x0C ] = rSett.GetWorkspaceColor().GetColor();
1016 pColor[ 0x0D ] = rSett.GetHighlightColor().GetColor();
1017 pColor[ 0x0E ] = rSett.GetHighlightTextColor().GetColor();
1018 pColor[ 0x0F ] = rSett.GetFaceColor().GetColor();
1019 pColor[ 0x10 ] = rSett.GetShadowColor().GetColor();
1020 pColor[ 0x12 ] = rSett.GetButtonTextColor().GetColor();
1021 pColor[ 0x13 ] = rSett.GetDeactiveTextColor().GetColor();
1022 pColor[ 0x14 ] = rSett.GetHighlightColor().GetColor();
1023 pColor[ 0x15 ] = rSett.GetDarkShadowColor().GetColor();
1024 pColor[ 0x16 ] = rSett.GetShadowColor().GetColor();
1025 pColor[ 0x17 ] = rSett.GetHelpTextColor().GetColor();
1026 pColor[ 0x18 ] = rSett.GetHelpColor().GetColor();
1027 }
1028
ImportColor(sal_uInt32 nColor) const1029 sal_uInt32 OCX_Control::ImportColor(sal_uInt32 nColor) const
1030 {
1031 sal_uInt8 nUpper = (sal_uInt8)( nColor >> 24 );
1032 if (nUpper & 0x80) //Palette color, should be switch on bottom 24 bits
1033 {
1034 /*Might as well use my systems ones in the absence of any other ideas*/
1035 nColor = nColor&0x00FFFFFF;
1036 DBG_ASSERT (nColor <= 24,"Unknown Palette Index");
1037 if (nColor > 24)
1038 nColor = 0xFFFFFF;
1039 else
1040 nColor = pColor[nColor];
1041 }
1042 else
1043 {
1044 //Stored in bgr! rather than rgb
1045 nColor = SwapColor(nColor);
1046 }
1047 return nColor;
1048 }
1049
ImportAlign(sal_uInt8 _nJustification) const1050 sal_Int16 OCX_FontData::ImportAlign(sal_uInt8 _nJustification) const
1051 {
1052 sal_Int16 nRet;
1053 switch (_nJustification)
1054 {
1055 default:
1056 case 1:
1057 nRet = 0;
1058 break;
1059 case 2:
1060 nRet = 2;
1061 break;
1062 case 3:
1063 nRet = 1;
1064 break;
1065 }
1066 return nRet;
1067 }
1068
ExportAlign(sal_Int16 nAlign) const1069 sal_uInt8 OCX_FontData::ExportAlign(sal_Int16 nAlign) const
1070 {
1071 sal_Int8 nRet;
1072 switch (nAlign)
1073 {
1074 default:
1075 case 0:
1076 nRet = 1;
1077 break;
1078 case 2:
1079 nRet = 2;
1080 break;
1081 case 1:
1082 nRet = 3;
1083 break;
1084 }
1085 return nRet;
1086 }
1087
SwapColor(sal_uInt32 nColor) const1088 sal_uInt32 OCX_Control::SwapColor(sal_uInt32 nColor) const
1089 {
1090 sal_uInt8
1091 r(static_cast<sal_uInt8>(nColor&0xFF)),
1092 g(static_cast<sal_uInt8>(((nColor)>>8)&0xFF)),
1093 b(static_cast<sal_uInt8>((nColor>>16)&0xFF));
1094 nColor = (r<<16) + (g<<8) + b;
1095 return nColor;
1096 }
1097
ExportColor(sal_uInt32 nColor) const1098 sal_uInt32 OCX_Control::ExportColor(sal_uInt32 nColor) const
1099 {
1100 sal_uInt8 nUpper = (sal_uInt8)( nColor >> 24 );
1101 if (nUpper & 0x80) //Palette color, should be switch on bottom 24 bits
1102 {
1103 /*Might as well use my systems ones in the absence of any other ideas*/
1104 nColor = nColor&0x00FFFFFF;
1105 DBG_ASSERT (nColor <= 24,"Unknown Palette Index");
1106 if (nColor > 24)
1107 nColor = 0xFFFFFF;
1108 else
1109 nColor = pColor[nColor];
1110 }
1111
1112 //Stored in bgr! rather than rgb
1113 nColor = SwapColor(nColor);
1114 return nColor;
1115 }
1116
Import(const uno::Reference<lang::XMultiServiceFactory> & rServiceFactory,uno::Reference<form::XFormComponent> & rFComp,awt::Size & rSz)1117 sal_Bool OCX_Control::Import(
1118 const uno::Reference< lang::XMultiServiceFactory > &rServiceFactory,
1119 uno::Reference< form::XFormComponent > &rFComp, awt::Size &rSz)
1120 {
1121
1122 if(msFormType.getLength() == 0)
1123 return sal_False;
1124
1125 rSz.Width = nWidth;
1126 rSz.Height = nHeight;
1127
1128 uno::Reference<uno::XInterface> xCreate =
1129 rServiceFactory->createInstance(msFormType);
1130 if (!xCreate.is())
1131 return sal_False;
1132
1133 rFComp = uno::Reference<form::XFormComponent>(xCreate,uno::UNO_QUERY);
1134 if (!rFComp.is())
1135 return sal_False;
1136 uno::Reference<beans::XPropertySet> xPropSet(xCreate,uno::UNO_QUERY);
1137 if (!xPropSet.is())
1138 return sal_False;
1139 return Import(xPropSet);
1140 }
1141
Import(uno::Reference<container::XNameContainer> & rDialog)1142 sal_Bool OCX_Control::Import(uno::Reference<container::XNameContainer> &rDialog
1143 )
1144 {
1145 uno::Reference<lang::XMultiServiceFactory>
1146 xFactory(rDialog, uno::UNO_QUERY);
1147
1148 uno::Reference<uno::XInterface> xCreate =
1149 xFactory->createInstance(msDialogType);
1150 if (!xCreate.is())
1151 return sal_False;
1152
1153 uno::Reference<awt::XControlModel> xModel(xCreate, uno::UNO_QUERY);
1154 if (!xModel.is())
1155 return sal_False;
1156
1157 /* #147900# sometimes insertion of a control fails due to existing name,
1158 do not break entire form import then... */
1159 try
1160 {
1161 rDialog->insertByName(sName, uno::makeAny(xModel));
1162 }
1163 catch( uno::Exception& )
1164 {
1165 DBG_ERRORFILE(
1166 ByteString( "OCX_Control::Import - cannot insert control \"" ).
1167 Append( ByteString( sName, RTL_TEXTENCODING_UTF8 ) ).
1168 Append( '"' ).GetBuffer() );
1169 }
1170
1171 uno::Reference<beans::XPropertySet> xPropSet(xCreate, uno::UNO_QUERY);
1172 if (!xPropSet.is())
1173 return sal_False;
1174
1175 if (!Import(xPropSet))
1176 return sal_False;
1177
1178 uno::Any aTmp;
1179 aTmp <<= sal_Int32((mnLeft * 2) / 100);
1180 xPropSet->setPropertyValue(WW8_ASCII2STR("PositionX"), aTmp);
1181 aTmp <<= sal_Int32((mnTop * 2) / 100);
1182 xPropSet->setPropertyValue(WW8_ASCII2STR("PositionY"), aTmp);
1183 aTmp <<= sal_Int32((nWidth * 2) / 100);
1184 xPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
1185 aTmp <<= sal_Int32((nHeight * 2) / 100);
1186 xPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
1187 if ( msToolTip.Len() > 0 )
1188 xPropSet->setPropertyValue(WW8_ASCII2STR("HelpText"), uno::Any(OUString(msToolTip)));
1189
1190 if ( mnStep )
1191 {
1192 aTmp <<= mnStep;
1193 xPropSet->setPropertyValue(WW8_ASCII2STR("Step"), aTmp);
1194 }
1195
1196 try
1197 {
1198 xPropSet->setPropertyValue(WW8_ASCII2STR("EnableVisible"), uno::makeAny( mbVisible ) );
1199 }
1200 catch( uno::Exception& )
1201 {
1202 }
1203 return sal_True;
1204 }
1205
ImportBorder(sal_uInt16 nSpecialEffect,sal_uInt16 nBorderStyle) const1206 sal_Int16 OCX_Control::ImportBorder(sal_uInt16 nSpecialEffect,
1207 sal_uInt16 nBorderStyle) const
1208 {
1209 if ((nSpecialEffect == 0) && (nBorderStyle == 0))
1210 return 0; //No Border
1211 else if ((nSpecialEffect == 0) && (nBorderStyle == 1))
1212 return 2; //Flat Border
1213 return 1; //3D Border
1214 }
1215
ExportBorder(sal_uInt16 nBorder,sal_uInt8 & rBorderStyle) const1216 sal_uInt8 OCX_Control::ExportBorder(sal_uInt16 nBorder,sal_uInt8 &rBorderStyle)
1217 const
1218 {
1219 sal_uInt8 nRet;
1220 switch(nBorder)
1221 {
1222 case 0:
1223 nRet = rBorderStyle = 0;
1224 break;
1225 default:
1226 case 1:
1227 nRet = 2;
1228 rBorderStyle = 0;
1229 break;
1230 case 2:
1231 nRet = 0;
1232 rBorderStyle = 1;
1233 break;
1234 }
1235 return nRet;
1236 }
1237
ImportSpecEffect(sal_uInt8 nSpecialEffect) const1238 sal_Int16 OCX_Control::ImportSpecEffect( sal_uInt8 nSpecialEffect ) const
1239 {
1240 return (nSpecialEffect == 0) ? 2 : 1;
1241 }
1242
ExportSpecEffect(sal_Int16 nApiEffect) const1243 sal_uInt8 OCX_Control::ExportSpecEffect( sal_Int16 nApiEffect ) const
1244 {
1245 return (nApiEffect == 2) ? 0 : 2;
1246 }
1247
ReadFontData(SvStorageStream * pS)1248 sal_Bool OCX_Control::ReadFontData(SvStorageStream *pS)
1249 {
1250 return aFontData.Read(pS);
1251 }
1252
1253
1254 const uno::Reference< drawing::XDrawPage >&
GetDrawPage()1255 SvxMSConvertOCXControls::GetDrawPage()
1256 {
1257 if( !xDrawPage.is() && pDocSh )
1258 {
1259 uno::Reference< drawing::XDrawPageSupplier > xTxtDoc(pDocSh->GetModel(),
1260 uno::UNO_QUERY);
1261 DBG_ASSERT(xTxtDoc.is(),"XDrawPageSupplier nicht vom XModel erhalten");
1262 xDrawPage = xTxtDoc->getDrawPage();
1263 DBG_ASSERT( xDrawPage.is(), "XDrawPage nicht erhalten" );
1264 }
1265
1266 return xDrawPage;
1267 }
1268
1269
1270 const uno::Reference< lang::XMultiServiceFactory >&
GetServiceFactory()1271 SvxMSConvertOCXControls::GetServiceFactory()
1272 {
1273 if( !xServiceFactory.is() && pDocSh )
1274 {
1275 xServiceFactory = uno::Reference< lang::XMultiServiceFactory >
1276 (pDocSh->GetBaseModel(), uno::UNO_QUERY);
1277 DBG_ASSERT( xServiceFactory.is(),
1278 "XMultiServiceFactory nicht vom Model erhalten" );
1279 }
1280
1281 return xServiceFactory;
1282 }
1283
GetShapes()1284 const uno::Reference< drawing::XShapes >& SvxMSConvertOCXControls::GetShapes()
1285 {
1286 if( !xShapes.is() )
1287 {
1288 GetDrawPage();
1289 if( xDrawPage.is() )
1290 {
1291
1292 xShapes = uno::Reference< drawing::XShapes >(xDrawPage,
1293 uno::UNO_QUERY);
1294 DBG_ASSERT( xShapes.is(), "XShapes nicht vom XDrawPage erhalten" );
1295 }
1296 }
1297 return xShapes;
1298 }
1299
1300 const uno::Reference< container::XIndexContainer >&
GetFormComps()1301 SvxMSConvertOCXControls::GetFormComps()
1302 {
1303 if( !xFormComps.is() )
1304 {
1305 GetDrawPage();
1306 if( xDrawPage.is() )
1307 {
1308 uno::Reference< form::XFormsSupplier > xFormsSupplier( xDrawPage,
1309 uno::UNO_QUERY );
1310 DBG_ASSERT( xFormsSupplier.is(),
1311 "XFormsSupplier nicht vom XDrawPage erhalten" );
1312
1313 uno::Reference< container::XNameContainer > xNameCont =
1314 xFormsSupplier->getForms();
1315
1316 // Das Formular bekommt einen Namen wie "WW-Standard[n]" und
1317 // wird in jedem Fall neu angelegt.
1318 UniString sName( sWW8_form, RTL_TEXTENCODING_MS_1252 );
1319 sal_uInt16 n = 0;
1320
1321 while( xNameCont->hasByName( sName ) )
1322 {
1323 sName.AssignAscii( sWW8_form );
1324 sName += String::CreateFromInt32( ++n );
1325 }
1326
1327 const uno::Reference< lang::XMultiServiceFactory > &rServiceFactory
1328 = GetServiceFactory();
1329 if( !rServiceFactory.is() )
1330 return xFormComps;
1331
1332 uno::Reference< uno::XInterface > xCreate =
1333 rServiceFactory->createInstance(WW8_ASCII2STR(
1334 "com.sun.star.form.component.Form"));
1335 if( xCreate.is() )
1336 {
1337 uno::Reference< beans::XPropertySet > xFormPropSet( xCreate,
1338 uno::UNO_QUERY );
1339
1340 uno::Any aTmp(&sName,getCppuType((OUString *)0));
1341 xFormPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
1342
1343 uno::Reference< form::XForm > xForm( xCreate, uno::UNO_QUERY );
1344 DBG_ASSERT(xForm.is(), "keine Form?");
1345
1346 uno::Reference< container::XIndexContainer > xForms( xNameCont,
1347 uno::UNO_QUERY );
1348 DBG_ASSERT( xForms.is(), "XForms nicht erhalten" );
1349
1350 aTmp.setValue( &xForm,
1351 ::getCppuType((uno::Reference < form::XForm >*)0));
1352 xForms->insertByIndex( xForms->getCount(), aTmp );
1353
1354 xFormComps = uno::Reference< container::XIndexContainer >
1355 (xCreate, uno::UNO_QUERY);
1356 }
1357 }
1358 }
1359
1360 return xFormComps;
1361 }
1362
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)1363 sal_Bool OCX_CommandButton::Import( com::sun::star::uno::Reference<
1364 com::sun::star::beans::XPropertySet> &rPropSet)
1365 {
1366 uno::Any aTmp(&sName,getCppuType((OUString *)0));
1367 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
1368
1369 aTmp <<= ImportColor(mnForeColor);
1370 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
1371
1372 //fBackStyle is a flag. 1 means with background color. 0 means default.
1373 if( fBackStyle )
1374 aTmp <<= ImportColor(mnBackColor);
1375 else
1376 aTmp = uno::Any();
1377 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
1378
1379 sal_Bool bTemp;
1380 if ((!(fEnabled)) || (fLocked))
1381 bTemp = sal_False;
1382 else
1383 bTemp = sal_True;
1384 aTmp = bool2any(bTemp);
1385
1386 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
1387
1388 bTemp = fWordWrap != 0;
1389 aTmp = bool2any(bTemp);
1390 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
1391
1392 if (pCaption)
1393 {
1394 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
1395 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
1396 }
1397
1398 aTmp = bool2any( mbTakeFocus );
1399 rPropSet->setPropertyValue( WW8_ASCII2STR( "FocusOnClick" ), aTmp );
1400
1401 aFontData.Import(rPropSet);
1402 return sal_True;
1403 }
1404
Export(SvStorageRef &,const uno::Reference<beans::XPropertySet> &,const awt::Size &)1405 sal_Bool OCX_GroupBox::Export(SvStorageRef& /* rObj */,
1406 const uno::Reference< beans::XPropertySet >& /* rPropSet */,
1407 const awt::Size& /* rSize */ )
1408 {
1409 sal_Bool bRet=sal_True;
1410 return bRet;
1411 }
1412
WriteContents(SvStorageStreamRef &,const uno::Reference<beans::XPropertySet> &,const awt::Size &)1413 sal_Bool OCX_GroupBox::WriteContents(SvStorageStreamRef& /* rObj */,
1414 const uno::Reference< beans::XPropertySet >& /* rPropSet */,
1415 const awt::Size& /* rSize */)
1416 {
1417 sal_Bool bRet=sal_True;
1418 return bRet;
1419 }
1420
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)1421 sal_Bool OCX_CommandButton::WriteContents(SvStorageStreamRef& rContents,
1422 const uno::Reference< beans::XPropertySet >& rPropSet,
1423 const awt::Size& rSize )
1424 {
1425 sal_Bool bRet=sal_True;
1426
1427 sal_uInt32 nOldPos = rContents->Tell();
1428 rContents->SeekRel(8);
1429
1430 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
1431 if (aTmp.hasValue())
1432 aTmp >>= mnForeColor;
1433 *rContents << ExportColor(mnForeColor);
1434
1435 //fBackStyle is a flag. 1 means with background color. 0 means default.
1436 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1437 if (aTmp.hasValue())
1438 aTmp >>= mnBackColor;
1439 else
1440 fBackStyle = 0;
1441 *rContents << ExportColor(mnBackColor);
1442
1443 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
1444 fEnabled = any2bool(aTmp);
1445 sal_uInt8 nTemp=0;//fEnabled;
1446 if (fEnabled)
1447 nTemp |= 0x02;//has enabled prop
1448 if (fBackStyle)
1449 nTemp |= 0x08;//has background color
1450 *rContents << nTemp;
1451 *rContents << sal_uInt8(0x00);
1452
1453 nTemp = 0;
1454 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
1455 fWordWrap = any2bool(aTmp);
1456 if (fWordWrap)
1457 nTemp |= 0x80;
1458 *rContents << nTemp;
1459 *rContents << sal_uInt8(0x00);
1460
1461 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
1462 aCaption.WriteLenField( *rContents );
1463 aCaption.WriteCharArray( *rContents );
1464
1465 WriteAlign(rContents,4);
1466
1467 *rContents << rSize.Width;
1468 *rContents << rSize.Height;
1469
1470 // "take focus on click" is directly in content flags, not in option field...
1471 mbTakeFocus = any2bool( rPropSet->getPropertyValue( WW8_ASCII2STR( "FocusOnClick" ) ) );
1472
1473 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
1474 aFontData.nDefaultAlign = 1;
1475 bRet = aFontData.Export(rContents,rPropSet);
1476
1477 rContents->Seek(nOldPos);
1478 *rContents << nStandardId;
1479 *rContents << nFixedAreaLen;
1480
1481 sal_uInt8 nTmp = 0x27;
1482 if (aCaption.HasData())
1483 nTmp |= 0x08;
1484 *rContents << nTmp;
1485 nTmp = 0x00;
1486 if( !mbTakeFocus ) // flag is set, if option is off
1487 nTmp |= 0x02;
1488 *rContents << nTmp;
1489 *rContents << sal_uInt8(0x00);
1490 *rContents << sal_uInt8(0x00);
1491
1492 DBG_ASSERT((rContents.Is() && (SVSTREAM_OK==rContents->GetError())),"damn");
1493 return bRet;
1494 }
1495
1496
1497
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)1498 sal_Bool OCX_CommandButton::Export(SvStorageRef &rObj,
1499 const uno::Reference< beans::XPropertySet > &rPropSet,
1500 const awt::Size &rSize)
1501 {
1502 static sal_uInt8 __READONLY_DATA aCompObj[] = {
1503 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1504 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1505 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1506 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1507 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1508 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1509 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1510 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1511 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1512 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1513 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1514 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1515 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1516 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1517 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1518 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1519 };
1520
1521 {
1522 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
1523 xStor->Write(aCompObj,sizeof(aCompObj));
1524 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
1525 }
1526
1527 {
1528 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
1529 xStor3->Write(aObjInfo,sizeof(aObjInfo));
1530 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
1531 }
1532
1533 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
1534 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x6D, 0x00,
1535 0x61, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x42, 0x00,
1536 0x75, 0x00, 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00,
1537 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1538 };
1539
1540 {
1541 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
1542 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
1543 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
1544 }
1545
1546 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
1547
1548 return WriteContents(xContents,rPropSet,rSize);
1549 }
1550
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)1551 sal_Bool OCX_ImageButton::WriteContents(SvStorageStreamRef &rContents,
1552 const uno::Reference< beans::XPropertySet > &rPropSet,
1553 const awt::Size &rSize)
1554 {
1555 sal_Bool bRet=sal_True;
1556
1557 sal_uInt32 nOldPos = rContents->Tell();
1558 rContents->SeekRel(8);
1559
1560 uno::Any aTmp=rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1561 if (aTmp.hasValue())
1562 aTmp >>= mnBackColor;
1563 *rContents << ExportColor(mnBackColor);
1564
1565 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
1566 fEnabled = any2bool(aTmp);
1567 sal_uInt8 nTemp=0;//fEnabled;
1568 if (fEnabled)
1569 nTemp |= 0x02;
1570 *rContents << nTemp;
1571 *rContents << sal_uInt8(0x00);
1572 *rContents << sal_uInt8(0x00);
1573 *rContents << sal_uInt8(0x00);
1574
1575 WriteAlign(rContents,4);
1576
1577 *rContents << rSize.Width;
1578 *rContents << rSize.Height;
1579
1580 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
1581
1582 bRet = aFontData.Export(rContents,rPropSet);
1583
1584 rContents->Seek(nOldPos);
1585 *rContents << nStandardId;
1586 *rContents << nFixedAreaLen;
1587
1588 sal_uInt8 nTmp = 0x26;
1589 *rContents << nTmp;
1590 *rContents << sal_uInt8(0x00);
1591 *rContents << sal_uInt8(0x00);
1592 *rContents << sal_uInt8(0x00);
1593
1594 DBG_ASSERT((rContents.Is() && (SVSTREAM_OK==rContents->GetError())),"damn");
1595 return bRet;
1596 }
1597
1598
1599
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)1600 sal_Bool OCX_ImageButton::Export(SvStorageRef &rObj,
1601 const uno::Reference< beans::XPropertySet > &rPropSet,
1602 const awt::Size &rSize)
1603 {
1604 static sal_uInt8 __READONLY_DATA aCompObj[] = {
1605 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1606 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1607 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1608 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1609 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1610 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1611 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1612 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1613 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1614 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1615 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1616 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1617 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1618 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1619 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1620 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1621 };
1622
1623 {
1624 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
1625 xStor->Write(aCompObj,sizeof(aCompObj));
1626 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
1627 }
1628
1629 {
1630 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
1631 xStor3->Write(aObjInfo,sizeof(aObjInfo));
1632 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
1633 }
1634
1635 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
1636 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x6D, 0x00,
1637 0x61, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x42, 0x00,
1638 0x75, 0x00, 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00,
1639 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1640 };
1641
1642 {
1643 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
1644 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
1645 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
1646 }
1647
1648 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
1649 return WriteContents(xContents,rPropSet,rSize);
1650 }
1651
1652
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)1653 sal_Bool OCX_OptionButton::Import(com::sun::star::uno::Reference<
1654 com::sun::star::beans::XPropertySet> &rPropSet)
1655 {
1656 uno::Any aTmp(&sName,getCppuType((OUString *)0));
1657 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
1658
1659 // background color: fBackStyle==0 -> transparent
1660 if( fBackStyle )
1661 aTmp <<= ImportColor(mnBackColor);
1662 else
1663 aTmp = uno::Any();
1664 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
1665
1666 sal_Bool bTemp;
1667 if ((!(fEnabled)) || (fLocked))
1668 bTemp = sal_False;
1669 else
1670 bTemp = sal_True;
1671 aTmp = bool2any(bTemp);
1672 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
1673
1674 bTemp = fWordWrap != 0;
1675 aTmp = bool2any(bTemp);
1676 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
1677
1678 aTmp <<= ImportColor(mnForeColor);
1679 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
1680
1681 aTmp <<= ImportSpecEffect( nSpecialEffect );
1682 rPropSet->setPropertyValue( WW8_ASCII2STR("VisualEffect"), aTmp);
1683
1684 if (pValue && !bSetInDialog)
1685 {
1686 sal_Int16 nTmp = pValue[0]-0x30;
1687 aTmp <<= nTmp;
1688 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
1689 }
1690
1691 if (pCaption)
1692 {
1693 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
1694 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
1695 }
1696
1697 // #i40279# always centered vertically
1698 aTmp <<= ::com::sun::star::style::VerticalAlignment_MIDDLE;
1699 rPropSet->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp );
1700
1701 aFontData.Import(rPropSet);
1702 return sal_True;
1703 }
1704
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)1705 sal_Bool OCX_OptionButton::WriteContents(SvStorageStreamRef &rContents,
1706 const uno::Reference< beans::XPropertySet > &rPropSet,
1707 const awt::Size &rSize)
1708 {
1709 sal_Bool bRet=sal_True;
1710
1711 sal_uInt32 nOldPos = rContents->Tell();
1712 rContents->SeekRel(12);
1713
1714 pBlockFlags[0] = 0;
1715 pBlockFlags[1] = 0x01;
1716 pBlockFlags[2] = 0;
1717 pBlockFlags[3] = 0x80;
1718 pBlockFlags[4] = 0;
1719 pBlockFlags[5] = 0;
1720 pBlockFlags[6] = 0;
1721 pBlockFlags[7] = 0;
1722
1723 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
1724 fEnabled = any2bool(aTmp);
1725
1726 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1727 if (aTmp.hasValue())
1728 aTmp >>= mnBackColor;
1729 else
1730 fBackStyle = 0;
1731
1732 sal_uInt8 nTemp=0;//=fEnabled;
1733 if (fEnabled)
1734 nTemp |= 0x02;
1735 if (fBackStyle)
1736 nTemp |= 0x08;
1737 *rContents << nTemp;
1738 pBlockFlags[0] |= 0x01;
1739 *rContents << sal_uInt8(0x00);
1740 nTemp = 0;
1741 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
1742 fWordWrap = any2bool(aTmp);
1743 if (fWordWrap)
1744 nTemp |= 0x80;
1745 *rContents << nTemp;
1746 *rContents << sal_uInt8(0x00);
1747
1748 *rContents << ExportColor(mnBackColor);
1749 pBlockFlags[0] |= 0x02;
1750
1751 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
1752 if (aTmp.hasValue())
1753 aTmp >>= mnForeColor;
1754 *rContents << ExportColor(mnForeColor);
1755 pBlockFlags[0] |= 0x04;
1756
1757 nStyle = 5;
1758 *rContents << nStyle;
1759 pBlockFlags[0] |= 0x40;
1760
1761 WriteAlign(rContents,4);
1762 nValueLen = 1|SVX_MSOCX_COMPRESSED;
1763 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultState"));
1764 sal_Int16 nDefault = sal_Int16();
1765 aTmp >>= nDefault;
1766 *rContents << nValueLen;
1767 pBlockFlags[2] |= 0x40;
1768
1769
1770 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
1771 if (aCaption.HasData())
1772 pBlockFlags[2] |= 0x80;
1773 aCaption.WriteLenField( *rContents );
1774
1775 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("VisualEffect"));
1776 if (aTmp.hasValue())
1777 {
1778 sal_Int16 nApiSpecEffect = sal_Int16();
1779 aTmp >>= nApiSpecEffect;
1780 nSpecialEffect = ExportSpecEffect( nApiSpecEffect );
1781 }
1782 *rContents << nSpecialEffect;
1783 pBlockFlags[3] |= 0x04;
1784
1785 WriteAlign(rContents,4);
1786 *rContents << rSize.Width;
1787 *rContents << rSize.Height;
1788
1789 nDefault += 0x30;
1790 *rContents << sal_uInt8(nDefault);
1791 *rContents << sal_uInt8(0x00);
1792
1793 aCaption.WriteCharArray( *rContents );
1794
1795 WriteAlign(rContents,4);
1796 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
1797 bRet = aFontData.Export(rContents,rPropSet);
1798
1799 rContents->Seek(nOldPos);
1800 *rContents << nStandardId;
1801 *rContents << nFixedAreaLen;
1802
1803 *rContents << pBlockFlags[0];
1804 *rContents << pBlockFlags[1];
1805 *rContents << pBlockFlags[2];
1806 *rContents << pBlockFlags[3];
1807 *rContents << pBlockFlags[4];
1808 *rContents << pBlockFlags[5];
1809 *rContents << pBlockFlags[6];
1810 *rContents << pBlockFlags[7];
1811
1812 DBG_ASSERT((rContents.Is() &&
1813 (SVSTREAM_OK==rContents->GetError())),"damn");
1814 return bRet;
1815 }
1816
1817
1818
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)1819 sal_Bool OCX_OptionButton::Export(SvStorageRef &rObj,
1820 const uno::Reference< beans::XPropertySet > &rPropSet,
1821 const awt::Size &rSize)
1822 {
1823 static sal_uInt8 __READONLY_DATA aCompObj[] = {
1824 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1825 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1826 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1827 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1828 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1829 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1830 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1831 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1832 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1833 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1834 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1835 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1836 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1837 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1838 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1839 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1840 };
1841
1842 {
1843 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
1844 xStor->Write(aCompObj,sizeof(aCompObj));
1845 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
1846 }
1847
1848 {
1849 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
1850 xStor3->Write(aObjInfo,sizeof(aObjInfo));
1851 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
1852 }
1853
1854 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
1855 0x4F, 0x00, 0x70, 0x00, 0x74, 0x00, 0x69, 0x00,
1856 0x6F, 0x00, 0x6E, 0x00, 0x42, 0x00, 0x75, 0x00,
1857 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x6E, 0x00,
1858 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1859 };
1860
1861 {
1862 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
1863 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
1864 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
1865 }
1866
1867 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
1868 return WriteContents(xContents, rPropSet, rSize);
1869 }
1870
1871
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)1872 sal_Bool OCX_TextBox::Import(com::sun::star::uno::Reference<
1873 com::sun::star::beans::XPropertySet> &rPropSet)
1874 {
1875 uno::Any aTmp(&sName,getCppuType((OUString *)0));
1876 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
1877
1878 aTmp = bool2any( fEnabled != 0 );
1879 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
1880
1881 aTmp = bool2any( fLocked != 0 );
1882 rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
1883
1884 aTmp = bool2any( fHideSelection != 0 );
1885 rPropSet->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp);
1886
1887 aTmp <<= ImportColor(mnForeColor);
1888 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
1889
1890 aTmp <<= ImportColor(mnBackColor);
1891 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
1892
1893 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
1894 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
1895
1896 aTmp <<= ImportColor( nBorderColor );
1897 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
1898
1899 aTmp = bool2any( fMultiLine != 0 );
1900 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
1901
1902 sal_uInt16 nTmp = static_cast<sal_uInt16>(nMaxLength);
1903 aTmp <<= nTmp;
1904 rPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);
1905
1906
1907 sal_Bool bTemp1,bTemp2;
1908 uno::Any aBarsH,aBarsV;
1909 switch(nScrollBars)
1910 {
1911 case 1:
1912 bTemp1 = sal_True;
1913 bTemp2 = sal_False;
1914 break;
1915 case 2:
1916 bTemp1 = sal_False;
1917 bTemp2 = sal_True;
1918 break;
1919 case 3:
1920 bTemp1 = sal_True;
1921 bTemp2 = sal_True;
1922 break;
1923 case 0:
1924 default:
1925 bTemp1 = sal_False;
1926 bTemp2 = sal_False;
1927 break;
1928 }
1929
1930 aBarsH = bool2any(bTemp1);
1931 aBarsV = bool2any(bTemp2);
1932 rPropSet->setPropertyValue( WW8_ASCII2STR("HScroll"), aBarsH);
1933 rPropSet->setPropertyValue( WW8_ASCII2STR("VScroll"), aBarsV);
1934
1935 nTmp = nPasswordChar;
1936 aTmp <<= nTmp;
1937 rPropSet->setPropertyValue( WW8_ASCII2STR("EchoChar"), aTmp);
1938
1939 if (pValue)
1940 {
1941 aTmp <<= lclCreateOUString( pValue, nValueLen );
1942 // DefaultText seems to no longer be in UnoEditControlModel
1943 if ( bSetInDialog )
1944 {
1945 rPropSet->setPropertyValue( WW8_ASCII2STR("Text"), aTmp);
1946 }
1947 else
1948 {
1949 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
1950 }
1951 }
1952
1953 aFontData.Import(rPropSet);
1954 return sal_True;
1955 }
1956
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)1957 sal_Bool OCX_TextBox::WriteContents(SvStorageStreamRef &rContents,
1958 const uno::Reference< beans::XPropertySet > &rPropSet,
1959 const awt::Size &rSize)
1960 {
1961 sal_Bool bRet=sal_True;
1962 sal_uInt32 nOldPos = rContents->Tell();
1963 rContents->SeekRel(12);
1964
1965 pBlockFlags[0] = 0;
1966 pBlockFlags[1] = 0x01;
1967 pBlockFlags[2] = 0x00;
1968 pBlockFlags[3] = 0x80;
1969 pBlockFlags[4] = 0;
1970 pBlockFlags[5] = 0;
1971 pBlockFlags[6] = 0;
1972 pBlockFlags[7] = 0;
1973
1974
1975 sal_uInt8 nTemp=0x19;
1976 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
1977 fEnabled = any2bool(aTmp);
1978 if (fEnabled)
1979 nTemp |= 0x02;
1980
1981 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
1982 fLocked = any2bool(aTmp);
1983 if (fLocked)
1984 nTemp |= 0x04;
1985
1986 *rContents << nTemp;
1987 pBlockFlags[0] |= 0x01;
1988 *rContents << sal_uInt8(0x48);
1989 *rContents << sal_uInt8(0x80);
1990
1991 fMultiLine = any2bool(rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine")));
1992 fHideSelection = any2bool(rPropSet->getPropertyValue(WW8_ASCII2STR("HideInactiveSelection")));
1993 nTemp = 0x0C;
1994 if (fMultiLine)
1995 nTemp |= 0x80;
1996 if( fHideSelection )
1997 nTemp |= 0x20;
1998 *rContents << nTemp;
1999
2000 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2001 if (aTmp.hasValue())
2002 aTmp >>= mnBackColor;
2003 *rContents << ExportColor(mnBackColor);
2004 pBlockFlags[0] |= 0x02;
2005
2006 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2007 if (aTmp.hasValue())
2008 aTmp >>= mnForeColor;
2009 *rContents << ExportColor(mnForeColor);
2010 pBlockFlags[0] |= 0x04;
2011
2012 aTmp = rPropSet->getPropertyValue( WW8_ASCII2STR("MaxTextLen"));
2013 aTmp >>= nMaxLength;
2014 *rContents << nMaxLength;
2015 pBlockFlags[0] |= 0x08;
2016
2017 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
2018 sal_Int16 nBorder = sal_Int16();
2019 aTmp >>= nBorder;
2020 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
2021 *rContents << nBorderStyle;
2022 pBlockFlags[0] |= 0x10;
2023
2024 aTmp = rPropSet->getPropertyValue( WW8_ASCII2STR("HScroll"));
2025 sal_Bool bTemp1 = any2bool(aTmp);
2026 aTmp = rPropSet->getPropertyValue( WW8_ASCII2STR("VScroll"));
2027 sal_Bool bTemp2 = any2bool(aTmp);
2028 if (!bTemp1 && !bTemp2)
2029 nScrollBars =0;
2030 else if (bTemp1 && bTemp2)
2031 nScrollBars = 3;
2032 else if (!bTemp1 && bTemp2)
2033 nScrollBars = 2;
2034 else
2035 nScrollBars = 1;
2036 *rContents << nScrollBars;
2037 pBlockFlags[0] |= 0x20;
2038
2039 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("EchoChar"));
2040 sal_uInt16 nTmp = sal_uInt16();
2041 aTmp >>= nTmp;
2042 nPasswordChar = static_cast<sal_uInt8>(nTmp);
2043 *rContents << nPasswordChar;
2044 pBlockFlags[1] |= 0x02;
2045
2046 SvxOcxString aValue( rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2047 aValue.WriteLenField( *rContents );
2048 if (aValue.HasData())
2049 pBlockFlags[2] |= 0x40;
2050
2051 WriteAlign(rContents,4);
2052 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2053 if (aTmp.hasValue())
2054 aTmp >>= nBorderColor;
2055 *rContents << ExportColor(nBorderColor);
2056 pBlockFlags[3] |= 0x02;
2057
2058 *rContents << nSpecialEffect;
2059 pBlockFlags[3] |= 0x04;
2060
2061 WriteAlign(rContents,4);
2062 *rContents << rSize.Width;
2063 *rContents << rSize.Height;
2064
2065 aValue.WriteCharArray( *rContents );
2066
2067 WriteAlign(rContents,4);
2068
2069 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2070
2071 bRet = aFontData.Export(rContents,rPropSet);
2072
2073 rContents->Seek(nOldPos);
2074 *rContents << nStandardId;
2075 *rContents << nFixedAreaLen;
2076
2077 *rContents << pBlockFlags[0];
2078 *rContents << pBlockFlags[1];
2079 *rContents << pBlockFlags[2];
2080 *rContents << pBlockFlags[3];
2081 *rContents << pBlockFlags[4];
2082 *rContents << pBlockFlags[5];
2083 *rContents << pBlockFlags[6];
2084 *rContents << pBlockFlags[7];
2085
2086 DBG_ASSERT((rContents.Is() &&
2087 (SVSTREAM_OK == rContents->GetError())),"damn");
2088 return bRet;
2089 }
2090
2091
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2092 sal_Bool OCX_TextBox::Export(SvStorageRef &rObj,
2093 const uno::Reference< beans::XPropertySet > &rPropSet,
2094 const awt::Size &rSize)
2095 {
2096 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2097 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2098 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
2099 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2100 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
2101 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2102 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2103 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
2104 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
2105 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
2106 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
2107 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
2108 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
2109 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
2110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2111 0x00, 0x00, 0x00, 0x00
2112 };
2113
2114 {
2115 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2116 xStor->Write(aCompObj,sizeof(aCompObj));
2117 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2118 }
2119
2120 {
2121 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2122 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2123 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2124 }
2125
2126 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2127 0x54, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00,
2128 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
2129 0x00, 0x00, 0x00, 0x00
2130 };
2131
2132 {
2133 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2134 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2135 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2136 }
2137
2138 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2139 return WriteContents(xContents, rPropSet, rSize);
2140 }
2141
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2142 sal_Bool OCX_FieldControl::WriteContents(SvStorageStreamRef &rContents,
2143 const uno::Reference< beans::XPropertySet > &rPropSet,
2144 const awt::Size &rSize)
2145 {
2146 sal_Bool bRet=sal_True;
2147 sal_uInt32 nOldPos = rContents->Tell();
2148 rContents->SeekRel(12);
2149
2150 pBlockFlags[0] = 0;
2151 pBlockFlags[1] = 0x01;
2152 pBlockFlags[2] = 0x00;
2153 pBlockFlags[3] = 0x80;
2154 pBlockFlags[4] = 0;
2155 pBlockFlags[5] = 0;
2156 pBlockFlags[6] = 0;
2157 pBlockFlags[7] = 0;
2158
2159
2160 sal_uInt8 nTemp=0x19;
2161 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2162 fEnabled = any2bool(aTmp);
2163 if (fEnabled)
2164 nTemp |= 0x02;
2165
2166 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2167 fLocked = any2bool(aTmp);
2168 if (fLocked)
2169 nTemp |= 0x04;
2170
2171 *rContents << nTemp;
2172 pBlockFlags[0] |= 0x01;
2173 *rContents << sal_uInt8(0x48);
2174 *rContents << sal_uInt8(0x80);
2175
2176 nTemp = 0x2C;
2177 *rContents << nTemp;
2178
2179 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2180 if (aTmp.hasValue())
2181 aTmp >>= mnBackColor;
2182 *rContents << ExportColor(mnBackColor);
2183 pBlockFlags[0] |= 0x02;
2184
2185 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2186 if (aTmp.hasValue())
2187 aTmp >>= mnForeColor;
2188 *rContents << ExportColor(mnForeColor);
2189 pBlockFlags[0] |= 0x04;
2190
2191 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
2192 sal_Int16 nBorder = sal_Int16();
2193 aTmp >>= nBorder;
2194 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
2195 *rContents << nBorderStyle;
2196 pBlockFlags[0] |= 0x10;
2197
2198 #if 0 //Each control has a different Value format, and how to convert each to text has to be found out
2199 SvxOcxString aValue( rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2200 aValue.WriteLenField( *rContents );
2201 if (aValue.HasData())
2202 pBlockFlags[2] |= 0x40;
2203 #endif
2204
2205 *rContents << nSpecialEffect;
2206 pBlockFlags[3] |= 0x04;
2207
2208 WriteAlign(rContents,4);
2209 *rContents << rSize.Width;
2210 *rContents << rSize.Height;
2211
2212 #if 0
2213 aValue.WriteCharArray( *rContents );
2214 #endif
2215
2216 WriteAlign(rContents,4);
2217
2218 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2219
2220 bRet = aFontData.Export(rContents,rPropSet);
2221
2222 rContents->Seek(nOldPos);
2223 *rContents << nStandardId;
2224 *rContents << nFixedAreaLen;
2225
2226 *rContents << pBlockFlags[0];
2227 *rContents << pBlockFlags[1];
2228 *rContents << pBlockFlags[2];
2229 *rContents << pBlockFlags[3];
2230 *rContents << pBlockFlags[4];
2231 *rContents << pBlockFlags[5];
2232 *rContents << pBlockFlags[6];
2233 *rContents << pBlockFlags[7];
2234
2235 DBG_ASSERT((rContents.Is() &&
2236 (SVSTREAM_OK==rContents->GetError())),"damn");
2237 return bRet;
2238 }
2239
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2240 sal_Bool OCX_FieldControl::Export(SvStorageRef &rObj,
2241 const uno::Reference< beans::XPropertySet > &rPropSet,
2242 const awt::Size &rSize)
2243 {
2244 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2245 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2246 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
2247 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2248 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
2249 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2250 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2251 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
2252 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
2253 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
2254 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
2255 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
2256 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
2257 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
2258 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2259 0x00, 0x00, 0x00, 0x00
2260 };
2261
2262 {
2263 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2264 xStor->Write(aCompObj,sizeof(aCompObj));
2265 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2266 }
2267
2268 {
2269 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2270 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2271 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2272 }
2273
2274 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2275 0x54, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00,
2276 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
2277 0x00, 0x00, 0x00, 0x00
2278 };
2279
2280 {
2281 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2282 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2283 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2284 }
2285
2286 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2287 return WriteContents(xContents, rPropSet, rSize);
2288 }
2289
2290
2291
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)2292 sal_Bool OCX_ToggleButton::Import(com::sun::star::uno::Reference<
2293 com::sun::star::beans::XPropertySet> &rPropSet)
2294 {
2295 uno::Any aTmp(&sName,getCppuType((OUString *)0));
2296 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
2297
2298 aTmp = bool2any(true);
2299 rPropSet->setPropertyValue( WW8_ASCII2STR("Toggle"), aTmp );
2300
2301 sal_Bool bTemp;
2302 if ((!(fEnabled)) || (fLocked))
2303 bTemp = sal_False;
2304 else
2305 bTemp = sal_True;
2306 aTmp = bool2any(bTemp);
2307 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
2308
2309 bTemp = fWordWrap != 0;
2310 aTmp = bool2any(bTemp);
2311 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
2312
2313 aTmp <<= ImportColor(mnForeColor);
2314 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
2315
2316 // fake transparent toggle button by setting window background color
2317 if( !fBackStyle )
2318 mnBackColor = 0x80000005;
2319 aTmp <<= ImportColor(mnBackColor);
2320 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
2321
2322 if (pValue)
2323 {
2324 sal_Int16 nTmp=pValue[0]-0x30;
2325 aTmp <<= nTmp == 1;
2326 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
2327 }
2328
2329 if (pCaption)
2330 {
2331 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
2332 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
2333 }
2334
2335 aFontData.Import(rPropSet);
2336 return sal_True;
2337 }
2338
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2339 sal_Bool OCX_ToggleButton::Export(
2340 SvStorageRef &rObj, const uno::Reference< beans::XPropertySet> &rPropSet,
2341 const awt::Size& rSize )
2342 {
2343 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2344 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2345 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
2346 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2347 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
2348 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2349 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2350 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
2351 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
2352 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
2353 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
2354 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
2355 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
2356 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
2357 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2358 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2360 };
2361
2362 {
2363 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2364 xStor->Write(aCompObj,sizeof(aCompObj));
2365 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2366 }
2367
2368 {
2369 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2370 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2371 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2372 }
2373
2374 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2375 0x54, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x67, 0x00,
2376 0x6C, 0x00, 0x65, 0x00, 0x42, 0x00, 0x75, 0x00,
2377 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x6E, 0x00,
2378 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
2379 };
2380
2381 {
2382 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2383 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2384 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2385 }
2386
2387 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2388
2389 return WriteContents(xContents,rPropSet,rSize);
2390 }
2391
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2392 sal_Bool OCX_ToggleButton::WriteContents(SvStorageStreamRef &rContents,
2393 const uno::Reference< beans::XPropertySet > &rPropSet,
2394 const awt::Size &rSize)
2395 {
2396 sal_Bool bRet=sal_True;
2397 sal_uInt32 nOldPos = rContents->Tell();
2398 rContents->SeekRel(12);
2399
2400 pBlockFlags[0] = 0;
2401 pBlockFlags[1] = 0x01;
2402 pBlockFlags[2] = 0;
2403 pBlockFlags[3] = 0x80;
2404 pBlockFlags[4] = 0;
2405 pBlockFlags[5] = 0;
2406 pBlockFlags[6] = 0;
2407 pBlockFlags[7] = 0;
2408
2409 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2410 fEnabled = any2bool(aTmp);
2411
2412 sal_uInt8 nTemp=fEnabled;
2413 if (fEnabled)
2414 nTemp = nTemp << 1;
2415 if (fBackStyle)
2416 nTemp |= 0x08;
2417 *rContents << nTemp;
2418 pBlockFlags[0] |= 0x01;
2419 *rContents << sal_uInt8(0x00);
2420 nTemp = 0;
2421 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
2422 fWordWrap = any2bool(aTmp);
2423 if (fWordWrap)
2424 nTemp |= 0x80;
2425 *rContents << nTemp;
2426 *rContents << sal_uInt8(0x00);
2427
2428 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2429 if (aTmp.hasValue())
2430 aTmp >>= mnBackColor;
2431 *rContents << ExportColor(mnBackColor);
2432 pBlockFlags[0] |= 0x02;
2433
2434 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2435 if (aTmp.hasValue())
2436 aTmp >>= mnForeColor;
2437 *rContents << ExportColor(mnForeColor);
2438 pBlockFlags[0] |= 0x04;
2439
2440 nStyle = 6;
2441 *rContents << nStyle;
2442 pBlockFlags[0] |= 0x40;
2443
2444 WriteAlign(rContents,4);
2445 nValueLen = 1|SVX_MSOCX_COMPRESSED;
2446 bool bDefault = false;
2447 rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultState")) >>= bDefault;
2448 sal_uInt8 nDefault = static_cast< sal_uInt8 >( bDefault ? '1' : '0' );
2449 *rContents << nValueLen;
2450 pBlockFlags[2] |= 0x40;
2451
2452 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
2453 aCaption.WriteLenField( *rContents );
2454 if (aCaption.HasData())
2455 pBlockFlags[2] |= 0x80;
2456
2457 WriteAlign(rContents,4);
2458 *rContents << rSize.Width;
2459 *rContents << rSize.Height;
2460
2461 *rContents << nDefault;
2462 *rContents << sal_uInt8(0x00);
2463
2464 aCaption.WriteCharArray( *rContents );
2465
2466 WriteAlign(rContents,4);
2467 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2468 bRet = aFontData.Export(rContents,rPropSet);
2469 rContents->Seek(nOldPos);
2470 *rContents << nStandardId;
2471 *rContents << nFixedAreaLen;
2472
2473 *rContents << pBlockFlags[0];
2474 *rContents << pBlockFlags[1];
2475 *rContents << pBlockFlags[2];
2476 *rContents << pBlockFlags[3];
2477 *rContents << pBlockFlags[4];
2478 *rContents << pBlockFlags[5];
2479 *rContents << pBlockFlags[6];
2480 *rContents << pBlockFlags[7];
2481
2482 DBG_ASSERT((rContents.Is() &&
2483 (SVSTREAM_OK==rContents->GetError())),"damn");
2484 return bRet;
2485 }
2486
Import(uno::Reference<beans::XPropertySet> & rPropSet)2487 sal_Bool OCX_Label::Import(uno::Reference< beans::XPropertySet > &rPropSet)
2488 {
2489 uno::Any aTmp(&sName,getCppuType((OUString *)0));
2490 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
2491
2492 sal_Bool bTemp;
2493 if ((!(fEnabled)) || (fLocked))
2494 bTemp = sal_False;
2495 else
2496 bTemp = sal_True;
2497 aTmp = bool2any(bTemp);
2498 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
2499
2500 aTmp <<= ImportColor(mnForeColor);
2501 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
2502
2503 // background color: fBackStyle==0 -> transparent
2504 if( fBackStyle )
2505 {
2506 aTmp <<= ImportColor(mnBackColor);
2507 }
2508 else
2509 {
2510 // try fake transparent by using parents backColor
2511 if ( bSetInDialog && mpParent != NULL )
2512 {
2513 aTmp <<= ImportColor( mpParent->mnBackColor );
2514 }
2515 else
2516 {
2517 aTmp = uno::Any(); // use SO default
2518 }
2519 }
2520 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
2521
2522 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
2523 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
2524
2525 aTmp <<= ImportColor( nBorderColor );
2526 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
2527
2528 bTemp=fWordWrap;
2529 aTmp = bool2any(bTemp);
2530 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
2531
2532 if (pCaption)
2533 {
2534 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
2535 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
2536 }
2537
2538 aFontData.Import(rPropSet);
2539 return sal_True;
2540 }
2541
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)2542 sal_Bool OCX_ComboBox::Import(com::sun::star::uno::Reference<
2543 com::sun::star::beans::XPropertySet> &rPropSet)
2544 {
2545
2546 uno::Any aTmp(&sName,getCppuType((OUString *)0));
2547 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
2548
2549 aTmp = bool2any(fEnabled != 0);
2550 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
2551
2552 aTmp = bool2any(fLocked != 0);
2553 rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
2554
2555 aTmp = bool2any( nDropButtonStyle != 0 );
2556 rPropSet->setPropertyValue( WW8_ASCII2STR("Dropdown"), aTmp);
2557
2558 aTmp = bool2any( fHideSelection != 0 );
2559 rPropSet->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp);
2560
2561 aTmp <<= ImportColor(mnForeColor);
2562 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
2563
2564 if (pValue)
2565 {
2566 aTmp <<= lclCreateOUString( pValue, nValueLen );
2567 if ( bSetInDialog )
2568 {
2569 rPropSet->setPropertyValue( WW8_ASCII2STR("Text"), aTmp);
2570 }
2571 else
2572 {
2573 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
2574 }
2575 }
2576
2577 aTmp <<= ImportColor(mnBackColor);
2578 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
2579
2580 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
2581 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
2582
2583 aTmp <<= ImportColor( nBorderColor );
2584 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
2585
2586 sal_Int16 nTmp=static_cast<sal_Int16>(nMaxLength);
2587 aTmp <<= nTmp;
2588 rPropSet->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp);
2589
2590 aFontData.Import(rPropSet);
2591 return sal_True;
2592 }
2593
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2594 sal_Bool OCX_ComboBox::WriteContents(SvStorageStreamRef &rContents,
2595 const uno::Reference< beans::XPropertySet > &rPropSet,
2596 const awt::Size &rSize)
2597 {
2598 sal_Bool bRet=sal_True;
2599 sal_uInt32 nOldPos = rContents->Tell();
2600 rContents->SeekRel(12);
2601
2602 pBlockFlags[0] = 0;
2603 pBlockFlags[1] = 0x01;
2604 pBlockFlags[2] = 0x00;
2605 pBlockFlags[3] = 0x80;
2606 pBlockFlags[4] = 0;
2607 pBlockFlags[5] = 0;
2608 pBlockFlags[6] = 0;
2609 pBlockFlags[7] = 0;
2610
2611
2612 sal_uInt8 nTemp=0x19;//fEnabled;
2613 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2614 fEnabled = any2bool(aTmp);
2615 if (fEnabled)
2616 nTemp |= 0x02;
2617
2618 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2619 fLocked = any2bool(aTmp);
2620 if (fLocked)
2621 nTemp |= 0x04;
2622
2623 *rContents << nTemp;
2624 pBlockFlags[0] |= 0x01;
2625 *rContents << sal_uInt8(0x48);
2626 *rContents << sal_uInt8(0x80);
2627
2628 nTemp = 0x0C;
2629 fHideSelection = any2bool(rPropSet->getPropertyValue(WW8_ASCII2STR("HideInactiveSelection")));
2630 if( fHideSelection )
2631 nTemp |= 0x20;
2632 *rContents << nTemp;
2633
2634 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2635 if (aTmp.hasValue())
2636 aTmp >>= mnBackColor;
2637 *rContents << ExportColor(mnBackColor);
2638 pBlockFlags[0] |= 0x02;
2639
2640 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2641 if (aTmp.hasValue())
2642 aTmp >>= mnForeColor;
2643 *rContents << ExportColor(mnForeColor);
2644 pBlockFlags[0] |= 0x04;
2645
2646 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
2647 sal_Int16 nBorder = sal_Int16();
2648 aTmp >>= nBorder;
2649 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
2650 *rContents << nBorderStyle;
2651 pBlockFlags[0] |= 0x10;
2652
2653 nStyle = 3;
2654 *rContents << nStyle;
2655 pBlockFlags[0] |= 0x40;
2656
2657 WriteAlign(rContents,2);
2658
2659 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("LineCount"));
2660 aTmp >>= nListRows;
2661 *rContents << nListRows;
2662 pBlockFlags[1] |= 0x40;
2663
2664 *rContents << sal_uInt8(1); //DefaultSelected One
2665 pBlockFlags[2] |= 0x01;
2666
2667 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Dropdown"));
2668 nDropButtonStyle = any2bool(aTmp);
2669 if (nDropButtonStyle)
2670 nDropButtonStyle=0x02;
2671 *rContents << nDropButtonStyle;
2672 pBlockFlags[2] |= 0x04;
2673
2674 SvxOcxString aValue( rPropSet->getPropertyValue(WW8_ASCII2STR("Text")) );
2675 aValue.WriteLenField( *rContents );
2676 if (aValue.HasData())
2677 pBlockFlags[2] |= 0x40;
2678
2679 WriteAlign(rContents,4);
2680 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2681 if (aTmp.hasValue())
2682 aTmp >>= nBorderColor;
2683 *rContents << ExportColor(nBorderColor);
2684 pBlockFlags[3] |= 0x02;
2685
2686 *rContents << nSpecialEffect;
2687 pBlockFlags[3] |= 0x04;
2688
2689 WriteAlign(rContents,4);
2690 *rContents << rSize.Width;
2691 *rContents << rSize.Height;
2692
2693 aValue.WriteCharArray( *rContents );
2694
2695 WriteAlign(rContents,4);
2696
2697 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2698
2699 bRet = aFontData.Export(rContents,rPropSet);
2700
2701 rContents->Seek(nOldPos);
2702 *rContents << nStandardId;
2703 *rContents << nFixedAreaLen;
2704
2705 *rContents << pBlockFlags[0];
2706 *rContents << pBlockFlags[1];
2707 *rContents << pBlockFlags[2];
2708 *rContents << pBlockFlags[3];
2709 *rContents << pBlockFlags[4];
2710 *rContents << pBlockFlags[5];
2711 *rContents << pBlockFlags[6];
2712 *rContents << pBlockFlags[7];
2713
2714 DBG_ASSERT((rContents.Is() &&
2715 (SVSTREAM_OK==rContents->GetError())),"damn");
2716 return bRet;
2717 }
2718
2719
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2720 sal_Bool OCX_ComboBox::Export(SvStorageRef &rObj,
2721 const uno::Reference< beans::XPropertySet > &rPropSet,
2722 const awt::Size &rSize)
2723 {
2724 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2725 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2726 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2727 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2728 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2729 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2730 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2731 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2732 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2733 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2734 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2735 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2736 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2737 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2738 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2739 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2740 };
2741
2742 {
2743 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2744 xStor->Write(aCompObj,sizeof(aCompObj));
2745 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2746 }
2747
2748 {
2749 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2750 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2751 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2752 }
2753
2754 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2755 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x62, 0x00,
2756 0x6F, 0x00, 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00,
2757 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
2758 };
2759
2760 {
2761 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2762 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2763 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2764 }
2765
2766 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2767 return WriteContents(xContents, rPropSet, rSize);
2768 }
2769
2770
2771
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)2772 sal_Bool OCX_ListBox::Import(com::sun::star::uno::Reference<
2773 com::sun::star::beans::XPropertySet> &rPropSet)
2774 {
2775
2776 uno::Any aTmp(&sName,getCppuType((OUString *)0));
2777 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
2778
2779 sal_Bool bTmp=fEnabled;
2780 aTmp = bool2any(bTmp);
2781 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
2782
2783 bTmp=fLocked;
2784 aTmp = bool2any(bTmp);
2785 rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
2786
2787 aTmp <<= ImportColor(mnForeColor);
2788 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
2789
2790 sal_Bool bTemp = nMultiState;
2791 aTmp = bool2any(bTemp);
2792 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiSelection"), aTmp);
2793
2794 #if 0 //Don't delete this for now until I figure out if I can make this
2795 if (pValue)
2796 {
2797 aTmp <<= lclCreateOUString( pValue, nValueLen );
2798 xPropSet->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp);
2799 }
2800 #endif
2801
2802 aTmp <<= ImportColor(mnBackColor);
2803 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
2804
2805 aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
2806 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
2807
2808 aTmp <<= ImportColor( nBorderColor );
2809 rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
2810
2811 aFontData.Import(rPropSet);
2812 return sal_True;
2813 }
2814
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2815 sal_Bool OCX_ListBox::WriteContents(SvStorageStreamRef &rContents,
2816 const uno::Reference< beans::XPropertySet > &rPropSet,
2817 const awt::Size &rSize)
2818 {
2819 sal_Bool bRet=sal_True;
2820 sal_uInt32 nOldPos = rContents->Tell();
2821 rContents->SeekRel(12);
2822
2823 pBlockFlags[0] = 0;
2824 pBlockFlags[1] = 0x01;
2825 pBlockFlags[2] = 0x01;
2826 pBlockFlags[3] = 0x80;
2827 pBlockFlags[4] = 0;
2828 pBlockFlags[5] = 0;
2829 pBlockFlags[6] = 0;
2830 pBlockFlags[7] = 0;
2831
2832 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
2833 fEnabled = any2bool(aTmp);
2834 sal_uInt8 nTemp=fEnabled;
2835 if (fEnabled)
2836 nTemp = nTemp << 1;
2837
2838 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2839 fLocked = any2bool(aTmp);
2840 if (fLocked)
2841 nTemp |= 0x04;
2842
2843 *rContents << nTemp;
2844 pBlockFlags[0] |= 0x01;
2845 *rContents << sal_uInt8(0x00);
2846 *rContents << sal_uInt8(0x00);
2847 *rContents << sal_uInt8(0x00);
2848
2849 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2850 if (aTmp.hasValue())
2851 aTmp >>= mnBackColor;
2852 *rContents << ExportColor(mnBackColor);
2853 pBlockFlags[0] |= 0x02;
2854
2855 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
2856 if (aTmp.hasValue())
2857 aTmp >>= mnForeColor;
2858 *rContents << ExportColor(mnForeColor);
2859 pBlockFlags[0] |= 0x04;
2860
2861 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
2862 sal_Int16 nBorder = sal_Int16();
2863 aTmp >>= nBorder;
2864 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
2865 WriteAlign(rContents,2);
2866 *rContents << nBorderStyle;
2867 pBlockFlags[0] |= 0x10;
2868
2869 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiSelection"));
2870 nMultiState = any2bool(aTmp);
2871
2872 if (nMultiState)
2873 {
2874 *rContents << nMultiState;
2875 pBlockFlags[0] |= 0x20;
2876 }
2877
2878 nStyle = 2;
2879 *rContents << nStyle;
2880 pBlockFlags[0] |= 0x40;
2881
2882
2883 WriteAlign(rContents,4);
2884
2885 #if 0
2886 SvxOcxString aValue( rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2887 aValue.WriteLenField( *rContents );
2888 if (aValue.HasData())
2889 pBlockFlags[2] |= 0x40;
2890
2891 WriteAlign(rContents,4);
2892 #endif
2893
2894 WriteAlign(rContents,4);
2895 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2896 if (aTmp.hasValue())
2897 aTmp >>= nBorderColor;
2898 *rContents << ExportColor(nBorderColor);
2899 pBlockFlags[3] |= 0x02;
2900
2901 *rContents << nSpecialEffect;
2902 pBlockFlags[3] |= 0x04;
2903
2904 WriteAlign(rContents,4);
2905 *rContents << rSize.Width;
2906 *rContents << rSize.Height;
2907
2908 #if 0
2909 aValue.WriteCharArray( *rContents );
2910 #endif
2911
2912 WriteAlign(rContents,4);
2913
2914 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
2915
2916 bRet = aFontData.Export(rContents,rPropSet);
2917
2918 rContents->Seek(nOldPos);
2919 *rContents << nStandardId;
2920 *rContents << nFixedAreaLen;
2921
2922 *rContents << pBlockFlags[0];
2923 *rContents << pBlockFlags[1];
2924 *rContents << pBlockFlags[2];
2925 *rContents << pBlockFlags[3];
2926 *rContents << pBlockFlags[4];
2927 *rContents << pBlockFlags[5];
2928 *rContents << pBlockFlags[6];
2929 *rContents << pBlockFlags[7];
2930
2931 DBG_ASSERT((rContents.Is() &&
2932 (SVSTREAM_OK==rContents->GetError())),"damn");
2933 return bRet;
2934 }
2935
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)2936 sal_Bool OCX_ListBox::Export(SvStorageRef &rObj,
2937 const uno::Reference< beans::XPropertySet > &rPropSet,
2938 const awt::Size &rSize)
2939 {
2940 static sal_uInt8 __READONLY_DATA aCompObj[] = {
2941 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2942 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
2943 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2944 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
2945 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2946 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2947 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
2948 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
2949 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
2950 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
2951 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
2952 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
2953 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
2954 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2955 0x00, 0x00, 0x00, 0x00
2956 };
2957
2958 {
2959 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
2960 xStor->Write(aCompObj,sizeof(aCompObj));
2961 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
2962 }
2963
2964 {
2965 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
2966 xStor3->Write(aObjInfo,sizeof(aObjInfo));
2967 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
2968 }
2969
2970 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
2971 0x4C, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00,
2972 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
2973 0x00, 0x00, 0x00, 0x00
2974 };
2975
2976 {
2977 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
2978 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
2979 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
2980 }
2981
2982 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
2983 return WriteContents(xContents, rPropSet, rSize);
2984 }
2985
Read(SvStorageStream * pS)2986 sal_Bool OCX_Control::Read(SvStorageStream *pS)
2987 {
2988 sal_uInt16 nIdentifier, nFixedAreaLen;
2989 *pS >> nIdentifier;
2990 DBG_ASSERT(nStandardId==nIdentifier,
2991 "A control that has a different identifier");
2992 *pS >> nFixedAreaLen;
2993 pS->SeekRel(nFixedAreaLen);
2994 return true;
2995 }
2996
Read(SvStorageStream * pS)2997 sal_Bool OCX_ModernControl::Read(SvStorageStream *pS)
2998 {
2999 long nStart = pS->Tell();
3000 *pS >> nIdentifier;
3001 DBG_ASSERT(nIdentifier==nStandardId,
3002 "A control that has a different identifier");
3003 *pS >> nFixedAreaLen;
3004 pS->Read(pBlockFlags,8);
3005
3006 if (pBlockFlags[0] & 0x01)
3007 {
3008 sal_uInt8 nTemp;
3009 *pS >> nTemp;
3010
3011 fEnabled = (nTemp & 0x02) >> 1;
3012 fLocked = (nTemp & 0x04) >> 2;
3013 fBackStyle = (nTemp & 0x08) >> 3;
3014
3015 *pS >> nTemp;
3016
3017 fColumnHeads = (nTemp & 0x04) >> 2;
3018 fIntegralHeight = (nTemp & 0x08) >> 3;
3019 fMatchRequired = (nTemp & 0x10) >> 4;
3020 fAlignment = (nTemp & 0x20) >> 5;
3021
3022 *pS >> nTemp;
3023
3024 fDragBehaviour = (nTemp & 0x08) >> 3;
3025 fEnterKeyBehaviour = (nTemp & 0x10) >> 4;
3026 fEnterFieldBehaviour = (nTemp & 0x20) >> 5;
3027 fTabKeyBehaviour = (nTemp & 0x40) >> 6;
3028 fWordWrap = (nTemp & 0x80) >> 7;
3029
3030 *pS >> nTemp;
3031 fSelectionMargin = (nTemp & 0x04) >> 2;
3032 fAutoWordSelect = (nTemp & 0x08) >> 3;
3033 fAutoSize = (nTemp & 0x10) >> 4;
3034 fHideSelection = (nTemp & 0x20) >> 5;
3035 fAutoTab = (nTemp & 0x40) >> 6;
3036 fMultiLine = (nTemp & 0x80) >> 7;
3037
3038 }
3039
3040 /*If any of these are set they follow eachother in this order one after
3041 another padded out to the next U32 boundary with 0's
3042 U8 can abut each other U16 must start on a U16 boundary and are padded to
3043 that with 0's. A standardish word alignment structure*/
3044
3045 if (pBlockFlags[0] & 0x02)
3046 *pS >> mnBackColor;
3047 if (pBlockFlags[0] & 0x04)
3048 *pS >> mnForeColor;
3049 if (pBlockFlags[0] & 0x08)
3050 *pS >> nMaxLength;
3051
3052 if (pBlockFlags[0] & 0x10)
3053 *pS >> nBorderStyle;
3054 if (pBlockFlags[0] & 0x20)
3055 *pS >> nScrollBars;
3056 if (pBlockFlags[0] & 0x40)
3057 *pS >> nStyle;// (UI 0 == Data 3, UI 2 = Data 7)
3058 if (pBlockFlags[0] & 0x80)
3059 *pS >> nMousePointer;
3060
3061 if (pBlockFlags[1] & 0x02)
3062 *pS >> nPasswordChar; //HUH ??? always 0 ??? not sure maybe just padding
3063
3064 if (pBlockFlags[1] & 0x04)
3065 {
3066 ReadAlign(pS, pS->Tell() - nStart, 4);
3067 *pS >> nListWidth;
3068 }
3069
3070 if (pBlockFlags[1] & 0x08)
3071 {
3072 ReadAlign(pS, pS->Tell() - nStart, 2);
3073 *pS >> nBoundColumn;
3074 }
3075 if (pBlockFlags[1] & 0x10)
3076 {
3077 ReadAlign(pS, pS->Tell() - nStart, 2);
3078 *pS >> nTextColumn;
3079 }
3080 if (pBlockFlags[1] & 0x20)
3081 {
3082 ReadAlign(pS, pS->Tell() - nStart, 2);
3083 *pS >> nColumnCount;
3084 }
3085 if (pBlockFlags[1] & 0x40)
3086 {
3087 ReadAlign(pS, pS->Tell() - nStart, 2);
3088 *pS >> nListRows;
3089 }
3090 if (pBlockFlags[1] & 0x80)
3091 {
3092 ReadAlign(pS, pS->Tell() - nStart, 2);
3093 *pS >> nUnknown8; //something to do with ColumnWidths
3094 }
3095 if (pBlockFlags[2] & 0x01)
3096 *pS >> nMatchEntry;
3097 if (pBlockFlags[2] & 0x02)
3098 *pS >> nListStyle;
3099 if (pBlockFlags[2] & 0x04)
3100 *pS >> nShowDropButtonWhen;
3101 if (pBlockFlags[2] & 0x10)
3102 *pS >> nDropButtonStyle;
3103 if (pBlockFlags[2] & 0x20)
3104 *pS >> nMultiState;
3105
3106 bool bValue = (pBlockFlags[2] & 0x40) != 0;
3107 if (bValue)
3108 {
3109 ReadAlign(pS, pS->Tell() - nStart, 4);
3110 *pS >> nValueLen;
3111 }
3112 bool bCaption = (pBlockFlags[2] & 0x80) != 0;
3113 if (bCaption)
3114 {
3115 ReadAlign(pS, pS->Tell() - nStart, 4);
3116 *pS >> nCaptionLen;
3117 }
3118 if (pBlockFlags[3] & 0x01)
3119 {
3120 ReadAlign(pS, pS->Tell() - nStart, 4);
3121 *pS >> nHorzPos;
3122 *pS >> nVertPos;
3123 }
3124 if (pBlockFlags[3] & 0x02)
3125 {
3126 ReadAlign(pS, pS->Tell() - nStart, 4);
3127 *pS >> nBorderColor;
3128 }
3129 if (pBlockFlags[3] & 0x04)
3130 {
3131 ReadAlign(pS, pS->Tell() - nStart, 4); // NEW
3132 *pS >> nSpecialEffect;
3133 pS->SeekRel( 3 ); // special effect is 32bit, not 8bit
3134 }
3135 if (pBlockFlags[3] & 0x08)
3136 {
3137 ReadAlign(pS, pS->Tell() - nStart, 2);
3138 *pS >> nIcon;
3139 DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
3140 }
3141 if (pBlockFlags[3] & 0x10)
3142 {
3143 ReadAlign(pS, pS->Tell() - nStart, 2);
3144 *pS >> nPicture;
3145 DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
3146 }
3147 if (pBlockFlags[3] & 0x20)
3148 *pS >> nAccelerator;
3149 /*
3150 if (pBlockFlags[3] & 0x80)
3151 *pS >> nUnknown9;
3152 */
3153 bool bGroupName = (pBlockFlags[4] & 0x01) != 0;
3154 if (bGroupName)
3155 {
3156 ReadAlign(pS, pS->Tell() - nStart, 4);
3157 *pS >> nGroupNameLen;
3158 }
3159
3160 //End
3161
3162 ReadAlign(pS, pS->Tell() - nStart, 4);
3163 *pS >> nWidth;
3164 *pS >> nHeight;
3165
3166 if (bValue)
3167 lclReadCharArray( *pS, pValue, nValueLen, pS->Tell() - nStart);
3168
3169 if (bCaption)
3170 lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
3171
3172 if (bGroupName)
3173 lclReadCharArray( *pS, pGroupName, nGroupNameLen, pS->Tell() - nStart);
3174
3175 ReadAlign(pS, pS->Tell() - nStart, 4);
3176 if (nIcon)
3177 {
3178 pS->Read(pIconHeader,20);
3179 *pS >> nIconLen;
3180 pIcon = new sal_uInt8[nIconLen];
3181 pS->Read(pIcon,nIconLen);
3182 }
3183
3184 if (nPicture)
3185 {
3186 pS->Read(pPictureHeader,20);
3187 *pS >> nPictureLen;
3188 pPicture = new sal_uInt8[nPictureLen];
3189 pS->Read(pPicture,nPictureLen);
3190 }
3191
3192 return sal_True;
3193 }
3194
3195
Read(SvStorageStream * pS)3196 sal_Bool OCX_CommandButton::Read(SvStorageStream *pS)
3197 {
3198 long nStart = pS->Tell();
3199 *pS >> nIdentifier;
3200 DBG_ASSERT(nStandardId==nIdentifier,
3201 "A control that has a different identifier");
3202 *pS >> nFixedAreaLen;
3203 pS->Read(pBlockFlags,4);
3204
3205
3206 if (pBlockFlags[0] & 0x01)
3207 *pS >> mnForeColor;
3208 if (pBlockFlags[0] & 0x02)
3209 *pS >> mnBackColor;
3210
3211 if (pBlockFlags[0] & 0x04)
3212 {
3213 sal_uInt8 nTemp;
3214 *pS >> nTemp;
3215 fEnabled = (nTemp&0x02)>>1;
3216 fLocked = (nTemp&0x04)>>2;
3217 fBackStyle = (nTemp&0x08)>>3;
3218 *pS >> nTemp;
3219 *pS >> nTemp;
3220 fWordWrap = (nTemp&0x80)>>7;
3221 *pS >> nTemp;
3222 fAutoSize = (nTemp&0x10)>>4;
3223 }
3224
3225 bool bCaption = (pBlockFlags[0] & 0x08) != 0;
3226 if (bCaption)
3227 {
3228 *pS >> nCaptionLen;
3229 }
3230 if (pBlockFlags[0] & 0x10) /*Picture Position, a strange mechanism here*/
3231 {
3232 *pS >> nVertPos;
3233 *pS >> nHorzPos;
3234 }
3235
3236 if (pBlockFlags[0] & 0x40) /*MousePointer*/
3237 *pS >> nMousePointer;
3238
3239 if (pBlockFlags[0] & 0x80)
3240 {
3241 ReadAlign(pS, pS->Tell() - nStart, 2);
3242 *pS >> nPicture;
3243 }
3244
3245 if (pBlockFlags[1] & 0x01)
3246 {
3247 ReadAlign(pS, pS->Tell() - nStart, 2);
3248 *pS >> nAccelerator;
3249 }
3250
3251 // "take focus on click" is directly in content flags, not in option field...
3252 mbTakeFocus = (pBlockFlags[1] & 0x02) == 0; // option is on, if flag is not set
3253
3254 if (pBlockFlags[1] & 0x04)
3255 {
3256 ReadAlign(pS, pS->Tell() - nStart, 2);
3257 *pS >> nIcon;
3258 }
3259
3260 if (bCaption)
3261 lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
3262
3263 ReadAlign(pS, pS->Tell() - nStart, 4);
3264 *pS >> nWidth;
3265 *pS >> nHeight;
3266
3267 if (nIcon)
3268 {
3269 pS->Read(pIconHeader,20);
3270 *pS >> nIconLen;
3271 pIcon = new sal_uInt8[nIconLen];
3272 pS->Read(pIcon,nIconLen);
3273 }
3274
3275 if (nPicture)
3276 {
3277 pS->Read(pPictureHeader,20);
3278 *pS >> nPictureLen;
3279 pPicture = new sal_uInt8[nPictureLen];
3280 pS->Read(pPicture,nPictureLen);
3281 }
3282
3283 return sal_True;
3284 }
3285
Read(SvStorageStream * pS)3286 sal_Bool OCX_Label::Read(SvStorageStream *pS)
3287 {
3288 long nStart = pS->Tell();
3289 *pS >> nIdentifier;
3290 DBG_ASSERT(nStandardId==nIdentifier,
3291 "A control that has a different identifier");
3292 *pS >> nFixedAreaLen;
3293 pS->Read(pBlockFlags,4);
3294
3295
3296 if (pBlockFlags[0] & 0x01)
3297 *pS >> mnForeColor;
3298 if (pBlockFlags[0] & 0x02)
3299 *pS >> mnBackColor;
3300
3301
3302 if (pBlockFlags[0] & 0x04)
3303 {
3304 sal_uInt8 nTemp;
3305 *pS >> nTemp;
3306 fEnabled = (nTemp&0x02)>>1;
3307 fLocked = (nTemp&0x04)>>2;
3308 fBackStyle = (nTemp&0x08)>>3;
3309 *pS >> nTemp;
3310 *pS >> nTemp;
3311 fWordWrap = (nTemp&0x80)>>7;
3312 *pS >> nTemp;
3313 fAutoSize = (nTemp&0x10)>>4;
3314 }
3315 bool bCaption = (pBlockFlags[0] & 0x08) != 0;
3316 if (bCaption)
3317 *pS >> nCaptionLen;
3318
3319 if (pBlockFlags[0] & 0x10)
3320 {
3321 *pS >> nVertPos;
3322 *pS >> nHorzPos;
3323 }
3324
3325 if (pBlockFlags[0] & 0x40)
3326 *pS >> nMousePointer;
3327
3328 if (pBlockFlags[0] & 0x80)
3329 {
3330 ReadAlign(pS,pS->Tell() - nStart, 4);
3331 *pS >> nBorderColor;
3332 }
3333
3334 if (pBlockFlags[1] & 0x01)
3335 {
3336 ReadAlign(pS, pS->Tell() - nStart, 2);
3337 *pS >> nBorderStyle;
3338 }
3339
3340 if (pBlockFlags[1] & 0x02)
3341 {
3342 ReadAlign(pS, pS->Tell() - nStart, 2);
3343 *pS >> nSpecialEffect;
3344 }
3345
3346 if (pBlockFlags[1] & 0x04)
3347 {
3348 ReadAlign(pS, pS->Tell() - nStart, 2);
3349 *pS >> nPicture;
3350 }
3351
3352 if (pBlockFlags[1] & 0x08)
3353 {
3354 ReadAlign(pS, pS->Tell() - nStart, 2);
3355 *pS >> nAccelerator;
3356 }
3357
3358 if (pBlockFlags[1] & 0x10)
3359 {
3360 ReadAlign(pS, pS->Tell() - nStart, 2);
3361 *pS >> nIcon;
3362 }
3363
3364 if (bCaption)
3365 lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
3366
3367 ReadAlign(pS, pS->Tell() - nStart, 4);
3368 *pS >> nWidth;
3369 *pS >> nHeight;
3370
3371 if (nPicture)
3372 {
3373 pS->Read(pPictureHeader,20);
3374 *pS >> nPictureLen;
3375 pPicture = new sal_uInt8[nPictureLen];
3376 pS->Read(pPicture,nPictureLen);
3377 }
3378 if (nIcon)
3379 {
3380 pS->Read(pIconHeader,20);
3381 *pS >> nIconLen;
3382 pIcon = new sal_uInt8[nIconLen];
3383 pS->Read(pIcon,nIconLen);
3384 }
3385
3386 return sal_True;
3387 }
3388
TypeName(sal_Char * pName,sal_uInt32 nStoreId,sal_uInt32 nLen,sal_uInt16 nType,sal_Int32 nLeft,sal_Int32 nTop)3389 TypeName::TypeName(sal_Char *pName, sal_uInt32 nStoreId, sal_uInt32 nLen, sal_uInt16 nType, sal_Int32 nLeft,
3390 sal_Int32 nTop)
3391 : msName(lclCreateOUString(pName, nLen)), mnType(nType), mnLeft(nLeft),
3392 mnTop(nTop),mnStoreId(nStoreId)
3393 {
3394 }
3395
OCX_ContainerControl(SotStorageRef & parent,const::rtl::OUString & storageName,const::rtl::OUString & sN,const uno::Reference<container::XNameContainer> & rParent,OCX_Control * pParent)3396 OCX_ContainerControl::OCX_ContainerControl( SotStorageRef& parent,
3397 const ::rtl::OUString& storageName,
3398 const ::rtl::OUString& sN,
3399 const uno::Reference< container::XNameContainer > &rParent,
3400 OCX_Control* pParent ) :
3401 OCX_Control(sN, pParent), rbGroupMgr( sName ), mxParent(rParent), nNoRecords(0), nTotalLen(0), containerType( STDCONTAINER )
3402 {
3403
3404 mContainerStorage = parent->OpenSotStorage(storageName,
3405 STREAM_READWRITE |
3406 STREAM_NOCREATE |
3407 STREAM_SHARE_DENYALL);
3408 mContainerStream = mContainerStorage->OpenSotStream(
3409 String(RTL_CONSTASCII_STRINGPARAM("f"),
3410 RTL_TEXTENCODING_MS_1252),
3411 STREAM_STD_READ | STREAM_NOCREATE);
3412 mContainedControlsStream = mContainerStorage->OpenSotStream( String(RTL_CONSTASCII_STRINGPARAM("o"),
3413 RTL_TEXTENCODING_MS_1252),
3414 STREAM_STD_READ | STREAM_NOCREATE);
3415 }
~OCX_ContainerControl()3416 OCX_ContainerControl::~OCX_ContainerControl()
3417 {
3418 CtrlIterator aEnd = mpControls.end();
3419 for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
3420 {
3421 delete *aIter;
3422 }
3423 }
3424
3425 // Really import should receive the parent e.g. a Userform, Frame or Multi Page
3426 // and call import on its containees with itself ( up-called from
3427 // the base class ) but... the reality is we have no containment model
3428 // so we make sure rPropSet is always the parent Dialog
3429
Import(uno::Reference<beans::XPropertySet> &)3430 sal_Bool OCX_ContainerControl::Import(uno::Reference<beans::XPropertySet>& /* rProps */ )
3431 {
3432 if ( !mxParent.is() )
3433 {
3434 return sal_False;
3435 }
3436 CtrlIterator aEnd = mpControls.end();
3437 // int count = 0;
3438 for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
3439 {
3440 if ( !(*aIter)->Import( mxParent ) )
3441 {
3442 return sal_False;
3443 }
3444 }
3445 return sal_True;
3446 }
3447
createSubStreamName(const sal_uInt32 & subStorageId)3448 OUString OCX_ContainerControl::createSubStreamName( const sal_uInt32& subStorageId )
3449 {
3450 static OUString sI = OUString::createFromAscii("i");
3451 static OUString sZero = OUString::createFromAscii( "0" );
3452 OUStringBuffer buf( 6 );
3453 buf.append( sI );
3454 // for subStorage id < 10 stream name has leading '0'
3455 // eg "i07"
3456 if ( subStorageId < 10 )
3457 {
3458 buf.append( sZero );
3459 }
3460 buf.append( OUString::valueOf( (sal_Int32)subStorageId ) );
3461 return buf.makeStringAndClear();
3462 }
3463
createFromContainerRecord(const ContainerRecord & record,OCX_Control * & pControl)3464 bool OCX_ContainerControl::createFromContainerRecord( const ContainerRecord& record, OCX_Control*& pControl )
3465 {
3466 pControl = NULL;
3467 switch ( record.nTypeIdent)
3468 {
3469 case CMDBUTTON:
3470 pControl = new OCX_CommandButton;
3471 break;
3472 case LABEL:
3473 pControl = new OCX_UserFormLabel(this);
3474 break;
3475 case TEXTBOX:
3476 pControl = new OCX_TextBox;
3477 break;
3478 case LISTBOX:
3479 pControl = new OCX_ListBox;
3480 break;
3481 case COMBOBOX:
3482 pControl = new OCX_ComboBox;
3483 break;
3484 case CHECKBOX:
3485 pControl = new OCX_CheckBox;
3486 break;
3487 case OPTIONBUTTON:
3488 pControl = new OCX_OptionButton;
3489 break;
3490 case TOGGLEBUTTON:
3491 pControl = new OCX_ToggleButton;
3492 break;
3493 case IMAGE: //Image
3494 {
3495 pControl = new OCX_Image;
3496 break;
3497 }
3498 case PAGE: // Page
3499 {
3500 OUString sMSStore = createSubStreamName( record.nSubStorageId );
3501 pControl = new OCX_Page(mContainerStorage, sMSStore,
3502 record.cName, mxParent, this);
3503 break;
3504 }
3505 case MULTIPAGE: // MultiPage
3506 {
3507 OUString sMSStore = createSubStreamName( record.nSubStorageId );
3508 pControl = new OCX_MultiPage( mContainerStorage, sMSStore,
3509 record.cName, mxParent, this);
3510 break;
3511 }
3512 case FRAME: //Frame
3513 {
3514 OUString sFrameStore = createSubStreamName( record.nSubStorageId );
3515 pControl = new OCX_Frame(mContainerStorage, sFrameStore,
3516 record.cName, mxParent, this);
3517
3518 break;
3519 }
3520 case SPINBUTTON: //SpinButton
3521 {
3522 pControl = new OCX_SpinButton;
3523 break;
3524 }
3525 case TABSTRIP: //TabStrip
3526 {
3527 pControl = new OCX_TabStrip;
3528 break;
3529 }
3530 case SCROLLBAR: //ScrollBar
3531 pControl = new OCX_ScrollBar;
3532 break;
3533 case PROGRESSBAR: //ProgressBar Active X control
3534 pControl = new OCX_ProgressBar;
3535 break;
3536 default:
3537 OSL_TRACE( "**** Unknown control 0x%x", record.nTypeIdent );
3538 DBG_ERROR( "Unknown control");
3539 return false;
3540 }
3541 pControl->sName = record.cName;
3542 return true;
3543 }
3544
3545
addSeperator(std::vector<OCX_Control * > & dest)3546 void addSeperator( std::vector< OCX_Control* >& dest )
3547 {
3548 OCX_Control* seperator = new OCX_CommandButton;
3549 seperator->SetInDialog(true);
3550 seperator->sName = C2S("GroupSeperator");
3551 dest.push_back( seperator );
3552 }
3553
addRButtons(std::vector<OCX_Control * > & src,std::vector<OCX_Control * > & dest,bool addGroupSeperator)3554 void addRButtons( std::vector< OCX_Control* >& src,
3555 std::vector< OCX_Control* >& dest,
3556 bool addGroupSeperator )
3557 {
3558 if ( addGroupSeperator )
3559 {
3560 addSeperator( dest );
3561 }
3562
3563 for ( CtrlIterator rbIter = src.begin(); rbIter != src.end(); ++rbIter )
3564 {
3565 dest.push_back( *rbIter );
3566 }
3567 }
3568
ProcessControl(OCX_Control * pControl,SvStorageStream *,ContainerRecord & rec)3569 void OCX_ContainerControl::ProcessControl(OCX_Control* pControl,SvStorageStream* /* pS */, ContainerRecord& rec )
3570 {
3571 SotStorageStreamRef oStream = mContainedControlsStream;
3572
3573 // can insert into OO Dialog (e.g is this a supported dialog control)??
3574 if ( rec.nTypeIdent == SPINBUTTON ||
3575 rec.nTypeIdent == TABSTRIP)
3576 {
3577 // skip the record in the stream, discard the control
3578 oStream->SeekRel( rec.nSubStreamLen );
3579 delete pControl;
3580 }
3581 else
3582 {
3583 // A container control needs to read the f stream in
3584 // the folder ( substorage ) associated with this control
3585 if ( rec.nTypeIdent == FRAME ||
3586 rec.nTypeIdent == MULTIPAGE||
3587 rec.nTypeIdent == PAGE )
3588 {
3589 OCX_ContainerControl* pContainer =
3590 static_cast< OCX_ContainerControl* >( pControl );
3591 oStream = pContainer->getContainerStream();
3592 }
3593
3594 pControl->sName = rec.cName;
3595 pControl->msToolTip = rec.controlTip;
3596 // Position of controls is relative to the container
3597 pControl->mnTop = rec.nTop + mnTop;
3598 pControl->mnLeft = rec.nLeft + mnLeft;
3599 // MS tabIndex, pretty useless in OpenOffice land
3600 // as tab indexes in MS are relative to parent container.
3601 // However we need this value in order to set
3602 // OpenOffice tab indices in a sensible way to
3603 // reflect the ms tabbing from orig MS UserForm, see below
3604 pControl->mnTabPos = rec.nTabPos;
3605 pControl->SetInDialog(true);
3606 pControl->mbVisible = rec.bVisible;
3607 if ( mnStep )
3608 {
3609 // If the container has a step then it should be
3610 // applied to all containees
3611 pControl->mnStep = mnStep;
3612 }
3613
3614 // #117490# DR: container records provide size of substream, use it here...
3615
3616 // remember initial position to set correct stream position
3617 sal_uLong nStrmPos = oStream->Tell();
3618 // import control, may return with invalid stream position
3619 pControl->FullRead(oStream);
3620 // set stream to position behind substream of this control
3621 oStream->Seek( nStrmPos + rec.nSubStreamLen );
3622
3623 //need to fake grouping behaviour for radio ( option ) buttons
3624 if ( rec.nTypeIdent == OPTIONBUTTON )
3625 {
3626 OCX_OptionButton* pRButton =
3627 static_cast< OCX_OptionButton*>(pControl);
3628 rbGroupMgr.addRadioButton( pRButton );
3629 }
3630 else
3631 {
3632 mpControls.push_back( pControl );
3633 }
3634 }
3635 }
3636
Read(SvStorageStream * pS)3637 sal_Bool OCX_ContainerControl::Read(SvStorageStream *pS)
3638 {
3639
3640 if ( mpParent )
3641 {
3642 mnBackColor = mpParent->mnBackColor;
3643 }
3644
3645 std::auto_ptr< ContainerRecReader > reader (
3646 ContainerRecordReaderFac::instance( containerType ) );
3647
3648 reader->Read( this, pS );
3649 // Need to honour the MS Tab Indexes. However MS tab indexes are
3650 // relative to parent, this hack sorts the controls in each container
3651 // based on the ms tab indexes. When import is called we create the
3652 // controls in Open/Star office based on the order of the tab indexes,
3653 // this ensures that the default tab index created by Star/Open office
3654 // reflects the "flattened" ms tab order.
3655 ::std::sort( mpControls.begin(), mpControls.end(), SortOrderByTabPos() );
3656 mpControls = rbGroupMgr.insertGroupsIntoControlList( mpControls );
3657 return true;
3658 }
3659
OCX_MultiPage(SotStorageRef & parent,const::rtl::OUString & storageName,const::rtl::OUString & sN,const uno::Reference<container::XNameContainer> & rDialog,OCX_Control * pParent)3660 OCX_MultiPage::OCX_MultiPage( SotStorageRef& parent,
3661 const ::rtl::OUString& storageName,
3662 const ::rtl::OUString& sN,
3663 const uno::Reference< container::XNameContainer > &rDialog,
3664 OCX_Control* pParent):
3665 OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ), fUnknown1(0), fEnabled(1),
3666 fLocked(0), fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0),
3667 nVertPos(1), nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3668 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
3669 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
3670 bPictureTiling(sal_False), nAccelerator(0), nIcon(0), pCaption(0),
3671 nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
3672 pPicture(0)
3673 {
3674 msDialogType = C2U("NotSupported");
3675 mnForeColor = 0x80000012L,
3676 mnBackColor = 0x8000000FL;
3677 bSetInDialog = true;// UserForm control only
3678 aFontData.SetHasAlign(sal_True);
3679 containerType = MULTIPAGE;
3680 mnCurrentPageStep = 0;
3681 }
3682
ProcessControl(OCX_Control * pControl,SvStorageStream *,ContainerRecord & rec)3683 void OCX_MultiPage::ProcessControl(OCX_Control* pControl, SvStorageStream* /* pS */, ContainerRecord& rec )
3684 {
3685 SotStorageStreamRef oStream = mContainedControlsStream;
3686
3687 OCX_Page *pPage = NULL;
3688 if ( rec.nTypeIdent == PAGE )
3689 pPage = static_cast< OCX_Page* >( pControl );
3690 if ( pPage != NULL )
3691 {
3692 pPage->mnStep = ++mnCurrentPageStep;
3693
3694 pPage->mnTop = mnTop;// move these to Page::import ?
3695 pPage->mnLeft = mnLeft;
3696 pPage->mnBackColor = mnBackColor;
3697
3698 oStream = pPage->getContainerStream();
3699 // Position of controls is relative to pos of this MuliPage
3700 // Control
3701 pPage->FullRead( oStream );
3702
3703 mpControls.push_back( pPage );
3704 }
3705 else
3706 {
3707 OSL_TRACE("!!!! Unsupported Control 0x%x ", rec.nTypeIdent);
3708 DBG_ERROR("MultiPage error expected Page control");
3709 }
3710
3711 }
3712
Read(SvStorageStream * pS)3713 sal_Bool OCX_MultiPage::Read(SvStorageStream *pS)
3714 {
3715 // Unlike the other containers e.g. UserForm & Frame
3716 // the o stream is does not contain info for the contained controls
3717 // ( e.g. the pages themselves ) but seems to be for the MultiPage
3718 // itself - need to check this in more detail
3719
3720 // For the moment skip read of the MultiPage specific properties
3721 // not much point reading these as we can't display the multi page
3722 // control or in fact any sort of tabbed layout, best we can do is
3723 // import just the contained controls of the individual pages
3724 // Note: the record skipped below ( does not contain the expected
3725 // info on this control, that seems to be contained in the o stream,
3726 // see comment above)
3727 OCX_Control skip(C2S("Dummy"));
3728 skip.Read( pS );
3729 mnCurrentPageStep = mnStep; //( set step of of pages relative to step
3730 //of this MultiPage ( e.g. emulate containment )
3731 return OCX_ContainerControl::Read(pS);
3732 }
3733
3734
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)3735 sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
3736 com::sun::star::beans::XPropertySet> &rPropSet)
3737 {
3738 // Calls import on contained controls
3739 OCX_ContainerControl::Import( rPropSet );
3740 return sal_True;
3741 }
3742
Import(com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> & rDialog)3743 sal_Bool OCX_MultiPage::Import(com::sun::star::uno::Reference<
3744 com::sun::star::container::XNameContainer>
3745 &rDialog)
3746 {
3747 uno::Reference<beans::XPropertySet> xPropSet( rDialog, uno::UNO_QUERY );
3748
3749 // Although MultiPage is not represeted by a "real" control we still
3750 // need to propagate the backcolor of this logical parent
3751 // ( the dialog or Frame or whatever ) to the children of this control.
3752 // For example the controls contained in the Page of a
3753 // MultiPage control use the parents backcolor ( e,g,
3754 // Pages backcolor ) when trying to fake transparency
3755 mnBackColor = mpParent->mnBackColor;
3756
3757 if ( xPropSet.is() )
3758 {
3759 // Calls import on contained pages
3760 return OCX_ContainerControl::Import( xPropSet );
3761 }
3762 OSL_TRACE("*** Major problem, no dialog to add controls to ");
3763 DBG_ERROR(" Major problem, no dialog to add controls to ");
3764 return false;
3765 }
3766
3767
3768
OCX_Page(SotStorageRef & parent,const::rtl::OUString & storageName,const::rtl::OUString & sN,const uno::Reference<container::XNameContainer> & rDialog,OCX_Control * pParent)3769 OCX_Page::OCX_Page( SotStorageRef& parent,
3770 const ::rtl::OUString& storageName,
3771 const ::rtl::OUString& sN,
3772 const uno::Reference< container::XNameContainer > &rDialog,
3773 OCX_Control* pParent):
3774 OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ),
3775 fUnknown1(0), fEnabled(1), fLocked(0),
3776 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
3777 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3778 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
3779 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
3780 bPictureTiling(sal_False), nAccelerator(0), nIcon(0), pCaption(0),
3781 nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
3782 pPicture(0)
3783 {
3784 msDialogType = C2U("NotSupported");
3785 mnForeColor = 0x80000012,
3786 mnBackColor = 0x8000000F,
3787 bSetInDialog = true;// UserForm control only
3788 aFontData.SetHasAlign(sal_True);
3789 }
3790
3791
Read(SvStorageStream * pS)3792 sal_Bool OCX_Page::Read(SvStorageStream *pS)
3793 {
3794 long nStart = pS->Tell();
3795 *pS >> nIdentifier;
3796 DBG_ASSERT(0x400==nIdentifier,
3797 "A control that has a different identifier");
3798 *pS >> nFixedAreaLen;
3799 pS->Read(pBlockFlags,4);
3800
3801 pS->SeekRel( nFixedAreaLen - sizeof( pBlockFlags ) );
3802
3803 ReadAlign( pS, pS->Tell() - nStart, 4);
3804
3805 if (pBlockFlags[2] & 0x10)
3806 {
3807 //Font Stuff..
3808 pS->SeekRel(0x1a);
3809 sal_uInt8 nFontLen;
3810 *pS >> nFontLen;
3811 pS->SeekRel(nFontLen);
3812 }
3813 return OCX_ContainerControl::Read(pS);
3814
3815 }
3816
Import(com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> & rDialog)3817 sal_Bool OCX_Page::Import(com::sun::star::uno::Reference<
3818 com::sun::star::container::XNameContainer>
3819 &rDialog)
3820 {
3821
3822 uno::Reference<beans::XPropertySet> xPropSet( rDialog, uno::UNO_QUERY );
3823 if ( xPropSet.is() )
3824 {
3825 // apply Step to contained controls
3826 CtrlIterator aEnd = mpControls.end();
3827 for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
3828 {
3829 (*aIter)->mnStep = mnStep;
3830 }
3831 // Calls import on contained pages
3832 return OCX_ContainerControl::Import( xPropSet );
3833 }
3834 OSL_TRACE("*** Major problem, no dialog to add controls to ");
3835 DBG_ERROR("*** Major problem, no dialog to add controls to ");
3836 return sal_False;
3837 }
3838
OCX_Frame(SotStorageRef & parent,const::rtl::OUString & storageName,const::rtl::OUString & sN,const uno::Reference<container::XNameContainer> & rDialog,OCX_Control * pParent)3839 OCX_Frame::OCX_Frame( SotStorageRef& parent,
3840 const ::rtl::OUString& storageName,
3841 const ::rtl::OUString& sN,
3842 const uno::Reference< container::XNameContainer > &rDialog, OCX_Control* pParent):
3843 OCX_ContainerControl(parent, storageName, sN, rDialog, pParent ),fUnknown1(0),fEnabled(1), fLocked(0),
3844 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
3845 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3846 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
3847 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
3848 bPictureTiling(sal_False), nAccelerator(0), nIcon(0), pCaption(0),
3849 nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0),
3850 pPicture(0)
3851 {
3852 msDialogType = C2U("com.sun.star.awt.UnoControlGroupBoxModel");
3853 mnForeColor = 0x80000012;
3854 mnBackColor = 0x8000000F;
3855 bSetInDialog = true;// UserForm control only
3856 aFontData.SetHasAlign(sal_True);
3857 }
3858
3859
Read(SvStorageStream * pS)3860 sal_Bool OCX_Frame::Read(SvStorageStream *pS)
3861 {
3862 long nStart = pS->Tell();
3863 *pS >> nIdentifier;
3864 DBG_ASSERT(0x400==nIdentifier,
3865 "A control that has a different identifier");
3866 *pS >> nFixedAreaLen;
3867 pS->Read(pBlockFlags,4);
3868
3869 if (pBlockFlags[0] & 0x01)
3870 {
3871 DBG_ASSERT(sal_False, "ARSE");
3872 }
3873 if (pBlockFlags[0] & 0x02)
3874 *pS >> mnBackColor;
3875 if (pBlockFlags[0] & 0x04)
3876 *pS >> mnForeColor;
3877 if (pBlockFlags[0] & 0x08)
3878 *pS >> fUnknown1;
3879 if (pBlockFlags[0] & 0x40)
3880 {
3881 sal_uInt8 nTemp;
3882 *pS >> nTemp;
3883 fEnabled = (nTemp&0x04)>>2;
3884 fBackStyle = (nTemp&0x08)>>3;
3885 *pS >> nTemp;
3886 *pS >> nTemp;
3887 fWordWrap = (nTemp&0x80)>>7;
3888 *pS >> nTemp;
3889 fAutoSize = (nTemp&0x10)>>4;
3890 }
3891 if (pBlockFlags[0] & 0x80)
3892 {
3893 *pS >> nBorderStyle;
3894 }
3895
3896 ReadAlign(pS, pS->Tell() - nStart, 4);
3897
3898 if (pBlockFlags[1] & 0x01)
3899 *pS >> nMousePointer;
3900 if (pBlockFlags[1] & 0x02)
3901 *pS >> nKeepScrollBarsVisible;
3902 if (pBlockFlags[1] & 0x20)
3903 *pS >> fUnknown1; // another unknown 32 bit ( or is 8 or 16 bit with padding ? )
3904
3905 if (pBlockFlags[1] & 0x80)
3906 {
3907 ReadAlign(pS, pS->Tell() - nStart, 2);
3908 *pS >> nIcon;
3909 DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
3910 }
3911
3912 bool bCaption = false;
3913
3914 if (pBlockFlags[2] & 0x01)
3915 *pS >> nCycle;
3916 if (pBlockFlags[2] & 0x02)
3917 *pS >> nSpecialEffect;
3918
3919 if (pBlockFlags[2] & 0x04)
3920 {
3921 ReadAlign(pS, pS->Tell() - nStart, 4);
3922 *pS >> nBorderColor;
3923 }
3924
3925 if (pBlockFlags[2] & 0x08)
3926 {
3927 ReadAlign(pS, pS->Tell() - nStart, 4);
3928 *pS >> nCaptionLen;
3929 bCaption = true;
3930 }
3931
3932 if (pBlockFlags[2] & 0x10)
3933 {
3934 ReadAlign(pS, pS->Tell() - nStart, 2);
3935 sal_uInt16 nNoIdea;
3936 *pS >> nNoIdea;
3937 DBG_ASSERT(nNoIdea == 0xFFFF, "Expected 0xFFFF, (related to font ?)");
3938 }
3939
3940 if (pBlockFlags[2] & 0x20)
3941 {
3942 ReadAlign(pS, pS->Tell() - nStart, 2);
3943 *pS >> nPicture;
3944 DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
3945 }
3946
3947 if (pBlockFlags[2] & 0x80)
3948 *pS >> nPictureAlignment;
3949
3950 if (pBlockFlags[3] & 0x01)
3951 bPictureTiling = true;
3952
3953 if (pBlockFlags[3] & 0x02)
3954 *pS >> nPictureSizeMode;
3955
3956 if (pBlockFlags[3] & 0x04)
3957 {
3958 ReadAlign(pS, pS->Tell() - nStart, 4);
3959 *pS >> fUnknown8;
3960 }
3961
3962 if (pBlockFlags[3] & 0x08)
3963 {
3964 ReadAlign(pS, pS->Tell() - nStart, 4);
3965 *pS >> fUnknown9;
3966 }
3967
3968 ReadAlign(pS, pS->Tell() - nStart, 4);
3969 *pS >> nWidth;
3970 *pS >> nHeight;
3971 *pS >> nScrollWidth;
3972 *pS >> nScrollHeight;
3973
3974 if (pBlockFlags[1] & 0x10)
3975 {
3976 *pS >> nScrollLeft;
3977 *pS >> nScrollTop;
3978 }
3979
3980 if ( bCaption )
3981 {
3982 lclReadCharArray( *pS, pCaption, nCaptionLen, pS->Tell() - nStart);
3983 }
3984
3985 OUString tempCaption = lclCreateOUString( pCaption, nCaptionLen );
3986
3987 if (nIcon)
3988 {
3989 pS->Read(pIconHeader,20);
3990 *pS >> nIconLen;
3991 pIcon = new sal_uInt8[nIconLen];
3992 pS->Read(pIcon,nIconLen);
3993 }
3994
3995 if (nPicture)
3996 {
3997 pS->Read(pPictureHeader,20);
3998 *pS >> nPictureLen;
3999 pPicture = new sal_uInt8[nPictureLen];
4000 pS->Read(pPicture,nPictureLen);
4001 }
4002
4003 ReadAlign( pS, pS->Tell() - nStart, 4);
4004
4005 if (pBlockFlags[2] & 0x10)
4006 {
4007 //Font Stuff..
4008 pS->SeekRel(0x1a);
4009 sal_uInt8 nFontLen;
4010 *pS >> nFontLen;
4011 pS->SeekRel(nFontLen);
4012 }
4013
4014 return OCX_ContainerControl::Read( pS );
4015 }
4016
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)4017 sal_Bool OCX_Frame::Import(com::sun::star::uno::Reference<
4018 com::sun::star::beans::XPropertySet> &rPropSet)
4019 {
4020 uno::Any aTmp(&sName,getCppuType((OUString *)0));
4021 rPropSet->setPropertyValue(
4022 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
4023 if ( pCaption )
4024 {
4025 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
4026 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
4027 }
4028
4029 // Calls import on contained controls
4030 OCX_ContainerControl::Import( rPropSet );
4031 return sal_True;
4032 }
OCX_UserForm(SotStorageRef & parent,const OUString & storageName,const OUString & sN,const::uno::Reference<container::XNameContainer> & rDialog,const::uno::Reference<lang::XMultiServiceFactory> & rMsf)4033 OCX_UserForm::OCX_UserForm( SotStorageRef& parent,
4034 const OUString& storageName,
4035 const OUString& sN,
4036 const ::uno::Reference< container::XNameContainer > &rDialog,
4037 const ::uno::Reference< lang::XMultiServiceFactory >& rMsf):
4038 OCX_ContainerControl(parent, storageName, sN, rDialog),
4039 nChildrenA(0), fEnabled(1), fLocked(0),
4040 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
4041 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012), nChildrenB(0),
4042 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
4043 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
4044 bPictureTiling(sal_False), nAccelerator(0), nIcon(0), pCaption(0),
4045 nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0),
4046 pPicture(0)
4047 {
4048 mnForeColor = 0x80000012;
4049 mnBackColor = 0x8000000F;
4050 uno::Reference< beans::XPropertySet> xProps( rMsf, uno::UNO_QUERY);
4051 if ( xProps.is() )
4052 {
4053 xProps->getPropertyValue(C2S("DefaultContext")) >>= mxCtx;
4054 }
4055 aFontData.SetHasAlign(sal_True);
4056 }
Read(SvStorageStream * pS)4057 sal_Bool OCX_UserForm::Read(SvStorageStream *pS)
4058 {
4059 long nStart = pS->Tell();
4060 *pS >> nIdentifier;
4061 DBG_ASSERT(0x400==nIdentifier,
4062 "A control that has a different identifier");
4063 *pS >> nFixedAreaLen;
4064 pS->Read(pBlockFlags,4);
4065
4066 if (pBlockFlags[0] & 0x01)
4067 {
4068 DBG_ASSERT(sal_False, "ARSE");
4069 }
4070 if (pBlockFlags[0] & 0x02)
4071 *pS >> mnBackColor;
4072 if (pBlockFlags[0] & 0x04)
4073 *pS >> mnForeColor;
4074 if (pBlockFlags[0] & 0x08)
4075 *pS >> nChildrenA;
4076 if (pBlockFlags[0] & 0x40)
4077 {
4078 sal_uInt8 nTemp;
4079 *pS >> nTemp;
4080 fEnabled = (nTemp&0x04)>>2;
4081 fBackStyle = (nTemp&0x08)>>3;
4082 *pS >> nTemp;
4083 *pS >> nTemp;
4084 fWordWrap = (nTemp&0x80)>>7;
4085 *pS >> nTemp;
4086 fAutoSize = (nTemp&0x10)>>4;
4087 }
4088 if (pBlockFlags[0] & 0x80)
4089 {
4090 ReadAlign(pS, pS->Tell() - nStart, 4);
4091 *pS >> nBorderStyle;
4092 }
4093 #if 0
4094 sal_uInt16 nFixedOrAlign;
4095 *pS >> nFixedOrAlign;
4096 #endif
4097 if (pBlockFlags[1] & 0x01)
4098 *pS >> nMousePointer;
4099 if (pBlockFlags[1] & 0x02)
4100 *pS >> nKeepScrollBarsVisible;
4101 if (pBlockFlags[1] & 0x20)
4102 {
4103 sal_uInt32 nUnknown32;
4104 *pS >> nUnknown32;
4105 }
4106 if (pBlockFlags[1] & 0x80)
4107 {
4108 ReadAlign(pS, pS->Tell() - nStart, 2);
4109 *pS >> nIcon;
4110 DBG_ASSERT(nIcon == 0xFFFF, "Unexpected nIcon");
4111 }
4112 if (pBlockFlags[2] & 0x01)
4113 *pS >> nCycle;
4114 if (pBlockFlags[2] & 0x02)
4115 *pS >> nSpecialEffect;
4116
4117 if (pBlockFlags[2] & 0x04)
4118 {
4119 ReadAlign(pS, pS->Tell() - nStart, 4);
4120 *pS >> nBorderColor;
4121 }
4122
4123 if (pBlockFlags[2] & 0x10)
4124 {
4125 ReadAlign(pS, pS->Tell() - nStart, 2);
4126 sal_uInt16 nNoIdea;
4127 *pS >> nNoIdea;
4128 DBG_ASSERT(nNoIdea == 0xFFFF, "Expected 0xFFFF, (related to font ?)");
4129 }
4130
4131 if (pBlockFlags[2] & 0x20)
4132 {
4133 ReadAlign(pS, pS->Tell() - nStart, 2);
4134 *pS >> nPicture;
4135 DBG_ASSERT(nPicture == 0xFFFF, "Unexpected nIcon");
4136 }
4137
4138 if (pBlockFlags[2] & 0x80)
4139 *pS >> nPictureAlignment;
4140
4141 if (pBlockFlags[3] & 0x01)
4142 bPictureTiling = true;
4143
4144 if (pBlockFlags[3] & 0x02)
4145 *pS >> nPictureSizeMode;
4146
4147 if (pBlockFlags[3] & 0x04)
4148 {
4149 ReadAlign(pS, pS->Tell() - nStart, 4);
4150 *pS >> nChildrenB;
4151 }
4152
4153 ReadAlign(pS, pS->Tell() - nStart, 4);
4154 *pS >> nDrawBuffer;
4155
4156 ReadAlign(pS, pS->Tell() - nStart, 4);
4157 *pS >> nWidth;
4158 *pS >> nHeight;
4159 *pS >> nScrollWidth;
4160 *pS >> nScrollHeight;
4161
4162 if (pBlockFlags[1] & 0x10)
4163 {
4164 *pS >> nScrollLeft;
4165 *pS >> nScrollTop;
4166 }
4167
4168 if (nIcon)
4169 {
4170 pS->Read(pIconHeader,20);
4171 *pS >> nIconLen;
4172 pIcon = new sal_uInt8[nIconLen];
4173 pS->Read(pIcon,nIconLen);
4174 }
4175
4176 if (nPicture)
4177 {
4178 pS->Read(pPictureHeader,20);
4179 *pS >> nPictureLen;
4180 pPicture = new sal_uInt8[nPictureLen];
4181 pS->Read(pPicture,nPictureLen);
4182 }
4183
4184 ReadAlign( pS, pS->Tell() - nStart, 4);
4185
4186 if (pBlockFlags[2] & 0x10)
4187 {
4188 //Font Stuff..
4189 pS->SeekRel(0x1a);
4190 sal_uInt8 nFontLen;
4191 *pS >> nFontLen;
4192 pS->SeekRel(nFontLen);
4193 }
4194
4195 sal_Int16 numTrailingRecs = 0;
4196 *pS >> numTrailingRecs;
4197 // seems to be no. of trailing records,
4198 // before container record starts proper
4199 // ( unknown what these trailing records are for)
4200 if ( numTrailingRecs )
4201 {
4202 for ( ; numTrailingRecs ; --numTrailingRecs )
4203 {
4204 OCX_Control skip(C2S("dummy")) ;
4205 skip.Read( pS );
4206 }
4207 }
4208 return OCX_ContainerControl::Read( pS );
4209 }
4210
Import(uno::Reference<container::XNameContainer> & rLib)4211 sal_Bool OCX_UserForm::Import(
4212 uno::Reference<container::XNameContainer> &rLib )
4213 {
4214 uno::Reference<beans::XPropertySet>
4215 xDialogPropSet(mxParent, uno::UNO_QUERY);
4216 uno::Any aTmp(&sName,getCppuType((OUString *)0));
4217 xDialogPropSet->setPropertyValue(
4218 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp);
4219 xDialogPropSet->setPropertyValue(
4220 OUString(RTL_CONSTASCII_USTRINGPARAM("Title")), aTmp);
4221 aTmp <<= ImportColor(mnBackColor);
4222 xDialogPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
4223
4224 aTmp <<= sal_Int32((nWidth * 2) / 100);
4225 xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Width"), aTmp);
4226 aTmp <<= sal_Int32((nHeight * 2) / 100);
4227 xDialogPropSet->setPropertyValue(WW8_ASCII2STR("Height"), aTmp);
4228
4229 uno::Reference<beans::XPropertySet> xPropSet( mxParent, uno::UNO_QUERY );
4230 OCX_ContainerControl::Import( xPropSet );
4231
4232 uno::Reference<io::XInputStreamProvider> xSource =
4233 xmlscript::exportDialogModel(mxParent, mxCtx);
4234 uno::Any aSourceAny(uno::makeAny(xSource));
4235 if (rLib->hasByName(sName))
4236 rLib->replaceByName(sName, aSourceAny);
4237 else
4238 rLib->insertByName(sName, aSourceAny);
4239 return sal_True;
4240 }
4241
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)4242 sal_Bool OCX_Label::WriteContents(SvStorageStreamRef &rContents,
4243 const uno::Reference< beans::XPropertySet > &rPropSet,
4244 const awt::Size &rSize)
4245 {
4246 sal_Bool bRet = sal_True;
4247 sal_uInt32 nOldPos = rContents->Tell();
4248 rContents->SeekRel(8);
4249 pBlockFlags[0] = 0x20;
4250 pBlockFlags[1] = 0;
4251 pBlockFlags[2] = 0;
4252 pBlockFlags[3] = 0;
4253
4254 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
4255 if (aTmp.hasValue())
4256 aTmp >>= mnForeColor;
4257 *rContents << ExportColor(mnForeColor);
4258 pBlockFlags[0] |= 0x01;
4259
4260 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
4261 if (aTmp.hasValue())
4262 aTmp >>= mnBackColor;
4263 *rContents << ExportColor(mnBackColor);
4264 pBlockFlags[0] |= 0x02;
4265
4266 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
4267 fEnabled = any2bool(aTmp);
4268 sal_uInt8 nTemp=fEnabled;
4269 if (fEnabled)
4270 nTemp = nTemp << 1;
4271 *rContents << nTemp;
4272 *rContents << sal_uInt8(0x00);
4273
4274 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
4275 fWordWrap = any2bool(aTmp);
4276 nTemp=fWordWrap;
4277 nTemp = nTemp << 7;
4278 *rContents << nTemp;
4279 *rContents << sal_uInt8(0x00);
4280 pBlockFlags[0] |= 0x04;
4281
4282 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
4283 aCaption.WriteLenField( *rContents );
4284 if (aCaption.HasData())
4285 pBlockFlags[0] |= 0x08;
4286
4287 WriteAlign(rContents,4);
4288 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BorderColor"));
4289 if (aTmp.hasValue())
4290 aTmp >>= nBorderColor;
4291 *rContents << ExportColor(nBorderColor);
4292 pBlockFlags[0] |= 0x80;
4293
4294 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
4295 sal_Int16 nBorder = sal_Int16();
4296 aTmp >>= nBorder;
4297 sal_uInt8 nNewBorder;
4298 nSpecialEffect = ExportBorder(nBorder,nNewBorder);
4299 nBorderStyle = nNewBorder;
4300 *rContents << nBorderStyle;
4301 pBlockFlags[1] |= 0x01;
4302 *rContents << nSpecialEffect;
4303 pBlockFlags[1] |= 0x02;
4304
4305 aCaption.WriteCharArray( *rContents );
4306
4307 WriteAlign(rContents,4);
4308 *rContents << rSize.Width;
4309 *rContents << rSize.Height;
4310 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
4311
4312 bRet = aFontData.Export(rContents,rPropSet);
4313
4314 rContents->Seek(nOldPos);
4315 *rContents << nStandardId;
4316 *rContents << nFixedAreaLen;
4317
4318 *rContents << pBlockFlags[0];
4319 *rContents << pBlockFlags[1];
4320 *rContents << pBlockFlags[2];
4321 *rContents << pBlockFlags[3];
4322
4323 DBG_ASSERT((rContents.Is() &&
4324 (SVSTREAM_OK==rContents->GetError())),"damn");
4325 return bRet;
4326 }
4327
4328
4329
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)4330 sal_Bool OCX_Label::Export(SvStorageRef &rObj,
4331 const uno::Reference< beans::XPropertySet > &rPropSet,
4332 const awt::Size &rSize)
4333 {
4334 static sal_uInt8 __READONLY_DATA aCompObj[] = {
4335 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
4336 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
4337 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
4338 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
4339 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
4340 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
4341 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
4342 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
4343 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
4344 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
4345 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
4346 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
4347 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
4348 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
4349 };
4350
4351 {
4352 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
4353 xStor->Write(aCompObj,sizeof(aCompObj));
4354 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
4355 }
4356
4357 {
4358 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
4359 xStor3->Write(aObjInfo,sizeof(aObjInfo));
4360 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
4361 }
4362
4363 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
4364 0x4C, 0x00, 0x61, 0x00, 0x62, 0x00, 0x65, 0x00,
4365 0x6C, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
4366 };
4367
4368 {
4369 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
4370 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
4371 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
4372 }
4373 /*
4374 static sal_uInt8 __READONLY_DATA aTest[] = {
4375 0x00, 0x02, 0x20, 0x00, 0x2B, 0x00, 0x00, 0x00,
4376 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00,
4377 0x06, 0x00, 0x00, 0x80, 0x4C, 0x61, 0x62, 0x65,
4378 0x6C, 0x31, 0x18, 0x00, 0xEC, 0x09, 0x00, 0x00,
4379 0x7B, 0x02, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00,
4380 0x35, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x80,
4381 0xC3, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
4382 0x54, 0x69, 0x6D, 0x65, 0x73, 0x20, 0x4E, 0x65,
4383 0x77, 0x20, 0x52, 0x6F, 0x6D, 0x61, 0x6E, 0x00,
4384 };
4385 */
4386 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
4387 return WriteContents(xContents, rPropSet, rSize);
4388 }
4389
4390 typedef OCX_Control *(*FNCreate)();
4391
4392
4393 struct OCX_map
4394 {
4395 FNCreate pCreate;
4396 const char *sId;
4397 sal_Int16 nId;
4398 const char *sName;
4399 };
4400
4401 OCX_map aOCXTab[] =
4402 {
4403 // Command button MUST be at index 0
4404 {&OCX_CommandButton::Create,"D7053240-CE69-11CD-a777-00dd01143c57",
4405 form::FormComponentType::COMMANDBUTTON,"CommandButton"},
4406 // Toggle button MUST be at index 1
4407 {&OCX_ToggleButton::Create,"8BD21D60-EC42-11CE-9e0d-00aa006002f3",
4408 form::FormComponentType::COMMANDBUTTON,"ToggleButton"},
4409 {&OCX_Label::Create, "978C9E23-D4B0-11CE-bf2d-00aa003f40d0",
4410 form::FormComponentType::FIXEDTEXT,"Label"},
4411 {&OCX_TextBox::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4412 form::FormComponentType::TEXTFIELD,"TextBox"},
4413 {&OCX_ListBox::Create,"8BD21D20-EC42-11CE-9e0d-00aa006002f3",
4414 form::FormComponentType::LISTBOX,"ListBox"},
4415 {&OCX_ComboBox::Create,"8BD21D30-EC42-11CE-9e0d-00aa006002f3",
4416 form::FormComponentType::COMBOBOX,"ComboBox"},
4417 {&OCX_CheckBox::Create,"8BD21D40-EC42-11CE-9e0d-00aa006002f3",
4418 form::FormComponentType::CHECKBOX,"CheckBox"},
4419 {&OCX_OptionButton::Create,"8BD21D50-EC42-11CE-9e0d-00aa006002f3",
4420 form::FormComponentType::RADIOBUTTON,"OptionButton"},
4421 {&OCX_Image::Create,"4C599241-6926-101B-9992-00000b65c6f9",
4422 form::FormComponentType::IMAGECONTROL,"Image"},
4423 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4424 form::FormComponentType::DATEFIELD,"TextBox"},
4425 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4426 form::FormComponentType::TIMEFIELD,"TextBox"},
4427 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4428 form::FormComponentType::NUMERICFIELD,"TextBox"},
4429 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4430 form::FormComponentType::CURRENCYFIELD,"TextBox"},
4431 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4432 form::FormComponentType::PATTERNFIELD,"TextBox"},
4433 #if 0
4434 {&OCX_FieldControl::Create,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4435 form::FormComponentType::FORMULAFIELD,"TextBox"},
4436 #endif
4437 {&OCX_ImageButton::Create,"D7053240-CE69-11CD-a777-00dd01143c57",
4438 form::FormComponentType::IMAGEBUTTON,"CommandButton"},
4439 {&OCX_SpinButton::Create,"79176FB0-B7F2-11CE-97ef-00aa006d2776",
4440 form::FormComponentType::SPINBUTTON,"SpinButton"},
4441 {&OCX_ScrollBar::Create,"DFD181E0-5E2F-11CE-a449-00aa004a803d",
4442 form::FormComponentType::SCROLLBAR,"ScrollBar"},
4443 {&OCX_GroupBox::Create,"",
4444 form::FormComponentType::GROUPBOX,""},
4445 {&OCX_ProgressBar::Create,"",
4446 form::FormComponentType::CONTROL,""}
4447 };
4448
4449 const int NO_OCX = sizeof( aOCXTab ) / sizeof( *aOCXTab );
4450
SvxMSConvertOCXControls(SfxObjectShell * pDSh,SwPaM * pP)4451 SvxMSConvertOCXControls::SvxMSConvertOCXControls(SfxObjectShell *pDSh, SwPaM *pP) :
4452 pDocSh(pDSh), pPaM(pP), nEdit(0), nCheckbox(0)
4453 {
4454 DBG_ASSERT( pDocSh, "No DocShell, Cannot do Controls" );
4455 OCX_Control::FillSystemColors();
4456 }
4457
~SvxMSConvertOCXControls()4458 SvxMSConvertOCXControls::~SvxMSConvertOCXControls()
4459 {
4460 }
4461
OCX_Factory(const String & sName)4462 OCX_Control * SvxMSConvertOCXControls::OCX_Factory(const String &sName)
4463 {
4464 for (int i=0;i<NO_OCX;i++)
4465 {
4466 if ( sName.EqualsIgnoreCaseAscii( aOCXTab[i].sId ))
4467 return(aOCXTab[i].pCreate());
4468 }
4469 return(NULL);
4470 }
4471
OCX_Factory(const uno::Reference<awt::XControlModel> & rControlModel,String & rId,String & rName)4472 OCX_Control * SvxMSConvertOCXControls::OCX_Factory(
4473 const uno::Reference< awt::XControlModel > &rControlModel,
4474 String &rId, String &rName)
4475 {
4476 rName.Erase();
4477 rId.Erase();
4478
4479 uno::Reference< beans::XPropertySet > xPropSet(
4480 rControlModel,uno::UNO_QUERY);
4481
4482 uno::Any aTmp = xPropSet->getPropertyValue(
4483 OUString::createFromAscii("ClassId"));
4484 sal_Int16 nClassId = *(sal_Int16*) aTmp.getValue();
4485
4486 //Begin nasty hack
4487 /*
4488 There is a truly horrible thing with EditControls and FormattedField
4489 Controls, they both pretend to have an EDITBOX ClassId for compatibility
4490 reasons, at some stage in the future hopefully there will be a proper
4491 FormulaField ClassId rather than this piggybacking two controls onto the
4492 same ClassId, when this happens uncomment the FORMULAFIELD in the OCX_Tab
4493 and delete this block, cmc.
4494
4495 And also the nClassId for ImageControls is being reported as "CONTROL"
4496 rather than IMAGECONTROL
4497 */
4498 if (nClassId == form::FormComponentType::TEXTFIELD)
4499 {
4500 uno::Reference< lang::XServiceInfo > xInfo(rControlModel,
4501 uno::UNO_QUERY);
4502 if (xInfo->
4503 supportsService(OUString::createFromAscii(
4504 "com.sun.star.form.component.FormattedField")))
4505 {
4506 rId.AppendAscii("8BD21D10-EC42-11CE-9e0d-00aa006002f3");
4507 rName.AppendAscii("TextBox");
4508 return new OCX_FieldControl;
4509 }
4510 }
4511 else if (nClassId == form::FormComponentType::CONTROL)
4512 {
4513 uno::Reference< lang::XServiceInfo > xInfo(rControlModel,
4514 uno::UNO_QUERY);
4515 if (xInfo->
4516 supportsService(OUString::createFromAscii(
4517 "com.sun.star.form.component.ImageControl")))
4518 nClassId = form::FormComponentType::IMAGECONTROL;
4519 }
4520 //End nasty hack
4521
4522 const OCX_map* pEntry = 0;
4523
4524 // distinguish between push button and toggle button
4525 if( nClassId == form::FormComponentType::COMMANDBUTTON )
4526 {
4527 pEntry = any2bool(xPropSet->getPropertyValue(WW8_ASCII2STR("Toggle"))) ?
4528 (aOCXTab + 1) : aOCXTab;
4529 }
4530 else
4531 {
4532 for( int i = 2; (i < NO_OCX) && !pEntry; ++i )
4533 if( nClassId == aOCXTab[ i ].nId )
4534 pEntry = aOCXTab + i;
4535 }
4536
4537 if( pEntry )
4538 {
4539 rId.AppendAscii( pEntry->sId );
4540 rName.AppendAscii( pEntry->sName );
4541 return pEntry->pCreate();
4542 }
4543
4544 return 0;
4545 }
4546
4547
ReadOCXStream(SvStorageRef & rSrc1,uno::Reference<drawing::XShape> * pShapeRef,sal_Bool bFloatingCtrl)4548 sal_Bool SvxMSConvertOCXControls::ReadOCXStream( SvStorageRef& rSrc1,
4549 uno::Reference < drawing::XShape > *pShapeRef,sal_Bool bFloatingCtrl)
4550 {
4551
4552 SvStorageStreamRef xCrash = rSrc1->OpenSotStream( WW8_ASCII2STR("contents") );
4553 sal_Bool bRet=sal_False;
4554
4555 SvStorageStreamRef xSrc2 = rSrc1->OpenSotStream( WW8_ASCII2STR("\3OCXNAME") );
4556 SvStorageStream* pSt = xSrc2;
4557 pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
4558
4559 /* #117832# import control name */
4560 OUString controlName;
4561 bool hasCName = readOCXNAME( controlName, pSt );
4562
4563 xSrc2 = rSrc1->OpenSotStream( WW8_ASCII2STR("contents") );
4564 pSt = xSrc2;
4565 pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
4566
4567 /*Get Class Id of this object, see if it is one of the types
4568 *that this importer can handle, call the appropriate handler
4569 to read that control, and call the appropriate handler to
4570 insert that control
4571 */
4572
4573 SvGlobalName aTest = rSrc1->GetClassName();
4574 OCX_Control *pObj = OCX_Factory(aTest.GetHexName());
4575 if (pObj)
4576 {
4577 pObj->pDocSh = pDocSh;
4578 /* #117832# set imported control name */
4579 if ( hasCName )
4580 {
4581 pObj->sName = controlName;
4582 }
4583 com::sun::star::awt::Size aSz;
4584 uno::Reference< form::XFormComponent > xFComp;
4585 const uno::Reference< lang::XMultiServiceFactory > & rServiceFactory =
4586 GetServiceFactory();
4587 if(!rServiceFactory.is())
4588 return(sal_False);
4589 bRet = pObj->FullRead(pSt);
4590 if(bRet)
4591 if (pObj->Import(rServiceFactory,xFComp,aSz))
4592 bRet = InsertControl( xFComp, aSz,pShapeRef,bFloatingCtrl);
4593 delete pObj;
4594 }
4595 return bRet;
4596 }
4597
4598
ReadOCXExcelKludgeStream(SvStorageStreamRef & rSrc1,uno::Reference<drawing::XShape> * pShapeRef,sal_Bool bFloatingCtrl)4599 sal_Bool SvxMSConvertOCXControls::ReadOCXExcelKludgeStream(
4600 SvStorageStreamRef& rSrc1, uno::Reference < drawing::XShape > *
4601 pShapeRef,sal_Bool bFloatingCtrl)
4602 {
4603 sal_Bool bRet=sal_False;
4604 /*Get Class Id of this object, see if it is one of the types
4605 *that this importer can handle, call the appropriate handler
4606 to read that control, and call the appropriate handler to
4607 insert that control
4608 */
4609 /*The Excel Kludge is to concatenate a class id with a contents
4610 * stream, and then concatenate all the controls together,
4611 * This means that you should have the cnts stream wound to the
4612 * correct location before passing the control stream in here*/
4613 SvStream *pSt = rSrc1;
4614 pSt->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
4615 SvGlobalName aTest;
4616 *pSt >> aTest;
4617 OCX_Control *pObj = OCX_Factory(aTest.GetHexName());
4618 if (pObj)
4619 {
4620
4621 com::sun::star::awt::Size aSz;
4622 uno::Reference< form::XFormComponent > xFComp;
4623 const uno::Reference< lang::XMultiServiceFactory > & rServiceFactory =
4624 GetServiceFactory();
4625 if(!rServiceFactory.is())
4626 return(sal_False);
4627 bRet = pObj->FullRead(rSrc1);
4628 if(bRet)
4629 if (pObj->Import(rServiceFactory,xFComp,aSz))
4630 bRet = InsertControl( xFComp, aSz,pShapeRef,bFloatingCtrl);
4631 delete pObj;
4632 }
4633 return bRet;
4634 }
4635
4636
WriteOCXStream(SvStorageRef & rSrc1,const uno::Reference<awt::XControlModel> & rControlModel,const awt::Size & rSize,String & rName)4637 sal_Bool SvxMSConvertOCXControls::WriteOCXStream( SvStorageRef& rSrc1,
4638 const uno::Reference< awt::XControlModel > &rControlModel,
4639 const awt::Size &rSize, String &rName)
4640 {
4641 sal_Bool bRet=sal_False;
4642
4643 DBG_ASSERT( rControlModel.is(), "UNO-Control missing Model, panic!" );
4644 if( !rControlModel.is() )
4645 return sal_False;
4646
4647 #if 0
4648 uno::Any aTmp = xPropSet->getPropertyValue(
4649 OUString::createFromAscii("ClassId"));
4650 sal_Int16 nClassId = *(sal_Int16*) aTmp.getValue();
4651 #endif
4652
4653 String sId;
4654 OCX_Control *pObj = OCX_Factory(rControlModel,sId,rName);
4655 if (pObj != NULL)
4656 {
4657 uno::Reference<beans::XPropertySet> xPropSet(rControlModel,
4658 uno::UNO_QUERY);
4659
4660 /* #117832# - also enable export of control name */
4661 OUString sCName;
4662 xPropSet->getPropertyValue(C2S("Name")) >>= sCName;
4663 pObj->sName = sCName;
4664
4665 SvGlobalName aName;
4666 aName.MakeId(sId);
4667 String sFullName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
4668 "Microsoft Forms 2.0 ")));
4669 sFullName.Append(rName);
4670 rSrc1->SetClass(aName,0x5C,sFullName);
4671 // ^^^^, this pathetic 0x5c is the magic number
4672 // which the lack of originally blocked the implementation of
4673 // the controls export
4674 // cmc
4675
4676 bRet = pObj->Export(rSrc1,xPropSet,rSize);
4677 SvStorageStreamRef xStor2( rSrc1->OpenSotStream( WW8_ASCII2STR("\3OCXNAME")));
4678 /* #117832# - also enable export of control name */
4679 writeOCXNAME( sCName, xStor2 );
4680 delete pObj;
4681 }
4682 return bRet;
4683 }
4684
4685
4686 //I think this should work for excel documents, create the "Ctls" stream
4687 //and give it here as rContents, we'll append out streams ole id and
4688 //contents here and that appears to be what Excel is doing
WriteOCXExcelKludgeStream(SvStorageStreamRef & rContents,const uno::Reference<awt::XControlModel> & rControlModel,const awt::Size & rSize,String & rName)4689 sal_Bool SvxMSConvertOCXControls::WriteOCXExcelKludgeStream(
4690 SvStorageStreamRef& rContents,
4691 const uno::Reference< awt::XControlModel > &rControlModel,
4692 const awt::Size &rSize, String &rName)
4693 {
4694 sal_Bool bRet=sal_False;
4695
4696 DBG_ASSERT( rControlModel.is(), "UNO-Control missing Model, panic!" );
4697 if( !rControlModel.is() )
4698 return sal_False;
4699
4700 String sId;
4701 OCX_Control *pObj = OCX_Factory(rControlModel,sId,rName);
4702 if (pObj != NULL)
4703 {
4704 uno::Reference<beans::XPropertySet> xPropSet(rControlModel,
4705 uno::UNO_QUERY);
4706
4707 SvGlobalName aName;
4708 aName.MakeId(sId);
4709 String sFullName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
4710 "Microsoft Forms 2.0 ")));
4711 sFullName.Append(rName);
4712 SvStream *pS=rContents;
4713 *pS << aName;
4714 bRet = pObj->WriteContents(rContents,xPropSet,rSize);
4715 delete pObj;
4716 // export needs correct stream position
4717 rContents->Seek( STREAM_SEEK_TO_END );
4718 }
4719 return bRet;
4720 }
4721
4722
4723
4724
4725
4726
4727
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)4728 sal_Bool OCX_CheckBox::Import(com::sun::star::uno::Reference<
4729 com::sun::star::beans::XPropertySet> &rPropSet)
4730 {
4731 uno::Any aTmp(&sName,getCppuType((OUString *)0));
4732 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
4733
4734 // background color: fBackStyle==0 -> transparent
4735 if( fBackStyle )
4736 aTmp <<= ImportColor(mnBackColor);
4737 else
4738 aTmp = uno::Any();
4739 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
4740
4741 sal_Bool bTemp;
4742 if ((!(fEnabled)) || (fLocked))
4743 bTemp = sal_False;
4744 else
4745 bTemp = sal_True;
4746 aTmp = bool2any(bTemp);
4747 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
4748
4749 bTemp = fWordWrap != 0;
4750 aTmp = bool2any(bTemp);
4751 rPropSet->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp);
4752
4753 aTmp <<= ImportColor(mnForeColor);
4754 rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
4755
4756 bTemp = nMultiState;
4757 aTmp = bool2any(bTemp);
4758 rPropSet->setPropertyValue( WW8_ASCII2STR("TriState"), aTmp);
4759
4760 aTmp <<= ImportSpecEffect( nSpecialEffect );
4761 rPropSet->setPropertyValue( WW8_ASCII2STR("VisualEffect"), aTmp);
4762
4763 if (pValue && !bSetInDialog)
4764 {
4765 sal_Int16 nTmp=pValue[0]-0x30;
4766 aTmp <<= nTmp;
4767 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp);
4768 }
4769
4770 if (pCaption)
4771 {
4772 aTmp <<= lclCreateOUString( pCaption, nCaptionLen );
4773 rPropSet->setPropertyValue( WW8_ASCII2STR("Label"), aTmp);
4774 }
4775
4776 // #i40279# always centered vertically
4777 aTmp <<= ::com::sun::star::style::VerticalAlignment_MIDDLE;
4778 rPropSet->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp );
4779
4780 aFontData.Import(rPropSet);
4781 return(sal_True);
4782 }
4783
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)4784 sal_Bool OCX_CheckBox::WriteContents(SvStorageStreamRef &rContents,
4785 const uno::Reference< beans::XPropertySet > &rPropSet,
4786 const awt::Size &rSize)
4787
4788 {
4789 sal_Bool bRet=sal_True;
4790 sal_uInt32 nOldPos = rContents->Tell();
4791 rContents->SeekRel(12);
4792
4793 pBlockFlags[0] = 0;
4794 pBlockFlags[1] = 0x01;
4795 pBlockFlags[2] = 0;
4796 pBlockFlags[3] = 0x80;
4797 pBlockFlags[4] = 0;
4798 pBlockFlags[5] = 0;
4799 pBlockFlags[6] = 0;
4800 pBlockFlags[7] = 0;
4801
4802 uno::Any aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
4803 fEnabled = any2bool(aTmp);
4804
4805 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
4806 fBackStyle = aTmp.hasValue() ? 1 : 0;
4807 if (fBackStyle)
4808 aTmp >>= mnBackColor;
4809
4810 sal_uInt8 nTemp=fEnabled;
4811 if (fEnabled)
4812 nTemp = nTemp << 1;
4813 if (fBackStyle)
4814 nTemp |= 0x08;
4815 *rContents << nTemp;
4816 pBlockFlags[0] |= 0x01;
4817 *rContents << sal_uInt8(0x00);
4818 nTemp = 0;
4819 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("MultiLine"));
4820 fWordWrap = any2bool(aTmp);
4821 if (fWordWrap)
4822 nTemp |= 0x80;
4823 *rContents << nTemp;
4824 *rContents << sal_uInt8(0x00);
4825
4826 *rContents << ExportColor(mnBackColor);
4827 pBlockFlags[0] |= 0x02;
4828
4829 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TextColor"));
4830 if (aTmp.hasValue())
4831 aTmp >>= mnForeColor;
4832 *rContents << ExportColor(mnForeColor);
4833 pBlockFlags[0] |= 0x04;
4834
4835 nStyle = 4;
4836 *rContents << nStyle;
4837 pBlockFlags[0] |= 0x40;
4838
4839 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("TriState"));
4840 nMultiState = any2bool(aTmp);
4841 *rContents << nMultiState;
4842 pBlockFlags[2] |= 0x20;
4843
4844 WriteAlign(rContents,4);
4845 nValueLen = 1|SVX_MSOCX_COMPRESSED;
4846 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("DefaultState"));
4847 sal_Int16 nDefault = sal_Int16();
4848 aTmp >>= nDefault;
4849 *rContents << nValueLen;
4850 pBlockFlags[2] |= 0x40;
4851
4852 SvxOcxString aCaption( rPropSet->getPropertyValue(WW8_ASCII2STR("Label")) );
4853 aCaption.WriteLenField( *rContents );
4854 if (aCaption.HasData())
4855 pBlockFlags[2] |= 0x80;
4856
4857 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("VisualEffect"));
4858 if (aTmp.hasValue())
4859 {
4860 sal_Int16 nApiSpecEffect = sal_Int16();
4861 aTmp >>= nApiSpecEffect;
4862 nSpecialEffect = ExportSpecEffect( nApiSpecEffect );
4863 }
4864 WriteAlign(rContents,4);
4865 *rContents << nSpecialEffect;
4866 pBlockFlags[3] |= 0x04;
4867
4868 WriteAlign(rContents,4);
4869 *rContents << rSize.Width;
4870 *rContents << rSize.Height;
4871
4872 nDefault += 0x30;
4873 *rContents << sal_uInt8(nDefault);
4874 *rContents << sal_uInt8(0x00);
4875
4876 aCaption.WriteCharArray( *rContents );
4877
4878 WriteAlign(rContents,4);
4879 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
4880 bRet = aFontData.Export(rContents,rPropSet);
4881 rContents->Seek(nOldPos);
4882 *rContents << nStandardId;
4883 *rContents << nFixedAreaLen;
4884
4885 *rContents << pBlockFlags[0];
4886 *rContents << pBlockFlags[1];
4887 *rContents << pBlockFlags[2];
4888 *rContents << pBlockFlags[3];
4889 *rContents << pBlockFlags[4];
4890 *rContents << pBlockFlags[5];
4891 *rContents << pBlockFlags[6];
4892 *rContents << pBlockFlags[7];
4893
4894 DBG_ASSERT((rContents.Is() &&
4895 (SVSTREAM_OK==rContents->GetError())),"damn");
4896 return bRet;
4897 }
4898
4899
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)4900 sal_Bool OCX_CheckBox::Export(SvStorageRef &rObj,
4901 const uno::Reference< beans::XPropertySet > &rPropSet,
4902 const awt::Size &rSize)
4903
4904 {
4905 static sal_uInt8 __READONLY_DATA aCompObj[] = {
4906 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
4907 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
4908 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
4909 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
4910 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
4911 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
4912 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
4913 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
4914 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
4915 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
4916 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
4917 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
4918 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
4919 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4920 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
4921 };
4922
4923 {
4924 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
4925 xStor->Write(aCompObj,sizeof(aCompObj));
4926 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
4927 }
4928
4929 {
4930 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
4931 xStor3->Write(aObjInfo,sizeof(aObjInfo));
4932 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
4933 }
4934
4935 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
4936 0x43, 0x00, 0x68, 0x00, 0x65, 0x00, 0x63, 0x00,
4937 0x6B, 0x00, 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00,
4938 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
4939 };
4940 {
4941 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
4942 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
4943 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
4944 }
4945 /*
4946 static sal_uInt8 __READONLY_DATA aTest[] = {
4947 0x00, 0x02, 0x34, 0x00, 0x46, 0x01, 0xC0, 0x80,
4948 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00,
4949 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
4950 0x01, 0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x80,
4951 0xE2, 0x0E, 0x00, 0x00, 0x95, 0x02, 0x00, 0x00,
4952 0x30, 0x69, 0x1D, 0x00, 0x43, 0x68, 0x65, 0x63,
4953 0x6B, 0x42, 0x6F, 0x78, 0x31, 0x20, 0x52, 0x6F,
4954 0x00, 0x02, 0x20, 0x00, 0x35, 0x00, 0x00, 0x00,
4955 0x0F, 0x00, 0x00, 0x80, 0xC3, 0x00, 0x00, 0x00,
4956 0x00, 0x02, 0x00, 0x00, 0x54, 0x69, 0x6D, 0x65,
4957 0x73, 0x20, 0x4E, 0x65, 0x77, 0x20, 0x52, 0x6F,
4958 0x6D, 0x61, 0x6E, 0x00,
4959 };
4960 */
4961 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
4962 return WriteContents(xContents, rPropSet, rSize);
4963 }
4964
4965
Read(SvStorageStream * pS)4966 sal_Bool OCX_FontData::Read(SvStorageStream *pS)
4967 {
4968 long nStart = pS->Tell();
4969 *pS >> nIdentifier;
4970 *pS >> nFixedAreaLen;
4971 pS->Read(pBlockFlags,4);
4972
4973 bool bFontName = (pBlockFlags[0] & 0x01) != 0;
4974 if (bFontName)
4975 *pS >> nFontNameLen;
4976 if (pBlockFlags[0] & 0x02)
4977 {
4978 sal_uInt8 nTmp;
4979 *pS >> nTmp;
4980 fBold = nTmp & 0x01;
4981 fItalic = (nTmp & 0x02) >> 1;
4982 fUnderline = (nTmp & 0x04) >> 2;
4983 fStrike = (nTmp & 0x08) >> 3;
4984 fUnknown1 = (nTmp & 0xF0) >> 4;
4985 *pS >> nUnknown2;
4986 *pS >> nUnknown3;
4987 *pS >> nUnknown4;
4988 }
4989 if (pBlockFlags[0] & 0x04)
4990 {
4991 ReadAlign(pS, pS->Tell() - nStart, 4);
4992 *pS >> nFontSize;
4993 }
4994 else
4995 nFontSize = 240;
4996 if (pBlockFlags[0] & 0x10)
4997 {
4998 ReadAlign(pS, pS->Tell() - nStart, 2);
4999 *pS >> nLanguageID;
5000 }
5001 if (pBlockFlags[0] & 0x40)
5002 {
5003 *pS >> nJustification;
5004 }
5005 if (pBlockFlags[0] & 0x80) // font weight before font name
5006 {
5007 ReadAlign(pS, pS->Tell() - nStart, 2);
5008 *pS >> nFontWeight;
5009 }
5010
5011 if (bFontName)
5012 lclReadCharArray( *pS, pFontName, nFontNameLen, pS->Tell() - nStart);
5013
5014 ReadAlign(pS, pS->Tell() - nStart, 4);
5015 return(sal_True);
5016 }
5017
Import(uno::Reference<beans::XPropertySet> & rPropSet)5018 void OCX_FontData::Import(uno::Reference< beans::XPropertySet > &rPropSet)
5019 {
5020 uno::Any aTmp;
5021 if (pFontName)
5022 {
5023 aTmp <<= lclCreateOUString( pFontName, nFontNameLen );
5024 rPropSet->setPropertyValue( WW8_ASCII2STR("FontName"), aTmp);
5025 }
5026
5027 if (bHasAlign)
5028 {
5029 sal_Int16 nAlign = ImportAlign(nJustification);
5030 aTmp <<= nAlign;
5031 rPropSet->setPropertyValue( WW8_ASCII2STR("Align"), aTmp);
5032 }
5033
5034 if (fBold)
5035 {
5036 aTmp <<= awt::FontWeight::BOLD;
5037 rPropSet->setPropertyValue( WW8_ASCII2STR("FontWeight"), aTmp);
5038 }
5039
5040 if (fItalic)
5041 {
5042 aTmp <<= (sal_Int16)awt::FontSlant_ITALIC;
5043 rPropSet->setPropertyValue( WW8_ASCII2STR("FontSlant"), aTmp);
5044 }
5045
5046 if (fUnderline)
5047 {
5048 aTmp <<= awt::FontUnderline::SINGLE;
5049 rPropSet->setPropertyValue( WW8_ASCII2STR("FontUnderline"), aTmp);
5050 }
5051
5052 if (fStrike)
5053 {
5054 aTmp <<= awt::FontStrikeout::SINGLE;
5055 rPropSet->setPropertyValue( WW8_ASCII2STR("FontStrikeout"), aTmp);
5056 }
5057
5058 // 2004-09-17: very strange way of storing font sizes...
5059 // 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135
5060 // 8pt->165, 9pt->180, 10pt->195, 11pt->225, ...
5061 aTmp <<= sal_Int16( (nFontSize <= 30) ? 1 : ((nFontSize + 10) / 20) );
5062 rPropSet->setPropertyValue( WW8_ASCII2STR("FontHeight"), aTmp);
5063 }
5064
Export(SvStorageStreamRef & rContent,const uno::Reference<beans::XPropertySet> & rPropSet)5065 sal_Bool OCX_FontData::Export(SvStorageStreamRef &rContent,
5066 const uno::Reference< beans::XPropertySet > &rPropSet)
5067 {
5068 sal_uInt8 nFlags=0x00;
5069 sal_uInt32 nOldPos = rContent->Tell();
5070 rContent->SeekRel(8);
5071 SvxOcxString aFontName;
5072 uno::Any aTmp;
5073
5074 if (bHasFont)
5075 aFontName = rPropSet->getPropertyValue(WW8_ASCII2STR("FontName"));
5076 if (!aFontName.HasData())
5077 aFontName = OUString( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) );
5078 aFontName.WriteLenField( *rContent );
5079 nFlags |= 0x01;
5080
5081 if (bHasFont)
5082 {
5083 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("FontWeight"));
5084 //Export font related props
5085 if ( aTmp.hasValue() )
5086 {
5087 float nBold = 0.0;
5088 aTmp >>= nBold;
5089 if ( nBold >= 150 )
5090 fBold = 1;
5091 }
5092
5093 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("FontSlant"));
5094 if ( aTmp.hasValue() )
5095 {
5096 short eItalic = 0 ;
5097 aTmp >>= eItalic ;
5098 if ( eItalic == awt::FontSlant_ITALIC )
5099 fItalic = 1;
5100 }
5101
5102 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("FontUnderline"));
5103 if ( aTmp.hasValue() )
5104 {
5105 short eUnderline = 0 ;
5106 aTmp >>= eUnderline;
5107 if ( eUnderline == awt::FontUnderline::SINGLE )
5108 fUnderline = 1;
5109 }
5110
5111 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("FontStrikeout"));
5112 if ( aTmp.hasValue() )
5113 {
5114 short eLtStrikeout = 0;
5115 aTmp >>= eLtStrikeout;
5116 if ( eLtStrikeout == awt::FontStrikeout::SINGLE )
5117 fStrike = 1;
5118 }
5119
5120 sal_uInt8 nTmp= 1 * fBold + 2* fItalic + 4* fUnderline + 8 * fStrike;
5121 if ( nTmp > 0 )
5122 {
5123 nFlags |= 0x02;
5124 *rContent << nTmp;
5125 nTmp=0x00;
5126 *rContent << nTmp;
5127 *rContent << nTmp;
5128 *rContent << nTmp;
5129 }
5130
5131 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("FontHeight"));
5132 float nFontHeight = 0;
5133 aTmp >>= nFontHeight;
5134 if (nFontHeight)
5135 {
5136 nFlags |= 0x04;
5137 // 2004-09-17: very strange way of storing font sizes:
5138 // 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135
5139 // 8pt->165, 9pt->180, 10pt->195, 11pt->225, ...
5140 nFontSize = (nFontHeight == 1) ? 30 : (static_cast<sal_uInt32>((nFontHeight*4+1)/3)*15);
5141 *rContent << nFontSize;
5142 }
5143
5144 if (bHasAlign)
5145 {
5146 *rContent << sal_uInt16(0x0200);
5147 nFlags |= 0x10;
5148
5149 nFlags |= 0x20; // ?
5150
5151 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Align"));
5152 nFlags |= 0x40;
5153 sal_Int16 nAlign = nDefaultAlign;
5154 if (aTmp.hasValue())
5155 aTmp >>= nAlign;
5156 nJustification = ExportAlign(nAlign);
5157 *rContent << nJustification;
5158 }
5159 }
5160
5161 aFontName.WriteCharArray( *rContent );
5162 WriteAlign(rContent,4);
5163
5164 sal_uInt16 nFixedAreaLn = static_cast<sal_uInt16>(rContent->Tell()-nOldPos-4);
5165 rContent->Seek(nOldPos);
5166 *rContent << nStandardId;
5167 *rContent << nFixedAreaLn;
5168 *rContent << nFlags;
5169 *rContent << sal_uInt8(0x00);
5170 *rContent << sal_uInt8(0x00);
5171 *rContent << sal_uInt8(0x00);
5172
5173 WriteAlign(rContent,4);
5174 return sal_True;
5175 }
5176
5177 // Doesn't really read anything but just skips the
5178 // record.
Read(SotStorageStream * pS)5179 sal_Bool OCX_TabStrip::Read(SotStorageStream *pS)
5180 {
5181 const long skipLen = 0x18;
5182 *pS >> nIdentifier;
5183 DBG_ASSERT(nStandardId==nIdentifier,
5184 "A control that has a different identifier");
5185 *pS >> nFixedAreaLen;
5186
5187 pS->Read(pBlockFlags, sizeof(pBlockFlags));
5188 pS->SeekRel(skipLen);
5189 *pS >> nNumTabs;
5190 // skip to end of control
5191 pS->SeekRel(nFixedAreaLen - sizeof(pBlockFlags) - sizeof(nNumTabs) - skipLen );
5192 return sal_True;
5193 }
5194
ReadFontData(SotStorageStream * pS)5195 sal_Bool OCX_TabStrip::ReadFontData(SotStorageStream *pS)
5196 {
5197 // Seems like there is a real font record followed by
5198 // a number of blank records ( e.g. nFixedAreaLen = 0 )
5199 // The number of trailing blank records is equal to the number of tabs
5200 OCX_Control::ReadFontData(pS);
5201 for ( sal_uInt16 index = 0; index < nNumTabs; index++ )
5202 {
5203 OCX_Control::Read(pS); // read trailing records
5204 }
5205 return sal_True;
5206 }
5207
Read(SotStorageStream * pS)5208 sal_Bool OCX_Image::Read(SotStorageStream *pS)
5209 {
5210 if ( !bSetInDialog )
5211 {
5212 // preserve the present behavior at the moment.
5213 // only import image control for UserForms
5214 return sal_False;
5215 }
5216 sal_uLong nStart = pS->Tell();
5217 *pS >> nIdentifier;
5218 DBG_ASSERT(nStandardId==nIdentifier,
5219 "A control that has a different identifier");
5220 *pS >> nFixedAreaLen;
5221
5222 pS->Read(pBlockFlags, sizeof(pBlockFlags));
5223
5224 bool hasEmbeddedImage = false;
5225
5226 if ( pBlockFlags[0] & 0x04 )
5227 {
5228 bAutoSize = true;
5229 }
5230 if ( pBlockFlags[0] & 0x08 )
5231 {
5232 *pS >> nBorderColor;
5233 }
5234 if ( pBlockFlags[0] & 0x10 )
5235 {
5236 *pS >> mnBackColor;
5237 }
5238 if ( pBlockFlags[0] & 0x20 )
5239 {
5240 *pS >> nBorderStyle;
5241 }
5242 if ( pBlockFlags[0] & 0x40 )
5243 {
5244 *pS >> nMousePointer;
5245 }
5246 if ( pBlockFlags[0] & 0x80 )
5247 {
5248 *pS >> nPictureSizeMode;
5249 }
5250
5251 if ( pBlockFlags[ 1 ] & 0x1 )
5252 {
5253 *pS >> nSpecialEffect;
5254 }
5255 // investigate if valid also for formcontrols, although for controls
5256 // images themselves seem to come through from escher ( as shape, think
5257 // its probably a preview? )
5258
5259 // np a bit of a guess ( until proved incorrect )
5260 if ( pBlockFlags[ 1 ] & 0x4 )
5261 {
5262 ReadAlign(pS, pS->Tell() - nStart, 2);
5263 hasEmbeddedImage = true;
5264 sal_uInt16 unknown;
5265 *pS >> unknown;
5266 }
5267
5268
5269 if ( pBlockFlags[ 1 ] & 0x8 )
5270 {
5271 ReadAlign(pS, pS->Tell() - nStart, 2);
5272 *pS >> nPictureAlignment;
5273
5274 }
5275 if ( pBlockFlags[ 1 ] & 0x10 )
5276 {
5277 bPictureTiling = true;
5278 }
5279 if ( pBlockFlags[1] & 0x20 )
5280 {
5281 ReadAlign(pS, pS->Tell() - nStart, 4);
5282 sal_uInt8 nTemp;
5283 *pS >> nTemp;
5284 fEnabled = (nTemp&0x02)>>1;
5285 fBackStyle = (nTemp&0x08)>>3;
5286 // padding?
5287 *pS >> nTemp;
5288 *pS >> nTemp;
5289 *pS >> nTemp;
5290 }
5291 ReadAlign(pS, pS->Tell() - nStart, 4);
5292 *pS >> nWidth;
5293 *pS >> nHeight;
5294
5295 if ( hasEmbeddedImage )
5296 {
5297 //image follows this block
5298 //len of image is 0x14 relative to end of this block
5299 pS->Seek( pS->Tell() + 0x14 );
5300
5301 sal_uInt32 nImageLen = 0;
5302 *pS >> nImageLen;
5303
5304 long imagePos = pS->Tell();
5305
5306 pS->Seek( imagePos );
5307
5308 sImageUrl = C2U("vnd.sun.star.expand:${$OOO_BASE_DIR/program/") + C2U( SAL_CONFIGFILE( "bootstrap" ) ) + C2U("::UserInstallation}/user/temp/") + sName;
5309
5310 sal_uInt8* pImage = new sal_uInt8[ nImageLen ];
5311 pS->Read(pImage, nImageLen);
5312 bool result = storePictureInFileSystem( sImageUrl, pImage, nImageLen );
5313 OUString pictName = sImageUrl.copy( sImageUrl.lastIndexOf('/') + 1 );
5314 result = storePictureInDoc( pDocSh, pictName, pImage, nImageLen );
5315 delete [] pImage;
5316 }
5317 return sal_True;
5318 }
5319
Import(uno::Reference<beans::XPropertySet> & rPropSet)5320 sal_Bool OCX_Image::Import( uno::Reference< beans::XPropertySet > &rPropSet )
5321 {
5322 uno::Any aTmp(&sName,getCppuType((OUString *)0));
5323 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
5324
5325 if( fBackStyle )
5326 aTmp <<= ImportColor(mnBackColor);
5327 else
5328 aTmp = uno::Any();
5329 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
5330
5331 sal_Bool bTemp;
5332 if (fEnabled)
5333 bTemp = sal_True;
5334 else
5335 bTemp = sal_False;
5336 aTmp = bool2any(bTemp);
5337 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
5338 if ( sImageUrl.getLength() )
5339 {
5340 aTmp <<= sImageUrl;
5341 rPropSet->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp);
5342 }
5343 return sal_True;
5344 }
5345
WriteContents(SvStorageStreamRef & rContents,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)5346 sal_Bool OCX_Image::WriteContents(SvStorageStreamRef &rContents,
5347 const uno::Reference< beans::XPropertySet > &rPropSet,
5348 const awt::Size &rSize)
5349 {
5350 sal_Bool bRet=sal_True;
5351 sal_uInt32 nOldPos = rContents->Tell();
5352 rContents->SeekRel(8);
5353
5354 pBlockFlags[0] = 0;
5355 pBlockFlags[1] = 0x02;
5356 pBlockFlags[2] = 0;
5357 pBlockFlags[3] = 0;
5358
5359 uno::Any aTmp = rPropSet->getPropertyValue(
5360 WW8_ASCII2STR("BackgroundColor"));
5361 if (aTmp.hasValue())
5362 aTmp >>= mnBackColor;
5363 *rContents << ExportColor(mnBackColor);
5364 pBlockFlags[0] |= 0x10;
5365
5366
5367 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Border"));
5368 sal_Int16 nBorder = sal_Int16();
5369 aTmp >>= nBorder;
5370 nSpecialEffect = ExportBorder(nBorder,nBorderStyle);
5371 *rContents << nBorderStyle;
5372 pBlockFlags[0] |= 0x20;
5373
5374 *rContents << nSpecialEffect;
5375 pBlockFlags[1] |= 0x01;
5376
5377 WriteAlign(rContents,4);
5378
5379 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("Enabled"));
5380 fEnabled = any2bool(aTmp);
5381 if (fEnabled)
5382 {
5383 sal_uInt8 nTemp = 0x19;
5384 *rContents << nTemp;
5385 pBlockFlags[1] |= 0x20;
5386 *rContents << sal_uInt8(0x00);
5387 *rContents << sal_uInt8(0x00);
5388 *rContents << sal_uInt8(0x00);
5389 }
5390
5391 aTmp = rPropSet->getPropertyValue(WW8_ASCII2STR("ImageURL"));
5392 // OUString *pStr = (OUString *)aTmp.getValue();
5393 /*Magically fetch that image and turn it into something that
5394 *we can store in ms controls, wmf,png,jpg are almost certainly
5395 *the options we have for export...*/
5396
5397 WriteAlign(rContents,4);
5398 *rContents << rSize.Width;
5399 *rContents << rSize.Height;
5400
5401 WriteAlign(rContents,4);
5402 nFixedAreaLen = static_cast<sal_uInt16>(rContents->Tell()-nOldPos-4);
5403
5404 rContents->Seek(nOldPos);
5405 *rContents << nStandardId;
5406 *rContents << nFixedAreaLen;
5407
5408 *rContents << pBlockFlags[0];
5409 *rContents << pBlockFlags[1];
5410 *rContents << pBlockFlags[2];
5411 *rContents << pBlockFlags[3];
5412 DBG_ASSERT((rContents.Is() &&
5413 (SVSTREAM_OK==rContents->GetError())),"damn");
5414 return bRet;
5415 }
5416
5417
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)5418 sal_Bool OCX_Image::Export(SvStorageRef &rObj,
5419 const uno::Reference< beans::XPropertySet > &rPropSet,
5420 const awt::Size &rSize)
5421 {
5422 static sal_uInt8 __READONLY_DATA aCompObj[] = {
5423 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5424 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
5425 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
5426 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
5427 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5428 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5429 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
5430 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
5431 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
5432 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
5433 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
5434 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
5435 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
5436 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5437 };
5438
5439 {
5440 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
5441 xStor->Write(aCompObj,sizeof(aCompObj));
5442 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
5443 }
5444
5445 {
5446 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
5447 xStor3->Write(aObjInfo,sizeof(aObjInfo));
5448 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
5449 }
5450
5451 static sal_uInt8 __READONLY_DATA aOCXNAME[] = {
5452 0x49, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x67, 0x00,
5453 0x65, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
5454 };
5455
5456 {
5457 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
5458 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
5459 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
5460 }
5461
5462 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
5463 return WriteContents(xContents, rPropSet, rSize);
5464 }
5465
5466 // ============================================================================
5467
OCX_SpinButton()5468 OCX_SpinButton::OCX_SpinButton() :
5469 OCX_Control( OUString( RTL_CONSTASCII_USTRINGPARAM( "SpinButton" ) ) ),
5470 mnBlockFlags( 0 ),
5471 mnValue( 0 ),
5472 mnMin( 0 ),
5473 mnMax( 100 ),
5474 mnSmallStep( 1 ),
5475 mnPageStep( 1 ),
5476 mnOrient( -1 ),
5477 mnDelay( 50 ),
5478 mbEnabled( true ),
5479 mbLocked( false ),
5480 mbPropThumb( true )
5481 {
5482 msFormType = C2U("com.sun.star.form.component.SpinButton");
5483 msDialogType = C2U("com.sun.star.awt.UnoControlSpinButtonModel");
5484 mnBackColor = 0x8000000F;
5485 mnForeColor = 0x80000012;
5486 }
5487
Create()5488 OCX_Control* OCX_SpinButton::Create()
5489 {
5490 return new OCX_SpinButton;
5491 }
5492
Read(SvStorageStream * pS)5493 sal_Bool OCX_SpinButton::Read( SvStorageStream *pS )
5494 {
5495 if( !pS ) return sal_False;
5496
5497 SvStream& rStrm = *pS;
5498 sal_uInt16 nId, nSize;
5499 sal_Int32 nIcon = 0;
5500
5501 rStrm >> nId >> nSize >> mnBlockFlags;
5502
5503 DBG_ASSERT( nStandardId == nId, "OCX_SpinButton::Read - unknown identifier" );
5504
5505 if( mnBlockFlags & 0x00000001 ) rStrm >> mnForeColor;
5506 if( mnBlockFlags & 0x00000002 ) rStrm >> mnBackColor;
5507 if( mnBlockFlags & 0x00000004 )
5508 {
5509 sal_Int32 nFlags;
5510 rStrm >> nFlags;
5511 mbEnabled = (nFlags & 0x00000002) != 0;
5512 mbLocked = (nFlags & 0x00000004) != 0;
5513 }
5514 if( mnBlockFlags & 0x00000010 ) rStrm.SeekRel( 4 ); // mouse pointer
5515 if( mnBlockFlags & 0x00000020 ) rStrm >> mnMin;
5516 if( mnBlockFlags & 0x00000040 ) rStrm >> mnMax;
5517 if( mnBlockFlags & 0x00000080 ) rStrm >> mnValue;
5518 if( mnBlockFlags & 0x00000100 ) rStrm.SeekRel( 4 ); // unknown
5519 if( mnBlockFlags & 0x00000200 ) rStrm.SeekRel( 4 ); // unknown
5520 if( mnBlockFlags & 0x00000400 ) rStrm.SeekRel( 4 ); // unknown
5521 if( mnBlockFlags & 0x00000800 ) rStrm >> mnSmallStep;
5522 if( mnBlockFlags & 0x00001000 ) rStrm >> mnPageStep;
5523 if( mnBlockFlags & 0x00002000 ) rStrm >> mnOrient;
5524 if( mnBlockFlags & 0x00004000 )
5525 {
5526 sal_Int32 nThumb;
5527 *pS >> nThumb;
5528 mbPropThumb = nThumb != 0;
5529 }
5530 if( mnBlockFlags & 0x00008000 ) rStrm >> mnDelay;
5531 if( mnBlockFlags & 0x00010000 ) rStrm >> nIcon;
5532 if( mnBlockFlags & 0x00000008 ) rStrm >> nWidth >> nHeight;
5533
5534 if( nIcon )
5535 {
5536 sal_Int32 nIconSize;
5537 pS->SeekRel( 20 );
5538 *pS >> nIconSize;
5539 pS->SeekRel( nIconSize );
5540 }
5541
5542 return sal_True;
5543 }
5544
ReadFontData(SvStorageStream *)5545 sal_Bool OCX_SpinButton::ReadFontData( SvStorageStream* /* pS */ )
5546 {
5547 // spin buttons and scroll bars do not support font data
5548 return sal_True;
5549 }
5550
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)5551 sal_Bool OCX_SpinButton::Import(com::sun::star::uno::Reference<
5552 com::sun::star::beans::XPropertySet> &rPropSet)
5553 {
5554 if( (nWidth < 1) || (nHeight < 1) )
5555 return sal_False;
5556
5557 uno::Any aTmp( &sName, getCppuType((OUString *)0) );
5558 rPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
5559
5560 aTmp <<= ImportColor( mnForeColor );
5561 rPropSet->setPropertyValue( WW8_ASCII2STR("SymbolColor"), aTmp);
5562
5563 aTmp <<= ImportColor( mnBackColor );
5564 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
5565
5566 aTmp = bool2any( mbEnabled && !mbLocked );
5567 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
5568
5569 aTmp <<= mnValue;
5570 if ( bSetInDialog )
5571 {
5572 rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValue"), aTmp );
5573 }
5574 else
5575 {
5576 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultSpinValue"), aTmp );
5577 }
5578
5579 aTmp <<= mnMin;
5580 rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValueMin"), aTmp );
5581
5582 aTmp <<= mnMax;
5583 rPropSet->setPropertyValue( WW8_ASCII2STR("SpinValueMax"), aTmp );
5584
5585 aTmp <<= mnSmallStep;
5586 rPropSet->setPropertyValue( WW8_ASCII2STR("SpinIncrement"), aTmp );
5587
5588 namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
5589 switch( mnOrient )
5590 {
5591 case 0: aTmp <<= AwtScrollOrient::VERTICAL; break;
5592 case 1: aTmp <<= AwtScrollOrient::HORIZONTAL; break;
5593 default: aTmp <<= (nWidth < nHeight) ? AwtScrollOrient::VERTICAL : AwtScrollOrient::HORIZONTAL;
5594 }
5595 rPropSet->setPropertyValue( WW8_ASCII2STR("Orientation"), aTmp );
5596
5597 aTmp = bool2any( true );
5598 rPropSet->setPropertyValue( WW8_ASCII2STR("Repeat"), aTmp );
5599
5600 aTmp <<= mnDelay;
5601 rPropSet->setPropertyValue( WW8_ASCII2STR("RepeatDelay"), aTmp );
5602
5603 aTmp <<= sal_Int16( 0 );
5604 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
5605
5606 return sal_True;
5607 }
5608
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)5609 sal_Bool OCX_SpinButton::Export(
5610 SvStorageRef &rObj,
5611 const uno::Reference< beans::XPropertySet>& rPropSet,
5612 const awt::Size& rSize )
5613 {
5614 static sal_uInt8 __READONLY_DATA aCompObj[] =
5615 {
5616 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5617 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
5618 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
5619 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
5620 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5621 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5622 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
5623 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
5624 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
5625 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
5626 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
5627 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x70, 0x69,//Add those to avoid MS crash when open
5628 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
5629 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
5630 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5631 0x00, 0x00
5632 };
5633
5634 {
5635 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
5636 xStor->Write(aCompObj,sizeof(aCompObj));
5637 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
5638 }
5639
5640 {
5641 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
5642 xStor3->Write(aObjInfo,sizeof(aObjInfo));
5643 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
5644 }
5645
5646 static sal_uInt8 __READONLY_DATA aOCXNAME[] =
5647 {
5648 0x53, 0x00, 0x70, 0x00, 0x69, 0x00, 0x6E, 0x00,
5649 0x42, 0x00, 0x75, 0x00, 0x74, 0x00, 0x74, 0x00,
5650 0x6F, 0x00, 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00,
5651 0x00, 0x00
5652 };
5653
5654 {
5655 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
5656 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
5657 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
5658 }
5659
5660 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
5661 return WriteContents(xContents, rPropSet, rSize);
5662 }
5663
WriteContents(SvStorageStreamRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)5664 sal_Bool OCX_SpinButton::WriteContents(
5665 SvStorageStreamRef &rObj,
5666 const uno::Reference< beans::XPropertySet> &rPropSet,
5667 const awt::Size& rSize )
5668 {
5669 if( !rObj.Is() )
5670 return sal_False;
5671
5672 mnBlockFlags = 0x00000008;
5673 nWidth = rSize.Width;
5674 nHeight = rSize.Height;
5675
5676 GetInt32Property( mnForeColor, rPropSet, WW8_ASCII2STR( "SymbolColor" ), 0x00000001 );
5677 GetInt32Property( mnBackColor, rPropSet, WW8_ASCII2STR( "BackgroundColor" ), 0x00000002 );
5678 GetBoolProperty( mbEnabled, rPropSet, WW8_ASCII2STR( "Enabled" ), 0x00000304 );
5679 GetInt32Property( mnMin, rPropSet, WW8_ASCII2STR( "SpinValueMin" ), 0x00000020 );
5680 GetInt32Property( mnMax, rPropSet, WW8_ASCII2STR( "SpinValueMax" ), 0x00000040 );
5681 GetInt32Property( mnValue, rPropSet, WW8_ASCII2STR( "SpinValue" ), 0x00000080 );
5682 GetInt32Property( mnSmallStep, rPropSet, WW8_ASCII2STR( "SpinIncrement" ), 0x00000800 );
5683 GetInt32Property( mnDelay, rPropSet, WW8_ASCII2STR( "RepeatDelay" ), 0x00008000 );
5684
5685 namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
5686 sal_Int16 nApiOrient = sal_Int16();
5687 if( rPropSet->getPropertyValue( WW8_ASCII2STR( "Orientation" ) ) >>= nApiOrient )
5688 UpdateInt32Property( mnOrient, (nApiOrient == AwtScrollOrient::VERTICAL) ? 0 : 1, 0x00002000 );
5689
5690 return WriteData( *rObj );
5691 }
5692
UpdateInt32Property(sal_Int32 & rnCoreValue,sal_Int32 nNewValue,sal_Int32 nBlockFlag)5693 void OCX_SpinButton::UpdateInt32Property(
5694 sal_Int32& rnCoreValue, sal_Int32 nNewValue, sal_Int32 nBlockFlag )
5695 {
5696 if( nNewValue != rnCoreValue )
5697 {
5698 rnCoreValue = nNewValue;
5699 mnBlockFlags |= nBlockFlag;
5700 }
5701 }
5702
GetInt32Property(sal_Int32 & rnCoreValue,const uno::Reference<beans::XPropertySet> & rxPropSet,const OUString & rPropName,sal_Int32 nBlockFlag)5703 void OCX_SpinButton::GetInt32Property(
5704 sal_Int32& rnCoreValue, const uno::Reference< beans::XPropertySet>& rxPropSet,
5705 const OUString& rPropName, sal_Int32 nBlockFlag )
5706 {
5707 sal_Int32 nNewValue = 0;
5708 if( rxPropSet->getPropertyValue( rPropName ) >>= nNewValue )
5709 UpdateInt32Property( rnCoreValue, nNewValue, nBlockFlag );
5710 }
5711
UpdateBoolProperty(bool & rbCoreValue,bool bNewValue,sal_Int32 nBlockFlag)5712 void OCX_SpinButton::UpdateBoolProperty(
5713 bool& rbCoreValue, bool bNewValue, sal_Int32 nBlockFlag )
5714 {
5715 if( bNewValue != rbCoreValue )
5716 {
5717 rbCoreValue = bNewValue;
5718 mnBlockFlags |= nBlockFlag;
5719 }
5720 }
5721
GetBoolProperty(bool & rbCoreValue,const uno::Reference<beans::XPropertySet> & rxPropSet,const OUString & rPropName,sal_Int32 nBlockFlag)5722 void OCX_SpinButton::GetBoolProperty(
5723 bool& rbCoreValue, const uno::Reference< beans::XPropertySet>& rxPropSet,
5724 const OUString& rPropName, sal_Int32 nBlockFlag )
5725 {
5726 UpdateBoolProperty( rbCoreValue,
5727 any2bool( rxPropSet->getPropertyValue( rPropName ) ), nBlockFlag );
5728 }
5729
WriteData(SvStream & rStrm) const5730 sal_Bool OCX_SpinButton::WriteData( SvStream& rStrm ) const
5731 {
5732 sal_Bool bRet = sal_True;
5733 sal_uLong nStartPos = rStrm.Tell();
5734
5735 rStrm << sal_Int32( 0 ) << mnBlockFlags;
5736
5737 if( mnBlockFlags & 0x00000001 ) rStrm << ExportColor( mnForeColor );
5738 if( mnBlockFlags & 0x00000002 ) rStrm << ExportColor( mnBackColor );
5739 if( mnBlockFlags & 0x00000004 )
5740 {
5741 sal_Int32 nFlags = 0x00000019; // always set
5742 if( mbEnabled ) nFlags |= 0x00000002;
5743 if( mbLocked ) nFlags |= 0x00000004;
5744 rStrm << nFlags;
5745 }
5746 if( mnBlockFlags & 0x00000020 ) rStrm << mnMin;
5747 if( mnBlockFlags & 0x00000040 ) rStrm << mnMax;
5748 if( mnBlockFlags & 0x00000080 ) rStrm << mnValue;
5749 if( mnBlockFlags & 0x00000100 ) rStrm << sal_Int32( 0 ); // unknown
5750 if( mnBlockFlags & 0x00000200 ) rStrm << sal_Int32( 0 ); // unknown
5751 if( mnBlockFlags & 0x00000400 ) rStrm << sal_Int32( 0 ); // unknown
5752 if( mnBlockFlags & 0x00000800 ) rStrm << mnSmallStep;
5753 if( mnBlockFlags & 0x00001000 ) rStrm << mnPageStep;
5754 if( mnBlockFlags & 0x00002000 ) rStrm << mnOrient;
5755 if( mnBlockFlags & 0x00004000 ) rStrm << sal_Int32( mbPropThumb ? 1 : 0 );
5756 if( mnBlockFlags & 0x00008000 ) rStrm << mnDelay;
5757 if( mnBlockFlags & 0x00000008 ) rStrm << nWidth << nHeight;
5758
5759 sal_uInt16 nSize = static_cast< sal_uInt16 >( rStrm.Tell() - nStartPos - 4 );
5760 rStrm.Seek( nStartPos );
5761 rStrm << nStandardId << nSize;
5762
5763 DBG_ASSERT( rStrm.GetError() == SVSTREAM_OK, "OCX_SpinButton::WriteData - error in stream" );
5764 return bRet;
5765 }
5766
5767 // ============================================================================
5768
OCX_ScrollBar()5769 OCX_ScrollBar::OCX_ScrollBar()
5770 {
5771 sName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollBar" ) );
5772 mnMax = 32767;
5773 msFormType = C2U("com.sun.star.form.component.ScrollBar");
5774 msDialogType = C2U("com.sun.star.awt.UnoControlScrollBarModel");
5775
5776 }
5777
Create()5778 OCX_Control* OCX_ScrollBar::Create()
5779 {
5780 return new OCX_ScrollBar;
5781 }
5782
Import(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> & rPropSet)5783 sal_Bool OCX_ScrollBar::Import(com::sun::star::uno::Reference<
5784 com::sun::star::beans::XPropertySet> &rPropSet)
5785 {
5786 if( (nWidth < 1) || (nHeight < 1) )
5787 return sal_False;
5788
5789 uno::Any aTmp( &sName, getCppuType((OUString *)0) );
5790 rPropSet->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp );
5791
5792 aTmp <<= ImportColor( mnForeColor );
5793 rPropSet->setPropertyValue( WW8_ASCII2STR("SymbolColor"), aTmp);
5794
5795 aTmp <<= ImportColor( mnBackColor );
5796 rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
5797
5798 aTmp = bool2any( mbEnabled && !mbLocked );
5799 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
5800
5801 aTmp <<= mnValue;
5802 if ( bSetInDialog )
5803 {
5804 rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValue"), aTmp );
5805 }
5806 else
5807 {
5808 rPropSet->setPropertyValue( WW8_ASCII2STR("DefaultScrollValue"), aTmp );
5809 }
5810
5811 aTmp <<= mnMin;
5812 rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValueMin"), aTmp );
5813
5814 aTmp <<= mnMax;
5815 rPropSet->setPropertyValue( WW8_ASCII2STR("ScrollValueMax"), aTmp );
5816
5817 aTmp <<= mnSmallStep;
5818 rPropSet->setPropertyValue( WW8_ASCII2STR("LineIncrement"), aTmp );
5819
5820 aTmp <<= mnPageStep;
5821 rPropSet->setPropertyValue( WW8_ASCII2STR("BlockIncrement"), aTmp );
5822 if( mbPropThumb && (mnPageStep > 0) )
5823 rPropSet->setPropertyValue( WW8_ASCII2STR("VisibleSize"), aTmp );
5824
5825 namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
5826 switch( mnOrient )
5827 {
5828 case 0: aTmp <<= AwtScrollOrient::VERTICAL; break;
5829 case 1: aTmp <<= AwtScrollOrient::HORIZONTAL; break;
5830 default: aTmp <<= (nWidth < nHeight) ? AwtScrollOrient::VERTICAL : AwtScrollOrient::HORIZONTAL;
5831 }
5832 rPropSet->setPropertyValue( WW8_ASCII2STR("Orientation"), aTmp );
5833
5834 aTmp <<= mnDelay;
5835 rPropSet->setPropertyValue( WW8_ASCII2STR("RepeatDelay"), aTmp );
5836
5837 aTmp <<= sal_Int16( 0 );
5838 rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
5839
5840 return sal_True;
5841 }
5842
Export(SvStorageRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)5843 sal_Bool OCX_ScrollBar::Export(
5844 SvStorageRef &rObj,
5845 const uno::Reference< beans::XPropertySet>& rPropSet,
5846 const awt::Size& rSize )
5847 {
5848 static sal_uInt8 __READONLY_DATA aCompObj[] =
5849 {
5850 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5851 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
5852 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
5853 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
5854 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5855 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5856 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
5857 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
5858 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
5859 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
5860 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
5861 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
5862 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
5863 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
5864 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5865 };
5866
5867 {
5868 SvStorageStreamRef xStor( rObj->OpenSotStream( C2S("\1CompObj")));
5869 xStor->Write(aCompObj,sizeof(aCompObj));
5870 DBG_ASSERT((xStor.Is() && (SVSTREAM_OK == xStor->GetError())),"damn");
5871 }
5872
5873 {
5874 SvStorageStreamRef xStor3( rObj->OpenSotStream( C2S("\3ObjInfo")));
5875 xStor3->Write(aObjInfo,sizeof(aObjInfo));
5876 DBG_ASSERT((xStor3.Is() && (SVSTREAM_OK == xStor3->GetError())),"damn");
5877 }
5878
5879 static sal_uInt8 __READONLY_DATA aOCXNAME[] =
5880 {
5881 0x53, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6F, 0x00,
5882 0x6C, 0x00, 0x6C, 0x00, 0x42, 0x00, 0x61, 0x00,
5883 0x72, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
5884 };
5885
5886 {
5887 SvStorageStreamRef xStor2( rObj->OpenSotStream( C2S("\3OCXNAME")));
5888 xStor2->Write(aOCXNAME,sizeof(aOCXNAME));
5889 DBG_ASSERT((xStor2.Is() && (SVSTREAM_OK == xStor2->GetError())),"damn");
5890 }
5891
5892 SvStorageStreamRef xContents( rObj->OpenSotStream( C2S("contents")));
5893 return WriteContents(xContents, rPropSet, rSize);
5894 }
5895
WriteContents(SvStorageStreamRef & rObj,const uno::Reference<beans::XPropertySet> & rPropSet,const awt::Size & rSize)5896 sal_Bool OCX_ScrollBar::WriteContents(
5897 SvStorageStreamRef &rObj,
5898 const uno::Reference< beans::XPropertySet> &rPropSet,
5899 const awt::Size& rSize )
5900 {
5901 if( !rObj.Is() )
5902 return sal_False;
5903
5904 mnBlockFlags = 0x00000008;
5905 nWidth = rSize.Width;
5906 nHeight = rSize.Height;
5907
5908 GetInt32Property( mnForeColor, rPropSet, WW8_ASCII2STR( "SymbolColor" ), 0x00000001 );
5909 GetInt32Property( mnBackColor, rPropSet, WW8_ASCII2STR( "BackgroundColor" ), 0x00000002 );
5910 GetBoolProperty( mbEnabled, rPropSet, WW8_ASCII2STR( "Enabled" ), 0x00000304 );
5911 GetInt32Property( mnMin, rPropSet, WW8_ASCII2STR( "ScrollValueMin" ), 0x00000020 );
5912 GetInt32Property( mnMax, rPropSet, WW8_ASCII2STR( "ScrollValueMax" ), 0x00000040 );
5913 GetInt32Property( mnValue, rPropSet, WW8_ASCII2STR( "ScrollValue" ), 0x00000080 );
5914 GetInt32Property( mnSmallStep, rPropSet, WW8_ASCII2STR( "LineIncrement" ), 0x00000800 );
5915 GetInt32Property( mnPageStep, rPropSet, WW8_ASCII2STR( "BlockIncrement" ), 0x00001000 );
5916 GetInt32Property( mnDelay, rPropSet, WW8_ASCII2STR( "RepeatDelay" ), 0x00008000 );
5917
5918 namespace AwtScrollOrient = ::com::sun::star::awt::ScrollBarOrientation;
5919 sal_Int16 nApiOrient = sal_Int16();
5920 if( rPropSet->getPropertyValue( WW8_ASCII2STR( "Orientation" ) ) >>= nApiOrient )
5921 UpdateInt32Property( mnOrient, (nApiOrient == AwtScrollOrient::VERTICAL) ? 0 : 1, 0x00002000 );
5922
5923 UpdateBoolProperty( mbPropThumb, true, 0x00004000 );
5924
5925 return WriteData( *rObj );
5926 }
5927
OCX_ProgressBar()5928 OCX_ProgressBar::OCX_ProgressBar() :
5929 OCX_Control( OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressBar" ) ) ),
5930 nMin( 0 ),
5931 nMax( 0 ),
5932 bFixedSingle(true),
5933 bEnabled( true ),
5934 b3d( true )
5935 {
5936 msDialogType = C2U("com.sun.star.awt.UnoControlProgressBarModel");
5937 bSetInDialog = true;
5938 }
5939
Read(SvStorageStream * pS)5940 sal_Bool OCX_ProgressBar::Read( SvStorageStream *pS )
5941 {
5942 pS->SeekRel( 8 );
5943 *pS >> nWidth >> nHeight;
5944 pS->SeekRel( 12 );
5945
5946 float fMin, fMax;
5947 *pS >> fMin >> fMax;
5948 nMin = static_cast< sal_Int32 >( fMin );
5949 nMax = static_cast< sal_Int32 >( fMax );
5950 bool bVisible = true;
5951 sal_uInt8 pUnknownFlags[4];
5952 pS->Read(pUnknownFlags,4);
5953
5954 // complete guess, but we don't handle visible anyway
5955 if ( ( pUnknownFlags[2] & 0x8 ) && ( pUnknownFlags[2] & 0x2 ) )
5956 bVisible = false;
5957
5958 sal_uInt32 nFlags;
5959 *pS >> nFlags;
5960
5961 // seems these work out
5962 bFixedSingle = (nFlags & 0x01) != 0;
5963 bEnabled = (nFlags & 0x02) != 0;
5964 b3d = (nFlags & 0x04) != 0;
5965
5966 return true;
5967 }
5968
Create()5969 OCX_Control* OCX_ProgressBar::Create()
5970 {
5971 return new OCX_ProgressBar;
5972 }
5973
Import(uno::Reference<beans::XPropertySet> & rPropSet)5974 sal_Bool OCX_ProgressBar::Import(uno::Reference< beans::XPropertySet > &rPropSet)
5975 {
5976 uno::Any aTmp(&sName,getCppuType((OUString *)0));
5977 rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
5978 aTmp <<= nMax;
5979 rPropSet->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp );
5980 aTmp <<= nMin;
5981 rPropSet->setPropertyValue( WW8_ASCII2STR("ProgressValueMin"), aTmp );
5982
5983 if ( !bEnabled )
5984 rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), uno::makeAny( sal_False ) );
5985 return sal_True;
5986 }
5987 // ============================================================================
5988
5989 /* vi:set tabstop=4 shiftwidth=4 expandtab: */
5990