//There might be more repeters below the current repeater whose value of top and bottom might have canged because of new row additions private void IncreaseReapetersBeneathDefinitionRowBy(int increaseByValue, int fromRowNumber) { int i = fromRowNumber; while (i <= CurrentReportBounds.Bottom) { int j = CurrentReportBounds.Left; while (j <= CurrentReportBounds.Right) { string cellText = Document.GetCellValueAsString(i, j); if (HasRepeaterDefinition(cellText)) { if (HasVertRepeaterDefined(cellText)) { int startIndex = cellText.IndexOf("<vertrepeat"); int endIndex = cellText.IndexOf("/>", startIndex); string frequency = GetVertRepeatFrequency(cellText); RepeatMode repeatMode = GetVertRepeatMode(cellText); Bounds vertRepeatbounds = GetVertRepeaterBounds(cellText /*, out frequency, out repeatMode*/); cellText = cellText.Remove(startIndex, endIndex - startIndex).Insert(startIndex, "<vertrepeat " + "top=" + (vertRepeatbounds.Top + increaseByValue). ToString() + " , " + "bottom=" + (vertRepeatbounds. Bottom + increaseByValue). ToString() + " , " + "left=" + vertRepeatbounds.Left. ToString() + " , " + "right=" + vertRepeatbounds.Right. ToString() + " , " + "frequency=" + frequency.ToString() + " , " + "mode=" + repeatMode.ToString()); Document.SetCellValue(i, j, cellText); } if (HasHorizRepeaterDefined(cellText)) { int startIndex = cellText.IndexOf("<horizrepeat"); int endIndex = cellText.IndexOf("/>", startIndex); string frequency = GetHorizRepeatFrequency(cellText); RepeatMode repeatMode = GetHorizRepeatMode(cellText); Bounds vertRepeatbounds = GetHorizRepeaterBounds(cellText /*, out frequency, out repeatMode*/); cellText = cellText.Remove(startIndex, endIndex - startIndex).Insert(startIndex, "<horizrepeat " + "top=" + (vertRepeatbounds.Top + increaseByValue). ToString() + " , " + "bottom=" + (vertRepeatbounds. Bottom + increaseByValue). ToString() + " , " + "left=" + vertRepeatbounds.Left. ToString() + " , " + "right=" + vertRepeatbounds.Right. ToString() + " , " + "frequency=" + frequency.ToString() + " , " + "mode=" + repeatMode.ToString()); Document.SetCellValue(i, j, cellText); } } j++; } i++; j = CurrentReportBounds.Left; } }
//Increase the top and bottom values of the sub repeaters that might have been replicated private void IncreaseChildReapeterRowBy(int increaseByValue, int row, int col, Bounds parentRepeaterBounds) { string cellText = Document.GetCellValueAsString(row, col); if (HasRepeaterDefinition(cellText)) { if (HasVertRepeaterDefined(cellText)) { int startIndex = cellText.IndexOf("<vertrepeat"); int endIndex = cellText.IndexOf("/>", startIndex); string frequency = GetVertRepeatFrequency(cellText); RepeatMode repeatMode = GetVertRepeatMode(cellText); Bounds vertRepeatbounds = GetVertRepeaterBounds(cellText /*, out frequency, out repeatMode*/); //if any side is within the parent than make sure that it is completly within it. if ((vertRepeatbounds.Left >= parentRepeaterBounds.Left && vertRepeatbounds.Left <= parentRepeaterBounds.Right) || (vertRepeatbounds.Right <= parentRepeaterBounds.Right && vertRepeatbounds.Right >= parentRepeaterBounds.Left) || (vertRepeatbounds.Bottom <= parentRepeaterBounds.Bottom && vertRepeatbounds.Bottom >= parentRepeaterBounds.Top) || (vertRepeatbounds.Top <= parentRepeaterBounds.Bottom && vertRepeatbounds.Top >= parentRepeaterBounds.Top)) { if (vertRepeatbounds.Top >= parentRepeaterBounds.Top && vertRepeatbounds.Bottom <= parentRepeaterBounds.Bottom && vertRepeatbounds.Left >= parentRepeaterBounds.Left && vertRepeatbounds.Right <= parentRepeaterBounds.Right) { //Its ok do nothing } else { throw new Exception( "A child repeater cannot define boundaries which are out side the parent boundaries"); } } cellText = cellText.Remove(startIndex, endIndex - startIndex).Insert(startIndex, "<vertrepeat " + "top=" + (vertRepeatbounds.Top + increaseByValue).ToString() + " , " + "bottom=" + (vertRepeatbounds.Bottom + increaseByValue).ToString() + " , " + "left=" + (vertRepeatbounds.Left).ToString() + " , " + "right=" + (vertRepeatbounds.Right).ToString() + " , " + "frequency=" + frequency.ToString()) + " , " + "mode=" + repeatMode.ToString(); Document.SetCellValue(row, col, cellText); } if (HasHorizRepeaterDefined(cellText)) { int startIndex = cellText.IndexOf("<horizrepeat"); int endIndex = cellText.IndexOf("/>", startIndex); string frequency = GetHorizRepeatFrequency(cellText); RepeatMode repeatMode = GetHorizRepeatMode(cellText); Bounds horizRepeaterBounds = GetHorizRepeaterBounds(cellText /*, out frequency, out repeatMode*/); //if any side is within the parent than make sure that it is completly within it. if ((horizRepeaterBounds.Left >= parentRepeaterBounds.Left && horizRepeaterBounds.Left <= parentRepeaterBounds.Right) || (horizRepeaterBounds.Right <= parentRepeaterBounds.Right && horizRepeaterBounds.Right >= parentRepeaterBounds.Left) || (horizRepeaterBounds.Bottom <= parentRepeaterBounds.Bottom && horizRepeaterBounds.Bottom >= parentRepeaterBounds.Top) || (horizRepeaterBounds.Top <= parentRepeaterBounds.Bottom && horizRepeaterBounds.Top >= parentRepeaterBounds.Top)) { if (horizRepeaterBounds.Top >= parentRepeaterBounds.Top && horizRepeaterBounds.Bottom <= parentRepeaterBounds.Bottom && horizRepeaterBounds.Left >= parentRepeaterBounds.Left && horizRepeaterBounds.Right <= parentRepeaterBounds.Right) { //Its ok do nothing } else { throw new Exception( "A child repeater cannot define boundaries which are out side the parent boundaries"); } } cellText = cellText.Remove(startIndex, endIndex - startIndex).Insert(startIndex, "<horizrepeat " + "top=" + (horizRepeaterBounds.Top + increaseByValue).ToString() + " , " + "bottom=" + (horizRepeaterBounds.Bottom + increaseByValue).ToString() + " , " + "left=" + (horizRepeaterBounds.Left).ToString() + " , " + "right=" + (horizRepeaterBounds.Right).ToString() + " , " + "frequency=" + frequency.ToString()) + " , " + "mode=" + repeatMode.ToString(); Document.SetCellValue(row, col, cellText); } } }
/// <summary> /// Converts the given <see cref="RepeatMode"/> to string. /// </summary> /// <param name="mode"><see cref="RepeatMode"/> to convert.</param> /// <returns>Converted string or <see cref="null"/> if the conversion fails.</returns> public string ToString(RepeatMode mode) => mode != RepeatMode.Unknown ? mode.ToString().ToLowerInvariant() : null;