コード例 #1
0
        public void AddXMLNode(Office.CustomXMLPart TreeviewXMLPart, string id, string wordcount, string pgcount, string text, string bookmark, System.Windows.Media.Color CardColor)// this adds a node for the card in the custom XML file
        {
            string color = CardColor.R.ToString() + "," + CardColor.G.ToString() + "," + CardColor.B.ToString();

            Office.CustomXMLNode node = TreeviewXMLPart.SelectSingleNode("//cardList[1]");//[@xmlns=CARDS]
            Office.CustomXMLNode childNode;
            if (node == null)
            {
                MessageBox.Show("Node = null");
            }
            try
            {
                node.AppendChildNode("node", "", Office.MsoCustomXMLNodeType.msoCustomXMLNodeElement, text);
                childNode = node.LastChild;
                childNode.AppendChildNode("id", "", Office.MsoCustomXMLNodeType.msoCustomXMLNodeAttribute, id);
                childNode.AppendChildNode("words", "", Office.MsoCustomXMLNodeType.msoCustomXMLNodeAttribute, wordcount);
                childNode.AppendChildNode("Pages", "", Office.MsoCustomXMLNodeType.msoCustomXMLNodeAttribute, pgcount);
                childNode.AppendChildNode("bookmark", "", Office.MsoCustomXMLNodeType.msoCustomXMLNodeAttribute, bookmark);
                childNode.AppendChildNode("color", "", Office.MsoCustomXMLNodeType.msoCustomXMLNodeAttribute, color);
            }
            catch
            {
                MessageBox.Show("problem: " + TreeviewXMLPart.DocumentElement.XML + "\n---------\n" + TreeviewXMLPart.XML);
            }
        }
        /// <summary>
        /// Change the currently active document.
        /// </summary>
        internal void ChangeCurrentDocument()
        {
            Debug.WriteLine("Changing event document to " + Globals.ThisAddIn.Application.ActiveDocument.Name);

            //unhook existing events
            m_wddoc.ContentControlOnEnter  -= (Word.DocumentEvents2_ContentControlOnEnterEventHandler)m_alDocumentEvents[0];
            m_wddoc.ContentControlAfterAdd -= (Word.DocumentEvents2_ContentControlAfterAddEventHandler)m_alDocumentEvents[1];
            m_parts.PartAfterAdd           -= (Office._CustomXMLPartsEvents_PartAfterAddEventHandler)m_alPartsEvents[0];
            m_parts.PartBeforeDelete       -= (Office._CustomXMLPartsEvents_PartBeforeDeleteEventHandler)m_alPartsEvents[1];
            m_parts.PartAfterLoad          -= (Office._CustomXMLPartsEvents_PartAfterLoadEventHandler)m_alPartsEvents[2];
            m_currentPart.NodeAfterDelete  -= (Office._CustomXMLPartEvents_NodeAfterDeleteEventHandler)m_alPartEvents[0];
            m_currentPart.NodeAfterInsert  -= (Office._CustomXMLPartEvents_NodeAfterInsertEventHandler)m_alPartEvents[1];
            m_currentPart.NodeAfterReplace -= (Office._CustomXMLPartEvents_NodeAfterReplaceEventHandler)m_alPartEvents[2];

            //release the streams + stream handler references
            m_alDocumentEvents.Clear();
            m_alPartsEvents.Clear();
            m_alPartEvents.Clear();

            //clean up the m_wddoc object (since otherwise the RCW gets disposed out from under it)
            m_wddoc = null;
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            //hook up new objects
            m_wddoc       = Globals.ThisAddIn.Application.ActiveDocument;
            m_parts       = m_wddoc.CustomXMLParts;
            m_currentPart = m_parts[1];

            SetupEventHandlers();
        }
コード例 #3
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //prompt to delete the stream
            if (ShowYesNoMessage(Properties.Resources.DeletePartMessage) == DialogResult.Yes)
            {
                try
                {
                    //try to delete the stream
                    Office.CustomXMLPart partToDelete = CurrentPartCollection[m_intLastSelected + 1];
                    partToDelete.Delete();

                    //refresh the picker
                    RefreshPartList(true, true, false, string.Empty, null, null);

                    //set the new selection
                    m_intLastSelected = comboBoxPartList.SelectedIndex;

                    //fire back at the event class to switch up the event handlers as well
                    Debug.Assert(EventHandler != null, "null event handler");
                    EventHandler.ChangeCurrentPart(CurrentPartCollection[m_intLastSelected + 1]);
                }
                catch (COMException ex)
                {
                    ShowErrorMessage(string.Format(CultureInfo.CurrentUICulture, Properties.Resources.ErrorDeletePart, ex.Message));
                }
            }
        }
コード例 #4
0
        private InternalBookmark GetPdeInternalBookmark(Excel.Workbook workbook)
        {
            // get partID
            object objProperties     = workbook.CustomDocumentProperties;
            Type   objPropertiesType = objProperties.GetType();
            object objProperty       = objPropertiesType.InvokeMember("Item",
                                                                      System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.GetProperty,
                                                                      null, objProperties, new object[] { ProntoMarkup.InternalBMCustomXmlPartId });
            Type   objPropertyType = objProperty.GetType();
            string partID          = objPropertyType.InvokeMember("Value",
                                                                  System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.GetProperty,
                                                                  null, objProperty, new object[] { }).ToString();

            if (string.IsNullOrWhiteSpace(partID))
            {
                return(null);
            }

            // get XmlObject in CustomXmlPart
            Office.CustomXMLPart xmlPart = workbook.CustomXMLParts.SelectByID(partID);
            string xmlObjectString       = xmlPart.XML;

            if (string.IsNullOrWhiteSpace(xmlObjectString))
            {
                return(null);
            }
            XmlObject xmlObject = ProntoDoc.Framework.Utils.ObjectSerializeHelper.Deserialize <XmlObject>(xmlObjectString);

            // get InternalBookmark
            if (xmlObject == null || string.IsNullOrWhiteSpace(xmlObject.Content))
            {
                return(null);
            }
            return(ProntoDoc.Framework.Utils.ObjectSerializeHelper.Deserialize <InternalBookmark>(xmlObject.Content));
        }
