Changeset 198 for trunk/Forms
- Timestamp:
- Aug 23, 2018, 3:38:32 PM (6 years ago)
- Location:
- trunk/Forms
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormCheck.lfm
r192 r198 34 34 object GroupBox1: TGroupBox 35 35 Left = 11 36 Height = 2 8436 Height = 217 37 37 Top = 199 38 38 Width = 206 39 39 Anchors = [akTop, akLeft, akRight] 40 40 Caption = 'Summary section' 41 ClientHeight = 25941 ClientHeight = 192 42 42 ClientWidth = 202 43 43 TabOrder = 1 … … 128 128 OnClick = ButtonLoadFromFileClick 129 129 TabOrder = 3 130 end 131 object CheckBoxCaseSensitive: TCheckBox 132 Left = 11 133 Height = 24 134 Top = 424 135 Width = 197 136 Caption = 'Case sensitive comparison' 137 TabOrder = 4 130 138 end 131 139 end … … 151 159 Top = 8 152 160 Width = 645 153 ActivePage = TabSheet Source161 ActivePage = TabSheetReport 154 162 Align = alClient 155 163 BorderSpacing.Around = 8 156 TabIndex = 0164 TabIndex = 1 157 165 TabOrder = 0 158 166 object TabSheetSource: TTabSheet … … 175 183 ClientHeight = 586 176 184 ClientWidth = 637 177 object MemoReport: TMemo178 Left = 8179 Height = 56 8180 Top = 8181 Width = 62 0185 object ListViewReport: TListView 186 Left = 7 187 Height = 564 188 Top = 13 189 Width = 625 182 190 Anchors = [akTop, akLeft, akRight, akBottom] 191 Columns = < 192 item 193 Caption = 'Position' 194 Width = 80 195 end 196 item 197 Caption = 'Type' 198 Width = 100 199 end 200 item 201 Caption = 'Message' 202 Width = 800 203 end> 204 OwnerData = True 205 PopupMenu = PopupMenuReport 183 206 ReadOnly = True 184 ScrollBars = ssAutoBoth207 RowSelect = True 185 208 TabOrder = 0 209 ViewStyle = vsReport 210 OnData = ListViewReportData 186 211 end 187 212 end … … 194 219 top = 493 195 220 end 221 object PopupMenuReport: TPopupMenu 222 left = 378 223 top = 202 224 object MenuItemGoTo: TMenuItem 225 Caption = 'Go to location' 226 OnClick = MenuItemGoToClick 227 end 228 end 196 229 end -
trunk/Forms/UFormCheck.pas
r195 r198 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ExtCtrls, ComCtrls, UAcronym, URegistry, Registry, UCommon;9 ExtCtrls, ComCtrls, Menus, UAcronym, URegistry, Registry, UCommon, fgl; 10 10 11 11 type 12 TReportType = (rtNone, rtNote, rtWarning, rtError); 13 14 TReportItem = class 15 Message: string; 16 Position: TPoint; 17 Kind: TReportType; 18 end; 19 20 { TReportItems } 21 22 TReportItems = class(TFPGObjectList<TReportItem>) 23 function AddNew(Message: string; Position: TPoint; 24 Kind: TReportType = rtNone): TReportItem; 25 end; 12 26 13 27 { TFormCheck } … … 18 32 ButtonAcronymsSummary: TButton; 19 33 ButtonCheck: TButton; 34 CheckBoxCaseSensitive: TCheckBox; 20 35 EditSummaryStart: TEdit; 21 36 EditSummaryEnd: TEdit; … … 26 41 LabelAcronymCountContent: TLabel; 27 42 LabelAcronymCountSummary: TLabel; 43 ListViewReport: TListView; 28 44 MemoDocument: TMemo; 29 Me moReport: TMemo;45 MenuItemGoTo: TMenuItem; 30 46 OpenDialog1: TOpenDialog; 31 47 PageControl1: TPageControl; 32 48 Panel1: TPanel; 33 49 Panel2: TPanel; 50 PopupMenuReport: TPopupMenu; 34 51 Splitter1: TSplitter; 35 52 TabSheetSource: TTabSheet; … … 43 60 procedure FormDestroy(Sender: TObject); 44 61 procedure FormShow(Sender: TObject); 62 procedure ListViewReportData(Sender: TObject; Item: TListItem); 63 procedure MenuItemGoToClick(Sender: TObject); 45 64 private 46 65 AcronymDbSummary: TAcronymDb; … … 61 80 procedure ReportDifferencies; 62 81 function WordContainsLetters(Text, Letters: string): Boolean; 82 function StringEqual(Text1, Text2: string): Boolean; 83 procedure ReloadReport; 63 84 public 85 ReportItems: TReportItems; 64 86 procedure UpdateInterface; 65 87 procedure LoadConfig; … … 70 92 FormCheck: TFormCheck; 71 93 94 const 95 ReportTypeString: array[TReportType] of string = ('', 'Note', 'Warning', 'Error'); 96 72 97 73 98 implementation … … 81 106 SAcronymCountContent = 'Content acronym count:'; 82 107 SAcronymCountSummary = 'Summary acronym count:'; 83 SDuplicateAcronymContent = ' Warning:Duplicate acronym %s with "%s" in document body.';84 SDuplicateAcronymSummary = ' Warning:Duplicate acronym %s with "%s" in acronym summary.';85 SMissingAcronymContent = ' Warning:Document body acronym %s with meaning "%s" missing from acronym summary.';86 SMissingAcronymSummary = ' Warning:Summary acronym %s with meaning "%s" missing from document body.';87 SAcronymContentMultipleMeanings = ' Warning:Content acronym %s has multiple meanings: %s.';88 SAcronymSummaryMultipleMeanings = ' Warning:Summary acronym %s has multiple meanings: %s.';89 SAcronymWithDifferentMeaning = ' Warning:Acronym %s has different meaning for content "%s" and for summary "%s".';90 SAcronymWithDifferentMeaningCount = ' Warning:Acronym %s has different meaning count for content (%d) and for summary (%d).';91 SPluralAcronym = ' Note:Acronym %s is defined as plural in document body.';92 SPluralAcronymUsed = ' Note:Acronym %s is used as plural in document body.';108 SDuplicateAcronymContent = 'Duplicate acronym %s with "%s" in document body.'; 109 SDuplicateAcronymSummary = 'Duplicate acronym %s with "%s" in acronym summary.'; 110 SMissingAcronymContent = 'Document body acronym %s with meaning "%s" missing from acronym summary.'; 111 SMissingAcronymSummary = 'Summary acronym %s with meaning "%s" missing from document body.'; 112 SAcronymContentMultipleMeanings = 'Content acronym %s has multiple meanings: %s.'; 113 SAcronymSummaryMultipleMeanings = 'Summary acronym %s has multiple meanings: %s.'; 114 SAcronymWithDifferentMeaning = 'Acronym %s has different meaning for content "%s" and for summary "%s".'; 115 SAcronymWithDifferentMeaningCount = 'Acronym %s has different meaning count for content (%d) and for summary (%d).'; 116 SPluralAcronym = 'Acronym %s is defined as plural in document body.'; 117 SPluralAcronymUsed = 'Acronym %s is used as plural in document body.'; 93 118 SSummaryAcronyms = 'Summary acronyms'; 94 119 SContentAcronyms = 'Content acronyms'; … … 98 123 MinAcronymLength = 2; 99 124 125 { TReportItems } 126 127 function TReportItems.AddNew(Message: string; Position: TPoint; 128 Kind: TReportType = rtNone): TReportItem; 129 begin 130 Result := TReportItem.Create; 131 Result.Message := Message; 132 Result.Position := Position; 133 Result.Kind := Kind; 134 Add(Result); 135 end; 136 100 137 { TFormCheck } 101 138 102 139 procedure TFormCheck.ButtonCheckClick(Sender: TObject); 103 140 begin 104 MemoReport.Lines.Clear; 141 ReportItems.Clear; 142 UpdateInterface; 105 143 FindInSummary; 106 144 FindInContent; 107 145 ReportDifferencies; 108 146 UpdateInterface; 147 ReloadReport; 109 148 TabSheetReport.Show; 110 149 end; … … 132 171 Core.CoolTranslator1.TranslateComponentRecursive(Self); 133 172 Core.ThemeManager.UseTheme(Self); 173 ReportItems := TReportItems.Create; 134 174 end; 135 175 136 176 procedure TFormCheck.FormDestroy(Sender: TObject); 137 177 begin 178 ReportItems.Free; 138 179 AcronymDbSummary.Free; 139 180 AcronymDbContent.Free; … … 142 183 procedure TFormCheck.FormShow(Sender: TObject); 143 184 begin 185 PageControl1.TabIndex := 0; 144 186 Core.PersistentForm1.Load(Self); 145 if FileExists(LastDocumentFileName) then MemoDocument.Lines.LoadFromFile(LastDocumentFileName); 187 if FileExists(LastDocumentFileName) then 188 MemoDocument.Lines.LoadFromFile(LastDocumentFileName); 146 189 UpdateInterface; 190 end; 191 192 procedure TFormCheck.ListViewReportData(Sender: TObject; Item: TListItem); 193 begin 194 if Item.Index < ReportItems.Count then 195 with ReportItems[Item.Index] do begin 196 if Position <> Point(0, 0) then 197 Item.Caption := IntToStr(Position.X) + ', ' + IntToStr(Position.Y) 198 else Item.Caption := ''; 199 Item.Data := ReportItems[Item.Index]; 200 Item.SubItems.Add(ReportTypeString[Kind]); 201 Item.SubItems.Add(Message); 202 end; 203 end; 204 205 procedure TFormCheck.MenuItemGoToClick(Sender: TObject); 206 begin 207 if Assigned(ListViewReport.Selected) then 208 with TReportItem(ListViewReport.Selected.Data) do 209 if Position <> Point(0, 0) then begin 210 MemoDocument.CaretPos := Position; 211 TabSheetSource.Show; 212 end; 147 213 end; 148 214 … … 214 280 Meaning := Trim(Copy(Line, Pos(' ', Line) + 1, Length(Line))); 215 281 if Assigned(AcronymDbSummary.SearchAcronym(Acronym, Meaning)) then 216 MemoReport.Lines.Add(Format(SDuplicateAcronymSummary, [Acronym, Meaning]))282 ReportItems.AddNew(Format(SDuplicateAcronymSummary, [Acronym, Meaning]), Point(0, I), rtWarning) 217 283 else AcronymDbSummary.AddAcronym(Acronym, Meaning); 218 284 end; … … 295 361 AllowedSideChar(AcronymCharBefore, AcronymCharAfter) then begin 296 362 // If plural acronym then try to remove ending 's' character from the meaning 297 if Plural then MemoReport.Lines.Add(Format(SPluralAcronymUsed, [Acronym]));363 if Plural then ReportItems.AddNew(Format(SPluralAcronymUsed, [Acronym]), Point(0, 0), rtNote); 298 364 299 365 Acro := AcronymDbContent.Acronyms.SearchByName(Acronym); 300 366 if not Assigned(Acro) then begin 301 MemoReport.Lines.Add(Format(SAcronymUsedBeforeDefined, [Acronym]));367 ReportItems.AddNew(Format(SAcronymUsedBeforeDefined, [Acronym]), Point(0, 0), rtNote); 302 368 AcronymDbContent.AddAcronym(Acronym, ''); 303 369 end; … … 323 389 if HasMeaning1 or HasMeaning2 then begin 324 390 // If plural acronym then try to remove ending 's' character from the meaning 325 if Plural then MemoReport.Lines.Add(Format(SPluralAcronym, [Acronym]));391 if Plural then ReportItems.AddNew(Format(SPluralAcronym, [Acronym]), Point(0, 0)); 326 392 if Plural and (Length(Meaning) >= 1) and (Meaning[Length(Meaning)] = 's') then begin 327 393 Meaning := Copy(Meaning, 1, Length(Meaning) - 1); 328 394 end; 329 395 if Assigned(AcronymDbContent.SearchAcronym(Acronym, Meaning)) then 330 MemoReport.Lines.Add(Format(SDuplicateAcronymContent, [Acronym, Meaning]))396 ReportItems.AddNew(Format(SDuplicateAcronymContent, [Acronym, Meaning]), Point(0, 0), rtWarning) 331 397 else AcronymDbContent.AddAcronym(Acronym, Meaning); 332 398 end; … … 511 577 Acronym := TAcronym(AcronymDbContent.Acronyms[I]); 512 578 if Acronym.Meanings.Count > 1 then 513 MemoReport.Lines.Add(Format(SAcronymContentMultipleMeanings, [Acronym.Name, Acronym.Meanings.GetNames])); 579 ReportItems.AddNew(Format(SAcronymContentMultipleMeanings, [Acronym.Name, 580 Acronym.Meanings.GetNames]), Point(0, 0), rtWarning); 514 581 Acronym2 := AcronymDbSummary.Acronyms.SearchByName(Acronym.Name); 515 582 if not Assigned(Acronym2) then … … 517 584 Meaning := TAcronymMeaning(Acronym.Meanings[J]); 518 585 if not Assigned(AcronymDbSummary.SearchAcronym(Acronym.Name, Meaning.Name, [sfCaseInsensitive])) then 519 MemoReport.Lines.Add(Format(SMissingAcronymContent, [Acronym.Name, Meaning.Name]));586 ReportItems.AddNew(Format(SMissingAcronymContent, [Acronym.Name, Meaning.Name]), Point(0, 0), rtWarning); 520 587 end; 521 588 end; … … 525 592 Acronym := TAcronym(AcronymDbSummary.Acronyms[I]); 526 593 if Acronym.Meanings.Count > 1 then 527 MemoReport.Lines.Add(Format(SAcronymSummaryMultipleMeanings, [Acronym.Name, Acronym.Meanings.GetNames]));594 ReportItems.AddNew(Format(SAcronymSummaryMultipleMeanings, [Acronym.Name, Acronym.Meanings.GetNames]), Point(0, 0), rtWarning); 528 595 Acronym2 := AcronymDbContent.Acronyms.SearchByName(Acronym.Name); 529 596 if not Assigned(Acronym2) then … … 531 598 Meaning := TAcronymMeaning(Acronym.Meanings[J]); 532 599 if not Assigned(AcronymDbContent.SearchAcronym(Acronym.Name, Meaning.Name, [sfCaseInsensitive])) then 533 MemoReport.Lines.Add(Format(SMissingAcronymSummary, [Acronym.Name, Meaning.Name]));600 ReportItems.AddNew(Format(SMissingAcronymSummary, [Acronym.Name, Meaning.Name]), Point(0, 0), rtWarning); 534 601 end; 535 602 end; … … 543 610 Meaning := TAcronymMeaning(Acronym.Meanings[0]); 544 611 Meaning2 := TAcronymMeaning(Acronym2.Meanings[0]); 545 if Meaning.Name <> Meaning2.Namethen546 MemoReport.Lines.Add(Format(SAcronymWithDifferentMeaning, [Acronym.Name, Meaning.Name, Meaning2.Name]));612 if not StringEqual(Meaning.Name, Meaning2.Name) then 613 ReportItems.AddNew(Format(SAcronymWithDifferentMeaning, [Acronym.Name, Meaning2.Name, Meaning.Name]), Point(0, 0), rtWarning); 547 614 end else 548 MemoReport.Lines.Add(Format(SAcronymWithDifferentMeaningCount, [Acronym.Name, Acronym.Meanings.Count, Acronym2.Meanings.Count]));615 ReportItems.AddNew(Format(SAcronymWithDifferentMeaningCount, [Acronym.Name, Acronym2.Meanings.Count, Acronym.Meanings.Count]), Point(0, 0), rtWarning); 549 616 end; 550 617 end; … … 568 635 end; 569 636 637 function TFormCheck.StringEqual(Text1, Text2: string): Boolean; 638 begin 639 if CheckBoxCaseSensitive.Checked then Result := Text1 = Text2 640 else Result := LowerCase(Text1) = LowerCase(Text2); 641 end; 642 643 procedure TFormCheck.ReloadReport; 644 begin 645 ListViewReport.Items.Count := ReportItems.Count; 646 ListViewReport.Refresh; 647 end; 648 570 649 procedure TFormCheck.UpdateInterface; 571 650 begin … … 582 661 EditSummaryStart.Text := ReadStringWithDefault('SummaryStart', 'ACRONYMS AND ABBREVIATIONS'); 583 662 EditSummaryEnd.Text := ReadStringWithDefault('SummaryEnd', 'Appendix'); 584 LastDocumentFileName := ReadStringWithDefault('LastDocumentFileName', '') 663 LastDocumentFileName := ReadStringWithDefault('LastDocumentFileName', ''); 664 CheckBoxCaseSensitive.Checked := ReadBoolWithDefault('CaseSensitiveComparison', False); 585 665 finally 586 666 Free; … … 597 677 WriteString('SummaryEnd', EditSummaryEnd.Text); 598 678 WriteString('LastDocumentFileName', LastDocumentFileName); 679 WriteBool('CaseSensitiveComparison', CheckBoxCaseSensitive.Checked); 599 680 finally 600 681 Free;
Note:
See TracChangeset
for help on using the changeset viewer.