1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: msocximex.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
35 #include <com/sun/star/uno/Any.h>
36 #include <com/sun/star/text/VertOrientation.hpp>
37 #include <com/sun/star/text/XText.hpp>
38 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HDL_
39 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/text/TextContentAnchorType.hpp>
42 #include <com/sun/star/drawing/XShape.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/drawing/XDrawPage.hpp>
45 #include <com/sun/star/drawing/XShapes.hpp>
46 #include <com/sun/star/drawing/XControlShape.hpp>
47 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
48 #include <com/sun/star/container/XIndexContainer.hpp>
49 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
50 #include <com/sun/star/form/XFormsSupplier.hpp>
51 #include <com/sun/star/form/XForm.hpp>
52 #include <com/sun/star/form/binding/XBindableValue.hpp>
53 #include <com/sun/star/form/binding/XValueBinding.hpp>
54 #include <com/sun/star/form/binding/XListEntrySink.hpp>
55 #include <com/sun/star/form/binding/XListEntrySource.hpp>
56 #include <com/sun/star/form/FormComponentType.hpp>
57 #include <com/sun/star/awt/FontWeight.hpp>
58 #include <com/sun/star/awt/FontSlant.hpp>
59 #include <com/sun/star/awt/FontUnderline.hpp>
60 #include <com/sun/star/awt/FontStrikeout.hpp>
61 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
62 #include <com/sun/star/style/VerticalAlignment.hpp>
63 #include <comphelper/extract.hxx>
64 #include <com/sun/star/awt/XControlModel.hpp>
65 #include <com/sun/star/io/XInputStreamProvider.hpp>
66 #include <rtl/ustrbuf.hxx>
67 #include <vcl/svapp.hxx>
68 #include <sfx2/objsh.hxx>
69 #include <xmlscript/xmldlg_imexp.hxx>
70 #include <svx/msocximex.hxx>
72 #include <osl/file.hxx>
73 #include <unotools/ucbstreamhelper.hxx>
74 //#include <sfx2/docfile.hxx>
76 #include <com/sun/star/embed/XStorage.hpp>
77 #include <com/sun/star/embed/XTransactedObject.hpp>
78 #include <com/sun/star/embed/ElementModes.hpp>
80 #include <comphelper/processfactory.hxx> // shouldn't be needed
81 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
86 #include <com/sun/star/graphic/GraphicObject.hpp>
87 #include <com/sun/star/graphic/XGraphicProvider.hpp>
88 #include <com/sun/star/graphic/XGraphic.hpp>
89 #include <com/sun/star/io/XInputStream.hpp>
90 #include <comphelper/componentcontext.hxx>
91 #include <unotools/streamwrap.hxx>
93 #include <com/sun/star/beans/NamedValue.hpp>
94 #include <com/sun/star/table/XCellRange.hpp>
95 #include <com/sun/star/table/CellRangeAddress.hpp>
96 #include <com/sun/star/table/CellAddress.hpp>
97 #include <com/sun/star/sheet/XSpreadsheetView.hpp>
98 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
99 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
100 #include <svtools/filterutils.hxx>
103 #define C2S(cChar) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(cChar))
106 #define C2U(cChar) rtl::OUString::createFromAscii(cChar)
109 using namespace ::com::sun::star
;
111 using namespace ::com::sun::star::uno
;
112 using namespace ::com::sun::star::lang
;
113 using namespace ::com::sun::star::beans
;
114 using namespace ::com::sun::star::drawing
;
115 using namespace ::com::sun::star::form
;
116 using namespace ::com::sun::star::text
;
117 using namespace ::com::sun::star::container
;
119 using namespace ::rtl
;
120 using namespace cppu
;
123 #define WW8_ASCII2STR(s) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(s))
124 #define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
127 static char sWW8_form
[] = "WW-Standard";
130 struct SortOrderByTabPos
132 bool operator()( const OCX_Control
* a
, const OCX_Control
* b
)
134 return a
->mnTabPos
< b
->mnTabPos
;
139 sal_uInt8 __READONLY_DATA
OCX_Control::aObjInfo
[4] = { 0x00, 0x12, 0x03, 0x00 };
141 long ReadAlign(SvStorageStream
*pS
, long nPos
, int nAmount
)
143 if (long nAlign
= nPos
% nAmount
)
146 long nLen
= nAmount
- nAlign
;
153 // NP - Images in controls in OO2.0/SO8 exist as links, e.g. they are not part of the document so are
154 // referenced externally. On import from ms document try to save images for controls here.
155 // Images are stored in directory called temp in the user installation directory. Next version of OO/SO
156 // hopefully will address this issue and allow a choice e.g. images for controls to be stored as links
157 // or embeded in the document.
158 uno::Reference
< graphic::XGraphicObject
> lcl_readGraphicObject( SotStorageStream
*pS
)
160 uno::Reference
< graphic::XGraphicObject
> xGrfObj
;
161 uno::Reference
< lang::XMultiServiceFactory
> xServiceManager
= ::comphelper::getProcessServiceFactory();
162 if( xServiceManager
.is() )
166 // use the GraphicProvider service to get the XGraphic
167 uno::Reference
< graphic::XGraphicProvider
> xGraphProvider(
168 xServiceManager
->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.graphic.GraphicProvider" ) ), uno::UNO_QUERY
);
169 if( xGraphProvider
.is() )
171 uno::Reference
< io::XInputStream
> xStream( new utl::OInputStreamWrapper( *pS
) );
174 uno::Sequence
< beans::PropertyValue
> aMediaProps( 1 );
175 aMediaProps
[0].Name
= ::rtl::OUString::createFromAscii( "InputStream" );
176 aMediaProps
[0].Value
<<= xStream
;
177 uno::Reference
< graphic::XGraphic
> xGraphic
= xGraphProvider
->queryGraphic( aMediaProps
);
180 // create an XGraphicObject
181 ::comphelper::ComponentContext
aContext( xServiceManager
);
182 xGrfObj
= graphic::GraphicObject::create( aContext
.getUNOContext() );
183 xGrfObj
->setGraphic(xGraphic
);
188 catch( uno::Exception
& )
196 long WriteAlign(SvStorageStream
*pS
, int nAmount
)
198 if (long nAlign
= pS
->Tell() % nAmount
)
200 long nLen
= nAmount
- nAlign
;
201 for (long i
=0; i
< nLen
; ++i
)
202 *pS
<< sal_uInt8(0x00);
207 // string import/export =======================================================
208 /** #117832# import of form control names
209 * control name is located in stream ("\3OCXNAME")
210 * a strings in "\3OCXNAME" stream seem to be terminated by 4 trailing bytes of 0's.
212 * Note: If the string in the stream is overwritten by a shorter string
213 * some characters from the original string may remain, the new string however
214 * will still be terminated in the same way e.g. by 4 bytes with value 0.
217 bool writeOCXNAME( const OUString
& sOCXName
, SvStorageStream
* pStream
)
219 const sal_Unicode
* buffer
= sOCXName
.getStr();
220 for ( sal_Int32 index
=0; index
< sOCXName
.getLength(); index
++ )
222 sal_uInt16 ch
= static_cast< sal_uInt16
>( buffer
[ index
] );
226 *pStream
<< sal_uInt32(0);
227 return ( SVSTREAM_OK
== pStream
->GetError() );
231 bool readOCXNAME( OUString
& sCName
, SvStorageStream
* pStream
)
234 * Read uniCode until no data or 0 encountered
236 OUStringBuffer
buf(40);
241 sal_Unicode uni
= static_cast< sal_Unicode
>( ch
);
246 buf
.append( &uni
, 1 );
248 } while ( !pStream
->IsEof() );
250 sCName
= buf
.makeStringAndClear();
251 return ( SVSTREAM_OK
== pStream
->GetError() );
255 /* #110435# (DR, 2003-11-12) ** Import of Unicode strings in form controls **
257 Strings may be stored either as compressed or uncompressed Unicode
258 character array. There are no encoded byte strings anywhere.
260 The string length field stores the length of the character array (not the
261 character count of the string) in the lower 31 bits, and the compression
262 state in the highest bit.
264 A set bit means the character array is compressed. This means all Unicode
265 characters are <=0xFF. Therefore the high bytes of all characters are left
266 out, and the character array size is equal to the string length.
268 A cleared bit means the character array is not compressed. The buffer
269 contains Little-Endian Unicode characters, and the resulting string length
270 is half the buffer size.
272 TODO: This implementation of the new string import is a hack to keep
273 msocximex.hxx unchanged. A better implementation would replace the char*
274 members of all classes by something more reasonable.
279 const sal_uInt32 SVX_MSOCX_SIZEMASK
= 0x7FFFFFFF; /// Mask for character buffer size.
280 const sal_uInt32 SVX_MSOCX_COMPRESSED
= 0x80000000; /// 1 = compressed Unicode array.
283 /** Returns true, if the passed length field specifies a compressed character array.
285 inline bool lclIsCompressed( sal_uInt32 nLenFld
)
287 return (nLenFld
& SVX_MSOCX_COMPRESSED
) != 0;
291 /** Extracts and returns the memory size of the character buffer.
292 @return Character buffer size (may differ from resulting string length!).
294 inline sal_uInt32
lclGetBufferSize( sal_uInt32 nLenFld
)
296 return nLenFld
& SVX_MSOCX_SIZEMASK
;
300 // import ---------------------------------------------------------------------
302 /** Reads the character array of a string in a form control.
304 Creates a new character array containing the character data.
305 The length field must be read before and passed to this function.
306 Aligns stream position to multiple of 4 before.
312 (out-param) Will point to the created character array,
313 or will be 0 if string is empty. The array is NOT null-terminated.
314 If the passed pointer points to an old existing array, it will be
315 deleted before. Caller must delete the returned array.
318 The corresponding string length field read somewhere before.
320 void lclReadCharArray( SvStorageStream
& rStrm
, char*& rpcCharArr
, sal_uInt32 nLenFld
, long nPos
)
324 sal_uInt32 nBufSize
= lclGetBufferSize( nLenFld
);
325 DBG_ASSERT( nBufSize
<= 0xFFFF, "lclReadCharArray - possible read error: char array is too big" );
326 if( nBufSize
&& nBufSize
<= 0xFFFF )
328 rpcCharArr
= new char[ nBufSize
];
331 ReadAlign( &rStrm
, nPos
, 4 );
332 rStrm
.Read( rpcCharArr
, nBufSize
);
338 /** Creates an OUString from a character array created with lclReadCharArray().
340 The passed parameters must match, that means the length field must be the
341 same used to create the passed character array.
344 The character array returned by lclReadCharArray(). May be compressed
345 or uncompressed, next parameter nLenFld will specify this.
348 MUST be the same string length field that has been passed to
349 lclReadCharArray() to create the character array in previous parameter
353 An OUString containing the decoded string data. Will be empty if
356 OUString
lclCreateOUString( const char* pcCharArr
, sal_uInt32 nLenFld
)
358 sal_uInt32 nBufSize
= lclGetBufferSize( nLenFld
);
359 if( lclIsCompressed( nLenFld
) )
360 return svt::BinFilterUtils::CreateOUStringFromStringArray( pcCharArr
, nBufSize
);
362 return svt::BinFilterUtils::CreateOUStringFromUniStringArray( pcCharArr
, nBufSize
);
365 // export ---------------------------------------------------------------------
367 /** This class implements writing a character array from a Unicode string.
370 1) Construct an instance, either directly with an OUString, or with an UNO
371 Any containing an OUString.
372 2) Check with HasData(), if there is something to write.
373 3) Write the string length field with WriteLenField() at the right place.
374 4) Write the encoded character array with WriteCharArray().
379 /** Constructs an empty string. String data may be set later by assignment. */
380 inline explicit SvxOcxString() : mnLenFld( 0 ) {}
381 /** Constructs the string from the passed OUString. */
382 inline explicit SvxOcxString( const OUString
& rStr
) { Init( rStr
); }
383 /** Constructs the string from the passed UNO Any. */
384 inline explicit SvxOcxString( const uno::Any
& rAny
) { Init( rAny
); }
386 /** Assigns the passed string to the object. */
387 inline SvxOcxString
& operator=( const OUString
& rStr
) { Init( rStr
); return *this; }
388 /** Assigns the string in the passed UNO Any to the object. */
389 inline SvxOcxString
& operator=( const uno::Any
& rAny
) { Init( rAny
); return *this; }
391 /** Returns true, if the string contains at least one character to write. */
392 inline bool HasData() const { return maString
.getLength() > 0; }
394 /** Writes the encoded 32-bit string length field. Aligns stream position to mult. of 4 before. */
395 void WriteLenField( SvStorageStream
& rStrm
) const;
396 /** Writes the encoded character array. Aligns stream position to mult. of 4 before. */
397 void WriteCharArray( SvStorageStream
& rStrm
) const;
400 inline void Init( const OUString
& rStr
) { maString
= rStr
; Init(); }
401 void Init( const uno::Any
& rAny
);
404 OUString maString
; /// The initial string data.
405 sal_uInt32 mnLenFld
; /// The encoded string length field.
408 void SvxOcxString::Init( const uno::Any
& rAny
)
410 if( !(rAny
>>= maString
) )
411 maString
= OUString();
415 void SvxOcxString::Init()
417 mnLenFld
= static_cast< sal_uInt32
>( maString
.getLength() );
419 // try to find a character >= 0x100 -> character array will be stored uncompressed then
420 if( const sal_Unicode
* pChar
= maString
.getStr() )
421 for( const sal_Unicode
* pEnd
= pChar
+ maString
.getLength(); bCompr
&& (pChar
< pEnd
); ++pChar
)
422 bCompr
= (*pChar
< 0x100);
424 mnLenFld
|= SVX_MSOCX_COMPRESSED
;
429 void SvxOcxString::WriteLenField( SvStorageStream
& rStrm
) const
433 WriteAlign( &rStrm
, 4);
438 void SvxOcxString::WriteCharArray( SvStorageStream
& rStrm
) const
442 const sal_Unicode
* pChar
= maString
.getStr();
443 const sal_Unicode
* pEnd
= pChar
+ maString
.getLength();
444 bool bCompr
= lclIsCompressed( mnLenFld
);
446 WriteAlign( &rStrm
, 4);
447 for( ; pChar
< pEnd
; ++pChar
)
449 // write compressed Unicode (not encoded bytestring), or Little-Endian Unicode
450 rStrm
<< static_cast< sal_uInt8
>( *pChar
);
452 rStrm
<< static_cast< sal_uInt8
>( *pChar
>> 8 );
457 const sal_uInt16 USERFORM
= (sal_uInt16
)0xFF;
458 const sal_uInt16 STDCONTAINER
= (sal_uInt16
)0xFE;
460 const sal_uInt16 PAGE
= (sal_uInt16
)0x07;
462 const sal_uInt16 IMAGE
= (sal_uInt16
)0x0C;
463 const sal_uInt16 FRAME
= (sal_uInt16
)0x0E;
465 const sal_uInt16 SPINBUTTON
= (sal_uInt16
)0x10;
466 const sal_uInt16 CMDBUTTON
= (sal_uInt16
)0x11;
467 const sal_uInt16 TABSTRIP
= (sal_uInt16
)0x12;
469 const sal_uInt16 LABEL
= (sal_uInt16
)0x15;
471 const sal_uInt16 TEXTBOX
= (sal_uInt16
)0x17;
472 const sal_uInt16 LISTBOX
= (sal_uInt16
)0x18;
473 const sal_uInt16 COMBOBOX
= (sal_uInt16
)0x19;
474 const sal_uInt16 CHECKBOX
= (sal_uInt16
)0x1A;
476 const sal_uInt16 OPTIONBUTTON
= (sal_uInt16
)0x1B;
477 const sal_uInt16 TOGGLEBUTTON
= (sal_uInt16
)0x1C;
479 const sal_uInt16 SCROLLBAR
= (sal_uInt16
)0x2F;
481 const sal_uInt16 MULTIPAGE
= (sal_uInt16
)0x39;
482 // The IDs with bit 0x8000 set appear to be generated.
483 // It looks like these ID's are used with the non-toolbox [1]
484 // ActiveX controls that can be present in a Userform
485 // ( note: RefEdit seems to be an exception )
486 // In UserForm::Read just before the Container record starts
487 // you will notice there can be sometimes trailing records,
488 // it seems that these records have a 1:1 relationship with the non-toolbox
489 // controls present in the Userform. An id in the trailing record
490 // seems to identify the specific ActiveX control and an artificial nTypeIdent
491 // e.g. 0x8000, 0x8001 etc. is created so as to be able to associate
492 // the ActiveX control when referenced later
493 // [1] Such ActiveX controls are added via Tools/AddionalControls
496 // create a fixed set of those special id(s)
497 // ahem, we can only read one Progress bars at the moment so....
498 const sal_uInt16 PROGRESSBAR
= (sal_uInt16
)0x8000;
500 // A set of IDs from the trailing records mentioned above that seem to
501 // identify the following ActiveX controls
502 // Currently we only can process ( in a limited way ) the ProgressBar
503 // the other ID's are for reference ( & future )
505 // RefEdit control {00024512-0000-0000-c000-000000000046}
506 const sal_uInt8 aRefEditID
[] =
508 0x12, 0x45, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
511 // Microsoft ProgressBar Control, version 6.0 {35053A22-8589-11D1-B16A-00C0F0283628}
512 const sal_uInt8 aProgressID
[] =
514 0x22, 0x3a, 0x05, 0x35, 0x89, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
517 // Calendar Control 10.0
518 const sal_uInt8 aCalendarID
[] =
520 0x2b, 0xc9, 0x27, 0x8e, 0x64, 0x12, 0x1c, 0x10, 0x8a, 0x2f, 0x04, 0x02, 0x24, 0x00, 0x9c, 0x02,
524 // Microsoft ImageComboxBox Control, version 6.0 {DD9DA666-8594-11D1-B16A-00C0F0283628}
525 const sal_uInt8 aImageComboID
[] =
527 0x66, 0xa6, 0x9d, 0xdd, 0x94, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
530 // Microsoft ImageList Control, version 6.0 {2C247F23-8591-11D1-B16A-00C0F0283628}
531 const sal_uInt8 aImageListID
[] =
533 0x23, 0x7f, 0x24, 0x2c, 0x91, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
536 // Microsoft Slider Control, version 6.0 {F08DF954-8592-11D1-B16A-00C0F0283628}
537 const sal_uInt8 aSliderID
[] =
539 0x54, 0xf9, 0x8d, 0xf0, 0x92, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
542 // Microsoft StatusBar Control, version 6.0 {8E3867A3-8586-11D1-B16A-00C0F0283628}
543 const sal_uInt8 aStatusBarID
[] =
545 0xa3, 0x67, 0x38, 0x8e, 0x86, 0x85, 0xd1, 0x11, 0xb1, 0x6a, 0x00, 0xc0, 0xf0, 0x28, 0x36, 0x28,
548 // Microsoft Office Chart 10.0
549 const sal_uInt8 aChartSpaceID
[] =
551 0x46, 0xe5, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46,
554 const sal_Int16 ActiveXIDLen
= 0x10; // CLSID len
555 const sal_Int16 ActiveXIDBlockLen
= 0x30; // the block len that contains the CLSID
557 bool lcl_handleActiveXControl( SvStorageStream
*pS
, sal_uInt16
& nTypeID
)
559 nTypeID
= 0; // Illegal ActiveX ID
561 sal_uInt16 nIdentifier
, nFixedAreaLen
;
563 *pS
>> nFixedAreaLen
;
564 pS
->SeekRel( ( nFixedAreaLen
- ActiveXIDBlockLen
) );
565 sal_uInt8 aID
[ ActiveXIDLen
];
568 pS
->Read( aID
, ActiveXIDLen
);
569 pS
->SeekRel( ActiveXIDBlockLen
- ActiveXIDLen
); // read remainer of record
570 if ( memcmp( aID
, aProgressID
, ActiveXIDLen
) == 0 )
572 nTypeID
= PROGRESSBAR
;
573 OSL_TRACE("Found supported ***PROGRESSBAR*** ActiveX control");
576 #if (OSL_DEBUG_LEVEL > 0)
577 // If we really want to process these more controls we should put them in
578 // a list or array and have a single loop testing each id. For the moment
579 // as we only can process PROGRESSBAR, not much point doing that until
580 // we add support for at least another activex control
582 else if ( memcmp( aID
, aCalendarID
, ActiveXIDLen
) == 0 )
583 OSL_TRACE("Found unsupported ***CALENDAR*** ActiveX control");
584 else if ( memcmp( aID
, aRefEditID
, ActiveXIDLen
) == 0 )
585 OSL_TRACE("Found unsupported ***REFEDIT*** ActiveX control");
586 else if ( memcmp( aID
, aImageComboID
, ActiveXIDLen
) == 0 )
587 OSL_TRACE("Found unsupported ***IMAGECOMBO*** ActiveX control");
588 else if ( memcmp( aID
, aImageListID
, ActiveXIDLen
) == 0 )
589 OSL_TRACE("Found unsupported ***IMAGELIST*** ActiveX control");
590 else if ( memcmp( aID
, aChartSpaceID
, ActiveXIDLen
) == 0 )
591 OSL_TRACE("Found unsupported ***CHARTSPACE*** ActiveX control");
592 else if ( memcmp( aID
, aSliderID
, ActiveXIDLen
) == 0 )
593 OSL_TRACE("Found unsupported ***SLIDER*** ActiveX control");
594 else if ( memcmp( aID
, aStatusBarID
, ActiveXIDLen
) == 0 )
595 OSL_TRACE("Found unsupported ***STATUSBAR*** ActiveX control");
599 OSL_TRACE("Unknown activeX ID !");
605 typedef std::vector
< ContainerRecord
> ContainerRecordList
;
607 class ContainerRecReader
611 virtual ~ContainerRecReader() {}
613 virtual bool Read( OCX_ContainerControl
* pContainerControl
, SvStorageStream
*pS
)
620 if ( !handleMultiPageHdr( pS
) )
627 if ( !handleStandardHdr( pS
) )
634 for (sal_uInt32 nRecord
= 0; nRecord
< nNoRecords
; ++nRecord
)
636 // DR #134146# redo loading of FrameChild data
641 sal_uInt16 nId
, nSize
;
643 sal_Size nStartPos
= pS
->Tell();
646 sal_uInt32 nContentFlags
;
647 *pS
>> nContentFlags
;
649 // length of control name
650 sal_uInt32 nNameLen
= 0;
651 if( nContentFlags
& 0x00000001 )
653 // length of control tag
654 sal_uInt32 nTagLen
= 0;
655 if( nContentFlags
& 0x00000002 )
657 // substorage id for frames
658 if( nContentFlags
& 0x00000004 )
659 *pS
>> rec
.nSubStorageId
;
661 if( nContentFlags
& 0x00000008 )
664 if( nContentFlags
& 0x00000010 )
666 sal_uInt32 nBitFlags
= 0;
668 rec
.bVisible
= ( ( nBitFlags
& 0x02 ) == 0x02 );
671 if( nContentFlags
& 0x00000020 )
672 *pS
>> rec
.nSubStreamLen
;
674 if( nContentFlags
& 0x00000040 )
677 if( nContentFlags
& 0x00000080 )
678 *pS
>> rec
.nTypeIdent
;
679 if( nContentFlags
& 0x00000200 )
680 pS
->SeekRel( 4 ); // Grouping?
682 sal_uInt32 nTipLen
= 0;
683 if( nContentFlags
& 0x00000800 )
685 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
689 sal_uInt32 nCntrlIdLen
= 0;
690 if( nContentFlags
& 0x00001000 )
693 // length of control source name
694 sal_uInt32 nCtrlSrcLen
= 0;
695 if( nContentFlags
& 0x00002000 )
697 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
701 // length of row source name
702 sal_uInt32 nRowSrcLen
= 0;
703 if( nContentFlags
& 0x00004000 )
705 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
711 sal_uInt32 nNameBufSize
= lclGetBufferSize( nNameLen
);
712 if( nNameBufSize
> 0 )
714 pName
= new char[ nNameBufSize
];
715 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
716 pS
->Read( pName
, nNameBufSize
);
719 sal_uInt32 nTagBufSize
= lclGetBufferSize( nTagLen
);
720 if( nTagBufSize
> 0 )
722 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
723 pS
->SeekRel( nTagBufSize
);
727 if( nContentFlags
& 0x00000100 )
729 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
730 *pS
>> rec
.nLeft
>> rec
.nTop
;
734 sal_uInt32 nTipBufSize
= lclGetBufferSize( nTipLen
);
735 if( nTipBufSize
> 0 )
737 std::auto_ptr
< sal_Char
> pTipName
;
738 pTipName
.reset( new sal_Char
[ nTipBufSize
] );
739 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
740 pS
->Read( pTipName
.get(), nTipBufSize
);
741 rec
.controlTip
= lclCreateOUString( pTipName
.get(), nTipLen
);
744 sal_uInt32 nCntrlIdSize
= lclGetBufferSize( nCntrlIdLen
);
745 if( nCntrlIdSize
> 0 )
747 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
748 pS
->SeekRel( nCntrlIdSize
);
750 // control source name
751 sal_uInt32 nCtrlSrcBufSize
= lclGetBufferSize( nCtrlSrcLen
);
752 if( nCtrlSrcBufSize
> 0 )
754 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
755 std::auto_ptr
< sal_Char
> pCtrlSrcName
;
756 pCtrlSrcName
.reset( new sal_Char
[ nCtrlSrcBufSize
] );
757 pS
->Read( pCtrlSrcName
.get(), nCtrlSrcBufSize
);
758 rec
.sCtrlSource
= lclCreateOUString( pCtrlSrcName
.get(), nCtrlSrcLen
);
759 OSL_TRACE("*** *** *** ControlSourceName -> %s ", rtl::OUStringToOString( rec
.sCtrlSource
, RTL_TEXTENCODING_UTF8
).getStr() );
762 sal_uInt32 nRowSrcBufSize
= lclGetBufferSize( nRowSrcLen
);
763 if( nRowSrcBufSize
> 0 )
765 ReadAlign( pS
, pS
->Tell() - nStartPos
, 4 );
766 std::auto_ptr
< sal_Char
> pRowSrcName
;
767 pRowSrcName
.reset( new sal_Char
[ nRowSrcBufSize
] );
768 pS
->Read( pRowSrcName
.get(), nRowSrcBufSize
);
769 rec
.sRowSource
= lclCreateOUString( pRowSrcName
.get(), nRowSrcLen
);
770 OSL_TRACE("*** *** *** RowSourceName -> %s ", rtl::OUStringToOString( rec
.sRowSource
, RTL_TEXTENCODING_UTF8
).getStr() );
773 // seek to end of data
774 pS
->Seek( nStartPos
+ nSize
);
776 rec
.cName
= lclCreateOUString(pName
, nNameLen
);
779 OCX_Control
* pControl
= NULL
;
780 if( pContainerControl
->createFromContainerRecord( rec
, pControl
) &&
783 // propagate doc shell from parent
784 pControl
->pDocSh
= pContainerControl
->pDocSh
;
785 pContainerControl
->ProcessControl( pControl
, pS
, rec
);
787 else if ( rec
.nTypeIdent
& 0x8000 )
789 // Skip ActiveX Controls we can't import
790 SotStorageStreamRef oStream
= pContainerControl
->getContainedControlsStream();
791 ULONG nStrmPos
= oStream
->Tell();
792 oStream
->Seek( nStrmPos
+ rec
.nSubStreamLen
);
796 DBG_ERROR("Terminating import, unexpected error");
804 ContainerRecReader() : isMultiPage(false){}
806 sal_uInt32 nNoRecords
;
807 sal_uInt32 nTotalLen
;
810 bool handleStandardHdr( SvStorageStream
* pS
)
812 sal_uInt8 aUnknown11
[4];
813 pS
->Read(aUnknown11
, sizeof(aUnknown11
));
814 // discovered a dialog with value of 0xFF for aUnknown11
815 // needed an extra 4 bytes to offset correctly into the control
816 // records. Valid test or coincidence ?
817 if ( aUnknown11
[1] == 0xFF )
818 pS
->Read( aUnknown11
, sizeof(aUnknown11
));
822 bool handleMultiPageHdr( SvStorageStream
* pS
)
824 sal_uInt32 nUnknown_32b
; // unknown 32 bit structure, flags ?
825 sal_uInt16 nUnknown_16b
; // unknown 16 bit structure
826 sal_uInt16 nMysteryLen
; // lenght of unknown sub record
832 pS
->SeekRel( nMysteryLen
);
835 ContainerRecordList records
;
838 class StdContainerRecReader
: public ContainerRecReader
841 StdContainerRecReader(){}
844 class MultiPageContainerRecReader
: public ContainerRecReader
847 MultiPageContainerRecReader()
850 // Strictly speaking this approach shouldn't be necessary.
851 // It should be possible to have a common routine read the
852 // container record array and by examining the flags present in
853 // the record to determine we expect to read or not.
854 // In this case for a MultPage control there is no Top or Left
855 // values in the control record array, however time contraints
856 // and associated risk prevent further investigation of this
858 // similar situation exists for the start of the container record
859 // which in the case of the MultiPage is different from
860 // UserForm & Frame ( the other containers )
862 isMultiPage
= true; // tell the base class skip
866 class ContainerRecordReaderFac
869 static ContainerRecReader
* instance( sal_uInt32 containerType
)
871 switch( containerType
)
877 return new StdContainerRecReader();
879 return new MultiPageContainerRecReader();
881 DBG_ERROR("Illegal container type for factory");
886 ContainerRecordReaderFac();
891 // ============================================================================
893 class OCX_UserFormLabel
: public OCX_Label
896 OCX_UserFormLabel(OCX_Control
* pParent
) : OCX_Label( pParent
)
898 mnForeColor
= 0x80000012L
;
899 mnBackColor
= 0x8000000FL
;
904 sal_uInt16
OCX_Control::nStandardId(0x0200);
905 sal_uInt16
OCX_FontData::nStandardId(0x0200);
907 sal_uInt32
OCX_Control::pColor
[25] = {
908 0xC0C0C0, 0x008080, 0x000080, 0x808080, 0xC0C0C0, 0xFFFFFF, 0x000000,
909 0x000000, 0x000000, 0xFFFFFF, 0xC0C0C0, 0xC0C0C0, 0x808080, 0x000080,
910 0xFFFFFF, 0xC0C0C0, 0x808080, 0x808080, 0x000000, 0xC0C0C0, 0xFFFFFF,
911 0x000000, 0xC0C0C0, 0x000000, 0xFFFFC0 };
913 void OCX_Control::FillSystemColors()
915 // overwrite the predefined colors with available system colors
916 const StyleSettings
& rSett
= Application::GetSettings().GetStyleSettings();
918 pColor
[ 0x00 ] = rSett
.GetFaceColor().GetColor();
919 pColor
[ 0x01 ] = rSett
.GetWorkspaceColor().GetColor();
920 pColor
[ 0x02 ] = rSett
.GetActiveColor().GetColor();
921 pColor
[ 0x03 ] = rSett
.GetDeactiveColor().GetColor();
922 pColor
[ 0x04 ] = rSett
.GetMenuBarColor().GetColor();
923 pColor
[ 0x05 ] = rSett
.GetWindowColor().GetColor();
924 pColor
[ 0x07 ] = rSett
.GetMenuTextColor().GetColor();
925 pColor
[ 0x08 ] = rSett
.GetWindowTextColor().GetColor();
926 pColor
[ 0x09 ] = rSett
.GetActiveTextColor().GetColor();
927 pColor
[ 0x0A ] = rSett
.GetActiveBorderColor().GetColor();
928 pColor
[ 0x0B ] = rSett
.GetDeactiveBorderColor().GetColor();
929 pColor
[ 0x0C ] = rSett
.GetWorkspaceColor().GetColor();
930 pColor
[ 0x0D ] = rSett
.GetHighlightColor().GetColor();
931 pColor
[ 0x0E ] = rSett
.GetHighlightTextColor().GetColor();
932 pColor
[ 0x0F ] = rSett
.GetFaceColor().GetColor();
933 pColor
[ 0x10 ] = rSett
.GetShadowColor().GetColor();
934 pColor
[ 0x12 ] = rSett
.GetButtonTextColor().GetColor();
935 pColor
[ 0x13 ] = rSett
.GetDeactiveTextColor().GetColor();
936 pColor
[ 0x14 ] = rSett
.GetHighlightColor().GetColor();
937 pColor
[ 0x15 ] = rSett
.GetDarkShadowColor().GetColor();
938 pColor
[ 0x16 ] = rSett
.GetShadowColor().GetColor();
939 pColor
[ 0x17 ] = rSett
.GetHelpTextColor().GetColor();
940 pColor
[ 0x18 ] = rSett
.GetHelpColor().GetColor();
943 sal_uInt32
OCX_Control::ImportColor(sal_uInt32 nColor
) const
945 sal_uInt8 nUpper
= (sal_uInt8
)( nColor
>> 24 );
946 if (nUpper
& 0x80) //Palette color, should be switch on bottom 24 bits
948 /*Might as well use my systems ones in the absence of any other ideas*/
949 nColor
= nColor
&0x00FFFFFF;
950 DBG_ASSERT (nColor
<= 24,"Unknown Palette Index");
954 nColor
= pColor
[nColor
];
958 //Stored in bgr! rather than rgb
959 nColor
= SwapColor(nColor
);
964 sal_Int16
OCX_FontData::ImportAlign(sal_uInt8 _nJustification
) const
967 switch (_nJustification
)
983 sal_uInt8
OCX_FontData::ExportAlign(sal_Int16 nAlign
) const
1002 sal_uInt32
OCX_Control::SwapColor(sal_uInt32 nColor
) const
1005 r(static_cast<sal_uInt8
>(nColor
&0xFF)),
1006 g(static_cast<sal_uInt8
>(((nColor
)>>8)&0xFF)),
1007 b(static_cast<sal_uInt8
>((nColor
>>16)&0xFF));
1008 nColor
= (r
<<16) + (g
<<8) + b
;
1012 sal_uInt32
OCX_Control::ExportColor(sal_uInt32 nColor
) const
1014 sal_uInt8 nUpper
= (sal_uInt8
)( nColor
>> 24 );
1015 if (nUpper
& 0x80) //Palette color, should be switch on bottom 24 bits
1017 /*Might as well use my systems ones in the absence of any other ideas*/
1018 nColor
= nColor
&0x00FFFFFF;
1019 DBG_ASSERT (nColor
<= 24,"Unknown Palette Index");
1023 nColor
= pColor
[nColor
];
1026 //Stored in bgr! rather than rgb
1027 nColor
= SwapColor(nColor
);
1031 sal_Bool
OCX_Control::Import(
1032 const uno::Reference
< lang::XMultiServiceFactory
> &rServiceFactory
,
1033 uno::Reference
< form::XFormComponent
> &rFComp
, awt::Size
&rSz
)
1036 if(msFormType
.getLength() == 0)
1040 rSz
.Height
= nHeight
;
1042 uno::Reference
<uno::XInterface
> xCreate
=
1043 rServiceFactory
->createInstance(msFormType
);
1047 rFComp
= uno::Reference
<form::XFormComponent
>(xCreate
,uno::UNO_QUERY
);
1050 uno::Reference
<beans::XPropertySet
> xPropSet(xCreate
,uno::UNO_QUERY
);
1053 return Import(xPropSet
);
1056 sal_Bool
OCX_Control::Import(uno::Reference
<container::XNameContainer
> &rDialog
1059 uno::Reference
<beans::XPropertySet
> xDlgProps( rDialog
, uno::UNO_QUERY
);
1062 uno::Reference
<lang::XMultiServiceFactory
>
1063 xFactory(rDialog
, uno::UNO_QUERY
);
1065 uno::Reference
<uno::XInterface
> xCreate
=
1066 xFactory
->createInstance(msDialogType
);
1070 uno::Reference
<awt::XControlModel
> xModel(xCreate
, uno::UNO_QUERY
);
1074 sal_Bool bVBA
= sal_False
;
1075 /* #147900# sometimes insertion of a control fails due to existing name,
1076 do not break entire form import then... */
1079 rDialog
->insertByName(sName
, uno::makeAny(xModel
));
1080 if ( xDlgProps
.is() )
1081 xDlgProps
->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("VBAForm") ) ) >>= bVBA
;
1084 catch( uno::Exception
& )
1087 ByteString( "OCX_Control::Import - cannot insert control \"" ).
1088 Append( ByteString( sName
, RTL_TEXTENCODING_UTF8
) ).
1089 Append( '"' ).GetBuffer() );
1092 uno::Reference
<beans::XPropertySet
> xPropSet(xCreate
, uno::UNO_QUERY
);
1096 if (!Import(xPropSet
))
1100 sal_Int32 nFactor
= 3528;
1104 aTmp
<<= sal_Int32((mnLeft
* 2) / 100);
1105 xPropSet
->setPropertyValue(WW8_ASCII2STR("PositionX"), aTmp
);
1106 aTmp
<<= sal_Int32((mnTop
* 2) / 100);
1107 xPropSet
->setPropertyValue(WW8_ASCII2STR("PositionY"), aTmp
);
1108 aTmp
<<= sal_Int32((nWidth
* 2) / 100);
1109 xPropSet
->setPropertyValue(WW8_ASCII2STR("Width"), aTmp
);
1110 aTmp
<<= sal_Int32((nHeight
* 2) / 100);
1111 xPropSet
->setPropertyValue(WW8_ASCII2STR("Height"), aTmp
);
1115 aTmp
<<= sal_Int32(mnLeft
); // 100thmm
1116 xPropSet
->setPropertyValue(WW8_ASCII2STR("PositionX"), aTmp
);
1117 aTmp
<<= sal_Int32(mnTop
); //100th mm
1118 xPropSet
->setPropertyValue(WW8_ASCII2STR("PositionY"), aTmp
);
1119 aTmp
<<= sal_Int32(nWidth
); // 100thmm
1120 xPropSet
->setPropertyValue(WW8_ASCII2STR("Width"), aTmp
);
1121 aTmp
<<= sal_Int32(nHeight
); //100th mm
1122 xPropSet
->setPropertyValue(WW8_ASCII2STR("Height"), aTmp
);
1124 if ( msToolTip
.Len() > 0 )
1125 xPropSet
->setPropertyValue(WW8_ASCII2STR("HelpText"), uno::Any(OUString(msToolTip
)));
1130 xPropSet
->setPropertyValue(WW8_ASCII2STR("Step"), aTmp
);
1135 xPropSet
->setPropertyValue(WW8_ASCII2STR("EnableVisible"), uno::makeAny( mbVisible
) );
1137 catch( uno::Exception
& )
1143 sal_Int16
OCX_Control::ImportBorder(sal_uInt16 nSpecialEffect
,
1144 sal_uInt16 nBorderStyle
) const
1146 if ((nSpecialEffect
== 0) && (nBorderStyle
== 0))
1147 return 0; //No Border
1148 else if ((nSpecialEffect
== 0) && (nBorderStyle
== 1))
1149 return 2; //Flat Border
1150 return 1; //3D Border
1153 sal_uInt8
OCX_Control::ExportBorder(sal_uInt16 nBorder
,sal_uInt8
&rBorderStyle
)
1160 nRet
= rBorderStyle
= 0;
1175 sal_Int16
OCX_Control::ImportSpecEffect( sal_uInt8 nSpecialEffect
) const
1177 return (nSpecialEffect
== 0) ? 2 : 1;
1180 sal_uInt8
OCX_Control::ExportSpecEffect( sal_Int16 nApiEffect
) const
1182 return (nApiEffect
== 2) ? 0 : 2;
1185 sal_Bool
OCX_Control::ReadFontData(SvStorageStream
*pS
)
1187 return aFontData
.Read(pS
);
1191 const uno::Reference
< drawing::XDrawPage
>&
1192 SvxMSConvertOCXControls::GetDrawPage()
1194 if( !xDrawPage
.is() && pDocSh
)
1196 uno::Reference
< drawing::XDrawPageSupplier
> xTxtDoc(pDocSh
->GetModel(),
1198 DBG_ASSERT(xTxtDoc
.is(),"XDrawPageSupplier nicht vom XModel erhalten");
1199 xDrawPage
= xTxtDoc
->getDrawPage();
1200 DBG_ASSERT( xDrawPage
.is(), "XDrawPage nicht erhalten" );
1207 const uno::Reference
< lang::XMultiServiceFactory
>&
1208 SvxMSConvertOCXControls::GetServiceFactory()
1210 if( !xServiceFactory
.is() && pDocSh
)
1212 xServiceFactory
= uno::Reference
< lang::XMultiServiceFactory
>
1213 (pDocSh
->GetBaseModel(), uno::UNO_QUERY
);
1214 DBG_ASSERT( xServiceFactory
.is(),
1215 "XMultiServiceFactory nicht vom Model erhalten" );
1218 return xServiceFactory
;
1221 const uno::Reference
< drawing::XShapes
>& SvxMSConvertOCXControls::GetShapes()
1226 if( xDrawPage
.is() )
1229 xShapes
= uno::Reference
< drawing::XShapes
>(xDrawPage
,
1231 DBG_ASSERT( xShapes
.is(), "XShapes nicht vom XDrawPage erhalten" );
1237 const uno::Reference
< container::XIndexContainer
>&
1238 SvxMSConvertOCXControls::GetFormComps()
1240 if( !xFormComps
.is() )
1243 if( xDrawPage
.is() )
1245 uno::Reference
< form::XFormsSupplier
> xFormsSupplier( xDrawPage
,
1247 DBG_ASSERT( xFormsSupplier
.is(),
1248 "XFormsSupplier nicht vom XDrawPage erhalten" );
1250 uno::Reference
< container::XNameContainer
> xNameCont
=
1251 xFormsSupplier
->getForms();
1253 // Das Formular bekommt einen Namen wie "WW-Standard[n]" und
1254 // wird in jedem Fall neu angelegt.
1255 UniString
sName( sWW8_form
, RTL_TEXTENCODING_MS_1252
);
1258 while( xNameCont
->hasByName( sName
) )
1260 sName
.AssignAscii( sWW8_form
);
1261 sName
+= String::CreateFromInt32( ++n
);
1264 const uno::Reference
< lang::XMultiServiceFactory
> &rServiceFactory
1265 = GetServiceFactory();
1266 if( !rServiceFactory
.is() )
1269 uno::Reference
< uno::XInterface
> xCreate
=
1270 rServiceFactory
->createInstance(WW8_ASCII2STR(
1271 "com.sun.star.form.component.Form"));
1274 uno::Reference
< beans::XPropertySet
> xFormPropSet( xCreate
,
1277 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
1278 xFormPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
1280 uno::Reference
< form::XForm
> xForm( xCreate
, uno::UNO_QUERY
);
1281 DBG_ASSERT(xForm
.is(), "keine Form?");
1283 uno::Reference
< container::XIndexContainer
> xForms( xNameCont
,
1285 DBG_ASSERT( xForms
.is(), "XForms nicht erhalten" );
1287 aTmp
.setValue( &xForm
,
1288 ::getCppuType((uno::Reference
< form::XForm
>*)0));
1289 xForms
->insertByIndex( xForms
->getCount(), aTmp
);
1291 xFormComps
= uno::Reference
< container::XIndexContainer
>
1292 (xCreate
, uno::UNO_QUERY
);
1300 sal_Bool
OCX_CommandButton::Import( com::sun::star::uno::Reference
<
1301 com::sun::star::beans::XPropertySet
> &rPropSet
)
1303 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
1304 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
1306 aTmp
<<= ImportColor(mnForeColor
);
1307 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
1309 // fake transparent push button by setting window background color
1311 mnBackColor
= 0x80000005;
1312 aTmp
<<= ImportColor(mnBackColor
);
1313 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
1316 if ((!(fEnabled
)) || (fLocked
))
1320 aTmp
= bool2any(bTemp
);
1322 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
1324 bTemp
= fWordWrap
!= 0;
1325 aTmp
= bool2any(bTemp
);
1326 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp
);
1330 aTmp
<<= lclCreateOUString( pCaption
, nCaptionLen
);
1331 rPropSet
->setPropertyValue( WW8_ASCII2STR("Label"), aTmp
);
1334 aTmp
= bool2any( mbTakeFocus
);
1335 rPropSet
->setPropertyValue( WW8_ASCII2STR( "FocusOnClick" ), aTmp
);
1337 aFontData
.Import(rPropSet
);
1339 if ( sImageUrl
.getLength() )
1342 rPropSet
->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp
);
1347 sal_Bool
OCX_GroupBox::Export(SvStorageRef
& /* rObj */,
1348 const uno::Reference
< beans::XPropertySet
>& /* rPropSet */,
1349 const awt::Size
& /* rSize */ )
1351 sal_Bool bRet
=sal_True
;
1355 sal_Bool
OCX_GroupBox::WriteContents(SvStorageStreamRef
& /* rObj */,
1356 const uno::Reference
< beans::XPropertySet
>& /* rPropSet */,
1357 const awt::Size
& /* rSize */)
1359 sal_Bool bRet
=sal_True
;
1363 sal_Bool
OCX_CommandButton::WriteContents(SvStorageStreamRef
& rContents
,
1364 const uno::Reference
< beans::XPropertySet
>& rPropSet
,
1365 const awt::Size
& rSize
)
1367 sal_Bool bRet
=sal_True
;
1369 sal_uInt32 nOldPos
= rContents
->Tell();
1370 rContents
->SeekRel(8);
1372 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
1373 if (aTmp
.hasValue())
1374 aTmp
>>= mnForeColor
;
1375 *rContents
<< ExportColor(mnForeColor
);
1377 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1378 if (aTmp
.hasValue())
1379 aTmp
>>= mnBackColor
;
1380 *rContents
<< ExportColor(mnBackColor
);
1382 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
1383 fEnabled
= any2bool(aTmp
);
1384 sal_uInt8 nTemp
=0;//fEnabled;
1389 *rContents
<< nTemp
;
1390 *rContents
<< sal_uInt8(0x00);
1393 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("MultiLine"));
1394 fWordWrap
= any2bool(aTmp
);
1397 *rContents
<< nTemp
;
1398 *rContents
<< sal_uInt8(0x00);
1400 SvxOcxString
aCaption( rPropSet
->getPropertyValue(WW8_ASCII2STR("Label")) );
1401 aCaption
.WriteLenField( *rContents
);
1402 aCaption
.WriteCharArray( *rContents
);
1404 WriteAlign(rContents
,4);
1406 *rContents
<< rSize
.Width
;
1407 *rContents
<< rSize
.Height
;
1409 // "take focus on click" is directly in content flags, not in option field...
1410 mbTakeFocus
= any2bool( rPropSet
->getPropertyValue( WW8_ASCII2STR( "FocusOnClick" ) ) );
1412 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
1414 bRet
= aFontData
.Export(rContents
,rPropSet
);
1416 rContents
->Seek(nOldPos
);
1417 *rContents
<< nStandardId
;
1418 *rContents
<< nFixedAreaLen
;
1420 sal_uInt8 nTmp
= 0x27;
1421 if (aCaption
.HasData())
1425 if( !mbTakeFocus
) // flag is set, if option is off
1428 *rContents
<< sal_uInt8(0x00);
1429 *rContents
<< sal_uInt8(0x00);
1431 DBG_ASSERT((rContents
.Is() && (SVSTREAM_OK
==rContents
->GetError())),"damn");
1437 sal_Bool
OCX_CommandButton::Export(SvStorageRef
&rObj
,
1438 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
1439 const awt::Size
&rSize
)
1441 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
1442 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1443 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1444 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1445 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1446 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1447 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1448 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1449 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1450 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1451 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1452 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1453 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1454 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1455 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1456 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1457 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1461 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
1462 xStor
->Write(aCompObj
,sizeof(aCompObj
));
1463 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
1467 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
1468 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
1469 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
1472 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
1473 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x6D, 0x00,
1474 0x61, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x42, 0x00,
1475 0x75, 0x00, 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00,
1476 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1480 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
1481 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
1482 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
1485 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
1487 return WriteContents(xContents
,rPropSet
,rSize
);
1490 sal_Bool
OCX_ImageButton::WriteContents(SvStorageStreamRef
&rContents
,
1491 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
1492 const awt::Size
&rSize
)
1494 sal_Bool bRet
=sal_True
;
1496 sal_uInt32 nOldPos
= rContents
->Tell();
1497 rContents
->SeekRel(8);
1499 uno::Any aTmp
=rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1500 if (aTmp
.hasValue())
1501 aTmp
>>= mnBackColor
;
1502 *rContents
<< ExportColor(mnBackColor
);
1504 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
1505 fEnabled
= any2bool(aTmp
);
1506 sal_uInt8 nTemp
=0;//fEnabled;
1509 *rContents
<< nTemp
;
1510 *rContents
<< sal_uInt8(0x00);
1511 *rContents
<< sal_uInt8(0x00);
1512 *rContents
<< sal_uInt8(0x00);
1514 WriteAlign(rContents
,4);
1516 *rContents
<< rSize
.Width
;
1517 *rContents
<< rSize
.Height
;
1519 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
1521 bRet
= aFontData
.Export(rContents
,rPropSet
);
1523 rContents
->Seek(nOldPos
);
1524 *rContents
<< nStandardId
;
1525 *rContents
<< nFixedAreaLen
;
1527 sal_uInt8 nTmp
= 0x26;
1529 *rContents
<< sal_uInt8(0x00);
1530 *rContents
<< sal_uInt8(0x00);
1531 *rContents
<< sal_uInt8(0x00);
1533 DBG_ASSERT((rContents
.Is() && (SVSTREAM_OK
==rContents
->GetError())),"damn");
1539 sal_Bool
OCX_ImageButton::Export(SvStorageRef
&rObj
,
1540 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
1541 const awt::Size
&rSize
)
1543 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
1544 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1545 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1546 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1547 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1548 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1549 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1550 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1551 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1552 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1553 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1554 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1555 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1556 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1557 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1558 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1559 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1563 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
1564 xStor
->Write(aCompObj
,sizeof(aCompObj
));
1565 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
1569 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
1570 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
1571 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
1574 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
1575 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x6D, 0x00,
1576 0x61, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x42, 0x00,
1577 0x75, 0x00, 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00,
1578 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1582 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
1583 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
1584 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
1587 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
1588 return WriteContents(xContents
,rPropSet
,rSize
);
1591 bool lcl_isNamedRange( const rtl::OUString
& sAddress
, uno::Reference
< frame::XModel
>& xModel
, table::CellRangeAddress
& aAddress
)
1594 const static rtl::OUString
sNamedRanges( RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
1595 uno::Reference
< sheet::XCellRangeReferrer
> xReferrer
;
1598 uno::Reference
< beans::XPropertySet
> xPropSet( xModel
, uno::UNO_QUERY_THROW
);
1599 uno::Reference
< container::XNameAccess
> xNamed( xPropSet
->getPropertyValue( sNamedRanges
), uno::UNO_QUERY_THROW
);
1600 xReferrer
.set ( xNamed
->getByName( sAddress
), uno::UNO_QUERY
);
1602 catch( uno::Exception
& /*e*/ )
1606 if ( xReferrer
.is() )
1608 uno::Reference
< sheet::XCellRangeAddressable
> xRangeAddressable( xReferrer
->getReferredCells(), uno::UNO_QUERY
);
1609 if ( xRangeAddressable
.is() )
1611 aAddress
= xRangeAddressable
->getRangeAddress();
1618 void lcl_ApplyListSourceAndBindableStuff( uno::Reference
< frame::XModel
>& xModel
, const uno::Reference
< beans::XPropertySet
>& rPropSet
, const rtl::OUString
& rsCtrlSource
, const rtl::OUString
& rsRowSource
)
1621 uno::Reference
< lang::XMultiServiceFactory
> xFac
;
1623 xFac
.set( xModel
, uno::UNO_QUERY
);
1624 uno::Reference
< form::binding::XBindableValue
> xBindable( rPropSet
, uno::UNO_QUERY
);
1625 if ( xFac
.is() && rsCtrlSource
.getLength() && xBindable
.is() )
1628 // OOo address structures
1629 // RefCell - convert from XL
1630 // pretend we converted the imported string address into the
1631 // appropriate address structure
1632 uno::Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( C2U( "com.sun.star.table.CellAddressConversion" )), uno::UNO_QUERY
);
1633 table::CellAddress aAddress
;
1634 if ( xConvertor
.is() )
1636 // we need this service to properly convert XL notation also
1637 // Should be easy to extend
1638 xConvertor
->setPropertyValue( C2U( "XL_A1_Representation" ), uno::makeAny( rsCtrlSource
) );
1639 xConvertor
->getPropertyValue( C2U( "Address" ) ) >>= aAddress
;
1642 beans::NamedValue aArg1
;
1643 aArg1
.Name
= C2U("BoundCell");
1644 aArg1
.Value
<<= aAddress
;
1646 uno::Sequence
< uno::Any
> aArgs(1);
1647 aArgs
[ 0 ] <<= aArg1
;
1649 uno::Reference
< form::binding::XValueBinding
> xBinding( xFac
->createInstanceWithArguments( C2U("com.sun.star.table.CellValueBinding" ), aArgs
), uno::UNO_QUERY
);
1650 xBindable
->setValueBinding( xBinding
);
1652 uno::Reference
< form::binding::XListEntrySink
> xListEntrySink( rPropSet
, uno::UNO_QUERY
);
1653 if ( xFac
.is() && rsRowSource
.getLength() && xListEntrySink
.is() )
1656 // OOo address structures
1657 // RefCell - convert from XL
1658 // pretend we converted the imported string address into the
1659 // appropriate address structure
1660 uno::Reference
< beans::XPropertySet
> xConvertor( xFac
->createInstance( C2U( "com.sun.star.table.CellRangeAddressConversion" )), uno::UNO_QUERY
);
1661 table::CellRangeAddress aAddress
;
1662 if ( xConvertor
.is() )
1664 if ( !lcl_isNamedRange( rsRowSource
, xModel
, aAddress
) )
1666 // we need this service to properly convert XL notation also
1667 // Should be easy to extend
1668 xConvertor
->setPropertyValue( C2U( "XL_A1_Representation" ), uno::makeAny( rsRowSource
) );
1669 xConvertor
->getPropertyValue( C2U( "Address" ) ) >>= aAddress
;
1673 beans::NamedValue aArg1
;
1674 aArg1
.Name
= C2U("CellRange");
1675 aArg1
.Value
<<= aAddress
;
1677 uno::Sequence
< uno::Any
> aArgs(1);
1678 aArgs
[ 0 ] <<= aArg1
;
1680 uno::Reference
< form::binding::XListEntrySource
> xSource( xFac
->createInstanceWithArguments( C2U("com.sun.star.table.CellRangeListSource" ), aArgs
), uno::UNO_QUERY
);
1681 xListEntrySink
->setListEntrySource( xSource
);
1685 sal_Bool
OCX_OptionButton::Import(com::sun::star::uno::Reference
<
1686 com::sun::star::beans::XPropertySet
> &rPropSet
)
1688 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
1689 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
1691 // background color: fBackStyle==0 -> transparent
1693 aTmp
<<= ImportColor(mnBackColor
);
1696 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
1699 if ((!(fEnabled
)) || (fLocked
))
1703 aTmp
= bool2any(bTemp
);
1704 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
1706 bTemp
= fWordWrap
!= 0;
1707 aTmp
= bool2any(bTemp
);
1708 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp
);
1710 aTmp
<<= ImportColor(mnForeColor
);
1711 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
1713 aTmp
<<= ImportSpecEffect( nSpecialEffect
);
1714 rPropSet
->setPropertyValue( WW8_ASCII2STR("VisualEffect"), aTmp
);
1718 INT16 nTmp
= pValue
[0]-0x30;
1721 rPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp
);
1724 // dialog ( but we might be using the form model )
1725 if ( rPropSet
->getPropertySetInfo()->hasPropertyByName( WW8_ASCII2STR("DefaultState") ) )
1726 rPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp
);
1728 rPropSet
->setPropertyValue( WW8_ASCII2STR("State"), aTmp
);
1731 // If this is a dialog control then we need to set a groupname *always*
1732 rtl::OUString sGroupName
= lclCreateOUString( pGroupName
, nGroupNameLen
);
1733 if ( GetInDialog() ) // Userform/Dialog
1735 // By default groupnames are not set in Excel, it's not unusual to have
1736 // a number of groups of radiobuttons located inside frame ( or other container
1737 // controls ) where there is *no* specific groupname set for the radiobuttons.
1738 // But... there is implicit grouping for radio buttons in seperate containers
1739 // e.g. radio buttons in a frame are by default in the same group.
1740 // Unfortunately in openoffice there are no containers below the dialog itself :-(
1741 // To ensure correct grouping for imported radiobuttons either with no groupname
1742 // or identical groupnames that are in separate containers we *must* ensure
1743 // that a suitable groupname is applied.
1744 // Because controlNames are unique even across different containers we can use the
1745 // controls container (e.g. parent) name as a prefix for a group name
1746 rtl::OUString sParentName
= msParentName
;
1747 sGroupName
= sParentName
.concat( C2U( ":" ) ).concat( sGroupName
);
1749 if ( sGroupName
.getLength() == 0 )
1750 sGroupName
= rtl::OUString::createFromAscii("DefaultGroup");
1751 OSL_TRACE("RadioButton %s has groupname %s",
1752 rtl::OUStringToOString( sName
, RTL_TEXTENCODING_UTF8
).getStr(), rtl::OUStringToOString( sGroupName
, RTL_TEXTENCODING_UTF8
).getStr() );
1755 aTmp
<<= sGroupName
;
1756 rPropSet
->setPropertyValue( WW8_ASCII2STR("GroupName"), aTmp
);
1758 catch( uno::Exception
& )
1764 aTmp
<<= lclCreateOUString( pCaption
, nCaptionLen
);
1765 rPropSet
->setPropertyValue( WW8_ASCII2STR("Label"), aTmp
);
1768 // #i40279# always centered vertically
1769 aTmp
<<= ::com::sun::star::style::VerticalAlignment_MIDDLE
;
1770 rPropSet
->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp
);
1772 uno::Reference
< frame::XModel
> xModel ( pDocSh
? pDocSh
->GetModel() : NULL
);
1773 lcl_ApplyListSourceAndBindableStuff( xModel
, rPropSet
, msCtrlSource
, msRowSource
);
1774 if ( sImageUrl
.getLength() )
1777 rPropSet
->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp
);
1780 aFontData
.Import(rPropSet
);
1784 sal_Bool
OCX_OptionButton::WriteContents(SvStorageStreamRef
&rContents
,
1785 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
1786 const awt::Size
&rSize
)
1788 sal_Bool bRet
=sal_True
;
1790 sal_uInt32 nOldPos
= rContents
->Tell();
1791 rContents
->SeekRel(12);
1794 pBlockFlags
[1] = 0x01;
1796 pBlockFlags
[3] = 0x80;
1802 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
1803 fEnabled
= any2bool(aTmp
);
1805 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
1806 if (aTmp
.hasValue())
1807 aTmp
>>= mnBackColor
;
1811 sal_uInt8 nTemp
=0;//=fEnabled;
1816 *rContents
<< nTemp
;
1817 pBlockFlags
[0] |= 0x01;
1818 *rContents
<< sal_uInt8(0x00);
1820 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("MultiLine"));
1821 fWordWrap
= any2bool(aTmp
);
1824 *rContents
<< nTemp
;
1825 *rContents
<< sal_uInt8(0x00);
1827 *rContents
<< ExportColor(mnBackColor
);
1828 pBlockFlags
[0] |= 0x02;
1830 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
1831 if (aTmp
.hasValue())
1832 aTmp
>>= mnForeColor
;
1833 *rContents
<< ExportColor(mnForeColor
);
1834 pBlockFlags
[0] |= 0x04;
1837 *rContents
<< nStyle
;
1838 pBlockFlags
[0] |= 0x40;
1840 WriteAlign(rContents
,4);
1841 nValueLen
= 1|SVX_MSOCX_COMPRESSED
;
1842 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("DefaultState"));
1843 sal_Int16 nDefault
= sal_Int16();
1845 *rContents
<< nValueLen
;
1846 pBlockFlags
[2] |= 0x40;
1849 SvxOcxString
aCaption( rPropSet
->getPropertyValue(WW8_ASCII2STR("Label")) );
1850 if (aCaption
.HasData())
1851 pBlockFlags
[2] |= 0x80;
1852 aCaption
.WriteLenField( *rContents
);
1854 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("VisualEffect"));
1855 if (aTmp
.hasValue())
1857 sal_Int16 nApiSpecEffect
= sal_Int16();
1858 aTmp
>>= nApiSpecEffect
;
1859 nSpecialEffect
= ExportSpecEffect( nApiSpecEffect
);
1861 *rContents
<< nSpecialEffect
;
1862 pBlockFlags
[3] |= 0x04;
1864 WriteAlign(rContents
,4);
1865 *rContents
<< rSize
.Width
;
1866 *rContents
<< rSize
.Height
;
1869 *rContents
<< sal_uInt8(nDefault
);
1870 *rContents
<< sal_uInt8(0x00);
1872 aCaption
.WriteCharArray( *rContents
);
1874 WriteAlign(rContents
,4);
1875 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
1876 bRet
= aFontData
.Export(rContents
,rPropSet
);
1878 rContents
->Seek(nOldPos
);
1879 *rContents
<< nStandardId
;
1880 *rContents
<< nFixedAreaLen
;
1882 *rContents
<< pBlockFlags
[0];
1883 *rContents
<< pBlockFlags
[1];
1884 *rContents
<< pBlockFlags
[2];
1885 *rContents
<< pBlockFlags
[3];
1886 *rContents
<< pBlockFlags
[4];
1887 *rContents
<< pBlockFlags
[5];
1888 *rContents
<< pBlockFlags
[6];
1889 *rContents
<< pBlockFlags
[7];
1891 DBG_ASSERT((rContents
.Is() &&
1892 (SVSTREAM_OK
==rContents
->GetError())),"damn");
1898 sal_Bool
OCX_OptionButton::Export(SvStorageRef
&rObj
,
1899 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
1900 const awt::Size
&rSize
)
1902 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
1903 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1904 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1905 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1906 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1907 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1908 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1909 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1910 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1911 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1912 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1913 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1914 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1915 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1916 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1917 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1918 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1922 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
1923 xStor
->Write(aCompObj
,sizeof(aCompObj
));
1924 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
1928 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
1929 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
1930 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
1933 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
1934 0x4F, 0x00, 0x70, 0x00, 0x74, 0x00, 0x69, 0x00,
1935 0x6F, 0x00, 0x6E, 0x00, 0x42, 0x00, 0x75, 0x00,
1936 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x6E, 0x00,
1937 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
1941 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
1942 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
1943 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
1946 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
1947 return WriteContents(xContents
, rPropSet
, rSize
);
1951 sal_Bool
OCX_TextBox::Import(com::sun::star::uno::Reference
<
1952 com::sun::star::beans::XPropertySet
> &rPropSet
)
1954 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
1955 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
1957 aTmp
= bool2any( fEnabled
!= 0 );
1958 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
1960 aTmp
= bool2any( fLocked
!= 0 );
1961 rPropSet
->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp
);
1963 aTmp
= bool2any( fHideSelection
!= 0 );
1964 rPropSet
->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp
);
1966 aTmp
<<= ImportColor(mnForeColor
);
1967 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
1969 aTmp
<<= ImportColor(mnBackColor
);
1970 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
1972 aTmp
<<= ImportBorder(nSpecialEffect
,nBorderStyle
);
1973 rPropSet
->setPropertyValue( WW8_ASCII2STR("Border"), aTmp
);
1975 aTmp
<<= ImportColor( nBorderColor
);
1976 rPropSet
->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp
);
1978 aTmp
= bool2any( fMultiLine
!= 0 );
1979 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp
);
1981 sal_uInt16 nTmp
= static_cast<sal_uInt16
>(nMaxLength
);
1983 rPropSet
->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp
);
1986 sal_Bool bTemp1
,bTemp2
;
1987 uno::Any aBarsH
,aBarsV
;
2009 aBarsH
= bool2any(bTemp1
);
2010 aBarsV
= bool2any(bTemp2
);
2011 rPropSet
->setPropertyValue( WW8_ASCII2STR("HScroll"), aBarsH
);
2012 rPropSet
->setPropertyValue( WW8_ASCII2STR("VScroll"), aBarsV
);
2014 nTmp
= nPasswordChar
;
2016 rPropSet
->setPropertyValue( WW8_ASCII2STR("EchoChar"), aTmp
);
2020 aTmp
<<= lclCreateOUString( pValue
, nValueLen
);
2021 // DefaultText seems to no longer be in UnoEditControlModel
2024 rPropSet
->setPropertyValue( WW8_ASCII2STR("Text"), aTmp
);
2028 rPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp
);
2032 aFontData
.Import(rPropSet
);
2036 sal_Bool
OCX_TextBox::WriteContents(SvStorageStreamRef
&rContents
,
2037 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2038 const awt::Size
&rSize
)
2040 sal_Bool bRet
=sal_True
;
2041 sal_uInt32 nOldPos
= rContents
->Tell();
2042 rContents
->SeekRel(12);
2045 pBlockFlags
[1] = 0x01;
2046 pBlockFlags
[2] = 0x00;
2047 pBlockFlags
[3] = 0x80;
2054 sal_uInt8 nTemp
=0x19;
2055 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
2056 fEnabled
= any2bool(aTmp
);
2060 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2061 fLocked
= any2bool(aTmp
);
2065 *rContents
<< nTemp
;
2066 pBlockFlags
[0] |= 0x01;
2067 *rContents
<< sal_uInt8(0x48);
2068 *rContents
<< sal_uInt8(0x80);
2070 fMultiLine
= any2bool(rPropSet
->getPropertyValue(WW8_ASCII2STR("MultiLine")));
2071 fHideSelection
= any2bool(rPropSet
->getPropertyValue(WW8_ASCII2STR("HideInactiveSelection")));
2075 if( fHideSelection
)
2077 *rContents
<< nTemp
;
2079 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2080 if (aTmp
.hasValue())
2081 aTmp
>>= mnBackColor
;
2082 *rContents
<< ExportColor(mnBackColor
);
2083 pBlockFlags
[0] |= 0x02;
2085 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
2086 if (aTmp
.hasValue())
2087 aTmp
>>= mnForeColor
;
2088 *rContents
<< ExportColor(mnForeColor
);
2089 pBlockFlags
[0] |= 0x04;
2091 aTmp
= rPropSet
->getPropertyValue( WW8_ASCII2STR("MaxTextLen"));
2092 aTmp
>>= nMaxLength
;
2093 *rContents
<< nMaxLength
;
2094 pBlockFlags
[0] |= 0x08;
2096 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Border"));
2097 sal_Int16 nBorder
= sal_Int16();
2099 nSpecialEffect
= ExportBorder(nBorder
,nBorderStyle
);
2100 *rContents
<< nBorderStyle
;
2101 pBlockFlags
[0] |= 0x10;
2103 aTmp
= rPropSet
->getPropertyValue( WW8_ASCII2STR("HScroll"));
2104 sal_Bool bTemp1
= any2bool(aTmp
);
2105 aTmp
= rPropSet
->getPropertyValue( WW8_ASCII2STR("VScroll"));
2106 sal_Bool bTemp2
= any2bool(aTmp
);
2107 if (!bTemp1
&& !bTemp2
)
2109 else if (bTemp1
&& bTemp2
)
2111 else if (!bTemp1
&& bTemp2
)
2115 *rContents
<< nScrollBars
;
2116 pBlockFlags
[0] |= 0x20;
2118 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("EchoChar"));
2119 sal_uInt16 nTmp
= sal_uInt16();
2121 nPasswordChar
= static_cast<sal_uInt8
>(nTmp
);
2122 *rContents
<< nPasswordChar
;
2123 pBlockFlags
[1] |= 0x02;
2125 SvxOcxString
aValue( rPropSet
->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2126 aValue
.WriteLenField( *rContents
);
2127 if (aValue
.HasData())
2128 pBlockFlags
[2] |= 0x40;
2130 WriteAlign(rContents
,4);
2131 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2132 if (aTmp
.hasValue())
2133 aTmp
>>= nBorderColor
;
2134 *rContents
<< ExportColor(nBorderColor
);
2135 pBlockFlags
[3] |= 0x02;
2137 *rContents
<< nSpecialEffect
;
2138 pBlockFlags
[3] |= 0x04;
2140 WriteAlign(rContents
,4);
2141 *rContents
<< rSize
.Width
;
2142 *rContents
<< rSize
.Height
;
2144 aValue
.WriteCharArray( *rContents
);
2146 WriteAlign(rContents
,4);
2148 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
2150 bRet
= aFontData
.Export(rContents
,rPropSet
);
2152 rContents
->Seek(nOldPos
);
2153 *rContents
<< nStandardId
;
2154 *rContents
<< nFixedAreaLen
;
2156 *rContents
<< pBlockFlags
[0];
2157 *rContents
<< pBlockFlags
[1];
2158 *rContents
<< pBlockFlags
[2];
2159 *rContents
<< pBlockFlags
[3];
2160 *rContents
<< pBlockFlags
[4];
2161 *rContents
<< pBlockFlags
[5];
2162 *rContents
<< pBlockFlags
[6];
2163 *rContents
<< pBlockFlags
[7];
2165 DBG_ASSERT((rContents
.Is() &&
2166 (SVSTREAM_OK
== rContents
->GetError())),"damn");
2171 sal_Bool
OCX_TextBox::Export(SvStorageRef
&rObj
,
2172 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2173 const awt::Size
&rSize
)
2175 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
2176 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2177 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
2178 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2179 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
2180 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2181 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2182 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
2183 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
2184 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
2185 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
2186 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
2187 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
2188 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
2189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2190 0x00, 0x00, 0x00, 0x00
2194 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
2195 xStor
->Write(aCompObj
,sizeof(aCompObj
));
2196 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
2200 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
2201 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
2202 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
2205 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
2206 0x54, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00,
2207 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
2208 0x00, 0x00, 0x00, 0x00
2212 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
2213 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
2214 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
2217 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
2218 return WriteContents(xContents
, rPropSet
, rSize
);
2221 sal_Bool
OCX_FieldControl::WriteContents(SvStorageStreamRef
&rContents
,
2222 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2223 const awt::Size
&rSize
)
2225 sal_Bool bRet
=sal_True
;
2226 sal_uInt32 nOldPos
= rContents
->Tell();
2227 rContents
->SeekRel(12);
2230 pBlockFlags
[1] = 0x01;
2231 pBlockFlags
[2] = 0x00;
2232 pBlockFlags
[3] = 0x80;
2239 sal_uInt8 nTemp
=0x19;
2240 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
2241 fEnabled
= any2bool(aTmp
);
2245 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2246 fLocked
= any2bool(aTmp
);
2250 *rContents
<< nTemp
;
2251 pBlockFlags
[0] |= 0x01;
2252 *rContents
<< sal_uInt8(0x48);
2253 *rContents
<< sal_uInt8(0x80);
2256 *rContents
<< nTemp
;
2258 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2259 if (aTmp
.hasValue())
2260 aTmp
>>= mnBackColor
;
2261 *rContents
<< ExportColor(mnBackColor
);
2262 pBlockFlags
[0] |= 0x02;
2264 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
2265 if (aTmp
.hasValue())
2266 aTmp
>>= mnForeColor
;
2267 *rContents
<< ExportColor(mnForeColor
);
2268 pBlockFlags
[0] |= 0x04;
2270 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Border"));
2271 sal_Int16 nBorder
= sal_Int16();
2273 nSpecialEffect
= ExportBorder(nBorder
,nBorderStyle
);
2274 *rContents
<< nBorderStyle
;
2275 pBlockFlags
[0] |= 0x10;
2277 #if 0 //Each control has a different Value format, and how to convert each to text has to be found out
2278 SvxOcxString
aValue( rPropSet
->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2279 aValue
.WriteLenField( *rContents
);
2280 if (aValue
.HasData())
2281 pBlockFlags
[2] |= 0x40;
2284 *rContents
<< nSpecialEffect
;
2285 pBlockFlags
[3] |= 0x04;
2287 WriteAlign(rContents
,4);
2288 *rContents
<< rSize
.Width
;
2289 *rContents
<< rSize
.Height
;
2292 aValue
.WriteCharArray( *rContents
);
2295 WriteAlign(rContents
,4);
2297 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
2299 bRet
= aFontData
.Export(rContents
,rPropSet
);
2301 rContents
->Seek(nOldPos
);
2302 *rContents
<< nStandardId
;
2303 *rContents
<< nFixedAreaLen
;
2305 *rContents
<< pBlockFlags
[0];
2306 *rContents
<< pBlockFlags
[1];
2307 *rContents
<< pBlockFlags
[2];
2308 *rContents
<< pBlockFlags
[3];
2309 *rContents
<< pBlockFlags
[4];
2310 *rContents
<< pBlockFlags
[5];
2311 *rContents
<< pBlockFlags
[6];
2312 *rContents
<< pBlockFlags
[7];
2314 DBG_ASSERT((rContents
.Is() &&
2315 (SVSTREAM_OK
==rContents
->GetError())),"damn");
2319 sal_Bool
OCX_FieldControl::Export(SvStorageRef
&rObj
,
2320 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2321 const awt::Size
&rSize
)
2323 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
2324 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2325 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
2326 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2327 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
2328 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2329 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2330 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
2331 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
2332 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
2333 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
2334 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
2335 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
2336 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
2337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2338 0x00, 0x00, 0x00, 0x00
2342 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
2343 xStor
->Write(aCompObj
,sizeof(aCompObj
));
2344 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
2348 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
2349 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
2350 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
2353 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
2354 0x54, 0x00, 0x65, 0x00, 0x78, 0x00, 0x74, 0x00,
2355 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
2356 0x00, 0x00, 0x00, 0x00
2360 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
2361 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
2362 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
2365 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
2366 return WriteContents(xContents
, rPropSet
, rSize
);
2371 sal_Bool
OCX_ToggleButton::Import(com::sun::star::uno::Reference
<
2372 com::sun::star::beans::XPropertySet
> &rPropSet
)
2374 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
2375 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
2377 aTmp
= bool2any(true);
2378 rPropSet
->setPropertyValue( WW8_ASCII2STR("Toggle"), aTmp
);
2381 if ((!(fEnabled
)) || (fLocked
))
2385 aTmp
= bool2any(bTemp
);
2386 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
2388 bTemp
= fWordWrap
!= 0;
2389 aTmp
= bool2any(bTemp
);
2390 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp
);
2392 aTmp
<<= ImportColor(mnForeColor
);
2393 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
2395 // fake transparent toggle button by setting window background color
2397 mnBackColor
= 0x80000005;
2398 aTmp
<<= ImportColor(mnBackColor
);
2399 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
2403 INT16 nTmp
=pValue
[0]-0x30;
2405 rPropSet
->setPropertyValue( WW8_ASCII2STR("State"), aTmp
);
2410 aTmp
<<= lclCreateOUString( pCaption
, nCaptionLen
);
2411 rPropSet
->setPropertyValue( WW8_ASCII2STR("Label"), aTmp
);
2414 aFontData
.Import(rPropSet
);
2416 if ( sImageUrl
.getLength() )
2419 rPropSet
->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp
);
2424 sal_Bool
OCX_ToggleButton::Export(
2425 SvStorageRef
&rObj
, const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2426 const awt::Size
& rSize
)
2428 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
2429 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2430 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
2431 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2432 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
2433 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2434 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2435 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
2436 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
2437 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
2438 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
2439 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
2440 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
2441 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
2442 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2443 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2444 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2448 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
2449 xStor
->Write(aCompObj
,sizeof(aCompObj
));
2450 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
2454 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
2455 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
2456 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
2459 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
2460 0x54, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x67, 0x00,
2461 0x6C, 0x00, 0x65, 0x00, 0x42, 0x00, 0x75, 0x00,
2462 0x74, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x6E, 0x00,
2463 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
2467 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
2468 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
2469 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
2472 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
2474 return WriteContents(xContents
,rPropSet
,rSize
);
2477 sal_Bool
OCX_ToggleButton::WriteContents(SvStorageStreamRef
&rContents
,
2478 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2479 const awt::Size
&rSize
)
2481 sal_Bool bRet
=sal_True
;
2482 sal_uInt32 nOldPos
= rContents
->Tell();
2483 rContents
->SeekRel(12);
2486 pBlockFlags
[1] = 0x01;
2488 pBlockFlags
[3] = 0x80;
2494 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
2495 fEnabled
= any2bool(aTmp
);
2497 sal_uInt8 nTemp
=fEnabled
;
2502 *rContents
<< nTemp
;
2503 pBlockFlags
[0] |= 0x01;
2504 *rContents
<< sal_uInt8(0x00);
2506 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("MultiLine"));
2507 fWordWrap
= any2bool(aTmp
);
2510 *rContents
<< nTemp
;
2511 *rContents
<< sal_uInt8(0x00);
2513 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2514 if (aTmp
.hasValue())
2515 aTmp
>>= mnBackColor
;
2516 *rContents
<< ExportColor(mnBackColor
);
2517 pBlockFlags
[0] |= 0x02;
2519 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
2520 if (aTmp
.hasValue())
2521 aTmp
>>= mnForeColor
;
2522 *rContents
<< ExportColor(mnForeColor
);
2523 pBlockFlags
[0] |= 0x04;
2526 *rContents
<< nStyle
;
2527 pBlockFlags
[0] |= 0x40;
2529 WriteAlign(rContents
,4);
2530 nValueLen
= 1|SVX_MSOCX_COMPRESSED
;
2531 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("State"));
2532 sal_Int16 nDefault
= sal_Int16();
2534 *rContents
<< nValueLen
;
2535 pBlockFlags
[2] |= 0x40;
2537 SvxOcxString
aCaption( rPropSet
->getPropertyValue(WW8_ASCII2STR("Label")) );
2538 aCaption
.WriteLenField( *rContents
);
2539 if (aCaption
.HasData())
2540 pBlockFlags
[2] |= 0x80;
2542 WriteAlign(rContents
,4);
2543 *rContents
<< rSize
.Width
;
2544 *rContents
<< rSize
.Height
;
2547 *rContents
<< sal_uInt8(nDefault
);
2548 *rContents
<< sal_uInt8(0x00);
2550 aCaption
.WriteCharArray( *rContents
);
2552 WriteAlign(rContents
,4);
2553 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
2554 bRet
= aFontData
.Export(rContents
,rPropSet
);
2555 rContents
->Seek(nOldPos
);
2556 *rContents
<< nStandardId
;
2557 *rContents
<< nFixedAreaLen
;
2559 *rContents
<< pBlockFlags
[0];
2560 *rContents
<< pBlockFlags
[1];
2561 *rContents
<< pBlockFlags
[2];
2562 *rContents
<< pBlockFlags
[3];
2563 *rContents
<< pBlockFlags
[4];
2564 *rContents
<< pBlockFlags
[5];
2565 *rContents
<< pBlockFlags
[6];
2566 *rContents
<< pBlockFlags
[7];
2568 DBG_ASSERT((rContents
.Is() &&
2569 (SVSTREAM_OK
==rContents
->GetError())),"damn");
2573 sal_Bool
OCX_Label::Import(uno::Reference
< beans::XPropertySet
> &rPropSet
)
2575 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
2576 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
2579 if ((!(fEnabled
)) || (fLocked
))
2583 aTmp
= bool2any(bTemp
);
2584 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
2586 aTmp
<<= ImportColor(mnForeColor
);
2587 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
2589 // background color: fBackStyle==0 -> transparent
2592 aTmp
<<= ImportColor(mnBackColor
);
2596 // try fake transparent by using parents backColor
2597 if ( bSetInDialog
&& mpParent
!= NULL
)
2599 aTmp
<<= ImportColor( mpParent
->mnBackColor
);
2603 aTmp
= uno::Any(); // use SO default
2606 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
2608 aTmp
<<= ImportBorder(nSpecialEffect
,nBorderStyle
);
2609 rPropSet
->setPropertyValue( WW8_ASCII2STR("Border"), aTmp
);
2611 aTmp
<<= ImportColor( nBorderColor
);
2612 rPropSet
->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp
);
2615 aTmp
= bool2any(bTemp
);
2616 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp
);
2620 aTmp
<<= lclCreateOUString( pCaption
, nCaptionLen
);
2621 rPropSet
->setPropertyValue( WW8_ASCII2STR("Label"), aTmp
);
2624 aFontData
.Import(rPropSet
);
2628 sal_Bool
OCX_ComboBox::Import(com::sun::star::uno::Reference
<
2629 com::sun::star::beans::XPropertySet
> &rPropSet
)
2632 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
2633 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
2635 aTmp
= bool2any(fEnabled
!= 0);
2636 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
2638 aTmp
= bool2any(fLocked
!= 0);
2639 rPropSet
->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp
);
2641 aTmp
= bool2any( nDropButtonStyle
!= 0 );
2642 rPropSet
->setPropertyValue( WW8_ASCII2STR("Dropdown"), aTmp
);
2644 aTmp
= bool2any( fHideSelection
!= 0 );
2645 rPropSet
->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp
);
2647 aTmp
<<= ImportColor(mnForeColor
);
2648 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
2652 aTmp
<<= lclCreateOUString( pValue
, nValueLen
);
2655 rPropSet
->setPropertyValue( WW8_ASCII2STR("Text"), aTmp
);
2659 rPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp
);
2663 aTmp
<<= ImportColor(mnBackColor
);
2664 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
2666 aTmp
<<= ImportBorder(nSpecialEffect
,nBorderStyle
);
2667 rPropSet
->setPropertyValue( WW8_ASCII2STR("Border"), aTmp
);
2669 aTmp
<<= ImportColor( nBorderColor
);
2670 rPropSet
->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp
);
2672 sal_Int16 nTmp
=static_cast<sal_Int16
>(nMaxLength
);
2674 rPropSet
->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp
);
2676 aFontData
.Import(rPropSet
);
2677 uno::Reference
< frame::XModel
> xModel ( pDocSh
? pDocSh
->GetModel() : NULL
);
2678 lcl_ApplyListSourceAndBindableStuff( xModel
, rPropSet
, msCtrlSource
, msRowSource
);
2682 sal_Bool
OCX_ComboBox::WriteContents(SvStorageStreamRef
&rContents
,
2683 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2684 const awt::Size
&rSize
)
2686 sal_Bool bRet
=sal_True
;
2687 sal_uInt32 nOldPos
= rContents
->Tell();
2688 rContents
->SeekRel(12);
2691 pBlockFlags
[1] = 0x01;
2692 pBlockFlags
[2] = 0x00;
2693 pBlockFlags
[3] = 0x80;
2700 sal_uInt8 nTemp
=0x19;//fEnabled;
2701 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
2702 fEnabled
= any2bool(aTmp
);
2706 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2707 fLocked
= any2bool(aTmp
);
2711 *rContents
<< nTemp
;
2712 pBlockFlags
[0] |= 0x01;
2713 *rContents
<< sal_uInt8(0x48);
2714 *rContents
<< sal_uInt8(0x80);
2717 fHideSelection
= any2bool(rPropSet
->getPropertyValue(WW8_ASCII2STR("HideInactiveSelection")));
2718 if( fHideSelection
)
2720 *rContents
<< nTemp
;
2722 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2723 if (aTmp
.hasValue())
2724 aTmp
>>= mnBackColor
;
2725 *rContents
<< ExportColor(mnBackColor
);
2726 pBlockFlags
[0] |= 0x02;
2728 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
2729 if (aTmp
.hasValue())
2730 aTmp
>>= mnForeColor
;
2731 *rContents
<< ExportColor(mnForeColor
);
2732 pBlockFlags
[0] |= 0x04;
2734 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Border"));
2735 sal_Int16 nBorder
= sal_Int16();
2737 nSpecialEffect
= ExportBorder(nBorder
,nBorderStyle
);
2738 *rContents
<< nBorderStyle
;
2739 pBlockFlags
[0] |= 0x10;
2742 *rContents
<< nStyle
;
2743 pBlockFlags
[0] |= 0x40;
2745 WriteAlign(rContents
,2);
2747 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("LineCount"));
2749 *rContents
<< nListRows
;
2750 pBlockFlags
[1] |= 0x40;
2752 *rContents
<< sal_uInt8(1); //DefaultSelected One
2753 pBlockFlags
[2] |= 0x01;
2755 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Dropdown"));
2756 nDropButtonStyle
= any2bool(aTmp
);
2757 if (nDropButtonStyle
)
2758 nDropButtonStyle
=0x02;
2759 *rContents
<< nDropButtonStyle
;
2760 pBlockFlags
[2] |= 0x04;
2762 SvxOcxString
aValue( rPropSet
->getPropertyValue(WW8_ASCII2STR("Text")) );
2763 aValue
.WriteLenField( *rContents
);
2764 if (aValue
.HasData())
2765 pBlockFlags
[2] |= 0x40;
2767 WriteAlign(rContents
,4);
2768 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2769 if (aTmp
.hasValue())
2770 aTmp
>>= nBorderColor
;
2771 *rContents
<< ExportColor(nBorderColor
);
2772 pBlockFlags
[3] |= 0x02;
2774 *rContents
<< nSpecialEffect
;
2775 pBlockFlags
[3] |= 0x04;
2777 WriteAlign(rContents
,4);
2778 *rContents
<< rSize
.Width
;
2779 *rContents
<< rSize
.Height
;
2781 aValue
.WriteCharArray( *rContents
);
2783 WriteAlign(rContents
,4);
2785 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
2787 bRet
= aFontData
.Export(rContents
,rPropSet
);
2789 rContents
->Seek(nOldPos
);
2790 *rContents
<< nStandardId
;
2791 *rContents
<< nFixedAreaLen
;
2793 *rContents
<< pBlockFlags
[0];
2794 *rContents
<< pBlockFlags
[1];
2795 *rContents
<< pBlockFlags
[2];
2796 *rContents
<< pBlockFlags
[3];
2797 *rContents
<< pBlockFlags
[4];
2798 *rContents
<< pBlockFlags
[5];
2799 *rContents
<< pBlockFlags
[6];
2800 *rContents
<< pBlockFlags
[7];
2802 DBG_ASSERT((rContents
.Is() &&
2803 (SVSTREAM_OK
==rContents
->GetError())),"damn");
2808 sal_Bool
OCX_ComboBox::Export(SvStorageRef
&rObj
,
2809 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2810 const awt::Size
&rSize
)
2812 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
2813 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2814 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2815 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2816 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2817 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2818 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2819 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2820 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2821 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2822 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2823 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2824 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2825 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2826 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2827 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2831 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
2832 xStor
->Write(aCompObj
,sizeof(aCompObj
));
2833 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
2837 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
2838 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
2839 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
2842 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
2843 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x62, 0x00,
2844 0x6F, 0x00, 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00,
2845 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
2849 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
2850 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
2851 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
2854 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
2855 return WriteContents(xContents
, rPropSet
, rSize
);
2860 sal_Bool
OCX_ListBox::Import(com::sun::star::uno::Reference
<
2861 com::sun::star::beans::XPropertySet
> &rPropSet
)
2864 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
2865 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
2867 sal_Bool bTmp
=fEnabled
;
2868 aTmp
= bool2any(bTmp
);
2869 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
2872 aTmp
= bool2any(bTmp
);
2873 rPropSet
->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp
);
2875 aTmp
<<= ImportColor(mnForeColor
);
2876 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
2878 sal_Bool bTemp
= nMultiState
;
2879 aTmp
= bool2any(bTemp
);
2880 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiSelection"), aTmp
);
2882 #if 0 //Don't delete this for now until I figure out if I can make this
2885 aTmp
<<= lclCreateOUString( pValue
, nValueLen
);
2886 xPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp
);
2890 aTmp
<<= ImportColor(mnBackColor
);
2891 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
2893 aTmp
<<= ImportBorder(nSpecialEffect
,nBorderStyle
);
2894 rPropSet
->setPropertyValue( WW8_ASCII2STR("Border"), aTmp
);
2896 aTmp
<<= ImportColor( nBorderColor
);
2897 rPropSet
->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp
);
2898 uno::Reference
< frame::XModel
> xModel ( pDocSh
? pDocSh
->GetModel() : NULL
);
2899 lcl_ApplyListSourceAndBindableStuff( xModel
, rPropSet
, msCtrlSource
, msRowSource
);
2900 aFontData
.Import(rPropSet
);
2904 sal_Bool
OCX_ListBox::WriteContents(SvStorageStreamRef
&rContents
,
2905 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
2906 const awt::Size
&rSize
)
2908 sal_Bool bRet
=sal_True
;
2909 sal_uInt32 nOldPos
= rContents
->Tell();
2910 rContents
->SeekRel(12);
2913 pBlockFlags
[1] = 0x01;
2914 pBlockFlags
[2] = 0x01;
2915 pBlockFlags
[3] = 0x80;
2921 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
2922 fEnabled
= any2bool(aTmp
);
2923 sal_uInt8 nTemp
=fEnabled
;
2927 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("ReadOnly"));
2928 fLocked
= any2bool(aTmp
);
2932 *rContents
<< nTemp
;
2933 pBlockFlags
[0] |= 0x01;
2934 *rContents
<< sal_uInt8(0x00);
2935 *rContents
<< sal_uInt8(0x00);
2936 *rContents
<< sal_uInt8(0x00);
2938 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
2939 if (aTmp
.hasValue())
2940 aTmp
>>= mnBackColor
;
2941 *rContents
<< ExportColor(mnBackColor
);
2942 pBlockFlags
[0] |= 0x02;
2944 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
2945 if (aTmp
.hasValue())
2946 aTmp
>>= mnForeColor
;
2947 *rContents
<< ExportColor(mnForeColor
);
2948 pBlockFlags
[0] |= 0x04;
2950 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Border"));
2951 sal_Int16 nBorder
= sal_Int16();
2953 nSpecialEffect
= ExportBorder(nBorder
,nBorderStyle
);
2954 WriteAlign(rContents
,2);
2955 *rContents
<< nBorderStyle
;
2956 pBlockFlags
[0] |= 0x10;
2958 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("MultiSelection"));
2959 nMultiState
= any2bool(aTmp
);
2963 *rContents
<< nMultiState
;
2964 pBlockFlags
[0] |= 0x20;
2968 *rContents
<< nStyle
;
2969 pBlockFlags
[0] |= 0x40;
2972 WriteAlign(rContents
,4);
2975 SvxOcxString
aValue( rPropSet
->getPropertyValue(WW8_ASCII2STR("DefaultText")) );
2976 aValue
.WriteLenField( *rContents
);
2977 if (aValue
.HasData())
2978 pBlockFlags
[2] |= 0x40;
2980 WriteAlign(rContents
,4);
2983 WriteAlign(rContents
,4);
2984 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BorderColor"));
2985 if (aTmp
.hasValue())
2986 aTmp
>>= nBorderColor
;
2987 *rContents
<< ExportColor(nBorderColor
);
2988 pBlockFlags
[3] |= 0x02;
2990 *rContents
<< nSpecialEffect
;
2991 pBlockFlags
[3] |= 0x04;
2993 WriteAlign(rContents
,4);
2994 *rContents
<< rSize
.Width
;
2995 *rContents
<< rSize
.Height
;
2998 aValue
.WriteCharArray( *rContents
);
3001 WriteAlign(rContents
,4);
3003 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
3005 bRet
= aFontData
.Export(rContents
,rPropSet
);
3007 rContents
->Seek(nOldPos
);
3008 *rContents
<< nStandardId
;
3009 *rContents
<< nFixedAreaLen
;
3011 *rContents
<< pBlockFlags
[0];
3012 *rContents
<< pBlockFlags
[1];
3013 *rContents
<< pBlockFlags
[2];
3014 *rContents
<< pBlockFlags
[3];
3015 *rContents
<< pBlockFlags
[4];
3016 *rContents
<< pBlockFlags
[5];
3017 *rContents
<< pBlockFlags
[6];
3018 *rContents
<< pBlockFlags
[7];
3020 DBG_ASSERT((rContents
.Is() &&
3021 (SVSTREAM_OK
==rContents
->GetError())),"damn");
3025 sal_Bool
OCX_ListBox::Export(SvStorageRef
&rObj
,
3026 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
3027 const awt::Size
&rSize
)
3029 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
3030 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
3031 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
3032 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
3033 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
3034 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
3035 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
3036 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
3037 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
3038 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
3039 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
3040 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
3041 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
3042 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
3043 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3044 0x00, 0x00, 0x00, 0x00
3048 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
3049 xStor
->Write(aCompObj
,sizeof(aCompObj
));
3050 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
3054 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
3055 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
3056 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
3059 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
3060 0x4C, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00,
3061 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00, 0x31, 0x00,
3062 0x00, 0x00, 0x00, 0x00
3066 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
3067 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
3068 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
3071 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
3072 return WriteContents(xContents
, rPropSet
, rSize
);
3075 sal_Bool
OCX_Control::Read(SvStorageStream
*pS
)
3077 sal_uInt16 nIdentifier
, nFixedAreaLen
;
3079 DBG_ASSERT(nStandardId
==nIdentifier
,
3080 "A control that has a different identifier");
3081 *pS
>> nFixedAreaLen
;
3082 pS
->SeekRel(nFixedAreaLen
);
3086 sal_Bool
OCX_ModernControl::Read(SvStorageStream
*pS
)
3088 long nStart
= pS
->Tell();
3090 DBG_ASSERT(nIdentifier
==nStandardId
,
3091 "A control that has a different identifier");
3092 *pS
>> nFixedAreaLen
;
3093 pS
->Read(pBlockFlags
,8);
3095 if (pBlockFlags
[0] & 0x01)
3100 fEnabled
= (nTemp
& 0x02) >> 1;
3101 fLocked
= (nTemp
& 0x04) >> 2;
3102 fBackStyle
= (nTemp
& 0x08) >> 3;
3106 fColumnHeads
= (nTemp
& 0x04) >> 2;
3107 fIntegralHeight
= (nTemp
& 0x08) >> 3;
3108 fMatchRequired
= (nTemp
& 0x10) >> 4;
3109 fAlignment
= (nTemp
& 0x20) >> 5;
3113 fDragBehaviour
= (nTemp
& 0x08) >> 3;
3114 fEnterKeyBehaviour
= (nTemp
& 0x10) >> 4;
3115 fEnterFieldBehaviour
= (nTemp
& 0x20) >> 5;
3116 fTabKeyBehaviour
= (nTemp
& 0x40) >> 6;
3117 fWordWrap
= (nTemp
& 0x80) >> 7;
3120 fSelectionMargin
= (nTemp
& 0x04) >> 2;
3121 fAutoWordSelect
= (nTemp
& 0x08) >> 3;
3122 fAutoSize
= (nTemp
& 0x10) >> 4;
3123 fHideSelection
= (nTemp
& 0x20) >> 5;
3124 fAutoTab
= (nTemp
& 0x40) >> 6;
3125 fMultiLine
= (nTemp
& 0x80) >> 7;
3129 /*If any of these are set they follow eachother in this order one after
3130 another padded out to the next U32 boundary with 0's
3131 U8 can abut each other U16 must start on a U16 boundary and are padded to
3132 that with 0's. A standardish word alignment structure*/
3134 if (pBlockFlags
[0] & 0x02)
3136 if (pBlockFlags
[0] & 0x04)
3138 if (pBlockFlags
[0] & 0x08)
3141 if (pBlockFlags
[0] & 0x10)
3142 *pS
>> nBorderStyle
;
3143 if (pBlockFlags
[0] & 0x20)
3145 if (pBlockFlags
[0] & 0x40)
3146 *pS
>> nStyle
;// (UI 0 == Data 3, UI 2 = Data 7)
3147 if (pBlockFlags
[0] & 0x80)
3148 *pS
>> nMousePointer
;
3150 if (pBlockFlags
[1] & 0x02)
3151 *pS
>> nPasswordChar
; //HUH ??? always 0 ??? not sure maybe just padding
3153 if (pBlockFlags
[1] & 0x04)
3155 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3159 if (pBlockFlags
[1] & 0x08)
3161 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3162 *pS
>> nBoundColumn
;
3164 if (pBlockFlags
[1] & 0x10)
3166 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3169 if (pBlockFlags
[1] & 0x20)
3171 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3172 *pS
>> nColumnCount
;
3174 if (pBlockFlags
[1] & 0x40)
3176 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3179 if (pBlockFlags
[1] & 0x80)
3181 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3182 *pS
>> nUnknown8
; //something to do with ColumnWidths
3184 if (pBlockFlags
[2] & 0x01)
3186 if (pBlockFlags
[2] & 0x02)
3188 if (pBlockFlags
[2] & 0x04)
3189 *pS
>> nShowDropButtonWhen
;
3190 if (pBlockFlags
[2] & 0x10)
3191 *pS
>> nDropButtonStyle
;
3192 if (pBlockFlags
[2] & 0x20)
3195 bool bValue
= (pBlockFlags
[2] & 0x40) != 0;
3198 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3201 bool bCaption
= (pBlockFlags
[2] & 0x80) != 0;
3204 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3207 if (pBlockFlags
[3] & 0x01)
3209 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3213 if (pBlockFlags
[3] & 0x02)
3215 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3216 *pS
>> nBorderColor
;
3218 if (pBlockFlags
[3] & 0x04)
3220 ReadAlign(pS
, pS
->Tell() - nStart
, 4); // NEW
3221 *pS
>> nSpecialEffect
;
3222 pS
->SeekRel( 3 ); // special effect is 32bit, not 8bit
3224 if (pBlockFlags
[3] & 0x08)
3226 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3228 DBG_ASSERT(nIcon
== 0xFFFF, "Unexpected nIcon");
3230 if (pBlockFlags
[3] & 0x10)
3232 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3234 DBG_ASSERT(nPicture
== 0xFFFF, "Unexpected nIcon");
3236 if (pBlockFlags
[3] & 0x20)
3237 *pS
>> nAccelerator
;
3239 if (pBlockFlags[3] & 0x80)
3242 bool bGroupName
= (pBlockFlags
[4] & 0x01) != 0;
3245 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3246 *pS
>> nGroupNameLen
;
3251 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3256 lclReadCharArray( *pS
, pValue
, nValueLen
, pS
->Tell() - nStart
);
3259 lclReadCharArray( *pS
, pCaption
, nCaptionLen
, pS
->Tell() - nStart
);
3262 lclReadCharArray( *pS
, pGroupName
, nGroupNameLen
, pS
->Tell() - nStart
);
3264 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3267 pS
->Read(pIconHeader
,20);
3269 pIcon
= new sal_uInt8
[nIconLen
];
3270 pS
->Read(pIcon
,nIconLen
);
3275 pS
->Read(pPictureHeader
,20);
3277 long imagePos
= pS
->Tell();
3278 mxGrfObj
= lcl_readGraphicObject( pS
);
3281 sImageUrl
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX
) );
3282 sImageUrl
= sImageUrl
+ mxGrfObj
->getUniqueID();
3284 // make sure the stream position should be pointing after the image
3285 pS
->Seek( imagePos
+ nPictureLen
);
3292 sal_Bool
OCX_CommandButton::Read(SvStorageStream
*pS
)
3294 long nStart
= pS
->Tell();
3296 DBG_ASSERT(nStandardId
==nIdentifier
,
3297 "A control that has a different identifier");
3298 *pS
>> nFixedAreaLen
;
3299 pS
->Read(pBlockFlags
,4);
3302 if (pBlockFlags
[0] & 0x01)
3304 if (pBlockFlags
[0] & 0x02)
3307 if (pBlockFlags
[0] & 0x04)
3311 fEnabled
= (nTemp
&0x02)>>1;
3312 fLocked
= (nTemp
&0x04)>>2;
3313 fBackStyle
= (nTemp
&0x08)>>3;
3316 fWordWrap
= (nTemp
&0x80)>>7;
3318 fAutoSize
= (nTemp
&0x10)>>4;
3321 bool bCaption
= (pBlockFlags
[0] & 0x08) != 0;
3326 if (pBlockFlags
[0] & 0x10) /*Picture Position, a strange mechanism here*/
3332 if (pBlockFlags
[0] & 0x40) /*MousePointer*/
3333 *pS
>> nMousePointer
;
3335 if (pBlockFlags
[0] & 0x80)
3337 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3341 if (pBlockFlags
[1] & 0x01)
3343 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3344 *pS
>> nAccelerator
;
3347 // "take focus on click" is directly in content flags, not in option field...
3348 mbTakeFocus
= (pBlockFlags
[1] & 0x02) == 0; // option is on, if flag is not set
3350 if (pBlockFlags
[1] & 0x04)
3352 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3357 lclReadCharArray( *pS
, pCaption
, nCaptionLen
, pS
->Tell() - nStart
);
3359 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3365 pS
->Read(pIconHeader
,20);
3367 pIcon
= new sal_uInt8
[nIconLen
];
3368 pS
->Read(pIcon
,nIconLen
);
3373 pS
->Read(pPictureHeader
,20);
3375 long imagePos
= pS
->Tell();
3376 mxGrfObj
= lcl_readGraphicObject( pS
);
3379 sImageUrl
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX
) );
3380 sImageUrl
= sImageUrl
+ mxGrfObj
->getUniqueID();
3382 // make sure the stream position should be pointing after the image
3383 pS
->Seek( imagePos
+ nPictureLen
);
3389 sal_Bool
OCX_Label::Read(SvStorageStream
*pS
)
3391 long nStart
= pS
->Tell();
3393 DBG_ASSERT(nStandardId
==nIdentifier
,
3394 "A control that has a different identifier");
3395 *pS
>> nFixedAreaLen
;
3396 pS
->Read(pBlockFlags
,4);
3399 if (pBlockFlags
[0] & 0x01)
3401 if (pBlockFlags
[0] & 0x02)
3405 if (pBlockFlags
[0] & 0x04)
3409 fEnabled
= (nTemp
&0x02)>>1;
3410 fLocked
= (nTemp
&0x04)>>2;
3411 fBackStyle
= (nTemp
&0x08)>>3;
3414 fWordWrap
= (nTemp
&0x80)>>7;
3416 fAutoSize
= (nTemp
&0x10)>>4;
3418 bool bCaption
= (pBlockFlags
[0] & 0x08) != 0;
3422 if (pBlockFlags
[0] & 0x10)
3428 if (pBlockFlags
[0] & 0x40)
3429 *pS
>> nMousePointer
;
3431 if (pBlockFlags
[0] & 0x80)
3433 ReadAlign(pS
,pS
->Tell() - nStart
, 4);
3434 *pS
>> nBorderColor
;
3437 if (pBlockFlags
[1] & 0x01)
3439 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3440 *pS
>> nBorderStyle
;
3443 if (pBlockFlags
[1] & 0x02)
3445 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3446 *pS
>> nSpecialEffect
;
3449 if (pBlockFlags
[1] & 0x04)
3451 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3455 if (pBlockFlags
[1] & 0x08)
3457 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3458 *pS
>> nAccelerator
;
3461 if (pBlockFlags
[1] & 0x10)
3463 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
3468 lclReadCharArray( *pS
, pCaption
, nCaptionLen
, pS
->Tell() - nStart
);
3470 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
3476 pS
->Read(pPictureHeader
,20);
3478 pPicture
= new sal_uInt8
[nPictureLen
];
3479 pS
->Read(pPicture
,nPictureLen
);
3483 pS
->Read(pIconHeader
,20);
3485 pIcon
= new sal_uInt8
[nIconLen
];
3486 pS
->Read(pIcon
,nIconLen
);
3492 TypeName::TypeName(sal_Char
*pName
, sal_uInt32 nStoreId
, sal_uInt32 nLen
, sal_uInt16 nType
, sal_Int32 nLeft
,
3494 : msName(lclCreateOUString(pName
, nLen
)), mnType(nType
), mnLeft(nLeft
),
3495 mnTop(nTop
),mnStoreId(nStoreId
)
3499 OCX_ContainerControl::OCX_ContainerControl( SotStorageRef
& parent
,
3500 const ::rtl::OUString
& storageName
,
3501 const ::rtl::OUString
& sN
,
3502 const uno::Reference
< container::XNameContainer
> &rParent
,
3503 OCX_Control
* pParent
) :
3504 OCX_Control(sN
, pParent
), mxParent(rParent
), nNoRecords(0), nTotalLen(0), containerType( STDCONTAINER
)
3507 mContainerStorage
= parent
->OpenSotStorage(storageName
,
3510 STREAM_SHARE_DENYALL
);
3511 mContainerStream
= mContainerStorage
->OpenSotStream(
3512 String(RTL_CONSTASCII_STRINGPARAM("f"),
3513 RTL_TEXTENCODING_MS_1252
),
3514 STREAM_STD_READ
| STREAM_NOCREATE
);
3515 mContainedControlsStream
= mContainerStorage
->OpenSotStream( String(RTL_CONSTASCII_STRINGPARAM("o"),
3516 RTL_TEXTENCODING_MS_1252
),
3517 STREAM_STD_READ
| STREAM_NOCREATE
);
3519 OCX_ContainerControl::~OCX_ContainerControl()
3521 CtrlIterator aEnd
= mpControls
.end();
3522 for (CtrlIterator aIter
= mpControls
.begin(); aIter
!= aEnd
; ++ aIter
)
3528 // Really import should receive the parent e.g. a Userform, Frame or Multi Page
3529 // and call import on its containees with itself ( up-called from
3530 // the base class ) but... the reality is we have no containment model
3531 // so we make sure rPropSet is always the parent Dialog
3533 sal_Bool
OCX_ContainerControl::Import(uno::Reference
<beans::XPropertySet
>& /* rProps */ )
3535 if ( !mxParent
.is() )
3539 CtrlIterator aEnd
= mpControls
.end();
3541 for (CtrlIterator aIter
= mpControls
.begin(); aIter
!= aEnd
; ++ aIter
)
3543 if ( !(*aIter
)->Import( mxParent
) )
3551 OUString
OCX_ContainerControl::createSubStreamName( const sal_uInt32
& subStorageId
)
3553 static OUString sI
= OUString::createFromAscii("i");
3554 static OUString sZero
= OUString::createFromAscii( "0" );
3555 OUStringBuffer
buf( 6 );
3557 // for subStorage id < 10 stream name has leading '0'
3559 if ( subStorageId
< 10 )
3561 buf
.append( sZero
);
3563 buf
.append( OUString::valueOf( (sal_Int32
)subStorageId
) );
3564 return buf
.makeStringAndClear();
3568 bool OCX_ContainerControl::createFromContainerRecord( ContainerRecord
& record
, OCX_Control
*& pControl
)
3571 if ( record
.nTypeIdent
& 0x8000 )
3573 std::hash_map
<sal_uInt16
, sal_uInt16
>::iterator it
= mActiveXIDMap
.find( record
.nTypeIdent
);
3574 if ( it
== mActiveXIDMap
.end() )
3576 // replace the generated id with our hardcoded one
3577 record
.nTypeIdent
= it
->second
;
3579 switch ( record
.nTypeIdent
)
3582 pControl
= new OCX_CommandButton
;
3585 pControl
= new OCX_UserFormLabel(this);
3588 pControl
= new OCX_TextBox
;
3591 pControl
= new OCX_ListBox
;
3594 pControl
= new OCX_ComboBox
;
3597 pControl
= new OCX_CheckBox
;
3600 pControl
= new OCX_OptionButton
;
3603 pControl
= new OCX_ToggleButton
;
3607 pControl
= new OCX_Image
;
3612 OUString sMSStore
= createSubStreamName( record
.nSubStorageId
);
3613 pControl
= new OCX_Page(mContainerStorage
, sMSStore
,
3614 record
.cName
, mxParent
, this);
3617 case MULTIPAGE
: // MultiPage
3619 OUString sMSStore
= createSubStreamName( record
.nSubStorageId
);
3620 pControl
= new OCX_MultiPage( mContainerStorage
, sMSStore
,
3621 record
.cName
, mxParent
, this);
3626 OUString sFrameStore
= createSubStreamName( record
.nSubStorageId
);
3627 pControl
= new OCX_Frame(mContainerStorage
, sFrameStore
,
3628 record
.cName
, mxParent
, this);
3632 case SPINBUTTON
: //SpinButton
3634 pControl
= new OCX_SpinButton
;
3637 case TABSTRIP
: //TabStrip
3639 pControl
= new OCX_TabStrip
;
3642 case SCROLLBAR
: //ScrollBar
3643 pControl
= new OCX_ScrollBar
;
3645 case PROGRESSBAR
: //ProgressBar Active X control
3646 pControl
= new OCX_ProgressBar
;
3649 OSL_TRACE( "**** Unknown control 0x%x", record
.nTypeIdent
);
3650 DBG_ERROR( "Unknown control");
3653 pControl
->sName
= record
.cName
;
3658 void addSeperator( std::vector
< OCX_Control
* >& dest
)
3660 OCX_Control
* seperator
= new OCX_CommandButton
;
3661 seperator
->SetInDialog(true);
3662 seperator
->sName
= C2S("GroupSeperator");
3663 dest
.push_back( seperator
);
3666 void addRButtons( std::vector
< OCX_Control
* >& src
,
3667 std::vector
< OCX_Control
* >& dest
,
3668 bool addGroupSeperator
)
3670 if ( addGroupSeperator
)
3672 addSeperator( dest
);
3675 for ( CtrlIterator rbIter
= src
.begin(); rbIter
!= src
.end(); ++rbIter
)
3677 dest
.push_back( *rbIter
);
3681 void OCX_ContainerControl::ProcessControl(OCX_Control
* pControl
,SvStorageStream
* /* pS */, ContainerRecord
& rec
)
3683 SotStorageStreamRef oStream
= mContainedControlsStream
;
3685 // can insert into OO Dialog (e.g is this a supported dialog control)??
3686 if ( rec
.nTypeIdent
== TABSTRIP
)
3688 // skip the record in the stream, discard the control
3689 oStream
->SeekRel( rec
.nSubStreamLen
);
3694 // A container control needs to read the f stream in
3695 // the folder ( substorage ) associated with this control
3696 switch ( rec
.nTypeIdent
)
3702 OCX_ContainerControl
* pContainer
=
3703 static_cast< OCX_ContainerControl
* >( pControl
);
3704 oStream
= pContainer
->getContainerStream();
3713 pControl
->msCtrlSource
= rec
.sCtrlSource
;
3714 pControl
->msRowSource
= rec
.sRowSource
;
3717 pControl
->sName
= rec
.cName
;
3718 pControl
->msToolTip
= rec
.controlTip
;
3719 // Position of controls is relative to the container
3720 pControl
->mnTop
= rec
.nTop
+ mnTop
;
3721 pControl
->mnLeft
= rec
.nLeft
+ mnLeft
;
3722 // MS tabIndex, pretty useless in OpenOffice land
3723 // as tab indexes in MS are relative to parent container.
3724 // However we need this value in order to set
3725 // OpenOffice tab indices in a sensible way to
3726 // reflect the ms tabbing from orig MS UserForm, see below
3727 pControl
->mnTabPos
= rec
.nTabPos
;
3728 pControl
->SetInDialog(true);
3729 pControl
->mbVisible
= rec
.bVisible
;
3732 // If the container has a step then it should be
3733 // applied to all containees
3734 pControl
->mnStep
= mnStep
;
3736 pControl
->msParentName
= sName
;
3738 // #117490# DR: container records provide size of substream, use it here...
3740 // remember initial position to set correct stream position
3741 ULONG nStrmPos
= oStream
->Tell();
3742 // import control, may return with invalid stream position
3743 pControl
->FullRead(oStream
);
3744 // set stream to position behind substream of this control
3745 oStream
->Seek( nStrmPos
+ rec
.nSubStreamLen
);
3747 mpControls
.push_back( pControl
);
3751 sal_Bool
OCX_ContainerControl::Read(SvStorageStream
*pS
)
3756 mnBackColor
= mpParent
->mnBackColor
;
3759 std::auto_ptr
< ContainerRecReader
> reader (
3760 ContainerRecordReaderFac::instance( containerType
) );
3762 reader
->Read( this, pS
);
3763 // Need to honour the MS Tab Indexes. However MS tab indexes are
3764 // relative to parent, this hack sorts the controls in each container
3765 // based on the ms tab indexes. When import is called we create the
3766 // controls in Open/Star office based on the order of the tab indexes,
3767 // this ensures that the default tab index created by Star/Open office
3768 // reflects the "flattened" ms tab order.
3769 ::std::sort( mpControls
.begin(), mpControls
.end(), SortOrderByTabPos() );
3773 OCX_MultiPage::OCX_MultiPage( SotStorageRef
& parent
,
3774 const ::rtl::OUString
& storageName
,
3775 const ::rtl::OUString
& sN
,
3776 const uno::Reference
< container::XNameContainer
> &rDialog
,
3777 OCX_Control
* pParent
):
3778 OCX_ContainerControl(parent
, storageName
, sN
, rDialog
, pParent
), fUnknown1(0), fEnabled(1),
3779 fLocked(0), fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0),
3780 nVertPos(1), nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3781 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
3782 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
3783 bPictureTiling(FALSE
), nAccelerator(0), nIcon(0), pCaption(0),
3784 nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
3787 //msDialogType = C2U("NotSupported");
3788 msDialogType
= C2U("com.sun.star.awt.UnoMultiPageModel");
3789 mnForeColor
= 0x80000012L
,
3790 mnBackColor
= 0x8000000FL
;
3791 bSetInDialog
= true;// UserForm control only
3792 aFontData
.SetHasAlign(TRUE
);
3793 containerType
= MULTIPAGE
;
3794 mnCurrentPageStep
= 0;
3797 void OCX_MultiPage::ProcessControl(OCX_Control
* pControl
, SvStorageStream
* /* pS */, ContainerRecord
& rec
)
3799 SotStorageStreamRef oStream
= mContainedControlsStream
;
3801 OCX_Page
*pPage
= NULL
;
3802 if ( rec
.nTypeIdent
== PAGE
)
3803 pPage
= static_cast< OCX_Page
* >( pControl
);
3804 if ( pPage
!= NULL
)
3806 pPage
->mnStep
= ++mnCurrentPageStep
;
3808 pPage
->mnTop
= mnTop
;// move these to Page::import ?
3809 pPage
->mnLeft
= mnLeft
;
3810 pPage
->mnBackColor
= mnBackColor
;
3812 oStream
= pPage
->getContainerStream();;
3813 // Position of controls is relative to pos of this MuliPage
3815 pPage
->FullRead( oStream
);
3817 mpControls
.push_back( pPage
);
3821 OSL_TRACE("!!!! Unsupported Control 0x%x ", rec
.nTypeIdent
);
3822 DBG_ERROR("MultiPage error expected Page control");
3827 sal_Bool
OCX_MultiPage::Read(SvStorageStream
*pS
)
3829 // Unlike the other containers e.g. UserForm & Frame
3830 // the o stream is does not contain info for the contained controls
3831 // ( e.g. the pages themselves ) but seems to be for the MultiPage
3832 // itself - need to check this in more detail
3834 // For the moment skip read of the MultiPage specific properties
3835 // not much point reading these as we can't display the multi page
3836 // control or in fact any sort of tabbed layout, best we can do is
3837 // import just the contained controls of the individual pages
3838 // Note: the record skipped below ( does not contain the expected
3839 // info on this control, that seems to be contained in the o stream,
3840 // see comment above)
3841 OCX_Control
skip(C2S("Dummy"));
3843 mnCurrentPageStep
= mnStep
; //( set step of of pages relative to step
3844 //of this MultiPage ( e.g. emulate containment )
3845 return OCX_ContainerControl::Read(pS
);
3849 sal_Bool
OCX_MultiPage::Import(com::sun::star::uno::Reference
<
3850 com::sun::star::beans::XPropertySet
> &rPropSet
)
3852 OCX_ContainerControl::Import( rPropSet
);
3856 sal_Bool
OCX_MultiPage::Import(com::sun::star::uno::Reference
<
3857 com::sun::star::container::XNameContainer
>
3860 uno::Reference
<beans::XPropertySet
> xPropSet( rDialog
, uno::UNO_QUERY
);
3862 // Although MultiPage is not represeted by a "real" control we still
3863 // need to propagate the backcolor of this logical parent
3864 // ( the dialog or Frame or whatever ) to the children of this control.
3865 // For example the controls contained in the Page of a
3866 // MultiPage control use the parents backcolor ( e,g,
3867 // Pages backcolor ) when trying to fake transparency
3868 mnBackColor
= mpParent
->mnBackColor
;
3870 if ( xPropSet
.is() )
3872 uno::Reference
<lang::XMultiServiceFactory
>
3873 xFactory(rDialog
, uno::UNO_QUERY
);
3874 OSL_TRACE("** MultiPage creating control %s", rtl::OUStringToOString( msDialogType
, RTL_TEXTENCODING_UTF8
).getStr() );
3875 uno::Reference
<uno::XInterface
> xCreate
= xFactory
->createInstance(msDialogType
);
3879 uno::Reference
<awt::XControlModel
> xModel(xCreate
, uno::UNO_QUERY
);
3885 // we should just call MultiPage::Import( XPropertySet )
3886 OSL_TRACE("********* MULTIPAGE cName %s", rtl::OUStringToOString( sName
, RTL_TEXTENCODING_UTF8
).getStr() );
3887 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
3888 uno::Reference
<beans::XPropertySet
> xPrps(xModel
, uno::UNO_QUERY
);
3889 xPrps
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
3890 aTmp
= uno::makeAny( mnCurrentPageStep
);
3891 xPrps
->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp
);
3892 // default current page to 0 ( #FIXME, we need to read this value )
3893 aTmp
= uno::makeAny( sal_Int32(0) );
3894 xPrps
->setPropertyValue( WW8_ASCII2STR("ProgressValue"), aTmp
);
3895 OSL_TRACE("********* MULTIPAGE vomitted out properties");
3897 // Calls import on contained controls
3898 rDialog
->insertByName(sName
, uno::makeAny(xModel
));
3899 OSL_TRACE("*** inserted ***");
3901 catch( uno::Exception
& )
3904 ByteString( "OCX_Control::Import - cannot insert control \"" ).
3905 Append( ByteString( sName
, RTL_TEXTENCODING_UTF8
) ).
3906 Append( '"' ).GetBuffer() );
3909 // Calls import on contained pages
3910 return OCX_ContainerControl::Import( xPropSet
);
3912 OSL_TRACE("*** Major problem, no dialog to add controls to ");
3913 DBG_ERROR(" Major problem, no dialog to add controls to ");
3919 OCX_Page::OCX_Page( SotStorageRef
& parent
,
3920 const ::rtl::OUString
& storageName
,
3921 const ::rtl::OUString
& sN
,
3922 const uno::Reference
< container::XNameContainer
> &rDialog
,
3923 OCX_Control
* pParent
):
3924 OCX_ContainerControl(parent
, storageName
, sN
, rDialog
, pParent
),
3925 fUnknown1(0), fEnabled(1), fLocked(0),
3926 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
3927 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3928 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
3929 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
3930 bPictureTiling(FALSE
), nAccelerator(0), nIcon(0), pCaption(0),
3931 nScrollWidth(0), nScrollHeight(0), nIconLen(0), pIcon(0), nPictureLen(0),
3934 msDialogType
= C2U("NotSupported");
3935 mnForeColor
= 0x80000012,
3936 mnBackColor
= 0x8000000F,
3937 bSetInDialog
= true;// UserForm control only
3938 aFontData
.SetHasAlign(TRUE
);
3942 sal_Bool
OCX_Page::Read(SvStorageStream
*pS
)
3944 long nStart
= pS
->Tell();
3946 DBG_ASSERT(0x400==nIdentifier
,
3947 "A control that has a different identifier");
3948 *pS
>> nFixedAreaLen
;
3949 pS
->Read(pBlockFlags
,4);
3951 pS
->SeekRel( nFixedAreaLen
- sizeof( pBlockFlags
) );
3953 ReadAlign( pS
, pS
->Tell() - nStart
, 4);
3955 if (pBlockFlags
[2] & 0x10)
3961 pS
->SeekRel(nFontLen
);
3963 return OCX_ContainerControl::Read(pS
);
3967 sal_Bool
OCX_Page::Import(com::sun::star::uno::Reference
<
3968 com::sun::star::container::XNameContainer
>
3972 uno::Reference
<beans::XPropertySet
> xPropSet( rDialog
, uno::UNO_QUERY
);
3973 if ( xPropSet
.is() )
3975 // apply Step to contained controls
3976 CtrlIterator aEnd
= mpControls
.end();
3977 for (CtrlIterator aIter
= mpControls
.begin(); aIter
!= aEnd
; ++ aIter
)
3979 (*aIter
)->mnStep
= mnStep
;
3981 // Calls import on contained pages
3982 return OCX_ContainerControl::Import( xPropSet
);
3984 OSL_TRACE("*** Major problem, no dialog to add controls to ");
3985 DBG_ERROR("*** Major problem, no dialog to add controls to ");
3989 OCX_Frame::OCX_Frame( SotStorageRef
& parent
,
3990 const ::rtl::OUString
& storageName
,
3991 const ::rtl::OUString
& sN
,
3992 const uno::Reference
< container::XNameContainer
> &rDialog
, OCX_Control
* pParent
):
3993 OCX_ContainerControl(parent
, storageName
, sN
, rDialog
, pParent
),fUnknown1(0),fEnabled(1), fLocked(0),
3994 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
3995 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012),
3996 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
3997 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
3998 bPictureTiling(FALSE
), nAccelerator(0), nIcon(0), pCaption(0),
3999 nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0),
4002 msDialogType
= C2U("com.sun.star.awt.UnoControlGroupBoxModel");
4003 mnForeColor
= 0x80000012;
4004 mnBackColor
= 0x8000000F;
4005 bSetInDialog
= true;// UserForm control only
4006 aFontData
.SetHasAlign(TRUE
);
4010 sal_Bool
OCX_Frame::Read(SvStorageStream
*pS
)
4012 long nStart
= pS
->Tell();
4014 DBG_ASSERT(0x400==nIdentifier
,
4015 "A control that has a different identifier");
4016 *pS
>> nFixedAreaLen
;
4017 pS
->Read(pBlockFlags
,4);
4019 if (pBlockFlags
[0] & 0x01)
4021 DBG_ASSERT(!this, "ARSE");
4023 if (pBlockFlags
[0] & 0x02)
4025 if (pBlockFlags
[0] & 0x04)
4027 if (pBlockFlags
[0] & 0x08)
4029 if (pBlockFlags
[0] & 0x40)
4033 fEnabled
= (nTemp
&0x04)>>2;
4034 fBackStyle
= (nTemp
&0x08)>>3;
4037 fWordWrap
= (nTemp
&0x80)>>7;
4039 fAutoSize
= (nTemp
&0x10)>>4;
4041 if (pBlockFlags
[0] & 0x80)
4043 *pS
>> nBorderStyle
;
4046 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4048 if (pBlockFlags
[1] & 0x01)
4049 *pS
>> nMousePointer
;
4050 if (pBlockFlags
[1] & 0x02)
4051 *pS
>> nKeepScrollBarsVisible
;
4052 if (pBlockFlags
[1] & 0x20)
4053 *pS
>> fUnknown1
; // another unknown 32 bit ( or is 8 or 16 bit with padding ? )
4055 if (pBlockFlags
[1] & 0x80)
4057 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
4059 DBG_ASSERT(nIcon
== 0xFFFF, "Unexpected nIcon");
4062 bool bCaption
= false;
4064 if (pBlockFlags
[2] & 0x01)
4066 if (pBlockFlags
[2] & 0x02)
4067 *pS
>> nSpecialEffect
;
4069 if (pBlockFlags
[2] & 0x04)
4071 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4072 *pS
>> nBorderColor
;
4075 if (pBlockFlags
[2] & 0x08)
4077 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4082 if (pBlockFlags
[2] & 0x10)
4084 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
4087 DBG_ASSERT(nNoIdea
== 0xFFFF, "Expected 0xFFFF, (related to font ?)");
4090 if (pBlockFlags
[2] & 0x20)
4092 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
4094 DBG_ASSERT(nPicture
== 0xFFFF, "Unexpected nIcon");
4097 if (pBlockFlags
[2] & 0x80)
4098 *pS
>> nPictureAlignment
;
4100 if (pBlockFlags
[3] & 0x01)
4101 bPictureTiling
= true;
4103 if (pBlockFlags
[3] & 0x02)
4104 *pS
>> nPictureSizeMode
;
4106 if (pBlockFlags
[3] & 0x04)
4108 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4112 if (pBlockFlags
[3] & 0x08)
4114 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4118 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4121 *pS
>> nScrollWidth
;
4122 *pS
>> nScrollHeight
;
4124 if (pBlockFlags
[1] & 0x10)
4132 lclReadCharArray( *pS
, pCaption
, nCaptionLen
, pS
->Tell() - nStart
);
4135 OUString tempCaption
= lclCreateOUString( pCaption
, nCaptionLen
);
4139 pS
->Read(pIconHeader
,20);
4141 pIcon
= new sal_uInt8
[nIconLen
];
4142 pS
->Read(pIcon
,nIconLen
);
4147 pS
->Read(pPictureHeader
,20);
4149 pPicture
= new sal_uInt8
[nPictureLen
];
4150 pS
->Read(pPicture
,nPictureLen
);
4153 ReadAlign( pS
, pS
->Tell() - nStart
, 4);
4155 if (pBlockFlags
[2] & 0x10)
4161 pS
->SeekRel(nFontLen
);
4164 return OCX_ContainerControl::Read( pS
);
4167 sal_Bool
OCX_Frame::Import(com::sun::star::uno::Reference
<
4168 com::sun::star::beans::XPropertySet
> &rPropSet
)
4170 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
4171 rPropSet
->setPropertyValue(
4172 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp
);
4175 aTmp
<<= lclCreateOUString( pCaption
, nCaptionLen
);
4176 rPropSet
->setPropertyValue( WW8_ASCII2STR("Label"), aTmp
);
4179 // Calls import on contained controls
4180 OCX_ContainerControl::Import( rPropSet
);
4183 OCX_UserForm::OCX_UserForm( SotStorageRef
& parent
,
4184 const OUString
& storageName
,
4186 const ::uno::Reference
< container::XNameContainer
> &rDialog
,
4187 const ::uno::Reference
< lang::XMultiServiceFactory
>& rMsf
):
4188 OCX_ContainerControl(parent
, storageName
, sN
, rDialog
),
4189 nChildrenA(0), fEnabled(1), fLocked(0),
4190 fBackStyle(1), fWordWrap(1), fAutoSize(0), nCaptionLen(0), nVertPos(1),
4191 nHorzPos(7), nMousePointer(0), nBorderColor(0x80000012), nChildrenB(0),
4192 nKeepScrollBarsVisible(3), nCycle(0), nBorderStyle(0), nSpecialEffect(0),
4193 nPicture(0), nPictureAlignment(2), nPictureSizeMode(0),
4194 bPictureTiling(FALSE
), nAccelerator(0), nIcon(0), pCaption(0),
4195 nScrollWidth(0), nScrollHeight(0), nScrollLeft(0), nScrollTop(0), nIconLen(0), pIcon(0), nPictureLen(0)
4197 mnForeColor
= 0x80000012;
4198 mnBackColor
= 0x8000000F;
4199 uno::Reference
< beans::XPropertySet
> xProps( rMsf
, uno::UNO_QUERY
);
4202 xProps
->getPropertyValue(C2S("DefaultContext")) >>= mxCtx
;
4204 aFontData
.SetHasAlign(TRUE
);
4206 sal_Bool
OCX_UserForm::Read(SvStorageStream
*pS
)
4208 long nStart
= pS
->Tell();
4210 DBG_ASSERT(0x400==nIdentifier
,
4211 "A control that has a different identifier");
4212 *pS
>> nFixedAreaLen
;
4213 pS
->Read(pBlockFlags
,4);
4215 if (pBlockFlags
[0] & 0x01)
4217 DBG_ASSERT(!this, "ARSE");
4219 if (pBlockFlags
[0] & 0x02)
4221 if (pBlockFlags
[0] & 0x04)
4223 if (pBlockFlags
[0] & 0x08)
4225 if (pBlockFlags
[0] & 0x40)
4229 fEnabled
= (nTemp
&0x04)>>2;
4230 fBackStyle
= (nTemp
&0x08)>>3;
4233 fWordWrap
= (nTemp
&0x80)>>7;
4235 fAutoSize
= (nTemp
&0x10)>>4;
4237 if (pBlockFlags
[0] & 0x80)
4239 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4240 *pS
>> nBorderStyle
;
4243 sal_uInt16 nFixedOrAlign
;
4244 *pS
>> nFixedOrAlign
;
4246 if (pBlockFlags
[1] & 0x01)
4247 *pS
>> nMousePointer
;
4248 if (pBlockFlags
[1] & 0x02)
4249 *pS
>> nKeepScrollBarsVisible
;
4250 if (pBlockFlags
[1] & 0x20)
4252 sal_uInt32 nUnknown32
;
4255 if (pBlockFlags
[1] & 0x80)
4257 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
4259 DBG_ASSERT(nIcon
== 0xFFFF, "Unexpected nIcon");
4261 if (pBlockFlags
[2] & 0x01)
4263 if (pBlockFlags
[2] & 0x02)
4264 *pS
>> nSpecialEffect
;
4266 if (pBlockFlags
[2] & 0x04)
4268 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4269 *pS
>> nBorderColor
;
4272 if (pBlockFlags
[2] & 0x10)
4274 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
4277 DBG_ASSERT(nNoIdea
== 0xFFFF, "Expected 0xFFFF, (related to font ?)");
4280 if (pBlockFlags
[2] & 0x20)
4282 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
4284 DBG_ASSERT(nPicture
== 0xFFFF, "Unexpected nIcon");
4287 if (pBlockFlags
[2] & 0x80)
4288 *pS
>> nPictureAlignment
;
4290 if (pBlockFlags
[3] & 0x01)
4291 bPictureTiling
= true;
4293 if (pBlockFlags
[3] & 0x02)
4294 *pS
>> nPictureSizeMode
;
4296 if (pBlockFlags
[3] & 0x04)
4298 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4302 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4305 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
4308 *pS
>> nScrollWidth
;
4309 *pS
>> nScrollHeight
;
4311 if (pBlockFlags
[1] & 0x10)
4319 pS
->Read(pIconHeader
,20);
4321 pIcon
= new sal_uInt8
[nIconLen
];
4322 pS
->Read(pIcon
,nIconLen
);
4325 ReadAlign( pS
, pS
->Tell() - nStart
, 4);
4326 if (pBlockFlags
[2] & 0x10)
4332 pS
->SeekRel(nFontLen
);
4336 pS
->Read(pPictureHeader
,20);
4338 long imagePos
= pS
->Tell();
4339 // great embedded object
4340 mxGrfObj
= lcl_readGraphicObject( pS
);
4343 sImageUrl
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX
) );
4344 sImageUrl
= sImageUrl
+ mxGrfObj
->getUniqueID();
4346 // make sure the stream position should be pointing after the image.
4347 pS
->Seek( imagePos
+ nPictureLen
);
4350 sal_Int16 numTrailingRecs
= 0;
4351 *pS
>> numTrailingRecs
;
4352 // seems to be no. of trailing records,
4353 // before container record starts proper
4354 // ( unknown what these trailing records are for)
4355 if ( numTrailingRecs
)
4357 for ( sal_Int16 i
= 0 ; numTrailingRecs
; --numTrailingRecs
, ++i
)
4359 sal_uInt16 nTypeID
= 0;
4360 if ( lcl_handleActiveXControl( pS
, nTypeID
) )
4362 if ( nTypeID
& 0x8000 ) // valid ActiveXID
4363 mActiveXIDMap
[ ( i
| 0x8000 ) ] = nTypeID
;
4367 return OCX_ContainerControl::Read( pS
);
4370 sal_Bool
OCX_UserForm::Import(
4371 uno::Reference
<container::XNameContainer
> &rLib
)
4373 uno::Reference
<beans::XPropertySet
>
4374 xDialogPropSet(mxParent
, uno::UNO_QUERY
);
4375 if ( !xDialogPropSet
.is() )
4377 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
4378 xDialogPropSet
->setPropertyValue(
4379 OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aTmp
);
4380 xDialogPropSet
->setPropertyValue(
4381 OUString(RTL_CONSTASCII_USTRINGPARAM("Title")), aTmp
);
4382 aTmp
<<= ImportColor(mnBackColor
);
4383 xDialogPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
4384 sal_Bool bVBA
= sal_False
;
4385 // Ok we are importing xls but maybe we aren't in VBA mode
4386 // if we are not in VBA mode then we should import sizes etc. ( as before )
4389 xDialogPropSet
->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("VBAForm") ) ) >>= bVBA
;
4391 catch( uno::Exception
& e
)
4394 sal_Int32
nFactor( 3528 );
4397 aTmp
<<= sal_Int32((nWidth
* 2) / 100);
4398 xDialogPropSet
->setPropertyValue(WW8_ASCII2STR("Width"), aTmp
);
4399 aTmp
<<= sal_Int32((nHeight
* 2) / 100);
4400 xDialogPropSet
->setPropertyValue(WW8_ASCII2STR("Height"), aTmp
);
4404 aTmp
<<= sal_Int32( nWidth
+ 160 ); // 100thmm
4405 xDialogPropSet
->setPropertyValue(WW8_ASCII2STR("Width"), aTmp
);
4406 aTmp
<<= sal_Int32(nHeight
+ 662 - 714); //100th mm
4407 xDialogPropSet
->setPropertyValue(WW8_ASCII2STR("Height"), aTmp
);
4411 uno::Reference
<beans::XPropertySet
> xPropSet( mxParent
, uno::UNO_QUERY
);
4412 OCX_ContainerControl::Import( xPropSet
);
4414 uno::Reference
<io::XInputStreamProvider
> xSource
=
4415 xmlscript::exportDialogModel(mxParent
, mxCtx
, pDocSh
->GetModel() );
4416 uno::Any
aSourceAny(uno::makeAny(xSource
));
4417 if (rLib
->hasByName(sName
))
4418 rLib
->replaceByName(sName
, aSourceAny
);
4420 rLib
->insertByName(sName
, aSourceAny
);
4422 if ( sImageUrl
.getLength() )
4427 xDialogPropSet
->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp
);
4429 catch( uno::Exception
& )
4431 OSL_TRACE("OCX_UserForm::Import, Image fails to import");
4437 sal_Bool
OCX_Label::WriteContents(SvStorageStreamRef
&rContents
,
4438 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
4439 const awt::Size
&rSize
)
4441 sal_Bool bRet
= sal_True
;
4442 sal_uInt32 nOldPos
= rContents
->Tell();
4443 rContents
->SeekRel(8);
4444 pBlockFlags
[0] = 0x20;
4449 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
4450 if (aTmp
.hasValue())
4451 aTmp
>>= mnForeColor
;
4452 *rContents
<< ExportColor(mnForeColor
);
4453 pBlockFlags
[0] |= 0x01;
4455 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
4456 if (aTmp
.hasValue())
4457 aTmp
>>= mnBackColor
;
4458 *rContents
<< ExportColor(mnBackColor
);
4459 pBlockFlags
[0] |= 0x02;
4461 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
4462 fEnabled
= any2bool(aTmp
);
4463 sal_uInt8 nTemp
=fEnabled
;
4466 *rContents
<< nTemp
;
4467 *rContents
<< sal_uInt8(0x00);
4469 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("MultiLine"));
4470 fWordWrap
= any2bool(aTmp
);
4473 *rContents
<< nTemp
;
4474 *rContents
<< sal_uInt8(0x00);
4475 pBlockFlags
[0] |= 0x04;
4477 SvxOcxString
aCaption( rPropSet
->getPropertyValue(WW8_ASCII2STR("Label")) );
4478 aCaption
.WriteLenField( *rContents
);
4479 if (aCaption
.HasData())
4480 pBlockFlags
[0] |= 0x08;
4482 WriteAlign(rContents
,4);
4483 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BorderColor"));
4484 if (aTmp
.hasValue())
4485 aTmp
>>= nBorderColor
;
4486 *rContents
<< ExportColor(nBorderColor
);
4487 pBlockFlags
[0] |= 0x80;
4489 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Border"));
4490 sal_Int16 nBorder
= sal_Int16();
4492 sal_uInt8 nNewBorder
;
4493 nSpecialEffect
= ExportBorder(nBorder
,nNewBorder
);
4494 nBorderStyle
= nNewBorder
;
4495 *rContents
<< nBorderStyle
;
4496 pBlockFlags
[1] |= 0x01;
4497 *rContents
<< nSpecialEffect
;
4498 pBlockFlags
[1] |= 0x02;
4500 aCaption
.WriteCharArray( *rContents
);
4502 WriteAlign(rContents
,4);
4503 *rContents
<< rSize
.Width
;
4504 *rContents
<< rSize
.Height
;
4505 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
4507 bRet
= aFontData
.Export(rContents
,rPropSet
);
4509 rContents
->Seek(nOldPos
);
4510 *rContents
<< nStandardId
;
4511 *rContents
<< nFixedAreaLen
;
4513 *rContents
<< pBlockFlags
[0];
4514 *rContents
<< pBlockFlags
[1];
4515 *rContents
<< pBlockFlags
[2];
4516 *rContents
<< pBlockFlags
[3];
4518 DBG_ASSERT((rContents
.Is() &&
4519 (SVSTREAM_OK
==rContents
->GetError())),"damn");
4525 sal_Bool
OCX_Label::Export(SvStorageRef
&rObj
,
4526 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
4527 const awt::Size
&rSize
)
4529 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
4530 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
4531 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
4532 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
4533 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
4534 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
4535 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
4536 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
4537 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
4538 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
4539 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
4540 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
4541 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
4542 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
4543 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
4547 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
4548 xStor
->Write(aCompObj
,sizeof(aCompObj
));
4549 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
4553 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
4554 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
4555 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
4558 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
4559 0x4C, 0x00, 0x61, 0x00, 0x62, 0x00, 0x65, 0x00,
4560 0x6C, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
4564 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
4565 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
4566 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
4569 static sal_uInt8 __READONLY_DATA aTest[] = {
4570 0x00, 0x02, 0x20, 0x00, 0x2B, 0x00, 0x00, 0x00,
4571 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00,
4572 0x06, 0x00, 0x00, 0x80, 0x4C, 0x61, 0x62, 0x65,
4573 0x6C, 0x31, 0x18, 0x00, 0xEC, 0x09, 0x00, 0x00,
4574 0x7B, 0x02, 0x00, 0x00, 0x00, 0x02, 0x20, 0x00,
4575 0x35, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x80,
4576 0xC3, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
4577 0x54, 0x69, 0x6D, 0x65, 0x73, 0x20, 0x4E, 0x65,
4578 0x77, 0x20, 0x52, 0x6F, 0x6D, 0x61, 0x6E, 0x00,
4581 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
4582 return WriteContents(xContents
, rPropSet
, rSize
);
4585 typedef OCX_Control
*(*FNCreate
)();
4598 // Command button MUST be at index 0
4599 {&OCX_CommandButton::Create
,"D7053240-CE69-11CD-a777-00dd01143c57",
4600 form::FormComponentType::COMMANDBUTTON
,"CommandButton"},
4601 // Toggle button MUST be at index 1
4602 {&OCX_ToggleButton::Create
,"8BD21D60-EC42-11CE-9e0d-00aa006002f3",
4603 form::FormComponentType::COMMANDBUTTON
,"ToggleButton"},
4604 {&OCX_Label::Create
, "978C9E23-D4B0-11CE-bf2d-00aa003f40d0",
4605 form::FormComponentType::FIXEDTEXT
,"Label"},
4606 {&OCX_TextBox::Create
,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4607 form::FormComponentType::TEXTFIELD
,"TextBox"},
4608 {&OCX_ListBox::Create
,"8BD21D20-EC42-11CE-9e0d-00aa006002f3",
4609 form::FormComponentType::LISTBOX
,"ListBox"},
4610 {&OCX_ComboBox::Create
,"8BD21D30-EC42-11CE-9e0d-00aa006002f3",
4611 form::FormComponentType::COMBOBOX
,"ComboBox"},
4612 {&OCX_CheckBox::Create
,"8BD21D40-EC42-11CE-9e0d-00aa006002f3",
4613 form::FormComponentType::CHECKBOX
,"CheckBox"},
4614 {&OCX_OptionButton::Create
,"8BD21D50-EC42-11CE-9e0d-00aa006002f3",
4615 form::FormComponentType::RADIOBUTTON
,"OptionButton"},
4616 {&OCX_Image::Create
,"4C599241-6926-101B-9992-00000b65c6f9",
4617 form::FormComponentType::IMAGECONTROL
,"Image"},
4618 {&OCX_FieldControl::Create
,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4619 form::FormComponentType::DATEFIELD
,"TextBox"},
4620 {&OCX_FieldControl::Create
,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4621 form::FormComponentType::TIMEFIELD
,"TextBox"},
4622 {&OCX_FieldControl::Create
,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4623 form::FormComponentType::NUMERICFIELD
,"TextBox"},
4624 {&OCX_FieldControl::Create
,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4625 form::FormComponentType::CURRENCYFIELD
,"TextBox"},
4626 {&OCX_FieldControl::Create
,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4627 form::FormComponentType::PATTERNFIELD
,"TextBox"},
4629 {&OCX_FieldControl::Create
,"8BD21D10-EC42-11CE-9e0d-00aa006002f3",
4630 form::FormComponentType::FORMULAFIELD
,"TextBox"},
4632 {&OCX_ImageButton::Create
,"D7053240-CE69-11CD-a777-00dd01143c57",
4633 form::FormComponentType::IMAGEBUTTON
,"CommandButton"},
4634 {&OCX_SpinButton::Create
,"79176FB0-B7F2-11CE-97ef-00aa006d2776",
4635 form::FormComponentType::SPINBUTTON
,"SpinButton"},
4636 {&OCX_ScrollBar::Create
,"DFD181E0-5E2F-11CE-a449-00aa004a803d",
4637 form::FormComponentType::SCROLLBAR
,"ScrollBar"},
4638 {&OCX_GroupBox::Create
,"",
4639 form::FormComponentType::GROUPBOX
,""},
4640 {&OCX_ProgressBar::Create
,"", form::FormComponentType::CONTROL
,""},
4641 {&HTML_TextBox::Create
,"5512D11A-5CC6-11CF-8d67-00aa00bdce1d", form::FormComponentType::TEXTFIELD
,"TextBox"},
4642 {&HTML_Select::Create
,"5512D122-5CC6-11CF-8d67-00aa00bdce1d",
4643 form::FormComponentType::LISTBOX
,"ListBox"},
4646 const int NO_OCX
= sizeof( aOCXTab
) / sizeof( *aOCXTab
);
4648 SvxMSConvertOCXControls::SvxMSConvertOCXControls(SfxObjectShell
*pDSh
, SwPaM
*pP
) :
4649 pDocSh(pDSh
), pPaM(pP
), nEdit(0), nCheckbox(0)
4651 DBG_ASSERT( pDocSh
, "No DocShell, Cannot do Controls" );
4652 OCX_Control::FillSystemColors();
4655 SvxMSConvertOCXControls::~SvxMSConvertOCXControls()
4659 OCX_Control
* SvxMSConvertOCXControls::OCX_Factory(const String
&sName
)
4661 for (int i
=0;i
<NO_OCX
;i
++)
4663 if ( sName
.EqualsIgnoreCaseAscii( aOCXTab
[i
].sId
))
4664 return(aOCXTab
[i
].pCreate());
4669 OCX_Control
* SvxMSConvertOCXControls::OCX_Factory(
4670 const uno::Reference
< awt::XControlModel
> &rControlModel
,
4671 String
&rId
, String
&rName
)
4676 uno::Reference
< beans::XPropertySet
> xPropSet(
4677 rControlModel
,uno::UNO_QUERY
);
4679 uno::Any aTmp
= xPropSet
->getPropertyValue(
4680 OUString::createFromAscii("ClassId"));
4681 sal_Int16 nClassId
= *(sal_Int16
*) aTmp
.getValue();
4685 There is a truly horrible thing with EditControls and FormattedField
4686 Controls, they both pretend to have an EDITBOX ClassId for compability
4687 reasons, at some stage in the future hopefully there will be a proper
4688 FormulaField ClassId rather than this piggybacking two controls onto the
4689 same ClassId, when this happens uncomment the FORMULAFIELD in the OCX_Tab
4690 and delete this block, cmc.
4692 And also the nClassId for ImageControls is being reported as "CONTROL"
4693 rather than IMAGECONTROL
4695 if (nClassId
== form::FormComponentType::TEXTFIELD
)
4697 uno::Reference
< lang::XServiceInfo
> xInfo(rControlModel
,
4700 supportsService(OUString::createFromAscii(
4701 "com.sun.star.form.component.FormattedField")))
4703 rId
.AppendAscii("8BD21D10-EC42-11CE-9e0d-00aa006002f3");
4704 rName
.AppendAscii("TextBox");
4705 return new OCX_FieldControl
;
4708 else if (nClassId
== form::FormComponentType::CONTROL
)
4710 uno::Reference
< lang::XServiceInfo
> xInfo(rControlModel
,
4713 supportsService(OUString::createFromAscii(
4714 "com.sun.star.form.component.ImageControl")))
4715 nClassId
= form::FormComponentType::IMAGECONTROL
;
4719 const OCX_map
* pEntry
= 0;
4721 // distinguish between push button and toggle button
4722 if( nClassId
== form::FormComponentType::COMMANDBUTTON
)
4724 pEntry
= any2bool(xPropSet
->getPropertyValue(WW8_ASCII2STR("Toggle"))) ?
4725 (aOCXTab
+ 1) : aOCXTab
;
4729 for( int i
= 2; (i
< NO_OCX
) && !pEntry
; ++i
)
4730 if( nClassId
== aOCXTab
[ i
].nId
)
4731 pEntry
= aOCXTab
+ i
;
4736 rId
.AppendAscii( pEntry
->sId
);
4737 rName
.AppendAscii( pEntry
->sName
);
4738 return pEntry
->pCreate();
4745 sal_Bool
SvxMSConvertOCXControls::ReadOCXStream( SvStorageRef
& rSrc1
,
4746 uno::Reference
< drawing::XShape
> *pShapeRef
,BOOL bFloatingCtrl
)
4749 SvStorageStreamRef xCrash
= rSrc1
->OpenSotStream( WW8_ASCII2STR("contents") );
4750 sal_Bool bRet
=sal_False
;
4752 SvStorageStreamRef xSrc2
= rSrc1
->OpenSotStream( WW8_ASCII2STR("\3OCXNAME") );
4753 SvStorageStream
* pSt
= xSrc2
;
4754 pSt
->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN
);
4756 /* #117832# import control name */
4757 OUString controlName
;
4758 bool hasCName
= readOCXNAME( controlName
, pSt
);
4760 xSrc2
= rSrc1
->OpenSotStream( WW8_ASCII2STR("contents") );
4762 pSt
->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN
);
4764 /*Get Class Id of this object, see if it is one of the types
4765 *that this importer can handle, call the appropiate handler
4766 to read that control, and call the appropiate handler to
4770 SvGlobalName aTest
= rSrc1
->GetClassName();
4771 OCX_Control
*pObj
= OCX_Factory(aTest
.GetHexName());
4774 pObj
->pDocSh
= pDocSh
;
4775 /* #117832# set imported control name */
4778 pObj
->sName
= controlName
;
4780 com::sun::star::awt::Size aSz
;
4781 uno::Reference
< form::XFormComponent
> xFComp
;
4782 const uno::Reference
< lang::XMultiServiceFactory
> & rServiceFactory
=
4783 GetServiceFactory();
4784 if(!rServiceFactory
.is())
4786 bRet
= pObj
->FullRead(pSt
);
4788 if (pObj
->Import(rServiceFactory
,xFComp
,aSz
))
4789 bRet
= InsertControl( xFComp
, aSz
,pShapeRef
,bFloatingCtrl
);
4796 sal_Bool
SvxMSConvertOCXControls::ReadOCXExcelKludgeStream(
4797 SvStorageStreamRef
& rSrc1
, uno::Reference
< drawing::XShape
> *
4798 pShapeRef
,BOOL bFloatingCtrl
)
4800 sal_Bool bRet
=sal_False
;
4801 /*Get Class Id of this object, see if it is one of the types
4802 *that this importer can handle, call the appropiate handler
4803 to read that control, and call the appropiate handler to
4806 /*The Excel Kludge is to concatenate a class id with a contents
4807 * stream, and then concatenate all the controls together,
4808 * This means that you should have the cnts stream wound to the
4809 * correct location before passing the control stream in here*/
4810 SvStream
*pSt
= rSrc1
;
4811 pSt
->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN
);
4814 OCX_Control
*pObj
= OCX_Factory(aTest
.GetHexName());
4818 com::sun::star::awt::Size aSz
;
4819 uno::Reference
< form::XFormComponent
> xFComp
;
4820 const uno::Reference
< lang::XMultiServiceFactory
> & rServiceFactory
=
4821 GetServiceFactory();
4822 if(!rServiceFactory
.is())
4824 bRet
= pObj
->FullRead(rSrc1
);
4826 if (pObj
->Import(rServiceFactory
,xFComp
,aSz
))
4827 bRet
= InsertControl( xFComp
, aSz
,pShapeRef
,bFloatingCtrl
);
4834 sal_Bool
SvxMSConvertOCXControls::WriteOCXStream( SvStorageRef
& rSrc1
,
4835 const uno::Reference
< awt::XControlModel
> &rControlModel
,
4836 const awt::Size
&rSize
, String
&rName
)
4838 sal_Bool bRet
=sal_False
;
4840 DBG_ASSERT( rControlModel
.is(), "UNO-Control missing Model, panic!" );
4841 if( !rControlModel
.is() )
4845 uno::Any aTmp
= xPropSet
->getPropertyValue(
4846 OUString::createFromAscii("ClassId"));
4847 sal_Int16 nClassId
= *(sal_Int16
*) aTmp
.getValue();
4851 OCX_Control
*pObj
= OCX_Factory(rControlModel
,sId
,rName
);
4854 uno::Reference
<beans::XPropertySet
> xPropSet(rControlModel
,
4857 /* #117832# - also enable export of control name */
4859 xPropSet
->getPropertyValue(C2S("Name")) >>= sCName
;
4860 pObj
->sName
= sCName
;
4864 String
sFullName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
4865 "Microsoft Forms 2.0 ")));
4866 sFullName
.Append(rName
);
4867 rSrc1
->SetClass(aName
,0x5C,sFullName
);
4868 // ^^^^, this pathetic 0x5c is the magic number
4869 // which the lack of originally blocked the implementation of
4870 // the controls export
4873 bRet
= pObj
->Export(rSrc1
,xPropSet
,rSize
);
4874 SvStorageStreamRef
xStor2( rSrc1
->OpenSotStream( WW8_ASCII2STR("\3OCXNAME")));
4875 /* #117832# - also enable export of control name */
4876 writeOCXNAME( sCName
, xStor2
);
4883 //I think this should work for excel documents, create the "Ctls" stream
4884 //and give it here as rContents, we'll append out streams ole id and
4885 //contents here and that appears to be what Excel is doing
4886 sal_Bool
SvxMSConvertOCXControls::WriteOCXExcelKludgeStream(
4887 SvStorageStreamRef
& rContents
,
4888 const uno::Reference
< awt::XControlModel
> &rControlModel
,
4889 const awt::Size
&rSize
, String
&rName
)
4891 sal_Bool bRet
=sal_False
;
4893 DBG_ASSERT( rControlModel
.is(), "UNO-Control missing Model, panic!" );
4894 if( !rControlModel
.is() )
4898 OCX_Control
*pObj
= OCX_Factory(rControlModel
,sId
,rName
);
4901 uno::Reference
<beans::XPropertySet
> xPropSet(rControlModel
,
4906 String
sFullName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
4907 "Microsoft Forms 2.0 ")));
4908 sFullName
.Append(rName
);
4909 SvStream
*pS
=rContents
;
4911 bRet
= pObj
->WriteContents(rContents
,xPropSet
,rSize
);
4913 // export needs correct stream position
4914 rContents
->Seek( STREAM_SEEK_TO_END
);
4925 sal_Bool
OCX_CheckBox::Import(com::sun::star::uno::Reference
<
4926 com::sun::star::beans::XPropertySet
> &rPropSet
)
4928 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
4929 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
4931 // background color: fBackStyle==0 -> transparent
4933 aTmp
<<= ImportColor(mnBackColor
);
4936 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
4939 if ((!(fEnabled
)) || (fLocked
))
4943 aTmp
= bool2any(bTemp
);
4944 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
4946 bTemp
= fWordWrap
!= 0;
4947 aTmp
= bool2any(bTemp
);
4948 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp
);
4950 aTmp
<<= ImportColor(mnForeColor
);
4951 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
4953 bTemp
= nMultiState
;
4954 aTmp
= bool2any(bTemp
);
4955 rPropSet
->setPropertyValue( WW8_ASCII2STR("TriState"), aTmp
);
4957 aTmp
<<= ImportSpecEffect( nSpecialEffect
);
4958 rPropSet
->setPropertyValue( WW8_ASCII2STR("VisualEffect"), aTmp
);
4962 INT16 nTmp
=pValue
[0]-0x30;
4964 if ( !bSetInDialog
)
4965 rPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultState"), aTmp
);
4967 rPropSet
->setPropertyValue( WW8_ASCII2STR("State"), aTmp
);
4972 aTmp
<<= lclCreateOUString( pCaption
, nCaptionLen
);
4973 rPropSet
->setPropertyValue( WW8_ASCII2STR("Label"), aTmp
);
4976 // #i40279# always centered vertically
4977 aTmp
<<= ::com::sun::star::style::VerticalAlignment_MIDDLE
;
4978 rPropSet
->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp
);
4980 aFontData
.Import(rPropSet
);
4984 sal_Bool
OCX_CheckBox::WriteContents(SvStorageStreamRef
&rContents
,
4985 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
4986 const awt::Size
&rSize
)
4989 sal_Bool bRet
=sal_True
;
4990 sal_uInt32 nOldPos
= rContents
->Tell();
4991 rContents
->SeekRel(12);
4994 pBlockFlags
[1] = 0x01;
4996 pBlockFlags
[3] = 0x80;
5002 uno::Any aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
5003 fEnabled
= any2bool(aTmp
);
5005 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("BackgroundColor"));
5006 fBackStyle
= aTmp
.hasValue() ? 1 : 0;
5008 aTmp
>>= mnBackColor
;
5010 sal_uInt8 nTemp
=fEnabled
;
5015 *rContents
<< nTemp
;
5016 pBlockFlags
[0] |= 0x01;
5017 *rContents
<< sal_uInt8(0x00);
5019 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("MultiLine"));
5020 fWordWrap
= any2bool(aTmp
);
5023 *rContents
<< nTemp
;
5024 *rContents
<< sal_uInt8(0x00);
5026 *rContents
<< ExportColor(mnBackColor
);
5027 pBlockFlags
[0] |= 0x02;
5029 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TextColor"));
5030 if (aTmp
.hasValue())
5031 aTmp
>>= mnForeColor
;
5032 *rContents
<< ExportColor(mnForeColor
);
5033 pBlockFlags
[0] |= 0x04;
5036 *rContents
<< nStyle
;
5037 pBlockFlags
[0] |= 0x40;
5039 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("TriState"));
5040 nMultiState
= any2bool(aTmp
);
5041 *rContents
<< nMultiState
;
5042 pBlockFlags
[2] |= 0x20;
5044 WriteAlign(rContents
,4);
5045 nValueLen
= 1|SVX_MSOCX_COMPRESSED
;
5046 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("DefaultState"));
5047 sal_Int16 nDefault
= sal_Int16();
5049 *rContents
<< nValueLen
;
5050 pBlockFlags
[2] |= 0x40;
5052 SvxOcxString
aCaption( rPropSet
->getPropertyValue(WW8_ASCII2STR("Label")) );
5053 aCaption
.WriteLenField( *rContents
);
5054 if (aCaption
.HasData())
5055 pBlockFlags
[2] |= 0x80;
5057 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("VisualEffect"));
5058 if (aTmp
.hasValue())
5060 sal_Int16 nApiSpecEffect
= sal_Int16();
5061 aTmp
>>= nApiSpecEffect
;
5062 nSpecialEffect
= ExportSpecEffect( nApiSpecEffect
);
5064 WriteAlign(rContents
,4);
5065 *rContents
<< nSpecialEffect
;
5066 pBlockFlags
[3] |= 0x04;
5068 WriteAlign(rContents
,4);
5069 *rContents
<< rSize
.Width
;
5070 *rContents
<< rSize
.Height
;
5073 *rContents
<< sal_uInt8(nDefault
);
5074 *rContents
<< sal_uInt8(0x00);
5076 aCaption
.WriteCharArray( *rContents
);
5078 WriteAlign(rContents
,4);
5079 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
5080 bRet
= aFontData
.Export(rContents
,rPropSet
);
5081 rContents
->Seek(nOldPos
);
5082 *rContents
<< nStandardId
;
5083 *rContents
<< nFixedAreaLen
;
5085 *rContents
<< pBlockFlags
[0];
5086 *rContents
<< pBlockFlags
[1];
5087 *rContents
<< pBlockFlags
[2];
5088 *rContents
<< pBlockFlags
[3];
5089 *rContents
<< pBlockFlags
[4];
5090 *rContents
<< pBlockFlags
[5];
5091 *rContents
<< pBlockFlags
[6];
5092 *rContents
<< pBlockFlags
[7];
5094 DBG_ASSERT((rContents
.Is() &&
5095 (SVSTREAM_OK
==rContents
->GetError())),"damn");
5100 sal_Bool
OCX_CheckBox::Export(SvStorageRef
&rObj
,
5101 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
5102 const awt::Size
&rSize
)
5105 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
5106 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5107 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
5108 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
5109 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
5110 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5111 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5112 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
5113 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
5114 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
5115 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
5116 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
5117 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
5118 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
5119 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5124 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
5125 xStor
->Write(aCompObj
,sizeof(aCompObj
));
5126 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
5130 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
5131 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
5132 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
5135 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
5136 0x43, 0x00, 0x68, 0x00, 0x65, 0x00, 0x63, 0x00,
5137 0x6B, 0x00, 0x42, 0x00, 0x6F, 0x00, 0x78, 0x00,
5138 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
5141 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
5142 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
5143 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
5146 static sal_uInt8 __READONLY_DATA aTest[] = {
5147 0x00, 0x02, 0x34, 0x00, 0x46, 0x01, 0xC0, 0x80,
5148 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00,
5149 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
5150 0x01, 0x00, 0x00, 0x80, 0x09, 0x00, 0x00, 0x80,
5151 0xE2, 0x0E, 0x00, 0x00, 0x95, 0x02, 0x00, 0x00,
5152 0x30, 0x69, 0x1D, 0x00, 0x43, 0x68, 0x65, 0x63,
5153 0x6B, 0x42, 0x6F, 0x78, 0x31, 0x20, 0x52, 0x6F,
5154 0x00, 0x02, 0x20, 0x00, 0x35, 0x00, 0x00, 0x00,
5155 0x0F, 0x00, 0x00, 0x80, 0xC3, 0x00, 0x00, 0x00,
5156 0x00, 0x02, 0x00, 0x00, 0x54, 0x69, 0x6D, 0x65,
5157 0x73, 0x20, 0x4E, 0x65, 0x77, 0x20, 0x52, 0x6F,
5158 0x6D, 0x61, 0x6E, 0x00,
5161 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
5162 return WriteContents(xContents
, rPropSet
, rSize
);
5166 sal_Bool
OCX_FontData::Read(SvStorageStream
*pS
)
5168 long nStart
= pS
->Tell();
5170 *pS
>> nFixedAreaLen
;
5171 pS
->Read(pBlockFlags
,4);
5173 bool bFontName
= (pBlockFlags
[0] & 0x01) != 0;
5175 *pS
>> nFontNameLen
;
5176 if (pBlockFlags
[0] & 0x02)
5180 fBold
= nTmp
& 0x01;
5181 fItalic
= (nTmp
& 0x02) >> 1;
5182 fUnderline
= (nTmp
& 0x04) >> 2;
5183 fStrike
= (nTmp
& 0x08) >> 3;
5184 fUnknown1
= (nTmp
& 0xF0) >> 4;
5189 if (pBlockFlags
[0] & 0x04)
5191 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
5196 if (pBlockFlags
[0] & 0x10)
5198 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
5201 if (pBlockFlags
[0] & 0x40)
5203 *pS
>> nJustification
;
5205 if (pBlockFlags
[0] & 0x80) // font weight before font name
5207 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
5212 lclReadCharArray( *pS
, pFontName
, nFontNameLen
, pS
->Tell() - nStart
);
5214 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
5218 void OCX_FontData::Import(uno::Reference
< beans::XPropertySet
> &rPropSet
)
5223 aTmp
<<= lclCreateOUString( pFontName
, nFontNameLen
);
5224 rPropSet
->setPropertyValue( WW8_ASCII2STR("FontName"), aTmp
);
5229 sal_Int16 nAlign
= ImportAlign(nJustification
);
5231 rPropSet
->setPropertyValue( WW8_ASCII2STR("Align"), aTmp
);
5236 aTmp
<<= awt::FontWeight::BOLD
;
5237 rPropSet
->setPropertyValue( WW8_ASCII2STR("FontWeight"), aTmp
);
5242 aTmp
<<= (sal_Int16
)awt::FontSlant_ITALIC
;
5243 rPropSet
->setPropertyValue( WW8_ASCII2STR("FontSlant"), aTmp
);
5248 aTmp
<<= awt::FontUnderline::SINGLE
;
5249 rPropSet
->setPropertyValue( WW8_ASCII2STR("FontUnderline"), aTmp
);
5254 aTmp
<<= awt::FontStrikeout::SINGLE
;
5255 rPropSet
->setPropertyValue( WW8_ASCII2STR("FontStrikeout"), aTmp
);
5258 // 2004-09-17: very strange way of storing font sizes...
5259 // 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135
5260 // 8pt->165, 9pt->180, 10pt->195, 11pt->225, ...
5261 aTmp
<<= sal_Int16( (nFontSize
<= 30) ? 1 : ((nFontSize
+ 10) / 20) );
5262 rPropSet
->setPropertyValue( WW8_ASCII2STR("FontHeight"), aTmp
);
5265 sal_Bool
OCX_FontData::Export(SvStorageStreamRef
&rContent
,
5266 const uno::Reference
< beans::XPropertySet
> &rPropSet
)
5268 sal_uInt8 nFlags
=0x00;
5269 sal_uInt32 nOldPos
= rContent
->Tell();
5270 rContent
->SeekRel(8);
5271 SvxOcxString aFontName
;
5275 aFontName
= rPropSet
->getPropertyValue(WW8_ASCII2STR("FontName"));
5276 if (!aFontName
.HasData())
5277 aFontName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "Times New Roman" ) );
5278 aFontName
.WriteLenField( *rContent
);
5283 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("FontWeight"));
5290 sal_uInt8 nTmp
=0x01;
5298 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("FontHeight"));
5299 float nFontHeight
= 0;
5300 aTmp
>>= nFontHeight
;
5304 // 2004-09-17: very strange way of storing font sizes:
5305 // 1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135
5306 // 8pt->165, 9pt->180, 10pt->195, 11pt->225, ...
5307 nFontSize
= (nFontHeight
== 1) ? 30 : (static_cast<sal_uInt32
>((nFontHeight
*4+1)/3)*15);
5308 *rContent
<< nFontSize
;
5313 *rContent
<< sal_uInt16(0x0200);
5316 nFlags
|= 0x20; // ?
5318 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Align"));
5320 sal_Int16
nAlign(0);
5321 if (aTmp
.hasValue())
5323 nJustification
= ExportAlign(nAlign
);
5324 *rContent
<< nJustification
;
5328 aFontName
.WriteCharArray( *rContent
);
5329 WriteAlign(rContent
,4);
5331 sal_uInt16 nFixedAreaLn
= static_cast<sal_uInt16
>(rContent
->Tell()-nOldPos
-4);
5332 rContent
->Seek(nOldPos
);
5333 *rContent
<< nStandardId
;
5334 *rContent
<< nFixedAreaLn
;
5335 *rContent
<< nFlags
;
5336 *rContent
<< sal_uInt8(0x00);
5337 *rContent
<< sal_uInt8(0x00);
5338 *rContent
<< sal_uInt8(0x00);
5340 WriteAlign(rContent
,4);
5344 // Doesn't really read anything but just skips the
5346 sal_Bool
OCX_TabStrip::Read(SotStorageStream
*pS
)
5348 const long skipLen
= 0x18;
5350 DBG_ASSERT(nStandardId
==nIdentifier
,
5351 "A control that has a different identifier");
5352 *pS
>> nFixedAreaLen
;
5354 pS
->Read(pBlockFlags
, sizeof(pBlockFlags
));
5355 pS
->SeekRel(skipLen
);
5357 // skip to end of control
5358 pS
->SeekRel(nFixedAreaLen
- sizeof(pBlockFlags
) - sizeof(nNumTabs
) - skipLen
);
5362 sal_Bool
OCX_TabStrip::ReadFontData(SotStorageStream
*pS
)
5364 // Seems like there is a real font record followed by
5365 // a number of blank records ( e.g. nFixedAreaLen = 0 )
5366 // The number of trailing blank records is equal to the number of tabs
5367 OCX_Control::ReadFontData(pS
);
5368 for ( sal_uInt16 index
= 0; index
< nNumTabs
; index
++ )
5370 OCX_Control::Read(pS
); // read trailing records
5375 sal_Bool
OCX_Image::Read(SotStorageStream
*pS
)
5377 ULONG nStart
= pS
->Tell();
5379 DBG_ASSERT(nStandardId
==nIdentifier
,
5380 "A control that has a different identifier");
5381 *pS
>> nFixedAreaLen
;
5383 pS
->Read(pBlockFlags
, sizeof(pBlockFlags
));
5385 bool hasEmbeddedImage
= false;
5387 if ( pBlockFlags
[0] & 0x04 )
5391 if ( pBlockFlags
[0] & 0x08 )
5393 *pS
>> nBorderColor
;
5395 if ( pBlockFlags
[0] & 0x10 )
5399 if ( pBlockFlags
[0] & 0x20 )
5401 *pS
>> nBorderStyle
;
5403 if ( pBlockFlags
[0] & 0x40 )
5405 *pS
>> nMousePointer
;
5407 if ( pBlockFlags
[0] & 0x80 )
5409 *pS
>> nPictureSizeMode
;
5412 if ( pBlockFlags
[ 1 ] & 0x1 )
5414 *pS
>> nSpecialEffect
;
5416 // investigate if valid also for formcontrols, although for controls
5417 // images themselves seem to come through from escher ( as shape, think
5418 // its probably a preview? )
5420 // np a bit of a guess ( until proved incorrect )
5421 if ( pBlockFlags
[ 1 ] & 0x4 )
5423 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
5424 hasEmbeddedImage
= true;
5430 if ( pBlockFlags
[ 1 ] & 0x8 )
5432 ReadAlign(pS
, pS
->Tell() - nStart
, 2);
5433 *pS
>> nPictureAlignment
;
5436 if ( pBlockFlags
[ 1 ] & 0x10 )
5438 bPictureTiling
= true;
5440 if ( pBlockFlags
[1] & 0x20 )
5442 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
5445 fEnabled
= (nTemp
&0x02)>>1;
5446 fBackStyle
= (nTemp
&0x08)>>3;
5452 ReadAlign(pS
, pS
->Tell() - nStart
, 4);
5456 if ( hasEmbeddedImage
)
5458 //image follows this block
5459 //len of image is 0x14 relative to end of this block
5460 pS
->Seek( pS
->Tell() + 0x14 );
5462 sal_uInt32 nImageLen
= 0;
5465 long imagePos
= pS
->Tell();
5467 mxGrfObj
= lcl_readGraphicObject( pS
);
5470 sImageUrl
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX
) );
5471 sImageUrl
= sImageUrl
+ mxGrfObj
->getUniqueID();
5473 // make sure the stream position should be pointing after the image
5474 pS
->Seek( imagePos
+ nImageLen
);
5479 sal_Bool
OCX_Image::Import( uno::Reference
< beans::XPropertySet
> &rPropSet
)
5481 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
5482 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
5485 aTmp
<<= ImportColor(mnBackColor
);
5488 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
5495 aTmp
= bool2any(bTemp
);
5496 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
5497 if ( sImageUrl
.getLength() )
5500 rPropSet
->setPropertyValue( WW8_ASCII2STR("ImageURL"), aTmp
);
5505 sal_Bool
OCX_Image::WriteContents(SvStorageStreamRef
&rContents
,
5506 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
5507 const awt::Size
&rSize
)
5509 sal_Bool bRet
=sal_True
;
5510 sal_uInt32 nOldPos
= rContents
->Tell();
5511 rContents
->SeekRel(8);
5514 pBlockFlags
[1] = 0x02;
5518 uno::Any aTmp
= rPropSet
->getPropertyValue(
5519 WW8_ASCII2STR("BackgroundColor"));
5520 if (aTmp
.hasValue())
5521 aTmp
>>= mnBackColor
;
5522 *rContents
<< ExportColor(mnBackColor
);
5523 pBlockFlags
[0] |= 0x10;
5526 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Border"));
5527 sal_Int16 nBorder
= sal_Int16();
5529 nSpecialEffect
= ExportBorder(nBorder
,nBorderStyle
);
5530 *rContents
<< nBorderStyle
;
5531 pBlockFlags
[0] |= 0x20;
5533 *rContents
<< nSpecialEffect
;
5534 pBlockFlags
[1] |= 0x01;
5536 WriteAlign(rContents
,4);
5538 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("Enabled"));
5539 fEnabled
= any2bool(aTmp
);
5542 sal_uInt8 nTemp
= 0x19;
5543 *rContents
<< nTemp
;
5544 pBlockFlags
[1] |= 0x20;
5545 *rContents
<< sal_uInt8(0x00);
5546 *rContents
<< sal_uInt8(0x00);
5547 *rContents
<< sal_uInt8(0x00);
5550 aTmp
= rPropSet
->getPropertyValue(WW8_ASCII2STR("ImageURL"));
5551 // OUString *pStr = (OUString *)aTmp.getValue();
5552 /*Magically fetch that image and turn it into something that
5553 *we can store in ms controls, wmf,png,jpg are almost certainly
5554 *the options we have for export...*/
5556 WriteAlign(rContents
,4);
5557 *rContents
<< rSize
.Width
;
5558 *rContents
<< rSize
.Height
;
5560 WriteAlign(rContents
,4);
5561 nFixedAreaLen
= static_cast<sal_uInt16
>(rContents
->Tell()-nOldPos
-4);
5563 rContents
->Seek(nOldPos
);
5564 *rContents
<< nStandardId
;
5565 *rContents
<< nFixedAreaLen
;
5567 *rContents
<< pBlockFlags
[0];
5568 *rContents
<< pBlockFlags
[1];
5569 *rContents
<< pBlockFlags
[2];
5570 *rContents
<< pBlockFlags
[3];
5571 DBG_ASSERT((rContents
.Is() &&
5572 (SVSTREAM_OK
==rContents
->GetError())),"damn");
5577 sal_Bool
OCX_Image::Export(SvStorageRef
&rObj
,
5578 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
5579 const awt::Size
&rSize
)
5581 static sal_uInt8 __READONLY_DATA aCompObj
[] = {
5582 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5583 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
5584 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
5585 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
5586 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5587 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5588 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
5589 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
5590 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
5591 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
5592 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
5593 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
5594 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
5595 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5599 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
5600 xStor
->Write(aCompObj
,sizeof(aCompObj
));
5601 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
5605 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
5606 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
5607 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
5610 static sal_uInt8 __READONLY_DATA aOCXNAME
[] = {
5611 0x49, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x67, 0x00,
5612 0x65, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
5616 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
5617 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
5618 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
5621 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
5622 return WriteContents(xContents
, rPropSet
, rSize
);
5625 // ============================================================================
5627 OCX_SpinButton::OCX_SpinButton() :
5628 OCX_Control( OUString( RTL_CONSTASCII_USTRINGPARAM( "SpinButton" ) ) ),
5641 msFormType
= C2U("com.sun.star.form.component.SpinButton");
5642 msDialogType
= C2U("com.sun.star.form.component.SpinButton");
5643 mnBackColor
= 0x8000000F;
5644 mnForeColor
= 0x80000012;
5647 OCX_Control
* OCX_SpinButton::Create()
5649 return new OCX_SpinButton
;
5652 sal_Bool
OCX_SpinButton::Read( SvStorageStream
*pS
)
5654 if( !pS
) return sal_False
;
5656 SvStream
& rStrm
= *pS
;
5657 sal_uInt16 nId
, nSize
;
5658 sal_Int32 nIcon
= 0;
5660 rStrm
>> nId
>> nSize
>> mnBlockFlags
;
5662 DBG_ASSERT( nStandardId
== nId
, "OCX_SpinButton::Read - unknown identifier" );
5664 if( mnBlockFlags
& 0x00000001 ) rStrm
>> mnForeColor
;
5665 if( mnBlockFlags
& 0x00000002 ) rStrm
>> mnBackColor
;
5666 if( mnBlockFlags
& 0x00000004 )
5670 mbEnabled
= (nFlags
& 0x00000002) != 0;
5671 mbLocked
= (nFlags
& 0x00000004) != 0;
5673 if( mnBlockFlags
& 0x00000010 ) rStrm
.SeekRel( 4 ); // mouse pointer
5674 if( mnBlockFlags
& 0x00000020 ) rStrm
>> mnMin
;
5675 if( mnBlockFlags
& 0x00000040 ) rStrm
>> mnMax
;
5676 if( mnBlockFlags
& 0x00000080 ) rStrm
>> mnValue
;
5677 if( mnBlockFlags
& 0x00000100 ) rStrm
.SeekRel( 4 ); // unknown
5678 if( mnBlockFlags
& 0x00000200 ) rStrm
.SeekRel( 4 ); // unknown
5679 if( mnBlockFlags
& 0x00000400 ) rStrm
>> mnSmallStep
;
5680 if( mnBlockFlags
& 0x00000800 ) rStrm
.SeekRel( 4 ); // unknown
5681 if( mnBlockFlags
& 0x00001000 ) rStrm
>> mnPageStep
;
5682 if( mnBlockFlags
& 0x00002000 ) rStrm
>> mnOrient
;
5683 if( mnBlockFlags
& 0x00004000 )
5687 mbPropThumb
= nThumb
!= 0;
5689 if( mnBlockFlags
& 0x00008000 ) rStrm
>> mnDelay
;
5690 if( mnBlockFlags
& 0x00010000 ) rStrm
>> nIcon
;
5691 if( mnBlockFlags
& 0x00000008 ) rStrm
>> nWidth
>> nHeight
;
5695 sal_Int32 nIconSize
;
5698 pS
->SeekRel( nIconSize
);
5704 sal_Bool
OCX_SpinButton::ReadFontData( SvStorageStream
* /* pS */ )
5706 // spin buttons and scroll bars do not support font data
5710 sal_Bool
OCX_SpinButton::Import(com::sun::star::uno::Reference
<
5711 com::sun::star::beans::XPropertySet
> &rPropSet
)
5713 if( (nWidth
< 1) || (nHeight
< 1) )
5716 uno::Any
aTmp( &sName
, getCppuType((OUString
*)0) );
5717 rPropSet
->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp
);
5719 aTmp
<<= ImportColor( mnForeColor
);
5720 rPropSet
->setPropertyValue( WW8_ASCII2STR("SymbolColor"), aTmp
);
5722 aTmp
<<= ImportColor( mnBackColor
);
5723 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
5725 aTmp
= bool2any( mbEnabled
&& !mbLocked
);
5726 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
5731 rPropSet
->setPropertyValue( WW8_ASCII2STR("SpinValue"), aTmp
);
5735 rPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultSpinValue"), aTmp
);
5739 rPropSet
->setPropertyValue( WW8_ASCII2STR("SpinValueMin"), aTmp
);
5742 rPropSet
->setPropertyValue( WW8_ASCII2STR("SpinValueMax"), aTmp
);
5744 aTmp
<<= mnSmallStep
;
5745 rPropSet
->setPropertyValue( WW8_ASCII2STR("SpinIncrement"), aTmp
);
5747 namespace AwtScrollOrient
= ::com::sun::star::awt::ScrollBarOrientation
;
5750 case 0: aTmp
<<= AwtScrollOrient::VERTICAL
; break;
5751 case 1: aTmp
<<= AwtScrollOrient::HORIZONTAL
; break;
5752 default: aTmp
<<= (nWidth
< nHeight
) ? AwtScrollOrient::VERTICAL
: AwtScrollOrient::HORIZONTAL
;
5754 rPropSet
->setPropertyValue( WW8_ASCII2STR("Orientation"), aTmp
);
5756 aTmp
= bool2any( true );
5757 rPropSet
->setPropertyValue( WW8_ASCII2STR("Repeat"), aTmp
);
5760 rPropSet
->setPropertyValue( WW8_ASCII2STR("RepeatDelay"), aTmp
);
5762 aTmp
<<= sal_Int16( 0 );
5763 rPropSet
->setPropertyValue( WW8_ASCII2STR("Border"), aTmp
);
5765 uno::Reference
< frame::XModel
> xModel ( pDocSh
? pDocSh
->GetModel() : NULL
);
5766 lcl_ApplyListSourceAndBindableStuff( xModel
, rPropSet
, msCtrlSource
, msRowSource
);
5771 sal_Bool
OCX_SpinButton::Export(
5773 const uno::Reference
< beans::XPropertySet
>& rPropSet
,
5774 const awt::Size
& rSize
)
5776 static sal_uInt8 __READONLY_DATA aCompObj
[] =
5778 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
5779 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
5780 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
5781 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
5782 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
5783 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
5784 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
5785 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
5786 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
5787 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
5788 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
5789 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
5790 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
5791 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5796 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
5797 xStor
->Write(aCompObj
,sizeof(aCompObj
));
5798 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
5802 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
5803 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
5804 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
5807 static sal_uInt8 __READONLY_DATA aOCXNAME
[] =
5809 0x53, 0x00, 0x70, 0x00, 0x69, 0x00, 0x6E, 0x00,
5810 0x42, 0x00, 0x75, 0x00, 0x74, 0x00, 0x74, 0x00,
5811 0x6F, 0x00, 0x6E, 0x00, 0x31, 0x00, 0x00, 0x00,
5816 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
5817 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
5818 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
5821 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
5822 return WriteContents(xContents
, rPropSet
, rSize
);
5825 sal_Bool
OCX_SpinButton::WriteContents(
5826 SvStorageStreamRef
&rObj
,
5827 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
5828 const awt::Size
& rSize
)
5833 mnBlockFlags
= 0x00000008;
5834 nWidth
= rSize
.Width
;
5835 nHeight
= rSize
.Height
;
5837 GetInt32Property( mnForeColor
, rPropSet
, WW8_ASCII2STR( "SymbolColor" ), 0x00000001 );
5838 GetInt32Property( mnBackColor
, rPropSet
, WW8_ASCII2STR( "BackgroundColor" ), 0x00000002 );
5839 GetBoolProperty( mbEnabled
, rPropSet
, WW8_ASCII2STR( "Enabled" ), 0x00000304 );
5840 GetInt32Property( mnMin
, rPropSet
, WW8_ASCII2STR( "SpinValueMin" ), 0x00000020 );
5841 GetInt32Property( mnMax
, rPropSet
, WW8_ASCII2STR( "SpinValueMax" ), 0x00000040 );
5842 GetInt32Property( mnValue
, rPropSet
, WW8_ASCII2STR( "SpinValue" ), 0x00000080 );
5843 GetInt32Property( mnSmallStep
, rPropSet
, WW8_ASCII2STR( "SpinIncrement" ), 0x00000800 );
5844 GetInt32Property( mnDelay
, rPropSet
, WW8_ASCII2STR( "RepeatDelay" ), 0x00008000 );
5846 namespace AwtScrollOrient
= ::com::sun::star::awt::ScrollBarOrientation
;
5847 sal_Int16 nApiOrient
= sal_Int16();
5848 if( rPropSet
->getPropertyValue( WW8_ASCII2STR( "Orientation" ) ) >>= nApiOrient
)
5849 UpdateInt32Property( mnOrient
, (nApiOrient
== AwtScrollOrient::VERTICAL
) ? 0 : 1, 0x00002000 );
5851 return WriteData( *rObj
);
5854 void OCX_SpinButton::UpdateInt32Property(
5855 sal_Int32
& rnCoreValue
, sal_Int32 nNewValue
, sal_Int32 nBlockFlag
)
5857 if( nNewValue
!= rnCoreValue
)
5859 rnCoreValue
= nNewValue
;
5860 mnBlockFlags
|= nBlockFlag
;
5864 void OCX_SpinButton::GetInt32Property(
5865 sal_Int32
& rnCoreValue
, const uno::Reference
< beans::XPropertySet
>& rxPropSet
,
5866 const OUString
& rPropName
, sal_Int32 nBlockFlag
)
5868 sal_Int32 nNewValue
= 0;
5869 if( rxPropSet
->getPropertyValue( rPropName
) >>= nNewValue
)
5870 UpdateInt32Property( rnCoreValue
, nNewValue
, nBlockFlag
);
5873 void OCX_SpinButton::UpdateBoolProperty(
5874 bool& rbCoreValue
, bool bNewValue
, sal_Int32 nBlockFlag
)
5876 if( bNewValue
!= rbCoreValue
)
5878 rbCoreValue
= bNewValue
;
5879 mnBlockFlags
|= nBlockFlag
;
5883 void OCX_SpinButton::GetBoolProperty(
5884 bool& rbCoreValue
, const uno::Reference
< beans::XPropertySet
>& rxPropSet
,
5885 const OUString
& rPropName
, sal_Int32 nBlockFlag
)
5887 UpdateBoolProperty( rbCoreValue
,
5888 any2bool( rxPropSet
->getPropertyValue( rPropName
) ), nBlockFlag
);
5891 sal_Bool
OCX_SpinButton::WriteData( SvStream
& rStrm
) const
5893 sal_Bool bRet
= sal_True
;
5894 ULONG nStartPos
= rStrm
.Tell();
5896 rStrm
<< sal_Int32( 0 ) << mnBlockFlags
;
5898 if( mnBlockFlags
& 0x00000001 ) rStrm
<< ExportColor( mnForeColor
);
5899 if( mnBlockFlags
& 0x00000002 ) rStrm
<< ExportColor( mnBackColor
);
5900 if( mnBlockFlags
& 0x00000004 )
5902 sal_Int32 nFlags
= 0x00000019; // always set
5903 if( mbEnabled
) nFlags
|= 0x00000002;
5904 if( mbLocked
) nFlags
|= 0x00000004;
5907 if( mnBlockFlags
& 0x00000020 ) rStrm
<< mnMin
;
5908 if( mnBlockFlags
& 0x00000040 ) rStrm
<< mnMax
;
5909 if( mnBlockFlags
& 0x00000080 ) rStrm
<< mnValue
;
5910 if( mnBlockFlags
& 0x00000100 ) rStrm
<< sal_Int32( 0 ); // unknown
5911 if( mnBlockFlags
& 0x00000200 ) rStrm
<< sal_Int32( 0 ); // unknown
5912 if( mnBlockFlags
& 0x00000400 ) rStrm
<< sal_Int32( 0 ); // unknown
5913 if( mnBlockFlags
& 0x00000800 ) rStrm
<< mnSmallStep
;
5914 if( mnBlockFlags
& 0x00001000 ) rStrm
<< mnPageStep
;
5915 if( mnBlockFlags
& 0x00002000 ) rStrm
<< mnOrient
;
5916 if( mnBlockFlags
& 0x00004000 ) rStrm
<< sal_Int32( mbPropThumb
? 1 : 0 );
5917 if( mnBlockFlags
& 0x00008000 ) rStrm
<< mnDelay
;
5918 if( mnBlockFlags
& 0x00000008 ) rStrm
<< nWidth
<< nHeight
;
5920 sal_uInt16 nSize
= static_cast< sal_uInt16
>( rStrm
.Tell() - nStartPos
- 4 );
5921 rStrm
.Seek( nStartPos
);
5922 rStrm
<< nStandardId
<< nSize
;
5924 DBG_ASSERT( rStrm
.GetError() == SVSTREAM_OK
, "OCX_SpinButton::WriteData - error in stream" );
5928 // ============================================================================
5930 OCX_ScrollBar::OCX_ScrollBar()
5932 sName
= OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollBar" ) );
5934 msFormType
= C2U("com.sun.star.form.component.ScrollBar");
5935 msDialogType
= C2U("com.sun.star.form.component.ScrollBar");
5939 OCX_Control
* OCX_ScrollBar::Create()
5941 return new OCX_ScrollBar
;
5944 sal_Bool
OCX_ScrollBar::Import(com::sun::star::uno::Reference
<
5945 com::sun::star::beans::XPropertySet
> &rPropSet
)
5947 if( (nWidth
< 1) || (nHeight
< 1) )
5950 uno::Any
aTmp( &sName
, getCppuType((OUString
*)0) );
5951 rPropSet
->setPropertyValue( WW8_ASCII2STR( "Name" ), aTmp
);
5953 aTmp
<<= ImportColor( mnForeColor
);
5954 rPropSet
->setPropertyValue( WW8_ASCII2STR("SymbolColor"), aTmp
);
5956 aTmp
<<= ImportColor( mnBackColor
);
5957 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
5959 aTmp
= bool2any( mbEnabled
&& !mbLocked
);
5960 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
5965 rPropSet
->setPropertyValue( WW8_ASCII2STR("ScrollValue"), aTmp
);
5969 rPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultScrollValue"), aTmp
);
5973 rPropSet
->setPropertyValue( WW8_ASCII2STR("ScrollValueMin"), aTmp
);
5976 rPropSet
->setPropertyValue( WW8_ASCII2STR("ScrollValueMax"), aTmp
);
5978 aTmp
<<= mnSmallStep
;
5979 rPropSet
->setPropertyValue( WW8_ASCII2STR("LineIncrement"), aTmp
);
5981 aTmp
<<= mnPageStep
;
5982 rPropSet
->setPropertyValue( WW8_ASCII2STR("BlockIncrement"), aTmp
);
5983 if( mbPropThumb
&& (mnPageStep
> 0) )
5984 rPropSet
->setPropertyValue( WW8_ASCII2STR("VisibleSize"), aTmp
);
5986 namespace AwtScrollOrient
= ::com::sun::star::awt::ScrollBarOrientation
;
5989 case 0: aTmp
<<= AwtScrollOrient::VERTICAL
; break;
5990 case 1: aTmp
<<= AwtScrollOrient::HORIZONTAL
; break;
5991 default: aTmp
<<= (nWidth
< nHeight
) ? AwtScrollOrient::VERTICAL
: AwtScrollOrient::HORIZONTAL
;
5993 rPropSet
->setPropertyValue( WW8_ASCII2STR("Orientation"), aTmp
);
5996 rPropSet
->setPropertyValue( WW8_ASCII2STR("RepeatDelay"), aTmp
);
5998 aTmp
<<= sal_Int16( 0 );
5999 rPropSet
->setPropertyValue( WW8_ASCII2STR("Border"), aTmp
);
6001 uno::Reference
< frame::XModel
> xModel ( pDocSh
? pDocSh
->GetModel() : NULL
);
6002 lcl_ApplyListSourceAndBindableStuff( xModel
, rPropSet
, msCtrlSource
, msRowSource
);
6007 sal_Bool
OCX_ScrollBar::Export(
6009 const uno::Reference
< beans::XPropertySet
>& rPropSet
,
6010 const awt::Size
& rSize
)
6012 static sal_uInt8 __READONLY_DATA aCompObj
[] =
6014 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
6015 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
6016 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
6017 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
6018 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
6019 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
6020 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
6021 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
6022 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
6023 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
6024 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
6025 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
6026 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
6027 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
6028 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
6032 SvStorageStreamRef
xStor( rObj
->OpenSotStream( C2S("\1CompObj")));
6033 xStor
->Write(aCompObj
,sizeof(aCompObj
));
6034 DBG_ASSERT((xStor
.Is() && (SVSTREAM_OK
== xStor
->GetError())),"damn");
6038 SvStorageStreamRef
xStor3( rObj
->OpenSotStream( C2S("\3ObjInfo")));
6039 xStor3
->Write(aObjInfo
,sizeof(aObjInfo
));
6040 DBG_ASSERT((xStor3
.Is() && (SVSTREAM_OK
== xStor3
->GetError())),"damn");
6043 static sal_uInt8 __READONLY_DATA aOCXNAME
[] =
6045 0x53, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6F, 0x00,
6046 0x6C, 0x00, 0x6C, 0x00, 0x42, 0x00, 0x61, 0x00,
6047 0x72, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00
6051 SvStorageStreamRef
xStor2( rObj
->OpenSotStream( C2S("\3OCXNAME")));
6052 xStor2
->Write(aOCXNAME
,sizeof(aOCXNAME
));
6053 DBG_ASSERT((xStor2
.Is() && (SVSTREAM_OK
== xStor2
->GetError())),"damn");
6056 SvStorageStreamRef
xContents( rObj
->OpenSotStream( C2S("contents")));
6057 return WriteContents(xContents
, rPropSet
, rSize
);
6060 sal_Bool
OCX_ScrollBar::WriteContents(
6061 SvStorageStreamRef
&rObj
,
6062 const uno::Reference
< beans::XPropertySet
> &rPropSet
,
6063 const awt::Size
& rSize
)
6068 mnBlockFlags
= 0x00000008;
6069 nWidth
= rSize
.Width
;
6070 nHeight
= rSize
.Height
;
6072 GetInt32Property( mnForeColor
, rPropSet
, WW8_ASCII2STR( "SymbolColor" ), 0x00000001 );
6073 GetInt32Property( mnBackColor
, rPropSet
, WW8_ASCII2STR( "BackgroundColor" ), 0x00000002 );
6074 GetBoolProperty( mbEnabled
, rPropSet
, WW8_ASCII2STR( "Enabled" ), 0x00000304 );
6075 GetInt32Property( mnMin
, rPropSet
, WW8_ASCII2STR( "ScrollValueMin" ), 0x00000020 );
6076 GetInt32Property( mnMax
, rPropSet
, WW8_ASCII2STR( "ScrollValueMax" ), 0x00000040 );
6077 GetInt32Property( mnValue
, rPropSet
, WW8_ASCII2STR( "ScrollValue" ), 0x00000080 );
6078 GetInt32Property( mnSmallStep
, rPropSet
, WW8_ASCII2STR( "LineIncrement" ), 0x00000800 );
6079 GetInt32Property( mnPageStep
, rPropSet
, WW8_ASCII2STR( "BlockIncrement" ), 0x00001000 );
6080 GetInt32Property( mnDelay
, rPropSet
, WW8_ASCII2STR( "RepeatDelay" ), 0x00008000 );
6082 namespace AwtScrollOrient
= ::com::sun::star::awt::ScrollBarOrientation
;
6083 sal_Int16 nApiOrient
= sal_Int16();
6084 if( rPropSet
->getPropertyValue( WW8_ASCII2STR( "Orientation" ) ) >>= nApiOrient
)
6085 UpdateInt32Property( mnOrient
, (nApiOrient
== AwtScrollOrient::VERTICAL
) ? 0 : 1, 0x00002000 );
6087 UpdateBoolProperty( mbPropThumb
, true, 0x00004000 );
6089 return WriteData( *rObj
);
6092 OCX_ProgressBar::OCX_ProgressBar() :
6093 OCX_Control( OUString( RTL_CONSTASCII_USTRINGPARAM( "ProgressBar" ) ) ),
6100 msDialogType
= C2U("com.sun.star.awt.UnoControlProgressBarModel");
6101 bSetInDialog
= true;
6104 sal_Bool
OCX_ProgressBar::Read( SvStorageStream
*pS
)
6107 *pS
>> nWidth
>> nHeight
;
6111 *pS
>> fMin
>> fMax
;
6112 nMin
= static_cast< sal_Int32
>( fMin
);
6113 nMax
= static_cast< sal_Int32
>( fMax
);
6114 bool bVisible
= true;
6115 sal_uInt8 pUnknownFlags
[4];
6116 pS
->Read(pUnknownFlags
,4);
6118 // complete guess, but we don't handle visible anyway
6119 if ( ( pUnknownFlags
[2] & 0x8 ) && ( pUnknownFlags
[2] & 0x2 ) )
6125 // seems these work out
6126 bFixedSingle
= (nFlags
& 0x01) != 0;
6127 bEnabled
= (nFlags
& 0x02) != 0;
6128 b3d
= (nFlags
& 0x04) != 0;
6133 OCX_Control
* OCX_ProgressBar::Create()
6135 return new OCX_ProgressBar
;
6138 sal_Bool
OCX_ProgressBar::Import(uno::Reference
< beans::XPropertySet
> &rPropSet
)
6140 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
6141 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
6143 rPropSet
->setPropertyValue( WW8_ASCII2STR("ProgressValueMax"), aTmp
);
6145 rPropSet
->setPropertyValue( WW8_ASCII2STR("ProgressValueMin"), aTmp
);
6148 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), uno::makeAny( sal_False
) );
6151 // ============================================================================
6156 sal_Bool
HTML_TextBox::Import(com::sun::star::uno::Reference
<
6157 com::sun::star::beans::XPropertySet
> &rPropSet
)
6159 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
6160 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
6162 aTmp
= bool2any( fEnabled
!= 0 );
6163 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
6165 aTmp
= bool2any( fLocked
!= 0 );
6166 rPropSet
->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp
);
6168 aTmp
= bool2any( fHideSelection
!= 0 );
6169 rPropSet
->setPropertyValue( WW8_ASCII2STR( "HideInactiveSelection" ), aTmp
);
6171 aTmp
<<= ImportColor(mnForeColor
);
6172 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
6174 aTmp
<<= ImportColor(mnBackColor
);
6175 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
6177 aTmp
<<= ImportBorder(nSpecialEffect
,nBorderStyle
);
6178 rPropSet
->setPropertyValue( WW8_ASCII2STR("Border"), aTmp
);
6180 aTmp
<<= ImportColor( nBorderColor
);
6181 rPropSet
->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp
);
6183 aTmp
= bool2any( fMultiLine
!= 0 );
6184 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiLine"), aTmp
);
6186 sal_uInt16 nTmp
= static_cast<sal_uInt16
>(nMaxLength
);
6188 rPropSet
->setPropertyValue( WW8_ASCII2STR("MaxTextLen"), aTmp
);
6191 sal_Bool bTemp1
,bTemp2
;
6192 uno::Any aBarsH
,aBarsV
;
6214 aBarsH
= bool2any(bTemp1
);
6215 aBarsV
= bool2any(bTemp2
);
6216 rPropSet
->setPropertyValue( WW8_ASCII2STR("HScroll"), aBarsH
);
6217 rPropSet
->setPropertyValue( WW8_ASCII2STR("VScroll"), aBarsV
);
6219 nTmp
= nPasswordChar
;
6221 rPropSet
->setPropertyValue( WW8_ASCII2STR("EchoChar"), aTmp
);
6225 aTmp
<<= lclCreateOUString( pValue
, nValueLen
);
6226 // DefaultText seems to no longer be in UnoEditControlModel
6229 rPropSet
->setPropertyValue( WW8_ASCII2STR("Text"), aTmp
);
6233 rPropSet
->setPropertyValue( WW8_ASCII2STR("DefaultText"), aTmp
);
6237 // aFontData.Import(rPropSet);
6241 sal_Bool
HTML_TextBox::Read(SotStorageStream
*pS
)
6246 sal_Bool
HTML_TextBox::ReadFontData(SotStorageStream
*pS
)
6252 sal_Bool
HTML_Select::Import(com::sun::star::uno::Reference
<
6253 com::sun::star::beans::XPropertySet
> &rPropSet
)
6255 uno::Any
aTmp(&sName
,getCppuType((OUString
*)0));
6256 rPropSet
->setPropertyValue( WW8_ASCII2STR("Name"), aTmp
);
6258 sal_Bool bTmp
=fEnabled
;
6259 aTmp
= bool2any(bTmp
);
6260 rPropSet
->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp
);
6263 aTmp
= bool2any(bTmp
);
6264 rPropSet
->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp
);
6266 aTmp
<<= ImportColor(mnForeColor
);
6267 rPropSet
->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp
);
6269 sal_Bool bTemp
= nMultiState
;
6270 aTmp
= bool2any(bTemp
);
6271 rPropSet
->setPropertyValue( WW8_ASCII2STR("MultiSelection"), aTmp
);
6273 aTmp
<<= ImportColor(mnBackColor
);
6274 rPropSet
->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp
);
6276 aTmp
<<= ImportBorder(nSpecialEffect
,nBorderStyle
);
6277 rPropSet
->setPropertyValue( WW8_ASCII2STR("Border"), aTmp
);
6279 aTmp
<<= ImportColor( nBorderColor
);
6280 rPropSet
->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp
);
6282 if ( msListData
.getLength() )
6284 aTmp
<<= msListData
;
6285 rPropSet
->setPropertyValue( WW8_ASCII2STR("StringItemList"), aTmp
);
6286 if ( msIndices
.getLength() )
6289 rPropSet
->setPropertyValue( WW8_ASCII2STR("SelectedItems"), aTmp
);
6292 rPropSet
->setPropertyValue( WW8_ASCII2STR("Dropdown"), uno::makeAny( sal_True
));
6297 sal_Bool
HTML_Select::Read(SotStorageStream
*pS
)
6299 static rtl::OUString
sTerm( RTL_CONSTASCII_USTRINGPARAM("</SELECT") );
6300 static String
sMultiple( RTL_CONSTASCII_USTRINGPARAM("<SELECT MULTIPLE") );
6301 static String
sSelected( RTL_CONSTASCII_USTRINGPARAM("OPTION SELECTED") );
6303 // we should be positioned at the html fragment ( really we should
6304 // reorganise the reading of controls from excel such that the position and
6305 // lenght of the associated record in the Ctls stream is available
6306 // But since we don't know about the lenght of the stream lets read the stream
6307 // until we reach the end of the fragment
6308 // I wish I know where there was a html parser in openoffice
6309 OUStringBuffer
buf(40);
6310 bool bTerminate
= false;
6315 sal_Unicode uni
= static_cast< sal_Unicode
>( ch
);
6316 // if the buffer ends with </SELECT> we are done
6319 rtl::OUString
bufContents( buf
.getStr() );
6320 if ( bufContents
.indexOf( sTerm
) != -1 )
6324 buf
.append( &uni
, 1 );
6326 } while ( !pS
->IsEof() && !bTerminate
);
6327 String data
= buf
.makeStringAndClear();
6329 // replace crlf with lf
6330 data
.SearchAndReplaceAll( String( RTL_CONSTASCII_USTRINGPARAM( "\x0D\x0A" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "\x0A" ) ) );
6331 std::vector
< rtl::OUString
> listValues
;
6332 std::vector
< sal_Int16
> selectedIndices
;
6334 // Ultra hacky parser for the info
6335 sal_Int32 nTokenCount
= data
.GetTokenCount( '\n' );
6337 for ( sal_Int32 nToken
= 0; nToken
< nTokenCount
; ++nToken
)
6339 String
sLine( data
.GetToken( nToken
, '\n' ) );
6340 if ( !nToken
) // first line will tell us if multiselect is enabled
6342 if ( sLine
.CompareTo( sMultiple
, sMultiple
.Len() ) == COMPARE_EQUAL
)
6345 // skip first and last lines, no data there
6346 else if ( nToken
< nTokenCount
- 1)
6348 if ( sLine
.GetTokenCount( '>' ) )
6350 String displayValue
= sLine
.GetToken( 1, '>' );
6351 if ( displayValue
.Len() )
6353 // Really we should be using a proper html parser
6354 // escaping some common bits to be escaped
6355 displayValue
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "<" ) ), String( RTL_CONSTASCII_USTRINGPARAM("<") ) );
6356 displayValue
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( ">" ) ), String( RTL_CONSTASCII_USTRINGPARAM(">") ) );
6357 displayValue
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( """ ) ), String( RTL_CONSTASCII_USTRINGPARAM("\"") ) );
6358 displayValue
.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&" ) ), String( RTL_CONSTASCII_USTRINGPARAM("&") ) );
6359 listValues
.push_back( displayValue
);
6360 if( sLine
.Search( sSelected
) != STRING_NOTFOUND
)
6361 selectedIndices
.push_back( static_cast< sal_Int16
>( listValues
.size() ) - 1 );
6366 if ( listValues
.size() )
6368 msListData
.realloc( listValues
.size() );
6369 sal_Int32 index
= 0;
6370 for( std::vector
< rtl::OUString
>::iterator it
= listValues
.begin(); it
!= listValues
.end(); ++it
, ++index
)
6371 msListData
[ index
] = *it
;
6373 if ( selectedIndices
.size() )
6375 msIndices
.realloc( selectedIndices
.size() );
6376 sal_Int32 index
= 0;
6377 for( std::vector
< sal_Int16
>::iterator it
= selectedIndices
.begin(); it
!= selectedIndices
.end(); ++it
, ++index
)
6378 msIndices
[ index
] = *it
;
6383 sal_Bool
HTML_Select::ReadFontData(SotStorageStream
*pS
)
6387 /* vi:set tabstop=4 shiftwidth=4 expandtab: */