コード例 #5
0
        public static bool areOpenDoPEPartsPresent(Word.Document document)
        {
            // TODO consider removing this, or moving it,
            // refer instead Model.cs

            // Modified from OpenDoPE_Wed ThisAddIn
            Office.CustomXMLPart xpathsPart     = null;
            Office.CustomXMLPart conditionsPart = null;

            foreach (Office.CustomXMLPart cp in document.CustomXMLParts)
            {
                if (cp.NamespaceURI.Equals(Namespaces.XPATHS))
                {
                    // check for duplicate parts; introduced 2013 12 08
                    if (xpathsPart != null)
                    {
                        MessageBox.Show("Duplicate parts detected. This template needs to be manually repaired.  Please contact your help desk.");
                    }


                    xpathsPart = cp;
                }
                else if (cp.NamespaceURI.Equals(Namespaces.CONDITIONS))
                {
                    conditionsPart = cp;
                }
            }

            return(xpathsPart != null && conditionsPart != null);
        }
        /// <summary>
        /// Change the currently active XML part.
        /// </summary>
        /// <param name="cxp">The CustomXMLPart specifying the newly active XML part.</param>
        internal void ChangeCurrentPart(Office.CustomXMLPart cxp)
        {
            if (cxp != null)
            {
                Debug.WriteLine("Changing event stream to " + cxp.Id);

                //unhook the stream event handlers
                m_currentPart.NodeAfterDelete  -= (Office._CustomXMLPartEvents_NodeAfterDeleteEventHandler)m_alPartEvents[0];
                m_currentPart.NodeAfterInsert  -= (Office._CustomXMLPartEvents_NodeAfterInsertEventHandler)m_alPartEvents[1];
                m_currentPart.NodeAfterReplace -= (Office._CustomXMLPartEvents_NodeAfterReplaceEventHandler)m_alPartEvents[2];

                //release the streams + event handler references
                m_currentPart = null;
                m_alPartEvents.Clear();

                //hook up the new stream
                m_currentPart = cxp;

                //set up event handlers on the supplied stream
                m_alPartEvents.Add(new Office._CustomXMLPartEvents_NodeAfterDeleteEventHandler(part_NodeAfterDelete));
                m_alPartEvents.Add(new Office._CustomXMLPartEvents_NodeAfterInsertEventHandler(part_NodeAfterInsert));
                m_alPartEvents.Add(new Office._CustomXMLPartEvents_NodeAfterReplaceEventHandler(part_NodeAfterReplace));
                m_currentPart.NodeAfterDelete  += (Office._CustomXMLPartEvents_NodeAfterDeleteEventHandler)m_alPartEvents[0];
                m_currentPart.NodeAfterInsert  += (Office._CustomXMLPartEvents_NodeAfterInsertEventHandler)m_alPartEvents[1];
                m_currentPart.NodeAfterReplace += (Office._CustomXMLPartEvents_NodeAfterReplaceEventHandler)m_alPartEvents[2];
            }
            else
            {
                Debug.Fail("SetCurrentStream received a null stream");
            }
        }
コード例 #7
0
 private void ThisDocument_Startup(object sender, System.EventArgs e)
 {
     this.ContentControlOnEnter += ThisDocument_ContentControlOnEnter;
     this.BeforeSave            += ThisDocument_BeforeSave;
     try
     {
         Office.DocumentProperties docProps =
             this.CustomDocumentProperties as Office.DocumentProperties;
         foreach (Office.DocumentProperty docprop in docProps)
         {
             if (docprop.Name == "HurTestDataSet")
             {
                 docDataSetID = (string)docprop.Value;
                 if (docDataSetID != null)
                 {
                     Office.CustomXMLPart docDataSetPart =
                         this.CustomXMLParts.SelectByID(docDataSetID);
                     System.IO.StringReader srdr = new System.IO.StringReader(docDataSetPart.XML);
                     docDataSet.ReadXml(srdr);
                 }
             }
         }
     }
     catch
     {
     }
 }
コード例 #8
0
        Office.CustomXMLPart addCustomXmlPart(Word.Document document, string xml)
        {
            object missing = System.Reflection.Missing.Value;

            Office.CustomXMLPart cxp = document.CustomXMLParts.Add(xml, missing);

            log.Debug("part added");

            //bool result = cxp.LoadXML("<mynewpart><blagh/></mynewpart>");

            /*
             * Can't do this .. causes System.Runtime.InteropServices.COMException
             * "This custom XML part has already been loaded"
             *
             * Why?  What is the method for if it can't be used?
             *
             * So our options are:
             *
             * 1. replace from root node
             * 2. Delete the part, and re-add
             *
             * Will Word remove the bindings if we do this?
             *
             */

            //replaceXmlDoc(cxp, "<mynewpart><blagh/></mynewpart>");

            log.Debug("done");

            return(cxp);
        }
コード例 #9
0
        public static void replaceXmlDoc(Office.CustomXMLPart cxp, String newContent)
        {
            /* Office.CustomXMLNode node = cxp.SelectSingleNode("/");
             * // gives you #document,
             * // but you can't get the root node from it?
             *
             * //node = cxp.SelectSingleNode("/mypart");
             */

            Office.CustomXMLNode node = cxp.SelectSingleNode("/node()");
            //log.Debug(node.XML);
            //log.Debug(node.XPath);

            Office.CustomXMLNode parent = node.ParentNode;

            log.Debug(parent.BaseName);

            //parent.ReplaceChildNode(node, "mynewnode", "", Office.MsoCustomXMLNodeType.msoCustomXMLNodeElement, "");

            parent.ReplaceChildSubtree(newContent, node);

            //parent.RemoveChild(node); //doesn't work

            //parent.AppendChildSubtree("<mynewpart><blagh/></mynewpart>");

            node = cxp.SelectSingleNode("/");
            log.Debug(node.XML);
        }
コード例 #10
0
        public FormAddNode(IXPathNavigable node, Office.CustomXMLPart part)
        {
            InitializeComponent();

            //set up state
            m_xn = node as XmlNode;
            m_cxp = part;
        }
コード例 #11
0
        public FormAddNode(IXPathNavigable node, Office.CustomXMLPart part)
        {
            InitializeComponent();

            //set up state
            m_xn  = node as XmlNode;
            m_cxp = part;
        }
コード例 #12
0
        public FormQuestion(Office.CustomXMLPart questionsPart, string xpath, string xpathId)
        {
            InitializeComponent();
            this.questionsPart = questionsPart;

            this.textBoxXPath.Text = xpath;
            this.textBoxQID.Text = "q" + xpathId;
        }
コード例 #13
0
        public FormQuestion(Office.CustomXMLPart questionsPart, string xpath, string xpathId)
        {
            InitializeComponent();
            this.questionsPart = questionsPart;

            this.textBoxXPath.Text = xpath;
            this.textBoxQID.Text   = "q" + xpathId;
        }
