/// <summary>
        /// Constructor that find and initialize the first chart found in the content control
        /// </summary>
        /// <param name="content_control">SdtElement instance represent the content control</param>
        public Helper_WordBarChart(SdtElement content_control)
        {
            rotated_table = StaticValues.barchart_rotatedtable;
            if (!Init(content_control))
            {
                return;
            }

            // Get the first ChartPart instance found in the content control
            XElement chart_content_control = Helper_WordBase.GetContentControlByTag(Helper_WordBase.GetContentControlXMLBySdtElement(content_control), StaticValues.content_cc_name);
            string   chart_id = (string)chart_content_control.Descendants(StaticValues.c + "chart").Attributes(StaticValues.r + "id").FirstOrDefault <XAttribute>().Value;

            chart_part = (ChartPart)WordTemplateManager.document.MainDocumentPart.GetPartById(chart_id);

            if (chart_part == null)
            {
                StaticValues.logs += "[Error][WordChart]Can't initialize required data using the input content control" + Environment.NewLine;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// The function used to initialize the required data
        /// </summary>
        /// <param name="content_control">SdtElement instance for the content control</param>
        public virtual bool Init(SdtElement content_control)
        {
            this.content_control = content_control;
            if (this.content_control == null)
            {
                StaticValues.logs += "[Error]Can't get the content control" + Environment.NewLine;
                return(false);
            }

            // Get the SQL statement in the nested content control
            XElement sql_content_control = Helper_WordBase.GetContentControlByTag(Helper_WordBase.GetContentControlXMLBySdtElement(content_control), StaticValues.sql_cc_name);

            if (sql_content_control != null)
            {
                sql_query = sql_content_control.Value.ToString();
            }

            if (sql_query != null && !StaticValues.use_default_tablename_in_sql)
            {
                sql_query = sql_query.Replace(StaticValues.dummy_table_name, StaticValues.project_table_name);
            }

            return(true);
        }