LazReport, added compatible read for original (produced with Lazarus 1.4.4, frVersion=28) prepared reports on newer versions plus option (enabled by default) for ugrading old prepared reports to current version, fix issue #29966

git-svn-id: trunk@52108 -
This commit is contained in:
jesus 2016-04-05 21:24:15 +00:00
parent eb754b6fff
commit 3594a6b528
15 changed files with 140 additions and 6 deletions

View File

@ -2312,6 +2312,14 @@ msgstr "Zobrazit na všech stránkách"
msgid "Report file"
msgstr "Soubor reportu"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr "Datum vytvoření reportu"

View File

@ -2310,6 +2310,14 @@ msgstr "Auf allen Seiten anzeigen"
msgid "Report file"
msgstr "Reportdatei"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr "Erstelldatum"

View File

@ -2303,6 +2303,14 @@ msgstr "Mostrar en todas las páginas"
msgid "Report file"
msgstr "Archivo de reporte"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr "Fecha de creación del reporte"

View File

@ -2303,6 +2303,14 @@ msgstr "Afficher dans toutes les pages"
msgid "Report file"
msgstr "Fichier du rapport"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr "Date de création du rapport"

View File

@ -2302,6 +2302,14 @@ msgstr "Megjelenítés minden oldalon"
msgid "Report file"
msgstr "Jelentés &fájl"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr "Jelentés létrehozásának dátuma"

View File

@ -2348,6 +2348,14 @@ msgstr "Tampilkan pada semua halaman"
msgid "Report file"
msgstr "File laporan"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr ""

View File

@ -2304,6 +2304,14 @@ msgstr "Mostra su tutte le pagine"
msgid "Report file"
msgstr "File del report"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr "Data di creazione del report"

View File

@ -2320,6 +2320,14 @@ msgstr "Rodyti visuose lapuose"
msgid "Report file"
msgstr "Pranešimo failas"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
#, fuzzy
#| msgid "Report create date"

View File

@ -2308,6 +2308,14 @@ msgstr "Pokaż na wszystkich stronach"
msgid "Report file"
msgstr "Plik zapisanego raportu"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr "Data utworzenia raportu"

View File

@ -2295,6 +2295,14 @@ msgstr ""
msgid "Report file"
msgstr ""
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr ""

View File

@ -2319,6 +2319,14 @@ msgstr "Exibir em todas as páginas"
msgid "Report file"
msgstr "Arquivo relatório"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
#, fuzzy
#| msgid "Report create date"

View File

@ -2302,6 +2302,14 @@ msgstr "Показывать на всех страницах"
msgid "Report file"
msgstr "Файл очёта"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr "Дата создания отчёта"

View File

@ -2321,6 +2321,14 @@ msgstr "Показувати на всіх сторінках"
msgid "Report file"
msgstr "Файл звіту"
#: lr_const.sreportcorruptoldknowversion
msgid "This report is corrupt, it probably needs \"LRE_OLDV%d_FRF_READ\"=true"
msgstr ""
#: lr_const.sreportcorruptunknownversion
msgid "This report is corrupt, frVersion=%d"
msgstr ""
#: lr_const.sreportcreatedate
msgid "Report creation date"
msgstr ""

View File

@ -90,7 +90,7 @@ type
TfrFrameBorders = set of TfrFrameBorder;
TfrFrameStyle = (frsSolid,frsDash, frsDot, frsDashDot, frsDashDotDot,frsDouble);
TfrPageType = (ptReport, ptDialog); //todo: - remove this
TfrReportOption = (roIgnoreFieldNotFound, roIgnoreSymbolNotFound, roHideDefaultFilter);
TfrReportOption = (roIgnoreFieldNotFound, roIgnoreSymbolNotFound, roHideDefaultFilter, roDontUpgradePreparedReport);
TfrReportOptions = set of TfrReportOption;
TfrObjectType = (otlReportView, otlUIControl);
@ -1022,6 +1022,7 @@ type
procedure SaveToStream(AStream: TStream);
procedure SavePageToStream(PageNo:Integer; AStream: TStream);
procedure SaveToXML({%H-}XML: TLrXMLConfig; const {%H-}Path: String);
procedure UpgradeToCurrentVersion;
property Pages[Index: Integer]: PfrPageInfo read GetPages; default;
property Count: Integer read GetCount;
end;
@ -1587,6 +1588,7 @@ var
FRE_COMPATIBLE_READ: Boolean = False;
{$ENDIF}
LRE_OLDV25_FRF_READ: Boolean = False; // read broken frf v25 reports, bug 25037
LRE_OLDV28_FRF_READ: Boolean = False; // read frf v28 (lazarus 1.4.4) reports, bug 29966
// variables used through report building
TempBmp: TBitmap; // temporary bitmap used by TfrMemoView
@ -1664,7 +1666,10 @@ end;
function ViewInfo(View: TfrView): string;
begin
result := format('"%s":%s typ=%s',[View.Name, dbgsname(View), frTypeObjectToStr(View.Typ)]);
if View=nil then
result := 'View is nil'
else
result := format('"%s":%s typ=%s',[View.Name, dbgsname(View), frTypeObjectToStr(View.Typ)]);
end;
function ViewInfoDim(View: TfrView): string;
@ -4582,7 +4587,10 @@ begin
frReadMemo(Stream, FOnMouseEnter);
frReadMemo(Stream, FOnMouseLeave);
FDetailReport:=frReadString(Stream);
Stream.Read(FParagraphGap, SizeOf(FParagraphGap));
if LRE_OLDV28_FRF_READ and (frVersion=28) then
//
else
Stream.Read(FParagraphGap, SizeOf(FParagraphGap));
end;
if frVersion >= 29 then
@ -9170,9 +9178,17 @@ begin
else
s := '';
t := frCreateObject(b, s, P^.Page);
t.StreamMode := smPrinting;
t.LoadFromStream(Stream);
t.StreamMode := smDesigning;
try
t.StreamMode := smPrinting;
t.LoadFromStream(Stream);
t.StreamMode := smDesigning;
except
if frVersion in [25, 28] then
ShowMessage(format(sReportCorruptOldKnowVersion,[frVersion]))
else
ShowMessage(format(sReportCorruptUnknownVersion,[frVersion]));
break;
end;
// Page.Objects.Add(t);
end;
end;
@ -9557,6 +9573,16 @@ begin
// Todo
end;
procedure TfrEMFPages.UpgradeToCurrentVersion;
var
i: Integer;
begin
for i:=0 to Count-1 do begin
ObjectsToPage(i);
PageToObjects(i);
end;
end;
{-----------------------------------------------------------------------}
constructor TfrValues.Create;
begin
@ -10614,6 +10640,8 @@ var
Stream: TFileStreamUtf8;
begin
Stream := TFileStreamUtf8.Create(FName, fmCreate);
if not CanRebuild and not (roDontUpgradePreparedReport in Options) then
EMFPages.UpgradeToCurrentVersion;
EMFPages.SaveToStream(Stream);
Stream.Free;
end;

View File

@ -816,6 +816,8 @@ resourcestring
sUseFixedFontSettings = 'Use fixed font settings';
sScriptEditor = 'Script editor';
sUseSyntaxHighlight = 'Use syntax highlight';
sReportCorruptOldKnowVersion = 'This report is corrupt, it probably needs "LRE_OLDV%d_FRF_READ"=true';
sReportCorruptUnknownVersion = 'This report is corrupt, frVersion=%d';
const
frRes = 53000;