コード例 #14
0
        public static void AddCustomXmlPart(Excel.Workbook workbook, string namespaceName, string xmlString)
        {
            System.Collections.IEnumerator enumerator = workbook.CustomXMLParts.SelectByNamespace(namespaceName).GetEnumerator();
            enumerator.Reset();

            if (!(enumerator.MoveNext())) // false if XmlPart already exists
            {
                Office.CustomXMLPart p = workbook.CustomXMLParts.Add(xmlString);
            }
        }
コード例 #15
0
        public DocumentEvents(Controls.ControlMain cm)
        {
            //get the initial part
            m_cmTaskPane  = cm;
            m_wddoc       = Globals.ThisAddIn.Application.ActiveDocument;
            m_parts       = m_wddoc.CustomXMLParts;
            m_currentPart = cm.model.getUserPart(System.Configuration.ConfigurationManager.AppSettings["RootElement"]);

            //hook up event handlers
            SetupEventHandlers();
        }
        public DocumentEvents(Controls.ControlMain cm)
        {
            //get the initial part
            m_cmTaskPane  = cm;
            m_wddoc       = Globals.ThisAddIn.Application.ActiveDocument;
            m_parts       = m_wddoc.CustomXMLParts;
            m_currentPart = m_parts[1];

            //hook up event handlers
            SetupEventHandlers();
        }
コード例 #17
0
        public void Create_CustomXML()// this adds a custom XML file with the right parameters
        {
            var xDoc = new XDocument(
                new XDeclaration("1.0", "utf-8", "no"),
                new XComment("Data for Cards Add-In"),
                new XElement("Root",
                             new XElement("cardList", "")
                             )
                );

            myXML = this.Application.ActiveDocument.CustomXMLParts.Add(xDoc.ToString(), missing);
            //CardTotal = 0;
        }
コード例 #18
0
 public void Check_CustomXML(int firstoccurrence = 0)// this check if there is a custom XML file and if not add one
 {
     myXML = GetMyXML();
     if (myXML != null)
     {
         MessageBox.Show("This document had already a Custom XML file.");
     }
     else
     {
         Create_CustomXML();
         MessageBox.Show("Created a new Custom XML file.");
     }
 }
コード例 #19
0
        /// <summary>
        /// Replace the contents of the existing XML part.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void buttonReplaceXML_Click(Office.IRibbonControl control)
        {
            CustomTaskPane ctpPaneForThisWindow = Utilities.FindTaskPaneForCurrentWindow();

            Controls.ControlMain ccm = (Controls.ControlMain)ctpPaneForThisWindow.Control;

            Office.CustomXMLPart userPart = null;
            bool cancelled = false;

            while (userPart == null && !cancelled)
            {
                using (Forms.FormAddPart fap = new Forms.FormAddPart())
                {
                    if (fap.ShowDialog() == DialogResult.OK)
                    {
                        string requiredRoot = System.Configuration.ConfigurationManager.AppSettings["RootElement"];
                        if (string.IsNullOrWhiteSpace(requiredRoot))
                        {
                            ccm.EventHandlerAndOnChildren.NodeAfterReplaceDisconnect();
                            Office.CustomXMLPart existingPart = ccm.model.getUserPart(requiredRoot);
                            CustomXmlUtilities.replaceXmlDoc(existingPart, fap.XmlString);
                            userPart = existingPart;
                        }
                        else
                        {
                            Office.CustomXMLPart existingPart = ccm.model.getUserPart(requiredRoot);
                            if (existingPart.DocumentElement.BaseName.Equals(requiredRoot))
                            {
                                ccm.EventHandlerAndOnChildren.NodeAfterReplaceDisconnect();
                                CustomXmlUtilities.replaceXmlDoc(existingPart, fap.XmlString);
                                userPart = existingPart;
                            }
                            else
                            {
                                MessageBox.Show("You need to use root element: " + requiredRoot);
                            }
                        }
                    }
                    else
                    {
                        cancelled = true;
                    }
                }
            }

            if (!cancelled)
            {
                ccm.EventHandlerAndOnChildren.NodeAfterReplaceReconnect();
            }
            ccm.RefreshTreeControl(null);
        }
コード例 #20
0
        /* public void RefreshCardsIDs()
         * {
         *   int idx = 1;
         *   foreach (CardControl carditem in ListCardControls)
         *   {
         *       carditem.IDfield = idx.ToString();
         *       idx++;
         *   }
         * }*/

        #region XML-ListCardControls CONNECTION
        public void LoadXmltoListCardControls(Office.CustomXMLPart xmlPart)
        {
            ListCardControls.Clear();

            Office.CustomXMLNodes XMLnodes = xmlPart.SelectNodes("//node");
            string colorstring             = "";

            foreach (Office.CustomXMLNode nodElem in XMLnodes)
            {
                CardControl card = new CardControl();
                card.Textfield = nodElem.Text;


                foreach (Office.CustomXMLNode attr in nodElem.Attributes) // grab the attributes for the node tag
                {
                    if (attr.XML.Contains("id"))
                    {
                        card.IDfield = attr.NodeValue;
                    }
                    if (attr.XML.Contains("bookmark"))
                    {
                        if (attr.NodeValue == "")
                        {
                            attr.NodeValue = "NONE";
                        }
                        card.Bookmarkfield = attr.NodeValue;
                    }
                    if (attr.XML.Contains("color"))
                    {
                        colorstring = attr.NodeValue;
                    }
                }
                string wordcount = "0";
                string pgcount   = "0";

                string[] i = colorstring.Split(',');
                System.Windows.Media.Color CardColor = System.Windows.Media.Color.FromRgb(250, 250, 160);
                try
                {
                    card.Colorfield = Color.FromRgb(byte.Parse(i[0]), byte.Parse(i[1]), byte.Parse(i[2]));
                }
                catch
                {
                    card.Colorfield = CardColor;
                }

                ListCardControls.Add(card);
                card.IDfield = FindIndexCard(card);
            }
        }
コード例 #21
0
        //</Snippet3>

        //<Snippet4>
        private void AddCustomXmlPart(string xmlData)
        {
            if (xmlData != null)
            {
                employeeXMLPart = this.CustomXMLParts.SelectByID(employeeXMLPartID);
                if (employeeXMLPart == null)
                {
                    employeeXMLPart = this.CustomXMLParts.Add(xmlData);
                    employeeXMLPart.NamespaceManager.AddNamespace("ns",
                                                                  @"http://schemas.microsoft.com/vsto/samples");
                    employeeXMLPartID = employeeXMLPart.Id;
                }
            }
        }
