Ejemplo n.º 1
0
// returns a list of permissions denied by this document
// Caller needs to free the result
static WCHAR *FormatPermissions(Doc doc)
{
    if (!doc.IsEngine())
        return NULL;

    WStrVec denials;

    if (!doc.AsEngine()->AllowsPrinting())
        denials.Push(str::Dup(_TR("printing document")));
    if (!doc.AsEngine()->AllowsCopyingText())
        denials.Push(str::Dup(_TR("copying text")));

    return denials.Join(L", ");
}
Ejemplo n.º 2
0
// returns a list of permissions denied by this document
// Caller needs to free the result
static WCHAR *FormatPermissions(Controller *ctrl)
{
    if (!ctrl->AsFixed())
        return nullptr;

    WStrVec denials;

    BaseEngine *engine = ctrl->AsFixed()->GetEngine();
    if (!engine->AllowsPrinting())
        denials.Push(str::Dup(_TR("printing document")));
    if (!engine->AllowsCopyingText())
        denials.Push(str::Dup(_TR("copying text")));

    return denials.Join(L", ");
}
Ejemplo n.º 3
0
void CopySelectionToClipboard(WindowInfo* win) {
    if (!win->currentTab || !win->currentTab->selectionOnPage)
        return;
    CrashIf(win->currentTab->selectionOnPage->size() == 0 && win->mouseAction != MouseAction::SelectingText);
    if (win->currentTab->selectionOnPage->size() == 0)
        return;
    CrashIf(!win->AsFixed());
    if (!win->AsFixed())
        return;

    if (!OpenClipboard(nullptr))
        return;
    EmptyClipboard();

    DisplayModel* dm = win->AsFixed();
#ifndef DISABLE_DOCUMENT_RESTRICTIONS
    if (!dm->GetEngine()->AllowsCopyingText())
        win->ShowNotification(_TR("Copying text was denied (copying as image only)"));
    else
#endif
        if (!dm->GetEngine()->IsImageCollection()) {
        AutoFreeW selText;
        bool isTextSelection = dm->textSelection->result.len > 0;
        if (isTextSelection) {
            selText.Set(dm->textSelection->ExtractText(L"\r\n"));
        } else {
            WStrVec selections;
            for (SelectionOnPage& sel : *win->currentTab->selectionOnPage) {
                WCHAR* text = dm->GetTextInRegion(sel.pageNo, sel.rect);
                if (text)
                    selections.Push(text);
            }
            selText.Set(selections.Join());
        }

        // don't copy empty text
        if (!str::IsEmpty(selText.Get()))
            CopyTextToClipboard(selText, true);

        if (isTextSelection) {
            // don't also copy the first line of a text selection as an image
            CloseClipboard();
            return;
        }
    }

    /* also copy a screenshot of the current selection to the clipboard */
    SelectionOnPage* selOnPage = &win->currentTab->selectionOnPage->at(0);
    RenderedBitmap* bmp = dm->GetEngine()->RenderBitmap(selOnPage->pageNo, dm->GetZoomReal(), dm->GetRotation(),
                                                        &selOnPage->rect, RenderTarget::Export);
    if (bmp)
        CopyImageToClipboard(bmp->GetBitmap(), true);
    delete bmp;

    CloseClipboard();
}
Ejemplo n.º 4
0
void CopySelectionToClipboard(WindowInfo *win)
{
    if (!win->selectionOnPage) return;
    CrashIf(win->selectionOnPage->Count() == 0);
    if (win->selectionOnPage->Count() == 0) return;
    CrashIf(!win->dm || !win->dm->engine);
    if (!win->dm || !win->dm->engine) return;

    if (!OpenClipboard(NULL)) return;
    EmptyClipboard();

#ifndef DISABLE_DOCUMENT_RESTRICTIONS
    if (!win->dm->engine->AllowsCopyingText())
        ShowNotification(win, _TR("Copying text was denied (copying as image only)"));
    else
#endif
    if (!win->dm->engine->IsImageCollection()) {
        ScopedMem<WCHAR> selText;
        bool isTextSelection = win->dm->textSelection->result.len > 0;
        if (isTextSelection) {
            selText.Set(win->dm->textSelection->ExtractText(L"\r\n"));
        }
        else {
            WStrVec selections;
            for (size_t i = 0; i < win->selectionOnPage->Count(); i++) {
                SelectionOnPage *selOnPage = &win->selectionOnPage->At(i);
                WCHAR *text = win->dm->GetTextInRegion(selOnPage->pageNo, selOnPage->rect);
                if (text)
                    selections.Push(text);
            }
            selText.Set(selections.Join());
        }

        // don't copy empty text
        if (!str::IsEmpty(selText.Get()))
            CopyTextToClipboard(selText, true);

        if (isTextSelection) {
            // don't also copy the first line of a text selection as an image
            CloseClipboard();
            return;
        }
    }

    /* also copy a screenshot of the current selection to the clipboard */
    SelectionOnPage *selOnPage = &win->selectionOnPage->At(0);
    RenderedBitmap * bmp = win->dm->engine->RenderBitmap(selOnPage->pageNo,
        win->dm->ZoomReal(), win->dm->Rotation(), &selOnPage->rect, Target_Export);
    if (bmp)
        CopyImageToClipboard(bmp->GetBitmap(), true);
    delete bmp;

    CloseClipboard();
}
Ejemplo n.º 5
0
static WCHAR *FormatPdfFileStructure(Doc doc)
{
    ScopedMem<WCHAR> fstruct(doc.GetProperty(Prop_PdfFileStructure));
    if (str::IsEmpty(fstruct.Get()))
        return NULL;
    WStrVec parts;
    parts.Split(fstruct, L",", true);
    
    WStrVec props;

    if (parts.Find(L"linearized") != -1)
        props.Push(str::Dup(_TR("Fast Web View")));
    if (parts.Find(L"tagged") != -1)
        props.Push(str::Dup(_TR("Tagged PDF")));
    if (parts.Find(L"PDFX") != -1)
        props.Push(str::Dup(L"PDF/X (ISO 15930)"));
    if (parts.Find(L"PDFA1") != -1)
        props.Push(str::Dup(L"PDF/A (ISO 19005)"));
    if (parts.Find(L"PDFE1") != -1)
        props.Push(str::Dup(L"PDF/E (ISO 24517)"));

    return props.Join(L", ");
}
Ejemplo n.º 6
0
static WCHAR *FormatPdfFileStructure(Controller *ctrl)
{
    ScopedMem<WCHAR> fstruct(ctrl->GetProperty(Prop_PdfFileStructure));
    if (str::IsEmpty(fstruct.Get()))
        return nullptr;
    WStrVec parts;
    parts.Split(fstruct, L",", true);

    WStrVec props;

    if (parts.Contains(L"linearized"))
        props.Push(str::Dup(_TR("Fast Web View")));
    if (parts.Contains(L"tagged"))
        props.Push(str::Dup(_TR("Tagged PDF")));
    if (parts.Contains(L"PDFX"))
        props.Push(str::Dup(L"PDF/X (ISO 15930)"));
    if (parts.Contains(L"PDFA1"))
        props.Push(str::Dup(L"PDF/A (ISO 19005)"));
    if (parts.Contains(L"PDFE1"))
        props.Push(str::Dup(L"PDF/E (ISO 24517)"));

    return props.Join(L", ");
}