Пример #1
0
 /// ------------------------------------------------------------------------------------
 private void SetText(WordListCache resultCache)
 {
     if (resultCache != null)
     {
         Text = (resultCache.SearchQuery == null ? string.Empty : resultCache.SearchQuery.ToString());
     }
 }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the tab's result view with a new result cache.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void RefreshResultView(WordListCache resultCache)
        {
            SetText(resultCache);

            if (resultCache != null)
            {
                UnsubscribeToGridEvents();
                m_resultView.Initialize(resultCache);
                UpdateRecordView();
                SubscribeToGridEvents();
                SearchQuery = resultCache.SearchQuery;
            }

            if (CIEOptionsButton.Visible)
            {
                FindInfo.CanFindAgain    = false;
                CIEOptionsButton.Visible = (m_resultView != null &&
                                            m_resultView.Grid != null && m_resultView.Grid.Cache != null &&
                                            m_resultView.Grid.Cache.IsMinimalPair);
            }

            if (CIESimilarOptionsButton.Visible)
            {
                FindInfo.CanFindAgain           = false;
                CIESimilarOptionsButton.Visible = (m_resultView != null &&
                                                   m_resultView.Grid != null && m_resultView.Grid.Cache != null &&
                                                   m_resultView.Grid.Cache.IsSimilarEnvironment);
            }

            AdjustWidth();
        }