コード例 #22
0
        /// <summary>
        /// remove custom xml part (internal bookmark, osql, checksum, comment)
        /// </summary>
        /// <param name="wDoc"></param>
        private void RemoveCustomXmlParts(Microsoft.Office.Interop.Word.Document wDoc)
        {
            try
            {
                Pdwx.Services.WordHeper.RemoveProtectPassword(wDoc, ProtectLevel.All);

                // accept all changes
                try
                {
                    if (wDoc.TrackRevisions)
                    {
                        wDoc.AcceptAllRevisions();
                    }
                }
                catch { }

                List <string> xmlPartIds = new List <string>();
                if (wDoc.CustomXMLParts != null)
                {
                    foreach (Microsoft.Office.Core.CustomXMLPart xmlPart in wDoc.CustomXMLParts)
                    {
                        if (!xmlPart.BuiltIn)
                        {
                            xmlPartIds.Add(xmlPart.Id);
                        }
                    }
                }
                foreach (string xmlPartId in xmlPartIds)
                {
                    Microsoft.Office.Core.CustomXMLPart oldXmlPart = wDoc.CustomXMLParts.SelectByID(xmlPartId);

                    if (oldXmlPart != null)
                    {
                        oldXmlPart.Delete();
                    }
                }

                if (wDoc.Bookmarks != null)
                {
                    foreach (Microsoft.Office.Interop.Word.Bookmark wBm in wDoc.Bookmarks)
                    {
                        if (Core.MarkupUtilities.IsProntoDocCommentBookmark(wBm.Name))
                        {
                            wBm.Range.Text = string.Empty; // remove the bookmark
                        }
                    }
                }
            }
            catch { }
        }
コード例 #23
0
        //<Snippet1>
        private void AddCustomXmlPartToWorkbook(Excel.Workbook workbook)
        {
            string xmlString =
                "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
                "<employees xmlns=\"http://schemas.microsoft.com/vsto/samples\">" +
                "<employee>" +
                "<name>Karina Leal</name>" +
                "<hireDate>1999-04-01</hireDate>" +
                "<title>Manager</title>" +
                "</employee>" +
                "</employees>";

            Office.CustomXMLPart employeeXMLPart = workbook.CustomXMLParts.Add(xmlString, missing);
        }
コード例 #24
0
        //<Snippet1>
        private void AddCustomXmlPartToPresentation(PowerPoint.Presentation presentation)
        {
            string xmlString =
                "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
                "<employees xmlns=\"http://schemas.microsoft.com/vsto/samples\">" +
                "<employee>" +
                "<name>Karina Leal</name>" +
                "<hireDate>1999-04-01</hireDate>" +
                "<title>Manager</title>" +
                "</employee>" +
                "</employees>";

            Office.CustomXMLPart employeeXMLPart =
                presentation.CustomXMLParts.Add(xmlString, missing);
        }
コード例 #25
0
        public static List <string> ListXmlNamespaces(Excel.Workbook workbook)
        {
            var result = new List <string>();

            Office.CustomXMLParts ps = workbook.CustomXMLParts;
            for (int i = 1; i <= workbook.CustomXMLParts.Count; i++)
            {
                Office.CustomXMLPart p = ps[i];

                //p.BuiltIn will be true for internal buildin excel parts
                if (p != null && !p.BuiltIn)
                {
                    result.Add(p.NamespaceURI);
                }
            }

            return(result);
        }
コード例 #26
0
        /// <summary>
        /// Stuff required to create XPath element
        /// (except for ID, which this method generates)
        /// </summary>
        /// <param name="xpath"></param>
        /// <param name="storeItemID"></param>
        /// <param name="prefixMappings"></param>
        /// <param name="questionID"></param>
        public static xpathsXpath updateXPathsPart(
            Office.CustomXMLPart xpathsPart,
            string xpath,
            string xpathId,
            string storeItemID, string prefixMappings,
            string questionID)
        {
            //Office.CustomXMLPart xpathsPart = ((WedTaskPane)this.Parent.Parent.Parent).xpathsPart;

            xpaths xpaths = new xpaths();

            xpaths.Deserialize(xpathsPart.XML, out xpaths);

            xpathsXpath item = new xpathsXpath();

            item.id = xpathId; //System.Guid.NewGuid().ToString();

            if (!string.IsNullOrWhiteSpace(questionID))
            {
                item.questionID = questionID;
            }

            xpathsXpathDataBinding db = new xpathsXpathDataBinding();

            db.xpath       = xpath;
            db.storeItemID = storeItemID;
            if (!string.IsNullOrWhiteSpace(prefixMappings))
            {
                db.prefixMappings = prefixMappings;
            }
            item.dataBinding = db;

            xpaths.xpath.Add(item);

            // Save it in docx
            string result = xpaths.Serialize();

            log.Info(result);
            CustomXmlUtilities.replaceXmlDoc(xpathsPart, result);

            return(item);
        }
コード例 #27
0
        public static Office.CustomXMLNode GetCustomXmlNode(Excel.Workbook workbook, string xNameSpace,
                                                            string xPath)
        {
            Office.CustomXMLParts ps = workbook.CustomXMLParts;
            ps = ps.SelectByNamespace(xNameSpace);


            for (int i = 1; i <= ps.Count; i++)
            {
                Office.CustomXMLPart p = ps[i];
                var nsmgr = p.NamespaceManager;
                nsmgr.AddNamespace("x", xNameSpace);

                Office.CustomXMLNode node = p.SelectSingleNode(xPath);
                if (node != null)
                {
                    return(node);
                }
            }
            return(null);
        }
