diff options
author | Marco Cecchetti <mrcekets@gmail.com> | 2011-06-30 01:05:12 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-06-30 01:05:12 +0200 |
commit | d275bc903dae0db887b07d042be7dc927e668e35 (patch) | |
tree | a60f6ce41837e98e60b2419e1a879fab7b9eb481 /filter | |
parent | Revert patch to change .idl (diff) | |
download | core-d275bc903dae0db887b07d042be7dc927e668e35.tar.gz core-d275bc903dae0db887b07d042be7dc927e668e35.zip |
svg export filter: added support for browsing slides
Cleaner svg, convert javascript to working state
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/svg/svgexport.cxx | 17 | ||||
-rw-r--r-- | filter/source/svg/svgscript.hxx | 133 |
2 files changed, 140 insertions, 10 deletions
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index 6a523541c221..b59830fb1743 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -496,8 +496,6 @@ sal_Bool SVGFilter::implExportDocument( const Reference< XDrawPages >& rxMasterP if( !bSinglePage ) { mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "xmlns:ooo", B2UCONST( "http://xml.openoffice.org/svg/export" ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "onclick", B2UCONST( "onClick(evt)" ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "onkeypress", B2UCONST( "onKeyPress(evt)" ) ); } @@ -587,10 +585,10 @@ sal_Bool SVGFilter::implGenerateMetaData( const Reference< XDrawPages >& /* rxMa if( rxDrawPages->getCount() ) { mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", B2UCONST( "meta_slides" ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "numberOfSlides", OUString::valueOf( rxDrawPages->getCount() ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "ooo:numberOfSlides", OUString::valueOf( rxDrawPages->getCount() ) ); { - SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "ooo:slidesInfo", sal_True, sal_True ); + SvXMLElementExport aExp( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); const OUString aId( B2UCONST( "meta_slide" ) ); for( sal_Int32 i = 0, nCount = rxDrawPages->getCount(); i < nCount; ++i ) @@ -618,12 +616,12 @@ sal_Bool SVGFilter::implGenerateMetaData( const Reference< XDrawPages >& /* rxMa aMasterVisibility = B2UCONST( "hidden" ); mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "id", aSlideId ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "slide", implGetValidIDFromInterface( xDrawPage ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "master", implGetValidIDFromInterface( xMasterPage ) ); - mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "master-visibility", aMasterVisibility ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "ooo:slide", implGetValidIDFromInterface( xDrawPage ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "ooo:master", implGetValidIDFromInterface( xMasterPage ) ); + mpSVGExport->AddAttribute( XML_NAMESPACE_NONE, "ooo:master-visibility", aMasterVisibility ); { - SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "ooo:slideInfo", sal_True, sal_True ); + SvXMLElementExport aExp2( *mpSVGExport, XML_NAMESPACE_NONE, "g", sal_True, sal_True ); } } } @@ -650,6 +648,9 @@ sal_Bool SVGFilter::implGenerateScript( const Reference< XDrawPages >& /* rxMast { xExtDocHandler->unknown( OUString::createFromAscii( aSVGScript1 ) ); xExtDocHandler->unknown( OUString::createFromAscii( aSVGScript2 ) ); + xExtDocHandler->unknown( OUString::createFromAscii( aSVGScript3 ) ); + xExtDocHandler->unknown( OUString::createFromAscii( aSVGScript4 ) ); + xExtDocHandler->unknown( OUString::createFromAscii( aSVGScript5 ) ); } } diff --git a/filter/source/svg/svgscript.hxx b/filter/source/svg/svgscript.hxx index 2019994dced0..0c714f3a6952 100644 --- a/filter/source/svg/svgscript.hxx +++ b/filter/source/svg/svgscript.hxx @@ -26,7 +26,7 @@ * ************************************************************************/ -static const char aSVGScript1[] = +static const char aSVGScriptA[] = "<![CDATA[\n\ var nCurSlide = 0;\n\ var nSlides = 0;\n\ @@ -72,7 +72,7 @@ static const char aSVGScript1[] = \n\ "; -static const char aSVGScript2[] = +static const char aSVGScriptB[] = " function switchSlide( aEvt, nOffset ) \n\ {\n\ var nNextSlide = nCurSlide + nOffset;\n\ @@ -119,4 +119,133 @@ static const char aSVGScript2[] = init();\n\ ]]>"; +static const char aSVGScript1[] = +"<![CDATA[\n\ +\n\ + window.onload = init;\n\ + \n\ + // Keycodes.\n\ + var LEFT_KEY = 37; // cursor left keycode\n\ + var UP_KEY = 38; // cursor up keycode\n\ + var RIGHT_KEY = 39; // cursor right keycode\n\ + var DOWN_KEY = 40; // cursor down keycode\n\ + var PAGE_UP_KEY = 33; // page up keycode\n\ + var PAGE_DOWN_KEY = 34; // page down keycode\n\ + var HOME_KEY = 36; // home keycode\n\ + var END_KEY = 35; // end keycode\n\ + var ENTER_KEY = 13; \n\ + var SPACE_KEY = 32;\n\ + var ESCAPE_KEY = 27;\n\ + \n\ + \n\ + var nCurSlide = 0;\n\ + var nSlides = 0;\n\ + var aSlides = new Array();\n\ + var aMasters = new Array();\n\ + var aMasterVisibilities = new Array();\n\ +\n\ +\n\ +\n\ +\n\ +"; + + +static const char aSVGScript2[] = +" function onClick( aEvt )\n\ + {\n\ + if (!aEvt)\n\ + aEvt = window.event;\n\ + \n\ + var nOffset = 0;\n\ + \n\ + if( aEvt.button == 0 ) \n\ + nOffset = 1;\n\ + else if( aEvt.button == 2 ) \n\ + nOffset = -1;\n\ + \n\ + if( 0 != nOffset )\n\ + switchSlide( aEvt, nOffset );\n\ + }\n\ + document.onclick = onClick;\n\ + \n\ + \n\ +"; + +static const char aSVGScript3[] = +" function onKeyPress( aEvt )\n\ + {\n\ + if (!aEvt)\n\ + aEvt = window.event;\n\ + \n\ + var nCode = aEvt.keyCode || aEvt.charCode;\n\ + var nOffset = 0;\n\ + if( nCode == SPACE_KEY || nCode == PAGE_DOWN_KEY || nCode == RIGHT_KEY )\n\ + {\n\ + nOffset = 1;\n\ + }\n\ + else if( nCode == PAGE_UP_KEY ||nCode == LEFT_KEY )\n\ + {\n\ + nOffset = -1;\n\ + }\n\ + \n\ + if( 0 != nOffset )\n\ + switchSlide( aEvt, nOffset );\n\ + }\n\ + document.onkeypress = onKeyPress; \n\ + \n\ +"; + +static const char aSVGScript4[] = +" function switchSlide( aEvt, nOffset ) \n\ + {\n\ + var nNextSlide = nCurSlide + nOffset;\n\ +\n\ + if( nNextSlide < 0 && nSlides > 0 )\n\ + nNextSlide = nSlides - 1;\n\ + else if( nNextSlide >= nSlides ) \n\ + nNextSlide = 0;\n\ +\n\ + aSlides[ nCurSlide ].setAttribute( \"visibility\", \"hidden\" );\n\ + aSlides[ nNextSlide ].setAttribute( \"visibility\", \"visible\" );\n\ +\n\ + var aCurMaster = aMasters[ nCurSlide ];\n\ + var aCurMasterVisibility = aMasterVisibilities[ nCurSlide ];\n\ + \n\ + var aNextMaster = aMasters[ nNextSlide ];\n\ + var aNextMasterVisibility = aMasterVisibilities[ nNextSlide ];\n\ +\n\ + if( ( aCurMaster != aNextMaster ) || ( aCurMasterVisibility != aNextMasterVisibility ) ) \n\ + {\n\ + if( aCurMaster != aNextMaster )\n\ + aCurMaster.setAttribute(\"visibility\", \"hidden\" );\n\ + \n\ + aNextMaster.setAttribute( \"visibility\", aNextMasterVisibility );\n\ + }\n\ +\n\ + nCurSlide = nNextSlide; \n\ + }\n\ +\n\ +"; + +static const char aSVGScript5[] = +" function init() \n\ + {\n\ + nSlides = document.getElementById( \"meta_slides\" ).getAttribute( \"ooo:numberOfSlides\" );\n\ +\n\ + for( i = 0; i < nSlides; i++ )\n\ + {\n\ + var aMetaSlide = document.getElementById( \"meta_slide\" + i );\n\ + if( aMetaSlide )\n\ + {\n\ + aSlides.push( document.getElementById( aMetaSlide.getAttribute( \"ooo:slide\" ) ) );\n\ + aMasters.push( document.getElementById( aMetaSlide.getAttribute( \"ooo:master\" ) ) );\n\ + aMasterVisibilities.push( aMetaSlide.getAttribute( \"ooo:master-visibility\" ) );\n\ + }\n\ + }\n\ + }\n\ + \n\ +]]>"; + + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |