[ooo-build-commit] patches/dev300
Noel Power
noelp at kemper.freedesktop.org
Mon Jul 27 05:43:14 PDT 2009
patches/dev300/apply | 1
patches/dev300/svx-hacky-htmlselect-control-import.diff | 210 ++++++++++++++++
2 files changed, 211 insertions(+)
New commits:
commit 0bbe0ae7f9b334e74fd9b4e5ee8029e112b6e999
Author: Noel Power <noel.power at novell.com>
Date: Mon Jul 27 13:40:36 2009 +0100
allow HTMLSelect activex objects to be read on import from Excel
* patches/dev300/apply: fix for n#523191
* patches/dev300/svx-hacky-htmlselect-control-import.diff: fix for n#523191 hacky fix for filter to read HTMLSelect object
diff --git a/patches/dev300/apply b/patches/dev300/apply
index a31a2cb..83ba82c 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -2758,6 +2758,7 @@ field-patch.diff, n#248354, freuter
# FIXME: hack to fix split build by pmladek
field-patch-split-build.diff, n#248354, freuter
sw-import-html-controls.diff, n#485609, freuter
+svx-hacky-htmlselect-control-import.diff, n#523191, noelpwer
sd-slideshow-slideshowview-transformation-fix.diff, rodo
diff --git a/patches/dev300/svx-hacky-htmlselect-control-import.diff b/patches/dev300/svx-hacky-htmlselect-control-import.diff
new file mode 100644
index 0000000..2e1322d
--- /dev/null
+++ b/patches/dev300/svx-hacky-htmlselect-control-import.diff
@@ -0,0 +1,210 @@
+diff --git svx/inc/svx/msocximex.hxx svx/inc/svx/msocximex.hxx
+index c56be5f..ef28415 100644
+--- svx/inc/svx/msocximex.hxx
++++ svx/inc/svx/msocximex.hxx
+@@ -1384,6 +1384,41 @@ public:
+ const com::sun::star::awt::Size& rSize );
+ };
+
++class HTML_Select : public OCX_ModernControl
++{
++public:
++ HTML_Select() : OCX_ModernControl(rtl::OUString::createFromAscii("TextBox")) {
++ msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.ListBox");
++ msDialogType = rtl::OUString::createFromAscii("com.sun.star.form.component.ListBox");
++ mnBackColor = 0x80000005L;
++ mnForeColor = 0x80000008L;
++ nBorderColor = 0x80000006L;
++ aFontData.SetHasAlign(TRUE);
++ fEnabled = true;
++ nMultiState =false;
++ }
++
++ using OCX_ModernControl::Import; // to not hide the other two import methods
++ virtual sal_Bool Import(com::sun::star::uno::Reference<
++ com::sun::star::beans::XPropertySet> &rPropSet);
++ /*
++ sal_Bool Export(SotStorageRef &rObj,
++ const com::sun::star::uno::Reference<
++ com::sun::star::beans::XPropertySet> &rPropSet,
++ const com::sun::star::awt::Size& rSize);
++ sal_Bool WriteContents(SotStorageStreamRef &rObj,
++ const com::sun::star::uno::Reference<
++ com::sun::star::beans::XPropertySet> &rPropSet,
++ const com::sun::star::awt::Size& rSize);
++ */
++ static OCX_Control *Create() { return new HTML_Select;}
++
++ virtual sal_Bool Read(SotStorageStream *pS);
++ virtual sal_Bool ReadFontData(SotStorageStream *pS);
++ com::sun::star::uno::Sequence< rtl::OUString > msListData;
++ com::sun::star::uno::Sequence< sal_Int16 > msIndices;
++};
++
+
+ class HTML_TextBox : public OCX_ModernControl
+ {
+diff --git svx/source/msfilter/msocximex.cxx svx/source/msfilter/msocximex.cxx
+index ca53640..e00e942 100644
+--- svx/source/msfilter/msocximex.cxx
++++ svx/source/msfilter/msocximex.cxx
+@@ -98,7 +98,7 @@
+ #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+ #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+ #include <svtools/filterutils.hxx>
+-
++
+ #ifndef C2S
+ #define C2S(cChar) String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(cChar))
+ #endif
+@@ -4642,7 +4642,8 @@ OCX_map aOCXTab[] =
+ form::FormComponentType::GROUPBOX,""},
+ {&OCX_ProgressBar::Create,"", form::FormComponentType::CONTROL,""},
+ {&HTML_TextBox::Create,"5512D11A-5CC6-11CF-8d67-00aa00bdce1d", form::FormComponentType::TEXTFIELD,"TextBox"},
+- {&HTML_TextBox::Create,"5512D124-5CC6-11CF-8d67-00aa00bdce1d", form::FormComponentType::TEXTFIELD,"TextBox"}
++ {&HTML_Select::Create,"5512D122-5CC6-11CF-8d67-00aa00bdce1d",
++ form::FormComponentType::LISTBOX,"ListBox"},
+ };
+
+ const int NO_OCX = sizeof( aOCXTab ) / sizeof( *aOCXTab );
+@@ -6250,5 +6251,140 @@ sal_Bool HTML_TextBox::ReadFontData(SotStorageStream *pS)
+ return sal_True;
+ }
+
++// HTML_Select
++sal_Bool HTML_Select::Import(com::sun::star::uno::Reference<
++ com::sun::star::beans::XPropertySet> &rPropSet)
++{
++ uno::Any aTmp(&sName,getCppuType((OUString *)0));
++ rPropSet->setPropertyValue( WW8_ASCII2STR("Name"), aTmp );
++
++ sal_Bool bTmp=fEnabled;
++ aTmp = bool2any(bTmp);
++ rPropSet->setPropertyValue( WW8_ASCII2STR("Enabled"), aTmp);
++
++ bTmp=fLocked;
++ aTmp = bool2any(bTmp);
++ rPropSet->setPropertyValue( WW8_ASCII2STR("ReadOnly"), aTmp);
++
++ aTmp <<= ImportColor(mnForeColor);
++ rPropSet->setPropertyValue( WW8_ASCII2STR("TextColor"), aTmp);
++
++ sal_Bool bTemp = nMultiState;
++ aTmp = bool2any(bTemp);
++ rPropSet->setPropertyValue( WW8_ASCII2STR("MultiSelection"), aTmp);
++
++ aTmp <<= ImportColor(mnBackColor);
++ rPropSet->setPropertyValue( WW8_ASCII2STR("BackgroundColor"), aTmp);
++
++ aTmp <<= ImportBorder(nSpecialEffect,nBorderStyle);
++ rPropSet->setPropertyValue( WW8_ASCII2STR("Border"), aTmp);
++
++ aTmp <<= ImportColor( nBorderColor );
++ rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
++
++ if ( msListData.getLength() )
++ {
++ aTmp <<= msListData;
++ rPropSet->setPropertyValue( WW8_ASCII2STR("StringItemList"), aTmp);
++ if ( msIndices.getLength() )
++ {
++ aTmp <<= msIndices;
++ rPropSet->setPropertyValue( WW8_ASCII2STR("SelectedItems"), aTmp);
++ }
++ }
++ rPropSet->setPropertyValue( WW8_ASCII2STR("Dropdown"), uno::makeAny( sal_True ));
++
++ return sal_True;
++}
++
++sal_Bool HTML_Select::Read(SotStorageStream *pS)
++{
++ static rtl::OUString sTerm( RTL_CONSTASCII_USTRINGPARAM("</SELECT") );
++ static String sMultiple( RTL_CONSTASCII_USTRINGPARAM("<SELECT MULTIPLE") );
++ static String sSelected( RTL_CONSTASCII_USTRINGPARAM("OPTION SELECTED") );
++
++ // we should be positioned at the html fragment ( really we should
++ // reorganise the reading of controls from excel such that the position and
++ // lenght of the associated record in the Ctls stream is available
++ // But since we don't know about the lenght of the stream lets read the stream
++ // until we reach the end of the fragment
++ // I wish I know where there was a html parser in openoffice
++ OUStringBuffer buf(40);
++ bool bTerminate = false;
++ do
++ {
++ sal_uInt16 ch = 0;
++ *pS >> ch;
++ sal_Unicode uni = static_cast< sal_Unicode >( ch );
++ // if the buffer ends with </SELECT> we are done
++ if ( uni == '>' )
++ {
++ rtl::OUString bufContents( buf.getStr() );
++ if ( bufContents.indexOf( sTerm ) != -1 )
++ bTerminate = true;
++
++ }
++ buf.append( &uni, 1 );
++
++ } while ( !pS->IsEof() && !bTerminate );
++ String data = buf.makeStringAndClear();
++
++ // replace crlf with lf
++ data.SearchAndReplaceAll( String( RTL_CONSTASCII_USTRINGPARAM( "\x0D\x0A" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "\x0A" ) ) );
++ std::vector< rtl::OUString > listValues;
++ std::vector< sal_Int16 > selectedIndices;
+
++ // Ultra hacky parser for the info
++ sal_Int32 nTokenCount = data.GetTokenCount( '\n' );
++
++ for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken )
++ {
++ String sLine( data.GetToken( nToken, '\n' ) );
++ if ( !nToken ) // first line will tell us if multiselect is enabled
++ {
++ if ( sLine.CompareTo( sMultiple, sMultiple.Len() ) == COMPARE_EQUAL )
++ nMultiState = true;
++ }
++ // skip first and last lines, no data there
++ else if ( nToken < nTokenCount - 1)
++ {
++ if ( sLine.GetTokenCount( '>' ) )
++ {
++ String displayValue = sLine.GetToken( 1, '>' );
++ if ( displayValue.Len() )
++ {
++ // Really we should be using a proper html parser
++ // escaping some common bits to be escaped
++ displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "<" ) ), String( RTL_CONSTASCII_USTRINGPARAM("<") ) );
++ displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( ">" ) ), String( RTL_CONSTASCII_USTRINGPARAM(">") ) );
++ displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( """ ) ), String( RTL_CONSTASCII_USTRINGPARAM("\"") ) );
++ displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&" ) ), String( RTL_CONSTASCII_USTRINGPARAM("&") ) );
++ listValues.push_back( displayValue );
++ if( sLine.Search( sSelected ) != STRING_NOTFOUND )
++ selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 );
++ }
++ }
++ }
++ }
++ if ( listValues.size() )
++ {
++ msListData.realloc( listValues.size() );
++ sal_Int32 index = 0;
++ for( std::vector< rtl::OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index )
++ msListData[ index ] = *it;
++ }
++ if ( selectedIndices.size() )
++ {
++ msIndices.realloc( selectedIndices.size() );
++ sal_Int32 index = 0;
++ for( std::vector< sal_Int16 >::iterator it = selectedIndices.begin(); it != selectedIndices.end(); ++it, ++index )
++ msIndices[ index ] = *it;
++ }
++ return sal_True;
++}
++
++sal_Bool HTML_Select::ReadFontData(SotStorageStream *pS)
++{
++ return sal_True;
++}
+ /* vi:set tabstop=4 shiftwidth=4 expandtab: */
More information about the ooo-build-commit
mailing list