diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2001-03-14 15:41:59 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2001-03-14 15:41:59 +0000 |
commit | c2af40ce0ef3b4cf061119f75bc702610b3ad2ab (patch) | |
tree | e7cdb465599784123b5f84be6714e8506c3ce16b /xmlscript | |
parent | 2cbacc4c7fc7f133dd013376446f81d867b54311 (diff) |
*** empty log message ***
Diffstat (limited to 'xmlscript')
-rw-r--r-- | xmlscript/test/imexp.cxx | 71 | ||||
-rw-r--r-- | xmlscript/test/test.xml | 142 |
2 files changed, 118 insertions, 95 deletions
diff --git a/xmlscript/test/imexp.cxx b/xmlscript/test/imexp.cxx index 9792d53a1578..d2956f0dd895 100644 --- a/xmlscript/test/imexp.cxx +++ b/xmlscript/test/imexp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: imexp.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dbo $ $Date: 2001-02-28 18:22:08 $ + * last change: $Author: dbo $ $Date: 2001-03-14 16:41:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -221,7 +221,7 @@ Reference< lang::XMultiServiceFactory > createApplicationServiceManager() // ----------------------------------------------------------------------- -Sequence< Reference< container::XNameContainer > > importFile( +Reference< container::XNameContainer > importFile( char const * fname ) { // create the input stream @@ -232,13 +232,16 @@ Sequence< Reference< container::XNameContainer > > importFile( int nLength = ::ftell( f ); ::fseek( f, 0, SEEK_SET ); - Sequence< sal_Int8 > bytes( nLength ); + ByteSequence bytes( nLength ); ::fread( bytes.getArray(), nLength, 1, f ); ::fclose( f ); - Sequence< Reference< container::XNameContainer > > models; - ::xmlscript::importDialogModelsFromByteSequence( &models, bytes ); - return models; + Reference< lang::XMultiServiceFactory > xSMgr( ::comphelper::getProcessServiceFactory() ); + Reference< container::XNameContainer > xModel( xSMgr->createInstance( + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); + ::xmlscript::importDialogModel( ::xmlscript::createInputStream( bytes ), xModel ); + + return xModel; } else { @@ -249,10 +252,26 @@ Sequence< Reference< container::XNameContainer > > importFile( void exportToFile( char const * fname, - Sequence< Reference< container::XNameContainer > > const & models ) + Reference< container::XNameContainer > const & xModel ) { + Reference< io::XInputStreamProvider > xProvider( ::xmlscript::exportDialogModel( xModel ) ); + Reference< io::XInputStream > xStream( xProvider->createInputStream() ); + Sequence< sal_Int8 > bytes; - ::xmlscript::exportDialogModelsToByteSequence( &bytes, models ); + sal_Int32 nPos = xStream->readBytes( bytes, xStream->available() ); + while (xStream->available() > 0) + { + Sequence< sal_Int8 > addBytes; + sal_Int32 nRead = xStream->readBytes( addBytes, xStream->available() ); + sal_Int8 * pBytes = bytes.getArray(); + sal_Int8 const * pAddBytes = addBytes.getConstArray(); + sal_Int32 nPos = nRead; + while (nRead--) + { + pBytes[ nPos + nPos ] = pAddBytes[ nPos ]; + } + nPos += nRead; + } FILE * f = ::fopen( fname, "w" ); ::fwrite( bytes.getConstArray(), 1, bytes.getLength(), f ); @@ -265,7 +284,7 @@ void exportToFile( class MyApp : public Application { public: - void Main(); + void Main(); }; MyApp aMyApp; @@ -293,26 +312,34 @@ void MyApp::Main() // import dialogs OString aParam1( OUStringToOString( OUString( GetCommandLineParam( 0 ) ), RTL_TEXTENCODING_ASCII_US ) ); - Sequence< Reference< container::XNameContainer > > models( importFile( aParam1.getStr() ) ); + Reference< container::XNameContainer > xModel( importFile( aParam1.getStr() ) ); + OSL_ASSERT( xModel.is() ); - Reference< container::XNameContainer > const * pModels = models.getConstArray(); - for ( sal_Int32 nPos = 0; nPos < models.getLength(); ++nPos ) - { - Reference< awt::XControl > xDlg( xMSF->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), UNO_QUERY ); - xDlg->setModel( Reference< awt::XControlModel >::query( pModels[ nPos ] ) ); - xDlg->createPeer( xToolkit, 0 ); - Reference< awt::XDialog > xD( xDlg, UNO_QUERY ); - xD->execute(); - } + Reference< awt::XControl > xDlg( xMSF->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialog" ) ) ), UNO_QUERY ); + xDlg->setModel( Reference< awt::XControlModel >::query( xModel ) ); + xDlg->createPeer( xToolkit, 0 ); + Reference< awt::XDialog > xD( xDlg, UNO_QUERY ); + xD->execute(); if (GetCommandLineParamCount() == 2) { // write modified dialogs OString aParam2( OUStringToOString( OUString( GetCommandLineParam( 1 ) ), RTL_TEXTENCODING_ASCII_US ) ); - exportToFile( aParam2.getStr(), models ); + exportToFile( aParam2.getStr(), xModel ); } } + catch (xml::sax::SAXException & rExc) + { + OString aStr( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); + uno::Exception exc; + if (rExc.WrappedException >>= exc) + { + aStr += OString( " >>> " ); + aStr += OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ); + } + OSL_ENSURE( 0, aStr.getStr() ); + } catch (uno::Exception & rExc) { OString aStr( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); diff --git a/xmlscript/test/test.xml b/xmlscript/test/test.xml index 0d812819e590..ad3d0bacd0c9 100644 --- a/xmlscript/test/test.xml +++ b/xmlscript/test/test.xml @@ -1,88 +1,84 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dialog:dialogs SYSTEM "../dtd/dialog.dtd"> -<dialogs xmlns="http://openoffice.org/2000/dialog"> +<window xmlns="http://openoffice.org/2000/dialog" + xmlns:dlg="http://openoffice.org/2000/dialog" + id="window1" title="Test-Dialog" left="50" top="50" height="660" width="400"> - <window xmlns:dlg="http://openoffice.org/2000/dialog" - id="window1" title="Test-Dialog" left="50" top="50" height="660" width="400"> + <dlg:styles xmlns:dlg="http://openoffice.org/2000/dialog"> + <dlg:style style-id="bla" background-color="0xffffff" dlg:text-color="255"/> + <dlg:style style-id="bla3" background-color="0" dlg:text-color="0xffffff" font-name="Arial" font-height="24"/> + <dlg:style style-id="no_border" border="none"/> + </dlg:styles> - <dlg:styles> - <dlg:style style-id="bla" background-color="0xffffff" dlg:text-color="255"/> - <dlg:style style-id="bla3" background-color="0" dlg:text-color="0xffffff" font-name="Arial" font-height="24"/> - <dlg:style style-id="no_border" border="none"/> - </dlg:styles> + <dlg:bulletinboard xmlns:ns="http://www.fake" xmlns:dlg="http://openoffice.org/2000/dialog"> - <dlg:bulletinboard xmlns:ns="http://www.fake"> + <button dlg:id="button1" ns:value="hallo" dlg:left="50" ns:top="50" width="50" height="50" style-id="bla3" xmlns:ns="http://openoffice.org/2000/dialog"> + <event listener-type="type" event-method="clicked" script-type="basic" script-code="code" param="testi"/> + </button> - <button dlg:id="button1" ns:value="hallo" dlg:left="50" ns:top="50" width="50" height="50" style-id="bla3" xmlns:ns="http://openoffice.org/2000/dialog"> - <event listener-type="type" event-method="clicked" script-type="basic" script-code="code" param="testi"/> - </button> - <button dlg:id="button3" ns:value="hallo2" dlg:left="250" ns:top="50" width="50" height="50" style-id="bla" xmlns:ns="http://openoffice.org/2000/dialog"/> - <checkbox id="check1" value="checked" left="50" top="150" width="100" height="20" checked="true"/> - <checkbox id="check2" value="dontknow" left="50" top="170" width="100" height="20" tristate="true"/> - <checkbox id="check3" value="tristate_checked" left="50" top="190" width="100" height="20" checked="true" tristate="true"/> - <menulist id="list1" multiselection="true" left="50" top="400" width="100" height="100"> - <menupopup> - <menuitem value="item1"/> - <menuitem value="item2 sel" selected="true"/> - <menuitem value="item3 sel" selected="true"/> - </menupopup> - </menulist> - <menulist id="list2" left="250" top="400" width="100" height="100"> - <menupopup> - <menuitem value="item4" selected="false"/> - <menuitem value="item5 sel" selected="true"/> - <menuitem value="item6"/> - </menupopup> - </menulist> - <combobox id="combo1" value="combotext1" left="250" top="150" width="50" height="50"> - <menupopup> - <menuitem value="Citem1"/> - <menuitem value="Citem2"/> - </menupopup> - </combobox> - <combobox id="combo2" value="combotext2" left="310" top="150" width="50" height="50" spin="true"> - <menupopup> - <menuitem value="Citem3"/> - <menuitem value="Citem4"/> - </menupopup> - </combobox> - <radiogroup> - <radio id="radio1" value="default radio" left="50" top="250" width="100" height="20"/> - <radio id="radio2" value="checked" left="50" top="270" width="100" height="20" checked="true"/> - <radio id="radio3" value="unchecked" left="50" top="290" width="100" height="20" checked="false"/> - <radio id="radio4" value="dont know" left="50" top="310" width="100" height="20" tristate="true"/> - </radiogroup> - <titledbox id="groupbox1" left="250" top="250" width="120" height="100"> - <title value="grouped"/> - <radio id="radio5" value="default radio" left="5" top="15" width="100" height="20"/> - <radio id="radio6" value="dont know" left="5" top="35" width="100" height="20" tristate="true"/> - <radio id="radio7" value="tristate checked" left="5" top="55" width="100" height="20" tristate="true" checked="true"/> - <radio id="radio8" value="checked" left="5" top="75" width="100" height="20" checked="true"/> - </titledbox> - <text id="fixed1" left="50" top="520" width="180" height="20" value="fixed text is here..." multiline="true" align="center"/> - <textfield id="field1" left="250" top="520" width="50" height="40" value="edit no text here..." readonly="true" vscroll="true" multiline="true" align="right" style-id="no_border"/> - <textfield id="field2" left="320" top="520" width="50" height="40" value="hidden text" hscroll="true" echochar="*" align="left"/> - <img id="image1" left="50" top="600" width="80" height="50" src="../../test/w3c.jpg"/> - <filecontrol id="file1" left="150" top="600" width="100" height="20" value="../../test/w3c.jpg"/> + <button dlg:id="button3" ns:value="hallo2" dlg:left="250" ns:top="50" width="50" height="50" style-id="bla" xmlns:ns="http://openoffice.org/2000/dialog"/> - </dlg:bulletinboard> + <checkbox id="check1" value="checked" left="50" top="150" width="100" height="20" checked="true"/> + <checkbox id="check2" value="dontknow" left="50" top="170" width="100" height="20" tristate="true"/> + <checkbox id="check3" value="tristate_checked" left="50" top="190" width="100" height="20" checked="true" tristate="true"/> - </window> + <menulist id="list1" multiselection="true" left="50" top="400" width="100" height="100"> + <menupopup> + <menuitem value="item1"/> + <menuitem value="item2 sel" selected="true"/> + <menuitem value="item3 sel" selected="true"/> + </menupopup> + </menulist> - <window xmlns:dlg2="http://openoffice.org/2000/dialog" - id="window2" title="Test-Dialog2" left="100" top="100" height="200" width="200"> + <dlg:menulist id="list2" left="250" top="400" width="100" height="100"> + <menupopup> + <menuitem value="item4" selected="false"/> + <menuitem value="item5 sel" selected="true"/> + <menuitem value="item6"/> + </menupopup> + </dlg:menulist> - <dlg2:bulletinboard> + <combobox id="combo1" value="combotext1" left="250" top="150" width="50" height="50"> + <menupopup> + <menuitem value="Citem1"/> + <menuitem value="Citem2"/> + </menupopup> + </combobox> - <dlg2:datefield id="datefield1" left="20" top="20" width="100" height="20" date-format="short_DDMMYY" spin="true" value="20010301"/> - <timefield id="time1" left="20" top="50" width="100" height="20" time-format="24h_long" value-min="0" value-max="24000000" strict-format="true" value="12000000" spin="true"/> - <patternfield id="pattern1" left="20" top="80" width="100" height="20" value="pattern" strict-format="true" readonly="true"/> - <currencyfield id="currency1" left="20" top="110" width="100" height="20" value="5.6075" value-min="0.5" value-max="10.0" value-step="0.1" spin="true" thousands-separator="true" currency-symbol="$"/> - <numericfield id="numeric1" left="20" top="140" width="100" height="20" value="5.6075" value-min="0.5" value-max="10.0" value-step="0.1" thousands-separator="true"/> + <combobox id="combo2" value="combotext2" left="310" top="150" width="50" height="50" spin="true"> + <menupopup> + <menuitem value="Citem3"/> + <menuitem value="Citem4"/> + </menupopup> + </combobox> - </dlg2:bulletinboard> + <radiogroup> + <radio id="radio1" value="default radio" left="50" top="250" width="100" height="20"/> + <radio id="radio2" value="checked" left="50" top="270" width="100" height="20" checked="true"/> + <radio id="radio3" value="unchecked" left="50" top="290" width="100" height="20" checked="false"/> + <radio id="radio4" value="dont know" left="50" top="310" width="100" height="20" tristate="true"/> + </radiogroup> - </window> + <titledbox id="groupbox1" left="250" top="250" width="120" height="100"> + <title value="grouped"/> + <radio id="radio5" value="default radio" left="5" top="15" width="100" height="20"/> + <radio id="radio6" value="dont know" left="5" top="35" width="100" height="20" tristate="true"/> + <radio id="radio7" value="tristate checked" left="5" top="55" width="100" height="20" tristate="true" checked="true"/> + <radio id="radio8" value="checked" left="5" top="75" width="100" height="20" checked="true"/> + </titledbox> -</dialogs> + <text id="fixed1" left="50" top="520" width="180" height="20" value="fixed text is here..." multiline="true" align="center"/> + <textfield id="field1" left="250" top="520" width="50" height="40" value="edit no text here..." readonly="true" vscroll="true" multiline="true" align="right" style-id="no_border"/> + <textfield id="field2" left="320" top="520" width="50" height="40" value="hidden text" hscroll="true" echochar="*" align="left"/> + <img id="image1" left="50" top="585" width="80" height="20" src="../../test/w3c.jpg"/> + <filecontrol id="file1" left="150" top="585" width="100" height="20" value="../../test/w3c.jpg"/> + + <datefield id="datefield1" left="20" top="610" width="100" height="20" date-format="short_DDMMYY" spin="true" value="20010301"/> + <timefield id="time1" left="20" top="635" width="100" height="20" time-format="24h_long" value-min="0" value-max="24000000" strict-format="true" value="12000000" spin="true"/> + <patternfield id="pattern1" left="20" top="0" width="100" height="20" value="pattern" strict-format="true" readonly="true"/> + <currencyfield id="currency1" left="200" top="610" width="100" height="20" value="5.6075" value-min="0.5" value-max="10.0" value-step="0.1" spin="true" thousands-separator="true" currency-symbol="$"/> + <numericfield id="numeric1" left="200" top="635" width="100" height="20" value="5.6075" value-min="0.5" value-max="10.0" value-step="0.1" thousands-separator="true"/> + </dlg:bulletinboard> + +</window> |