예제 #1
0
        public void GetStrPropValue_DoesNotExist_ReturnsNull()
        {
            TsTextProps tps   = CreateNonEmptyTextProps();
            string      value = tps.GetStrPropValue((int)FwTextPropType.ktptParaStyle);

            Assert.That(value, Is.Null);
        }
예제 #2
0
        public void GetStrPropValue_Exists_ReturnsCorrectValue()
        {
            TsTextProps tps   = CreateNonEmptyTextProps();
            string      value = tps.GetStrPropValue((int)FwTextPropType.ktptFontFamily);

            Assert.That(value, Is.EqualTo("Arial"));
        }
예제 #3
0
        public void GetIntProp_IndexOutOfRange_Throws()
        {
            TsTextProps tps = TsTextProps.EmptyProps;
            int         tpt, var;

            Assert.That(() => tps.GetIntProp(0, out tpt, out var), Throws.InstanceOf <ArgumentOutOfRangeException>());
        }
예제 #4
0
        private static TsTextProps EditIntProperty(TsTextProps textProps, int tpt, int nVar, int nVal)
        {
            ITsPropsBldr tpb = textProps.GetBldr();

            tpb.SetIntPropValues(tpt, nVar, nVal);
            return((TsTextProps)tpb.GetTextProps());
        }
예제 #5
0
        private void ReplaceInternal(int ichMin, int ichLim, string insertText, IList <TsRun> insertRuns)
        {
            // This is the only case where we can end up with an empty run.
            if (insertText.Length == 0)
            {
                // If we're deleting everything and we were passed a run, use it.
                if (ichMin == 0 && ichLim == Length)
                {
                    m_text.Clear();
                    // If we were given some run properties, let them become those of the empty string.
                    TsTextProps props = insertRuns.Count > 0 ? insertRuns[0].TextProps : m_runs[0].TextProps;
                    m_runs.Clear();
                    m_runs.Add(new TsRun(0, props));
                    return;
                }

                // We're not deleting everything, therefore any run we were passed describes
                // no characters and should be ignored.
                if (insertRuns.Count > 0)
                {
                    insertRuns = new TsRun[0];
                }
            }

            int minRunIndex = get_RunAt(ichMin);
            int limRunIndex = get_RunAt(ichLim);

            m_text.Remove(ichMin, ichLim - ichMin);
            m_text.Insert(ichMin, insertText);

            // dich is the amount that indices >= ichLim should be adjusted by after the replace.
            int dich = insertText.Length - ichLim + ichMin;

            SetPropertiesInternal(ichMin, ichLim, minRunIndex, limRunIndex, dich, insertRuns);
        }
예제 #6
0
        public void Equals_NotSame_ReturnsFalse()
        {
            TsTextProps tps1 = TsTextProps.EmptyProps;
            TsTextProps tps2 = CreateNonEmptyTextProps();

            Assert.That(tps1.Equals(tps2), Is.False);
        }
예제 #7
0
        public void Equals_SameNonEmpty_ReturnsTrue()
        {
            TsTextProps tps1 = CreateNonEmptyTextProps();
            TsTextProps tps2 = CreateNonEmptyTextProps();

            Assert.That(tps1.Equals(tps2), Is.True);
        }
예제 #8
0
        public void Equals_SameEmpty_ReturnsTrue()
        {
            TsTextProps tps1 = TsTextProps.EmptyProps;
            TsTextProps tps2 = TsTextProps.EmptyProps;

            Assert.That(tps1.Equals(tps2), Is.True);
        }
예제 #9
0
        private static TsTextProps EditStrProperty(TsTextProps textProps, int tpt, string strVal)
        {
            ITsPropsBldr tpb = textProps.GetBldr();

            tpb.SetStrPropValue(tpt, strVal);
            return((TsTextProps)tpb.GetTextProps());
        }
예제 #10
0
        public void GetIntPropValues_DoesNotExist_ReturnsNegativeOne()
        {
            TsTextProps tps = CreateNonEmptyTextProps();
            int         var;
            int         value = tps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var);

            Assert.That(var, Is.EqualTo(-1));
            Assert.That(value, Is.EqualTo(-1));
        }
예제 #11
0
        public void GetIntPropValues_Exists_ReturnsCorrectValue()
        {
            TsTextProps tps = CreateNonEmptyTextProps();
            int         var;
            int         value = tps.GetIntPropValues((int)FwTextPropType.ktptWs, out var);

            Assert.That(var, Is.EqualTo((int)FwTextPropVar.ktpvDefault));
            Assert.That(value, Is.EqualTo(1));
        }
