mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 21:20:30 +02:00
IDE: unit resources: check dfm
git-svn-id: trunk@40328 -
This commit is contained in:
parent
02953d0b7f
commit
9a6e0c6e66
@ -1,3 +1,28 @@
|
|||||||
|
{
|
||||||
|
***************************************************************************
|
||||||
|
* *
|
||||||
|
* This source is free software; you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This code is distributed in the hope that it will be useful, but *
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||||
|
* General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* A copy of the GNU General Public License is available on the World *
|
||||||
|
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||||
|
* obtain it by writing to the Free Software Foundation, *
|
||||||
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
|
* *
|
||||||
|
***************************************************************************
|
||||||
|
|
||||||
|
Author: Joost van der Sluis
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
Registers the lfm resource format of forms.
|
||||||
|
}
|
||||||
unit lfmUnitResource;
|
unit lfmUnitResource;
|
||||||
|
|
||||||
{$mode objfpc}{$H+}
|
{$mode objfpc}{$H+}
|
||||||
@ -8,7 +33,7 @@ uses
|
|||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
LCLMemManager,
|
LCLMemManager,
|
||||||
Forms,
|
Forms,
|
||||||
UnitResources;
|
UnitResources, SrcEditorIntf, LazFileCache;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -18,7 +43,7 @@ type
|
|||||||
public
|
public
|
||||||
class function FindResourceDirective(Source: TObject): boolean; override;
|
class function FindResourceDirective(Source: TObject): boolean; override;
|
||||||
class function ResourceDirectiveFilename: string; override;
|
class function ResourceDirectiveFilename: string; override;
|
||||||
class function GetUnitResourceFilename(AUnitFilenae: string): string; override;
|
class function GetUnitResourceFilename(AUnitFilename: string; Loading: boolean): string; override;
|
||||||
class procedure TextStreamToBinStream(ATxtStream, ABinStream: TExtMemoryStream); override;
|
class procedure TextStreamToBinStream(ATxtStream, ABinStream: TExtMemoryStream); override;
|
||||||
class procedure BinStreamToTextStream(ABinStream, ATextStream: TExtMemoryStream); override;
|
class procedure BinStreamToTextStream(ABinStream, ATextStream: TExtMemoryStream); override;
|
||||||
class function GetClassNameFromStream(s: TStream; out IsInherited: Boolean): shortstring; override;
|
class function GetClassNameFromStream(s: TStream; out IsInherited: Boolean): shortstring; override;
|
||||||
@ -53,9 +78,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
class function TLFMUnitResourcefileFormat.GetUnitResourceFilename(
|
class function TLFMUnitResourcefileFormat.GetUnitResourceFilename(
|
||||||
AUnitFilenae: string): string;
|
AUnitFilename: string; Loading: boolean): string;
|
||||||
|
var
|
||||||
|
DFMFilename: String;
|
||||||
begin
|
begin
|
||||||
result := ChangeFileExt(AUnitFilenae,'.lfm');
|
Result := ChangeFileExt(AUnitFilename,'.lfm');
|
||||||
|
if not FileExistsCached(AUnitFilename)
|
||||||
|
// ToDo: search in source editor
|
||||||
|
then begin
|
||||||
|
DFMFilename:=ChangeFileExt(AUnitFilename,'.dfm');
|
||||||
|
if FileExistsCached(DFMFilename) then
|
||||||
|
Result:=DFMFilename;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TLFMUnitResourcefileFormat.TextStreamToBinStream(ATxtStream,
|
class procedure TLFMUnitResourcefileFormat.TextStreamToBinStream(ATxtStream,
|
||||||
|
@ -5089,6 +5089,7 @@ var
|
|||||||
// parse once all available component names in all .lfm files
|
// parse once all available component names in all .lfm files
|
||||||
for i:=0 to UnitFilenames.Count-1 do begin
|
for i:=0 to UnitFilenames.Count-1 do begin
|
||||||
UnitFilename:=UnitFilenames[i];
|
UnitFilename:=UnitFilenames[i];
|
||||||
|
// ToDo: use UnitResources
|
||||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||||
if not FileExistsCached(LFMFilename) then
|
if not FileExistsCached(LFMFilename) then
|
||||||
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
||||||
@ -5154,6 +5155,7 @@ var
|
|||||||
DebugLn(['TMainIDE.DoFixupComponentReferences.LoadDependencyHidden failed to find lfm for "',RefRootName,'"']);
|
DebugLn(['TMainIDE.DoFixupComponentReferences.LoadDependencyHidden failed to find lfm for "',RefRootName,'"']);
|
||||||
exit(mrCancel);
|
exit(mrCancel);
|
||||||
end;
|
end;
|
||||||
|
// ToDo: use UnitResources
|
||||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||||
if not FileExistsUTF8(LFMFilename) then
|
if not FileExistsUTF8(LFMFilename) then
|
||||||
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
||||||
@ -12123,6 +12125,7 @@ begin
|
|||||||
EditorInfo := AnUnitInfo.OpenEditorInfo[0]
|
EditorInfo := AnUnitInfo.OpenEditorInfo[0]
|
||||||
else
|
else
|
||||||
EditorInfo := AnUnitInfo.EditorInfo[0];
|
EditorInfo := AnUnitInfo.EditorInfo[0];
|
||||||
|
// ToDo: use UnitResources
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename, '.lfm');
|
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename, '.lfm');
|
||||||
if not FileExistsUTF8(LFMFilename) then
|
if not FileExistsUTF8(LFMFilename) then
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename, '.dfm');
|
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename, '.dfm');
|
||||||
|
@ -2957,7 +2957,7 @@ begin
|
|||||||
if (not AnUnitInfo.IsVirtual) or (sfSaveToTestDir in Flags) then
|
if (not AnUnitInfo.IsVirtual) or (sfSaveToTestDir in Flags) then
|
||||||
begin
|
begin
|
||||||
// save lfm file
|
// save lfm file
|
||||||
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename,false);
|
||||||
if AnUnitInfo.IsVirtual then
|
if AnUnitInfo.IsVirtual then
|
||||||
LFMFilename:=AppendPathDelim(MainBuildBoss.GetTestBuildDirectory)+LFMFilename;
|
LFMFilename:=AppendPathDelim(MainBuildBoss.GetTestBuildDirectory)+LFMFilename;
|
||||||
if LFMCode=nil then begin
|
if LFMCode=nil then begin
|
||||||
@ -3154,6 +3154,7 @@ begin
|
|||||||
OldFilename:=AnUnitInfo.Filename;
|
OldFilename:=AnUnitInfo.Filename;
|
||||||
OldFilePath:=ExtractFilePath(OldFilename);
|
OldFilePath:=ExtractFilePath(OldFilename);
|
||||||
OldLFMFilename:='';
|
OldLFMFilename:='';
|
||||||
|
// ToDo: use UnitResources
|
||||||
if FilenameIsPascalUnit(OldFilename) then begin
|
if FilenameIsPascalUnit(OldFilename) then begin
|
||||||
OldLFMFilename:=ChangeFileExt(OldFilename,'.lfm');
|
OldLFMFilename:=ChangeFileExt(OldFilename,'.lfm');
|
||||||
if not FileExistsUTF8(OldLFMFilename) then
|
if not FileExistsUTF8(OldLFMFilename) then
|
||||||
@ -3871,19 +3872,11 @@ begin
|
|||||||
//DebugLn(['TLazSourceFileManager.LoadResourceFile ',AnUnitInfo.Filename,' HasResources=',AnUnitInfo.HasResources,' IgnoreSourceErrors=',IgnoreSourceErrors,' AutoCreateResourceCode=',AutoCreateResourceCode]);
|
//DebugLn(['TLazSourceFileManager.LoadResourceFile ',AnUnitInfo.Filename,' HasResources=',AnUnitInfo.HasResources,' IgnoreSourceErrors=',IgnoreSourceErrors,' AutoCreateResourceCode=',AutoCreateResourceCode]);
|
||||||
// Load the lfm file (without parsing)
|
// Load the lfm file (without parsing)
|
||||||
if not AnUnitInfo.IsVirtual then begin // and (AnUnitInfo.Component<>nil)
|
if not AnUnitInfo.IsVirtual then begin // and (AnUnitInfo.Component<>nil)
|
||||||
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename,true);
|
||||||
if (FileExistsUTF8(LFMFilename)) then begin
|
if (FileExistsCached(LFMFilename)) then begin
|
||||||
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],ShowAbort);
|
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],ShowAbort);
|
||||||
if not (Result in [mrOk,mrIgnore]) then
|
if not (Result in [mrOk,mrIgnore]) then
|
||||||
exit;
|
exit;
|
||||||
end else begin
|
|
||||||
// Is this still being used?!?
|
|
||||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
|
||||||
if (FileExistsUTF8(LFMFilename)) then begin
|
|
||||||
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],ShowAbort);
|
|
||||||
if not (Result in [mrOk,mrIgnore]) then
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if AnUnitInfo.HasResources then begin
|
if AnUnitInfo.HasResources then begin
|
||||||
@ -3926,9 +3919,7 @@ begin
|
|||||||
|
|
||||||
UnitResourceFileformat:=AnUnitInfo.UnitResourceFileformat;
|
UnitResourceFileformat:=AnUnitInfo.UnitResourceFileformat;
|
||||||
// Note: think about virtual and normal .lfm files.
|
// Note: think about virtual and normal .lfm files.
|
||||||
UnitResourceFilename:=UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
UnitResourceFilename:=UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename,true);
|
||||||
if not FileExistsInIDE(UnitResourceFilename,[pfsfOnlyEditorFiles]) then
|
|
||||||
UnitResourceFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
|
||||||
LFMBuf:=nil;
|
LFMBuf:=nil;
|
||||||
if not FileExistsInIDE(UnitResourceFilename,[pfsfOnlyEditorFiles]) then begin
|
if not FileExistsInIDE(UnitResourceFilename,[pfsfOnlyEditorFiles]) then begin
|
||||||
// there is no LFM file -> ok
|
// there is no LFM file -> ok
|
||||||
@ -4295,6 +4286,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// ToDo: use UnitResources
|
||||||
LFMFilename:=ChangeFileExt(AFilename,'.lfm');
|
LFMFilename:=ChangeFileExt(AFilename,'.lfm');
|
||||||
if not FileExistsInIDE(LFMFilename,[]) then
|
if not FileExistsInIDE(LFMFilename,[]) then
|
||||||
LFMFilename:=ChangeFileExt(AFilename,'.dfm');
|
LFMFilename:=ChangeFileExt(AFilename,'.dfm');
|
||||||
@ -4549,6 +4541,7 @@ var
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
// ToDo: use UnitResources
|
||||||
CurLFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
CurLFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||||
if not FileExistsCached(CurLFMFilename) then
|
if not FileExistsCached(CurLFMFilename) then
|
||||||
begin
|
begin
|
||||||
|
@ -33,7 +33,7 @@ type
|
|||||||
public
|
public
|
||||||
class function FindResourceDirective(Source: TObject): boolean; virtual; abstract;
|
class function FindResourceDirective(Source: TObject): boolean; virtual; abstract;
|
||||||
class function ResourceDirectiveFilename: string; virtual; abstract;
|
class function ResourceDirectiveFilename: string; virtual; abstract;
|
||||||
class function GetUnitResourceFilename(AUnitFilename: string): string; virtual; abstract;
|
class function GetUnitResourceFilename(AUnitFilename: string; Loading: boolean): string; virtual; abstract;
|
||||||
class procedure TextStreamToBinStream(ATxtStream, ABinStream: TExtMemoryStream); virtual; abstract;
|
class procedure TextStreamToBinStream(ATxtStream, ABinStream: TExtMemoryStream); virtual; abstract;
|
||||||
class procedure BinStreamToTextStream(ABinStream, ATextStream: TExtMemoryStream); virtual; abstract;
|
class procedure BinStreamToTextStream(ABinStream, ATextStream: TExtMemoryStream); virtual; abstract;
|
||||||
class function GetClassNameFromStream(s: TStream; out IsInherited: Boolean): shortstring; virtual; abstract;
|
class function GetClassNameFromStream(s: TStream; out IsInherited: Boolean): shortstring; virtual; abstract;
|
||||||
|
Loading…
Reference in New Issue
Block a user