public override Cell[] GetCellArray( InstanceReport report )
        {
            Cell[] values = new Cell[ report.Rows.Count ];

            for( int r = 0; r < values.Length; r++ )
            {
                values[ r ] = report.Rows[ r ].Cells.Find( ( c ) => c.Id == this.Id );
            }

            return values;
        }
        public void TestRowLevelPromotions_4()
        {
            InstanceReport thisReport = new InstanceReport();

            //[1]    [2]     [1],[2]     NULL   [3],[4]    --> NOTHING promoted
            InstanceReportRow thisRow = new InstanceReportRow();
            thisRow.Label = "Row 1";
            thisRow.Id = 1;

            Cell c0 = new Cell(0);
            c0.IsNumeric = true;
            c0.FootnoteIndexer = "[1]";
            thisRow.Cells.Add(c0);

            Cell c1 = new Cell(1);
            c1.IsNumeric = true;
            c1.FootnoteIndexer = "[2]";
            thisRow.Cells.Add(c1);

            Cell c2 = new Cell(2);
            c2.IsNumeric = true;
            c2.FootnoteIndexer = "[1],[2]";
            thisRow.Cells.Add(c2);

            Cell c3 = new Cell(3);
            c3.IsNumeric = false;
            thisRow.Cells.Add(c3);

            Cell c4 = new Cell(4);
            c4.IsNumeric = true;
            c4.FootnoteIndexer = "[3],[4]";
            thisRow.Cells.Add(c4);

            thisReport.Rows.Add(thisRow);
            thisReport.PromoteFootnotes();

            Console.WriteLine("Row level index = " + thisRow.FootnoteIndexer);
            foreach (Cell c in thisRow.Cells)
            {
                Console.WriteLine(c.Id + " Cell level index = " + c.FootnoteIndexer);
            }

            Assert.IsTrue(thisRow.FootnoteIndexer == "");
            Assert.IsTrue((thisRow.Cells[0] as Cell).FootnoteIndexer == "[1]");
            Assert.IsTrue((thisRow.Cells[1] as Cell).FootnoteIndexer == "[2]");
            Assert.IsTrue((thisRow.Cells[2] as Cell).FootnoteIndexer == "[1],[2]");
            Assert.IsTrue((thisRow.Cells[3] as Cell).FootnoteIndexer == "");
            Assert.IsTrue((thisRow.Cells[4] as Cell).FootnoteIndexer == "[3],[4]");
        }
        public void TestRowLevelPromotions_1()
        {
            InstanceReport thisReport = new InstanceReport();

            //[1], [1], [1], [1], NULL --> [1] promoted
            InstanceReportRow thisRow = new InstanceReportRow();
            thisRow.Label = "Row 1";
            thisRow.Id = 1;
            for (int index = 0; index <= 3; index++)
            {
                Cell c = new Cell(index);
                c.IsNumeric = true;
                c.NumericAmount = 100;
                c.FootnoteIndexer = "[1]";
                thisRow.Cells.Add(c);
            }
            Cell c4 = new Cell(4);
            c4.IsNumeric = false;
            thisRow.Cells.Add(c4);

            thisReport.Rows.Add(thisRow);
            thisReport.PromoteFootnotes();

            Console.WriteLine ("Row level index = " + thisRow.FootnoteIndexer);
            foreach (Cell c in thisRow.Cells)
            {
                Console.WriteLine(c.Id + " Cell level index = " + c.FootnoteIndexer);
            }

            Assert.IsTrue(thisRow.FootnoteIndexer == "[1]");
            for (int index = 0; index <= 3; index++)
            {
                Cell c1 = thisRow.Cells[index] as Cell;
                Assert.IsTrue(String.IsNullOrEmpty(c1.FootnoteIndexer));

            }
        }
        public void TestColumnLevelPromotions_3()
        {
            InstanceReport thisReport = new InstanceReport();
            InstanceReportColumn irc1 = new InstanceReportColumn();
            InstanceReportColumn irc2 = new InstanceReportColumn();

            //c0: [1],[2]    [1],[2]    [1],[2]    [1],[2],[3]     [1],[2] --> [1],[2]
            //c1: [4], [5], [6], [7], [8] --> NULL
            irc1.Id = 1;
            thisReport.Columns.Add(irc1);
            irc2.Id = 2;
            thisReport.Columns.Add(irc2);

            for (int index = 0; index <= 4; index++)
            {
                InstanceReportRow irr = new InstanceReportRow();
                irr.Id = index + 1;
                Cell c1 = new Cell(1);
                irr.Cells.Add(c1);
                Cell c2 = new Cell(2);
                irr.Cells.Add(c2);
                thisReport.Rows.Add(irr);
            }
            (thisReport.Rows[0].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[0].Cells[0] as Cell).FootnoteIndexer = "[1],[2]";
            (thisReport.Rows[1].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[1].Cells[0] as Cell).FootnoteIndexer = "[1],[2]";
            (thisReport.Rows[2].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[2].Cells[0] as Cell).FootnoteIndexer = "[1],[2]";
            (thisReport.Rows[3].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[3].Cells[0] as Cell).FootnoteIndexer = "[1],[2],[3]";
            (thisReport.Rows[4].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[4].Cells[0] as Cell).FootnoteIndexer = "[1],[2]";

            (thisReport.Rows[0].Cells[1] as Cell).IsNumeric = true;
            (thisReport.Rows[0].Cells[1] as Cell).FootnoteIndexer = "[4]";
            (thisReport.Rows[1].Cells[1] as Cell).IsNumeric = true;
            (thisReport.Rows[1].Cells[1] as Cell).FootnoteIndexer = "[5]";
            (thisReport.Rows[2].Cells[1] as Cell).IsNumeric = true;
            (thisReport.Rows[2].Cells[1] as Cell).FootnoteIndexer = "[6]";
            (thisReport.Rows[3].Cells[1] as Cell).IsNumeric = true;
            (thisReport.Rows[3].Cells[1] as Cell).FootnoteIndexer = "[7]";
            (thisReport.Rows[4].Cells[1] as Cell).IsNumeric = true;
            (thisReport.Rows[4].Cells[1] as Cell).FootnoteIndexer = "[8]";

            thisReport.PromoteFootnotes();

            Console.WriteLine("Column 1 level index = " + irc1.FootnoteIndexer);
            Console.WriteLine("Column 2 level index = " + irc2.FootnoteIndexer);
            foreach (InstanceReportRow irr in thisReport.Rows)
            {
                Cell c1 = irr.Cells[0] as Cell;
                Console.WriteLine(c1.Id + " Cell level index = " + c1.FootnoteIndexer);
                Cell c2 = irr.Cells[1] as Cell;
                Console.WriteLine(c2.Id + " Cell level index = " + c2.FootnoteIndexer);
            }

            Assert.IsTrue(irc1.FootnoteIndexer == "[1],[2]");
            Assert.IsTrue(irc2.FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[0].Cells[0] as Cell).FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[1].Cells[0] as Cell).FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[2].Cells[0] as Cell).FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[3].Cells[0] as Cell).FootnoteIndexer == "[3]");
            Assert.IsTrue((thisReport.Rows[4].Cells[0] as Cell).FootnoteIndexer == "");

            Assert.IsTrue((thisReport.Rows[0].Cells[1] as Cell).FootnoteIndexer == "[4]");
            Assert.IsTrue((thisReport.Rows[1].Cells[1] as Cell).FootnoteIndexer == "[5]");
            Assert.IsTrue((thisReport.Rows[2].Cells[1] as Cell).FootnoteIndexer == "[6]");
            Assert.IsTrue((thisReport.Rows[3].Cells[1] as Cell).FootnoteIndexer == "[7]");
            Assert.IsTrue((thisReport.Rows[4].Cells[1] as Cell).FootnoteIndexer == "[8]");
        }
 public abstract void ReplaceCell( InstanceReport report, int cellIndex, Cell cell );
 /// <summary>
 /// Replace a cell at a specific location within the <see
 /// cref="InstanceReportRow"/>.
 /// </summary>
 /// <param name="report">Unused.</param>
 /// <param name="cellIndex">The index at which to perform the cell
 /// replacement.</param>
 /// <param name="cell">The new cell.</param>
 public override void ReplaceCell( InstanceReport report, int cellIndex, Cell cell )
 {
     this.Cells.RemoveAt( cellIndex );
     this.Cells.Insert( cellIndex, cell );
 }
