mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 16:37:49 +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;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
@ -8,7 +33,7 @@ uses
|
||||
Classes, SysUtils,
|
||||
LCLMemManager,
|
||||
Forms,
|
||||
UnitResources;
|
||||
UnitResources, SrcEditorIntf, LazFileCache;
|
||||
|
||||
type
|
||||
|
||||
@ -18,7 +43,7 @@ type
|
||||
public
|
||||
class function FindResourceDirective(Source: TObject): boolean; 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 BinStreamToTextStream(ABinStream, ATextStream: TExtMemoryStream); override;
|
||||
class function GetClassNameFromStream(s: TStream; out IsInherited: Boolean): shortstring; override;
|
||||
@ -53,9 +78,18 @@ begin
|
||||
end;
|
||||
|
||||
class function TLFMUnitResourcefileFormat.GetUnitResourceFilename(
|
||||
AUnitFilenae: string): string;
|
||||
AUnitFilename: string; Loading: boolean): string;
|
||||
var
|
||||
DFMFilename: String;
|
||||
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;
|
||||
|
||||
class procedure TLFMUnitResourcefileFormat.TextStreamToBinStream(ATxtStream,
|
||||
|
@ -5089,6 +5089,7 @@ var
|
||||
// parse once all available component names in all .lfm files
|
||||
for i:=0 to UnitFilenames.Count-1 do begin
|
||||
UnitFilename:=UnitFilenames[i];
|
||||
// ToDo: use UnitResources
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||
if not FileExistsCached(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
||||
@ -5154,6 +5155,7 @@ var
|
||||
DebugLn(['TMainIDE.DoFixupComponentReferences.LoadDependencyHidden failed to find lfm for "',RefRootName,'"']);
|
||||
exit(mrCancel);
|
||||
end;
|
||||
// ToDo: use UnitResources
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||
if not FileExistsUTF8(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(UnitFilename,'.dfm');
|
||||
@ -12123,6 +12125,7 @@ begin
|
||||
EditorInfo := AnUnitInfo.OpenEditorInfo[0]
|
||||
else
|
||||
EditorInfo := AnUnitInfo.EditorInfo[0];
|
||||
// ToDo: use UnitResources
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename, '.lfm');
|
||||
if not FileExistsUTF8(LFMFilename) then
|
||||
LFMFilename:=ChangeFileExt(AnUnitInfo.Filename, '.dfm');
|
||||
|
@ -2957,7 +2957,7 @@ begin
|
||||
if (not AnUnitInfo.IsVirtual) or (sfSaveToTestDir in Flags) then
|
||||
begin
|
||||
// save lfm file
|
||||
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
||||
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename,false);
|
||||
if AnUnitInfo.IsVirtual then
|
||||
LFMFilename:=AppendPathDelim(MainBuildBoss.GetTestBuildDirectory)+LFMFilename;
|
||||
if LFMCode=nil then begin
|
||||
@ -3154,6 +3154,7 @@ begin
|
||||
OldFilename:=AnUnitInfo.Filename;
|
||||
OldFilePath:=ExtractFilePath(OldFilename);
|
||||
OldLFMFilename:='';
|
||||
// ToDo: use UnitResources
|
||||
if FilenameIsPascalUnit(OldFilename) then begin
|
||||
OldLFMFilename:=ChangeFileExt(OldFilename,'.lfm');
|
||||
if not FileExistsUTF8(OldLFMFilename) then
|
||||
@ -3871,19 +3872,11 @@ begin
|
||||
//DebugLn(['TLazSourceFileManager.LoadResourceFile ',AnUnitInfo.Filename,' HasResources=',AnUnitInfo.HasResources,' IgnoreSourceErrors=',IgnoreSourceErrors,' AutoCreateResourceCode=',AutoCreateResourceCode]);
|
||||
// Load the lfm file (without parsing)
|
||||
if not AnUnitInfo.IsVirtual then begin // and (AnUnitInfo.Component<>nil)
|
||||
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
||||
if (FileExistsUTF8(LFMFilename)) then begin
|
||||
LFMFilename:=AnUnitInfo.UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename,true);
|
||||
if (FileExistsCached(LFMFilename)) then begin
|
||||
Result:=LoadCodeBuffer(LFMCode,LFMFilename,[lbfCheckIfText],ShowAbort);
|
||||
if not (Result in [mrOk,mrIgnore]) then
|
||||
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;
|
||||
if AnUnitInfo.HasResources then begin
|
||||
@ -3926,9 +3919,7 @@ begin
|
||||
|
||||
UnitResourceFileformat:=AnUnitInfo.UnitResourceFileformat;
|
||||
// Note: think about virtual and normal .lfm files.
|
||||
UnitResourceFilename:=UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename);
|
||||
if not FileExistsInIDE(UnitResourceFilename,[pfsfOnlyEditorFiles]) then
|
||||
UnitResourceFilename:=ChangeFileExt(AnUnitInfo.Filename,'.dfm');
|
||||
UnitResourceFilename:=UnitResourceFileformat.GetUnitResourceFilename(AnUnitInfo.Filename,true);
|
||||
LFMBuf:=nil;
|
||||
if not FileExistsInIDE(UnitResourceFilename,[pfsfOnlyEditorFiles]) then begin
|
||||
// there is no LFM file -> ok
|
||||
@ -4295,6 +4286,7 @@ begin
|
||||
exit;
|
||||
end;
|
||||
|
||||
// ToDo: use UnitResources
|
||||
LFMFilename:=ChangeFileExt(AFilename,'.lfm');
|
||||
if not FileExistsInIDE(LFMFilename,[]) then
|
||||
LFMFilename:=ChangeFileExt(AFilename,'.dfm');
|
||||
@ -4549,6 +4541,7 @@ var
|
||||
{$ENDIF}
|
||||
exit;
|
||||
end;
|
||||
// ToDo: use UnitResources
|
||||
CurLFMFilename:=ChangeFileExt(UnitFilename,'.lfm');
|
||||
if not FileExistsCached(CurLFMFilename) then
|
||||
begin
|
||||
|
@ -33,7 +33,7 @@ type
|
||||
public
|
||||
class function FindResourceDirective(Source: TObject): boolean; 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 BinStreamToTextStream(ABinStream, ATextStream: TExtMemoryStream); virtual; abstract;
|
||||
class function GetClassNameFromStream(s: TStream; out IsInherited: Boolean): shortstring; virtual; abstract;
|
||||
|
Loading…
Reference in New Issue
Block a user