Ejemplo n.º 1
0
        public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
        {
            Application onApp = (Application)Application;

            this.addInsList = onApp.COMAddIns;
            this.lTools     = addInsList.Item(1);
        }
Ejemplo n.º 2
0
        private bool addWordItem(String subTemplateName, ExportItemMap itemMap)
        {
            word.Application Word = Globals.ThisAddIn.wordApp;
            if (Word == null || Word.Visible == false)
            {
                MessageBox.Show("word doesn't link, this just for debug");
                return(false);//do not link, just return.
            }
            COMAddIns addins = Word.COMAddIns;

            foreach (COMAddIn addin in addins)
            {
                if (addin.Description.Equals("Pdw"))
                {
                    Object pdwApp = addin.Object;
                    //object[] invokeArgs = { subTemplateName, itemMap.treeNodeIndex, itemMap.treeNodeName, itemMap.type };
                    int[]    indexs;
                    string[] names;
                    string[] types;
                    if (itemMap.mapType == ProntoDoc.Framework.CoreObject.MapType.singleCell)
                    {
                        indexs = new int[1];
                        names  = new string[1];
                        types  = new string[1];
                    }
                    else
                    {
                        int count = itemMap.tabCols.Count + 1;
                        indexs = new int[count];
                        names  = new string[count];
                        types  = new string[count];
                        int i = 1;
                        foreach (TableColumnMap col in itemMap.tabCols)
                        {
                            indexs[i] = 0;//
                            names[i]  = col.treeNodeName;
                            types[i]  = col.dataType;
                            i++;
                        }
                    }
                    indexs[0] = itemMap.treeNodeIndex;
                    names[0]  = itemMap.treeNodeName;
                    types[0]  = itemMap.dataType;

                    object[] invokeArgs = { subTemplateName, indexs, names, types };
                    try
                    {
                        object retVal = pdwApp.GetType().InvokeMember("addPdeItem",
                                                                      System.Reflection.BindingFlags.InvokeMethod, null, pdwApp, invokeArgs);
                        return(Boolean.Parse(retVal.ToString()));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.StackTrace);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        private void enablePdw(word.Application app)
        {
            COMAddIns addins = app.COMAddIns;

            foreach (COMAddIn addin in addins)
            {
                if (addin.Description.Equals("Pdw"))
                {
                    addin.Connect = true;
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        private void refershWordAddIn(word.Application Word)
        {
            COMAddIns addins = Word.COMAddIns;

            foreach (COMAddIn addin in addins)
            {
                if (addin.Description.Equals("Pdw"))
                {
                    //IAddinUtilities util = (IAddinUtilities)addin.Object;
                    //string result = util.DoSomething("from1");
                    //MessageBox.Show(result);

                    Object   pdwApp     = addin.Object;
                    object[] invokeArgs = { " name in excel" };
                    object   retVal     = pdwApp.GetType().InvokeMember("DoSomething",
                                                                        System.Reflection.BindingFlags.InvokeMethod, null, pdwApp, invokeArgs);
                    MessageBox.Show(retVal.ToString());
                }
            }
        }
Ejemplo n.º 5
0
        private void button5_Click(object sender, EventArgs e)
        {
            word.Application wordApp = new word.Application();
            COMAddIns        addins  = wordApp.COMAddIns;

            foreach (COMAddIn addin in addins)
            {
                if (addin.Description.Equals("Pdw"))
                {
                    AddinUtilities util   = (AddinUtilities)addin.Object;
                    string         result = util.DoSomething("from1");
                    MessageBox.Show(result);

                    Object   pdwApp     = addin.Object;
                    object[] invokeArgs = { "name in form1" };
                    object   retVal     = pdwApp.GetType().InvokeMember("DoSomething",
                                                                        System.Reflection.BindingFlags.InvokeMethod, null, pdwApp, invokeArgs);
                    MessageBox.Show(retVal.ToString());
                }
            }
        }
Ejemplo n.º 6
0
        private void SetEikonExcelDisable(ref ExcelApp excelApp, ref COMAddIn comAddIn)
        {
            excelApp = new ExcelApp(false, false);
            if (excelApp == null)
            {
                string msg = "Excel could not be started. Check that your office installation and project reference are correct!";
                Logger.Log(msg, Logger.LogType.Error);
                return;
            }

            COMAddIns addIns = excelApp.ExcelAppInstance.COMAddIns;

            foreach (COMAddIn item in addIns)
            {
                //Disable Eikon Excel.
                if (item.ProgId.Trim().Equals("PowerlinkCOMAddIn.COMAddIn"))
                {
                    item.Connect = false;
                    comAddIn     = item;
                }
            }
        }
Ejemplo n.º 7
0
        private word.Application createWord()
        {
            word.Application app = new word.Application();
            app.Visible = true;

            Thread.Sleep(2000);

            //disable the pdw plugin
            COMAddIn  pdwAddin = null;
            COMAddIns addins   = app.COMAddIns;

            foreach (COMAddIn addin in addins)
            {
                if (addin.Description.Equals("Pdw"))
                {
                    addin.Connect = false;
                    pdwAddin      = addin;
                    break;
                }
            }
            Thread.Sleep(1000);
            return(app);
        }
Ejemplo n.º 8
0
        private bool updateWordItem(String subTemplateName, string treeNodePath, string newName)
        {
            word.Application Word = Globals.ThisAddIn.wordApp;
            if (Word == null || Word.Visible == false)
            {
                MessageBox.Show("word doesn't link, this just for debug");
                return(false);//do not link, just return.
            }
            COMAddIns addins = Word.COMAddIns;

            foreach (COMAddIn addin in addins)
            {
                if (addin.Description.Equals("Pdw"))
                {
                    Object   pdwApp     = addin.Object;
                    object[] invokeArgs = { subTemplateName, treeNodePath, newName };
                    object   retVal     = pdwApp.GetType().InvokeMember("updatePdeItem",
                                                                        System.Reflection.BindingFlags.InvokeMethod, null, pdwApp, invokeArgs);
                    return(Boolean.Parse(retVal.ToString()));
                }
            }
            MessageBox.Show("Cannot found pdw plugin in word, please check it!");
            return(false);
        }
Ejemplo n.º 9
0
        private void button8_Click(object sender, EventArgs e)
        {
            word.Application app = new word.Application();
            app.Visible = true;

            Thread.Sleep(2000);

            //disable the pdw plugin
            COMAddIn  pdwAddin = null;
            COMAddIns addins   = app.COMAddIns;

            foreach (COMAddIn addin in addins)
            {
                if (addin.Description.Equals("Pdw"))
                {
                    addin.Connect = false;
                    pdwAddin      = addin;
                    break;
                }
            }
            Thread.Sleep(1000);
            string tempFile = textBox_pdw.Text;
            string wordFile = tempFile.Split('.')[0] + ".docx";

            File.Copy(tempFile, wordFile, true);
            word.Document doc = app.Documents.Open(wordFile);
            //change properties of document
            //foreach (DocumentProperty docPro in doc.CustomDocumentProperties)
            //{
            //    if (docPro.Name.StartsWith("Pronto_ImportedExcelFileName"))
            //    {
            //        docPro.Value = textBox_pdwpder.Text;
            //    }
            //}
            //remove pde template and add pder file.
            PdeContent pdeImported = null;
            string     xsl         = null;

            foreach (CustomXMLPart xmlPart in doc.CustomXMLParts)
            {
                if (xmlPart.BuiltIn)
                {
                    continue;
                }
                XmlObject customObject = ObjectSerializeHelper.Deserialize <XmlObject>(xmlPart.XML);
                if (customObject.ContentType == ContentType.ImportedPde)
                {
                    pdeImported = ObjectSerializeHelper.Deserialize <PdeContent>(customObject.Content);
                }
                else if (customObject.ContentType == ContentType.Xslt)
                {
                    xsl = customObject.Content;
                }
                xmlPart.Delete();
            }
            //add pder file
            CustomXMLPart xmlPart_pder = doc.CustomXMLParts.Add();

            pdeImported.FileContent = FileHelper.ExcelToBase64(textBox_pdwpder.Text);
            //pdeImported.FullFileName = textBox_pdwpder.Text;
            XmlObject pderObj = new XmlObject();

            pderObj.ContentType = ContentType.ImportedPde;
            pderObj.Content     = ObjectSerializeHelper.SerializeToString <PdeContent>(pdeImported);
            xmlPart_pder.LoadXML(ObjectSerializeHelper.SerializeToString <XmlObject>(pderObj));
            //add xml data file
            XmlDocument dataXml = new XmlDocument();

            dataXml.Load(textBox_pdwd.Text);
            XmlObject     pdwrXml     = new XmlObject(dataXml.InnerXml, ContentType.PdwrXml);
            CustomXMLPart xmlPart_xml = doc.CustomXMLParts.Add();

            xmlPart_xml.LoadXML(ObjectSerializeHelper.SerializeToString <XmlObject>(pdwrXml));
            //add xsl file
            XmlObject xslObj = new XmlObject();

            xslObj.ContentType = ContentType.PdwrXsl;
            xslObj.Content     = xsl;
            CustomXMLPart xmlpart_xsl = doc.CustomXMLParts.Add();

            xmlpart_xsl.LoadXML(ObjectSerializeHelper.SerializeToString <XmlObject>(xslObj));
            //add pdwr setting
            XmlObject settObj = new XmlObject();

            settObj.ContentType = ContentType.PdwrSettings;
            settObj.Content     = "<?xml version=\"1.0\" encoding=\"utf-16\"?><RenderSettings xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Media>Docx</Media><Channel>Display</Channel></RenderSettings>";
            CustomXMLPart xmlpart_sett = doc.CustomXMLParts.Add();

            xmlpart_sett.LoadXML(ObjectSerializeHelper.SerializeToString <XmlObject>(settObj));

            doc.Save();
            doc.Close();
            pdwAddin.Connect = true;
            app.Quit();
            File.Copy(wordFile, wordFile.Split('.')[0] + ".pdwr", true);
            MessageBox.Show("Create pdwr file success.");
        }