Inheritance: IDisposable, cIReportSection
        public cReportSection add(cReportSection c, String key, int index)
        {
            try
            {
                if (c == null)
                {
                    c = new cReportSection();
                }
                if (key == "")
                {
                    key = cReportGlobals.getNextKey().ToString();
                }
                else
                {
                    cReportGlobals.refreshNextKey(key);
                }

                key = cReportGlobals.getKey(key);

                if ((index != -1) && this.count() > 0)
                {
                    m_keys.Insert(index, key);
                }
                else
                {
                    m_keys.Add(key);
                }

                m_coll.Add(key, c);
                c.setCopyColl(m_copyColl);

                if (this.count() == 1)
                {
                    c.setTypeSection(m_mainTypeSection);
                }
                else
                {
                    c.setTypeSection(m_typeSection);
                }

                pRefreshIndex();

                c.setIndex(this.count()-1);
                c.setKey(key);

                return c;
            }
            catch
            {
                return null;
            }
        }
        private bool getRegionForControlAux(cIReportGroupSections rptSections, 
                                            float x, 
                                            float y, 
                                            out cReportSection rptSection, 
                                            bool isFreeCtrl) 
        {
            float y1 = 0;
            float y2 = 0;
            cReportSection rtnSec = null;

            rptSection = null;

            for (int _i = 0; _i < rptSections.count(); _i++) {
                
                cReportSection rptSec = rptSections.item(_i);
                cReportAspect w_aspect = rptSec.getAspect();

                y1 = w_aspect.getTop();
                y2 = w_aspect.getTop() + w_aspect.getHeight();

                if (isFreeCtrl) {
                    if (y1 <= y) {
                        rtnSec = rptSec;
                    }
                } 
                else {
                    if (y1 <= y && y2 >= y) { 
                        return true; 
                    }
                }
            }

            if (rtnSec != null) {
                rptSection = rtnSec;
                return true;
            }
            else {
                return false;
            }
        }
        private bool getRegionForControl(String sKeyPaintObj, out cReportSection rptSection, bool isFreeCtrl) 
        { 
            float x = 0;
            float y = 0;

            cReportAspect w_aspect = m_paint.getPaintObject(sKeyPaintObj).getAspect();
                
            // Headers
            //
            x = w_aspect.getLeft();
            if (isFreeCtrl) {
                y = w_aspect.getTop();
            } 
            else {
                y = w_aspect.getTop() + w_aspect.getHeight() / 2;
            }

            if (getRegionForControlAux(m_report.getHeaders(), x, y, out rptSection, isFreeCtrl)) {
                w_aspect.setOffset(0);
                return true;
            }

            // Groups Headers
            //
            if (getRegionForControlAux(m_report.getGroupsHeaders(), x, y, out rptSection, isFreeCtrl)) {
                w_aspect.setOffset(0);
                return true;
            }

            // Details
            //
            if (getRegionForControlAux(m_report.getDetails(), x, y, out rptSection, isFreeCtrl)) {
                w_aspect.setOffset(0);
                return true;
            }

            // Groups Footers
            //
            if (getRegionForControlAux(m_report.getGroupsFooters(), x, y, out rptSection, isFreeCtrl)) {
                w_aspect.setOffset(0);
                return true;
            }

            y = y + m_offSet;

            // Footers
            //
            if (getRegionForControlAux(m_report.getFooters(), x, y, out rptSection, isFreeCtrl)) {
                w_aspect.setOffset(m_offSet);
                return true;
            }

            return false;
        }
 public void setHeader(cReportSection rhs)
 {
     m_header = rhs;
 }
        private float pValidateSectionAspecAux(float top, cReportSection sec) {
            cReportSectionLine secLn = null;
            float topLn = 0;
            int i = 0;
            float secLnHeight = 0;
            float width = 0;

            cReportPaperInfo w_paperInfo = m_report.getPaperInfo();
            width = CSReportPaint.cGlobals.getRectFromPaperSize(
                                                    m_report.getPaperInfo(), 
                                                    w_paperInfo.getPaperSize(), 
                                                    w_paperInfo.getOrientation()).Width;
            topLn = top;

            cReportAspect w_aspect;

            for (i = 1; i <= sec.getSectionLines().count() - 1; i++) {
                secLn = sec.getSectionLines().item(i);
                w_aspect = secLn.getAspect();
                w_aspect.setTop(topLn);
                w_aspect.setWidth(width);
                if (w_aspect.getHeight() < C_MIN_HEIGHT_SECTION) {
                    w_aspect.setHeight(C_MIN_HEIGHT_SECTION);
                }
                topLn = topLn + w_aspect.getHeight();
                secLnHeight = secLnHeight + w_aspect.getHeight();
            }

            cReportSectionLines w_sectionLines = sec.getSectionLines();
            secLn = w_sectionLines.item(w_sectionLines.count());

            w_aspect = secLn.getAspect();
            w_aspect.setTop(topLn);
            w_aspect.setHeight(sec.getAspect().getHeight() - secLnHeight);
            if (w_aspect.getHeight() < C_MIN_HEIGHT_SECTION) {
                w_aspect.setHeight(C_MIN_HEIGHT_SECTION);
            }
            secLnHeight = secLnHeight + w_aspect.getHeight();

            w_aspect = sec.getAspect();
            w_aspect.setHeight(secLnHeight);
            if (w_aspect.getHeight() < C_MIN_HEIGHT_SECTION) {
                w_aspect.setHeight(C_MIN_HEIGHT_SECTION);
            }
            w_aspect.setWidth(width);
            w_aspect.setTop(top);
            topLn = top;
            top = top + w_aspect.getHeight();

            pChangeTopSection(sec, 0, false, false);
            return top;
        }
        private float pGetSecHeigthFromSecLines(cReportSection sec) {
            float rtn = 0;

            for (int _i = 0; _i < sec.getSectionLines().count(); _i++) {
                cReportSectionLine secLn = sec.getSectionLines().item(_i);
                rtn = rtn + secLn.getAspect().getHeight();
            }

            return rtn;
        }
        private void pChangeHeightSection(cReportSection sec, float oldSecHeight) {
            int i = 0;
            float heightLines = 0;
            cReportAspect w_aspect;

            // Update section line
            //
            for (i = 1; i <= sec.getSectionLines().count() - 1; i++) {
                w_aspect = sec.getSectionLines().item(i).getAspect();
                heightLines = heightLines + w_aspect.getHeight();
            }

            // for the last section line the height is the rest
            //
            cReportSectionLines w_sectionLines = sec.getSectionLines();
            w_aspect = w_sectionLines.item(w_sectionLines.count()).getAspect();
            w_aspect.setHeight(sec.getAspect().getHeight() - heightLines);

            pChangeTopSection(sec, 0, false, true);
        }
        private void pChangeBottomSections(cReportSection secToMove, float offsetTop) { 

            cReportSection sec = null;
            bool bChangeTop = false;
            int i = 0;

            if (secToMove.getTypeSection() == csRptTypeSection.CSRPTTPSCFOOTER 
                || secToMove.getTypeSection() == csRptTypeSection.CSRPTTPMAINSECTIONFOOTER 
                || bChangeTop) {

                for (i = m_report.getFooters().count(); i <= 1; i--) {
                    sec = m_report.getFooters().item(i);

                    if (bChangeTop) {
                        pChangeTopSection(sec, offsetTop, bChangeTop, false);
                    }

                    if (sec == secToMove) {
                        bChangeTop = true;
                    }
                }
            }
        }
        private void getLineAux(cReportSection sec, cReportPageFields fields)
        {
            // for every control in every section line of sec
            // we need to create a new cPageField
            //
            cReportPageField field = null;
            cReportSectionLine secLn = null;
            cReportControl ctrl = null;
            bool isVisible = false;
            int indexCtrl = 0;

            // this indexes are used to
            //
            // indicate in which data source is this field
            //
            int indexRows = 0;
            //
            // in which row is this field
            //
            int indexRow = 0;
            //
            // in which column is this field
            //
            int indexField = 0;

            if (sec.getHasFormulaHide())
            {
                isVisible = cUtil.val(m_compiler.resultFunction(sec.getFormulaHide())) != 0;
            }
            else
            {
                isVisible = true;
            }

            if (isVisible)
            {
                // for every section line in sec
                //
                for (int _i = 0; _i < sec.getSectionLines().count(); _i++)
                {
                    secLn = sec.getSectionLines().item(_i);
                    m_lineIndex++;

                    if (secLn.getHasFormulaHide())
                    {
                        m_compiler.evalFunction(secLn.getFormulaHide());
                        isVisible = cUtil.val(m_compiler.resultFunction(secLn.getFormulaHide())) != 0;
                    }
                    else
                    {
                        isVisible = true;
                    }

                    if (isVisible)
                    {
                        // for every control in the section line
                        //
                        int[] collByLeft = secLn.getControls().getCollByLeft();
                        for (indexCtrl = 0; indexCtrl < collByLeft.Length; indexCtrl++)
                        {
                            ctrl = secLn.getControls().item(collByLeft[indexCtrl]);

                            // add a new field to the collection
                            //
                            field = fields.add(null, "");
                            field.setIndexLine(m_lineIndex);

                            if (ctrl.getHasFormulaValue())
                            {
                                field.setValue(
                                    cReportGlobals.format(
                                        m_compiler.resultFunction(ctrl.getFormulaValue()),
                                        ctrl.getLabel().getAspect().getFormat()));
                            }
                            else
                            {
                                cReportLabel w_label = null;
                                switch (ctrl.getControlType())
                                {
                                    case csRptControlType.CSRPTCTFIELD:

                                        pGetIndexRows(out indexRows, out indexRow, out indexField, ctrl);

                                        if (m_collRows[indexRows] != null)
                                        {
                                            // it looks ugly, dont think you?
                                            //
                                            // maybe this help a litle:
                                            //
                                            //    m_vCollRows(IndexRows)    a matrix with the data 
                                            //                              contained in the datasource
                                            //                              referd by this control
                                            //
                                            //    (IndexField, IndexRow)    a cell in this matrix
                                            //
                                            object value = m_collRows[indexRows].Rows[indexRow][indexField];
                                            field.setValue(
                                                cReportGlobals.format(
                                                    cReportGlobals.valVariant(value),
                                                    ctrl.getLabel().getAspect().getFormat()));
                                        }
                                        break;

                                    case csRptControlType.CSRPTCTLABEL:
                                        w_label = ctrl.getLabel();
                                        field.setValue(cReportGlobals.format(w_label.getText(), w_label.getAspect().getFormat()));
                                        break;

                                    case csRptControlType.CSRPTCTIMAGE:
                                        w_label = ctrl.getLabel();
                                        field.setValue(cReportGlobals.format(w_label.getText(), w_label.getAspect().getFormat()));
                                        field.setImage(ctrl.getImage().getImage());
                                        break;

                                    case csRptControlType.CSRPTCTDBIMAGE:
                                        pGetIndexRows(out indexRows, out indexRow, out indexField, ctrl);
                                        if (m_collRows[indexRows] != null)
                                        {
                                            field.setImage(pGetImage(indexRows, indexField, indexRow));
                                        }
                                        break;

                                    case csRptControlType.CSRPTCTCHART:
                                        pGetIndexRows(out indexRows, out indexRow, out indexField, ctrl);
                                        field.setImage(pGetChartImage(indexRows, indexField, indexRow, ctrl));
                                        break;
                                }
                            }

                            if (ctrl.getHasFormulaHide())
                            {
                                field.setVisible(cUtil.val(m_compiler.resultFunction(ctrl.getFormulaHide())) != 0);
                            }
                            else
                            {
                                field.setVisible(true);
                            }

                            // set a reference to the definition of this field
                            //
                            field.setInfo(m_pageSetting.item(ctrl.getKey()));
                        }
                    }
                }
            }
        }
