public void deleteObj(bool bDelSectionLine) {
int i = 0;
cReportSection sec = null;
cReportSections secs = null;
cReportSectionLine secLn = null;
cReportControl ctrl = null;
CSReportPaint.cReportPaintObject paintObj = null;
bool isGroupFooter = false;
bool isGroupHeader = false;
bool isSecLn = false;
if (m_keyFocus == "") { return; }
cReportGroup group = null;
cReportSection secG = null;
if (m_paint.paintObjIsSection(m_keyFocus)) {
if (m_paint.getPaintSections().item(m_keyFocus) == null) { return; }
CSReportPaint.cReportPaintObject po = m_paint.getPaintSections().item(m_keyFocus);
// first we check it is not a section line
//
sec = pGetSection(out isSecLn, out secLn, false, out isGroupHeader, out isGroupFooter);
if (!isSecLn) {
// check it is not the last section line in this section
//
if (bDelSectionLine) {
sec = pGetSection(out isSecLn, out secLn, true, out isGroupHeader, out isGroupFooter);
}
if (!pCanDeleteSection(out secs, sec, po.getTag())) { return; }
}
String what = "";
if (isSecLn) {
what = "the section line";
}
else {
what = "the section";
}
if (!cWindow.ask("Are yuo sure you want to delete "
+ what + " and all the controls it contains? ", VbMsgBoxResult.vbNo)) {
return;
}
if (isSecLn) {
for (int _i = 0; _i < secLn.getControls().count(); _i++) {
ctrl = secLn.getControls().item(_i);
for (i = 1; i <= m_paint.getPaintObjects().count(); i++) {
paintObj = m_paint.getPaintObjects().item(i);
if (paintObj.getTag() == ctrl.getKey()) {
m_paint.getPaintObjects().remove(paintObj.getKey());
break;
}
}
}
secLn.getControls().clear();
// at least one section line has to be in the section
//
if (sec.getSectionLines().count() > 1) {
sec.getSectionLines().remove(secLn.getKey());
}
}
else {
for (int _i = 0; _i < sec.getSectionLines().count(); _i++) {
secLn = sec.getSectionLines().item(_i);
for (int _j = 0; _j < secLn.getControls().count(); _j++) {
ctrl = secLn.getControls().item(_j);
for (i = 1; i <= m_paint.getPaintObjects().count(); i++) {
paintObj = m_paint.getPaintObjects().item(i);
if (paintObj.getTag() == ctrl.getKey()) {
m_paint.getPaintObjects().remove(paintObj.getKey());
break;
}
}
}
}
// if this is a group section we need to delete the header and the footer
//
if (isGroupFooter || isGroupHeader) {
if (isGroupHeader) {
for (int _i = 0; _i < m_report.getGroups().count(); _i++) {
group = m_report.getGroups().item(_i);
if (group.getHeader().getKey() == sec.getKey()) { break; }
}
secG = group.getFooter();
}
else if (isGroupFooter) {
for (int _i = 0; _i < m_report.getGroups().count(); _i++) {
group = m_report.getGroups().item(_i);
if (group.getFooter().getKey() == sec.getKey()) { break; }
}
secG = group.getHeader();
}
for (int _i = 0; _i < secG.getSectionLines().count(); _i++) {
secLn = secG.getSectionLines().item(_i);
for (int _j = 0; _j < secLn.getControls().count(); _j++) {
ctrl = secLn.getControls().item(_j);
for (i = 1; i <= m_paint.getPaintObjects().count(); i++) {
paintObj = m_paint.getPaintObjects().item(i);
if (paintObj.getTag() == ctrl.getKey()) {
m_paint.getPaintObjects().remove(paintObj.getKey());
break;
}
}
}
}
for (i = 1; i <= m_paint.getPaintSections().count(); i++) {
paintObj = m_paint.getPaintSections().item(i);
if (paintObj.getTag() == secG.getKey()) {
m_paint.getPaintSections().remove(paintObj.getKey());
break;
}
}
m_report.getGroups().remove(group.getIndex());
}
else {
secs.remove(sec.getKey());
}
}
bool bDeletePaintObj = false;
bDeletePaintObj = true;
if (isSecLn) {
bDeletePaintObj = sec.getKeyPaint() != m_keyFocus;
}
if (bDeletePaintObj) {
m_paint.getPaintSections().remove(m_keyFocus);
// if I have deleted the last section line in this
// section I need to delete the paint object
// asociated with the current last section line
// and then to asociate this section line with
// the paint object of the section
}
else {
cReportSectionLines secLns = sec.getSectionLines();
m_paint.getPaintSections().remove(secLns.item(secLns.count() - 1).getKeyPaint());
secLns.item(secLns.count() - 1).setKeyPaint(sec.getKeyPaint());
}
pResetKeysFocus();
G.redim(ref m_vSelectedKeys, 0);
}
else {
paintObj = m_paint.getPaintObjects().item(m_keyFocus);
if (paintObj == null) { return; }
if (!cWindow.ask("Confirm you want to delete the control? ", VbMsgBoxResult.vbNo)) { return; }
for (i = 1; i <= m_vSelectedKeys.Length; i++) {
paintObj = m_paint.getPaintObjects().item(m_vSelectedKeys[i]);
ctrl = m_report.getControls().item(paintObj.getTag());
m_paint.getPaintObjects().remove(paintObj.getKey());
if (ctrl == null) { return; }
ctrl.getSectionLine().getControls().remove(ctrl.getKey());
}
pResetKeysFocus();
G.redim(ref m_vSelectedKeys, 0);
}
refreshAll();
}