Пример #3
0
        public void CacheSortCvcAscPoaDescTest()
        {
            AddWords("fib bit dig ebay bitter digger drillbit abdiging",
                     "cvc cvc cvc vcvv cvccvc cvccvc ccvcccvc vccvcvcc");
            _query.Pattern = "b/*_*";
            WordListCache cache = App.Search(_query);

            _sortOptions.SortType        = PhoneticSortType.POA;
            _sortOptions.AdvancedEnabled = true;
            _sortOptions.SetPrimarySortField(_phoneticField, false, kDescending);      // 2nd sort
            _sortOptions.SetPrimarySortField(_cvField, false, kAscending);             // 1st sort
            cache.Sort(_sortOptions);

            System.Diagnostics.Debug.WriteLine("b = " + _prj.PhoneCache["b"].POAKey);
            System.Diagnostics.Debug.WriteLine("f = " + _prj.PhoneCache["f"].POAKey);
            System.Diagnostics.Debug.WriteLine("t = " + _prj.PhoneCache["t"].POAKey);
            System.Diagnostics.Debug.WriteLine("d = " + _prj.PhoneCache["d"].POAKey);
            System.Diagnostics.Debug.WriteLine("n = " + _prj.PhoneCache["n"].POAKey);
            System.Diagnostics.Debug.WriteLine("r = " + _prj.PhoneCache["r"].POAKey);
            System.Diagnostics.Debug.WriteLine("l = " + _prj.PhoneCache["l"].POAKey);
            System.Diagnostics.Debug.WriteLine("g = " + _prj.PhoneCache["g"].POAKey);
            System.Diagnostics.Debug.WriteLine("i = " + _prj.PhoneCache["i"].POAKey);
            System.Diagnostics.Debug.WriteLine("e = " + _prj.PhoneCache["e"].POAKey);
            System.Diagnostics.Debug.WriteLine("a = " + _prj.PhoneCache["a"].POAKey);
            System.Diagnostics.Debug.WriteLine("y = " + _prj.PhoneCache["y"].POAKey);

            Assert.AreEqual(6, cache.Count);
            Assert.AreEqual("drillbit", cache[0].WordCacheEntry["Phonetic"]);
            Assert.AreEqual("fib", cache[1].WordCacheEntry["Phonetic"]);
            Assert.AreEqual("bit", cache[2].WordCacheEntry["Phonetic"]);
            Assert.AreEqual("bitter", cache[3].WordCacheEntry["Phonetic"]);
            Assert.AreEqual("abdiging", cache[4].WordCacheEntry["Phonetic"]);
            Assert.AreEqual("ebay", cache[5].WordCacheEntry["Phonetic"]);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnRegExpressionShowSearchResults(object args)
        {
            SearchQuery query = args as SearchQuery;

            if (query == null || m_findPhoneWnd == null || m_findPhoneWnd.ResultViewManger == null)
            {
                return(true);
            }

            ISearchResultsViewHost srchRsltVwHost = ReflectionHelper.GetField(
                m_findPhoneWnd.ResultViewManger, "m_srchRsltVwHost") as ISearchResultsViewHost;

            if (srchRsltVwHost != null)
            {
                srchRsltVwHost.BeforeSearchPerformed(query, null);
            }

            //PaApp.InitializeProgressBar(ResourceHelper.GetString("kstidQuerySearchingMsg"));

            RegExpressionSearch regExpSrch  = new RegExpressionSearch(query);
            WordListCache       resultCache = regExpSrch.Search();

            if (resultCache != null)
            {
                resultCache.SearchQuery = query.Clone();
                ReflectionHelper.CallMethod(m_findPhoneWnd.ResultViewManger,
                                            "ShowResults", resultCache, SearchResultLocation.CurrentTabGroup);
            }

            //PaApp.UninitializeProgressBar();

            return(true);
        }
Пример #5
0
        public void AdvancedPOASortTest1()
        {
            AddWords("mappu sippu", null);
            _query.Pattern = "p/*_*";
            WordListCache cache = App.Search(_query);

            Assert.IsNotNull(cache);

            _sortOptions.SortType        = PhoneticSortType.POA;
            _sortOptions.AdvancedEnabled = true;
            _sortOptions.AdvSortOrder    = new[] { 1, 0, 2 };
            _sortOptions.AdvRlOptions    = new[] { true, false, false };
            _sortOptions.SetPrimarySortField(_phoneticField, false, kAscending);
            cache.Sort(_sortOptions);

            Assert.AreEqual(4, cache.Count);
            Assert.AreEqual("sippu", cache[0].PhoneticValue);
            Assert.AreEqual(3, cache[0].SearchItemOffset);
            Assert.AreEqual("mappu", cache[1].PhoneticValue);
            Assert.AreEqual(3, cache[1].SearchItemOffset);
            Assert.AreEqual("sippu", cache[2].PhoneticValue);
            Assert.AreEqual(2, cache[2].SearchItemOffset);
            Assert.AreEqual("mappu", cache[3].PhoneticValue);
            Assert.AreEqual(2, cache[3].SearchItemOffset);
        }
Пример #6
0
 /// ------------------------------------------------------------------------------------
 public WordListGroupingBuilder(PaWordListGrid grid)
 {
     m_grid = grid;
     if (grid != null)
     {
         m_cache = grid.Cache;
     }
 }
Пример #7
0
 public void TestSetup()
 {
     _prj.PhoneCache.Clear();
     _prj.RecordCache.Clear();
     _recCache    = _prj.RecordCache;
     _cache       = new WordListCache();
     _query       = new SearchQuery();
     _sortOptions = new SortOptions(true, _prj);
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates and loads a result cache for the specified search query.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public WordListCache Search()
        {
            if (!m_query.IsPatternRegExpression || m_regExBefore == null ||
                m_regExItem == null || m_regExAfter == null)
            {
                return(null);
            }

            WordListCache resultCache = new WordListCache();

            foreach (WordCacheEntry wordEntry in PaApp.WordCache)
            {
                int    offset   = 0;
                string phonetic = wordEntry.PhoneticValueWithPrimaryUncertainty;

                while (offset < phonetic.Length)
                {
                    // Find the search item starting at offset.
                    Match match = m_regExItem.Match(phonetic, offset);
                    if (!match.Success)
                    {
                        break;
                    }

                    offset = match.Index;
                    int length = match.Length;

                    // Search for the environment before, looking for a match that
                    // butts up against the match on the search item.
                    match = m_regExBefore.Match(phonetic);
                    while (match.Success && match.Index + match.Length < offset)
                    {
                        match = m_regExBefore.Match(phonetic, match.Index + 1);
                    }

                    if (match.Success && match.Index + match.Length == offset)
                    {
                        // Search for the environment after.
                        match = m_regExAfter.Match(phonetic, offset);
                        if (match.Success && match.Index == offset)
                        {
                            resultCache.AddEntryFromRegExpSearch(wordEntry, null, offset, length, false);
                        }
                    }

                    offset++;
                }
            }

            resultCache.ExtendRegExpMatchesToPhoneBoundaries();
            resultCache.IsForSearchResults       = true;
            resultCache.IsForRegExpSearchResults = true;
            return(resultCache);
        }
Пример #9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Called when the desire is to build a word list that is not a list of find Phone
        /// search results.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void LoadWindow()
        {
            var cache = new WordListCache();

            foreach (var entry in Project.WordCache)
            {
                cache.Add(entry);
            }

            Initialize(cache);
        }
Пример #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a wordEntry list grid with the specified cache and adds it to the form.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void Initialize(WordListCache cache)
        {
            App.MsgMediator.SendMessage("BeforeSearchResultViewInitialized", this);
            Controls.Clear();

            _query = (cache != null ? cache.SearchQuery : null);

            if (cache == null || cache.Count == 0)
            {
                if (_grid != null)
                {
                    _grid.Dispose();
                    _grid = null;
                }

                if (_query != null && _query.Errors.Count > 0)
                {
                    SetupErrorDisplay(_query);
                }

                return;
            }

            // Save the grid we're replacing.
            var tmpgrid = _grid;

            _grid = new PaWordListGrid(cache, _owningViewType);
            _grid.OwningViewType = _owningViewType;
            _grid.TMAdapter      = _tmAdapter;

            // Even though the grid is docked, setting it's size here prevents the user from
            // seeing it during that split second during which the grid goes from it's small,
            // default size to its docked size.
            _grid.Size = Size;

            _grid.Name = Name + "Grid";
            _grid.LoadSettings();
            _grid.Visible = false;
            Controls.Add(_grid);
            _grid.Visible = true;

            // I wait until the new grid is all done building and loading before
            // removing the old so the user cannot see the painting of the new one.
            if (tmpgrid != null)
            {
                Controls.Remove(tmpgrid);
                tmpgrid.Dispose();
            }

            _grid.UseWaitCursor = false;
            _grid.Cursor        = Cursors.Default;

            App.MsgMediator.SendMessage("AfterSearchResultViewInitialized", this);
        }
Пример #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Constructs an object to find the list of minimal pairs within the specified cache.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public CIEBuilder(WordListCache cache, SortOptions sortOptions, CIEOptions cieOptions)
        {
            if (cache == null || cache.Count <= 2)
            {
                return;
            }

            Cache        = cache;
            CIEOptions   = cieOptions;
            _sortOptions = sortOptions.Copy();
            _sortOptions.AdvSortOrder = (CIEOptions.Type == CIEOptions.IdenticalType.After ?
                                         new[] { 2, 0, 1 } : new[] { 1, 0, 2 });
        }
Пример #12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Build the PaWordListGrid for searching.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void Initialize(string eticWrds, string cvWrds, string glossWrds)
        {
            m_recCache = _prj.RecordCache;
            m_cache    = new WordListCache();

            AddWords(eticWrds, cvWrds, glossWrds);

            // Create grid
            m_grid = new PaWordListGrid(m_cache, GetType(), false);

            // Make all the grid's rows & columns visible and thus searchable
            for (int row = 0; row < m_grid.Rows.Count; row++)
            {
                m_grid.Rows[row].Visible = true;
                for (int col = 0; col < m_grid.Columns.Count; col++)
                {
                    m_grid.Columns[col].Visible = true;
                }
            }

            // Get rid of columns we don't care about for the tests.
            for (int i = m_grid.ColumnCount - 1; i >= 0; i--)
            {
                if (!"Phonetic CVPattern Gloss".Contains(m_grid.Columns[i].Name))
                {
                    m_grid.Columns.Remove(m_grid.Columns[i]);
                }
            }

            // Set the CVPattern & Gloss column Display Indexes to the correct order
            // based on the columnsToSearch below.
            m_grid.Columns["Phonetic"].DisplayIndex  = 0;
            m_grid.Columns["CVPattern"].DisplayIndex = 1;
            m_grid.Columns["Gloss"].DisplayIndex     = 2;

            SetField(typeof(FindInfo), "s_reverseFind", false);
            FindInfo.Grid = m_grid;

            // Add columns to search
            var columnsToSearch = new List <FindDlgColItem>();

            columnsToSearch.Add(new FindDlgColItem(m_grid.Columns["Phonetic"].Index, 0, "Phonetic", "Phonetic"));
            columnsToSearch.Add(new FindDlgColItem(m_grid.Columns["CVPattern"].Index, 1, "CV Pattern", "CVPattern"));
            columnsToSearch.Add(new FindDlgColItem(m_grid.Columns["Gloss"].Index, 2, "Gloss", "Gloss"));
            FindInfo.ColumnsToSearch = columnsToSearch.ToArray();

            m_findDlg = new FindDlg(m_grid);
            ResetStartCell();
        }
Пример #13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Use a special sort to make sure the reference fields for word list cache entries
        /// that come from audio files are taken from the word list cache entries and not the
        /// record cache entries that own the word list entries.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnSortCache(object args)
        {
            object[] argArray = args as object[];
            if (argArray == null || argArray.Length < 2)
            {
                return(false);
            }

            WordListCache wcache      = argArray[0] as WordListCache;
            SortOptions   sortOptions = argArray[1] as SortOptions;

            if (wcache == null || sortOptions == null)
            {
                return(false);
            }

            wcache.Sort(new SACacheSortComparer(sortOptions));
            return(true);
        }
        /// ------------------------------------------------------------------------------------
        private void AddWords(string words)
        {
            var entry = new RecordCacheEntry(_prj);

            entry.SetValue("Phonetic", words);
            entry.NeedsParsing = true;
            entry.DataSource   = _dataSource;
            _recCache.Add(entry);
            _recCache.BuildWordCache(null);
            BuildPhoneSortKeysForTests();

            var query = new SearchQuery();

            query.IgnoreDiacritics  = false;
            query.IgnoredCharacters = null;
            query.Pattern           = "[V]/*_*";
            _cache             = App.Search(query);
            _cache.SearchQuery = query;
        }
Пример #15
0
        public void CacheSortCvcDescMoaAscTest()
        {
            AddWords("fib bit dig ebay bitter digger drillbit abdiging",
                     "cvc cvc cvc vcvc cvccvc cvccvc ccvcccvc vccvcvcc");
            _query.Pattern = "b/*_*";
            WordListCache cache = App.Search(_query);

            _sortOptions.SortType = PhoneticSortType.MOA;
            _sortOptions.SetPrimarySortField(_phoneticField, false, kAscending);        // 2nd sort
            _sortOptions.SetPrimarySortField(_cvField, false, kDescending);             // 1st sort
            cache.Sort(_sortOptions);

            Assert.AreEqual(6, cache.Count);
            string[] words = { "ebay", "abdiging", "bitter", "fib", "bit", "drillbit" };             // expected answer
            for (int i = 0; i < cache.Count; i++)
            {
                Assert.AreEqual(words[i], cache[i].WordCacheEntry["Phonetic"]);
            }
        }
Пример #16
0
        public void CacheAdvSortMoaDescTest()
        {
            AddWords("rabbit bir fib bit dig ebay bitter digger drillbit abdiging",
                     "cvccvc cvc cvc cvc cvc vcvc cvccvc cvccvc ccvcccvc vccvcvcc");
            _query.Pattern = "bi/*_*";
            WordListCache cache = App.Search(_query);

            _sortOptions.SortType        = PhoneticSortType.MOA;
            _sortOptions.AdvancedEnabled = true;
            _sortOptions.AdvSortOrder    = new[] { 0, 2, 1 };
            _sortOptions.AdvRlOptions    = new[] { true, true, true };
            _sortOptions.SetPrimarySortField(_phoneticField, false, kDescending);
            cache.Sort(_sortOptions);

            Assert.AreEqual(5, cache.Count);
            string[] words = { "rabbit", "drillbit", "bit", "bitter", "bir" };             // expected answer
            for (int i = 0; i < cache.Count; i++)
            {
                Assert.AreEqual(words[i], cache[i].WordCacheEntry["Phonetic"]);
            }
        }
Пример #17
0
        public void SimplePOASortTest1()
        {
            AddWords("b\u0324it bag", null);
            var cache = new WordListCache();

            foreach (var entry in _recCache.WordCache)
            {
                cache.Add(entry);
            }

            Assert.IsNotNull(cache);

            _sortOptions.SortType        = PhoneticSortType.POA;
            _sortOptions.AdvancedEnabled = false;
            _sortOptions.SetPrimarySortField(_phoneticField, false, kAscending);
            cache.Sort(_sortOptions);

            Assert.AreEqual(2, cache.Count);
            Assert.AreEqual("bag", cache[0].WordCacheEntry["Phonetic"]);
            Assert.AreEqual("b\u0324it", cache[1].WordCacheEntry["Phonetic"]);
        }
Пример #18
0
        public void CacheAdvSortPoaRLTest()
        {
            AddWords("pig big p\u02B0ig", null);
            _query.Pattern = "[V]/*_*";
            WordListCache cache = App.Search(_query);

            Assert.IsNotNull(cache);

            _sortOptions.SortType        = PhoneticSortType.POA;
            _sortOptions.AdvancedEnabled = true;
            _sortOptions.AdvSortOrder    = new[] { 1, 0, 2 };
            _sortOptions.AdvRlOptions    = new[] { true, false, false };
            _sortOptions.SetPrimarySortField(_phoneticField, false, kAscending);
            cache.Sort(_sortOptions);

            Assert.AreEqual(3, cache.Count);
            string[] words = { "pig", "p\u02B0ig", "big" };             // expected answer
            for (int i = 0; i < cache.Count; i++)
            {
                Assert.AreEqual(words[i], cache[i].WordCacheEntry["Phonetic"]);
            }
        }
Пример #19
0
        public void CacheAdvSortCvcAscPoaDescTest()
        {
            AddWords("pig fib bit dig ebay bitter digger drillbit abdiging",
                     "cvc cvc cvc cvc vcvc cvccvc cvccvc ccvcccvc vccvcvcc");
            _query.Pattern = "i/*_*";
            WordListCache cache = App.Search(_query);

            _sortOptions.SortType        = PhoneticSortType.POA;
            _sortOptions.AdvancedEnabled = true;
            _sortOptions.AdvSortOrder    = new[] { 2, 0, 1 };
            _sortOptions.AdvRlOptions    = new[] { true, false, true };
            _sortOptions.SetPrimarySortField(_phoneticField, false, kDescending);      // 2nd sort
            _sortOptions.SetPrimarySortField(_cvField, false, kAscending);             // 1st sort
            cache.Sort(_sortOptions);

            Assert.AreEqual(10, cache.Count);
            // Expected answer
            string[] words = { "drillbit", "drillbit", "dig", "pig", "bit", "fib", "digger", "bitter", "abdiging", "abdiging" };
            for (int i = 0; i < cache.Count; i++)
            {
                Assert.AreEqual(words[i], cache[i].WordCacheEntry["Phonetic"]);
            }
        }
Пример #20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a wordEntry list grid with the specified cache and adds it to the form.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void Initialize(WordListCache cache)
        {
            m_cache = cache;

            if (WordListGrid != null)
            {
                WordListGrid.Cache = m_cache;
            }
            else
            {
                WordListGrid                       = new PaWordListGrid(cache, GetType(), false);
                WordListGrid.BorderStyle           = BorderStyle.None;
                WordListGrid.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
                WordListGrid.TMAdapter             = m_tmAdapter;

                // Even thought the grid is docked, setting it's size here prevents the user
                // from seeing that split second during which time the grid goes from it's
                // small, default size to its docked size.
                WordListGrid.Size = new Size(splitOuter.Panel1.Width, splitOuter.Panel1.Height);

                WordListGrid.Name = Name + "Grid";
                WordListGrid.LoadSettings();
                WordListGrid.RowEnter += m_grid_RowEnter;
                WordListGrid.Visible   = false;
                pnlGrid.Controls.Add(WordListGrid);
                WordListGrid.Visible  = true;
                WordListGrid.TabIndex = 0;
                WordListGrid.Focus();
                WordListGrid.SortOptions           = Project.DataCorpusVwSortOptions;
                WordListGrid.IsCurrentPlaybackGrid = true;
                WordListGrid.UseWaitCursor         = false;
                WordListGrid.Cursor = Cursors.Default;
            }

            // This will enforce an update of the record pane.
            _recView.UpdateRecord(WordListGrid.GetRecord(), true);
        }
Пример #21
0
        /// ------------------------------------------------------------------------------------
        public WordListCache FindMinimalPairs()
        {
            if (Cache == null || !Cache.IsForSearchResults)
            {
                return(null);
            }

            foreach (var entry in Cache)
            {
                entry.CIEGroupId = -1;
            }

            // First, send a message to see if there is an AddOn to find minimal pairs. If so,
            // then return the cache it generated instead of the one built by this method.
            object args = this;

            if (App.MsgMediator.SendMessage("FindMinimalPairsAlternate", args))
            {
                if (args is WordListCache)
                {
                    return(args as WordListCache);
                }
            }

            var cieGroups = new Dictionary <string, List <WordListCacheEntry> >();
            var noDups    = new HashSet <string>();

            foreach (var entry in Cache)
            {
                string pattern = GetCIEPattern(entry, _cieOptions);

                List <WordListCacheEntry> entryList;
                if (!cieGroups.TryGetValue(pattern, out entryList))
                {
                    entryList          = new List <WordListCacheEntry>();
                    cieGroups[pattern] = entryList;
                }

                var setItem = pattern + "+" + entry.SearchItem;

                if (!noDups.Contains(setItem))
                {
                    noDups.Add(setItem);
                    entryList.Add(entry);
                }
            }
            noDups.Clear();

            // The groups are not guaranteed to be in any particular order, just the words within groups.
            // TODO: Sort groups by POA, or MOA, based on what's specified in _sortOptions.

            // Create a new cache which is the subset containing minimal pair entries.
            int cieGroupId    = 0;
            var cieGroupTexts = new SortedList <int, string>();
            var cieCache      = new WordListCache();

            foreach (var grp in cieGroups.Where(g => g.Value.Count >= 2))
            {
                foreach (var entry in grp.Value)
                {
                    entry.CIEGroupId = cieGroupId;
                    cieCache.Add(entry);
                }

                cieGroupTexts[cieGroupId++] = grp.Key;
            }

            cieCache.IsMinimalPair      = true;
            cieCache.CIEGroupTexts      = cieGroupTexts;
            cieCache.IsForSearchResults = true;
            cieCache.Sort(_sortOptions);
            cieCache.SearchQuery = Cache.SearchQuery.Clone();
            return(cieCache);
        }
Пример #22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// RtfCreator constructor.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public RtfCreator(PaProject project, ExportTarget target, ExportFormat format,
                          DataGridView grid, WordListCache cache, string rtfEditor)
        {
            m_project      = project;
            m_exportTarget = target;
            m_exportFormat = format;
            m_grid         = grid;

            if (m_grid != null)
            {
                m_graphics = m_grid.CreateGraphics();

                // Store the dots per inch value from the grid's graphic object
                m_pixelsPerInch = m_graphics.DpiX;
            }

            m_cache                = cache;
            m_rtfEditor            = rtfEditor;
            m_createSearchItemTabs = CreateSearchItemTabs.FirstTab;
            m_rtfBldr              = new StringBuilder();

            // Default value is 1/8" gap between columns.
            m_colRightPadding = Properties.Settings.Default.RTFExportGapBetweenColumns;

            // Add support for highlighting the search item
            if (m_cache.IsForSearchResults)
            {
                Dictionary <int, int> colorReferences;
                RtfHelper.ColorTable(Properties.Settings.Default.QuerySearchItemBackColor, out colorReferences);
                m_searchItemColorRefNumber = colorReferences[Properties.Settings.Default.QuerySearchItemBackColor.ToArgb()];
            }

            // Sort the visible columns by their display order.
            m_sortedColumns = new SortedList <int, DataGridViewColumn>();
            foreach (DataGridViewColumn col in m_grid.Columns)
            {
                if (col.Visible && !(col is SilHierarchicalGridColumn))
                {
                    m_sortedColumns[col.DisplayIndex] = col;
                }
            }

            GetPaperAndMarginValues();
            CalculateColumnWidths();
            OutputRTFHeadingStuff();

            // This is only for running tests
            if (m_maxFieldWidths.Count > 0)
            {
                MakeFinalWidthAdjustments();
                m_rtfBldr.AppendFormat(@"\paperw{0}\paperh{1}", m_paperWidth, m_paperHeight);
                m_rtfBldr.AppendFormat(@"\margl{0}\margr{1}", m_leftMargin, m_rightMargin);
                m_rtfBldr.AppendFormat(@"\margt{0}\margb{1}", m_topMargin, m_bottomMargin);
                m_rtfBldr.AppendLine();

                OutputReportHeadingInformation();
                OutputColumnInformation();
                OutputDataRows();
                WriteToFileOrClipboard();
            }

            if (m_graphics != null)
            {
                m_graphics.Dispose();
            }
        }