Skip to content

Commit

Permalink
Merge pull request #318 from FastReports/sync_branch_637631238216966946
Browse files Browse the repository at this point in the history
FastReport.OpenSource 2021.3.21
  • Loading branch information
KirillKornienko authored Jul 29, 2021
2 parents af34b58 + d011a0f commit 2733098
Show file tree
Hide file tree
Showing 23 changed files with 410 additions and 127 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../../../FastReport.Plugins.snk</AssemblyOriginatorKeyFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Copyright>Fast Reports Inc.</Copyright>
<Company>Fast Reports Inc.</Company>
<PackageLicenseUrl>https://www.fast-report.com/en/product/fast-report-net/license</PackageLicenseUrl>
<PackageProjectUrl>https://www.fast-report.com/en/product/fast-report-net</PackageProjectUrl>
<Authors>Fast Reports Inc.</Authors>
<Product>FastReport.Data.MongoDB</Product>
<Description>Represents a connection to MongoDB database</Description>
<PackageId>FastReport.Data.MongoDB</PackageId>
<PackageIconUrl>https://www.fast-report.com/download/images/frlogo-big.png</PackageIconUrl>
<PackageTags>reporting, MongoDB, connection, reports</PackageTags>
<Version>1.0.0</Version>
<Configurations>Debug;Release;</Configurations>
<AssemblyName>FastReport.Data.MongoDB</AssemblyName>
<RootNamespace>FastReport.Data</RootNamespace>
<PackageReleaseNotes>fixed a bug with wrong database name</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StrongNamer" Version="0.2.5">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\FastReport\FastReport.csproj">
<PrivateAssets>all</PrivateAssets>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Update="MongoDBConnectionEditor.cs" />
<Compile Update="MongoDBConnectionEditor.Designer.cs">
<DependentUpon>MongoDBConnectionEditor.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="MongoDBConnectionEditor.resx">
<DependentUpon>MongoDBConnectionEditor.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.13.0" />
</ItemGroup>
</Project>
8 changes: 7 additions & 1 deletion FastReport.Base/Data/TableDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,13 @@ protected override object GetValue(Column column)
return null;

if (column.Tag == null)
column.Tag = Table.Columns.IndexOf(column.Name);
{
int index = Table.Columns.IndexOf(column.Name);
if (index == -1)
return null;
column.Tag = index;
}


return CurrentRow == null ? null : ((DataRow)CurrentRow)[(int)column.Tag];
}
Expand Down
6 changes: 2 additions & 4 deletions FastReport.Base/Engine/ReportEngine.Subreports.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ private void RenderInnerSubreports(BandBase parentBand)

