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: svgscript.hxx,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 static const char aSVGScript1
[] =
35 var aSlides = new Object();\n\
36 var aMasters = new Object();\n\
37 var aMasterVisibilities = new Object();\n\
39 function onClick( aEvt )\n\
43 if( aEvt.getButton() == 0 ) \n\
45 else if( aEvt.getButton() == 2 ) \n\
49 switchSlide( aEvt, nOffset );\n\
52 function onKeyPress( aEvt ) \n\
54 var nCode = String.fromCharCode( aEvt.getCharCode() );\n\
57 if( ( ' ' == nCode ) || \n\
58 ( ( !aEvt.getCtrlKey() && !aEvt.getAltKey() && !aEvt.getMetaKey() && !aEvt.getShiftKey() ) && \n\
59 ( aEvt.getKeyCode() == aEvt.DOM_VK_PAGE_DOWN() ||\n\
60 aEvt.getKeyCode() == aEvt.DOM_VK_PAGE_RIGHT() ) ) )\n\
64 else if( ( !aEvt.getCtrlKey() && !aEvt.getAltKey() && !aEvt.getMetaKey() && !aEvt.getShiftKey() ) && \n\
65 ( aEvt.getKeyCode() == aEvt.DOM_VK_PAGE_UP() ||\n\
66 aEvt.getKeyCode() == aEvt.DOM_VK_LEFT() ) )\n\
72 switchSlide( aEvt, nOffset );\n\
77 static const char aSVGScript2
[] =
78 " function switchSlide( aEvt, nOffset ) \n\
80 var nNextSlide = nCurSlide + nOffset;\n\
82 if( nNextSlide < 0 && nSlides > 0 )\n\
83 nNextSlide = nSlides - 1;\n\
84 else if( nNextSlide >= nSlides ) \n\
87 aSlides[ nCurSlide ].setAttributeNS( null, \"visibility\", \"hidden\" );\n\
88 aSlides[ nNextSlide ].setAttributeNS( null, \"visibility\", \"visible\" );\n\
90 var aCurMaster = aMasters[ nCurSlide ];\n\
91 var aCurMasterVisibility = aMasterVisibilities[ nCurSlide ];\n\
93 var aNextMaster = aMasters[ nNextSlide ];\n\
94 var aNextMasterVisibility = aMasterVisibilities[ nNextSlide ];\n\
96 if( ( aCurMaster != aNextMaster ) || ( aCurMasterVisibility != aNextMasterVisibility ) ) \n\
98 if( aCurMaster != aNextMaster )\n\
99 aCurMaster.setAttributeNS( null, \"visibility\", \"hidden\" );\n\
101 aNextMaster.setAttributeNS( null, \"visibility\", aNextMasterVisibility );\n\
104 nCurSlide = nNextSlide; \n\
109 nSlides = document.getElementById( \"meta_slides\" ).getAttributeNS( null, \"numberOfSlides\" );\n\
111 for( i = 0; i < nSlides; i++ )\n\
113 var aSlide = document.getElementById( \"meta_slide\" + i );\n\
115 aSlides[ i ] = document.getElementById( aSlide.getAttributeNS( null, \"slide\" ) );\n\
116 aMasters[ i ] = document.getElementById( aSlide.getAttributeNS( null, \"master\" ) );\n\
117 aMasterVisibilities[ i ] = aSlide.getAttributeNS( null, \"master-visibility\" );\n\
128 var aSlides = new Object();
129 var aMasters = new Object();
130 var aMasterVisibilities;
132 function onClick( aEvt )
136 if( aEvt.getButton() == 0 )
138 else if( aEvt.getButton() == 2 )
142 switchSlide( aEvt, nOffset );
145 function onKeyPress( aEvt )
147 var nCode = String.fromCharCode( aEvt.getCharCode() );
150 if( ( ' ' == nCode ) ||
151 ( ( !aEvt.getCtrlKey() && !aEvt.getAltKey() && !aEvt.getMetaKey() && !aEvt.getShiftKey() ) &&
152 ( aEvt.getKeyCode() == aEvt.DOM_VK_PAGE_DOWN() ||
153 aEvt.getKeyCode() == aEvt.DOM_VK_PAGE_RIGHT() ) ) )
157 else if( ( !aEvt.getCtrlKey() && !aEvt.getAltKey() && !aEvt.getMetaKey() && !aEvt.getShiftKey() ) &&
158 ( aEvt.getKeyCode() == aEvt.DOM_VK_PAGE_UP() ||
159 aEvt.getKeyCode() == aEvt.DOM_VK_LEFT() ) )
165 switchSlide( aEvt, nOffset );
168 function switchSlide( aEvt, nOffset )
170 var nNextSlide = nCurSlide + nOffset;
172 if( nNextSlide < 0 && nSlides > 0 )
173 nNextSlide = nSlides - 1;
174 else if( nNextSlide >= nSlides )
177 aSlides[ nCurSlide ].setAttributeNS( null, "visibility", "hidden" );
178 aSlides[ nNextSlide ].setAttributeNS( null, "visibility", "visible" );
180 var aCurMaster = aMasters[ nCurSlide ];
181 var aCurMasterVisibility = aMasterVisibilities[ nCurSlide ];
183 var aNextMaster = aMasters[ nNextSlide ];
184 var aNextMasterVisibility = aMasterVisibilities[ nNextSlide ];
186 if( ( aCurMaster != aNextMaster ) || ( aCurMasterVisibility != aNextMasterVisibility ) )
188 if( aCurMaster != aNextMaster )
189 aCurMaster.setAttributeNS( null, "visibility", "hidden" );
191 aNextMaster.setAttributeNS( null, "visibility", aNextMasterVisibility );
194 nCurSlide = nNextSlide;
199 nSlides = document.getElementById( "meta_slides" ).getAttributeNS( null, "numberOfSlides" );
201 for( i = 0; i < nSlides; i++ )
203 var aSlide = document.getElementById( "meta_slide" + i );
205 aSlides[ i ] = document.getElementById( aSlide.getAttributeNS( null, "slide" ) );
206 aMasters[ i ] = document.getElementById( aSlide.getAttributeNS( null, "master" ) );
207 aMasterVisibilities[ i ] = aSlide.getAttributeNS( null, "master-visibility" );