コード例 #28
0
        /// <summary>
        /// Get a CustomXMLNode from a TreeNode.
        /// </summary>
        /// <param name="tn">The TreeNode to convert.</param>
        /// <param name="cxp">The CustomXMLPart containing the corresponding CustomXMLNode.</param>
        /// <param name="fRemoveTextNode">True to get the parent XML node, False otherwise.</param>
        /// <returns>The corresponding CustomXMLNode.</returns>
        internal static Office.CustomXMLNode MxnFromTn(TreeNode tn, Office.CustomXMLPart cxp, bool fRemoveTextNode)
        {
            if (tn == null || tn.Text == "/")
            {
                throw new ArgumentNullException("tn");
            }

            //if we hit a null node, bail
            if (((XmlNode)tn.Tag) == null)
            {
                throw new ArgumentNullException("tn");
            }

            //get an nsmgr
            NameTable           nt       = new NameTable();
            XmlNamespaceManager xmlnsMgr = new XmlNamespaceManager(nt);

            //check if we're editing the text node of an attribute, since then we'll want to get the XPath of the attribute
            string xpath;

            if (((XmlNode)tn.Tag).NodeType == XmlNodeType.Text && ((XmlNode)tn.Parent.Tag).NodeType == XmlNodeType.Attribute)
            {
                xpath = XpathFromTn(tn.Parent, fRemoveTextNode, cxp, xmlnsMgr);
            }
            else if (((XmlNode)tn.Tag).NodeType == XmlNodeType.Text)
            {
                xpath = XpathFromTn(tn, fRemoveTextNode, cxp, xmlnsMgr);
            }
            else
            {
                xpath = XpathFromTn(tn, false, cxp, xmlnsMgr);
            }

            Debug.Assert(!String.IsNullOrEmpty(xpath), "ASSERT: empty xpath", "xpathFromTn gave us back nothing!");

            Office.CustomXMLNode selectedNode = cxp.SelectSingleNode(xpath);

            Debug.Assert(selectedNode != null, "ASSERT: null mxn from xpath", "This XPath: " + xpath + " gave us back no node!");
            return(selectedNode);
        }
コード例 #29
0
        public FormConditionBuilder(Word.ContentControl cc, ConditionsPartEntry cpe, condition existingCondition)
        {
            InitializeComponent();

            // NET 4 way; see http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.extensions.aspx
            FabDocxState fabDocxState = (FabDocxState)Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument).Tag;

            // NET 3.5 way, which requires using Microsoft.Office.Tools.Word.Extensions
            //FabDocxState fabDocxState = (FabDocxState)Globals.ThisAddIn.Application.ActiveDocument.GetVstoObject(Globals.Factory).Tag;
            this.model = fabDocxState.model;
            xppe = new XPathsPartEntry(model);

            this.cc = cc;

            this.cpe = cpe;
            this.existingCondition = existingCondition;

            this.questionsPart = model.questionsPart;
            questionnaire qtmp = new questionnaire();
            questionnaire.Deserialize(questionsPart.XML, out qtmp);
            questionnaire = qtmp;

            conditions ctmp = new conditions();
            conditions.Deserialize(model.conditionsPart.XML, out ctmp);
            conditions = ctmp;

            log.Debug("conditions: " + conditions.Serialize());

            this.listBoxGovernor.Items.Add("all");
            this.listBoxGovernor.Items.Add("any");
            this.listBoxGovernor.Items.Add("none");
            this.listBoxGovernor.SelectedItem = "all";

            rowHelper = new Helpers.ConditionsFormRowHelper(model, xppe, questionnaire, cc, this);

            rowHelper.init(this.dataGridView);

            DataGridViewRow row = this.dataGridView.Rows[0];
            rowHelper.populateRow(row, null, null);
        }
コード例 #30
0
        internal void ConnectCurrent()
        {
            //hook up new objects
            m_wddoc = Globals.ThisAddIn.Application.ActiveDocument;
            m_parts = m_wddoc.CustomXMLParts;
            //m_currentPart = m_parts[1];  // bad that this is done here as well!

            m_cmTaskPane.model = OpenDoPEModel.Model.ModelFactory(m_wddoc);

            m_cmTaskPane.formPartList.Dispose();
            m_cmTaskPane.formPartList = new Forms.FormSwitchSelectedPart();
            m_cmTaskPane.formPartList.controlPartList.controlMain = m_cmTaskPane;

            if (m_cmTaskPane.model.userParts.Count == 0)
            {
                log.Error("No users part found! This shouldn't happen!");
            }
            m_currentPart = m_cmTaskPane.model.userParts[0];


            SetupEventHandlers();
        }
コード例 #31
0
        private void ThisDocument_BeforeSave(object sender, Microsoft.Office.Tools.Word.SaveEventArgs e)
        {
            Office.CustomXMLPart docDataSetPart = null;
            // Belgedeki içerik kontrol kutularıyla ilgili bilgileri içeren
            // veri setini belgeye ait XML alanları arasında sakla.
            if (docDataSetID != null)
            {
                docDataSetPart = this.CustomXMLParts.SelectByID(docDataSetID);
                if (docDataSetPart != null)
                {
                    docDataSetPart.Delete();
                }
            }
            string xmlDataSet = docDataSet.GetXml();

            docDataSetPart = this.CustomXMLParts.Add(xmlDataSet);
            Office.DocumentProperties docProps =
                this.CustomDocumentProperties as Office.DocumentProperties;
            if (docDataSetID != null)
            {
                docDataSetID = docDataSetPart.Id;
                foreach (Office.DocumentProperty docprop in docProps)
                {
                    if (docprop.Name == "HurTestDataSet")
                    {
                        docprop.Value = docDataSetID;
                        break;
                    }
                }
            }
            else
            {
                docDataSetID = docDataSetPart.Id;
                docProps.Add("HurTestDataSet", false, Office.MsoDocProperties.msoPropertyTypeString,
                             docDataSetID, missing);
            }
        }
コード例 #32
0
        public LibraryHelper(Model srcModel)
        {
            srcXppe = new XPathsPartEntry(srcModel); // used to get entries
            this.srcXPathsPart = srcModel.xpathsPart;

            srcCpe = new ConditionsPartEntry(srcModel);
            this.srcConditionsPart = srcModel.conditionsPart;

            this.srcQuestionsPart = srcModel.questionsPart;
            srcQuestionnaire = new questionnaire();
            questionnaire.Deserialize(srcQuestionsPart.XML, out srcQuestionnaire);

            srcAnswersPart = srcModel.answersPart;
            srcAnswers = new answers();
            answers.Deserialize(srcAnswersPart.XML, out srcAnswers);
        }
コード例 #33
0
ファイル: Model.cs プロジェクト: plutext/OpenDoPE-Model
        public void RemoveParts()
        {
            xpathsPart.Delete();
            xpathsPart = null;

            conditionsPart.Delete();
            conditionsPart = null;

            if (xpathsPart!=null) {
                questionsPart.Delete();
                questionsPart = null;
            }
            if (componentsPart!=null) {
                componentsPart.Delete();
                componentsPart = null;
            }

            if (answersPart != null)
            {
                answersPart.Delete();
                answersPart = null;
            }

            foreach (Office.CustomXMLPart part in userParts) {
                part.Delete();
            }
            userParts.Clear();
        }
 private void parts_PartLoad(Office.CustomXMLPart LoadedStream)
 {
     Debug.WriteLine("Streams.StreamAfterLoad fired.");
     m_cmTaskPane.RefreshControls(Controls.ControlMain.ChangeReason.PartLoaded, null, null, null, null, null);
 }
 private void parts_PartDelete(Office.CustomXMLPart OldStream)
 {
     Debug.WriteLine("Streams.StreamBeforeDelete fired.");
     m_cmTaskPane.RefreshControls(Controls.ControlMain.ChangeReason.PartDeleted, null, null, null, null, OldStream);
 }