Beispiel #7
0
        /// <summary>
        /// Checks <paramref name="report"/>.AxisMembersByPresentation for the segments used by <paramref name="c"/>.Markup
        /// </summary>
        /// <param name="report">The <see cref="InstanceReport"/> providing the axis members.</param>
        /// <param name="c">The cell to check (and thus c.Markup)</param>
        /// <returns>True on success, false on fail.</returns>
        private bool CellExistsInPresentation( InstanceReport report, Cell c )
        {
            foreach( Segment cellSegment in c.Markup.contextRef.Segments )
            {
                List<Segment> members;
                if( !report.AxisMembersByPresentation.TryGetValue( cellSegment.DimensionInfo.dimensionId, out members ) )
                {
                    //this member is not in the presentation, therefore this column should not be on this report.
                    return false;
                }

                bool found = false;
                foreach( Segment reportSegment in members )
                {
                    if( string.Equals( cellSegment.DimensionInfo.Id, reportSegment.DimensionInfo.Id ) )
                    {
                        cellSegment.ValueName = reportSegment.ValueName;
                        found = true;
                        break;
                    }
                }

                if( !found )
                {
                    Element el = this.currentTaxonomy.AllElements[ cellSegment.DimensionInfo.Id ] as Element;
                    if( el != null )
                    {
                        bool wasIdDifferent = !string.Equals( cellSegment.DimensionInfo.Id, el.Id );
                        bool isTaxonomyIdSame = string.Equals( cellSegment.DimensionInfo.Id, el.GetNameWithNamespacePrefix() );
                        if( isTaxonomyIdSame && wasIdDifferent )
                        {
                            cellSegment.DimensionInfo.Id = el.Id;
                            found = true;
                        }
                    }
                }

                if( !found )
                    return false;
            }

            return true;
        }
        private void InitializeTestInstanceReportCommonSegment()
        {
            this.Columns.Clear();
            this.Rows.Clear();

            Segment sharedSegment = new Segment("SharedSeg", "Shared Segment", "Shared Segment Value");
            sharedSegment.DimensionInfo = new ContextDimensionInfo();
            sharedSegment.DimensionInfo.Id = "SharedSegmentAxis";
            sharedSegment.DimensionInfo.dimensionId = "SharedSegmentMember";

            //Add reporting periods to columns for testing MergeInstanceAndDuration
            InstanceReportColumn irc = new InstanceReportColumn();
            ContextProperty cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            cp.Segments.Add(sharedSegment);
            LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            cp.Segments.Add(sharedSegment);
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu2", cp);
            cp.Segments.Add(sharedSegment);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu3", cp);
            cp.Segments.Add(sharedSegment);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(sharedSegment);
            irc.MCU = new MergedContextUnitsWrapper("mcu4", cp);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(sharedSegment);
            irc.MCU = new MergedContextUnitsWrapper("mcu5", cp);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            cp.Segments.Add(sharedSegment);
            irc.Labels.Add(new LabelLine(1, "Segment One"));
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(sharedSegment);
            irc.MCU = new MergedContextUnitsWrapper("mcu6", cp);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            cp.Segments.Add(sharedSegment);
            irc.Labels.Add(new LabelLine(2, "Segment Two"));
            this.Columns.Add(irc);

            InstanceReportRow irr = new InstanceReportRow("Test Elem", 7);
            irr.ElementName = "Test Elem";
            for (int i = 0; i < 7; i++)
            {
                Cell cell = new Cell();
                cell.NumericAmount = (decimal)((i + 1) * 10.0);
                irr.Cells.Add(cell);
            }
            this.Rows.Add(irr);
        }
        public bool ValueEquals( Cell rc, ref List<string> diffs )
        {
            bool ret = true;

            if( this.DisplayZeroAsNone != rc.DisplayZeroAsNone )
            {
                ret = false;

                if( diffs != null )
                    diffs.Add( "DisplayZeroAsNone" );
                else
                    return ret;
            }

            if( this.FootnoteIndexer != rc.FootnoteIndexer )
            {
                ret = false;

                if( diffs != null )
                    diffs.Add( "FootnoteIndexer" );
                else
                    return ret;
            }

            if( this.IsNumeric != rc.IsNumeric )
            {
                ret = false;

                if( diffs != null )
                    diffs.Add( "IsNumeric" );
                else
                    return ret;
            }

            if( this.IsRatio != rc.IsRatio )
            {
                ret = false;

                if( diffs != null )
                    diffs.Add( "IsRatio" );
                else
                    return ret;
            }

            if( this.NonNumbericText != rc.NonNumbericText )
            {
                ret = false;

                if( diffs != null )
                    diffs.Add( "NonNumbericText" );
                else
                    return ret;
            }

            if( this.NumericAmount != rc.NumericAmount )
            {
                ret = false;

                if( diffs != null )
                    diffs.Add( "NumericAmount" );
                else
                    return ret;
            }

            if( this.RoundedNumericAmount != rc.RoundedNumericAmount )
            {
                ret = false;

                if( diffs != null )
                    diffs.Add( "RoundedNumericAmount" );
                else
                    return ret;
            }

            if( this.ShowCurrencySymbol != rc.ShowCurrencySymbol )
            {
                ret = false;

                if( diffs != null )
                    diffs.Add( "ShowCurrencySymbol" );
                else
                    return ret;
            }

            if( this.IsIndependantCurrency != rc.IsIndependantCurrency )
            {
                if( this.ShowCurrencySymbol != rc.ShowCurrencySymbol )
                {
                    ret = false;

                    if( diffs != null )
                        diffs.Add( "IsIndependantCurrency" );
                    else
                        return ret;
                }
            }

            if( this.DisplayDateInUSFormat != rc.DisplayDateInUSFormat && !this.IsNumeric )
            {
                if( !( this.IsNil || string.IsNullOrEmpty( this.NonNumbericText ) ) )
                {
                    ret = false;

                    if( diffs != null )
                        diffs.Add( "DisplayDateInUSFormat" );
                    else
                        return ret;
                }
            }

            if( rc.ShowCurrencySymbol )
            {
                if( this.CurrencyCode != rc.CurrencyCode )
                {
                    ret = false;

                    if( diffs != null )
                        diffs.Add( "CurrencyCode" );
                    else
                        return ret;
                }

                if( this.CurrencySymbol != rc.CurrencySymbol )
                {
                    ret = false;

                    if( diffs != null )
                        diffs.Add( "CurrencySymbol" );
                    else
                        return ret;
                }
            }

            return ret;
        }
