/// ------------------------------------------------------------------------------------ /// <summary> /// Saves the paragraphs contained in this paragraph collection to the specified text /// </summary> /// <param name="text">The journal text (i.e., quote, discussion, suggestion, /// resolution, etc.) to write the paragraphs to</param> /// ------------------------------------------------------------------------------------ internal void WriteToCache(IStJournalText text) { Debug.Assert(text != null); if (text == null) { return; } if (text.ParagraphsOS.Count == 0 && Count == 0) { // Create one empty paragraph even if there's no data. IStPara para = text.ParagraphsOS.Append(new StTxtPara()); para.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.Remark); return; } foreach (IStTxtPara para in text.ParagraphsOS) { if (para == null) { continue; } ParaMatchType type; int iPara = FindMatchingParagraph(para, out type); switch (type) { case ParaMatchType.Exact: // new is same as old, just discard the imported paragraph. RemoveAt(iPara); break; case ParaMatchType.Contains: // no new information, just discard the imported paragraph. // REVIEW: this may indicate a deletion. RemoveAt(iPara); break; case ParaMatchType.IsContained: // we have new information added to an existing paragraph. // (or could it be a deletion?) // replace the current paragraph. para.Contents.UnderlyingTsString = this[iPara].StringBuilder.GetString(); para.StyleRules = this[iPara].ParaStylePropsProxy.Props; RemoveAt(iPara); break; case ParaMatchType.None: // Existing paragraph was not found in the list of imported paras. // REVIEW: this may indicate a deletion. break; } } // Append any new paragraphs to the list of paragraphs in the text. foreach (StTxtParaBldr paraBldr in this) { paraBldr.CreateParagraph(text.Hvo); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Insert end of paragraph marks if needed. /// </summary> /// <param name="vwenv"></param> /// <param name="paraHvo"></param> /// ------------------------------------------------------------------------------------ protected override void InsertEndOfParaMarks(IVwEnv vwenv, int paraHvo) { if (Options.ShowFormatMarksSetting && m_target == LayoutViewTarget.targetDraft) { IStPara para = m_cache.ServiceLocator.GetInstance <IStParaRepository>().GetObject(paraHvo); // If this is the last paragraph of a section then insert an // end of section mark, otherwise insert a paragraph mark. VwBoundaryMark boundaryMark = (para.IsFinalParaInText) ? VwBoundaryMark.endOfSection : VwBoundaryMark.endOfParagraph; vwenv.SetParagraphMark(boundaryMark); int flid = m_cache.ServiceLocator.GetInstance <Virtuals>().StParaIsFinalParaInText; vwenv.NoteDependency(new [] { paraHvo }, new [] { flid }, 1); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for the FootnoteInfo structure /// </summary> /// <param name="scrFootnote">given footnote</param> /// ------------------------------------------------------------------------------------ public FootnoteInfo(IScrFootnote scrFootnote) { footnote = scrFootnote; IStPara para = footnote.ParagraphsOS[0]; if (para.StyleRules != null) { paraStylename = para.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); } else { paraStylename = null; Debug.Fail("StyleRules should never be null."); } }
/// <summary> /// Returns the previous IStPara in the sequence with the current one /// or null if there isn't one /// </summary> /// <param name="para"></param> /// <returns></returns> private static IStPara GetPreviousParagraph(IStPara para) { var ipara = para.IndexInOwner; var text = para.Owner as IStText; if (text == null || text.ParagraphsOS == null) { return(null); } if (ipara == 0) { return(null); } return(text.ParagraphsOS[ipara - 1]); }
/// <summary> /// Returns the next IStPara in the sequence with the current one /// or null if there isn't one /// </summary> /// <param name="para"></param> /// <returns></returns> private static IStPara GetNextParagraph(IStPara para) { var text = para.Owner as IStText; var ipara = para.IndexInOwner; if (text == null || text.ParagraphsOS == null) { return(null); } if (ipara == text.ParagraphsOS.Count - 1) { return(null); } return(text.ParagraphsOS[ipara + 1]); }
/// <summary> /// Returns the previous IStPara in the sequence with the current one /// or null if there isn't one /// </summary> /// <param name="para"></param> /// <returns></returns> private static IStPara GetPreviousParagraph(IStPara para) { var ipara = para.IndexInOwner; var text = para.Owner as IStText; if (text == null || text.ParagraphsOS == null) return null; if (ipara == 0) return null; return text.ParagraphsOS[ipara - 1]; }
/// <summary> /// Returns the next IStPara in the sequence with the current one /// or null if there isn't one /// </summary> /// <param name="para"></param> /// <returns></returns> private static IStPara GetNextParagraph(IStPara para) { var text = para.Owner as IStText; var ipara = para.IndexInOwner; if (text == null || text.ParagraphsOS == null) return null; if (ipara == text.ParagraphsOS.Count - 1) return null; return text.ParagraphsOS[ipara + 1]; }
/// ------------------------------------------------------------------------------------ /// <summary> /// This is the main interesting method of displaying objects and fragments of them. /// A Scripture is displayed by displaying its Books; /// and a Book is displayed by displaying its Title and Sections; /// and a Section is diplayed by displaying its Heading and Content; /// which are displayed by using the standard view constructor for StText. /// </summary> /// <param name="vwenv"></param> /// <param name="hvo"></param> /// <param name="frag"></param> /// ------------------------------------------------------------------------------------ public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case (int)FootnoteFrags.kfrScripture: case (int)ScrFrags.kfrScripture: { vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1); // This fragment should only be used on full refresh - clear the user prompt // flags so they will be shown again. ClearUserPromptUpdates(); // We add this lazy - we will expand some of it immediately, but the non- // visible parts will remain lazy! vwenv.NoteDependency(new[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo }, new[] { ScriptureTags.kflidScriptureBooks }, 1); vwenv.AddLazyVecItems(BooksTag, this, frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook); // Add a 48 point gap at the bottom of the view if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture)) { vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); } break; } case (int)ScrFrags.kfrBook: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText); vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection); // Add a 48 point gap at the bottom of the view if (!PrintLayout && m_fShowTailingSpace) { vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0); } if (!PrintLayout) { InsertBookSeparator(hvo, vwenv); } vwenv.CloseDiv(); break; } case (int)ScrFrags.kfrSection: { vwenv.OpenDiv(); vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText); vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText); vwenv.CloseDiv(); break; } case (int)StTextFrags.kfrPara: if (PrintLayout || !m_fDisplayInTable) { // We are displaying Scripture or a print layout view base.Display(vwenv, hvo, frag); } else { // We are displaying a back translation or Scripture in draftview in a table // Open a table to display the BT para in column 1, and the icon in column 2. VwLength vlTable; // we use this to specify that the table takes 100% of the width. vlTable.nVal = 10000; vlTable.unit = VwUnit.kunPercent100; VwLength vlColumn; // and this one to specify 90% for the text vlColumn.nVal = DisplayTranslation ? 9000 : 10000; vlColumn.unit = VwUnit.kunPercent100; int nColumns = DisplayTranslation ? 2 : 1; vwenv.OpenTable(nColumns, // One or two columns. vlTable, // Table uses 100% of available width. 0, // Border thickness. VwAlignment.kvaLeft, // Default alignment. VwFramePosition.kvfpVoid, // No border. //VwFramePosition.kvfpBox, //VwRule.kvrlAll, // rule lines between cells VwRule.kvrlNone, 0, //No space between cells. 0, //No padding inside cells. false); // Specify column widths. The first argument is the number of columns, // not a column index. vwenv.MakeColumns(nColumns, vlColumn); vwenv.OpenTableBody(); vwenv.OpenTableRow(); // Display paragraph in the first cell vwenv.OpenTableCell(1, 1); InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this); vwenv.CloseTableCell(); if (DisplayTranslation) { // Stylesheet should never be null for a VC that displays BTs, but to be safe... Debug.Assert(m_stylesheet != null); if (m_stylesheet != null) { IStPara para = m_cache.ServiceLocator.GetInstance <IStParaRepository>().GetObject(hvo); ITsTextProps styleRules = para.StyleRules; if (styleRules == null) { Debug.Fail("Style Rules should not be null"); styleRules = NormalStyle; } string paraStyleName = styleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); ITsTextProps ttp = m_stylesheet.GetStyleRgch(0, paraStyleName); Debug.Assert(ttp != null); if (ttp != null) { int var; int spaceBefore = ttp.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out var); if (spaceBefore > 0) { vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, var, spaceBefore); } } } // BT status icon in the next cell, not editable vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable); vwenv.OpenTableCell(1, 1); vwenv.AddObjVec(StTxtParaTags.kflidTranslations, this, (int)ScrFrags.kfrBtTranslationStatus); vwenv.CloseTableCell(); } // Close table vwenv.CloseTableRow(); vwenv.CloseTableBody(); vwenv.CloseTable(); } break; case (int)ScrFrags.kfrBtTranslationStatus: { ICmTranslation trans = m_cache.ServiceLocator.GetInstance <ICmTranslationRepository>().GetObject(hvo); if (trans != null) { string status = trans.Status.get_String(m_wsDefault).Text; IPicture picture; if (status == BackTranslationStatus.Checked.ToString()) { picture = m_CheckedPic; } else if (status == BackTranslationStatus.Finished.ToString()) { picture = m_FinishedPic; } else { picture = m_UnfinishedPic; } vwenv.OpenDiv(); vwenv.AddPicture(picture, -1, 0, 0); vwenv.NoteDependency(new [] { hvo }, new [] { CmTranslationTags.kflidStatus }, 1); vwenv.CloseDiv(); } } break; default: base.Display(vwenv, hvo, frag); break; } }