예제 #12
0
        public void GetStrProp_ValidIndex_ReturnsCorrectValue()
        {
            TsTextProps tps = CreateNonEmptyTextProps();
            int         tpt;
            string      value = tps.GetStrProp(0, out tpt);

            Assert.That(tpt, Is.EqualTo((int)FwTextPropType.ktptFontFamily));
            Assert.That(value, Is.EqualTo("Arial"));

            value = tps.GetStrProp(1, out tpt);
            Assert.That(tpt, Is.EqualTo((int)FwTextPropType.ktptFieldName));
            Assert.That(value, Is.EqualTo("Field"));
        }
예제 #13
0
        public void GetIntProp_ValidIndex_ReturnsCorrectValue()
        {
            TsTextProps tps = CreateNonEmptyTextProps();
            int         tpt, var;
            int         value = tps.GetIntProp(0, out tpt, out var);

            Assert.That(tpt, Is.EqualTo((int)FwTextPropType.ktptWs));
            Assert.That(var, Is.EqualTo((int)FwTextPropVar.ktpvDefault));
            Assert.That(value, Is.EqualTo(1));

            value = tps.GetIntProp(2, out tpt, out var);
            Assert.That(tpt, Is.EqualTo((int)FwTextPropType.ktptBackColor));
            Assert.That(var, Is.EqualTo((int)FwTextPropVar.ktpvEnum));
            Assert.That(value, Is.EqualTo((int)FwTextColor.kclrYellow));
        }
예제 #14
0
        /// <summary>
        /// Creates a text properties object using the specified writing system, old writing system, and a character
        /// style. The writing system value may be zero which means no writing system is specified. The style may be null.
        /// If the writing system is zero, then the old writing system must also be zero. An exception will be thrown otherwise.
        /// </summary>
        public ITsTextProps MakeProps(string bstrStyle, int ws, int ows)
        {
            ThrowIfWSInvalid("ws", ws);

            var intProps = new Dictionary <int, TsIntPropValue>
            {
                { (int)FwTextPropType.ktptWs, new TsIntPropValue(ows, ws) }
            };

            Dictionary <int, string> strProps = null;

            if (!string.IsNullOrEmpty(bstrStyle))
            {
                strProps = new Dictionary <int, string>
                {
                    { (int)FwTextPropType.ktptNamedStyle, bstrStyle }
                };
            }

            return(TsTextProps.GetInternedTextProps(intProps, strProps));
        }
예제 #15
0
        public void GetBldr_Empty_ReturnsBldrWithCorrectData()
        {
            TsTextProps tps = TsTextProps.EmptyProps;

            Assert.That(tps.GetBldr().GetTextProps(), Is.EqualTo(tps));
        }
예제 #16
0
 internal TsString(string text, TsTextProps textProps)
     : this(text, new TsRun(text?.Length ?? 0, textProps).ToEnumerable())
 {
 }
예제 #17
0
 internal TsString(string text, int ws)
     : this(text, TsTextProps.GetInternedTextProps(ws))
 {
 }
예제 #18
0
파일: TsRun.cs 프로젝트: vkarthim/liblcm
 public TsRun(int ichLim, TsTextProps textProps)
 {
     m_ichLim    = ichLim;
     m_textProps = textProps;
 }
예제 #19
0
        public void StrPropCount_NonEmpty_ReturnsCorrectCount()
        {
            TsTextProps tps = CreateNonEmptyTextProps();

            Assert.That(tps.StrPropCount, Is.EqualTo(2));
        }
예제 #20
0
        public void StrPropCount_Empty_ReturnsZero()
        {
            TsTextProps tps = TsTextProps.EmptyProps;

            Assert.That(tps.StrPropCount, Is.EqualTo(0));
        }
예제 #21
0
        public void GetBldr_NonEmpty_ReturnsBldrWithCorrectData()
        {
            TsTextProps tps = CreateNonEmptyTextProps();

            Assert.That(tps.GetBldr().GetTextProps(), Is.EqualTo(tps));
        }
예제 #22
0
 internal TsStrBldr(string text, TsTextProps textProps)
     : this(text, new TsRun(text == null ? 0 : text.Length, textProps).ToEnumerable())
 {
 }
예제 #23
0
 /// <summary>
 /// Creates an <see cref="ITsTextProps"/> from the current state. The number of TextProps may be less then
 /// the number pushed or inserted do to the compression of like, adjacent values.
 /// </summary>
 public ITsTextProps GetTextProps()
 {
     return(TsTextProps.GetInternedTextProps(IntProperties, StringProperties));
 }