Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes and returns a new instance of the <see cref="QuotationMarksList"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static QuotationMarksList NewList()
        {
            QuotationMarksList list = new QuotationMarksList();

            list.EnsureLevelExists(2);
            return(list);
        }
Ejemplo n.º 2
0
		public void RunBeforeEachTest()
		{
			m_qmarks = QuotationMarksList.NewList();
			m_qmarks.QMarksList[0].Opening = "<<";
			m_qmarks.QMarksList[0].Closing = ">>";
			m_qmarks.QMarksList[1].Opening = "<";
			m_qmarks.QMarksList[1].Closing = ">";
			m_qmarks.EnsureLevelExists(5);
			m_source.SetParameterValue("QuotationMarkInfo", m_qmarks.XmlString);
		}
Ejemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Finds the first level that is followed by a non empty level.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public int FindGap()
        {
            QuotationMarksList tmpList = TrimmedList;

            for (int i = 0; i < tmpList.Levels; i++)
            {
                if (i < tmpList.Levels - 1 && tmpList[i].IsEmpty && !tmpList[i + 1].IsEmpty)
                {
                    return(i + 1);
                }
            }

            return(0);
        }
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a QuotationMarksList from the specified XML string.
        /// </summary>
        /// <param name="xmlSrc">The XML source string to load.</param>
        /// <param name="wsName">Name of the writing system (used for error reporting).</param>
        /// ------------------------------------------------------------------------------------
        public static QuotationMarksList Load(string xmlSrc, string wsName)
        {
            Exception          e;
            QuotationMarksList list =
                XmlSerializationHelper.DeserializeFromString <QuotationMarksList>(xmlSrc, out e);

            if (e != null)
            {
                throw new ContinuableErrorException("Invalid QuotationMarks field while loading the " +
                                                    wsName + " writing system.", e);
            }

            return(list == null || list.Levels == 0 ? NewList() : list);
        }
Ejemplo n.º 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns a copy of the list.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public QuotationMarksList Copy()
        {
            QuotationMarksList newList = new QuotationMarksList();

            for (int i = 0; i < Levels; i++)
            {
                QuotationMarks qm = new QuotationMarks();
                qm.Opening = this[i].Opening;
                qm.Closing = this[i].Closing;
                newList.Add(qm);
            }

            newList.ContinuationMark     = ContinuationMark;
            newList.ContinuationType     = ContinuationType;
            newList.LocaleOfLangUsedFrom = LocaleOfLangUsedFrom;
            return(newList);
        }
Ejemplo n.º 6
0
        public void TestTrimmedList()
        {
            m_qmList.AddLevel();
            Assert.AreEqual(3, m_qmList.Levels);

            m_qmList[0].Opening = "[";
            m_qmList[0].Closing = "]";
            Assert.AreEqual(1, m_qmList.TrimmedList.Levels);

            m_qmList[1].Opening = string.Empty;
            m_qmList[1].Closing = "}";
            Assert.AreEqual(2, m_qmList.TrimmedList.Levels);

            QuotationMarksList qmTrimmed = m_qmList.TrimmedList;

            Assert.AreEqual(m_qmList[0].Opening, qmTrimmed[0].Opening);
            Assert.AreEqual(m_qmList[0].Closing, qmTrimmed[0].Closing);
            Assert.AreEqual(m_qmList[1].Opening, qmTrimmed[1].Opening);
            Assert.AreEqual(m_qmList[1].Closing, qmTrimmed[1].Closing);
        }