コード例 #36
0
        public FormCondition(Word.ContentControl cc, ConditionsPartEntry cpe, condition existingCondition)
        {
            InitializeComponent();

            // NET 4 way; see http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.extensions.aspx
            FabDocxState fabDocxState = (FabDocxState)Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument).Tag;

            // NET 3.5 way, which requires using Microsoft.Office.Tools.Word.Extensions
            //FabDocxState fabDocxState = (FabDocxState)Globals.ThisAddIn.Application.ActiveDocument.GetVstoObject(Globals.Factory).Tag;
            this.model = fabDocxState.model;
            xppe = new XPathsPartEntry(model);

            this.cc = cc;

            this.cpe = cpe;
            this.existingCondition = existingCondition;

            this.questionsPart = model.questionsPart;
            questionnaire = new questionnaire();
            questionnaire.Deserialize(questionsPart.XML, out questionnaire);

            questionListHelper = new Helpers.QuestionListHelperForConditionsForm(model, xppe, questionnaire, cc);
            questionListHelper.listBoxTypeFilter = listBoxTypeFilter;
            questionListHelper.listBoxQuestions = listBoxQuestions;
            questionListHelper.checkBoxScope = checkBoxScope;

            questionListHelper.comboBoxValues = comboBoxValues;
            questionListHelper.listBoxPredicate = listBoxPredicate;

            this.listBoxQuestions.SelectedIndexChanged += new System.EventHandler(questionListHelper.listBoxQuestions_SelectedIndexChanged);
            this.listBoxTypeFilter.SelectedIndexChanged += new System.EventHandler(questionListHelper.listBoxTypeFilter_SelectedIndexChanged);

            question existingQuestion = null;
            string matchResponse = null;
            if (existingCondition != null)
            {
                // Use the question associated with it, to pre-select
                // the correct entries in the dialog.

                // Re-label the window, so user can see what the condition was about
                this.Text = "Editing Condition:   " + cc.Title;

                //List<xpathsXpath> xpaths = ConditionsPartEntry.getXPathsUsedInCondition(existingCondition, xppe);
                List<xpathsXpath> xpaths = new List<xpathsXpath>();
                existingCondition.listXPaths(xpaths, cpe.conditions, xppe.getXPaths());

                if (xpaths.Count > 1)
                {
                    // TODO: use complex conditions editor
                }
                xpathsXpath xpathObj = xpaths[0];

                String xpathVal = xpathObj.dataBinding.xpath;

                if (xpathVal.StartsWith("/"))
                {
                    // simple
                    //System.out.println("question " + xpathObj.getQuestionID()
                    //        + " is in use via boolean condition " + conditionId);

                    existingQuestion = this.questionnaire.getQuestion(xpathObj.questionID);
                    matchResponse = xpathVal;
                }
                else if (xpathVal.Contains("position"))
                {
                    // TODO
                }
                else
                {
                    //System.out.println(xpathVal);

                    String qid = xpathVal.Substring(
                        xpathVal.LastIndexOf("@id") + 5);
                    //						System.out.println("Got qid: " + qid);
                    qid = qid.Substring(0, qid.IndexOf("'"));
                    //						System.out.println("Got qid: " + qid);

                    //System.out.println("question " + qid
                    //        + " is in use via condition " + conditionId);

                    existingQuestion = this.questionnaire.getQuestion(qid);
                    matchResponse = xpathVal;

                }

            }

            questionListHelper.populateTypeFilter(true);

            if (existingQuestion == null)
            {
                // for init, populate with all questions
                questionListHelper.populateQuestions(null);
            }
            else
            {
                // Just show the existing question
                listBoxQuestions.Items.Add(existingQuestion);
            }

            if (this.listBoxQuestions.Items.Count == 0) // Never happens if in a repeat, and nor do we want it to, since user might just want to use "repeat pos" stuff
            {
                // Try including out of scope
                this.checkBoxScope.Checked = true;
                questionListHelper.populateQuestions(null);
                if (this.listBoxQuestions.Items.Count == 0)
                {
                    MessageBox.Show("You can't define a condition until you have set up at least one question. Let's do that now. ");

                    FormQA formQA = new FormQA(cc, false);
                    formQA.ShowDialog();
                    formQA.Dispose();

                    // Refresh these
                    xppe = new XPathsPartEntry(model);
                    questionnaire.Deserialize(questionsPart.XML, out questionnaire);

                    questionListHelper.filterAction();

                    return;
                }
            }
            // value
            question q;
            if (existingQuestion == null)
            {
                // for init, populate with all questions
                q = (question)this.listBoxQuestions.Items[0];
            }
            else
            {
                q = existingQuestion;
            }

            this.listBoxQuestions.SelectedItem = q;
            if (q.response.Item is responseFixed)
            {
                questionListHelper.populateValues((responseFixed)q.response.Item, matchResponse);
            }

            // predicate =
            questionListHelper.populatePredicates(q);  // TODO: set this correctly in editing mode
        }
