From c154b154e9f174ab98c6526ab7d63407f8140ea5 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 19 Jan 2018 15:20:45 +0300 Subject: [PATCH] [DE] Change style for existing table in contents from toolbar presets. --- .../main/app/controller/Links.js | 22 ++++++++++++++----- .../main/app/view/TableOfContentsSettings.js | 5 +++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 71173365b..db5780a80 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -204,20 +204,30 @@ define([ onTableContents: function(type){ switch (type) { case 0: - var props = new Asc.CTableOfContentsPr(); + var props = this.api.asc_GetTableOfContentsPr(), + hasTable = !!props; + if (!props) { + props = new Asc.CTableOfContentsPr(); + props.put_OutlineRange(1, 9); + } props.put_Hyperlink(true); props.put_ShowPageNumbers(true); props.put_RightAlignTab(true); props.put_TabLeader( Asc.c_oAscTabLeader.Dot); - props.put_OutlineRange(1, 9); - this.api.asc_AddTableOfContents(props); break; + (hasTable) ? this.api.asc_SetTableOfContentsPr(props) : this.api.asc_AddTableOfContents(props); + break; case 1: - var props = new Asc.CTableOfContentsPr(); + var props = this.api.asc_GetTableOfContentsPr(), + hasTable = !!props; + if (!props) { + props = new Asc.CTableOfContentsPr(); + props.put_OutlineRange(1, 9); + } props.put_Hyperlink(true); props.put_ShowPageNumbers(false); props.put_TabLeader( Asc.c_oAscTabLeader.None); - props.put_OutlineRange(1, 9); - this.api.asc_AddTableOfContents(props); break; + (hasTable) ? this.api.asc_SetTableOfContentsPr(props) : this.api.asc_AddTableOfContents(props); + break; case 'settings': var props = this.api.asc_GetTableOfContentsPr(), me = this; diff --git a/apps/documenteditor/main/app/view/TableOfContentsSettings.js b/apps/documenteditor/main/app/view/TableOfContentsSettings.js index 2d5b35b06..bcd738336 100644 --- a/apps/documenteditor/main/app/view/TableOfContentsSettings.js +++ b/apps/documenteditor/main/app/view/TableOfContentsSettings.js @@ -449,9 +449,10 @@ define([ props.put_Hyperlink(this.chLinks.getValue() == 'checked'); props.put_ShowPageNumbers(this.chPages.getValue() == 'checked'); - if (this.chPages.getValue() == 'checked') + if (this.chPages.getValue() == 'checked') { props.put_RightAlignTab(this.chAlign.getValue() == 'checked'); - props.put_TabLeader(this.cmbLeader.getValue()); + props.put_TabLeader(this.cmbLeader.getValue()); + } props.put_StylesType(this.cmbStyles.getValue()); props.clear_Styles();