Beispiel #10
0
        private void SetValues( Cell rc )
        {
            this.ContextID = rc.ContextID;
            this.UnitID = rc.UnitID;

            this.DisplayDateInUSFormat = rc.DisplayDateInUSFormat;
            this.DisplayZeroAsNone = rc.DisplayZeroAsNone;

            this.FootnoteIndexer = rc.FootnoteIndexer;

            this.IsNumeric = rc.IsNumeric;
            this.IsRatio = rc.IsRatio;

            this.NonNumbericText = rc.NonNumbericText;
            this.NumericAmount = rc.NumericAmount;

            this.RoundedNumericAmount = rc.RoundedNumericAmount;
            this.ShowCurrencySymbol = rc.ShowCurrencySymbol;

            if( EmbedReport.HasMatch( rc.NonNumbericText ) )
                this.EmbeddedReport = EmbedReport.LoadAndParse( rc.NonNumbericText );
        }
Beispiel #11
0
 public bool ValueEquals( Cell rc )
 {
     List<string> diffs = null;
     return ValueEquals( rc, ref diffs );
 }
Beispiel #12
0
        public void AddData( Cell rc )
        {
            if( rc == null )
                return;

            // if we don't already have data, it's ok to add it
            //if( !this.HasData )
                this.SetValues( rc );
        }