コード例 #37
0
        public FormRepeat(Office.CustomXMLPart questionsPart,
            Office.CustomXMLPart answersPart,
            Model model,
            Word.ContentControl cc)
        {
            InitializeComponent();

            this.model = model;
            this.cc = cc;

            this.questionsPart = questionsPart;
            questionnaire = new questionnaire();
            questionnaire.Deserialize(questionsPart.XML, out questionnaire);

            this.answersPart = answersPart;

            Office.CustomXMLNodes answers = answersPart.SelectNodes("//oda:repeat");
            foreach (Office.CustomXMLNode answer in answers)
            {
                this.answerID.Add(CustomXMLNodeHelper.getAttribute(answer, "qref")); // ID
            }

            // Suggest ID .. the idea is that
            // the question ID = answer ID.
               // this.ID = generateId();

            xppe = new XPathsPartEntry(model);
            // List of repeat names, for re-use purposes
            // (we need a map from repeat name (shown in the UI) to repeat id,
            //  which is xppe.xpathId).
            // What is it that distinguishes a repeat from any other question?
            // Answer: The fact that the XPath pointing to it ends with oda:row

            // Only show repeats which are in scope (since this repeat is not allowed elsewhere)
            // - if no ancestor repeat, then top level repeats.
            // - if there is an ancestor repeat, then just those which are direct children of it.
            Word.ContentControl rptAncestor = RepeatHelper.getYoungestRepeatAncestor(cc);
            String scope = "/oda:answers";
            if (rptAncestor != null)
            {
                // find its XPath
                scope = xppe.getXPathByID(  (new TagData(rptAncestor.Tag)).getRepeatID() ).dataBinding.xpath;

            }

            repeatNameToIdMap = new Dictionary<string, string>();
            foreach (xpathsXpath xpath in xppe.getXPaths().xpath)
            {
                if (xpath.dataBinding.xpath.EndsWith("oda:row"))
                {
                    if (isRepeatInScope(scope, xpath.dataBinding.xpath)) {
                        // the repeat "name" is its question text.
                        // Get that.
                        question q = questionnaire.getQuestion(xpath.questionID);
                        repeatNameToIdMap.Add(q.text, xpath.id);
                    }
                }
            }
            // Populate the comboBox
            foreach(KeyValuePair<String,String> entry in repeatNameToIdMap)
            {
                this.comboBoxRepeatNames.Items.Add(entry.Key);
            }
        }
コード例 #38
0
        /// <summary>
        // RULE: A variable cc can copied wherever.
        // If its repeat ancestors change, its "vary in repeat"
        // will need to change (to lowest common denominator).
        // If this cc is not in any repeat,
        // make the answer top level and we're done
        // Otherwise, could assume its position is OK wrt
        // existing repeats.
        // So if anything, we just need to move it
        // up the tree until
        // we reach a node which contains this additional repeat.
        // But we'd like this code to
        // be used for both moves and copy. (Move case
        // needs this constraint relaxed)
        // So our algorithm finds viable positions
        // (ie ancestors common to all
        // repeats).
        // That node and higher are candidates for new position
        // Ask user to choose.
        /// </summary>
        protected void handleXPath(string xpathID, bool dontAskIfOkAsis)
        {
            xpathsXpath xp = xppe.getXPathByID(xpathID);

            string questionID = xp.questionID;

            // If this cc is not in any repeat,
            // make the answer top level and we're done

            // Otherwise, we can assume its position is OK wrt
            // existing repeats.

            // So if anything, we just need to move it
            // up the tree until
            // we reach a node which contains this additional repeat.

            // But for the variable move case (handled in MoveHandler)
            // an existing repeat will no longer be a constraint.
            // So better to just have a single algorithm which
            // finds viable positions (ie ancestors common to all
            // repeats).

            // 2 algorithms for doing this.
            // The first:  Make a list of the ancestors of the
            // first repeat.  Then cross off that list anything
            // which isn't an ancestor of the other repeats.

            // The second: Get XPath for each repeat.
            // Find the shortest XPath.
            // Then find the shortest substring common to each
            // repeat. Then make a list out of that.

            // I like the first better.

            // Find all cc's in which this question is used.
            QuestionHelper qh = new QuestionHelper(xppe, cpe);
            List<Word.ContentControl> thisQuestionControls = qh.getControlsUsingQuestion(questionID, xpathID);

            // For each such cc, find closest repeat ancestor cc (if any).
            // With each such repeat, do the above algorithm.

            // Find all cc's in which this question is used.
            List<Word.ContentControl> relevantRepeats = new List<Word.ContentControl>();
            foreach (Word.ContentControl ccx in thisQuestionControls)
            {
                Word.ContentControl rpt = RepeatHelper.getYoungestRepeatAncestor(ccx);
                if (rpt == null)
                {
                    // make the answer top level and we're done.
                    // That means moving it in AF, and XPaths part.
                    log.Info("question " + questionID + " used at top level, so moving it there.");
                    NodeMover nm = new NodeMover();
                    nm.Move(xp.dataBinding.xpath, "/oda:answers");
                    nm.adjustBinding(thisQuestionControls, "/oda:answers", questionID);
                    return;

                }
                else
                {
                    relevantRepeats.Add(rpt);
                }
            }

            Office.CustomXMLPart answersPart = model.answersPart; // userParts[0]; // TODO: make this better

            // That node and higher are candidates for new position
            // Ask user to choose, or cancel (and remove this cc,
            // but what about any impending child add events??  Maybe
            // need a cancel state)

            this.questionsPart = model.questionsPart;
            questionnaire = new questionnaire();
            questionnaire.Deserialize(questionsPart.XML, out questionnaire);

            FormMoveQuestion formMoveQuestion = new FormMoveQuestion(answersPart, relevantRepeats, questionnaire, questionID, xppe);
            if (dontAskIfOkAsis
                && formMoveQuestion.OkAsis() )
            {
                // Do nothing
            }
            else
            {
                formMoveQuestion.ShowDialog();
                formMoveQuestion.moveIfNecessary(questionID, xp, answersPart);

                //string varyInRepeat = formMoveQuestion.getVaryingRepeat();
                //if (varyInRepeat == null)
                //{
                //    // make the answer top level and we're done.
                //    NodeMover nm = new NodeMover();
                //    nm.Move(xp.dataBinding.xpath, "/oda:answers");
                //    nm.adjustBinding(thisQuestionControls, "/oda:answers", questionID);
                //}
                //else
                //{
                //    // Move it to the selected repeat
                //    // get the node corresponding to the repeat's row
                //    Office.CustomXMLNode node = answersPart.SelectSingleNode("//oda:repeat[@qref='" + varyInRepeat + "']/oda:row[1]");
                //    if (node == null)
                //    {
                //        log.Error("no node for nested repeat " + varyInRepeat);
                //    }
                //    string toRepeat = NodeToXPath.getXPath(node);
                //    NodeMover nm = new NodeMover();
                //    nm.Move(xp.dataBinding.xpath, toRepeat);
                //    nm.adjustBinding(thisQuestionControls, toRepeat, questionID);

                //}
            }
            formMoveQuestion.Dispose();
        }
