Skip to content

Commit

Permalink
V3.0.0 Released
Browse files Browse the repository at this point in the history
  • Loading branch information
XceedBoucherS committed Jan 22, 2024
1 parent ea2ffa7 commit 076b73a
Show file tree
Hide file tree
Showing 66 changed files with 634 additions and 353 deletions.
2 changes: 1 addition & 1 deletion Xceed.Document.NET/AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at
internal static class _XceedVersionInfo
{
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public const string BaseVersion = "2.5";
public const string BaseVersion = "3.0";
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public const string Version = BaseVersion +
".0.0";
Expand Down
81 changes: 51 additions & 30 deletions Xceed.Document.NET/Src/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public virtual void ReplaceText( string searchValue,

// Update paragraph Indexes once to have valid values.
this.RefreshParagraphIndexes();
// Paragraph indexes won't be update during replacement, only after.
// Paragraph indexes won't be updated during replacement, only after.
this.PreventUpdateParagraphIndexes = true;

foreach( var p in this.Paragraphs )
Expand All @@ -422,7 +422,7 @@ public virtual void ReplaceText( string searchValue,

if( this.Paragraphs.Count > 0 )
{
this.Paragraphs[ 0 ].GetMainParentContainer().NeedRefreshParagraphIndexes = true;
this.Paragraphs[ 0 ].NeedRefreshIndexes();
}
}

Expand Down Expand Up @@ -482,7 +482,7 @@ public virtual void ReplaceText( string searchValue,

if( this.Paragraphs.Count > 0 )
{
this.Paragraphs[ 0 ].GetMainParentContainer().NeedRefreshParagraphIndexes = true;
this.Paragraphs[ 0 ].NeedRefreshIndexes();
}
}

Expand Down Expand Up @@ -530,7 +530,7 @@ public virtual void ReplaceTextWithObject( string searchValue,

if( this.Paragraphs.Count > 0 )
{
this.Paragraphs[ 0 ].GetMainParentContainer().NeedRefreshParagraphIndexes = true;
this.Paragraphs[ 0 ].NeedRefreshIndexes();
}
}

Expand Down Expand Up @@ -564,6 +564,8 @@ public virtual bool ReplaceTextWithObject( ObjectReplaceTextOptions replaceTextO
return this.ReplaceTextCore( replaceTextOptions );
}



/// Inserts the provided text at a bookmark location in this Container, using the specified formatting.
public virtual void InsertAtBookmark( string toInsert, string bookmarkName, Formatting formatting = null )
{
Expand Down Expand Up @@ -680,7 +682,7 @@ split[ 1 ]
}
this.SetParentContainer( p );
// Clear Paragraph cache because the split modified the paragraphs.
this.ClearParagraphsCache();
this.ClearParagraphsCache();

return p;
}
Expand Down Expand Up @@ -855,7 +857,7 @@ public virtual Paragraph InsertParagraph( string text, bool trackChanges, Format
}

this.SetParentContainer( newParagraphAdded );
this.AddParagraphInCache( newParagraphAdded );
this.AddParagraphInCache( newParagraphAdded );

return newParagraphAdded;
}
Expand All @@ -869,6 +871,8 @@ public virtual Paragraph InsertParagraph( string text, bool trackChanges, Format





/// <summary>
/// Removes paragraph at specified position
/// </summary>
Expand Down Expand Up @@ -1047,6 +1051,8 @@ public virtual List InsertList( int index, List list )
elements.Add( split[ 1 ] );
p.Xml.ReplaceWith( elements.ToArray() );

this.ClearParagraphsCache();

return list;
}

Expand Down Expand Up @@ -1111,10 +1117,13 @@ internal List<Paragraph> GetParagraphs()
}

var paragraph = new Paragraph( this.Document, xElement, index );
paragraph._startIndex = index;
var length = HelperFunctions.GetText( xElement ).Length;
index += Math.Max( 1, length );
paragraph._endIndex = Math.Max( 1, index - 1 );
paragraph.ParentContainer = this.GetParentFromXmlName( paragraph.Xml.Ancestors().First().Name.LocalName );
paragraph.PackagePart = this.PackagePart;
paragraphs.Add( paragraph );
index += Math.Max( 1, HelperFunctions.GetText( xElement ).Length );
}
}

