private void buttonReuseOK_Click(object sender, EventArgs e)
        {
            if (this.comboBoxRepeatNames.SelectedItem == null)
            {
                // do nothing for now.
                // TODO: grey out the OK button unless there is a selected item
                DialogResult = DialogResult.None;
                return;
            }
            string repeatName = (string)this.comboBoxRepeatNames.SelectedItem;

            // Get the ID we need to use
            String repeatId = repeatNameToIdMap[repeatName];

            TagData td = new TagData("");
            td.set("od:repeat", repeatId);
            cc.Tag = td.asQueryString();

            cc.Title = "REPEAT " + repeatName;
            cc.SetPlaceholderText(null, null, "Repeating content goes here.");

            // They could be trying to re-usw this repeat somewhere
            // outside its ancestral repeat scope.  This should handle that.
            ContentControlCopyHandler handler = new ContentControlCopyHandler();
            handler.handle(cc);
        }
Exemplo n.º 2
0
        public void extendedDocument_ContentControlAfterAdd(Word.ContentControl NewContentControl, bool InUndoRedo)
        {
            log.Info("add fired for " + NewContentControl.ID + " with tag " + NewContentControl.Tag);

            if (NewContentControl.Tag != null
                && NewContentControl.Tag.Contains("od:source=library"))
            {
                // If it is a building block insert, note that this event fires first.
                // We don't want this event detecting it as a copy, and deleting
                // unrecognised logic, when the logic we need is about to be added
                // (via building block insert event).
                log.Debug("ContentControlAfterAdd, ignoring for building block insertion");
                return;
            }

            FabDocxState fabDocxState = getState();

            // Can't refresh taskpane here;
            // it results in:
            //OpenDope_AnswerFormat.Ribbon.extendedDocument_ContentControlAfterAdd add fired for 3909469227 with tag
            //A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in OpenDope_AnswerFormat.DLL
            //OpenDope_AnswerFormat.Controls.LogicTaskPaneUserControl.populateLogicInUse System.Runtime.InteropServices.COMException (0x800A172A): The object is not valid.
            //   at Microsoft.Office.Interop.Word.Range.get_WordOpenXML()
            //   at OpenDope_AnswerFormat.Helpers.OpcHelper.GetPackageStreamFromRange(Range range)

            if (InUndoRedo)
            {
                log.Debug("InUndoRedo, ignoring cc add event");
            }
            else if (fabDocxState.inPlutextAdd)
            {
                // OK, my code added it.
                fabDocxState.registerKnownSdt(NewContentControl);
                log.Debug("ignoring cc add event");
                fabDocxState.inPlutextAdd = false;
            }
            else if (fabDocxState.areEventsSuppressed(NewContentControl))
            {
                log.Info("Ignored event for descendant CC " + NewContentControl.ID
                    + " " + NewContentControl.Tag + " " + NewContentControl.Title);
            }
            else if (fabDocxState.isKnownSdt(NewContentControl))
            {
                log.Debug("ContentControlAfterAdd, handling as Move");
                if (majorVersion >= 14)
                {
                    getWordApp().UndoRecord.StartCustomRecord("FabDocx Move content control");
                }

                // its a move
                ContentControlMoveHandler handler = new ContentControlMoveHandler();
                handler.handle(NewContentControl);
                if (majorVersion >= 14)
                {
                    getWordApp().UndoRecord.EndCustomRecord();
                }

            }
            else
            {
                log.Debug("ContentControlAfterAdd, handling as Copy");
                if (majorVersion >= 14)
                {
                    getWordApp().UndoRecord.StartCustomRecord("FabDocx Copy content control");
                }

                // its a copy
                ContentControlCopyHandler handler = new ContentControlCopyHandler();
                handler.handle(NewContentControl);
                if (majorVersion >= 14)
                {
                    getWordApp().UndoRecord.EndCustomRecord();
                }
            }
        }