~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to examples/fpdocrepair/mainunit.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
unit MainUnit;
2
 
 
3
 
{$mode objfpc}{$H+}
4
 
 
5
 
interface
6
 
 
7
 
uses
8
 
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, LCLProc,
9
 
  contnrs, CTXMLFixFragment;
10
 
 
11
 
type
12
 
 
13
 
  { TForm1 }
14
 
 
15
 
  TForm1 = class(TForm)
16
 
    procedure FormCreate(Sender: TObject);
17
 
  private
18
 
    FVerbose: boolean;
19
 
  public
20
 
    procedure TestComment;
21
 
    procedure TestInvalidCharacters;
22
 
    procedure TestOpenTag;
23
 
    procedure TestAttribute;
24
 
    procedure TestCloseTag;
25
 
    procedure TestBugReports;
26
 
    function Test(Title, Fragment, FixedFragment: string): boolean;
27
 
    property Verbose: boolean read FVerbose write FVerbose;
28
 
  end;
29
 
 
30
 
var
31
 
  Form1: TForm1;
32
 
 
33
 
implementation
34
 
 
35
 
{$R *.lfm}
36
 
 
37
 
{ TForm1 }
38
 
 
39
 
procedure TForm1.FormCreate(Sender: TObject);
40
 
begin
41
 
  Verbose:=false;
42
 
  TestComment;
43
 
  TestInvalidCharacters;
44
 
  TestOpenTag;
45
 
  TestAttribute;
46
 
  TestCloseTag;
47
 
  TestBugReports;
48
 
end;
49
 
 
50
 
procedure TForm1.TestComment;
51
 
begin
52
 
  Test('close comment','<!--','<!---->');
53
 
  Test('close comment and delete invalid char','<!--null'#0#1#2'comment','<!--nullcomment-->');
54
 
end;
55
 
 
56
 
procedure TForm1.TestInvalidCharacters;
57
 
begin
58
 
  Test('delete special characters','A'#0'B'#1#127,'AB');
59
 
  Test('replace tag characters','LT< GT>AMP&','LT&lt; GT&gt;AMP&amp;');
60
 
  Test('lower case special characters','&LT;','&lt;');
61
 
end;
62
 
 
63
 
procedure TForm1.TestOpenTag;
64
 
begin
65
 
  Test('missing tag name','<>','&lt;&gt;');
66
 
  Test('lower case tag name','<A></a>','<a></a>');
67
 
  Test('invalid character in tag','<a "></a>','<a >"&gt;</a>');
68
 
end;
69
 
 
70
 
procedure TForm1.TestAttribute;
71
 
begin
72
 
  Test('lower case attribute name','<a Name=""></a>','<a name=""></a>');
73
 
  Test('missing attribute equal','<a name ""></a>','<a name =""></a>');
74
 
  Test('missing attribute value','<a name=></a>','<a name=""></a>');
75
 
  Test('missing attribute quotes','<a name=1></a>','<a name="1"></a>');
76
 
  Test('missing attribute ending quote','<a name="1></a>','<a name="1"></a>');
77
 
  Test('invalid character in attribute value','<a name="&"></a>','<a name="&amp;"></a>');
78
 
  Test('amp attribute value','<a name="&amp;"></a>','<a name="&amp;"></a>');
79
 
end;
80
 
 
81
 
procedure TForm1.TestCloseTag;
82
 
begin
83
 
  Test('lower case close tag name','<a></A>','<a></a>');
84
 
  Test('close open tag','<a>','<a/>');
85
 
  Test('close open sub tag','<p><a></p>','<p><a/></p>');
86
 
  Test('disable invalid close tag','</p>','&lt;/p&gt;');
87
 
end;
88
 
 
89
 
procedure TForm1.TestBugReports;
90
 
begin
91
 
  Test('15120','operator <(TPoint, TPoint): Boolean',
92
 
                 'operator &lt;(TPoint, TPoint): Boolean');
93
 
  Test('16671','<br>',
94
 
               '<br/>');
95
 
end;
96
 
 
97
 
function TForm1.Test(Title, Fragment, FixedFragment: string): boolean;
98
 
var
99
 
  s: String;
100
 
  ErrorList: TObjectList;
101
 
begin
102
 
  Result:=true;
103
 
  try
104
 
    s:=Fragment;
105
 
    FixFPDocFragment(s,true,true,ErrorList,Verbose);
106
 
    if s<>FixedFragment then begin
107
 
      Result:=false;
108
 
      debugln(['failed: ',Title]);
109
 
      debugln(['  fragment: '+DbgStr(Fragment)]);
110
 
      debugln(['  should:   '+DbgStr(FixedFragment)]);
111
 
      debugln(['  result:   '+DbgStr(s)]);
112
 
    end;
113
 
  finally
114
 
    ErrorList.Free;
115
 
  end;
116
 
end;
117
 
 
118
 
end.
119