Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / inc / svdpdf.hxx
bloba644bee45d10cd23c88713a0a979928d9e0046ca
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
21 #define INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
23 #include <sal/config.h>
25 #include <memory>
27 #include <tools/fract.hxx>
28 #include <vcl/virdev.hxx>
29 #include <vcl/graph.hxx>
30 #include <svx/svdobj.hxx>
31 #include <svx/xdash.hxx>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
35 #include <vcl/filter/PDFiumLibrary.hxx>
37 // Forward Declarations
39 class SfxItemSet;
40 class SdrObjList;
41 class SdrModel;
42 class SdrPage;
43 class SdrObject;
44 class SvdProgressInfo;
46 // Helper Class to import PDF
47 class ImpSdrPdfImport final
49 std::vector<rtl::Reference<SdrObject>> maTmpList;
50 ScopedVclPtr<VirtualDevice> mpVD;
51 tools::Rectangle maScaleRect;
52 size_t mnMapScalingOfs; // from here on, not edited with MapScaling
53 std::unique_ptr<SfxItemSet> mpLineAttr;
54 std::unique_ptr<SfxItemSet> mpFillAttr;
55 std::unique_ptr<SfxItemSet> mpTextAttr;
56 SdrModel* mpModel;
57 SdrLayerID mnLayer;
58 Color maOldLineColor;
59 sal_Int32 mnLineWidth;
60 static constexpr css::drawing::LineCap gaLineCap = css::drawing::LineCap_BUTT;
61 XDash maDash;
63 bool mbMov;
64 bool mbSize;
65 Point maOfs;
66 double mfScaleX;
67 double mfScaleY;
68 Fraction maScaleX;
69 Fraction maScaleY;
71 bool mbFntDirty;
73 // to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
74 bool mbLastObjWasPolyWithoutLine;
75 bool mbNoLine;
76 bool mbNoFill;
78 // clipregion
79 basegfx::B2DPolyPolygon maClip;
81 std::unique_ptr<vcl::pdf::PDFiumDocument> mpPdfDocument;
82 int mnPageCount;
83 double mdPageHeightPts;
84 /// The current transformation matrix, typically used with Form objects.
85 basegfx::B2DHomMatrix maCurrentMatrix;
87 /// Correct the vertical coordinate to start at the top.
88 /// PDF coordinate system has origin at the bottom right.
89 double correctVertOrigin(double offsetPts) const { return mdPageHeightPts - offsetPts; }
90 /// Convert PDF points to logic (twips).
91 tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const;
92 Point PointsToLogic(double x, double y) const;
94 std::shared_ptr<vcl::pdf::PDFium> mpPDFium;
96 // check for clip and evtl. fill maClip
97 void checkClip();
98 bool isClip() const;
100 void ImportPdfObject(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
101 std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
102 int nPageObjectIndex);
103 void ImportForm(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
104 std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
105 int nPageObjectIndex);
106 void ImportImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
107 int nPageObjectIndex);
108 void ImportPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
109 int nPageObjectIndex);
110 void ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
111 std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
112 int nPageObjectIndex);
113 void InsertTextObject(const Point& rPos, const Size& rSize, const OUString& rStr);
115 void SetupPageScale(const double dPageWidth, const double dPageHeight);
116 void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
117 void InsertObj(SdrObject* pObj, bool bScale = true);
118 void MapScaling();
120 // #i73407# reformulation to use new B2DPolygon classes
121 bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
123 void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
125 // Copy assignment is forbidden and not implemented.
126 ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;
127 ImpSdrPdfImport& operator=(const ImpSdrPdfImport&) = delete;
129 public:
130 ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect,
131 Graphic const& rGraphic);
133 ~ImpSdrPdfImport();
135 int GetPageCount() const { return mnPageCount; }
136 size_t DoImport(SdrObjList& rDestList, size_t nInsPos, int nPageNumber,
137 SvdProgressInfo* pProgrInfo = nullptr);
140 #endif // INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */