void CSimpleReport::RowDownMulti() { CXTPReportSelectedRows* pRows = GetSelectedRows(); if (!pRows) return; int total = GetRows()->GetCount() - 1; int cnt = pRows->GetCount(); CXTPReportRow* pRow = pRows->GetAt(cnt-1); // 선택 영역의 마지막 row if (!pRow) return; int n = pRow->GetIndex(); if (n >= total) // 더이상 내려갈 수 없음 return; // 마지막 row 뒤에 paste하기 위해 m_bAdd를 true로 만듬. // 그럼 cut후 add가 됨 if (n+1 >= total) m_bAdd = true; // focus는 cut된 시점에서 첫번째로 잡음. pRow = pRows->GetAt(0); n = pRow->GetIndex(); Cut(); // 컷하면 선택된 갯수는 제거되므로 total-cnt가 RowSetFocused(n+1); Paste(); SetFocus(); }
int CSimpleReport::RowGetFocused() { CXTPReportRow* pRow = GetFocusedRow(); if (!pRow) return -1; return pRow->GetIndex(); }
void CXTPReportGroupRow::SetSelectedChilds() { for (int I = 0; I < m_pControl->m_pPlainTree->GetCount(); I++) { CXTPReportRow* pTRow = m_pControl->m_pPlainTree->GetAt(I); if (pTRow) { if (pTRow->IsGroupRow()) { CXTPReportGroupRow* pTgRow = (CXTPReportGroupRow*) pTRow; if (pTgRow->GetChilds(FALSE) && pTgRow->IsExpanded()) { for (int J = 0; J < pTgRow->GetChilds()->GetCount(); J++) { CXTPReportRow* pChRow = pTgRow->GetChilds(FALSE)->GetAt(J); if (pChRow) { CXTPReportRecord* pChRec = pChRow->GetRecord(); if (pChRec) pChRec->m_bSelectedAsChildFlag = pChRow->IsSelected(); } } } } } } }
int CDocStructRecordItem::GetReportAreaRows(CXTPReportControl *pReportControl, int nStartRow, BOOL bMoveDown) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); int nDirection = bMoveDown ? +1 : -1; int top = pReportControl->GetReportRectangle().top; CClientDC dc(pReportControl); int nHeaderWidth = pReportControl->GetReportHeader()->GetWidth(); for (int i = nStartRow; (i < pReportControl->GetRows()->GetCount() && i >= 0); i += nDirection) { CXTPReportRow* pRow = pReportControl->GetRows()->GetAt(i); ASSERT(pRow); if (!pRow) { continue; } int rowHeight = pRow->GetHeight(&dc, nHeaderWidth); if (top + rowHeight > pReportControl->GetReportRectangle().bottom && i + 1 <= pReportControl->GetRows()->GetCount()) { return bMoveDown ? i - nStartRow + 1 : nStartRow - i + 1; } else if (top + rowHeight > pReportControl->GetReportRectangle().bottom) { return bMoveDown ? i - nStartRow : nStartRow - i; } top += rowHeight; } return bMoveDown ? pReportControl->GetRows()->GetCount() - nStartRow : nStartRow; }
void CXTPReportGroupRow::SetSelectedMostDeepChilds() { for (int II = 0; II < m_pControl->GetRows()->GetCount(); II++) { CXTPReportRow* pRow = m_pControl->GetRows()->GetAt(II); if (pRow->GetChilds(FALSE)) continue; CXTPReportRecord* pChRec = pRow->GetRecord(); if (pChRec) pChRec->m_bSelectedAsChildFlag = pRow->IsSelected(); } }
void CSimpleReport::RowSetFocused(CXTPReportRecord* pRec) { CXTPReportRows* pRows = GetRows(); for (int i = 0; i < pRows->GetCount(); i++) { CXTPReportRow* pRow = pRows->GetAt(i); if (pRow->GetRecord() == pRec) { SetFocusedRow(pRow); return; } } }
void CXTPReportGroupRow::UpdateSelectedMostDeepChilds() { for (int II = 0; II < m_pControl->GetRows()->GetCount(); II++) { CXTPReportRow* pRow = m_pControl->GetRows()->GetAt(II); if (pRow->GetChilds(FALSE)) continue; CXTPReportRecord* pChRec = pRow->GetRecord(); if (pChRec) pRow->SetSelected(pChRec->m_bSelectedAsChildFlag); //if (pChRec && !pRow->IsGroupRow()) // pRow->SetSelected(pChRec->m_bSelectedAsChildFlag); //else if (pRow->IsGroupRow()) // pRow->SetSelected(FALSE); } }
void CXTPReportGroupRow::UpdateSelectedMostDeepChilds() { for (int nRow=0; nRow<m_pSection->GetRows()->GetCount(); nRow++) { CXTPReportRow *pRow = m_pSection->GetRows()->GetAt(nRow); if (pRow->GetChilds(FALSE)) continue; CXTPReportRecord *pRecord = pRow->GetRecord(); if (pRecord) { pRow->SetSelected(pRecord->IsSelected()); } } }
void CXTPReportGroupRow::UpdateSelectedChilds() { for (int II = 0; II < m_pSection->m_pTree->GetCount(); II++) { CXTPReportRow* pTRow = m_pSection->m_pTree->GetAt(II); if (pTRow) { if (pTRow->IsGroupRow()) { CXTPReportGroupRow* pTgRow = (CXTPReportGroupRow*) pTRow; if (pTgRow->GetChilds(FALSE) && pTgRow->IsExpanded()) { for (int J = 0; J < pTgRow->GetChilds()->GetCount(); J++) { CXTPReportRow* pChRow = pTgRow->GetChilds(FALSE)->GetAt(J); if (pChRow) { CXTPReportRecord* pChRec = pChRow->GetRecord(); if (pChRec) { CXTPReportRow* ptRow = m_pSection->m_pTree->FindInTree(pChRec); if (ptRow && !ptRow->IsGroupRow()) ptRow->SetSelected(pChRec->IsSelected()); } } } } } } } }
void CSimpleReport::RowUpMulti() { // 한꺼번에 여러개를 올림 CXTPReportSelectedRows* pRows = GetSelectedRows(); if (!pRows) return; CXTPReportRow* pRow = pRows->GetAt(0); if (!pRow) return; int n = pRow->GetIndex(); if (n == 0) // 더이상 올라갈 수 없음 return; Cut(); RowSetFocused(n-1); Paste(); SetFocus(); }
void CXTPReportIconNavigator::BeginEdit() { if (!m_pReportControl) return; CXTPReportRow* pFocusedRow = m_pReportControl->GetFocusedRow(); if (!pFocusedRow) return; CXTPReportColumn* pIconColumn = m_pReportControl->GetColumns()->Find(m_pReportControl->m_iIconViewColumn); if (pIconColumn && pFocusedRow && pFocusedRow->GetRecord()) { XTP_REPORTRECORDITEM_ARGS itemArgs(m_pReportControl, pFocusedRow, pIconColumn); if (itemArgs.pItem && itemArgs.pItem->IsAllowEdit(&itemArgs)) m_pReportControl->EditItem(&itemArgs); } }
void CSimpleReport::RowInsert(CXTPReportRecord* pRec, bool bAdd) { if (!pRec) return; CXTPReportRow* pRow = GetFocusedRow(); if (bAdd) { pRec = GetRecords()->Add(pRec); // 맨 뒤에 추가 } else { if (pRow != NULL) { int n = pRow->GetRecord()->GetIndex(); GetRecords()->InsertAt(n, pRec); } else { // 데이터 처음으로 넣음 pRec = GetRecords()->Add(pRec); } } Populate(); RowSetFocused(pRec); }
BOOL CXTPReportGroupRow::CalculateByChilds(CXTPReportRow* pPassedRow, int col_start, int col_end, double& dPassedValue) { BOOL bRet = FALSE; CXTPReportRow* pRow = NULL; CXTPReportRecord* pRec = NULL; CXTPReportRecordItem* pItem = NULL; for (int row = 0; row < pPassedRow->GetChilds(FALSE)->GetCount(); row++) { pRow = pPassedRow->GetChilds(FALSE)->GetAt(row); if (pRow && !pRow->IsGroupRow()) { pRec = pRow->GetRecord(); if (pRec) { bRet = TRUE; for (int col = col_start; col < col_end; col++) { if (col < pRec->GetItemCount()) { pItem = pRec->GetItem(col); if (pItem) { CString s = pItem->GetCaption(NULL); dPassedValue += pItem->StringToDouble(s); } } } } } else if (pRow && pRow->IsGroupRow()) { bRet = CalculateByChilds(pRow, col_start, col_end, dPassedValue); } } return bRet; }
void CXTPReportIconNavigator::MoveUpStep(BOOL bShiftKey, BOOL bControlKey) { if (!m_pReportControl) return; if (m_pReportControl->IsMultiSelectionMode()) bControlKey = TRUE; CXTPReportRow* pPrevRow = NULL; CXTPReportRow* pFocusedRow = m_pReportControl->GetFocusedRow(); if (!pFocusedRow) return; if (m_pReportControl->IsIconView()) { int iPrevRowIndex = -1; int iFocusRow = pFocusedRow->GetIndex(); // body rows pPrevRow = m_pReportControl->GetRows()->GetPrev(pFocusedRow, m_pReportControl->IsSkipGroupsFocusEnabled()); if (pPrevRow) { if (pPrevRow && pPrevRow->GetIndex() != iPrevRowIndex) { // from the first body row jump to the last header row if (iFocusRow <= pPrevRow->GetIndex()) { if (m_pReportControl->IsHeaderRowsVisible() && m_pReportControl->IsHeaderRowsAllowAccess()) MoveLastVisibleRow(xtpRowTypeHeader); } else { m_pReportControl->SetFocusedRow(pPrevRow, bShiftKey, bControlKey); } } } } }
void CXTPReportIconNavigator::MoveDown(BOOL bShiftKey, BOOL bControlKey) { if (!m_pReportControl) return; if (m_pReportControl->IsMultiSelectionMode()) bControlKey = TRUE; CXTPReportRow* pNextRow = NULL; CXTPReportRow* pFocusedRow = m_pReportControl->GetFocusedRow(); if (!pFocusedRow) return; int iPrevRowIndex = -1; int iFocusRow = pFocusedRow->GetIndex(); int nRpL = m_pReportControl->GetRowsPerLine(); int iRowOffset = iFocusRow % nRpL; // body rows pNextRow = m_pReportControl->GetRows()->GetNext(pFocusedRow, m_pReportControl->IsSkipGroupsFocusEnabled()); if (pNextRow) { while( pNextRow && pNextRow->GetIndex() != iPrevRowIndex && iRowOffset != pNextRow->GetIndex() % nRpL) { iPrevRowIndex = pNextRow->GetIndex(); pNextRow = m_pReportControl->GetRows()->GetNext(pNextRow, m_pReportControl->IsSkipGroupsFocusEnabled()); } if (pNextRow && pNextRow->GetIndex() != iPrevRowIndex) { // from the last body row jump to the first header row if (iFocusRow >= pNextRow->GetIndex()) { if (m_pReportControl->IsFooterRowsVisible() && m_pReportControl->IsFooterRowsAllowAccess()) MoveFirstVisibleRow(xtpRowTypeFooter); } else { m_pReportControl->SetFocusedRow(pNextRow, bShiftKey, bControlKey); } } } }
int CDocStructRecordItem::Draw(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (pDrawArgs->pDC == NULL || pDrawArgs->pControl == NULL || pDrawArgs->pRow == NULL || pDrawArgs->pItem == NULL) { ASSERT(FALSE); return 0; } int offSet = 0; CDC* pDC = pDrawArgs->pDC; int nTreeDepth = pDrawArgs->pRow->GetTreeDepth(); int nLeftIndent = pDrawArgs->pControl->GetIndent(nTreeDepth); CRect rcRow = pDrawArgs->pRow->GetRect(); nTreeDepth == 0 ? offSet = 0 : offSet = 0; CXTPOffice2007Image *pImage = XTPOffice2007Images()->LoadFile(_T("PUSHBUTTON")); ASSERT(pImage); int nState = 0; if (pDrawArgs->pRow->IsSelected() == TRUE) { nState = 2; } CDocStructRecord* pRecord = (CDocStructRecord*)GetRecord(); if (pRecord) { int nCurrentLayout = pRecord->m_nCurrentLayout; if (nCurrentLayout == DocumentStructureLayout(Thumbnail)) { rcRow.left += nTreeDepth * TREE_DEPTH_OFFSET; rcRow.top += 2; rcRow.bottom -= 2; rcRow.right -= nTreeDepth * TREE_DEPTH_OFFSET; } else { rcRow.left += 0; //nLeftIndent + offSet; } if (pImage) { // Draw a blue rectangle that surrounds all child items to show that an item is part of a group. if (nCurrentLayout == DocumentStructureLayout(Thumbnail) && pDrawArgs->pRow->GetParentRow() != NULL) { int nTopRow = pDrawArgs->pControl->GetTopRowIndex(); int nVisibleRows = GetReportAreaRows(pDrawArgs->pControl, pDrawArgs->pControl->GetTopRowIndex(), TRUE); CXTPReportRow *pTopRow = pDrawArgs->pControl->GetRows()->GetAt(nTopRow); if (pTopRow != NULL) { if (pTopRow->GetTreeDepth() > 1 && pTopRow == pDrawArgs->pRow) { for (int i = 1; i < pTopRow->GetTreeDepth(); i++) { int iExpandedChildsHeight = GetExpandedChildsHeight(pDrawArgs->pControl, pDrawArgs->pRow->GetParentRow()->GetRecord()); CRect rcParentRect(pTopRow->GetRect()); bool bReset = false; for (int j = nTopRow; j < nTopRow + nVisibleRows ; j++) { int iRowLevel = pDrawArgs->pControl->GetRows()->GetAt(j)->GetTreeDepth(); if (iRowLevel >= i+1) { if (bReset == false) { iExpandedChildsHeight = 0; bReset = true; } iExpandedChildsHeight += pDrawArgs->pControl->GetPaintManager()->GetRowHeight(NULL, pDrawArgs->pControl->GetRows()->GetAt(j)); } else { break; } } rcParentRect.bottom = iExpandedChildsHeight < pDrawArgs->pControl->GetReportRectangle().bottom ? iExpandedChildsHeight : pDrawArgs->pControl->GetReportRectangle().bottom + 2; rcParentRect.left += i * TREE_DEPTH_OFFSET; rcParentRect.right -= i * TREE_DEPTH_OFFSET; pImage->DrawImage(pDC, rcParentRect, pImage->GetSource(0, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } } } } // Draw an orange/blue image over item. if ((nCurrentLayout == DocumentStructureLayout(Thumbnail)) ||((nCurrentLayout == DocumentStructureLayout(Compact)) && nState == 2)) { if (pRecord->IsPage()) { pImage->DrawImage(pDC, rcRow, pImage->GetSource(nState, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } else { // take tree depth and draw button images of tree depth size. CRect newRowOffset(rcRow); if (pDrawArgs->pRow->GetTreeDepth() != 0 && nCurrentLayout == DocumentStructureLayout(Thumbnail)) { newRowOffset.bottom += GetExpandedChildsHeight(pDrawArgs->pControl, pDrawArgs->pRow->GetRecord()); if ( pDrawArgs->pRow->IsExpanded() == TRUE ) { newRowOffset.bottom += 1; } pImage->DrawImage(pDC, newRowOffset, pImage->GetSource(0, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } if (pDrawArgs->pRow->GetTreeDepth() == 0) { pImage->DrawImage(pDC, rcRow, pImage->GetSource(nState, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } if (nState == 2) { pImage->DrawImage(pDC, rcRow, pImage->GetSource(nState, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } } } } pDC->SetBkMode(TRANSPARENT); if (nCurrentLayout == DocumentStructureLayout(Thumbnail) && pRecord->IsPage()) { int x = rcRow.left + RECORD_ITEM_OFFSET; int y = rcRow.top + RECORD_ITEM_OFFSET; int nWidth = rcRow.Width() - 2*RECORD_ITEM_OFFSET; int nHeight = nWidth * 3/4; if (nWidth > rcRow.Width()) { nWidth = rcRow.Width(); } CRect rcThumb; rcThumb.SetRect(x, y, x + nWidth, y + nHeight); if (pRecord->m_pContainer != NULL) { pRecord->m_pContainer->DrawThumbWhiteboard(pRecord->m_pvData, rcThumb, pDC); } } } // Code taken from CXTPReportControlItem::Draw - but a bit modified m_pControl = pDrawArgs->pControl; CRect& rcItem = pDrawArgs->rcItem; CXTPReportPaintManager* pPaintManager = pDrawArgs->pControl->GetPaintManager(); CRgn rgn; rgn.CreateRectRgn(rcItem.left, rcItem.top - 1, rcItem.right, rcItem.bottom); if (!pDC->IsPrinting()) { pDC->SelectClipRgn(&rgn); } XTP_REPORTRECORDITEM_METRICS* pMetrics = new XTP_REPORTRECORDITEM_METRICS(); pMetrics->strText = GetCaption(pDrawArgs->pColumn); pDrawArgs->pRow->GetItemMetrics(pDrawArgs, pMetrics); ASSERT(pMetrics->pFont); ASSERT(pMetrics->clrForeground != XTP_REPORT_COLOR_DEFAULT); int nItemGlyphs = rcItem.left; // draw tree inside item rect (see also HitTest function) if (pDrawArgs->pColumn && pDrawArgs->pColumn->IsTreeColumn()) { int nTreeDepth = pDrawArgs->pRow->GetTreeDepth() - pDrawArgs->pRow->GetGroupLevel(); if (nTreeDepth > 0) { nTreeDepth++; } rcItem.left += pDrawArgs->pControl->GetIndent(nTreeDepth); BOOL bHasChildren = pDrawArgs->pControl->IsVirtualMode() ? pDrawArgs->pRow->GetTreeDepth() == 0 && (pMetrics->nVirtRowFlags & xtpVirtRowHasChildren) : pDrawArgs->pRow->HasChildren(); CRect rcBitmap(rcItem); CSize sizeBitmap = pPaintManager->DrawCollapsedBitmap(NULL, pDrawArgs->pRow, rcBitmap); int nIconAlign = pDrawArgs->nTextAlign & xtpColumnIconMask; // horizontal alignment switch (nIconAlign) { case xtpColumnIconRight: rcBitmap.left = rcBitmap.right - sizeBitmap.cx - 2; break; case xtpColumnIconLeft: rcBitmap.right = rcBitmap.left + sizeBitmap.cx + 2; break; } // vertical alignment switch (nIconAlign) { case xtpColumnIconTop: rcBitmap.bottom = rcBitmap.top + sizeBitmap.cy + 2; break; case xtpColumnIconBottom: rcBitmap.top = rcBitmap.bottom - sizeBitmap.cy - 2; break; } bool bDrawArrow = false; if (bHasChildren || (pRecord->IsDocument() && !pRecord->IsEmptyDocument())) { bDrawArrow = true; } if (pRecord->IsDocument() && !pRecord->IsLoadedDocument()) { pDrawArgs->pRow->SetExpanded(FALSE); } sizeBitmap = pPaintManager->DrawCollapsedBitmap(bDrawArrow ? pDC : NULL, pDrawArgs->pRow, rcBitmap); if (!pDC->IsPrinting() && bHasChildren) { pDrawArgs->pRow->SetCollapseRect(rcBitmap); } // Draw a custom image at the left side of the record item if (pPaintManager->GetRuntimeClass() == RUNTIME_CLASS(CXTPDocumentStructurePaintManager)) { if (pRecord->IsChapter() || pRecord->IsDocument()) { CRect rcBitmap(rcItem); if (((CDocStructRecord*) pDrawArgs->pRow->GetRecord())->m_nCurrentLayout == DocumentStructureLayout(Thumbnail)) { rcBitmap.left += 15; rcBitmap.top -= 5; CSize csBitmap = ((CXTPDocumentStructurePaintManager*)pPaintManager)->DrawCustomBitmap(pDC, pDrawArgs->pRow, rcBitmap, m_nImageIndex); rcItem.left += sizeBitmap.cx + 35; } else { rcBitmap.left += 18; CSize csBitmap = ((CXTPDocumentStructurePaintManager*)pPaintManager)->DrawCustomBitmap(pDC, pDrawArgs->pRow, rcBitmap, m_nImageIndex); rcItem.left += sizeBitmap.cx + 25; } } else { if (((CDocStructRecord*) pDrawArgs->pRow->GetRecord())->m_nCurrentLayout == DocumentStructureLayout(Compact)) { rcBitmap.left += 15; CSize csBitmap = ((CXTPDocumentStructurePaintManager*)pPaintManager)->DrawCustomBitmap(pDC, pDrawArgs->pRow, rcBitmap, m_nImageIndex); rcItem.left += sizeBitmap.cx + 10; } rcItem.left += sizeBitmap.cx + 2; } } } COLORREF clrText = XTPOffice2007Images()->GetImageColor(_T("LISTBOX"), _T("NormalText")); pDC->SetTextColor(clrText); CFont* pOldFont = (CFont*)pDC->SelectObject(pMetrics->pFont); if (pMetrics->clrBackground != XTP_REPORT_COLOR_DEFAULT) { pDC->SetBkColor(pMetrics->clrBackground); } else { pDC->SetBkColor(pPaintManager->m_clrControlBack); } if (m_bHasCheckbox) { DrawCheckBox(pDrawArgs, rcItem); } // Do the draw bitmap pDC, rcItem, GetIconIndex() if (pMetrics->nItemIcon != XTP_REPORT_NOICON || GetIconIndex() != XTP_REPORT_NOICON) { pPaintManager->DrawItemBitmap(pDrawArgs, rcItem, pMetrics->nItemIcon != XTP_REPORT_NOICON ? pMetrics->nItemIcon : GetIconIndex()); } nItemGlyphs = (rcItem.left - nItemGlyphs); OnDrawControls(pDrawArgs, rcItem); if (rcItem.Width()) { OnDrawCaption(pDrawArgs, pMetrics); } int nItemTextWidth = nItemGlyphs + 7; if (m_pMarkupUIElement) { nItemTextWidth += XTPMarkupMeasureElement(m_pMarkupUIElement, rcItem.Width(), INT_MAX).cx; } else { nItemTextWidth += pDC->GetTextExtent(pMetrics->strText).cx; } pDC->SelectObject(pOldFont); pMetrics->InternalRelease(); if (!pDC->IsPrinting()) { pDC->SelectClipRgn(NULL); } return nItemTextWidth; }
void CXTPReportSelectedRows::SelectBlock(int nBlockBegin, int nEnd, BOOL bControlKey) { CXTPReportRows* pRows; switch(m_nRowType) { case xtpRowTypeHeader : pRows = m_pControl->GetHeaderRows(); break; case xtpRowTypeFooter : pRows = m_pControl->GetFooterRows(); break; default : pRows = m_pControl->GetRows(); break; } int nRowsCount(0); if (pRows) nRowsCount = pRows->GetCount(); BOOL bGo = (nBlockBegin >= 0 && nBlockBegin < nRowsCount && nEnd < nRowsCount); if (!bGo) { Clear(GetNotifyOnSelectedRowsClear()); return; } if (bControlKey == FALSE) { nBlockBegin = m_nRowBlockBegin != -1 ? m_nRowBlockBegin : nBlockBegin; int nBegin = nBlockBegin; if (nBegin == -1 || nEnd == -1) return; if (nBegin > nEnd) { nBegin = nEnd; nEnd = nBlockBegin; } if (m_arrSelectedBlocks.GetSize() == 1 && m_arrSelectedBlocks[0].nIndexBegin == nBegin && m_arrSelectedBlocks[0].nIndexEnd == nEnd + 1) { return; } XTPReportRowType nRowType = m_nRowType; Clear(GetNotifyOnSelectedRowsClear()); m_nRowType = nRowType; if (m_nRowBlockBegin == -1) m_nRowBlockBegin = nBlockBegin; BOOL bSkipGroupFocus = m_pControl->IsSkipGroupsFocusEnabled(); BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0; if (!bHasGroups || !bSkipGroupFocus) { _InsertBlock(0, nBegin, nEnd + 1); } else { for (int i = nBegin; i <= nEnd; i++) { CXTPReportRow* pRow = pRows->GetAt(i); if (!pRow) continue; if (!bSkipGroupFocus || !pRow->IsGroupRow() || !pRow->IsExpanded() || (i == nBegin) || (i == nEnd)) { Add(pRow); } } } // notify owner the selection state has changed. _NotifyStateChanged(nBegin, nEnd); } else { int kSB = (int) m_arrSelectedBlocks.GetSize(); if (kSB > 0) { int iMin = m_arrSelectedBlocks[0].nIndexBegin; int iMax = m_arrSelectedBlocks[kSB - 1].nIndexEnd; if (nEnd >= iMin && nEnd < iMax) { return; } } BOOL bSkipGroupFocus = FALSE;//m_pControl->IsSkipGroupsFocusEnabled(); BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0; BOOL bWasShiftKey = m_pControl->m_bWasShiftKey; if (m_nRowBlockBegin != -1) nBlockBegin = m_nRowBlockBegin; int nBegin(nBlockBegin), iB, iE; if (nBegin == -1 || nEnd == -1) { return; } BOOL bSwap = SwapIfNeed(nBegin, nEnd); int nArSz = (int) m_arrSelectedBlocks.GetSize(); CUIntArray ar; if (nArSz > 0) { for (int k = 0; k < nArSz; k++) { int iB = m_arrSelectedBlocks[nArSz - 1 - k].nIndexBegin; int iE = m_arrSelectedBlocks[nArSz - 1 - k].nIndexEnd; if (iE == iB + 1 && iB == 0) k++; //this fix a case of initial selection from any row to any row with SHIFT+CONTROL pressed if (k < nArSz) { ar.Add(m_arrSelectedBlocks[k].nIndexBegin); ar.Add(m_arrSelectedBlocks[k].nIndexEnd); } } } XTPReportRowType nRowType = m_nRowType; Clear(GetNotifyOnSelectedRowsClear()); m_nRowType = nRowType; if (m_nRowBlockBegin == -1) m_nRowBlockBegin = nBlockBegin; if (!bHasGroups || !bSkipGroupFocus) //<<>> { int k = 0; int N = (int) ar.GetSize(); if (N > 0 && bControlKey && !bWasShiftKey) { for (k = 0; k < N / 2; k++) { iB = ar.GetAt(2 * k); iE = ar.GetAt(2 * k + 1); if (iE < nBegin || iB > nEnd) { _InsertBlock(k, iB, iE); } else if (iB >= nBegin && iE <= nEnd) //skip [iB:iE] segment - totally covered { } else if (iB <= nBegin && iE <= nEnd) //skip [iB:iE] segment amd modify new segment { nBegin = iB; } else if (iB <= nBegin && iE > nEnd) //skip [iB:iE] segment amd modify new segment { nBegin = iB; nEnd = iE; } else if (iB >= nBegin && iE > nEnd) //skip [iB:iE] segment amd modify new segment { nEnd = iE; } else { } } if (bSwap) { _InsertBlock(0, nBegin, nEnd); } else { _InsertBlock(k, nEnd + 1, nBegin); } } else { _InsertBlock(0, nBegin, nEnd + 1); } CUIntArray aDel; for (int l = 0; l < m_arrSelectedBlocks.GetSize(); l++) { if (m_arrSelectedBlocks[l].nIndexBegin == m_arrSelectedBlocks[l].nIndexEnd) aDel.Add(l); } for (int ll = 0; ll < aDel.GetSize(); ll++) m_arrSelectedBlocks.RemoveAt(aDel.GetAt(ll)); } else { for (int i = nBegin; i <= nEnd; i++) { CXTPReportRow* pRow = pRows->GetAt(i); if (!pRow) continue; if (!pRow->IsGroupRow() || !bSkipGroupFocus || !pRow->IsExpanded() || i == nBegin || i == nEnd) Add(pRow); } } // notify owner the selection state has changed. _NotifyStateChanged(nBegin, nEnd); } if (m_pControl->m_bSelectionExcludeGroupRows) m_pControl->UnselectGroupRows(); //to show only selected childs under group rows //flag - m_bSelectionExcludeGroupRows default = TRUE - this is 12.1 way to show selection TRACE(_T("return from SelectBlock with Count=%d\n"), GetCount()); }
bool CSimpleReport::doCutPaste(CPoint pt, int op) { CXTPReportSelectedRows* pRows = GetSelectedRows(); if (pRows == NULL) return false; CXTPReportRow* pRow = pRows->GetAt(0); int nRow = 0; if (pRow) nRow = pRows->GetAt(0)->GetIndex(); int n; CMenu menu; if (!menu.CreatePopupMenu()) return false; if ((op & DO_ADD) != 0) { menu.AppendMenu(MF_STRING, 10, "Add New"); menu.AppendMenu(MF_STRING, 13, "Insert"); } if (CanCopy() && (op & DO_COPY) != 0) menu.AppendMenu(MF_STRING, 11, "Copy"); if (CanCut() && (op & DO_CUT) != 0) menu.AppendMenu(MF_STRING, 12, "Delete"); n = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, pt.x, pt.y, this); menu.DestroyMenu(); switch (n) { case 10: // add case 13: // insert { CXTPReportRecord* pRec = newRec(); if (callback_add) { if (!callback_add(this, pRec)) { delete pRec; return false; } } RowInsert(pRec, (n == 10)); } break; case 11: // copy { pRow = GetFocusedRow(); if (!pRow) return false; CXTPReportRecord* pSource = pRow->GetRecord(); CXTPReportRecord* pTarget = newRec(); if (callback_copy) { if (!callback_copy(this, pSource, pTarget)) { delete pTarget; return false; } } RowInsert(pTarget); } break; case 12: // delete { n = pRows->GetCount(); for (int i = 0; i < n; i++) { if (callback_del) { CXTPReportRecord* pRec = pRows->GetAt(i)->GetRecord(); if (!callback_del(this, pRec)) { return false; } } } for (int i = n - 1; i >= 0; i--) { pRow = pRows->GetAt(i); GetRecords()->RemoveAt(pRow->GetRecord()->GetIndex()); } Populate(); RowSetFocused(nRow); } break; default: return false; } return true; }
void CSimpleReport::Paste() { if (IsVirtualMode()) return; CWaitCursor _WC; CLIPFORMAT uCF_Records = (CLIPFORMAT)::RegisterClipboardFormat(XTPREPORTCTRL_CF_RECORDS); CXTPReportRecords arRecords; BOOL bTryPasteFromText = TRUE; // Retrieve text from the clipboard if (!OpenClipboard()) return; if (::IsClipboardFormatAvailable(uCF_Records)) { HGLOBAL hPasteData = ::GetClipboardData(uCF_Records); if (hPasteData) { bTryPasteFromText = FALSE; const int cErrTextSize = 1024; TCHAR szErrText[cErrTextSize + 1]; CSharedFile fileSahred; fileSahred.SetHandle(hPasteData, FALSE); CArchive ar(&fileSahred, CArchive::load); try { CXTPPropExchangeArchive px(ar); BOOL bread = FALSE; #if _XTPLIB_VERSION_PREFIX == 1502 bread = _ReadRecordsFromData(&px, arRecords); #else bread = _ReadRecodsFromData(&px, arRecords); #endif if (!bread) { arRecords.RemoveAll(); } } catch(CArchiveException* pE) { if (pE->GetErrorMessage(szErrText, cErrTextSize)) { TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - %s\n"), szErrText); } pE->Delete(); } catch(CFileException* pE) { if (pE->GetErrorMessage(szErrText, cErrTextSize)) { TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - %s\n"), szErrText); } pE->Delete(); } catch(...) { TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - Unhandled Exception!\n")); } //********* ar.Close(); // detach from file fileSahred.Detach(); //detach from data ::GlobalUnlock(hPasteData); // unlock data } } UINT uCF_TText = sizeof(TCHAR) == 2 ? CF_UNICODETEXT : CF_TEXT; if (bTryPasteFromText && ::IsClipboardFormatAvailable(uCF_TText)) { // Try to get text data from the clipboard HGLOBAL hglbPaste = ::GetClipboardData(uCF_TText); // Import Text data into the control if (hglbPaste != NULL) { TCHAR* lpszClipboard = (TCHAR*)GlobalLock(hglbPaste); BOOL bRead = FALSE; #if _XTPLIB_VERSION_PREFIX == 1502 bRead = _ReadRecordsFromText(lpszClipboard, arRecords); #else bRead = _ReadRecodsFromText(lpszClipboard, arRecords); #endif if (!bRead) { arRecords.RemoveAll(); } ::GlobalUnlock(hglbPaste); } } ::CloseClipboard(); ////////////////////////////////////////////////////////////////////////// CUpdateContext updateContext(this); // Add and Populate records CXTPReportRow* pRow = GetFocusedRow(); if (pRow == NULL) return; int n = pRow->GetRecord()->GetIndex(); int nRecordsCount = arRecords.GetCount(); if (nRecordsCount > 0) { for (int i = nRecordsCount - 1; i >= 0; i--) { CXTPReportRecord* pRecord = arRecords.GetAt(i); if (pRecord) { CMDTARGET_ADDREF(pRecord); if (m_bAdd) GetRecords()->Add(arRecords.GetAt(i)); else GetRecords()->InsertAt(n, arRecords.GetAt(i)); } } Populate(); _SelectRows(&arRecords); } m_bAdd = false; }
void CSimpleReport::RowSetSelected(int nRow) { CXTPReportRow* pRow = GetRows()->GetAt(nRow); if (pRow) pRow->SetSelected(TRUE); }