Beispiel #1
0
        private void WriteDescription(IswItem parentItem, WordItem wordItem, IswItem newItem)
        {
            try
            {
                try
                {
                    newItem.Description = SWDescription.MakeDescription(SWUtility.RtfToRvfz(ConcatenateParagraphsRtf(wordItem.DescriptionParagraphs)));
                }
                catch (Exception ex)
                {
                    LogToDescription(String.Format("Couldn't write description to {0} ({1}) as {2}", newItem.Name, newItem.HandleStr, newItem.swItemType.SID));
                    MessageBox.Show(ex.Message);
                }
                if (parentItem.IsSID(DocumentItemSid))
                {
                    parentItem.AddPart(TitelPartSid, newItem);
                }
                else
                {
                    parentItem.AddPart(SubSectionSid, newItem);
                }

                //LogToDescription(String.Format("Created {0} ({1}) as {2}", newItem.Name, newItem.HandleStr, newItem.swItemType.SID));
                //LogToDescription(String.Format("Added {0} ({1}) to {2} at {3} ", newItem.Name, newItem.HandleStr, parentItem.Name, Convert.ToString(DateTime.Now)));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                LogToDescription(String.Format("Exception on part to item {0}: {1}", parentItem.Name, ex.Message));
            }
        }
Beispiel #2
0
        private void InternalClipboardCopyRtf(Range range)
        {
            Clipboard.Clear();
            range.Select();
            range.Copy();
            ClipboardAsync clAsync = new ClipboardAsync();

            if (clAsync.ContainsText(TextDataFormat.Rtf))
            {
                RtfData       = clAsync.GetText(TextDataFormat.Rtf);
                ParagraphData = SWUtility.RtfToRvfz(RtfData);
            }
        }
Beispiel #3
0
        public Import(IswItem topItem, List <SwParagraph> paragraphs, List <SwStyle> styles, List <SwStyle> description, string hostName, ThreadedWindowWrapper wrap)
        {
            LogToDescription("Importing from Office started at " + Convert.ToString(DateTime.Now));
            var             currentItem = topItem;
            List <WordItem> wordItems   = CreateWordItems(paragraphs, description);

            double progress = 0;
            double step     = (double)100 / (double)wordItems.Count;

            wrap.SetProgress(Convert.ToInt32(progress).ToString()); progress += step;

            int             handledItems        = 0;
            WdOutlineLevel  currentOutlineLevel = WdOutlineLevel.wdOutlineLevelBodyText;
            WdOutlineLevel  lastOutlineLevel    = 0;
            Stack <IswItem> parentItems         = new Stack <IswItem>();

            parentItems.Push(topItem);
            foreach (WordItem wordItem in wordItems)
            {
                if (wordItem.MainParagraph == null)
                {
                    topItem.Description = SWDescription.MakeDescription(SWUtility.RtfToRvfz(ConcatenateParagraphsRtf(wordItem.DescriptionParagraphs)));
                    continue;
                }
                currentOutlineLevel = wordItem.MainParagraph.OutlineLevel;

                if (currentOutlineLevel > lastOutlineLevel) // Sublevel -> Add to the stack
                {
                    currentItem = WriteItem(parentItems.Peek(), wordItem);
                    parentItems.Push(currentItem);
                }

                else // Higher level -> Remove items from the stack
                {
                    for (WdOutlineLevel i = currentOutlineLevel; (i <= lastOutlineLevel && parentItems.Count > 1); i++)
                    {
                        parentItems.Pop();
                    }
                    currentItem = WriteItem(parentItems.Peek(), wordItem);
                    parentItems.Push(currentItem);
                }

                lastOutlineLevel = currentOutlineLevel;

                wrap.SetProgress(Convert.ToInt32(progress).ToString()); progress += step;
                wrap.SetStatus(string.Format("Imported {0} paragraphs of {1}", ++handledItems, wordItems.Count));
            }
            LogToDescription("Script terminated gracefully at " + Convert.ToString(DateTime.Now));
            WriteLogToTopItem(topItem);
        }
Beispiel #4
0
        private IswItem CreateWordItem(IswItem currentItem, SwParagraph paragraph, string createSID, /* ref string oldVersionID, */ string descriptionRtf)
        {
            IswItem newItem;

            newItem = currentItem.HomeLibrary.CreateItem(createSID, paragraph.Text);
            try
            {
                newItem.Description = SWDescription.MakeDescription(SWUtility.RtfToRvfz(descriptionRtf));
            }
            catch (Exception ex)
            {
                LogToDescription(String.Format("Couldn't write description to {0} ({1}) as {2}", newItem.Name, newItem.HandleStr, newItem.swItemType.SID));
                MessageBox.Show(ex.Message);
            }
            return(newItem);
        }
Beispiel #5
0
 private void WriteLogToTopItem(IswItem topItem)
 {
     topItem.Description = SWDescription.MakeDescription(SWUtility.PlainTextToRvfz(_logTxt));
 }