@@ -111,6 +111,16 @@ customDesignerFunctions.getCustomFunctionsList = function () {
111111 } ) ;
112112} ;
113113
114+ customDesignerFunctions . getFirstCustomFunctionName = function ( ) {
115+ const list = Utils . customFunctionNames ;
116+ if ( list . length == 0 ) {
117+ console . log ( "not yey" ) ;
118+ return "ABS" // just none
119+ }
120+ list . sort ( ) ;
121+ return list [ 0 ] ;
122+ } ;
123+
114124customDesignerFunctions . fillWithArraySystemFonts = function ( ) {
115125 return vp_fonts . map ( val => { return { text : val , value : val } ; } ) ;
116126} ;
@@ -122,20 +132,235 @@ customDesignerFunctions.fillWithTruncatedArraySystemFonts = function () {
122132 } ) ;
123133} ;
124134
135+ customDesignerFunctions . handlerExportCsvSetting = function ( setting ) {
136+ var rowDelimiter = ( setting . rowDelimiter || "\r" ) ;
137+ let columnDelimiter = setting . columnDelimiter || "," ;
138+ setting . rowDelimiter = rowDelimiter . replace ( / \\ r / g, "\r" ) . replace ( / \\ n / g, "\n" ) . replace ( / \\ t / g, "\t" ) ;
139+ setting . columnDelimiter = columnDelimiter . replace ( / \\ r / g, '\r' ) . replace ( / \\ n / g, '\n' ) . replace ( / \\ t / g, '\t' ) ;
140+ } ;
141+
125142
126143customDesignerFunctions . init = function ( ) {
127- /*
128- let moduleSupportedFunctions = exported_modules.c["./src/commands/ribbon/formulas/functions/supportedFunctions/supportedFunctions.ts"].exports;
129- moduleSupportedFunctions.allFunctionItems = moduleSupportedFunctions.allFunctionItems.concat(customDesignerFunctions.getCustomFunctionsList());
130- moduleSupportedFunctions.allFunctionItems.sort(function (a, b) {
131- return a.text.localeCompare(b.text);
132- });
144+ var TemplateNames = GC . Spread . Sheets . Designer . TemplateNames ;
133145
134- let moduleInsertFunctionDialog = exported_modules.c["./src/commands/ribbon/formulas/functionHandler/insertFunctionDialog.tpl.ts"].exports;
135- moduleInsertFunctionDialog.insertFunctionDialogTemplate.content[0].children[0].children[1].children[1].children[13].items = customDesignerFunctions.getCustomFunctionsList();
136- moduleInsertFunctionDialog.insertFunctionDialogTemplate.content[0].children[0].children[1].children[1].children[0].items = moduleSupportedFunctions.allFunctionItems;
137- */
146+ // console.log("Remove 'export JS file' button from interface")
147+ var template = GC . Spread . Sheets . Designer . getTemplate ( TemplateNames . FileMenuPanelTemplate ) ;
148+ // Try the known path first
149+ let removed = false ;
150+ try {
151+ const exportSSJsonPanel = template . content [ 0 ] . children [ 0 ] . children [ 1 ] . children [ 2 ] . children [ 1 ] . children [ 1 ] . children [ 0 ] . children ;
152+
153+ if ( exportSSJsonPanel && Array . isArray ( exportSSJsonPanel ) ) {
154+ const buttonIndex = exportSSJsonPanel . findIndex ( child =>
155+ child && child . bindingPath === "button_export_javascript"
156+ ) ;
157+
158+ if ( buttonIndex !== - 1 ) {
159+ // console.log("Found 'export JS file' button at known path, index:", buttonIndex);
160+ exportSSJsonPanel . splice ( buttonIndex , 1 ) ;
161+ // console.log("Successfully removed 'export JS file' button!");
162+ removed = true ;
163+ }
164+ }
165+ } catch ( error ) {
166+ console . warn ( "Remove 'export JS file' button from interface: Known path not accessible:" , error . message ) ;
167+ }
138168
139- // add custom functions to the custom section of the insert function dialog
140- vp_insertFunctionDialogTemplate . content [ 0 ] . children [ 0 ] . children [ 1 ] . children [ 1 ] . children [ 13 ] . items = customDesignerFunctions . getCustomFunctionsList ( ) ;
169+ // If not found at known path, search recursively
170+ if ( ! removed ) {
171+ console . warn ( "Button not found at known path, searching entire template..." ) ;
172+
173+ function findAndRemoveButton ( obj , path = "" ) {
174+ if ( ! obj || typeof obj !== 'object' ) return null ;
175+
176+ if ( Array . isArray ( obj ) ) {
177+ for ( let i = 0 ; i < obj . length ; i ++ ) {
178+ if ( obj [ i ] && obj [ i ] . bindingPath === "button_export_javascript" ) {
179+ const foundPath = path + "[" + i + "]" ;
180+ console . error ( "ALERT: Button found at NEW PATH:" , foundPath ) ;
181+ console . error ( "Please update the code with this new path!" ) ;
182+ console . log ( "Button object:" , obj [ i ] ) ;
183+ obj . splice ( i , 1 ) ;
184+ console . log ( "Successfully removed 'export JS file' button!" ) ;
185+ return foundPath ;
186+ }
187+ const result = findAndRemoveButton ( obj [ i ] , path + "[" + i + "]" ) ;
188+ if ( result ) return result ;
189+ }
190+ } else {
191+ for ( let key in obj ) {
192+ if ( obj . hasOwnProperty ( key ) ) {
193+ const result = findAndRemoveButton ( obj [ key ] , path + "." + key ) ;
194+ if ( result ) return result ;
195+ }
196+ }
197+ }
198+ return null ;
199+ }
200+
201+ removed = findAndRemoveButton ( template , "template" ) ;
202+ if ( ! removed ) {
203+ console . error ( "ERROR: 'export JS file' button with bindingPath 'button_export_javascript' not found in entire template!" ) ;
204+ }
205+ }
206+ if ( removed ) {
207+ GC . Spread . Sheets . Designer . registerTemplate ( TemplateNames . FileMenuPanelTemplate , template ) ;
208+ }
209+
210+ // console.log("Add custom functions to the custom section of the insert function dialog")
211+ template = GC . Spread . Sheets . Designer . getTemplate ( TemplateNames . InsertFunctionDialogTemplate ) ;
212+ try {
213+ const prop$8 = ( o , o1 ) => `${ o } .${ o1 } ` ;
214+ template . content [ 0 ] . children [ 0 ] . children [ 1 ] . children [ 1 ] . children . unshift ( {
215+ type : "List" ,
216+ visibleWhen : prop$8 ( "functionDesc" , "functionCategory" ) + "=" + String ( template . content [ 0 ] . children [ 0 ] . children [ 1 ] . children [ 1 ] . children . length ) ,
217+ bindingPath : prop$8 ( "functionDesc" , "customFunction" ) ,
218+ items : customDesignerFunctions . getCustomFunctionsList ( ) ,
219+ keyboardSearch : true ,
220+ dblClickSubmit : true
221+ } ) ;
222+ template . content [ 0 ] . children [ 0 ] . children [ 0 ] . children [ 1 ] . items . sort ( function ( a , b ) {
223+ return a . text . localeCompare ( b . text ) ;
224+ } ) ;
225+ GC . Spread . Sheets . Designer . registerTemplate ( TemplateNames . InsertFunctionDialogTemplate , template ) ;
226+ } catch ( error ) {
227+ console . warn ( "Add custom functions to the custom section: " , error . message ) ;
228+ }
229+ template = GC . Spread . Sheets . Designer . getTemplate ( TemplateNames . InsertFunctionAllowDynamicArrayDialogTemplate ) ;
230+ try {
231+ const prop$8 = ( o , o1 ) => `${ o } .${ o1 } ` ;
232+ template . content [ 0 ] . children [ 0 ] . children [ 1 ] . children [ 1 ] . children . unshift ( {
233+ type : "List" ,
234+ visibleWhen : prop$8 ( "functionDesc" , "functionCategory" ) + "=" + String ( template . content [ 0 ] . children [ 0 ] . children [ 1 ] . children [ 1 ] . children . length ) ,
235+ bindingPath : prop$8 ( "functionDesc" , "customFunction" ) ,
236+ items : customDesignerFunctions . getCustomFunctionsList ( ) ,
237+ keyboardSearch : true ,
238+ dblClickSubmit : true
239+ } ) ;
240+ template . content [ 0 ] . children [ 0 ] . children [ 0 ] . children [ 1 ] . items . sort ( function ( a , b ) {
241+ return a . text . localeCompare ( b . text ) ;
242+ } ) ;
243+ GC . Spread . Sheets . Designer . registerTemplate ( TemplateNames . InsertFunctionAllowDynamicArrayDialogTemplate , template ) ;
244+ } catch ( error ) {
245+ console . warn ( "Add custom functions to the custom dynamic section: " , error . message ) ;
246+ }
247+
248+
249+ // todo localize stuff here?
141250} ;
251+
252+ class ViewProAppBase {
253+ constructor ( ) {
254+ this . _ms = [ null , null , ( ) => { return 0 } , ( ) => { } ] ;
255+ }
256+ notifyReady ( ) {
257+ customDesignerFunctions . notifyReady ( ) ;
258+ }
259+ showOpenDialog ( options ) {
260+ return Promise . reject ( {
261+ status : "" ,
262+ fileName : ""
263+ } ) ;
264+ }
265+ open ( fileName ) {
266+ return {
267+ status : "" ,
268+ message : "" ,
269+ data : "" ,
270+ fileName : ""
271+ } ;
272+ }
273+ save ( fileName , data2 , isJSFile ) {
274+ // customDesignerFunctions.saveAs
275+ return failed ;
276+ }
277+ exit ( ) { }
278+ importFile ( fileName , options ) {
279+ return Promise . resolve ( failed ) ;
280+ }
281+ showSaveDialog ( options ) {
282+ return cancelled ;
283+ }
284+ exportFile ( fileName , data2 ) {
285+ return Promise . resolve ( failed ) ;
286+ }
287+ needActive ( ) {
288+ return true ;
289+ }
290+ setClipboardData ( data2 ) { }
291+ getClipboardText ( ) {
292+ return "" ;
293+ }
294+ getBase64 ( fileName ) {
295+ return "" ;
296+ }
297+ getClipboardHTML ( ) {
298+ return "" ;
299+ }
300+ getSystemFonts ( ) {
301+ return customDesignerFunctions . fillWithTruncatedArraySystemFonts ( ) ;
302+ }
303+ closeAllWindows ( ) { }
304+ setClipboardText ( text ) { }
305+ setClipboardHTML ( string ) { }
306+ getFileInfo ( fullPath ) {
307+ // dir, fileName
308+ return { } ;
309+ }
310+ joinPath ( segments ) {
311+ return segments && segments . toString ( ) ;
312+ }
313+ config ( name , value ) {
314+ if ( value === void 0 ) {
315+ return this . getConfig ( name ) ;
316+ } else {
317+ this . setConfig ( name , value ) ;
318+ return osEnv ;
319+ }
320+ }
321+ getConfig ( name ) {
322+ this . initConfig ( true ) ;
323+ let path = name . split ( "." ) ;
324+ let value = this . _config ;
325+ if ( value ) {
326+ for ( let i = 0 ; i < path . length ; i ++ ) {
327+ let sub = value [ path [ i ] ] ;
328+ if ( sub === void 0 ) {
329+ return void 0 ;
330+ }
331+ value = sub ;
332+ }
333+ if ( name === _createdDateKey ) {
334+ let n = parseInt ( value , 36 ) ;
335+ return isNaN ( n ) ? null : new Date ( n ) ;
336+ }
337+ return value ;
338+ } else {
339+ return void 0 ;
340+ }
341+ }
342+ initConfig ( onget ) {
343+ if ( this . _config === void 0 ) {
344+ this . _config = { } ;
345+ }
346+ }
347+ setConfig ( name , value ) {
348+ this . initConfig ( false ) ;
349+ let path = name . split ( "." ) ;
350+ let item = this . _config ;
351+ if ( item ) {
352+ for ( let i = 0 ; i < path . length - 1 ; i ++ ) {
353+ let sub = item [ path [ i ] ] ;
354+ if ( sub === void 0 ) {
355+ item [ path [ i ] ] = sub = { } ;
356+ }
357+ item = sub ;
358+ }
359+ item [ path [ path . length - 1 ] ] = value ;
360+ }
361+ }
362+ restartApp ( ) { }
363+ }
364+
365+ window . osenv = new ViewProAppBase ( ) ;
366+ window . gc_native_app = true ;
0 commit comments