[poppler] poppler/Annot.cc poppler/Annot.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 29 13:32:52 UTC 2022


 poppler/Annot.cc |   22 +++++++++++-----------
 poppler/Annot.h  |    2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit f7f4ae85648fae49221c357fe496f650ae982983
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Mar 29 15:23:19 2022 +0200

    Rename variable, it's actually the number of cells

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 7d69bc94..5b7a4173 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -4300,7 +4300,7 @@ void AnnotAppearanceBuilder::writeString(const std::string &str)
 
 // Draw the variable text or caption for a field.
 bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da, const GfxResources *resources, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect,
-                                      const VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict, const int flags, const int combMaxLen)
+                                      const VariableTextQuadding quadding, XRef *xref, Dict *resourcesDict, const int flags, const int nCombs)
 {
     const bool forceZapfDingbats = flags & ForceZapfDingbatsDrawTextFlag;
 
@@ -4493,11 +4493,11 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da
         //~ replace newlines with spaces? - what does Acrobat do?
 
         // comb formatting
-        if (combMaxLen > 0) {
+        if (nCombs > 0) {
             int charCount;
 
             // compute comb spacing
-            const double w = (dx - 2 * borderWidth) / combMaxLen;
+            const double w = (dx - 2 * borderWidth) / nCombs;
 
             // compute font autosize
             if (fontSize == 0) {
@@ -4511,20 +4511,20 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da
 
             int dummy = 0;
             Annot::layoutText(text, &convertedText, &dummy, *font, nullptr, 0.0, &charCount, forceZapfDingbats);
-            if (charCount > combMaxLen) {
-                charCount = combMaxLen;
+            if (charCount > nCombs) {
+                charCount = nCombs;
             }
 
             // compute starting text cell
-            auto calculateX = [quadding, borderWidth, combMaxLen, charCount, w] {
+            auto calculateX = [quadding, borderWidth, nCombs, charCount, w] {
                 switch (quadding) {
                 case VariableTextQuadding::leftJustified:
                 default:
                     return borderWidth;
                 case VariableTextQuadding::centered:
-                    return borderWidth + (combMaxLen - charCount) / 2.0 * w;
+                    return borderWidth + (nCombs - charCount) / 2.0 * w;
                 case VariableTextQuadding::rightJustified:
-                    return borderWidth + (combMaxLen - charCount) * w;
+                    return borderWidth + (nCombs - charCount) * w;
                 }
             };
             const double x = calculateX();
@@ -4544,7 +4544,7 @@ bool AnnotAppearanceBuilder::drawText(const GooString *text, const GooString *da
             int len = convertedText.getLength();
             int i = 0;
             double xPrev = w; // so that first character is placed properly
-            while (i < combMaxLen && len > 0) {
+            while (i < nCombs && len > 0) {
                 CharCode code;
                 const Unicode *uAux;
                 int uLen, n;
@@ -5010,7 +5010,7 @@ bool AnnotAppearanceBuilder::drawFormFieldText(const FormFieldText *fieldText, c
             quadding = VariableTextQuadding::leftJustified;
         }
 
-        const int combMaxLen = fieldText->isComb() ? fieldText->getMaxLen() : 0;
+        const int nCombs = fieldText->isComb() ? fieldText->getMaxLen() : 0;
 
         int flags = EmitMarkedContentDrawTextFlag;
         if (fieldText->isMultiline()) {
@@ -5019,7 +5019,7 @@ bool AnnotAppearanceBuilder::drawFormFieldText(const FormFieldText *fieldText, c
         if (fieldText->isPassword()) {
             flags = flags | TurnTextToStarsDrawTextFlag;
         }
-        return drawText(contents, da, resources, border, appearCharacs, rect, quadding, xref, resourcesDict, flags, combMaxLen);
+        return drawText(contents, da, resources, border, appearCharacs, rect, quadding, xref, resourcesDict, flags, nCombs);
     }
 
     return true;
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 482bb33f..9ae274df 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -625,7 +625,7 @@ private:
                                 XRef *xref, Dict *resourcesDict);
     void drawSignatureFieldText(const GooString &text, const DefaultAppearance &da, const AnnotBorder *border, const PDFRectangle *rect, XRef *xref, Dict *resourcesDict, double leftMargin, bool centerVertically, bool centerHorizontally);
     bool drawText(const GooString *text, const GooString *da, const GfxResources *resources, const AnnotBorder *border, const AnnotAppearanceCharacs *appearCharacs, const PDFRectangle *rect, const VariableTextQuadding quadding, XRef *xref,
-                  Dict *resourcesDict, const int flags = NoDrawTextFlags, const int combMaxLen = 0);
+                  Dict *resourcesDict, const int flags = NoDrawTextFlags, const int nCombs = 0);
     void drawArrowPath(double x, double y, const Matrix &m, int orientation = 1);
 
     GooString *appearBuf;


More information about the poppler mailing list