diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-08-31 07:53:55 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-09-06 14:00:47 +0200 |
commit | 962f1bb95fc38cafe56ea2ba134ce19392102601 (patch) | |
tree | 47c9f721807dd03585c0f7130ae7f6b24bd774e2 /vcl/source/filter | |
parent | 11292d1cc405e7c3b9e1f374cc7581a63a54b994 (diff) |
store annotation subtype in PDFGraphicAnnotation, enum for subtype
Change-Id: Ib804f497a6c8f609e4899f9ebcef4c1096f44ce0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102090
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source/filter')
-rw-r--r-- | vcl/source/filter/ipdf/pdfread.cxx | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index 5282a012d423..01ab6d3625cd 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -286,36 +286,43 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<PDFGraphicResult>& rG for (int nAnnotation = 0; nAnnotation < pPage->getAnnotationCount(); nAnnotation++) { auto pAnnotation = pPage->getAnnotation(nAnnotation); - if (pAnnotation && pAnnotation->getSubType() == 1 /*FPDF_ANNOT_TEXT*/ - && pAnnotation->hasKey(vcl::pdf::constDictionaryKeyPopup)) + if (pAnnotation) { - OUString sAuthor = pAnnotation->getString(vcl::pdf::constDictionaryKeyTitle); - OUString sText = pAnnotation->getString(vcl::pdf::constDictionaryKeyContents); - auto pPopupAnnotation = pAnnotation->getLinked(vcl::pdf::constDictionaryKeyPopup); - - basegfx::B2DRectangle rRectangle = pAnnotation->getRectangle(); - basegfx::B2DRectangle rRectangleHMM( - convertPointToMm100(rRectangle.getMinX()), - convertPointToMm100(aPageSize.getY() - rRectangle.getMinY()), - convertPointToMm100(rRectangle.getMaxX()), - convertPointToMm100(aPageSize.getY() - rRectangle.getMaxY())); - - OUString sDateTimeString - = pAnnotation->getString(vcl::pdf::constDictionaryKeyModificationDate); - OUString sISO8601String = vcl::pdf::convertPdfDateToISO8601(sDateTimeString); - - css::util::DateTime aDateTime; - if (!sISO8601String.isEmpty()) + auto eSubtype = pAnnotation->getSubType(); + + if (eSubtype == vcl::pdf::PDFAnnotationSubType::Text + && pAnnotation->hasKey(vcl::pdf::constDictionaryKeyPopup)) { - utl::ISO8601parseDateTime(sISO8601String, aDateTime); + OUString sAuthor = pAnnotation->getString(vcl::pdf::constDictionaryKeyTitle); + OUString sText = pAnnotation->getString(vcl::pdf::constDictionaryKeyContents); + auto pPopupAnnotation + = pAnnotation->getLinked(vcl::pdf::constDictionaryKeyPopup); + + basegfx::B2DRectangle rRectangle = pAnnotation->getRectangle(); + basegfx::B2DRectangle rRectangleHMM( + convertPointToMm100(rRectangle.getMinX()), + convertPointToMm100(aPageSize.getY() - rRectangle.getMinY()), + convertPointToMm100(rRectangle.getMaxX()), + convertPointToMm100(aPageSize.getY() - rRectangle.getMaxY())); + + OUString sDateTimeString + = pAnnotation->getString(vcl::pdf::constDictionaryKeyModificationDate); + OUString sISO8601String = vcl::pdf::convertPdfDateToISO8601(sDateTimeString); + + css::util::DateTime aDateTime; + if (!sISO8601String.isEmpty()) + { + utl::ISO8601parseDateTime(sISO8601String, aDateTime); + } + + PDFGraphicAnnotation aPDFGraphicAnnotation; + aPDFGraphicAnnotation.maRectangle = rRectangleHMM; + aPDFGraphicAnnotation.maAuthor = sAuthor; + aPDFGraphicAnnotation.maText = sText; + aPDFGraphicAnnotation.maDateTime = aDateTime; + aPDFGraphicAnnotation.meSubType = eSubtype; + aPDFGraphicAnnotations.push_back(aPDFGraphicAnnotation); } - - PDFGraphicAnnotation aPDFGraphicAnnotation; - aPDFGraphicAnnotation.maRectangle = rRectangleHMM; - aPDFGraphicAnnotation.maAuthor = sAuthor; - aPDFGraphicAnnotation.maText = sText; - aPDFGraphicAnnotation.maDateTime = aDateTime; - aPDFGraphicAnnotations.push_back(aPDFGraphicAnnotation); } } |