private void RenderOuterSubreports(BandBase parentBand)
{
float saveCurX = CurX;
float saveCurY = CurY;
float saveOriginX = originX;
int saveCurPage = CurPage;
Expand All @@ -60,10 +59,9 @@ private void RenderOuterSubreports(BandBase parentBand)
{
for (int i = 0; i < parentBand.Objects.Count; i++)
{
if ((parentBand.Objects[i] is SubreportObject) && (parentBand.Objects[i] as SubreportObject).Visible &&
!(parentBand.Objects[i] as SubreportObject).PrintOnParent)
SubreportObject subreport = parentBand.Objects[i] as SubreportObject;
if (subreport != null && subreport.Visible && !subreport.PrintOnParent)
{
SubreportObject subreport = parentBand.Objects[i] as SubreportObject;
hasSubreports = true;
// restore start position
CurPage = saveCurPage;
Expand Down
4 changes: 3 additions & 1 deletion FastReport.Base/Engine/ReportEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,10 @@ internal void RunPhase1(bool resetDataState = true)
Report.OnStartReport(EventArgs.Empty);
}

internal void RunPhase2()
internal void RunPhase2(int? pagesLimit = null)
{
if (pagesLimit != null)
this.pagesLimit = pagesLimit.Value;
try
{
Config.ReportSettings.OnStartProgress(Report);
Expand Down
70 changes: 41 additions & 29 deletions FastReport.Base/PageFooterBand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,51 @@

namespace FastReport
{
/// <summary>
/// Represents a page footer band.
/// </summary>
public class PageFooterBand : BandBase
{
#region Properties
/// <summary>
/// This property is not relevant to this class.
/// Represents a page footer band.
/// </summary>
[Browsable(false)]
public new bool StartNewPage
public class PageFooterBand : BandBase
{
get { return base.StartNewPage; }
set { base.StartNewPage = value; }
}
#region Properties
/// <summary>
/// This property is not relevant to this class.
/// </summary>
[Browsable(false)]
public new bool StartNewPage
{
get { return base.StartNewPage; }
set { base.StartNewPage = value; }
}

/// <summary>
/// This property is not relevant to this class.
/// </summary>
[Browsable(false)]
public new bool PrintOnBottom
{
get { return base.PrintOnBottom; }
set { base.PrintOnBottom = value; }
}
#endregion
/// <summary>
/// This property is not relevant to this class.
/// </summary>
[Browsable(false)]
public new bool PrintOnBottom
{
get { return base.PrintOnBottom; }
set { base.PrintOnBottom = value; }
}
#endregion

/// <summary>
/// Initializes a new instance of the <see cref="PageFooterBand"/> class with default settings.
/// </summary>
public PageFooterBand()
{
FlagUseStartNewPage = false;
/// <inheritdoc/>
public override void InitializeComponent()
{
base.InitializeComponent();
// SubreportObject on a pagefooter will produce StackOverflow exception. Set PrintOnParent flag to avoid this
foreach (ReportComponentBase obj in Objects)
{
if (obj is SubreportObject)
(obj as SubreportObject).PrintOnParent = true;
}
}

/// <summary>
/// Initializes a new instance of the <see cref="PageFooterBand"/> class with default settings.
/// </summary>
public PageFooterBand()
{
FlagUseStartNewPage = false;
}
}
}
}
4 changes: 2 additions & 2 deletions FastReport.Base/Report.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2406,9 +2406,9 @@ public void PreparePhase1()
/// For internal use only.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void PreparePhase2()
public void PreparePhase2(int? pagesLimit = null)
{
Engine.RunPhase2();
Engine.RunPhase2(pagesLimit);
SetRunning(false);
}

Expand Down
3 changes: 2 additions & 1 deletion FastReport.Base/TextObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,11 +1110,12 @@ internal HtmlTextRenderer GetHtmlTextRenderer(IGraphics g, float scale, float fo

internal HtmlTextRenderer GetHtmlTextRenderer(IGraphics g, float formatScale, float scale, float fontScale, RectangleF textRect, StringFormat format, bool isPrinting)
{
bool isDifferentTabPositions = TabPositions.Count > 0;
return new HtmlTextRenderer(Text, g, font.Name, font.Size, font.Style, TextColor,
textOutline.Color, textRect, Underlines,
format, horzAlign, vertAlign, ParagraphFormat.MultipleScale(formatScale), ForceJustify,
scale * 96f / DrawUtils.ScreenDpi, fontScale * 96f / DrawUtils.ScreenDpi, InlineImageCache,
isPrinting);
isPrinting, isDifferentTabPositions);
}

/// <summary>
Expand Down
27 changes: 24 additions & 3 deletions FastReport.Base/Utils/HtmlTextRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class HtmlTextRenderer : IDisposable
private float fontScale;
private FastString cacheString = new FastString(100);
private bool isPrinting;
private bool isDifferentTabPositions;

#endregion Private Fields

#region Public Properties
Expand Down Expand Up @@ -110,7 +112,7 @@ public bool WordWrap
public HtmlTextRenderer(string text, IGraphics g, string font, float size,
FontStyle style, Color color, Color underlineColor, RectangleF rect, bool underlines,
StringFormat format, HorzAlign horzAlign, VertAlign vertAlign,
ParagraphFormat paragraphFormat, bool forceJustify, float scale, float fontScale, InlineImageCache cache, bool isPrinting = false)
ParagraphFormat paragraphFormat, bool forceJustify, float scale, float fontScale, InlineImageCache cache, bool isPrinting = false, bool isDifferentTabPositions = false)
{
this.cache = cache;
this.scale = scale;
Expand Down Expand Up @@ -143,6 +145,7 @@ public HtmlTextRenderer(string text, IGraphics g, string font, float size,
this.font = font;
this.size = size;
this.isPrinting = isPrinting;
this.isDifferentTabPositions = isDifferentTabPositions;
everUnderlines = underlines;

backgrounds = new List<RectangleFColor>();
Expand Down Expand Up @@ -550,6 +553,16 @@ private bool EndsWith(string str1, string str2)
}
}

private float GetTabPosition(float pos)
{
float tabOffset = TabOffset;
float tabSize = TabSize;
int tabPosition = (int)((pos - tabOffset) / tabSize);
if (pos < tabOffset)
return tabOffset;
return (tabPosition + 1) * tabSize + tabOffset;
}

private float GetTabPosition(float pos, int tabIndex)
{
float tabOffset = 0;
Expand Down Expand Up @@ -651,7 +664,11 @@ private void SplitToParagraphs(string text)

Run tabRun = new RunText(this, word, style, new List<CharWithIndex>(new CharWithIndex[] { reader.Character }), width, charIndex);
word.Runs.Add(tabRun);
float width2 = GetTabPosition(width, tabIndex);
float width2 = GetTabPosition(width);
if (isDifferentTabPositions)
{
width2 = GetTabPosition(width, tabIndex);
}
if (width2 < width) width2 = width;
if (line.Words.Count > 0 && width2 > displayRect.Width)
{
Expand All @@ -660,7 +677,11 @@ private void SplitToParagraphs(string text)
tabIndex = 0;
paragraph.Lines.Add(line);
width = 0;
width2 = GetTabPosition(width, tabIndex);
width2 = GetTabPosition(width);
if (isDifferentTabPositions)
{
width2 = GetTabPosition(width, tabIndex);
}
}
tabIndex++;
line.Words.Add(word);
Expand Down
12 changes: 6 additions & 6 deletions FastReport.Base/Utils/Zip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public void SaveToStream(Stream Stream)
Stream.Write(BitConverter.GetBytes(fileNameLength), 0, 2);
Stream.Write(BitConverter.GetBytes(extraFieldLength), 0, 2);
if (fileNameLength > 0)
Stream.Write(Converter.StringToByteArray(fileName), 0, fileNameLength);
Stream.Write(System.Text.Encoding.UTF8.GetBytes(fileName), 0, fileNameLength);
if (extraFieldLength > 0)
Stream.Write(Converter.StringToByteArray(extraField), 0, extraFieldLength);
}
Expand Down Expand Up @@ -421,7 +421,7 @@ public string FileName
set
{
fileName = value.Replace('\\', '/');
fileNameLength = (ushort)value.Length;
fileNameLength = (ushort)System.Text.Encoding.UTF8.GetBytes(value).Length;
}
}

Expand All @@ -440,7 +440,7 @@ public ZipLocalFileHeader()
{
localFileHeaderSignature = 0x04034b50;
version = 20;
generalPurpose = 0;
generalPurpose = 0x800;
compressionMethod = 0;
crc32 = 0;
lastModFileDate = 0;
Expand Down Expand Up @@ -591,7 +591,7 @@ public void SaveToStream(Stream Stream)
Stream.Write(BitConverter.GetBytes(internalFileAttribute), 0, 2);
Stream.Write(BitConverter.GetBytes(externalFileAttribute), 0, 4);
Stream.Write(BitConverter.GetBytes(relativeOffsetLocalHeader), 0, 4);
Stream.Write(Converter.StringToByteArray(fileName), 0, fileNameLength);
Stream.Write(System.Text.Encoding.UTF8.GetBytes(fileName), 0, fileNameLength);
Stream.Write(Converter.StringToByteArray(extraField), 0, extraFieldLength);
Stream.Write(Converter.StringToByteArray(fileComment), 0, fileCommentLength);
}
Expand Down Expand Up @@ -695,7 +695,7 @@ public string FileName
set
{
fileName = value.Replace('\\', '/');
fileNameLength = (ushort)value.Length;
fileNameLength = (ushort)System.Text.Encoding.UTF8.GetBytes(value).Length;
}
}

Expand Down Expand Up @@ -735,7 +735,7 @@ public ZipFileHeader()
diskNumberStart = 0;
lastModFileDate = 0;
versionMadeBy = 20;
generalPurpose = 0;
generalPurpose = 0x800;
fileNameLength = 0;
internalFileAttribute = 0;
extraFieldLength = 0;
Expand Down
Loading

0 comments on commit 2733098

Please sign in to comment.