.gitlab-ci.yml | 19 +-- README.contributors | 2 goo/gfile.h | 10 + poppler/CairoOutputDev.h | 100 ++++++++++++++--- poppler/Gfx.h | 10 + poppler/GfxState.h | 65 +++++++++-- poppler/GlobalParams.cc | 5 poppler/OutputDev.h | 107 +++++++++++++++--- poppler/PDFDoc.h | 260 ++++++++++++++++++++++++++++++++++++---------- poppler/PSOutputDev.h | 155 +++++++++++++++++++++------ poppler/SplashOutputDev.h | 15 ++ poppler/TextOutputDev.h | 125 +++++++++++++++++----- qt5/src/poppler-private.h | 5 qt6/src/poppler-private.h | 5 splash/Splash.h | 15 ++ utils/InMemoryFile.h | 5 16 files changed, 715 insertions(+), 188 deletions(-)
New commits: commit a94a444e5acff86e04d1688d862e81a82108cf03 Author: Albert Astals Cid <aa...@kde.org> Date: Fri Jul 29 16:31:10 2022 +0200 CI: clang 13 -> 14 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 67ac1996..a067dc65 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,9 +30,9 @@ clang_format: stage: build before_script: - apt-get update - - apt-get install --yes --no-install-recommends git clang-format-13 + - apt-get install --yes --no-install-recommends git clang-format-14 script: - - find . \( -name "*.cpp" -or -name "*.h" -or -name "*.c" -or -name "*.cc" \) -exec clang-format-13 -i {} \; + - find . \( -name "*.cpp" -or -name "*.h" -or -name "*.c" -or -name "*.cc" \) -exec clang-format-14 -i {} \; - git diff --exit-code build: @@ -44,28 +44,27 @@ build: - ninja - ctest --output-on-failure -build_clang13_libcpp: +build_clang14_libcpp: stage: build image: debian:bookworm script: - echo "We want to compile with C++23 here because it has some nice things like deleted std::string nullptr constructor" - sed -i -e "s@CMAKE_CXX_STANDARD 17@CMAKE_CXX_STANDARD 23@g" CMakeLists.txt - git clone --branch ${CI_COMMIT_REF_NAME} --depth 1 ${TEST_DATA_URL} test-data || git clone --depth 1 ${UPSTREAM_TEST_DATA_URL} test-data - - apt-get install --yes --no-install-recommends libclang-13-dev llvm-13-dev libc++-13-dev libc++abi-13-dev clang-tidy-13 clang-13 libunwind-13-dev gperf jq + - apt-get install --yes --no-install-recommends libclang-14-dev llvm-14-dev libc++-14-dev libc++abi-14-dev clang-tidy-14 clang-14 libunwind-14-dev gperf jq - srcdir=`pwd` && mkdir -p /tmp/poppler_build && cd /tmp/poppler_build - - clang++-13 -fPIC -shared -o goostring-format-checker.so $srcdir/test/goostring-format-checker/goostring-format-checker.cc -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -I /usr/lib/llvm-13/include/ - - CC=clang-13 CXX=clang++-13 cmake -G Ninja -DCMAKE_CXX_FLAGS="-stdlib=libc++ -Xclang -load -Xclang $PWD/goostring-format-checker.so -Xclang -add-plugin -Xclang goostring-format-checker -Werror -Wno-deprecated-declarations" -DTESTDATADIR=$srcdir/test-data -DCMAKE_EXPORT_COMPILE_COMMANDS=ON $srcdir + - clang++-14 -fPIC -shared -o goostring-format-checker.so $srcdir/test/goostring-format-checker/goostring-format-checker.cc -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -I /usr/lib/llvm-14/include/ + - CC=clang-14 CXX=clang++-14 cmake -G Ninja -DCMAKE_CXX_FLAGS="-stdlib=libc++ -Xclang -load -Xclang $PWD/goostring-format-checker.so -Xclang -add-plugin -Xclang goostring-format-checker -Werror -Wno-deprecated-declarations" -DTESTDATADIR=$srcdir/test-data -DCMAKE_EXPORT_COMPILE_COMMANDS=ON $srcdir - ninja - ctest --output-on-failure - echo "This is a complex way of not running clang-tidy over autogenerated files, unfortunately -DCMAKE_CXX_CLANG_TIDY doesn't support that https://gitlab.kitware.com/cmake/cmake/-/issues/19772" - cat compile_commands.json | jq '[.[] | select(.file | contains("'"$srcdir"'"))]' > compile_commands.aux.json - cp compile_commands.aux.json compile_commands.json - - echo "For some reason clang-tidy gets confused by -stdlib=libc++" - - sed -i -e "s@-stdlib=libc++@ @g" compile_commands.json - - echo "We're going to cheat and remove the moc includes so that we don't lint autogenerated code, with clang-tidy 14 we can remove this and use NOLINTBEGIN/NOLINTEND" + - echo "Cheat a bit and remove the moc includes so that we don't lint autogenerated code" + - echo "Maybe we can replace this with NOLINTBEGIN in the future https://github.com/llvm/llvm-project/issues/56983" - find $srcdir/qt* -name *.cpp -exec sed -E -i '/#include .*moc"$/d' {} \; - cp "$srcdir/.clang-tidy" . - - run-clang-tidy-13 + - run-clang-tidy-14 build_ubuntu_18_04: stage: build diff --git a/README.contributors b/README.contributors index 8cccd70f..b310a5b4 100644 --- a/README.contributors +++ b/README.contributors @@ -29,7 +29,7 @@ To get the clang-format warnings locally instead at CI time we recommend you to copy the hooks/pre-commit to your .git cp hooks/pre-commit .git/hooks/ -We are using clang-format 13 on CI. Unfortunately clang-format is not totally +We are using clang-format 14 on CI. Unfortunately clang-format is not totally compatible with older versions of itself. If CI gives you trouble but your local clang-format disagrees, just apply the changes suggested by CI and then commit with the --no-verify flag. If you get stuck, don't hesitate to ask the reviewer diff --git a/goo/gfile.h b/goo/gfile.h index 516c2fc2..08b1b5dc 100644 --- a/goo/gfile.h +++ b/goo/gfile.h @@ -132,7 +132,10 @@ public: #ifdef _WIN32 static std::unique_ptr<GooFile> open(const wchar_t *fileName); - ~GooFile() { CloseHandle(handle); } + ~GooFile() + { + CloseHandle(handle); + } // Asuming than on windows you can't change files that are already open bool modificationTimeChangedSinceOpen() const; @@ -142,7 +145,10 @@ private: HANDLE handle; struct _FILETIME modifiedTimeOnOpen; #else - ~GooFile() { close(fd); } + ~GooFile() + { + close(fd); + } bool modificationTimeChangedSinceOpen() const; diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index 791e9bc3..c287bf5c 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -118,21 +118,36 @@ public: // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0) - bool useShadedFills(int type) override { return type <= 7; } + bool useShadedFills(int type) override + { + return type <= 7; + } #else - bool useShadedFills(int type) override { return type > 1 && type < 4; } + bool useShadedFills(int type) override + { + return type > 1 && type < 4; + } #endif // Does this device use FillColorStop()? - bool useFillColorStop() override { return true; } + bool useFillColorStop() override + { + return true; + } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - bool interpretType3Chars() override { return false; } + bool interpretType3Chars() override + { + return false; + } // Does this device need to clip pages to the crop box even when the // box is the crop box? - bool needClipToCropBox() override { return true; } + bool needClipToCropBox() override + { + return true; + } //----- initialization and control @@ -233,7 +248,10 @@ public: // Called to prepare this output dev for rendering CairoType3Font. void startType3Render(GfxState *state, XRef *xref); - bool isReverseVideo() { return false; } + bool isReverseVideo() + { + return false; + } void setCairo(cairo_t *cr); void setTextPage(TextPage *text); @@ -244,15 +262,27 @@ public: } void copyAntialias(cairo_t *cr, cairo_t *source_cr); - void setInType3Char(bool inType3CharA) { inType3Char = inType3CharA; } + void setInType3Char(bool inType3CharA) + { + inType3Char = inType3CharA; + } void getType3GlyphWidth(double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; } - bool hasType3GlyphBBox() { return t3_glyph_has_bbox; } - double *getType3GlyphBBox() { return t3_glyph_bbox; } - bool type3GlyphHasColor() { return t3_glyph_has_color; } + bool hasType3GlyphBBox() + { + return t3_glyph_has_bbox; + } + double *getType3GlyphBBox() + { + return t3_glyph_bbox; + } + bool type3GlyphHasColor() + { + return t3_glyph_has_color; + } protected: void doPath(cairo_t *cairo, GfxState *state, const GfxPath *path); @@ -387,20 +417,35 @@ public: // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2) - bool useShadedFills(int type) override { return type <= 7; } + bool useShadedFills(int type) override + { + return type <= 7; + } #else - bool useShadedFills(int type) override { return type < 4; } + bool useShadedFills(int type) override + { + return type < 4; + } #endif // Does this device use FillColorStop()? - bool useFillColorStop() override { return false; } + bool useFillColorStop() override + { + return false; + } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - bool interpretType3Chars() override { return false; } + bool interpretType3Chars() override + { + return false; + } // Does this device need non-text content? - bool needNonText() override { return true; } + bool needNonText() override + { + return true; + } //----- save/restore graphics state void saveState(GfxState *state) override { } @@ -430,9 +475,18 @@ public: void fill(GfxState *state) override { } void eoFill(GfxState *state) override { } void clipToStrokePath(GfxState *state) override { } - bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override { return true; } - bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override { return true; } - bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override { return true; } + bool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, GfxTilingPattern *tPat, const double *mat, int x0, int y0, int x1, int y1, double xStep, double yStep) override + { + return true; + } + bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override + { + return true; + } + bool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override + { + return true; + } //----- path clipping void clip(GfxState *state) override { } @@ -462,8 +516,14 @@ public: imgDrawCbkData = data; } // Iterate through list of images. - int getNumImages() const { return numImages; } - CairoImage *getImage(int i) const { return images[i]; } + int getNumImages() const + { + return numImages; + } + CairoImage *getImage(int i) const + { + return images[i]; + } private: void saveImage(CairoImage *image); diff --git a/poppler/Gfx.h b/poppler/Gfx.h index fee97a72..81a620b5 100644 --- a/poppler/Gfx.h +++ b/poppler/Gfx.h @@ -166,7 +166,10 @@ public: Gfx(const Gfx &) = delete; Gfx &operator=(const Gfx &other) = delete; - XRef *getXRef() { return xref; } + XRef *getXRef() + { + return xref; + } // Interpret a stream or array of streams. void display(Object *obj, bool topLevel = true); @@ -188,7 +191,10 @@ public: void popStateGuard(); // Get the current graphics state object. - GfxState *getState() { return state; } + GfxState *getState() + { + return state; + } bool checkTransparencyGroup(Dict *resDict); diff --git a/poppler/GfxState.h b/poppler/GfxState.h index 08492df6..92db8ab2 100644 --- a/poppler/GfxState.h +++ b/poppler/GfxState.h @@ -586,8 +586,14 @@ public: #ifdef USE_CMS char *getPostScriptCSA(); void buildTransforms(GfxState *state); - void setProfile(GfxLCMSProfilePtr &profileA) { profile = profileA; } - GfxLCMSProfilePtr getProfile() { return profile; } + void setProfile(GfxLCMSProfilePtr &profileA) + { + profile = profileA; + } + GfxLCMSProfilePtr getProfile() + { + return profile; + } #endif private: @@ -599,7 +605,10 @@ private: #ifdef USE_CMS GfxLCMSProfilePtr profile; char *psCSA; - int getIntent() { return (transform != nullptr) ? transform->getIntent() : 0; } + int getIntent() + { + return (transform != nullptr) ? transform->getIntent() : 0; + } std::shared_ptr<GfxColorTransform> transform; std::shared_ptr<GfxColorTransform> lineTransform; // color transform for line mutable std::map<unsigned int, unsigned int> cmsCache; @@ -1607,17 +1616,29 @@ public: #ifdef USE_CMS void setDisplayProfile(const GfxLCMSProfilePtr &localDisplayProfileA); - GfxLCMSProfilePtr getDisplayProfile() { return localDisplayProfile; } + GfxLCMSProfilePtr getDisplayProfile() + { + return localDisplayProfile; + } std::shared_ptr<GfxColorTransform> getXYZ2DisplayTransform(); int getCmsRenderingIntent(); static GfxLCMSProfilePtr sRGBProfile; #endif - void setDefaultGrayColorSpace(GfxColorSpace *cs) { defaultGrayColorSpace = cs; } + void setDefaultGrayColorSpace(GfxColorSpace *cs) + { + defaultGrayColorSpace = cs; + } - void setDefaultRGBColorSpace(GfxColorSpace *cs) { defaultRGBColorSpace = cs; } + void setDefaultRGBColorSpace(GfxColorSpace *cs) + { + defaultRGBColorSpace = cs; + } - void setDefaultCMYKColorSpace(GfxColorSpace *cs) { defaultCMYKColorSpace = cs; } + void setDefaultCMYKColorSpace(GfxColorSpace *cs) + { + defaultCMYKColorSpace = cs; + } GfxColorSpace *copyDefaultGrayColorSpace() { @@ -1644,9 +1665,18 @@ public: } // Add to path. - void moveTo(double x, double y) { path->moveTo(curX = x, curY = y); } - void lineTo(double x, double y) { path->lineTo(curX = x, curY = y); } - void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) { path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); } + void moveTo(double x, double y) + { + path->moveTo(curX = x, curY = y); + } + void lineTo(double x, double y) + { + path->lineTo(curX = x, curY = y); + } + void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) + { + path->curveTo(x1, y1, x2, y2, curX = x3, curY = y3); + } void closePath() { path->close(); @@ -1678,13 +1708,22 @@ public: // Push/pop GfxState on/off stack. GfxState *save(); GfxState *restore(); - bool hasSaves() const { return saved != nullptr; } - bool isParentState(GfxState *state) { return saved == state || (saved && saved->isParentState(state)); } + bool hasSaves() const + { + return saved != nullptr; + } + bool isParentState(GfxState *state) + { + return saved == state || (saved && saved->isParentState(state)); + } // Misc bool parseBlendMode(Object *obj, GfxBlendMode *mode); - ReusablePathIterator *getReusablePath() { return new ReusablePathIterator(path); } + ReusablePathIterator *getReusablePath() + { + return new ReusablePathIterator(path); + } private: double hDPI, vDPI; // resolution diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc index 91a74c0b..e5b71975 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -260,7 +260,10 @@ public: void scanWindowsFonts(const std::string &winFontDir); #endif #ifdef WITH_FONTCONFIGURATION_FONTCONFIG - void addFcFont(SysFontInfo *si) { fonts.push_back(si); } + void addFcFont(SysFontInfo *si) + { + fonts.push_back(si); + } #endif private: #ifdef _WIN32 diff --git a/poppler/OutputDev.h b/poppler/OutputDev.h index 67c21618..f9c99a77 100644 --- a/poppler/OutputDev.h +++ b/poppler/OutputDev.h @@ -173,8 +173,14 @@ public: virtual void cvtDevToUser(double dx, double dy, double *ux, double *uy); virtual void cvtUserToDev(double ux, double uy, int *dx, int *dy); - const double *getDefCTM() const { return defCTM; } - const double *getDefICTM() const { return defICTM; } + const double *getDefCTM() const + { + return defCTM; + } + const double *getDefICTM() const + { + return defICTM; + } //----- save/restore graphics state virtual void saveState(GfxState * /*state*/) { } @@ -234,13 +240,34 @@ public: { return false; } - virtual bool functionShadedFill(GfxState * /*state*/, GfxFunctionShading * /*shading*/) { return false; } - virtual bool axialShadedFill(GfxState * /*state*/, GfxAxialShading * /*shading*/, double /*tMin*/, double /*tMax*/) { return false; } - virtual bool axialShadedSupportExtend(GfxState * /*state*/, GfxAxialShading * /*shading*/) { return false; } - virtual bool radialShadedFill(GfxState * /*state*/, GfxRadialShading * /*shading*/, double /*sMin*/, double /*sMax*/) { return false; } - virtual bool radialShadedSupportExtend(GfxState * /*state*/, GfxRadialShading * /*shading*/) { return false; } - virtual bool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) { return false; } - virtual bool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) { return false; } + virtual bool functionShadedFill(GfxState * /*state*/, GfxFunctionShading * /*shading*/) + { + return false; + } + virtual bool axialShadedFill(GfxState * /*state*/, GfxAxialShading * /*shading*/, double /*tMin*/, double /*tMax*/) + { + return false; + } + virtual bool axialShadedSupportExtend(GfxState * /*state*/, GfxAxialShading * /*shading*/) + { + return false; + } + virtual bool radialShadedFill(GfxState * /*state*/, GfxRadialShading * /*shading*/, double /*sMin*/, double /*sMax*/) + { + return false; + } + virtual bool radialShadedSupportExtend(GfxState * /*state*/, GfxRadialShading * /*shading*/) + { + return false; + } + virtual bool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) + { + return false; + } + virtual bool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) + { + return false; + } //----- path clipping @@ -329,11 +356,17 @@ public: //----- Profiling void startProfile(); - std::unordered_map<std::string, ProfileData> *getProfileHash() const { return profileHash.get(); } + std::unordered_map<std::string, ProfileData> *getProfileHash() const + { + return profileHash.get(); + } std::unique_ptr<std::unordered_map<std::string, ProfileData>> endProfile(); //----- transparency groups and soft masks - virtual bool checkTransparencyGroup(GfxState * /*state*/, bool /*knockout*/) { return true; } + virtual bool checkTransparencyGroup(GfxState * /*state*/, bool /*knockout*/) + { + return true; + } virtual void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) { } virtual void endTransparencyGroup(GfxState * /*state*/) { } virtual void paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) { } @@ -344,21 +377,51 @@ public: virtual void processLink(AnnotLink * /*link*/) { } #if 1 //~tmp: turn off anti-aliasing temporarily - virtual bool getVectorAntialias() { return false; } + virtual bool getVectorAntialias() + { + return false; + } virtual void setVectorAntialias(bool /*vaa*/) { } #endif #ifdef USE_CMS - void setDisplayProfile(const GfxLCMSProfilePtr &profile) { displayprofile = profile; } - GfxLCMSProfilePtr getDisplayProfile() const { return displayprofile; } - void setDefaultGrayProfile(const GfxLCMSProfilePtr &profile) { defaultGrayProfile = profile; } - GfxLCMSProfilePtr getDefaultGrayProfile() const { return defaultGrayProfile; } - void setDefaultRGBProfile(const GfxLCMSProfilePtr &profile) { defaultRGBProfile = profile; } - GfxLCMSProfilePtr getDefaultRGBProfile() const { return defaultRGBProfile; } - void setDefaultCMYKProfile(const GfxLCMSProfilePtr &profile) { defaultCMYKProfile = profile; } - GfxLCMSProfilePtr getDefaultCMYKProfile() const { return defaultCMYKProfile; } - - PopplerCache<Ref, GfxICCBasedColorSpace> *getIccColorSpaceCache() { return &iccColorSpaceCache; } + void setDisplayProfile(const GfxLCMSProfilePtr &profile) + { + displayprofile = profile; + } + GfxLCMSProfilePtr getDisplayProfile() const + { + return displayprofile; + } + void setDefaultGrayProfile(const GfxLCMSProfilePtr &profile) + { + defaultGrayProfile = profile; + } + GfxLCMSProfilePtr getDefaultGrayProfile() const + { + return defaultGrayProfile; + } + void setDefaultRGBProfile(const GfxLCMSProfilePtr &profile) + { + defaultRGBProfile = profile; + } + GfxLCMSProfilePtr getDefaultRGBProfile() const + { + return defaultRGBProfile; + } + void setDefaultCMYKProfile(const GfxLCMSProfilePtr &profile) + { + defaultCMYKProfile = profile; + } + GfxLCMSProfilePtr getDefaultCMYKProfile() const + { + return defaultCMYKProfile; + } + + PopplerCache<Ref, GfxICCBasedColorSpace> *getIccColorSpaceCache() + { + return &iccColorSpaceCache; + } #endif private: diff --git a/poppler/PDFDoc.h b/poppler/PDFDoc.h index b3f5f4ea..8cbef127 100644 --- a/poppler/PDFDoc.h +++ b/poppler/PDFDoc.h @@ -145,19 +145,34 @@ public: static std::unique_ptr<PDFDoc> ErrorPDFDoc(int errorCode, std::unique_ptr<GooString> &&fileNameA); // Was PDF document successfully opened? - bool isOk() const { return ok; } + bool isOk() const + { + return ok; + } // Get the error code (if isOk() returns false). - int getErrorCode() const { return errCode; } + int getErrorCode() const + { + return errCode; + } // Get the error code returned by fopen() (if getErrorCode() == // errOpenFile). - int getFopenErrno() const { return fopenErrno; } + int getFopenErrno() const + { + return fopenErrno; + } // Get file name. - const GooString *getFileName() const { return fileName.get(); } + const GooString *getFileName() const + { + return fileName.get(); + } #ifdef _WIN32 - wchar_t *getFileNameU() { return fileNameU; } + wchar_t *getFileNameU() + { + return fileNameU; + } #endif // Get the linearization table. @@ -165,33 +180,66 @@ public: bool checkLinearization(); // Get the xref table. - XRef *getXRef() const { return xref; } + XRef *getXRef() const + { + return xref; + } // Get catalog. - Catalog *getCatalog() const { return catalog; } + Catalog *getCatalog() const + { + return catalog; + } // Get optional content configuration - OCGs *getOptContentConfig() const { return catalog->getOptContentConfig(); } + OCGs *getOptContentConfig() const + { + return catalog->getOptContentConfig(); + } // Get base stream. - BaseStream *getBaseStream() const { return str; } + BaseStream *getBaseStream() const + { + return str; + } // Get page parameters. - double getPageMediaWidth(int page) { return getPage(page) ? getPage(page)->getMediaWidth() : 0.0; } - double getPageMediaHeight(int page) { return getPage(page) ? getPage(page)->getMediaHeight() : 0.0; } - double getPageCropWidth(int page) { return getPage(page) ? getPage(page)->getCropWidth() : 0.0; } - double getPageCropHeight(int page) { return getPage(page) ? getPage(page)->getCropHeight() : 0.0; } - int getPageRotate(int page) { return getPage(page) ? getPage(page)->getRotate() : 0; } + double getPageMediaWidth(int page) + { + return getPage(page) ? getPage(page)->getMediaWidth() : 0.0; + } + double getPageMediaHeight(int page) + { + return getPage(page) ? getPage(page)->getMediaHeight() : 0.0; + } + double getPageCropWidth(int page) + { + return getPage(page) ? getPage(page)->getCropWidth() : 0.0; + } + double getPageCropHeight(int page) + { + return getPage(page) ? getPage(page)->getCropHeight() : 0.0; + } + int getPageRotate(int page) + { + return getPage(page) ? getPage(page)->getRotate() : 0; + } // Get number of pages. int getNumPages(); // Return the contents of the metadata stream, or nullptr if there is // no metadata. - std::unique_ptr<GooString> readMetadata() const { return catalog->readMetadata(); } + std::unique_ptr<GooString> readMetadata() const + { + return catalog->readMetadata(); + } // Return the structure tree root object. - const StructTreeRoot *getStructTreeRoot() const { return catalog->getStructTreeRoot(); } + const StructTreeRoot *getStructTreeRoot() const + { + return catalog->getStructTreeRoot(); + } // Get page. Page *getPage(int page); @@ -210,7 +258,10 @@ public: // Find a page, given its object ID. Returns page number, or 0 if // not found. - int findPage(const Ref ref) { return catalog->findPage(ref); } + int findPage(const Ref ref) + { + return catalog->findPage(ref); + } // Returns the links for the current page, transferring ownership to // the caller. @@ -218,7 +269,10 @@ public: // Find a named destination. Returns the link destination, or // nullptr if <name> is not a destination. - std::unique_ptr<LinkDest> findDest(const GooString *name) { return catalog->findDest(name); } + std::unique_ptr<LinkDest> findDest(const GooString *name) + { + return catalog->findDest(name); + } // Process the links for a page. void processLinks(OutputDev *out, int page); @@ -227,29 +281,65 @@ public: Outline *getOutline(); // Is the file encrypted? - bool isEncrypted() { return xref->isEncrypted(); } + bool isEncrypted() + { + return xref->isEncrypted(); + } std::vector<FormFieldSignature *> getSignatureFields(); // Check various permissions. - bool okToPrint(bool ignoreOwnerPW = false) { return xref->okToPrint(ignoreOwnerPW); } - bool okToPrintHighRes(bool ignoreOwnerPW = false) { return xref->okToPrintHighRes(ignoreOwnerPW); } - bool okToChange(bool ignoreOwnerPW = false) { return xref->okToChange(ignoreOwnerPW); } - bool okToCopy(bool ignoreOwnerPW = false) { return xref->okToCopy(ignoreOwnerPW); } - bool okToAddNotes(bool ignoreOwnerPW = false) { return xref->okToAddNotes(ignoreOwnerPW); } - bool okToFillForm(bool ignoreOwnerPW = false) { return xref->okToFillForm(ignoreOwnerPW); } - bool okToAccessibility(bool ignoreOwnerPW = false) { return xref->okToAccessibility(ignoreOwnerPW); } - bool okToAssemble(bool ignoreOwnerPW = false) { return xref->okToAssemble(ignoreOwnerPW); } + bool okToPrint(bool ignoreOwnerPW = false) + { + return xref->okToPrint(ignoreOwnerPW); + } + bool okToPrintHighRes(bool ignoreOwnerPW = false) + { + return xref->okToPrintHighRes(ignoreOwnerPW); + } + bool okToChange(bool ignoreOwnerPW = false) + { + return xref->okToChange(ignoreOwnerPW); + } + bool okToCopy(bool ignoreOwnerPW = false) + { + return xref->okToCopy(ignoreOwnerPW); + } + bool okToAddNotes(bool ignoreOwnerPW = false) + { + return xref->okToAddNotes(ignoreOwnerPW); + } + bool okToFillForm(bool ignoreOwnerPW = false) + { + return xref->okToFillForm(ignoreOwnerPW); + } + bool okToAccessibility(bool ignoreOwnerPW = false) + { + return xref->okToAccessibility(ignoreOwnerPW); + } + bool okToAssemble(bool ignoreOwnerPW = false) + { + return xref->okToAssemble(ignoreOwnerPW); + } // Is this document linearized? bool isLinearized(bool tryingToReconstruct = false); // Return the document's Info dictionary (if any). - Object getDocInfo() { return xref->getDocInfo(); } - Object getDocInfoNF() { return xref->getDocInfoNF(); } + Object getDocInfo() + { + return xref->getDocInfo(); + } + Object getDocInfoNF() + { + return xref->getDocInfoNF(); + } // Remove the document's Info dictionary and update the trailer dictionary. - void removeDocInfo() { xref->removeDocInfo(); } + void removeDocInfo() + { + xref->removeDocInfo(); + } // Set doc info string entry. nullptr or empty value will cause a removal. // Takes ownership of value. @@ -258,35 +348,95 @@ public: // Set document's properties in document's Info dictionary. // nullptr or empty value will cause a removal. // Takes ownership of value. - void setDocInfoTitle(GooString *title) { setDocInfoStringEntry("Title", title); } - void setDocInfoAuthor(GooString *author) { setDocInfoStringEntry("Author", author); } - void setDocInfoSubject(GooString *subject) { setDocInfoStringEntry("Subject", subject); } - void setDocInfoKeywords(GooString *keywords) { setDocInfoStringEntry("Keywords", keywords); } - void setDocInfoCreator(GooString *creator) { setDocInfoStringEntry("Creator", creator); } - void setDocInfoProducer(GooString *producer) { setDocInfoStringEntry("Producer", producer); } - void setDocInfoCreatDate(GooString *creatDate) { setDocInfoStringEntry("CreationDate", creatDate); } - void setDocInfoModDate(GooString *modDate) { setDocInfoStringEntry("ModDate", modDate); } + void setDocInfoTitle(GooString *title) + { + setDocInfoStringEntry("Title", title); + } + void setDocInfoAuthor(GooString *author) + { + setDocInfoStringEntry("Author", author); + } + void setDocInfoSubject(GooString *subject) + { + setDocInfoStringEntry("Subject", subject); + } + void setDocInfoKeywords(GooString *keywords) + { + setDocInfoStringEntry("Keywords", keywords); + } + void setDocInfoCreator(GooString *creator) + { + setDocInfoStringEntry("Creator", creator); + } + void setDocInfoProducer(GooString *producer) + { + setDocInfoStringEntry("Producer", producer); + } + void setDocInfoCreatDate(GooString *creatDate) + { + setDocInfoStringEntry("CreationDate", creatDate); + } + void setDocInfoModDate(GooString *modDate) + { + setDocInfoStringEntry("ModDate", modDate); + } // Get document's properties from document's Info dictionary. // Returns nullptr on fail. std::unique_ptr<GooString> getDocInfoStringEntry(const char *key); - std::unique_ptr<GooString> getDocInfoTitle() { return getDocInfoStringEntry("Title"); } - std::unique_ptr<GooString> getDocInfoAuthor() { return getDocInfoStringEntry("Author"); } - std::unique_ptr<GooString> getDocInfoSubject() { return getDocInfoStringEntry("Subject"); } - std::unique_ptr<GooString> getDocInfoKeywords() { return getDocInfoStringEntry("Keywords"); } - std::unique_ptr<GooString> getDocInfoCreator() { return getDocInfoStringEntry("Creator"); } - std::unique_ptr<GooString> getDocInfoProducer() { return getDocInfoStringEntry("Producer"); } - std::unique_ptr<GooString> getDocInfoCreatDate() { return getDocInfoStringEntry("CreationDate"); } - std::unique_ptr<GooString> getDocInfoModDate() { return getDocInfoStringEntry("ModDate"); } + std::unique_ptr<GooString> getDocInfoTitle() + { + return getDocInfoStringEntry("Title"); + } + std::unique_ptr<GooString> getDocInfoAuthor() + { + return getDocInfoStringEntry("Author"); + } + std::unique_ptr<GooString> getDocInfoSubject() + { + return getDocInfoStringEntry("Subject"); + } + std::unique_ptr<GooString> getDocInfoKeywords() + { + return getDocInfoStringEntry("Keywords"); + } + std::unique_ptr<GooString> getDocInfoCreator() + { + return getDocInfoStringEntry("Creator"); + } + std::unique_ptr<GooString> getDocInfoProducer() + { + return getDocInfoStringEntry("Producer"); + } + std::unique_ptr<GooString> getDocInfoCreatDate() + { + return getDocInfoStringEntry("CreationDate"); + } + std::unique_ptr<GooString> getDocInfoModDate() + { + return getDocInfoStringEntry("ModDate"); + } // Return the PDF subtype, part, and conformance - PDFSubtype getPDFSubtype() const { return pdfSubtype; } - PDFSubtypePart getPDFSubtypePart() const { return pdfPart; } - PDFSubtypeConformance getPDFSubtypeConformance() const { return pdfConformance; } + PDFSubtype getPDFSubtype() const + { + return pdfSubtype; + } + PDFSubtypePart getPDFSubtypePart() const + { + return pdfPart; + } + PDFSubtypeConformance getPDFSubtypeConformance() const + { + return pdfConformance; + } // Return the PDF version specified by the file (either header or catalog). - int getPDFMajorVersion() const { return std::max(headerPdfMajorVersion, catalog->getPDFMajorVersion()); } + int getPDFMajorVersion() const + { + return std::max(headerPdfMajorVersion, catalog->getPDFMajorVersion()); + } int getPDFMinorVersion() const { const int catalogMajorVersion = catalog->getPDFMajorVersion(); @@ -314,7 +464,10 @@ public: int saveWithoutChangesAs(OutStream *outStr); // Return a pointer to the GUI (XPDFCore or WinPDFCore object). - void *getGUIData() { return guiData; } + void *getGUIData() + { + return guiData; + } // rewrite pageDict with MediaBox, CropBox and new page CTM void replacePageDict(int pageNo, int rotate, const PDFRectangle *mediaBox, const PDFRectangle *cropBox); @@ -355,7 +508,10 @@ private: { writeObject(obj, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, { objNum, objGen }); } - inline void writeObject(Object *obj, OutStream *outStr, unsigned char *fileKey, CryptAlgorithm encAlgorithm, int keyLength, Ref ref) { writeObject(obj, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, ref); } + inline void writeObject(Object *obj, OutStream *outStr, unsigned char *fileKey, CryptAlgorithm encAlgorithm, int keyLength, Ref ref) + { + writeObject(obj, outStr, getXRef(), 0, fileKey, encAlgorithm, keyLength, ref); + } static void writeStream(Stream *str, OutStream *outStr); static void writeRawStream(Stream *str, OutStream *outStr); void writeXRefTableTrailer(Goffset uxrefOffset, XRef *uxref, bool writeAllEntries, int uxrefSize, OutStream *outStr, bool incrUpdate); diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h index 76d72396..dfb4ad83 100644 --- a/poppler/PSOutputDev.h +++ b/poppler/PSOutputDev.h @@ -286,7 +286,10 @@ public: xScale0 = x; yScale0 = y; } - void setRotate(int rotateA) { rotate0 = rotateA; } + void setRotate(int rotateA) + { + rotate0 = rotateA; + } void setClip(double llx, double lly, double urx, double ury) { clipLLX0 = llx; @@ -304,31 +307,82 @@ public: overlayCbk = cbk; overlayCbkData = data; } - void setDisplayText(bool display) { displayText = display; } + void setDisplayText(bool display) + { + displayText = display; + } - void setPSCenter(bool center) { psCenter = center; } - void setPSExpandSmaller(bool expand) { psExpandSmaller = expand; } - void setPSShrinkLarger(bool shrink) { psShrinkLarger = shrink; } - void setOverprintPreview(bool overprintPreviewA) { overprintPreview = overprintPreviewA; } - void setRasterAntialias(bool a) { rasterAntialias = a; } - void setForceRasterize(PSForceRasterize f) { forceRasterize = f; } - void setRasterResolution(double r) { rasterResolution = r; } + void setPSCenter(bool center) + { + psCenter = center; + } + void setPSExpandSmaller(bool expand) + { + psExpandSmaller = expand; + } + void setPSShrinkLarger(bool shrink) + { + psShrinkLarger = shrink; + } + void setOverprintPreview(bool overprintPreviewA) + { + overprintPreview = overprintPreviewA; + } + void setRasterAntialias(bool a) + { + rasterAntialias = a; + } + void setForceRasterize(PSForceRasterize f) + { + forceRasterize = f; + } + void setRasterResolution(double r) + { + rasterResolution = r; + } void setRasterMono(bool b) { processColorFormat = splashModeMono8; processColorFormatSpecified = true; } - void setUncompressPreloadedImages(bool b) { uncompressPreloadedImages = b; } + void setUncompressPreloadedImages(bool b) + { + uncompressPreloadedImages = b; + } - bool getEmbedType1() const { return embedType1; } - bool getEmbedTrueType() const { return embedTrueType; } - bool getEmbedCIDPostScript() const { return embedCIDPostScript; } - bool getEmbedCIDTrueType() const { return embedCIDTrueType; } - bool getFontPassthrough() const { return fontPassthrough; } - bool getOptimizeColorSpace() const { return optimizeColorSpace; } - bool getPassLevel1CustomColor() const { return passLevel1CustomColor; } - bool getEnableLZW() const { return enableLZW; }; + bool getEmbedType1() const + { + return embedType1; + } + bool getEmbedTrueType() const + { + return embedTrueType; + } + bool getEmbedCIDPostScript() const + { + return embedCIDPostScript; + } + bool getEmbedCIDTrueType() const + { + return embedCIDTrueType; + } + bool getFontPassthrough() const + { + return fontPassthrough; + } + bool getOptimizeColorSpace() const + { + return optimizeColorSpace; + } + bool getPassLevel1CustomColor() const + { + return passLevel1CustomColor; + } + bool getEnableLZW() const + { + return enableLZW; + }; bool getEnableFlate() const #ifdef ENABLE_ZLIB { @@ -339,19 +393,58 @@ public: return false; } #endif - void setEmbedType1(bool b) { embedType1 = b; } - void setEmbedTrueType(bool b) { embedTrueType = b; } - void setEmbedCIDPostScript(bool b) { embedCIDPostScript = b; } - void setEmbedCIDTrueType(bool b) { embedCIDTrueType = b; } - void setFontPassthrough(bool b) { fontPassthrough = b; } - void setOptimizeColorSpace(bool b) { optimizeColorSpace = b; } - void setPassLevel1CustomColor(bool b) { passLevel1CustomColor = b; } - void setPreloadImagesForms(bool b) { preloadImagesForms = b; } - void setGenerateOPI(bool b) { generateOPI = b; } - void setUseASCIIHex(bool b) { useASCIIHex = b; } - void setUseBinary(bool b) { useBinary = b; } - void setEnableLZW(bool b) { enableLZW = b; } - void setEnableFlate(bool b) { enableFlate = b; } + void setEmbedType1(bool b) + { + embedType1 = b; + } + void setEmbedTrueType(bool b) + { + embedTrueType = b; + } + void setEmbedCIDPostScript(bool b) + { + embedCIDPostScript = b; + } + void setEmbedCIDTrueType(bool b) + { + embedCIDTrueType = b; + } + void setFontPassthrough(bool b) + { + fontPassthrough = b; + } + void setOptimizeColorSpace(bool b) + { + optimizeColorSpace = b; + } + void setPassLevel1CustomColor(bool b) + { + passLevel1CustomColor = b; + } + void setPreloadImagesForms(bool b) + { + preloadImagesForms = b; + } + void setGenerateOPI(bool b) + { + generateOPI = b; + } + void setUseASCIIHex(bool b) + { + useASCIIHex = b; + } + void setUseBinary(bool b) + { + useBinary = b; + } + void setEnableLZW(bool b) + { + enableLZW = b; + } + void setEnableFlate(bool b) + { + enableFlate = b; + } void setProcessColorFormat(SplashColorMode format) { diff --git a/poppler/SplashOutputDev.h b/poppler/SplashOutputDev.h index 88b13b42..04614124 100644 --- a/poppler/SplashOutputDev.h +++ b/poppler/SplashOutputDev.h @@ -341,11 +341,20 @@ public: void setVectorAntialias(bool vaa) override; #endif - bool getFontAntialias() { return fontAntialias; } - void setFontAntialias(bool anti) { fontAntialias = anti; } + bool getFontAntialias() + { + return fontAntialias; + } + void setFontAntialias(bool anti) + { + fontAntialias = anti; + } void setFreeTypeHinting(bool enable, bool enableSlightHinting); - void setEnableFreeType(bool enable) { enableFreeType = enable; } + void setEnableFreeType(bool enable) + { + enableFreeType = enable; + } protected: void doUpdateFont(GfxState *state); diff --git a/poppler/TextOutputDev.h b/poppler/TextOutputDev.h index af007fa0..5e53bf7a 100644 --- a/poppler/TextOutputDev.h +++ b/poppler/TextOutputDev.h @@ -108,14 +108,32 @@ public: #ifdef TEXTOUT_WORD_LIST // Get the font name (which may be NULL). - const GooString *getFontName() const { return fontName; } + const GooString *getFontName() const + { + return fontName; + } // Get font descriptor flags. - bool isFixedWidth() const { return flags & fontFixedWidth; } - bool isSerif() const { return flags & fontSerif; } - bool isSymbolic() const { return flags & fontSymbolic; } - bool isItalic() const { return flags & fontItalic; } - bool isBold() const { return flags & fontBold; } + bool isFixedWidth() const + { + return flags & fontFixedWidth; + } + bool isSerif() const + { + return flags & fontSerif; + } + bool isSymbolic() const + { + return flags & fontSymbolic; + } + bool isItalic() const + { + return flags & fontItalic; + } + bool isBold() const + { + return flags & fontBold; + } #endif private: @@ -177,10 +195,19 @@ public: const TextWord *getNext() const { return next; } #ifdef TEXTOUT_WORD_LIST - int getLength() const { return len; } - const Unicode *getChar(int idx) const { return &text[idx]; } + int getLength() const + { + return len; + } + const Unicode *getChar(int idx) const + { + return &text[idx]; + } GooString *getText() const; - const GooString *getFontName(int idx) const { return font[idx]->fontName; } + const GooString *getFontName(int idx) const + { + return font[idx]->fontName; + } void getColor(double *r, double *g, double *b) const { *r = colorR; @@ -195,18 +222,51 @@ public: *yMaxA = yMax; } void getCharBBox(int charIdx, double *xMinA, double *yMinA, double *xMaxA, double *yMaxA) const; - double getFontSize() const { return fontSize; } - int getRotation() const { return rot; } - int getCharPos() const { return charPos[0]; } - int getCharLen() const { return charPos[len] - charPos[0]; } - bool getSpaceAfter() const { return spaceAfter; } + double getFontSize() const + { + return fontSize; + } + int getRotation() const + { + return rot; + } + int getCharPos() const + { + return charPos[0]; + } + int getCharLen() const + { + return charPos[len] - charPos[0]; + } + bool getSpaceAfter() const + { + return spaceAfter; + } #endif - bool isUnderlined() const { return underlined; } - const AnnotLink *getLink() const { return link; } - double getEdge(int i) const { return edge[i]; } - double getBaseline() const { return base; } - bool hasSpaceAfter() const { return spaceAfter; } - const TextWord *nextWord() const { return next; }; + bool isUnderlined() const + { + return underlined; + } + const AnnotLink *getLink() const + { + return link; + } + double getEdge(int i) const + { + return edge[i]; + } + double getBaseline() const + { + return base; + } + bool hasSpaceAfter() const + { + return spaceAfter; + } + const TextWord *nextWord() const + { + return next; + }; private: void ensureCapacity(int capacity); @@ -872,7 +932,10 @@ public: TextPage *takeText(); // Turn extra processing for HTML conversion on or off. - void enableHTMLExtras(bool doHTMLA) { doHTML = doHTMLA; } + void enableHTMLExtras(bool doHTMLA) + { + doHTML = doHTMLA; + } // Get the head of the linked list of TextFlows for the // last rasterized page. @@ -886,10 +949,22 @@ public: return eolUnix; #endif } - void setTextEOL(EndOfLineKind textEOLA) { textEOL = textEOLA; } - void setTextPageBreaks(bool textPageBreaksA) { textPageBreaks = textPageBreaksA; } - double getMinColSpacing1() const { return minColSpacing1; } - void setMinColSpacing1(double val) { minColSpacing1 = val; } + void setTextEOL(EndOfLineKind textEOLA) + { + textEOL = textEOLA; + } + void setTextPageBreaks(bool textPageBreaksA) + { + textPageBreaks = textPageBreaksA; + } + double getMinColSpacing1() const + { + return minColSpacing1; + } + void setMinColSpacing1(double val) + { + minColSpacing1 = val; + } private: TextOutputFunc outputFunc; // output function diff --git a/qt5/src/poppler-private.h b/qt5/src/poppler-private.h index 39dfb6b0..f94e6541 100644 --- a/qt5/src/poppler-private.h +++ b/qt5/src/poppler-private.h @@ -143,7 +143,10 @@ public: void addTocChildren(QDomDocument *docSyn, QDomNode *parent, const std::vector<::OutlineItem *> *items); - void setPaperColor(const QColor &color) { paperColor = color; } + void setPaperColor(const QColor &color) + { + paperColor = color; + } void fillMembers() { diff --git a/qt6/src/poppler-private.h b/qt6/src/poppler-private.h index d1f73353..45ed4b41 100644 --- a/qt6/src/poppler-private.h +++ b/qt6/src/poppler-private.h @@ -140,7 +140,10 @@ public: DocumentData(const DocumentData &) = delete; DocumentData &operator=(const DocumentData &) = delete; - void setPaperColor(const QColor &color) { paperColor = color; } + void setPaperColor(const QColor &color) + { + paperColor = color; + } void fillMembers() { diff --git a/splash/Splash.h b/splash/Splash.h index e13be54c..66167510 100644 --- a/splash/Splash.h +++ b/splash/Splash.h @@ -242,9 +242,18 @@ public: void setDebugMode(bool debugModeA) { debugMode = debugModeA; } #if 1 //~tmp: turn off anti-aliasing temporarily - void setInShading(bool sh) { inShading = sh; } - bool getVectorAntialias() { return vectorAntialias; } - void setVectorAntialias(bool vaa) { vectorAntialias = vaa; } + void setInShading(bool sh) + { + inShading = sh; + } + bool getVectorAntialias() + { + return vectorAntialias; + } + void setVectorAntialias(bool vaa) + { + vectorAntialias = vaa; + } #endif // Do shaded fills with dynamic patterns diff --git a/utils/InMemoryFile.h b/utils/InMemoryFile.h index a578f524..f4fcb27f 100644 --- a/utils/InMemoryFile.h +++ b/utils/InMemoryFile.h @@ -50,7 +50,10 @@ public: * and must be fclosed() by the caller before destruction. */ FILE *open(const char *mode); - const std::vector<char> &getBuffer() const { return data; } + const std::vector<char> &getBuffer() const + { + return data; + } }; #endif // IN_MEMORY_FILE_H