2017-11-04 21:05:25 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_PRINTTARGETEMF_H
|
|
|
|
#define MOZILLA_GFX_PRINTTARGETEMF_H
|
|
|
|
|
|
|
|
#include "PrintTargetSkPDF.h"
|
2017-11-04 22:06:04 +03:00
|
|
|
#include "mozilla/ipc/Shmem.h"
|
2017-11-04 21:05:25 +03:00
|
|
|
|
|
|
|
/* include windows.h for the HDC definitions that we need. */
|
|
|
|
#include <windows.h>
|
|
|
|
|
2017-11-29 12:15:31 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace widget {
|
|
|
|
class PDFiumProcessParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-04 21:05:25 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gfx {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A new subclass of PrintTarget.
|
|
|
|
* 1. It uses PrintTargetSkPDF to generate one PDF file for one page.
|
|
|
|
* 2. It then passes the FileDescriptor of that generated PDF file to the
|
|
|
|
* PDFium process for EMF conversion.
|
|
|
|
* 3. After getting the converted EMF contents from the PDFium process, it then
|
|
|
|
* draws it onto the printer DC to finish one page printing task.
|
|
|
|
*/
|
|
|
|
class PrintTargetEMF final : public mozilla::gfx::PrintTarget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef gfx::IntSize IntSize;
|
2017-11-29 12:15:31 +03:00
|
|
|
typedef mozilla::widget::PDFiumProcessParent PDFiumProcessParent;
|
2017-11-04 21:05:25 +03:00
|
|
|
|
|
|
|
static already_AddRefed<PrintTargetEMF>
|
|
|
|
CreateOrNull(HDC aDC, const IntSize& aSizeInPoints);
|
|
|
|
|
|
|
|
nsresult BeginPrinting(const nsAString& aTitle,
|
|
|
|
const nsAString& aPrintToFileName,
|
|
|
|
int32_t aStartPage,
|
2018-02-06 09:46:57 +03:00
|
|
|
int32_t aEndPage) final;
|
|
|
|
nsresult EndPrinting() final;
|
|
|
|
nsresult AbortPrinting() final;
|
|
|
|
nsresult BeginPage() final;
|
|
|
|
nsresult EndPage() final;
|
2017-11-04 21:05:25 +03:00
|
|
|
|
|
|
|
already_AddRefed<DrawTarget>
|
|
|
|
MakeDrawTarget(const IntSize& aSize,
|
2018-02-06 09:46:57 +03:00
|
|
|
DrawEventRecorder* aRecorder = nullptr) final;
|
2017-11-04 21:05:25 +03:00
|
|
|
|
|
|
|
already_AddRefed<DrawTarget>
|
2018-02-06 09:46:57 +03:00
|
|
|
GetReferenceDrawTarget() final;
|
2017-11-04 21:05:25 +03:00
|
|
|
|
2017-11-04 22:06:04 +03:00
|
|
|
void ConvertToEMFDone(const nsresult& aResult, mozilla::ipc::Shmem&& aEMF);
|
2017-11-04 23:36:37 +03:00
|
|
|
bool IsSyncPagePrinting() const final { return false; }
|
2017-11-06 17:12:31 +03:00
|
|
|
void ChannelIsBroken() { mChannelBroken = true; }
|
2017-11-04 22:06:04 +03:00
|
|
|
|
2017-11-04 21:05:25 +03:00
|
|
|
private:
|
|
|
|
PrintTargetEMF(HDC aDC, const IntSize& aSize);
|
2017-11-29 12:15:31 +03:00
|
|
|
~PrintTargetEMF() override;
|
2017-11-04 21:05:25 +03:00
|
|
|
|
|
|
|
nsString mTitle;
|
|
|
|
RefPtr<PrintTargetSkPDF> mTargetForCurrentPage;
|
|
|
|
nsCOMPtr<nsIFile> mPDFFileForOnePage;
|
|
|
|
RefPtr<PrintTargetSkPDF> mRefTarget;
|
2017-11-29 12:15:31 +03:00
|
|
|
PDFiumProcessParent* mPDFiumProcess;
|
2017-11-04 21:05:25 +03:00
|
|
|
HDC mPrinterDC;
|
2017-11-06 17:12:31 +03:00
|
|
|
bool mChannelBroken;
|
2017-11-04 21:05:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* MOZILLA_GFX_PRINTTARGETEMF_H */
|