Expand Down Expand Up @@ -1265,7 +1274,7 @@ internal void AddParagraphInCache( Paragraph p )
{
this.Document.ClearParagraphsCache();
}
p.GetMainParentContainer().NeedRefreshParagraphIndexes = true;
p.NeedRefreshIndexes();
}

#endregion
Expand All @@ -1274,31 +1283,29 @@ internal void AddParagraphInCache( Paragraph p )

private void RemoveParagraphFromCache( int index )
{
if( ( index != -1 )
if( ( index >= 0 )
&& ( _editableParagraphsCollection.Count > 0 )
&& ( index < _editableParagraphsCollection.Count ) )
{
var mainContainer = _editableParagraphsCollection[ index ].GetMainParentContainer();
_editableParagraphsCollection.RemoveAt( index );
if( this is Section )
{
this.Document.ClearParagraphsCache();
}
mainContainer.NeedRefreshParagraphIndexes = true;
}
}

private void RemoveParagraphFromCache( Paragraph paragraph )
{
var index = _editableParagraphsCollection.FindIndex( p => p.Xml == paragraph.Xml );
if( index != -1 )
if( index >= 0 )
{
_editableParagraphsCollection.RemoveAt( index );
if( this is Section )
{
this.Document.ClearParagraphsCache();
}
paragraph.GetMainParentContainer().NeedRefreshParagraphIndexes = true;
paragraph.NeedRefreshIndexes();
}
}

Expand Down Expand Up @@ -1427,35 +1434,49 @@ private bool ReplaceTextCore( ReplaceTextOptionsBase replaceTextOptions )

// Update paragraph Indexes once to have valid values.
this.RefreshParagraphIndexes();
// Paragraph indexes won't be update during replacement, only after.
// Paragraph indexes won't be updated during replacement, only after.
this.PreventUpdateParagraphIndexes = true;

foreach( var p in this.Paragraphs.ToList() )
{
if( ( replaceTextOptions.StartIndex >= 0 ) && ( p.EndIndex < replaceTextOptions.StartIndex ) )
continue;
if( ( replaceTextOptions.EndIndex >= 0 ) && ( p.StartIndex > replaceTextOptions.EndIndex ) )
break;

var result = replaceTextOptions is StringReplaceTextOptions
? p.ReplaceText( replaceTextOptions as StringReplaceTextOptions )
: replaceTextOptions is FunctionReplaceTextOptions
? p.ReplaceText( replaceTextOptions as FunctionReplaceTextOptions )
: p.ReplaceTextWithObject( replaceTextOptions as ObjectReplaceTextOptions );

if( !replaceSuccess )



foreach( var p in this.Paragraphs.ToList() )
{
replaceSuccess = result;
}
if( ( replaceTextOptions.StartIndex >= 0 ) && ( p.EndIndex < replaceTextOptions.StartIndex ) )
continue;
if( ( replaceTextOptions.EndIndex >= 0 ) && ( p.StartIndex > replaceTextOptions.EndIndex ) )
break;

if( replaceTextOptions.StopAfterOneReplacement && result )
break;
bool result = false;
if( replaceTextOptions is StringReplaceTextOptions )
{
result = p.ReplaceText( replaceTextOptions as StringReplaceTextOptions );
}
else if( replaceTextOptions is FunctionReplaceTextOptions )
{
result = p.ReplaceText( replaceTextOptions as FunctionReplaceTextOptions );
}
else
{
result = p.ReplaceTextWithObject( replaceTextOptions as ObjectReplaceTextOptions );
}

if( !replaceSuccess )
{
replaceSuccess = result;
}

if( replaceTextOptions.StopAfterOneReplacement && result )
break;

}

this.PreventUpdateParagraphIndexes = false;
this.NeedRefreshParagraphIndexes = true;


return replaceSuccess;
}

Expand Down
Loading

0 comments on commit 076b73a

Please sign in to comment.