LibreOffice Module svx (master)  1
svdpdf.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
21 #define INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
22 
23 #include <config_features.h>
24 
25 #if HAVE_FEATURE_PDFIUM
26 #include <sal/config.h>
27 
28 #include <memory>
29 
30 #include <tools/fract.hxx>
31 #include <vcl/virdev.hxx>
32 #include <vcl/graph.hxx>
33 #include <svx/svdobj.hxx>
34 #include <svx/xdash.hxx>
35 
37 
39 
40 // Forward Declarations
41 
42 class SfxItemSet;
43 class SdrObjList;
44 class SdrModel;
45 class SdrPage;
46 class SdrObject;
47 class SvdProgressInfo;
48 
49 // Helper Class to import PDF
50 class ImpSdrPdfImport final
51 {
52  std::vector<SdrObject*> maTmpList;
54  tools::Rectangle maScaleRect;
55  size_t mnMapScalingOfs; // from here on, not edited with MapScaling
56  std::unique_ptr<SfxItemSet> mpLineAttr;
57  std::unique_ptr<SfxItemSet> mpFillAttr;
58  std::unique_ptr<SfxItemSet> mpTextAttr;
59  SdrModel* mpModel;
61  Color maOldLineColor;
62  sal_Int32 mnLineWidth;
63  static constexpr css::drawing::LineCap gaLineCap = css::drawing::LineCap_BUTT;
64  XDash maDash;
65 
66  bool mbMov;
67  bool mbSize;
68  Point maOfs;
69  double mfScaleX;
70  double mfScaleY;
71  Fraction maScaleX;
72  Fraction maScaleY;
73 
74  bool mbFntDirty;
75 
76  // to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
77  bool mbLastObjWasPolyWithoutLine;
78  bool mbNoLine;
79  bool mbNoFill;
80 
81  // clipregion
83 
84  std::unique_ptr<vcl::pdf::PDFiumDocument> mpPdfDocument;
85  int mnPageCount;
86  double mdPageHeightPts;
88  basegfx::B2DHomMatrix maCurrentMatrix;
89 
92  double correctVertOrigin(double offsetPts) const { return mdPageHeightPts - offsetPts; }
94  tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const;
95  Point PointsToLogic(double x, double y) const;
96 
97  std::shared_ptr<vcl::pdf::PDFium> mpPDFium;
98 
99  // check for clip and evtl. fill maClip
100  void checkClip();
101  bool isClip() const;
102 
103  void ImportPdfObject(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
104  std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
105  int nPageObjectIndex);
106  void ImportForm(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
107  std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
108  int nPageObjectIndex);
109  void ImportImage(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
110  int nPageObjectIndex);
111  void ImportPath(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
112  int nPageObjectIndex);
113  void ImportText(std::unique_ptr<vcl::pdf::PDFiumPageObject> const& pPageObject,
114  std::unique_ptr<vcl::pdf::PDFiumTextPage> const& pTextPage,
115  int nPageObjectIndex);
116  void InsertTextObject(const Point& rPos, const Size& rSize, const OUString& rStr);
117 
118  void SetupPageScale(const double dPageWidth, const double dPageHeight);
119  void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
120  void InsertObj(SdrObject* pObj, bool bScale = true);
121  void MapScaling();
122 
123  // #i73407# reformulation to use new B2DPolygon classes
124  bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
125 
126  void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
127 
128  // Copy assignment is forbidden and not implemented.
129  ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;
130  ImpSdrPdfImport& operator=(const ImpSdrPdfImport&) = delete;
131 
132 public:
133  ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect,
134  Graphic const& rGraphic);
135 
136  ~ImpSdrPdfImport();
137 
138  int GetPageCount() const { return mnPageCount; }
139  size_t DoImport(SdrObjList& rDestList, size_t nInsPos, int nPageNumber,
140  SvdProgressInfo* pProgrInfo = nullptr);
141 };
142 
143 #endif // HAVE_FEATURE_PDFIUM
144 
145 #endif // INCLUDED_SVX_SOURCE_SVDRAW_SVDFMTF_HXX
146 
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: xdash.hxx:31
basegfx::B2DPolyPolygon maClip
Helper class for the communication between the dialog In order to break open Metafiles (sd/source/ui/...
Definition: svdetc.hxx:111
Abstract DrawObject.
Definition: svdobj.hxx:261
const int mnLayer
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:365