Пример #1
0
        public static LfMultiParagraph GetCustomStTextValuesAsLfMultiPara(IStText obj, int flid,
			IWritingSystemManager wsManager, IFwMetaDataCache metaDataCacheAccessor, int fallbackWs)
        {
            if (obj == null || obj.ParagraphsOS == null || obj.ParagraphsOS.Count == 0) return null;
            var result = new LfMultiParagraph();
            result.Paragraphs = obj.ParagraphsOS.OfType<IStTxtPara>().Where(para => para.Contents != null).Select(para => FdoParaToLfPara(para, wsManager)).ToList();
            // StText objects in FDO have a single primary writing system, unlike MultiString or MultiUnicode objects
            int fieldWs = metaDataCacheAccessor.GetFieldWs(flid);
            string wsStr = wsManager.GetStrFromWs(fieldWs);
            if (wsStr == null) wsStr = wsManager.GetStrFromWs(fallbackWs);
            result.InputSystem = wsStr;
            return result;
        }
Пример #2
0
        public static LfMultiParagraph GetCustomStTextValuesAsLfMultiPara(IStText obj, int flid,
                                                                          WritingSystemManager wsManager, IFwMetaDataCache metaDataCacheAccessor, int fallbackWs)
        {
            if (obj == null || obj.ParagraphsOS == null || obj.ParagraphsOS.Count == 0)
            {
                return(null);
            }
            var result = new LfMultiParagraph();

            // result.Guid = obj.Guid;  // TODO: See if this would break LF PHP
            result.Paragraphs = obj.ParagraphsOS.OfType <IStTxtPara>().Where(para => para.Contents != null).Select(para => LcmParaToLfPara(para, wsManager)).ToList();
            // StText objects in LCM have a single primary writing system, unlike MultiString or MultiUnicode objects
            int    fieldWs = metaDataCacheAccessor.GetFieldWs(flid);
            string wsStr   = wsManager.GetStrFromWs(fieldWs);

            if (wsStr == null)
            {
                wsStr = wsManager.GetStrFromWs(fallbackWs);
            }
            result.InputSystem = wsStr;
            return(result);
        }
Пример #3
0
        private void SetupWsParams(XmlNode output, int fieldId)
        {
            if (fieldId == 0)
            {
                return;
            }
            int ws = m_mdc.GetFieldWs(fieldId);

            if (ws != 0)
            {
                // We've got the ws of the field, but there's a good chance it's for a multistring and is "plural"  However, the column can
                // only show one ws at a time, so we use this method to convert the "plural" ws to a "singular" one.
                // Since this may be a bulk edit field, we also want to use a simple WSID for the active one, while keeping the
                // other, if present, to indicate the other options.
                var wsSingular = WritingSystemServices.PluralMagicWsToSingularMagicWs(ws);
                var wsSimple   = WritingSystemServices.SmartMagicWsToSimpleMagicWs(ws);
                var newWsName  = "$ws=" + WritingSystemServices.GetMagicWsNameFromId(wsSimple);
                if (wsSimple != wsSingular)
                {
                    // replace wsName, and also append an "originalWs", which is not exactly the 'original' ws, but
                    // one of the ones the column configure dialog recognizes that will allow all relevant options
                    // to be chosen. If we use this part generator for cases where we want to allow multiple WSs
                    // to show, we need to change this to just use ws instead of wsSingular, but then we will need
                    // to generalize ColumnConfigureDialog.UpdateWsComboValue.
                    var visitorWs = new ReplaceAttrAndAppend("$wsName", newWsName,
                                                             "originalWs", WritingSystemServices.GetMagicWsNameFromId(wsSingular));
                    XmlUtils.VisitAttributes(output, visitorWs);
                    visitorWs.DoTheAppends();                     // after loop terminates.
                }
                else
                {
                    // no substitution, just replace wsName
                    XmlUtils.VisitAttributes(output, new ReplaceSubstringInAttr("$wsName", newWsName));
                }
            }
        }
Пример #4
0
        /// <summary>
        /// This is invoked when a generated part ref (<part ref="Custom" param="fieldName"/>)
        /// invokes the standard slice (<slice editor="autoCustom".../>). It comes up with the
        /// appropriate default slice for the custom field indicated in the param attribute of
        /// the caller.
        /// </summary>
        static Slice MakeAutoCustomSlice(FdoCache cache, ICmObject obj, XmlNode caller)
        {
            IFwMetaDataCache mdc = cache.DomainDataByFlid.MetaDataCache;
            int flid             = GetCustomFieldFlid(caller, mdc, obj);

            if (flid == 0)
            {
                return(null);
            }
            Slice slice = null;
            var   type  = (CellarPropertyType)mdc.GetFieldType(flid);

            switch (type)
            {
            case CellarPropertyType.String:
            case CellarPropertyType.MultiUnicode:
            case CellarPropertyType.MultiString:
                int ws = mdc.GetFieldWs(flid);
                switch (ws)
                {
                case 0:                                 // a desperate default.
                case WritingSystemServices.kwsAnal:
                    slice = new StringSlice(obj, flid, cache.DefaultAnalWs);
                    break;

                case WritingSystemServices.kwsVern:
                    slice = new StringSlice(obj, flid, cache.DefaultVernWs);
                    break;

                case WritingSystemServices.kwsAnals:
                case WritingSystemServices.kwsVerns:
                case WritingSystemServices.kwsAnalVerns:
                case WritingSystemServices.kwsVernAnals:
                    slice = new MultiStringSlice(obj, flid, ws, 0, false, true, true);
                    break;

                default:
                    throw new Exception("unhandled ws code in MakeAutoCustomSlice");
                }
                break;

            case CellarPropertyType.Integer:
                slice = new IntegerSlice(cache, obj, flid);
                break;

            case CellarPropertyType.GenDate:
                slice = new GenDateSlice(cache, obj, flid);
                break;

            case CellarPropertyType.OwningAtomic:
                int dstClsid = mdc.GetDstClsId(flid);
                if (dstClsid == StTextTags.kClassId)
                {
                    slice = new StTextSlice(obj, flid, cache.DefaultAnalWs);
                }
                break;

            case CellarPropertyType.ReferenceAtomic:
                slice = new AtomicReferenceSlice(cache, obj, flid);
                break;

            case CellarPropertyType.ReferenceCollection:
            case CellarPropertyType.ReferenceSequence:
                slice = new ReferenceVectorSlice(cache, obj, flid);
                break;
            }
            if (slice == null)
            {
                throw new Exception("unhandled field type in MakeAutoCustomSlice");
            }
            slice.Label = mdc.GetFieldLabel(flid);
            return(slice);
        }