Ejemplo n.º 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets a value indicating whether or not the list is equal to the specified list.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public bool Equals(QuotationMarksList list, bool considerParaCont)
        {
            if (list == null || Levels != list.Levels)
            {
                return(false);
            }

            if (considerParaCont && (ContinuationType != list.ContinuationType ||
                                     ContinuationMark != list.ContinuationMark))
            {
                return(false);
            }

            for (int i = 0; i < Levels; i++)
            {
                if (!this[i].Equals(list[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns a copy of the list.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public QuotationMarksList Copy()
		{
			QuotationMarksList newList = new QuotationMarksList();

			for (int i = 0; i < Levels; i++)
			{
				QuotationMarks qm = new QuotationMarks();
				qm.Opening = this[i].Opening;
				qm.Closing = this[i].Closing;
				newList.Add(qm);
			}

			newList.ContinuationMark = ContinuationMark;
			newList.ContinuationType = ContinuationType;
			newList.LocaleOfLangUsedFrom = LocaleOfLangUsedFrom;
			return newList;
		}
Ejemplo n.º 9
0
		public void Setup()
		{
			m_qmList = QuotationMarksList.NewList();
		}
Ejemplo n.º 10
0
		void SetupEnglish4()
		{
			m_qmarks = QuotationMarksList.NewList();
			m_qmarks.EnsureLevelExists(4);
			m_qmarks.QMarksList[0].Opening = "\u201C"; // Left double quotation mark
			m_qmarks.QMarksList[0].Closing = "\u201D"; // Right double quotation mark
			m_qmarks.QMarksList[1].Opening = "\u2018"; // Left single quotation mark
			m_qmarks.QMarksList[1].Closing = "\u2019"; // Right single quotation mark
			m_qmarks.QMarksList[2].Opening = "\u201C"; // Left double quotation mark
			m_qmarks.QMarksList[2].Closing = "\u201D"; // Right double quotation mark
			m_qmarks.QMarksList[3].Opening = "\u2018"; // Left single quotation mark
			m_qmarks.QMarksList[3].Closing = "\u2019"; // Right single quotation mark
			m_qmarks.ContinuationType = ParagraphContinuationType.None;
			m_qmarks.ContinuationMark = ParagraphContinuationMark.None;
			m_source.SetParameterValue("QuotationMarkInfo", m_qmarks.XmlString);
		}
Ejemplo n.º 11
0
		void SetupEnglish3() // TO DO: Is there a way to limit it?
		{
			m_qmarks = QuotationMarksList.NewList();
			m_qmarks.EnsureLevelExists(3);
			m_qmarks.QMarksList[0].Opening = "\u201C"; // Left double quotation mark
			m_qmarks.QMarksList[0].Closing = "\u201D"; // Right double quotation mark
			m_qmarks.QMarksList[1].Opening = "\u2018"; // Left single quotation mark
			m_qmarks.QMarksList[1].Closing = "\u2019"; // Right single quotation mark
			m_qmarks.QMarksList[2].Opening = "\u201C"; // Left double quotation mark
			m_qmarks.QMarksList[2].Closing = "\u201D"; // Right double quotation mark
			m_source.SetParameterValue("QuotationMarkInfo", m_qmarks.XmlString);
		}
Ejemplo n.º 12
0
		void SetupEnglish2()
		{
			m_qmarks = QuotationMarksList.NewList();
			m_qmarks.EnsureLevelExists(2);
			m_qmarks.QMarksList[0].Opening = "\u201C"; // Left double quotation mark
			m_qmarks.QMarksList[0].Closing = "\u201D"; // Right double quotation mark
			m_qmarks.QMarksList[1].Opening = "\u2018"; // Left single quotation mark
			m_qmarks.QMarksList[1].Closing = "\u2019"; // Right single quotation mark
			m_source.SetParameterValue("QuotationMarkInfo", m_qmarks.XmlString);
		}
Ejemplo n.º 13
0
		public void ToManyLevels()
		{
			m_qmarks = QuotationMarksList.NewList();
			m_qmarks.QMarksList[0].Opening = "<<";
			m_qmarks.QMarksList[0].Closing = ">>";
			m_qmarks.QMarksList[1].Opening = "<";
			m_qmarks.QMarksList[1].Closing = ">";
			m_source.SetParameterValue("QuotationMarkInfo", m_qmarks.XmlString);

			Test(new string[,] {
				{ "<", FormatMessage(kUnmatchedOpeningMark, 2) },
				{ "<<", FormatMessage(kUnmatchedOpeningMark, 1) },
				{ ">", FormatMessage(kUnmatchedClosingMark, 2) },
				{ ">>", FormatMessage(kUnmatchedClosingMark, 1) },
				}, @"\p \v 1 << <foo <<bar baz>> qux> quux>>");

			Test(new string[,] {
				{ "<", FormatMessage(kUnmatchedOpeningMark, 2) },
				{ ">", FormatMessage(kUnmatchedClosingMark, 2) },
				}, @"\p \v 1 << <foo <bar baz> qux> quux>>");
		}
Ejemplo n.º 14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="QuotationMarkCategorizer"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal QuotationMarkCategorizer(IChecksDataSource source)
		{
			m_quoteMarks = QuotationMarksList.Load(source.GetParameterValue("QuotationMarkInfo"),
				source.GetParameterValue("DefaultWritingSystemName"));
			m_styleInfo = StylePropsInfo.Load(source.GetParameterValue("StylesInfo"));
			CollapseAdjacentQuotes = source.GetParameterValue("CollapseAdjacentQuotes") == "No";
		}
Ejemplo n.º 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets a value indicating whether or not the list is equal to the specified list.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public bool Equals(QuotationMarksList list, bool considerParaCont)
		{
			if (list == null || Levels != list.Levels)
				return false;

			if (considerParaCont && (ContinuationType != list.ContinuationType ||
				ContinuationMark != list.ContinuationMark))
			{
				return false;
			}

			for (int i = 0; i < Levels; i++)
			{
				if (!this[i].Equals(list[i]))
					return false;
			}

			return true;
		}
Ejemplo n.º 16
0
		// The tests verify the inconsistencies found in various combinations of:
		// Correct or incorrect quotation marks
		// Appropriate or inappropriate writing system properties

		#region New test setup of quotation marks for levels

		void SetupEnglish1()
		{
			m_qmarks = QuotationMarksList.NewList();
			m_qmarks.RemoveLastLevel();
			m_qmarks.QMarksList[0].Opening = "\u201C"; // Left double quotation mark
			m_qmarks.QMarksList[0].Closing = "\u201D"; // Right double quotation mark
			m_qmarks.ContinuationMark = ParagraphContinuationMark.None;
			m_qmarks.ContinuationType = ParagraphContinuationType.None;
			m_source.SetParameterValue("QuotationMarkInfo", m_qmarks.XmlString);
		}
Ejemplo n.º 17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes and returns a new instance of the <see cref="T:QuotationMarksList"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static QuotationMarksList NewList()
		{
			QuotationMarksList list = new QuotationMarksList();
			list.EnsureLevelExists(2);
			return list;
		}
Ejemplo n.º 18
0
 public void Setup()
 {
     m_qmList = QuotationMarksList.NewList();
 }