Exemple #10
0
 public void setFooter(cReportSection rhs)
 {
     m_footer = rhs;
 }
 public cReportSection add(cReportSection c, String key)
 {
     return add(c, key, -1);
 }
Exemple #12
0
 public void setHeader(cReportSection rhs)
 {
     m_header = rhs;
 }
Exemple #13
0
 private void pSetName(cReportSection c, String name)
 {
     c.setName(pSetName(c.getName(), name));
 }
 public void setFooter(cReportSection rhs)
 {
     m_footer = rhs;
 }
        private void pChangeTopSection(cReportSection rptSec, 
                                        float offSetTopSection, 
                                        bool bChangeTop, 
                                        bool bZeroOffset) 
        { 
            float newTopCtrl = 0;
            float offSet = 0;
            float bottom = 0;
            float secTop = 0;
            float secLnHeigt = 0;
            float offSecLn = 0;
            cReportPaintObject paintSec;

            cReportAspect secAspect = rptSec.getAspect();
            secAspect.setTop(secAspect.getTop() + offSetTopSection);
            offSet = rptSec.getSectionLines().item(1).getAspect().getTop() - secAspect.getTop();
            secTop = secAspect.getTop();

            for (int _i = 0; _i < rptSec.getSectionLines().count(); _i++) {

                cReportSectionLine rptSecLine = rptSec.getSectionLines().item(_i);

                cReportAspect secLineAspect = rptSecLine.getAspect();

                // footers grow to top
                //
                if (rptSec.getTypeSection() == csRptTypeSection.CSRPTTPMAINSECTIONFOOTER 
                    || rptSec.getTypeSection() == csRptTypeSection.CSRPTTPSCFOOTER) {

                    if (bChangeTop) {

                        if (bZeroOffset) {
                            offSet = 0;
                        }

                    } 
                    else {

                        if (rptSecLine.getRealIndex() >= m_indexSecLnMoved && m_indexSecLnMoved > 0) {

                            bChangeTop = true;
                        }

                    }

                    // every other section grow to bottom
                    //
                } 
                else {
                    offSecLn = (secTop + secLnHeigt) - secLineAspect.getTop();

                    if (offSetTopSection != 0) {
                        offSecLn = 0;
                    }
                }

                secLineAspect.setTop(secTop + secLnHeigt);
                secLnHeigt = secLnHeigt + secLineAspect.getHeight();

                if (rptSecLine.getKeyPaint() != "") {
                    paintSec = m_paint.getPaintSections().item(rptSecLine.getKeyPaint());
                    paintSec.getAspect().setTop(secLineAspect.getTop() + secLineAspect.getHeight() - cGlobals.C_HEIGHT_BAR_SECTION);
                } 
                else {
                    paintSec = m_paint.getPaintSections().item(rptSec.getKeyPaint());
                }
                if (paintSec != null) {
                    paintSec.setHeightSecLine(secLineAspect.getHeight());
                }

                for (int _j = 0; _j < rptSecLine.getControls().count(); _j++) {
                    cReportControl rptCtrl = rptSecLine.getControls().item(_j);

                    cReportAspect ctrLabelAspect = rptCtrl.getLabel().getAspect();

                    if (rptCtrl.getIsFreeCtrl()) {
                        newTopCtrl = (ctrLabelAspect.getTop() - offSet) + offSecLn;
                    } 
                    else {
                        newTopCtrl = (ctrLabelAspect.getTop() + ctrLabelAspect.getHeight() - offSet) + offSecLn;
                    }

                    bottom = secLineAspect.getTop() + secLineAspect.getHeight();

                    if (newTopCtrl > bottom) {
                        newTopCtrl = bottom - ctrLabelAspect.getHeight();
                    } 
                    else {
                        newTopCtrl = (ctrLabelAspect.getTop() - offSet) + offSecLn;
                    }

                    if (newTopCtrl < secLineAspect.getTop()) { newTopCtrl = secLineAspect.getTop(); }

                    ctrLabelAspect.setTop(newTopCtrl);
                    if (m_paint.getPaintObject(rptCtrl.getKeyPaint()) != null) {
                        m_paint.getPaintObject(rptCtrl.getKeyPaint()).getAspect().setTop(ctrLabelAspect.getTop());
                    }
                }
            }

            // when a group is added the first to get here is the header
            // and the footer has not have a section yet
            //
            if (rptSec.getKeyPaint() == "") { return; }

            cReportAspect w_aspect = rptSec.getAspect();
            
            // we only draw the bottom line of the sections
            //
            paintSec = m_paint.getPaintSections().item(rptSec.getKeyPaint());

            if (paintSec != null) {
                paintSec.getAspect().setTop(w_aspect.getTop() 
                                            + w_aspect.getHeight() 
                                            - cGlobals.C_HEIGHT_BAR_SECTION);
                paintSec.setHeightSec(w_aspect.getHeight());
            }
        }
        private void pSetFormulaIndexGroup(cReportFormula formula, cReportSection sec)
        { // TODO: Use of ByRef founded Private Function pSetFormulaIndexGroup(ByRef Formula As cReportFormula, ByRef Sec As cReportSection) As Boolean
            cReportFormulaInt fint = null;
            int indexGroup = 0;

            for (int _i = 0; _i < formula.getFormulasInt().count(); _i++)
            {
                fint = formula.getFormulasInt().item(_i);

                if (pIsGroupFormula((int)fint.getFormulaType()))
                {
                    if (fint.getFormulaType() == csRptFormulaType.CSRPTGROUPPERCENT)
                    {
                        formula.setIdxGroup2(0);
                        indexGroup = cUtil.valAsInt(fint.getParameters().item(3).getValue());
                    }
                    else
                    {
                        indexGroup = cUtil.valAsInt(fint.getParameters().item(2).getValue());
                    }
                    if (fint.getParameters().item(cReportGlobals.C_KEYINDEXGROUP) == null)
                    {
                        fint.getParameters().add2("", cReportGlobals.C_KEYINDEXGROUP);
                    }
                    if (indexGroup == -1)
                    {
                        if (sec.getTypeSection() == csRptSectionType.GROUP_HEADER
                            || sec.getTypeSection() == csRptSectionType.GROUP_FOOTER)
                        {
                            // index of the group
                            //
                            fint.getParameters().item(cReportGlobals.C_KEYINDEXGROUP).setValue(sec.getIndex().ToString());
                            formula.setIdxGroup(sec.getIndex());
                        }
                        else if (sec.getTypeSection() == csRptSectionType.MAIN_DETAIL)
                        {
                            // index of the most internal group
                            //
                            fint.getParameters().item(cReportGlobals.C_KEYINDEXGROUP).setValue(m_groups.count().ToString());
                            formula.setIdxGroup(m_groups.count()-1);
                        }
                        else
                        {
                            fint.getParameters().item(cReportGlobals.C_KEYINDEXGROUP).setValue("0");
                            formula.setIdxGroup(0);
                        }
                    }
                    else
                    {
                        fint.getParameters().item(cReportGlobals.C_KEYINDEXGROUP).setValue(indexGroup.ToString());
                        formula.setIdxGroup(indexGroup);
                    }
                }
            }
        }
        private void moveSection(CSReportPaint.cReportPaintObject paintObj, 
                                    float x, 
                                    float y, 
                                    float minBottom, 
                                    float maxBottom, 
                                    cReportSection secToMove, 
                                    bool isNew) 
        { 
            float oldHeight = 0;
            int i = 0;

            m_dataHasChanged = true;

            cReportAspect w_aspect = paintObj.getAspect();

            // if Y is contained by the premited range everything is ok
            //
            if (y >= minBottom && y <= maxBottom) {
                w_aspect.setTop(y - m_offY);

                // because the top has been set to real dimensions
                // of the screen we must move to the offset
                // of his section
                //
                w_aspect.setTop(w_aspect.getTop() + w_aspect.getOffset());
            } 
            else {
                // if we have moved to top
                //
                if (y < minBottom) {
                    w_aspect.setTop(minBottom);

                    // because the top has been set to real dimensions
                    // of the screen we must move to the offset
                    // of his section
                    //
                    w_aspect.setTop(w_aspect.getTop() + w_aspect.getOffset());
                } 
                else {
                    w_aspect.setTop(maxBottom);
                }
            }

            m_paint.alingToGrid(paintObj.getKey());

            if (isNew) {
                oldHeight = 0;
            } 
            else {
                oldHeight = secToMove.getAspect().getHeight();
            }

            // for the detail section and every other section which is over the detail
            // we only change the height, for all sections bellow the detail we need to
            // change the height and top becasuse wen we strech a section it needs to move
            // to the bottom of the report
            //
            secToMove.getAspect().setHeight(w_aspect.getTop() 
                                            + cGlobals.C_HEIGHT_BAR_SECTION 
                                            - secToMove.getAspect().getTop());

            // every section bellow this section needs to update its top
            //
            float offsetTop = 0;

            w_aspect = secToMove.getAspect();

            offsetTop = oldHeight - (w_aspect.getHeight() + m_newSecLineOffSet);

            switch (secToMove.getTypeSection()) {

                    // if the section is a footer we move to bottom
                    // (Ojo footer sections, no group footers)
                    //
                case  csRptTypeSection.CSRPTTPSCFOOTER:
                case csRptTypeSection.CSRPTTPMAINSECTIONFOOTER:

                    w_aspect.setTop(w_aspect.getTop() + offsetTop);

                    // OJO: this has to be after we have changed the top of the section
                    //      to allow the paint object to reflect the change
                    //
                    // we move the controls of this section
                    //
                    pChangeHeightSection(secToMove, oldHeight);

                    // move the section
                    //
                    pChangeBottomSections(secToMove, offsetTop);

                    // for headers, group headers, group footers and the detail section we move to top
                    //
                    break;
                default:

                    // move all controls in this section
                    //
                    pChangeHeightSection(secToMove, oldHeight);

                    offsetTop = offsetTop * -1;

                    pChangeTopSections(secToMove, offsetTop);
                    break;
            }

            // finaly we need to update the offset of every section,
            // apply it to every object paint in m_Paint
            //
            float pageHeight = 0;
            cReportPaperInfo w_paperInfo = m_report.getPaperInfo();
            pGetOffSet(CSReportPaint.cGlobals.getRectFromPaperSize(
                                                        m_report.getPaperInfo(), 
                                                        w_paperInfo.getPaperSize(), 
                                                        w_paperInfo.getOrientation()).Height, 
                                                        pageHeight);
            pRefreshOffSetInPaintObjs();
            m_paint.setGridHeight(pageHeight);
        }
        private float getHeightOfSectionsBellowMe(cReportSection section, String secLnKey)
        {
            float height = 0;

            if ( ! String.IsNullOrEmpty(secLnKey) )
            {
                bool add = false;
                for (int _i = 0; _i < section.getSectionLines().count(); _i++)
                {
                    cReportSectionLine secLn = section.getSectionLines().item(_i);
                    if (add)
                    {
                        height += secLn.getAspect().getHeight();
                    }
                    else if (secLn.getKey() == secLnKey)
                    {
                        add = true;
                    }
                }
            }

            csRptSectionType rptType = section.getTypeSection();

            switch (rptType) {

                case csRptSectionType.HEADER:
                case csRptSectionType.MAIN_HEADER:
                    height += getHeightFromSections(m_report.getHeaders(), section);
                    height += getHeightFromSections(m_report.getGroupsHeaders(), null);
                    height += getHeightFromSections(m_report.getDetails(), null);
                    height += getHeightFromSections(m_report.getGroupsFooters(), null);
                    height += getHeightFromSections(m_report.getFooters(), null);
                    break;

                case csRptSectionType.GROUP_HEADER:
                    height += getHeightFromSections(m_report.getGroupsHeaders(), section);
                    height += getHeightFromSections(m_report.getDetails(), null);
                    height += getHeightFromSections(m_report.getGroupsFooters(), null);
                    height += getHeightFromSections(m_report.getFooters(), null);
                    break;

                case csRptSectionType.DETAIL:
                case csRptSectionType.MAIN_DETAIL:
                    height += getHeightFromSections(m_report.getDetails(), section);
                    height += getHeightFromSections(m_report.getGroupsFooters(), null);
                    height += getHeightFromSections(m_report.getFooters(), null);
                    break;

                case csRptSectionType.GROUP_FOOTER:
                    height += getHeightFromSections(m_report.getGroupsFooters(), section);
                    height += getHeightFromSections(m_report.getFooters(), null);
                    break;

                case csRptSectionType.FOOTER:
                case csRptSectionType.MAIN_FOOTER:
                    height += getHeightFromSections(m_report.getFooters(), section);
                    break;

                default:
                    throw new ReportEditorException(
                        csRptEditorErrors.CSRPT_EDITOR_SECTION_TYPE_INVALID,
                        C_MODULE,
                        cReportEditorError.errGetDescript(
                                        csRptEditorErrors.CSRPT_EDITOR_SECTION_TYPE_INVALID));
            }

            return height;
        }
        private void pChangeTopSections(cReportSection secToMove, float offsetTop) { 

            cReportSection sec = null;
            bool bChangeTop = false;
            int i = 0;

            if (secToMove.getTypeSection() == csRptTypeSection.CSRPTTPSCHEADER 
                || secToMove.getTypeSection() == csRptTypeSection.CSRPTTPMAINSECTIONHEADER) {

                for (int _i = 0; _i < m_report.getHeaders().count(); _i++) {
                    sec = m_report.getHeaders().item(_i);
                    if (bChangeTop) {
                        pChangeTopSection(sec, offsetTop, bChangeTop, false);
                    }

                    if (sec == secToMove) {
                        bChangeTop = true;
                    }
                }
            }

            if (secToMove.getTypeSection() == csRptTypeSection.CSRPTTPGROUPHEADER || bChangeTop) {

                for (int _i = 0; _i < m_report.getGroupsHeaders().count(); _i++) {
                    sec = m_report.getGroupsHeaders().item(_i);
                    if (bChangeTop) {
                        pChangeTopSection(sec, offsetTop, bChangeTop, false);
                    }

                    if (sec == secToMove) {
                        bChangeTop = true;
                    }
                }
            }

            if (secToMove.getTypeSection() == csRptTypeSection.CSRPTTPMAINSECTIONDETAIL 
                || secToMove.getTypeSection() == csRptTypeSection.CSRPTTPSCDETAIL || bChangeTop) {

                for (int _i = 0; _i < m_report.getDetails().count(); _i++) {
                    sec = m_report.getDetails().item(_i);
                    if (bChangeTop) {
                        pChangeTopSection(sec, offsetTop, bChangeTop, false);
                    }

                    if (sec == secToMove) {
                        bChangeTop = true;
                    }
                }
            }

            if (secToMove.getTypeSection() == csRptTypeSection.CSRPTTPGROUPFOOTER || bChangeTop) {

                for (int _i = 0; _i < m_report.getGroupsFooters().count(); _i++) {
                    sec = m_report.getGroupsFooters().item(_i);
                    if (bChangeTop) {
                        pChangeTopSection(sec, offsetTop, bChangeTop, false);
                    }

                    if (sec == secToMove) {
                        bChangeTop = true;
                    }
                }
            }
        }
 private float getHeightFromSections(cIReportGroupSections sections, cReportSection section)
 {
     bool add = section == null;
     float height = 0;
     for (int _i = 0; _i < sections.count(); _i++)
     {
         cReportSection sec = sections.item(_i);
         if (add)
         {
             height += sec.getAspect().getHeight();
         }
         else if (section == sec)
         {
             add = true;
         }
     }
     return height;
 }
        private void pAddPaintSetcionForSecLn(
            cReportSection sec, 
			csRptTypeSection typeSecLn) 
        { 
            int i = 0;
            cReportPaintObject paintSec = null;

            if (sec.getSectionLines().count() > 1) {

                for (i = 1; i <= sec.getSectionLines().count() - 1; i++) {
                    cReportSectionLine secLine = sec.getSectionLines().item(i);
                    secLine.setKeyPaint(
                        paintSection(
                            secLine.getAspect(), 
                            secLine.getKey(), 
                            sec.getTypeSection(), 
                            C_SECTIONLINE + i.ToString(), 
                            true));

                    // we set the height of every section line
                    //
                    paintSec = m_paint.getPaintSections().item(secLine.getKeyPaint());
                    paintSec.setHeightSecLine(secLine.getAspect().getHeight());
                    paintSec.setRptType(typeSecLn);
                    paintSec.setRptKeySec(sec.getKey());
                }

                // if there is more than one section we use
                // textLine to show the name of the last line
                //
                CSReportPaint.cReportPaintObject po = m_paint.getPaintSections().item(sec.getKeyPaint());
                po.setTextLine(C_SECTIONLINE + sec.getSectionLines().count().ToString());
            }

            // we set the height of the last section line
            //
            paintSec = m_paint.getPaintSections().item(sec.getKeyPaint());

            cReportSectionLines secLines = sec.getSectionLines();
            paintSec.setHeightSecLine(secLines.item(secLines.count()).getAspect().getHeight());
        }
        private bool pCanDeleteSection(
            out cReportSections secs, 
            cReportSection sec, 
            String tag) 
        { 
            cReportSection secAux = null;
            
            // header
            //
            secAux = m_report.getHeaders().item(tag);
            secs = null;

            if (secAux != null) {
                if (secAux.Equals(sec) || sec == null) {
                    if (secAux.getTypeSection() == csRptTypeSection.CSRPTTPMAINSECTIONHEADER) {
                        cWindow.msgInfo("The main header can't be deleted");
                        return false;
                    }
                    secs = m_report.getHeaders();
                }
            } 
            // if we don't find the section yet
            //
            if (secs == null) {

                // footers
                //
                secAux = m_report.getFooters().item(tag);
                if (secAux != null) {
                    if (secAux.Equals(sec) || sec == null) {
                        if (secAux.getTypeSection() == csRptTypeSection.CSRPTTPMAINSECTIONFOOTER) {
                            cWindow.msgInfo("The main footer can't be deleted");
                            return false;
                        }
                        secs = m_report.getFooters();
                    }
                } 
                // if we don't find the section yet
                //
                if (secs == null) {

                    // check for groups
                    //
                    secAux = m_report.getGroupsHeaders().item(tag);
                    if (secAux != null) {
                        if (!((secAux.Equals(sec) || sec == null))) {

                            secAux = m_report.getGroupsFooters().item(tag);
                            if (secAux != null) {
                                if (!((secAux.Equals(sec) || sec == null))) {

                                    // finally the detail section can't be deleted
                                    //
                                    cWindow.msgInfo("The detail section can't be deleted");
                                    return false;
                                }
                            }
                        }
                    }
                }
            }

            return true;
        }
 private float pGetMinBottomForSecLn(
     cReportSection sec, 
     String secLnKey, 
     float minBottom) 
 {
     for (int _i = 0; _i < sec.getSectionLines().count(); _i++) {
         cReportSectionLine secLn = sec.getSectionLines().item(_i);
         if (secLn.getKey() == secLnKey) { break; }
         minBottom = minBottom + secLn.getAspect().getHeight();
     }
     return minBottom;
 }
        private void pAddSectionLinesAux(
            cReportSection sec, 
            CSReportPaint.cReportPaintObject paintObj) 
        {
			csRptTypeSection typeSecLn = csRptTypeSection.CONTROL;
			cReportAspect aspect = null;
            int maxBottom = 0;
            int minBottom = 0;
            int index = 0;
			float y = 0;

            switch (sec.getTypeSection()) {
                case csRptTypeSection.CSRPTTPSCHEADER:
                case csRptTypeSection.CSRPTTPMAINSECTIONHEADER:

                    pMoveHeader(sec.getKey(), minBottom, maxBottom, false);
                    aspect = sec.getAspect();
                    y = aspect.getHeight() + aspect.getTop();
                    typeSecLn = csRptTypeSection.C_KEY_SECLN_HEADER;
                    index = sec.getSectionLines().count() - 1;
                    break;

                case csRptTypeSection.CSRPTTPSCDETAIL:
                case csRptTypeSection.CSRPTTPMAINSECTIONDETAIL:

                    pMoveDetails(sec.getKey(), minBottom, maxBottom, false);
                    aspect = sec.getAspect();
                    y = aspect.getHeight() + aspect.getTop();
                    typeSecLn = csRptTypeSection.C_KEY_SECLN_DETAIL;
                    index = sec.getSectionLines().count() - 1;
                    break;

                case csRptTypeSection.CSRPTTPGROUPHEADER:

                    pMoveGroupHeader(sec.getKey(), minBottom, maxBottom, false);
                    aspect = sec.getAspect();
                    y = aspect.getHeight() + aspect.getTop();
                    typeSecLn = csRptTypeSection.C_KEY_SECLN_GROUPH;
                    index = sec.getSectionLines().count() - 1;
                    break;

                case csRptTypeSection.CSRPTTPGROUPFOOTER:

                    pMoveGroupFooter(sec.getKey(), minBottom, maxBottom, false);
                    aspect = sec.getAspect();
                    y = aspect.getHeight() + aspect.getTop();
                    typeSecLn = csRptTypeSection.C_KEY_SECLN_GROUPF;
                    index = sec.getSectionLines().count() - 1;
                    break;

                case csRptTypeSection.CSRPTTPSCFOOTER:
                case csRptTypeSection.CSRPTTPMAINSECTIONFOOTER:

                    aspect = sec.getAspect();
                    aspect.setTop(aspect.getTop() - cGlobals.C_HEIGHT_NEW_SECTION);
                    pMoveFooter(sec.getKey(), minBottom, maxBottom, false);
                    m_offY = 0;
                    y = aspect.getHeight() + aspect.getTop() - m_offSet - cGlobals.C_HEIGHT_BAR_SECTION;
                    typeSecLn = csRptTypeSection.C_KEY_SECLN_FOOTER;
                    index = 1;
                    break;
            }
			// we add a paint object to all sectionlines except the last one 
            // the last sectionline uses the paint object of the section
            //
			cReportSectionLine secL = sec.getSectionLines().item(index);
			secL.setKeyPaint(
				paintSection(secL.getAspect(), 
								secL.getKey(), 
                                sec.getTypeSection(), 
								C_SECTIONLINE + (sec.getSectionLines().count() - 1).ToString(), 
								true));

			// section line
            CSReportPaint.cReportPaintObject po = m_paint.getPaintSections().item(secL.getKeyPaint());
			po.setRptType(typeSecLn);
			po.setRptKeySec(sec.getKey());

			// section
            po = m_paint.getPaintSections().item(sec.getKeyPaint());
			po.setTextLine(C_SECTIONLINE + sec.getSectionLines().count().ToString());

            moveSection(paintObj, 0, y, minBottom, maxBottom, sec, false);

            refreshBody();
            refreshRule();
        }
        private cReportSectionLine pGetSecLnFromKey(
            String secKey, 
			cIReportGroupSections sections, 
            out cReportSection rtnSec) 
        { 
            cReportSection sec = null;
			rtnSec = null;
			for (int _i = 0; _i < sections.count(); _i++) {
				sec = sections.item(_i);
				if (sec.getSectionLines().item(secKey) != null) {
                    rtnSec = sec;
                    return sec.getSectionLines().item(secKey);
                }
            }
			return null;
        }
 private void pSetName(cReportSection c, String name)
 {
     c.setName(pSetName(c.getName(), name));
 }