fpspreadsheet: Improved syntax for mixed fraction formatting strings

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4074 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2015-03-31 20:15:04 +00:00
parent 5c2b844bb7
commit ccf0fa6a51
4 changed files with 20 additions and 13 deletions

View File

@ -903,21 +903,21 @@ object MainForm: TMainForm
WorkbookSource = WorkbookSource
Caption = 'Fraction (1 digit)'
NumberFormat = nfFraction
NumberFormatString = '#" "#/#'
NumberFormatString = '# #/#'
end
object AcNumFormatFraction2: TsNumberFormatAction
Category = 'FPSpreadsheet'
WorkbookSource = WorkbookSource
Caption = 'Fraction (2 digits)'
NumberFormat = nfFraction
NumberFormatString = '#" "##/##'
NumberFormatString = '# ##/##'
end
object AcNumFormatFraction3: TsNumberFormatAction
Category = 'FPSpreadsheet'
WorkbookSource = WorkbookSource
Caption = 'Fraction (3 digits)'
NumberFormat = nfFraction
NumberFormatString = '#" "###/###'
NumberFormatString = '# ###/###'
end
object AcNumFormatDateTime: TsNumberFormatAction
Category = 'FPSpreadsheet'

View File

@ -122,13 +122,9 @@ type
// Format string
function BuildFormatString(ADialect: TsNumFormatDialect): String; virtual;
function BuildFormatStringFromSection(ASection: Integer;
ADialect: TsNumFormatDialect; AStartIndex: Integer = 0): String; virtual;
ADialect: TsNumFormatDialect): String; virtual;
// NumberFormat
procedure EvalNumFormatOfSection(ASection: Integer);
{; out ANumFormat: TsNumberFormat;
out ADecimals: byte; out ANumerator, ADenominator: Integer;
out ACurrencySymbol: String; out AColor: TsColor);
}
function IsCurrencyAt(ASection: Integer; out ANumFormat: TsNumberFormat;
out ADecimals: byte; out ACurrencySymbol: String; out AColor: TsColor): Boolean;
function IsDateAt(ASection,AIndex: Integer; out ANumberFormat: TsNumberFormat;
@ -296,7 +292,7 @@ end;
{ Creates a format string for the given section. This implementation covers
the formatstring dialects of fpc (nfdDefault) and Excel (nfdExcel). }
function TsNumFormatParser.BuildFormatStringFromSection(ASection: Integer;
ADialect: TsNumFormatDialect; AStartIndex: Integer = 0): String;
ADialect: TsNumFormatDialect): String;
var
element: TsNumFormatElement;
i: Integer;
@ -588,7 +584,7 @@ begin
exit;
end;
// nfFraction
if IsTextAt(' ', ASection, next) and
if (IsTokenAt(nftSpace, ASection, next) or IsTextAt(' ', ASection, next)) and
IsNumberAt(ASection, next+1, nf, num, next) and
IsTokenAt(nftFraction, ASection, next) and
IsNumberAt(ASection, next+1, nf, denom, next) and
@ -659,7 +655,7 @@ begin
end;
end;
// What is left must be a custom format.
// If we get here it must be a custom format.
FSections[ASection].NumFormat := nfCustom;
end;

View File

@ -1151,7 +1151,7 @@ begin
DupeString('#', ANumeratorDigits), DupeString('#', ADenominatorDigits)
]);
if AMixedFraction then
Result := '#" "' + Result;
Result := '# ' + Result;
end;
{@@ ----------------------------------------------------------------------------

View File

@ -20,12 +20,21 @@
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<MacroValues Count="1">
<Macro1 Name="LCLWidgetType" Value="win32"/>
</MacroValues>
<BuildModes Count="3">
<Item1 Name="Release" Default="True"/>
<Item2 Name="Debug">
<MacroValues Count="1">
<Macro1 Name="LCLWidgetType" Value="win32"/>
</MacroValues>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="bin\$(TargetCPU)-$(TargetOS)\BiffExplorer"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="mrumenu"/>
@ -48,6 +57,9 @@
</CompilerOptions>
</Item2>
<Item3 Name="Debug with heaptrace">
<MacroValues Count="1">
<Macro1 Name="LCLWidgetType" Value="win32"/>
</MacroValues>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
@ -165,7 +177,6 @@
<Unit10>
<Filename Value="betypes.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="beTypes"/>
</Unit10>
</Units>
</ProjectOptions>