Inheritance: cIReportGroupSections
        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 void pDestroyCrossRef(cReportSections secs)
        {
            cReportSection sec = null;
            cReportSectionLine secl = null;

            for (int _i = 0; _i < secs.count(); _i++)
            {
                sec = secs.item(_i);
                for (int _j = 0; _j < sec.getSectionLines().count(); _j++)
                {
                    secl = sec.getSectionLines().item(_j);
                    secl.getControls().setSectionLine(null);

                    if (secl.getControls().getCopyColl() != null)
                    {
                        secl.getControls().getCopyColl().clear();
                    }
                    secl.getControls().setCopyColl(null);
                    secl.getControls().clear();
                    secl.setControls(null);
                }
                sec.setCopyColl(null);
            }
            secs.setCopyColl(null);
        }
        private void pSetIndexColInGroupFormulasAux(cReportSections sections, List<object[]> recordsets)
        {
            cReportSection sec = null;
            cReportSectionLine secLn = null;
            cReportControl ctrl = null;

            for (int _i = 0; _i < sections.count(); _i++)
            {
                sec = sections.item(_i);
                if (sec.getHasFormulaHide())
                {
                    pSetIndexColInGroupFormula(sec.getFormulaHide(), recordsets);
                }
                for (int _j = 0; _j < sec.getSectionLines().count(); _j++)
                {
                    secLn = sec.getSectionLines().item(_j);
                    if (secLn.getHasFormulaHide())
                    {
                        pSetIndexColInGroupFormula(secLn.getFormulaHide(), recordsets);
                    }
                    for (int _k = 0; _k < secLn.getControls().count(); _k++)
                    {
                        ctrl = secLn.getControls().item(_k);
                        if (ctrl.getHasFormulaHide())
                        {
                            pSetIndexColInGroupFormula(ctrl.getFormulaHide(), recordsets);
                        }
                        if (ctrl.getHasFormulaValue())
                        {
                            pSetIndexColInGroupFormula(ctrl.getFormulaValue(), recordsets);
                        }
                    }
                }
            }
        }
        private void pSortControlsByLeftAux1(cReportSections sections)
        {
            cReportSection sec = null;
            cReportSectionLine secLn = null;

            for (int _i = 0; _i < sections.count(); _i++)
            {
                sec = sections.item(_i);
                for (int _j = 0; _j < sec.getSectionLines().count(); _j++)
                {
                    secLn = sec.getSectionLines().item(_j);
                    secLn.getControls().orderCollByLeft();
                }
            }
        }
        // public functions
        public void Dispose()
        {
            m_rows = null;
            m_collRows = null;
            m_vRowsIndexAux = null;
            m_vGroups = null;
            m_vRowsIndex = null;
            m_lastRowIndex = -1;
            m_lastRowPreEvalued = null;
            m_lastRowPostEvalued = null;

            m_controls.clear();
            m_controls = null;

            pDestroyCrossRef(m_headers);
            pDestroyCrossRef(m_details);
            pDestroyCrossRef(m_footers);
            pDestroyCrossRef(m_groups.getGroupsHeaders());
            pDestroyCrossRef(m_groups.getGroupsFooters());

            m_headers.clear();
            m_details.clear();
            m_footers.clear();
            m_groupsHeaders.clear();
            m_groupsFooters.clear();

            m_details.setCopyColl(null);
            m_headers.setCopyColl(null);
            m_footers.setCopyColl(null);
            m_groupsHeaders.setCopyColl(null);
            m_groupsFooters.setCopyColl(null);

            m_headers = null;
            m_details = null;
            m_footers = null;
            m_groupsHeaders = null;
            m_groupsFooters = null;

            m_paperInfo = null;

            m_formulas.clear();
            m_formulas = null;

            m_formulaTypes.clear();
            m_formulaTypes = null;

            m_connect = null;

            m_pages.clear();
            m_pages = null;

            m_pageSetting.clear();
            m_pageSetting = null;

            m_compiler = null;
            m_launchInfo = null;

            m_connectsAux.clear();
            m_connectsAux = null;

            pDestroyImages();
            m_images = null;
        }
        private void sortCollectionAux(cReportSections col)
        {
            cReportSection sec = null;
            cReportSectionLine secLn = null;

            for (int _i = 0; _i < col.count(); _i++)
            {
                sec = col.item(_i);
                for (int _j = 0; _j < sec.getSectionLines().count(); _j++)
                {
                    secLn = sec.getSectionLines().item(_j);
                    secLn.setControls(getControlsInZOrder(secLn.getControls()));
                }
            }
        }
        private bool loadAux(CSXml.cXml docXml, cReportSections sections, String keySection)
        {
            XmlNode nodeObj = null;
            XmlNode nodeObjAux = null;
            XmlNode nodeObjSec = null;

            nodeObj = docXml.getRootNode();
            nodeObj = docXml.getNodeFromNode(nodeObj, keySection);

            if (docXml.nodeHasChild(nodeObj))
            {
                nodeObjSec = docXml.getNodeChild(nodeObj);

                while (nodeObjSec != null)
                {
                    nodeObjAux = nodeObjSec;
                    String key = docXml.getNodeProperty(nodeObjAux, "Key").getValueString(eTypes.eText);
                    cReportSection sec = sections.add(null, key);
                    if (!sec.load(docXml, nodeObjAux)) 
                    { 
                        return false; 
                    }
                    nodeObjSec = docXml.getNextNode(nodeObjSec);
                }
            }
            return true;
        }
        private bool pAddFormulasInSection(cReportSections sections)
        { // TODO: Use of ByRef founded Private Function pAddFormulasInSection(ByRef Sections As cReportSections) As Boolean
            cReportSection sec = null;
            cReportSectionLine secLn = null;

            for (int _i = 0; _i < sections.count(); _i++)
            {
                sec = sections.item(_i);
                if (sec.getHasFormulaHide())
                {
                    if (!m_compiler.checkSyntax(sec.getFormulaHide())) 
                    { 
                        return false; 
                    }
                    // to have debug info
                    //
                    sec.getFormulaHide().setSectionName(sec.getName());

                    // add the formula to the formulas collection
                    //
                    addFormula(sec.getFormulaHide(), sec.getName() + "_" + "H");
                }
                for (int _j = 0; _j < sec.getSectionLines().count(); _j++)
                {
                    secLn = sec.getSectionLines().item(_j);
                    if (secLn.getHasFormulaHide())
                    {
                        if (!m_compiler.checkSyntax(secLn.getFormulaHide())) 
                        { 
                            return false; 
                        }
                        // to have debug info
                        //
                        secLn.getFormulaHide().setSectionName(secLn.getSectionName());
                        secLn.getFormulaHide().setSectionLineIndex(secLn.getIndex());

                        // add the formula to the formulas collection
                        //
                        addFormula(secLn.getFormulaHide(), sec.getName() 
                                    + "_R_" + secLn.getIndex().ToString() + "_" + "H");
                    }
                }
            }
            return true;
        }
        private void addFieldToNewPage(cReportSections sections, cReportPage page, int where)
        { // TODO: Use of ByRef founded Private Sub AddFieldToNewPage(ByRef Sections As cReportSections, ByRef Page As cReportPage, ByVal Where As Long)
            cReportPageField field = null;
            cReportSection sec = null;
            cReportSectionLine secline = null;
            cReportControl ctrl = null;
            bool isVisible = false;
            int indexCtrl = 0;
            float offset = 0;
            int recordCount = 0;

            if (m_rows != null)
            {
                recordCount = m_vRowsIndex.Length;
            }

            // this indexes means
            //
            // in which datasource is this control
            //
            int indexRows = 0;
            // in which row of the datasource is the control
            //
            int indexRow = 0;
            int indexField = 0;

            for (int _i = 0; _i < sections.count(); _i++)
            {
                sec = sections.item(_i);
                m_lineIndex = m_lineIndex + 1;

                if (sec.getHasFormulaHide())
                {
                    isVisible = cUtil.val(m_compiler.resultFunction(sec.getFormulaHide())) != 0;
                }
                else
                {
                    isVisible = true;
                }
                if (isVisible)
                {
                    for (int _j = 0; _j < sec.getSectionLines().count(); _j++)
                    {
                        secline = sec.getSectionLines().item(_j);
                        if (secline.getHasFormulaHide())
                        {
                            isVisible = cUtil.val(m_compiler.resultFunction(secline.getFormulaHide())) != 0;
                        }
                        else
                        {
                            isVisible = true;
                        }
                        if (isVisible)
                        {
                            // For Each Ctrl In Secline.Controls
                            //
                            for (indexCtrl = 0; indexCtrl < secline.getControls().getCollByLeft().Length; indexCtrl++)
                            {
                                ctrl = secline.getControls().item(secline.getControls().getCollByLeft()[indexCtrl]);

                                if (where == C_HEADERS)
                                {
                                    field = page.getHeader().add(null, "");
                                }
                                else if (where == C_FOOTERS)
                                {
                                    field = page.getFooter().add(null, "");
                                }

                                field.setIndexLine(m_lineIndex);

                                if (ctrl.getHasFormulaValue())
                                {
                                    field.setValue(
                                        cReportGlobals.format(
                                            m_compiler.resultFunction(ctrl.getFormulaValue()), 
                                            ctrl.getLabel().getAspect().getFormat()));
                                }
                                else
                                {
                                    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:
                                            field.setValue(
                                                cReportGlobals.format(
                                                    ctrl.getLabel().getText(), 
                                                    ctrl.getLabel().getAspect().getFormat()));
                                            break;

                                        case csRptControlType.CSRPTCTIMAGE:
                                            field.setValue(
                                                cReportGlobals.format(
                                                    ctrl.getLabel().getText(), 
                                                    ctrl.getLabel().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;
                                    }
                                }

                                field.setInfo(m_pageSetting.item(ctrl.getKey()));
                                field.setTop(field.getInfo().getAspect().getTop() + offset);

                                if (ctrl.getHasFormulaHide())
                                {
                                    field.setVisible(
                                        cUtil.val(m_compiler.resultFunction(ctrl.getFormulaHide())) != 0);
                                }
                                else
                                {
                                    field.setVisible(true);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (where == C_HEADERS)
                    {
                        offset = offset - sec.getAspect().getHeight();
                    }
                    else if (where == C_FOOTERS)
                    {
                        offset = offset + sec.getAspect().getHeight();
                    }
                }
            }
        }
        private void pSetGroupFormulaHF(cReportSections sections, int idxGrop)
        { // TODO: Use of ByRef founded Private Sub pSetGroupFormulaHF(ByRef Sections As cReportSections, ByVal IdxGrop As Integer)
            cReportSection sec = null;
            cReportSectionLine secLn = null;
            cReportControl ctrl = null;

            for (int _i = 0; _i < sections.count(); _i++)
            {
                sec = sections.item(_i);
                for (int _j = 0; _j < sec.getSectionLines().count(); _j++)
                {
                    secLn = sec.getSectionLines().item(_j);
                    for (int _k = 0; _k < secLn.getControls().count(); _k++)
                    {
                        ctrl = secLn.getControls().item(_k);
                        if (ctrl.getHasFormulaHide())
                        {
                            if (ctrl.getFormulaHide().getIdxGroup() == 0)
                            {
                                ctrl.getFormulaHide().setIdxGroup(idxGrop);
                            }
                        }
                        if (ctrl.getHasFormulaValue())
                        {
                            if (ctrl.getFormulaValue().getIdxGroup() == 0)
                            {
                                ctrl.getFormulaValue().setIdxGroup(idxGrop);
                            }
                        }
                    }
                }
            }
        }
        private void pSetIndexGroupInFormulaGroups(cReportSections sections)
        { // TODO: Use of ByRef founded Private Function pSetIndexGroupInFormulaGroups(ByRef Sections As cReportSections) As Boolean
            cReportSection sec = null;
            cReportSectionLine secLn = null;
            cReportControl ctrl = null;

            for (int _i = 0; _i < sections.count(); _i++)
            {
                sec = sections.item(_i);
                if (sec.getHasFormulaHide())
                {
                    pSetFormulaIndexGroup(sec.getFormulaHide(), sec);
                }
                for (int _j = 0; _j < sec.getSectionLines().count(); _j++)
                {
                    secLn = sec.getSectionLines().item(_j);
                    if (secLn.getHasFormulaHide())
                    {
                        pSetFormulaIndexGroup(secLn.getFormulaHide(), sec);
                    }
                    for (int _k = 0; _k < secLn.getControls().count(); _k++)
                    {
                        ctrl = secLn.getControls().item(_k);
                        if (ctrl.getHasFormulaHide())
                        {
                            pSetFormulaIndexGroup(ctrl.getFormulaHide(), sec);
                        }
                        if (ctrl.getHasFormulaValue())
                        {
                            pSetFormulaIndexGroup(ctrl.getFormulaValue(), sec);
                        }
                    }
                }
            }
        }
 public void setFooters(cReportSections rhs)
 {
     m_footers = rhs;
 }
 public void setHeaders(cReportSections rhs)
 {
     m_headers = rhs;
 }
 public void setDetails(cReportSections rhs)
 {
     m_details = rhs;
 }
        public cReport()
        {
            try
            {
                m_headers = new cReportSections();
                m_details = new cReportSections();
                m_footers = new cReportSections();
                m_groups = new cReportGroups();
                m_groupsHeaders = getGroups().getGroupsHeaders();
                m_groupsFooters = getGroups().getGroupsFooters();
                m_paperInfo = new cReportPaperInfo();
                m_controls = new cReportControls2();
                m_formulas = new cReportFormulas();
                m_formulaTypes = new cReportFormulaTypes();
                m_connect = new cReportConnect();
                m_pageSetting = new cReportPageSettings();
                m_pages = new cReportPages();

                m_compiler = new cReportCompiler();

                setConnectsAux(new cReportConnectsAux());

                m_details.setCopyColl(m_controls);
                m_headers.setCopyColl(m_controls);
                m_footers.setCopyColl(m_controls);
                m_groupsHeaders.setCopyColl(m_controls);
                m_groupsFooters.setCopyColl(m_controls);

                m_details.setTypeSection(csRptSectionType.DETAIL);
                m_headers.setTypeSection(csRptSectionType.HEADER);
                m_footers.setTypeSection(csRptSectionType.FOOTER);
                m_groupsHeaders.setTypeSection(csRptSectionType.GROUP_HEADER);
                m_groupsFooters.setTypeSection(csRptSectionType.GROUP_FOOTER);

                m_details.setMainTypeSection(csRptSectionType.MAIN_DETAIL);
                m_headers.setMainTypeSection(csRptSectionType.MAIN_HEADER);
                m_footers.setMainTypeSection(csRptSectionType.MAIN_FOOTER);
            }
            catch (Exception ex)
            {
                cError.mngError(ex, "Class_Initialize", C_MODULE, "");
            }
        }
 internal void setGroupsFooters(cReportSections rhs)
 {
     m_groupsFooters = rhs;
 }