Update ooo320-m1
[ooovba.git] / filter / source / svg / svgscript.hxx
blob6b6e7c5716e1598d295a01152881b2dc959c2998
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svgscript.hxx,v $
10 * $Revision: 1.5 $
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[] =
32 "<![CDATA[\n\
33 var nCurSlide = 0;\n\
34 var nSlides = 0;\n\
35 var aSlides = new Object();\n\
36 var aMasters = new Object();\n\
37 var aMasterVisibilities = new Object();\n\
38 \n\
39 function onClick( aEvt )\n\
40 {\n\
41 var nOffset = 0;\n\
42 \n\
43 if( aEvt.getButton() == 0 ) \n\
44 nOffset = 1;\n\
45 else if( aEvt.getButton() == 2 ) \n\
46 nOffset = -1;\n\
47 \n\
48 if( 0 != nOffset )\n\
49 switchSlide( aEvt, nOffset );\n\
50 }\n\
51 \n\
52 function onKeyPress( aEvt ) \n\
53 {\n\
54 var nCode = String.fromCharCode( aEvt.getCharCode() );\n\
55 var nOffset = 0;\n\
56 \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\
61 {\n\
62 nOffset = 1;\n\
63 }\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\
67 {\n\
68 nOffset = -1\n\
69 }\n\
70 \n\
71 if( 0 != nOffset )\n\
72 switchSlide( aEvt, nOffset );\n\
73 }\n\
74 \n\
77 static const char aSVGScript2[] =
78 " function switchSlide( aEvt, nOffset ) \n\
79 {\n\
80 var nNextSlide = nCurSlide + nOffset;\n\
81 \n\
82 if( nNextSlide < 0 && nSlides > 0 )\n\
83 nNextSlide = nSlides - 1;\n\
84 else if( nNextSlide >= nSlides ) \n\
85 nNextSlide = 0;\n\
86 \n\
87 aSlides[ nCurSlide ].setAttributeNS( null, \"visibility\", \"hidden\" );\n\
88 aSlides[ nNextSlide ].setAttributeNS( null, \"visibility\", \"visible\" );\n\
89 \n\
90 var aCurMaster = aMasters[ nCurSlide ];\n\
91 var aCurMasterVisibility = aMasterVisibilities[ nCurSlide ];\n\
92 \n\
93 var aNextMaster = aMasters[ nNextSlide ];\n\
94 var aNextMasterVisibility = aMasterVisibilities[ nNextSlide ];\n\
95 \n\
96 if( ( aCurMaster != aNextMaster ) || ( aCurMasterVisibility != aNextMasterVisibility ) ) \n\
97 {\n\
98 if( aCurMaster != aNextMaster )\n\
99 aCurMaster.setAttributeNS( null, \"visibility\", \"hidden\" );\n\
101 aNextMaster.setAttributeNS( null, \"visibility\", aNextMasterVisibility );\n\
102 }\n\
104 nCurSlide = nNextSlide; \n\
105 }\n\
107 function init() \n\
108 {\n\
109 nSlides = document.getElementById( \"meta_slides\" ).getAttributeNS( null, \"numberOfSlides\" );\n\
111 for( i = 0; i < nSlides; i++ )\n\
112 {\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\
118 }\n\
119 }\n\
121 init();\n\
122 ]]>";
125 <![CDATA[
126 var nCurSlide = 0;
127 var nSlides = 0;
128 var aSlides = new Object();
129 var aMasters = new Object();
130 var aMasterVisibilities;
132 function onClick( aEvt )
134 var nOffset = 0;
136 if( aEvt.getButton() == 0 )
137 nOffset = 1;
138 else if( aEvt.getButton() == 2 )
139 nOffset = -1;
141 if( 0 != nOffset )
142 switchSlide( aEvt, nOffset );
145 function onKeyPress( aEvt )
147 var nCode = String.fromCharCode( aEvt.getCharCode() );
148 var nOffset = 0;
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() ) ) )
155 nOffset = 1;
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() ) )
161 nOffset = -1
164 if( 0 != nOffset )
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 )
175 nNextSlide = 0;
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;
197 function init()
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" );
211 init();
212 ]]*/