Beispiel #13
0
 public static bool IsEmbedded( Cell cell )
 {
     return cell.HasEmbeddedReport;
 }
Beispiel #14
0
        private void InitializeTestEquityReport()
        {
            this.Columns.Clear();
            this.Rows.Clear();

            //Add reporting periods to columns for testing MergeInstanceAndDuration
            InstanceReportColumn irc = new InstanceReportColumn();
            irc.Id = 0;
            ContextProperty cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            cp.Segments.Add(new Segment("Segment 1", "Shared One", "Segment One Value"));
            LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 1;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            cp.Segments.Add(new Segment("Segment 1", "Shared One", "Segment One Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 2;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            cp.Segments.Add(new Segment("Segment 2", "Shared Two", "Segment Two Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 3;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            cp.Segments.Add(new Segment("Segment 2", "Shared Two", "Segment Two Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 4;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            cp.Segments.Add(new Segment("Segment 3", "Shared Three", "Segment Three Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 5;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            cp.Segments.Add(new Segment("Segment 3", "Shared Three", "Segment Three Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            for (int i = 0; i < 4; i++)
            {
                InstanceReportRow irr = new InstanceReportRow("Test Elem", 6);
                irr.ElementName = "Test Elem";
                irr.IsBeginningBalance = (i == 0);

                for (int j = 0; j < 6; j++)
                {
                    Cell cell = new Cell();
                    cell.Id = j;
                    cell.NumericAmount = (decimal)((j + 1) * 10.0);
                    irr.Cells.Add(cell);
                }
                this.Rows.Add(irr);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Loads data from this.<see cref="currentInstance"/> into dictionaries which will be used across all reports. See this.<see cref="ClearMarkupDictionaries"/>.  
        /// </summary>
        private void PopulateMarkupDictionaries()
        {
            //globals
            this.dar = new DefinitionAndReference();
            this.markupCache = new Dictionary<string, List<Cell>>();
            this.internalReports = new Dictionary<string, int>( StringComparer.CurrentCultureIgnoreCase );

            Dictionary<string,InstanceReportRow> localRowCache = new Dictionary<string, InstanceReportRow>();
            Dictionary<string, Dictionary<UnitType, int>> predominantElementTypes = new Dictionary<string, Dictionary<UnitType, int>>();
            foreach( MarkupProperty mp in this.currentInstance.markups )
            {
                if( mp.unitRef != null )
                {
                    switch( mp.unitRef.UnitType )
                    {
                        case UnitProperty.UnitTypeCode.Standard:
                            mp.unitRef.DenominatorMeasure = null;
                            mp.unitRef.MultiplyMeasures = null;
                            mp.unitRef.NumeratorMeasure = null;
                            break;
                        case UnitProperty.UnitTypeCode.Multiply:
                            mp.unitRef.DenominatorMeasure = null;
                            mp.unitRef.NumeratorMeasure = null;
                            mp.unitRef.StandardMeasure = null;
                            break;
                        case UnitProperty.UnitTypeCode.Divide:
                            mp.unitRef.MultiplyMeasures = null;
                            mp.unitRef.StandardMeasure = null;
                            break;
                    }
                }

                this.customUnits = new Dictionary<string, int>();
                this.unitDictionary = new Dictionary<int, string>();
                this.unitDictionary[ (int)UnitType.Other ] = "Other";
                this.unitDictionary[ (int)UnitType.Shares ] = "EPS";
                this.unitDictionary[ (int)UnitType.Monetary ] = "Monetary";
                this.unitDictionary[ (int)UnitType.EPS ] = "EPS";
                this.unitDictionary[ (int)UnitType.ExchangeRate ] = "ExchangeRate";

                this.CountUnitType( predominantElementTypes, mp );

                InstanceReportRow row = null;
                Element element = this.currentTaxonomy.AllElements[ mp.elementId ] as Element;
                if( !localRowCache.TryGetValue( mp.elementId, out row ) )
                {
                    this.markupCache[ mp.elementId ] = new List<Cell>();

                    row = new InstanceReportRow();
                    if( element != null )
                    {
                        row.ElementDataType = element.OrigElementType;
                        row.SimpleDataType = element.MyDataType.ToString().ToLower();
                        localRowCache[ mp.elementId ] = row;

                        string def = element.GetDefinition( this.preferredLanguage );
                        if( string.IsNullOrEmpty( def ) )
                        {
                            def = this.GetDocumentationInformation( mp.elementId, this.preferredLanguage );

                            if( string.IsNullOrEmpty( def ) )
                                def = InstanceUtils._noAuthRefAvailable;
                        }

                        string @ref = null;
                        if( !element.TryGetReferences( out @ref ) || string.IsNullOrEmpty( @ref ) )
                        {
                            @ref = this.GetReferenceInformation( mp.elementId );

                            if( string.IsNullOrEmpty( @ref ) )
                                @ref = InstanceUtils._noDefAvailable;
                        }

                        this.dar.Add( element.Id, def, @ref );
                    }
                    else
                    {
                        row.SimpleDataType = "na";
                    }
                }

                //populate this.markupCache
                Cell cell = new Cell( mp );
                if( row != null )
                {
                    if( row.IsNumericDataType )
                    {
                        if( decimal.TryParse( cell.NonNumbericText, out cell.NumericAmount ) )
                        {
                            cell.IsNumeric = true;
                            cell.NonNumbericText = string.Empty;
                        }
                    }
                    else if( element != null )
                    {
                        string newValue;

                        if( this.TryGetW3CDuration( element, cell.NonNumbericText, out newValue ) )
                        {
                            cell.NonNumbericText = newValue;
                        }
                        else if( cell.NonNumbericText.Contains( "~" ) && EmbedReport.ROLE_COMMAND_SPLITTER.IsMatch( cell.NonNumbericText ) )
                        {
                            if( EmbedReport.HasMatch( cell.NonNumbericText ) )
                            {
                                string embedWarning = string.Empty;
                                cell.EmbeddedReport = EmbedReport.LoadAndParse( cell.NonNumbericText, out embedWarning );

                                if( !string.IsNullOrEmpty( embedWarning ) )
                                    this.WriteEmbedWarning( row, element, cell, embedWarning );

                                if( !this.internalReports.ContainsKey( cell.EmbeddedReport.Role ) )
                                    this.internalReports[ cell.EmbeddedReport.Role ] = 0;

                                this.internalReports[ cell.EmbeddedReport.Role ]++;
                            }
                            else
                            {
                                const string INCORRECT_FORMAT_WARNING = @"Warning: Incorrectly formatted embedding in Element ""[Unknown Element]"" with UnitID ""[Unknown UnitID]"" and contextID ""[Unknown ContextID]"".";
                                this.WriteEmbedWarning( row, element, cell, INCORRECT_FORMAT_WARNING );
                            }
                        }
                    }
                }

                this.markupCache[ mp.elementId ].Add( cell );
            }

            //now that we have collected all of the types an element is used like,
            //take the most used type and remember it
            this.elementUnitTypes = new Dictionary<string, UnitType>();
            foreach( string elementID in predominantElementTypes.Keys )
            {
                int lastCount = 0;
                foreach( KeyValuePair<UnitType, int> unitType in predominantElementTypes[ elementID ] )
                {
                    if( lastCount < unitType.Value )
                    {
                        lastCount = unitType.Value;
                        this.elementUnitTypes[ elementID ] = unitType.Key;
                    }
                }
            }

            //populate this.elementRounding
            this.elementRounding = new Dictionary<string, Dictionary<string, Precision>>();
            foreach( KeyValuePair<string, List<Cell>> markups in this.markupCache )
            {
                bool hasSegments;
                int previousPrecision = int.MinValue;
                int previousPrecisionSegmented = int.MinValue;
                this.elementRounding[ markups.Key ] = new Dictionary<string, Precision>();

                Dictionary<int, int> uniqueDecimalValues = new Dictionary<int, int>();
                foreach( Cell cell in markups.Value )
                {
                    Precision p = InstanceUtils.WritePrecision( cell.Markup, ref previousPrecision, ref previousPrecisionSegmented, out hasSegments );
                    if( p != null )
                    {
                        uniqueDecimalValues[ p.NumberOfDigits ] = 1;
                        if( hasSegments )
                            this.elementRounding[ cell.Markup.elementId ][ InstanceUtils._PrecisionSegmented ] = p;
                        else
                            this.elementRounding[ cell.Markup.elementId ][ InstanceUtils._Precision ] = p;
                    }
                }

                if( uniqueDecimalValues.Count > 1 )
                {
                    List<int> tmpDecimalValues = new List<int>( uniqueDecimalValues.Keys );
                    tmpDecimalValues.Sort();
                    tmpDecimalValues.Reverse();

                    string[] tmpStrings = new string[ tmpDecimalValues.Count ];
                    for( int s = 0; s < tmpStrings.Length; s++ )
                    {
                        tmpStrings[ s ] = tmpDecimalValues[ s ].ToString();
                    }

                    Array.Reverse( tmpStrings );
                    string decimalAttributeValues = string.Join( " ", tmpStrings );
                    string info = string.Format( "Element {0} had a mix of decimals attribute values: {1}.", markups.Key, decimalAttributeValues );
                    this.currentFilingSummary.TraceInformation( info );
                }
            }

            //Common dimensions
            this.commonAxes = new List<string>();
            this.commonDimensions = new Dictionary<string,List<Segment>>();

            List<DimensionNode> dimensionNodes = null;
            string labelRole = string.IsNullOrEmpty( this.currentTaxonomy.CurrentLabelRole ) ? "preferredLabel" : currentTaxonomy.CurrentLabelRole;
            if( currentTaxonomy.TryGetCommonDimensionNodesForDisplay( currentTaxonomy.CurrentLanguage, labelRole, true, out dimensionNodes ) )
            {
                ArrayList topNodes = this.currentTaxonomy.GetNodesByPresentation( false, this.ExcludedReports );

                foreach( DimensionNode dNode in dimensionNodes )
                {
                    Node pNode = null;
                    foreach( Node topNode in topNodes )
                    {
                        if( string.Equals( topNode.MyPresentationLink.Role, dNode.MyDefinitionLink.Role ) )
                        {
                            pNode = topNode;
                            break;
                        }
                    }

                    if( pNode != null )
                        ReportBuilder.GetDimensions( this.currentTaxonomy, pNode, null, ref this.commonAxes, ref this.commonDimensions );
                    else
                        this.PopulateCommonDimensions( dNode );
                }
            }
        }
Beispiel #16
0
        private void InitializeTestInstanceReport()
        {
            this.Columns.Clear();
            this.Rows.Clear();

            //Add reporting periods to columns for testing MergeInstanceAndDuration
            InstanceReportColumn irc = new InstanceReportColumn();
            ContextProperty cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()), "Calendar");
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            ll = new LabelLine( 0, string.Format( "{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString() ), "Calendar" );
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu2", cp);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString(), "Calendar");
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu3", cp);
            ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" );
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu4", cp);
            ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" );
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(new Segment("Segment1", "Segment One", "Value1"));
            irc.MCU = new MergedContextUnitsWrapper("mcu5", cp);
            ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" );
            irc.Labels.Add(ll);
            irc.Labels.Add(new LabelLine(1, "Segment One"));
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(new Segment("Segment2", "Segment Two", "Value2"));
            irc.MCU = new MergedContextUnitsWrapper("mcu6", cp);
            ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" );
            irc.Labels.Add(ll);
            irc.Labels.Add(new LabelLine(2, "Segment Two"));
            this.Columns.Add(irc);

            InstanceReportRow irr = new InstanceReportRow("Test Elem", 0);
            irr.ElementName = "Test Elem";
            for (int i = 0; i < 7; i++)
            {
                Cell cell = new Cell();

                if( i < 2 || 4 < i )
                {
                    cell.IsNumeric = true;
                    cell.NumericAmount = (decimal)( ( i + 1 ) * 10.0 );
                }

                irr.Cells.Add(cell);
            }
            this.Rows.Add( irr );

            irr = new InstanceReportRow( "Test Elem2", 0 );
            irr.ElementName = "Test Elem2";
            for( int i = 0; i < 7; i++ )
            {
                Cell cell = new Cell();

                if( 1 < i && i < 5 )
                {
                    cell.IsNumeric = true;
                    cell.NumericAmount = (decimal)( ( i + 1 ) * 10.0 );
                }

                irr.Cells.Add( cell );
            }

            this.Rows.Add(irr);
        }
Beispiel #17
0
        /// <summary>
        /// <para>Writes the <paramref name="embedWarning"/> to the this.<see cref="currentFilingSummary"/>, exchanging templated tokens for their actual values.</para>
        /// <para><paramref name="embedWarning"/> is expected to be in a templated format.</para>
        /// </summary>
        /// <param name="row">Provides the element's PreferredLabelRole.</param>
        /// <param name="element">A taxonomy <see cref="Element"/> allowing us to look up its labels.</param>
        /// <param name="cell">A <see cref="Cell" /> object which provides the context and unit IDs.</param>
        /// <param name="embedWarning">The warning to rewrite.</param>
        /// <returns>The warning with substitution tokens replaced.</returns>
        private string WriteEmbedWarning( InstanceReportRow row, Element element, Cell cell, string embedWarning )
        {
            string labelForWarning = null;
            // Try preferred
            if( !string.IsNullOrEmpty( row.PreferredLabelRole ) )
            {
                element.TryGetLabel( this.preferredLanguage, row.PreferredLabelRole, out labelForWarning );
            }

            // If preferred not available, try default
            if( string.IsNullOrEmpty( labelForWarning ) )
            {
                element.TryGetLabel( this.preferredLanguage, "label", out labelForWarning );
            }

            // If default not available, fall back to element name
            if( string.IsNullOrEmpty( labelForWarning ) )
            {
                labelForWarning = element.Name;
            }

            // Specify warning scope and trace
            embedWarning = embedWarning.Replace( "[Unknown Element]", labelForWarning );
            // Unit refs are not required
            if( cell.Markup.unitRef != null )
            {
                embedWarning = embedWarning.Replace( "[Unknown UnitID]", cell.Markup.unitRef.UnitID );
            }
            else
            {
                embedWarning = embedWarning.Replace( "[Unknown UnitID]", "No UnitID Specified" );
            }
            embedWarning = embedWarning.Replace( "[Unknown ContextID]", cell.Markup.contextRef.ContextID );
            this.currentFilingSummary.TraceWarning( embedWarning );
            return embedWarning;
        }
Beispiel #18
0
        public void TestColumnLevelPromotions_1()
        {
            InstanceReport thisReport = new InstanceReport();
            InstanceReportColumn irc =  new InstanceReportColumn();

            //[1], [1], [1], [1], [1] --> nothing is promoted to column, should already be promoted to ROW
            irc.Id = 0;
            thisReport.Columns.Add(irc);

            for (int index = 0; index <= 4; index++)
            {
                InstanceReportRow irr = new InstanceReportRow();
                irr.Id = index;
                Cell c = new Cell(0);
                irr.Cells.Add(c);
                thisReport.Rows.Add(irr);
            }
            (thisReport.Rows[0].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[0].Cells[0] as Cell).FootnoteIndexer = "[1]";
            (thisReport.Rows[1].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[1].Cells[0] as Cell).FootnoteIndexer = "[1]";
            (thisReport.Rows[2].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[2].Cells[0] as Cell).FootnoteIndexer = "[1]";
            (thisReport.Rows[3].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[3].Cells[0] as Cell).FootnoteIndexer = "[1]";
            (thisReport.Rows[4].Cells[0] as Cell).IsNumeric = true;
            (thisReport.Rows[4].Cells[0] as Cell).FootnoteIndexer = "[1]";

            thisReport.PromoteFootnotes();

            Console.WriteLine("Column level index = " + irc.FootnoteIndexer);
            foreach (InstanceReportRow irr in thisReport.Rows)
            {
                Cell c = irr.Cells[0] as Cell;
                Console.WriteLine(c.Id + " Cell level index = " + c.FootnoteIndexer);
            }

            Assert.IsTrue(irc.FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[0].Cells[0] as Cell).FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[1].Cells[0] as Cell).FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[2].Cells[0] as Cell).FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[3].Cells[0] as Cell).FootnoteIndexer == "");
            Assert.IsTrue((thisReport.Rows[4].Cells[0] as Cell).FootnoteIndexer == "");
        }
Beispiel #19
0
        /// <summary>
        /// Fills in missing cells so that they align with their columns.  This method assumes all cells and columns have sequential IDs.
        /// </summary>
        /// <param name="report"></param>
        private static void FillMissingCells( InstanceReport report )
        {
            //now sort the cells and fill in the blanks
            foreach( InstanceReportRow row in report.Rows )
            {
                row.Cells.Sort( ( l, r ) => Comparer<int>.Default.Compare( l.Id, r.Id ) );

                //define this outside so we can continue the sequence
                int c;
                for( c = 0; c < row.Cells.Count; c++ )
                {
                    int actualID = row.Cells[ c ].Id;
                    int expectedID = c + 1;
                    for( int i = expectedID; i < actualID; i++ )
                    {
                        Cell blank = new Cell( i );
                        row.Cells.Insert( blank.Id - 1, blank );
                    }
                }

                //advance the pointer past our last cell
                c++;
                for( ; c <= report.Columns.Count; c++ )
                {
                    Cell blank = new Cell( c );
                    row.Cells.Insert( blank.Id - 1, blank );
                }

                Debug.Assert( row.Cells.Count == report.Columns.Count, "Why don't the cell and column counts match?" );
            }
        }
 public override void ReplaceCell( InstanceReport report, int rowIndex, Cell cell )
 {
     int cellIndex = report.Columns.IndexOf( this );
     report.Rows[ rowIndex ].Cells.RemoveAt( cellIndex );
     report.Rows[ rowIndex ].Cells.Insert( cellIndex, cell );
 }
        public bool ProcessSegments_Rule( BooleanWrapper processed )
        {
            //collect all of the segments to be permuted vertically
            List<InstanceReportColumn> uniqueSegmentColumns = this.GetSegmentScenarioColumnsForSegmentProcessing();
            //if( uniqueSegmentColumns.Count < 2 )
            //	return false;

            //collect all of the calendars to be retained horizontally
            Dictionary<int, List<InstanceReportColumn>> calendarsBySegment = this.GetSegmentScenarioCalendars( uniqueSegmentColumns );
            //if( uniqueSegmentColumns.Count < 2 )
            //	return false;

            //find the set of `allCalendars` which will hold all data without any adjustment
            List<InstanceReportColumn> allCalendars;
            bool doCalendarsOverlap = DoCalendarsOverlap( calendarsBySegment, out allCalendars );
            if( !doCalendarsOverlap )
                return false;

            List<Segment> commonSegmentsToPromote = GetCommonSegments( uniqueSegmentColumns );
            PromoteConsolidatedSegment( uniqueSegmentColumns, commonSegmentsToPromote );

            //set up a temporary holder for the rows - this helps with debugging
            InstanceReport segmentCandidate = new InstanceReport();
            segmentCandidate.Columns.AddRange( allCalendars );

            //The first row in every report is usually `IsReportTitle` - copy it to the temporary report
            InstanceReportRow reportTitleRow = this.FindCloneAndTruncate( row => row.IsReportTitle, allCalendars.Count );
            if( reportTitleRow != null )
            {
                reportTitleRow.Id = 0;
                segmentCandidate.Rows.Add( reportTitleRow );
            }

            //Now, for every `segmentSet`, rebuild the data vertically
            foreach( InstanceReportColumn segmentSet in uniqueSegmentColumns )
            {
                //If this segment set has segments, create an `IsSegmentTitle` row
                if( segmentSet.Segments != null && segmentSet.Segments.Count > 0 )
                {
                    string label = string.Empty;
                    foreach( Segment seg in segmentSet.Segments )
                    {
                        if( commonSegmentsToPromote != null && commonSegmentsToPromote.Count > 0 )
                        {
                            bool isCommon = ReportUtils.Exists( commonSegmentsToPromote, cSeg => cSeg.Equals( seg ) );
                            if( isCommon )
                                continue;
                        }

                        if( !string.IsNullOrEmpty( label ) )
                            label += " | ";

                        label += seg.ValueName;
                    }

                    if( !string.IsNullOrEmpty( label ) )
                    {
                        InstanceReportRow segmentRow = new InstanceReportRow( label, allCalendars.Count );
                        segmentRow.IsSegmentTitle = true;
                        segmentRow.Id = segmentCandidate.Rows.Count;
                        segmentRow.OriginalInstanceReportColumn = (InstanceReportColumn)segmentSet.Clone();

                        segmentCandidate.Rows.Add( segmentRow );
                    }
                }

                //`segmentSets` combined with `rows` provide our vertical (y) axis
                //for each row in the "base" report, we need to pull in the data
                InstanceReportRow lastAbstract = null;
                foreach( InstanceReportRow row in this.Rows )
                {
                    if( row.IsReportTitle )
                        continue;

                    //retain abstracts...
                    if( row.IsAbstractGroupTitle )
                    {
                        //...unless they're consecutive - retain the most recent one
                        if( lastAbstract != null )
                        {
                            int at = segmentCandidate.Rows.IndexOf( lastAbstract );
                            if( at == segmentCandidate.Rows.Count - 1 )
                                segmentCandidate.Rows.RemoveAt( at );
                        }

                        InstanceReportRow abstractRow = CloneAndTruncate( row, allCalendars.Count );
                        abstractRow.Id = segmentCandidate.Rows.Count;
                        segmentCandidate.Rows.Add( abstractRow );

                        lastAbstract = abstractRow;
                        continue;
                    }

                    //`calendars` provide our horizontal (x) axis
                    //`calendars` (x) combined with `segmentSets` & `rows` (y) allow us to look up the correct cell
                    bool hasData = false;
                    InstanceReportRow currentRow = new InstanceReportRow();
                    foreach( InstanceReportColumn calendar in allCalendars )
                    {
                        List<InstanceReportColumn> matches = this.GetMatchingColumns( calendar, segmentSet, row );

                        //apply exact match
                        InstanceReportColumn exactColumn = matches.Find( m => m.ReportingPeriodEquals( calendar ) );
                        if( exactColumn != null )
                        {
                            Cell exactCell = row.Cells.Find( c => c.Id == exactColumn.Id );
                            if( exactCell != null && exactCell.HasData )
                            {
                                hasData = true;
                                Cell newCell = (Cell)exactCell.Clone();
                                newCell.EmbeddedReport = exactCell.EmbeddedReport;

                                if( !string.IsNullOrEmpty( segmentSet.CurrencyCode ) )
                                {
                                    if( (int)row.Unit == (int)UnitType.Monetary ||
                                        (int)row.Unit == (int)UnitType.EPS )
                                    {
                                        newCell.CurrencyCode = segmentSet.CurrencyCode;
                                        newCell.CurrencySymbol = segmentSet.CurrencySymbol;
                                    }
                                }

                                currentRow.Cells.Add( newCell );
                                continue;
                            }
                        }

                        //apply similar matches
                        {
                            List<Cell> cells = matches.ConvertAll( col => row.Cells.Find( c => c.Id == col.Id ) );

                            //Now reduce our cells to those with values...
                            cells.RemoveAll( c => c == null || !c.HasData );

                            //...and non-duplicates
                            for( int c = 0; c < cells.Count; c++ )
                            {
                                Cell curCell = cells[ c ];
                                cells.RemoveAll( cell => cell.Id != curCell.Id && cell.NumericAmount == curCell.NumericAmount );
                            }

                            switch( cells.Count )
                            {
                                case 0:
                                    Cell emptyCell = new Cell();
                                    currentRow.Cells.Add( emptyCell );
                                    break;
                                case 1:
                                    hasData = true;
                                    Cell newCell = (Cell)cells[ 0 ].Clone();
                                    newCell.EmbeddedReport = cells[ 0 ].EmbeddedReport;

                                    if( !string.IsNullOrEmpty( segmentSet.CurrencyCode ) )
                                    {
                                        if( (int)row.Unit == (int)UnitType.Monetary ||
                                            (int)row.Unit == (int)UnitType.EPS )
                                        {
                                            newCell.CurrencyCode = segmentSet.CurrencyCode;
                                            newCell.CurrencySymbol = segmentSet.CurrencySymbol;
                                        }
                                    }

                                    currentRow.Cells.Add( newCell );
                                    break;
                                default:
                                    Debug.Assert( false, "Too many cells" );
                                    break;
                            }
                        }
                    }

                    //if we actually found data for this row, let's clone the original, and swap out the cells
                    if( hasData )
                    {
                        InstanceReportRow clonedRow = (InstanceReportRow)row.Clone( false, false );
                        clonedRow.Cells.AddRange( currentRow.Cells );
                        clonedRow.Id = segmentCandidate.Rows.Count;

                        segmentCandidate.Rows.Add( clonedRow );
                    }
                }

                //Same as above, don't preserve consecutive abstract rows
                if( lastAbstract != null )
                {
                    int at = segmentCandidate.Rows.IndexOf( lastAbstract );
                    if( at == segmentCandidate.Rows.Count - 1 )
                        segmentCandidate.Rows.RemoveAt( at );
                }
            }

            //now that the permutation is complete, apply the new rows and columns to the "base" report
            this.Columns.Clear();
            this.Columns.AddRange( segmentCandidate.Columns );

            this.Rows.Clear();
            this.Rows.AddRange( segmentCandidate.Rows );

            this.SynchronizeGrid();

            //this.InstantValues();

            processed.Value = true;
            return true;
        }