Ejemplo n.º 1
0
void ViewFilesDialog::ForkSelectCommon(ReformatHolder::ReformatPart part)
{
    GenericEntry* pEntry;
    ReformatHolder::ReformatID id;

    LOGI("Switching to file part=%d", part);
    ASSERT(fpHolder != NULL);
    ASSERT(fpSelSet != NULL);
    ASSERT(fpSelSet->IterCurrent() != NULL);
    pEntry = fpSelSet->IterCurrent()->GetEntry();
    ASSERT(pEntry != NULL);

    id = ConfigureFormatSel(part);

    Reformat(pEntry, part, id);
    DisplayText(pEntry->GetDisplayName());
}
Ejemplo n.º 2
0
void ViewFilesDialog::OnFviewPrev(void)
{
    ReformatHolder::ReformatPart part;
    ReformatHolder::ReformatID id;
    int result;

    if (fBusy) {
        LOGI("BUSY!");
        return;
    }

    fBusy = true;

    if (!fpSelSet->IterHasPrev()) {
        ASSERT(false);
        return;
    }

    /*
     * Get the pieces of the file.
     */
    SelectionEntry* pSelEntry = fpSelSet->IterPrev();
    GenericEntry* pEntry = pSelEntry->GetEntry();
    result = ReformatPrep(pEntry);

    fBusy = false;
    if (result != 0) {
        ASSERT(fpHolder == NULL);
        ASSERT(fpOutput == NULL);
        return;
    }

    /*
     * Format a piece.
     */
    ConfigurePartButtons(pEntry);
    part = GetSelectedPart();
    id = ConfigureFormatSel(part);
    Reformat(pEntry, part, id);

    DisplayText(pEntry->GetDisplayName());
}
Ejemplo n.º 3
0
void ViewFilesDialog::OnFormatSelChange(void)
{
    /*
     * The user has changed entries in the format selection drop box.
     *
     * Also called from the "quick change" buttons.
     */

    CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_FVIEW_FORMATSEL);
    ASSERT(pCombo != NULL);
    LOGD("+++ SELECTION IS NOW %d", pCombo->GetCurSel());

    SelectionEntry* pSelEntry = fpSelSet->IterCurrent();
    GenericEntry* pEntry = pSelEntry->GetEntry();
    ReformatHolder::ReformatPart part;
    ReformatHolder::ReformatID id;

    part = GetSelectedPart();
    id = (ReformatHolder::ReformatID) pCombo->GetItemData(pCombo->GetCurSel());
    Reformat(pEntry, part, id);

    DisplayText(pEntry->GetDisplayName());
}
Ejemplo n.º 4
0
HGLOBAL MainWindow::CreateFileCollection(SelectionSet* pSelSet)
{
    SelectionEntry* pSelEntry;
    GenericEntry* pEntry;
    HGLOBAL hGlobal = NULL;
    HGLOBAL hResult = NULL;
    LPVOID pGlobal;
    size_t totalLength, numFiles;
    long priorLength;

    /* get len of text version(s), with kluge to avoid close & reopen */
    priorLength = GetClipboardContentLen() * kClipTextMult;
    /* add some padding -- textmult doesn't work for fixed-size CF_LOCALE */
    priorLength += kWin98NeutralZone;

    totalLength = sizeof(FileCollection);
    numFiles = 0;

    /*
     * Compute the amount of space required to hold it all.
     */
    pSelSet->IterReset();
    pSelEntry = pSelSet->IterNext();
    while (pSelEntry != NULL) {
        pEntry = pSelEntry->GetEntry();
        ASSERT(pEntry != NULL);

        //LOGI("+++ Examining '%s'", pEntry->GetDisplayName());

        if (pEntry->GetRecordKind() != GenericEntry::kRecordKindVolumeDir) {
            totalLength += sizeof(FileCollectionEntry);
            totalLength += (wcslen(pEntry->GetPathNameUNI()) +1) * sizeof(WCHAR);
            numFiles++;
            if (pEntry->GetRecordKind() != GenericEntry::kRecordKindDirectory) {
                totalLength += (long) pEntry->GetDataForkLen();
                totalLength += (long) pEntry->GetRsrcForkLen();
            }
        }

        if (totalLength < 0) {
            DebugBreak();
            LOGI("Overflow");    // pretty hard to do right now!
            return NULL;
        }

        pSelEntry = pSelSet->IterNext();
    }

#if 0
    {
        CString msg;
        msg.Format("totalLength is %ld+%ld = %ld",
            totalLength, priorLength, totalLength+priorLength);
        if (MessageBox(msg, NULL, MB_OKCANCEL) == IDCANCEL)
            goto bail;
    }
#endif

    LOGI("Total length required is %ld + %ld = %ld",
        totalLength, priorLength, totalLength+priorLength);
    if (IsWin9x() && totalLength+priorLength >= kWin98ClipboardMax) {
        CString errMsg;
        errMsg.Format(IDS_CLIPBOARD_WIN9XMAX,
            kWin98ClipboardMax / (1024*1024),
            ((float) (totalLength+priorLength)) / (1024.0*1024.0));
        ShowFailureMsg(this, errMsg, IDS_MB_APP_NAME);
        goto bail;
    }

    /*
     * Create a big buffer to hold it all.
     */
    hGlobal = ::GlobalAlloc(GHND | GMEM_SHARE, totalLength);
    if (hGlobal == NULL) {
        CString errMsg;
        errMsg.Format(L"ERROR: unable to allocate %ld bytes for copy",
            totalLength);
        LOGI("%ls", (LPCWSTR) errMsg);
        ShowFailureMsg(this, errMsg, IDS_FAILED);
        goto bail;
    }
    pGlobal = ::GlobalLock(hGlobal);

    ASSERT(pGlobal != NULL);
    ASSERT(GlobalSize(hGlobal) >= (DWORD) totalLength);
    LOGI("hGlobal=0x%08lx pGlobal=0x%08lx size=%ld",
        (long) hGlobal, (long) pGlobal, GlobalSize(hGlobal));

    /*
     * Set up a progress dialog to track it.
     */
    ASSERT(fpActionProgress == NULL);
    fpActionProgress = new ActionProgressDialog;
    fpActionProgress->Create(ActionProgressDialog::kActionExtract, this);
    fpActionProgress->SetFileName(L"Clipboard");

    /*
     * Extract the data into the buffer.
     */
    long remainingLen;
    void* buf;

    remainingLen = totalLength - sizeof(FileCollection);
    buf = (uint8_t*) pGlobal + sizeof(FileCollection);
    pSelSet->IterReset();
    pSelEntry = pSelSet->IterNext();
    while (pSelEntry != NULL) {
        CString errStr;

        pEntry = pSelEntry->GetEntry();
        ASSERT(pEntry != NULL);

        fpActionProgress->SetArcName(pEntry->GetDisplayName());

        errStr = CopyToCollection(pEntry, &buf, &remainingLen);
        if (!errStr.IsEmpty()) {
            ShowFailureMsg(fpActionProgress, errStr, IDS_MB_APP_NAME);
            goto bail;
        }
        //LOGI("remainingLen now %ld", remainingLen);

        pSelEntry = pSelSet->IterNext();
    }

    ASSERT(remainingLen == 0);
    ASSERT(buf == (uint8_t*) pGlobal + totalLength);

    /*
     * Write the header.
     */
    FileCollection fileColl;
    fileColl.version = kClipVersion;
    fileColl.dataOffset = sizeof(FileCollection);
    fileColl.length = totalLength;
    fileColl.count = numFiles;
    memcpy(pGlobal, &fileColl, sizeof(fileColl));

    /*
     * Success!
     */
    ::GlobalUnlock(hGlobal);

    hResult = hGlobal;
    hGlobal = NULL;

bail:
    if (hGlobal != NULL) {
        ASSERT(hResult == NULL);
        ::GlobalUnlock(hGlobal);
        ::GlobalFree(hGlobal);
    }
    if (fpActionProgress != NULL) {
        fpActionProgress->Cleanup(this);
        fpActionProgress = NULL;
    }
    return hResult;
}