コード例 #39
0
        public FormAnswerOrder(Office.CustomXMLPart answersPart, Office.CustomXMLPart questionsPart)
        {
            InitializeComponent();

            // To populate the tree view, we need to traverse
            // the answers.  We could do this at the DOM level,
            // or using our answers object.
            // Best to use our answers object.

            this.answersPart = answersPart;
            answersObj = new answers();
            OpenDope_AnswerFormat.answers.Deserialize(answersPart.XML, out answersObj);

            // We want to show the question text in the tree view
            questionnaire = new questionnaire();
            questionnaire.Deserialize(questionsPart.XML, out questionnaire);

            ImageList TreeviewIL = new ImageList();
            TreeviewIL.Images.Add(System.Drawing.Image.FromStream(
                System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("OpenDope_AnswerFormat.folder.png")));
            TreeviewIL.Images.Add(System.Drawing.Image.FromStream(
                System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("OpenDope_AnswerFormat.Icons.LogicTree.variable_chevron.png")));
            TreeviewIL.Images.Add(System.Drawing.Image.FromStream(
                System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("OpenDope_AnswerFormat.Icons.LogicTree.repeat.png")));
            this.treeView1.ImageList = TreeviewIL;

            addNodes(answersObj.Items, root);
            this.treeView1.Nodes.Add(root);
            root.ImageIndex = 0;
            root.SelectedImageIndex = 0;

            treeView1.ExpandAll();
        }
コード例 #40
0
        private void init1()
        {
            FabDocxState fabDocxState = (FabDocxState)Globals.ThisAddIn.Application.ActiveDocument.GetVstoObject(Globals.Factory).Tag;
            this.model = fabDocxState.model;
            xppe = new XPathsPartEntry(model);

            this.questionsPart = model.questionsPart;
            questionnaire = new questionnaire();
            questionnaire.Deserialize(questionsPart.XML, out questionnaire);

            this.answersPart = model.answersPart;
        }
コード例 #41
0
        internal void ConnectCurrent()
        {
            //hook up new objects
            m_wddoc = Globals.ThisAddIn.Application.ActiveDocument;
            m_parts = m_wddoc.CustomXMLParts;
            //m_currentPart = m_parts[1];  // bad that this is done here as well!

            m_cmTaskPane.model = OpenDoPEModel.Model.ModelFactory(m_wddoc);

            m_cmTaskPane.formPartList.Dispose();
            m_cmTaskPane.formPartList = new Forms.FormSwitchSelectedPart();
            m_cmTaskPane.formPartList.controlPartList.controlMain = m_cmTaskPane;

            if (m_cmTaskPane.model.userParts.Count == 0)
            {
                log.Error("No users part found! This shouldn't happen!");
            }
            m_currentPart = m_cmTaskPane.model.userParts[0];

            SetupEventHandlers();
        }
コード例 #42
0
        /// <summary>
        /// Change the currently active XML part.
        /// </summary>
        /// <param name="cxp">The CustomXMLPart specifying the newly active XML part.</param>
        internal void ChangeCurrentPart(Office.CustomXMLPart cxp)
        {
            if (cxp != null)
            {
                log.Debug("Changing event stream to " + cxp.DocumentElement.BaseName + ".."  +   cxp.Id);

                //unhook the stream event handlers
                m_currentPart.NodeAfterDelete -= (Office._CustomXMLPartEvents_NodeAfterDeleteEventHandler)m_alPartEvents[0];
                m_currentPart.NodeAfterInsert -= (Office._CustomXMLPartEvents_NodeAfterInsertEventHandler)m_alPartEvents[1];
                m_currentPart.NodeAfterReplace -= (Office._CustomXMLPartEvents_NodeAfterReplaceEventHandler)m_alPartEvents[2];

                //release the streams + event handler references
                m_currentPart = null;
                m_alPartEvents.Clear();

                //hook up the new stream
                m_currentPart = cxp;

                //set up event handlers on the supplied stream
                m_alPartEvents.Add(new Office._CustomXMLPartEvents_NodeAfterDeleteEventHandler(part_NodeAfterDelete));
                m_alPartEvents.Add(new Office._CustomXMLPartEvents_NodeAfterInsertEventHandler(part_NodeAfterInsert));
                m_alPartEvents.Add(new Office._CustomXMLPartEvents_NodeAfterReplaceEventHandler(part_NodeAfterReplace));
                m_currentPart.NodeAfterDelete += (Office._CustomXMLPartEvents_NodeAfterDeleteEventHandler)m_alPartEvents[0];
                m_currentPart.NodeAfterInsert += (Office._CustomXMLPartEvents_NodeAfterInsertEventHandler)m_alPartEvents[1];
                m_currentPart.NodeAfterReplace += (Office._CustomXMLPartEvents_NodeAfterReplaceEventHandler)m_alPartEvents[2];
            }
            else
            {
                log.Error("SetCurrentStream received a null stream");
            }
        }
コード例 #43
0
        public DocumentEvents(Controls.ControlMain cm)
        {
            //get the initial part
            m_cmTaskPane = cm;
            m_wddoc = Globals.ThisAddIn.Application.ActiveDocument;
            m_parts = m_wddoc.CustomXMLParts;
            m_currentPart = cm.model.getUserPart(System.Configuration.ConfigurationManager.AppSettings["RootElement"]);

            //hook up event handlers
            SetupEventHandlers();
        }
コード例 #44
0
        public WedTaskPane(
            List<Office.CustomXMLPart> cxp,
            Office.CustomXMLPart xpathsPart,
            Office.CustomXMLPart conditionsPart,
            Office.CustomXMLPart questionsPart,
            Office.CustomXMLPart componentsPart
            )
        {
            if (questionsPart == null)
            {
                questions = false;
            }
            else
            {
                questions = true;
            }

            // TODO - remove this
            //XmlEditorControl af = new XmlEditorControl(cxp[0], ".xml", true);
            //af.Size = new System.Drawing.Size(350, 600);
            //this.Controls.Add(af);

            this.cxp = cxp;
            activeCxp = cxp[0];
            this.xpathsPart = xpathsPart;
            this.conditionsPart = conditionsPart;
            this.questionsPart = questionsPart;
            this.componentsPart = componentsPart;

            //Office.CustomXMLNode node = cxp.SelectSingleNode("/node()");
            //xp = new OpenDoPE_Wed.XP(node.XML);

            partBeingEdited = activeCxp;

            // setupCcEvents(Globals.ThisAddIn.Application.ActiveDocument);

            //timer = new System.Threading.Timer(timerCallback, this, SEC_1, SEC_1);
        }
コード例 #45
0
 public TreeViewElements(Office.CustomXMLPart cxpTreeView, Office.CustomXMLNode mxnNodeToSelect)
 {
     m_cxpTreeView = cxpTreeView;
     m_xdocTreeView = new XmlDocument();
     m_mxnNodeToSelect = mxnNodeToSelect;
 }