[Libreoffice-commits] core.git: Branch 'private/Ashod/cd-5.3.3.2' - 2520 commits - accessibility/inc accessibility/source avmedia/source basctl/inc basctl/source basctl/uiconfig basegfx/source basic/inc basic/qa basic/source bin/findunusedcode bin/lo-commit-stat bin/lo-pack-sources bin/pack-debug bin/upload_symbols.py bridges/source canvas/source chart2/inc chart2/Library_chartcore.mk chart2/qa chart2/source chart2/uiconfig cli_ure/qa cli_ure/source codemaker/source comphelper/qa comphelper/source compilerplugins/clang config_host/config_features.h.in config_host/config_global.h.in config_host/config_graphite.h.in config_host/config_orcus.h.in config_host.mk.in configmgr/source configure.ac connectivity/Configuration_writer.mk connectivity/inc connectivity/Library_calc.mk connectivity/Library_file.mk connectivity/Library_firebird_sdbc.mk connectivity/Library_writer.mk connectivity/Module_connectivity.mk connectivity/registry connectivity/source cppcanvas/inc cppcanvas/qa cppcanvas/source cppuhelp er/source cui/inc cui/source cui/uiconfig dbaccess/inc dbaccess/qa dbaccess/source dbaccess/uiconfig desktop/CppunitTest_desktop_app.mk desktop/inc desktop/Library_sofficeapp.mk desktop/Module_desktop.mk desktop/qa desktop/source desktop/unx desktop/win32 dictionaries distro-configs/CPLinux.conf distro-configs/CPLinux-LOKit.conf distro-configs/CPLinux-MPL.conf distro-configs/CPOSX.conf distro-configs/CPWin32.conf distro-configs/CPWin32-MPL.conf distro-configs/Jenkins distro-configs/LibreOfficeCoverity.conf distro-configs/LibreOfficeEmscripten.conf distro-configs/LibreOfficeFlatpak.conf distro-configs/LibreOfficeLinux.conf download.lst drawinglayer/source dtrans/source editeng/inc editeng/qa editeng/source embeddedobj/Library_embobj.mk embeddedobj/source embedserv/source extensions/source extensions/uiconfig external/cairo external/clucene external/curl external/expat external/firebird external/fontconfig external/freetype external/hunspell external/icu external/jpeg external/jpeg-tu rbo external/libcmis external/libmwaw external/liborcus external/libstaroffice external/libwpd external/libxml2 external/Module_external.mk external/more_fonts external/noto_font external/nss external/pdfium external/poppler external/python3 external/python33 external/redland extras/Package_palettes.mk extras/source filter/Configuration_filter.mk filter/Library_xmlfd.mk filter/Package_xslt.mk filter/qa filter/source filter/uiconfig forms/inc forms/source formula/source fpicker/source framework/inc framework/Library_fwk.mk framework/source framework/uiconfig .gitignore .gitreview helpcontent2 hwpfilter/qa hwpfilter/source i18npool/inc i18npool/Library_localedata_others.mk i18npool/qa i18npool/source icon-themes/breeze icon-themes/breeze_dark icon-themes/breeze_svg icon-themes/elementary icon-themes/galaxy icon-themes/hicontrast icon-themes/sifr include/basegfx include/basic include/codemaker include/comphelper include/dbaccess include/desktop include/drawinglayer include/editeng incl ude/filter include/formula include/LibreOfficeKit include/o3tl include/oox include/osl include/rtl include/sal include/sfx2 include/sot include/svl include/svtools include/svx include/test include/toolkit include/tools include/ucbhelper include/unotest include/unotools include/vbahelper include/vcl include/xmloff include/xmlscript include/xmlsecurity instsetoo_native/CustomTarget_install.mk instsetoo_native/CustomTarget_setup.mk instsetoo_native/inc_common instsetoo_native/inc_ooohelppack instsetoo_native/inc_openoffice instsetoo_native/inc_sdkoo instsetoo_native/util jvmfwk/inc jvmfwk/plugins l10ntools/source librelogo/source libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Executable_tilebench.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/README libreofficekit/source lingucomponent/source linguistic/source lotuswordpro/qa lotuswordpro/source Makefile.fetch Makefile.in nlpsolver/src o3tl/qa odk/docs odk/examples odk/index.html odk/index_onlin e.html offapi/com offapi/UnoApi_offapi.mk officecfg/README officecfg/registry oox/CppunitTest_oox_tokenmap.mk oox/inc oox/Library_oox.mk oox/source package/inc package/source postprocess/CustomTarget_registry.mk postprocess/CustomTarget_signing.mk postprocess/Rdb_services.mk readlicense_oo/docs readlicense_oo/license readlicense_oo/Package_files.mk registry/source reportdesign/inc reportdesign/source reportdesign/uiconfig RepositoryExternal.mk Repository.mk ridljar/com salhelper/source sal/osl sal/qa sal/rtl sal/textenc sal/util sax/source sccomp/source sc/CppunitTest_sc_macros_test.mk sc/CppunitTest_sc_subsequent_filters_test.mk sc/inc sc/Library_scfilt.mk sc/Library_sc.mk sc/Library_scui.mk scp2/inc scp2/source sc/qa scripting/Module_scripting.mk scripting/source sc/sdi sc/source sc/uiconfig sd/CppunitTest_sd_tiledrendering.mk sdext/CppunitTest_sdext_pdfimport.mk sdext/Executable_pdf2xml.mk sdext/Executable_pdfunzip.mk sdext/Library_pdfimport.mk sdext/Library_PresentationMinimizer .mk sdext/source sd/inc sd/Library_sd.mk sd/qa sd/sdi sd/source sd/uiconfig sd/util setup_native/source sfx2/emojiconfig sfx2/Library_sfx.mk sfx2/qa sfx2/sdi sfx2/source sfx2/uiconfig shell/CustomTarget_spsupp_idl.mk shell/CustomTarget_x64.mk shell/inc shell/Library_spsupp.mk shell/Library_spsupp_x64.mk shell/Library_syssh.mk shell/Module_shell.mk shell/source shell/WinResTarget_spsupp.mk slideshow/inc slideshow/source solenv/bin solenv/CompilerTest_compilerplugins_clang.mk solenv/gbuild solenv/gcc-wrappers solenv/gdb solenv/qa sot/inc sot/source starmath/inc starmath/qa starmath/source starmath/uiconfig stoc/source stoc/test svgio/inc svgio/qa svgio/source svl/source svtools/inc svtools/qa svtools/source svx/CppunitTest_svx_unit.mk svx/Executable_gengal.mk svx/inc svx/Library_svxcore.mk svx/qa svx/sdi svx/source svx/uiconfig sw/CppunitTest_sw_docbookexport.mk sw/CppunitTest_sw_globalfilter.mk sw/CppunitTest_sw_mailmerge.mk sw/CppunitTest_sw_odfexport.mk sw/CppunitTest_sw_odfimport. mk sw/CppunitTest_sw_ooxmlencryption.mk sw/CppunitTest_sw_ooxmlexport8.mk sw/CppunitTest_sw_ooxmlimport.mk sw/CppunitTest_sw_rtfexport.mk sw/CppunitTest_sw_rtfimport.mk sw/CppunitTest_sw_txtexport.mk sw/CppunitTest_sw_ww8export2.mk sw/CppunitTest_sw_ww8import.mk swext/mediawiki sw/inc sw/Library_msword.mk sw/Library_sw.mk sw/Module_sw.mk sw/ooxmlexport_setup.mk sw/qa sw/README sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk sysui/desktop sysui/productlist.mk test/source toolkit/source tools/inc tools/Library_tl.mk tools/qa tools/source translations ucbhelper/source ucb/Library_ucpfile1.mk ucb/source unotest/source unotools/inc unotools/source unusedcode.easy unusedcode.README uui/AllLangResTarget_uui.mk uui/Library_uui.mk uui/source vbahelper/inc vbahelper/source vcl/backendtest vcl/CppunitTest_vcl_pdfexport.mk vcl/CppunitTest_vcl_wmf_test.mk vcl/CustomTarget_afm_hash.mk vcl/headless vcl/inc vcl/Library_vcl.mk vcl/Module_vcl.mk vcl/opengl vcl/osx vcl/qa vcl/quartz vcl/README.GDI MetaFile vcl/source vcl/unx vcl/win vcl/workben winaccessibility/source wizards/com wizards/source writerfilter/inc writerfilter/source writerperfect/source xmloff/inc xmloff/Library_xo.mk xmloff/source xmlscript/source xmlsecurity/CppunitTest_xmlsecurity_pdfsigning.mk xmlsecurity/CppunitTest_xmlsecurity_signing.mk xmlsecurity/Executable_pdfverify.mk xmlsecurity/inc xmlsecurity/Library_xmlsecurity.mk xmlsecurity/Module_xmlsecurity.mk xmlsecurity/qa xmlsecurity/source xmlsecurity/uiconfig xmlsecurity/workben

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon May 21 12:27:57 UTC 2018


Rebased ref, commits from common ancestor:
commit 437a07db27679d33ddc0fdb716196d94fb1a39b4
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun May 20 22:31:36 2018 -0400

    sd: disable pdf import tests
    
    Change-Id: Iaee679d2ff322c67d081185588103d5685fa970a

diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 0f3bf242f8cb..4f1dd46e1bba 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -122,7 +122,7 @@ public:
     void testTableBorderLineStyle();
     void testBnc862510_6();
     void testBnc862510_7();
-#if ENABLE_PDFIMPORT
+#if ENABLE_PDFIMPORT && defined(IMPORT_PDF_ELEMENTS)
     void testPDFImport();
     void testPDFImportSkipImages();
 #endif
@@ -195,7 +195,7 @@ public:
     CPPUNIT_TEST(testTableBorderLineStyle);
     CPPUNIT_TEST(testBnc862510_6);
     CPPUNIT_TEST(testBnc862510_7);
-#if ENABLE_PDFIMPORT
+#if ENABLE_PDFIMPORT && defined(IMPORT_PDF_ELEMENTS)
     CPPUNIT_TEST(testPDFImport);
     CPPUNIT_TEST(testPDFImportSkipImages);
 #endif
@@ -1174,7 +1174,7 @@ void SdImportTest::testBnc862510_7()
     xDocShRef->DoClose();
 }
 
-#if ENABLE_PDFIMPORT
+#if ENABLE_PDFIMPORT && defined(IMPORT_PDF_ELEMENTS)
 
 void SdImportTest::testPDFImport()
 {
commit e8b81d5607d451d05de20be82f3f801991bf9d74
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Nov 14 09:17:59 2017 -0500

    gtktiledviewer downgrade min gtk+ to 3.16
    
    Change-Id: Ieb964ec1bbdeb632bd771db9b773f64b78107fc5
    Reviewed-on: https://gerrit.libreoffice.org/44724
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit a3f432a68733b6e76ecb68cf5704a59d1be1e5cb)

diff --git a/libreofficekit/qa/gtktiledviewer/gtv.ui b/libreofficekit/qa/gtktiledviewer/gtv.ui
index af5737c6a3dc..c3296d3c9c04 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv.ui
+++ b/libreofficekit/qa/gtktiledviewer/gtv.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- Generated with glade 3.20.0 -->
 <interface>
-  <requires lib="gtk+" version="3.20"/>
+  <requires lib="gtk+" version="3.16"/>
   <object class="GtkBox" id="container">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
commit eba16e104b14d401c8153628c90e50bddfec9f60
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun May 20 15:17:16 2018 -0400

    svx: set the font name of imported PDF text
    
    Change-Id: I79dde3c8983a70311de2d2a46093fac2722fb372

diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1
index de57d10e1be6..d0d7cb97060e 100644
--- a/external/pdfium/edit.patch.1
+++ b/external/pdfium/edit.patch.1
@@ -111,7 +111,7 @@ index fed1581..968b84a 100644
  FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
                                   void* buffer,
 diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
-index ec29891..a52e1a9 100644
+index ec29891..9daffc0 100644
 --- a/fpdfsdk/fpdf_editpage.cpp
 +++ b/fpdfsdk/fpdf_editpage.cpp
 @@ -12,12 +12,14 @@
@@ -137,7 +137,7 @@ index ec29891..a52e1a9 100644
  #include "fpdfsdk/cpdfsdk_helpers.h"
  #include "public/fpdf_formfill.h"
  #include "third_party/base/logging.h"
-@@ -624,3 +627,245 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
+@@ -624,3 +627,268 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
    pPageObj->SetDirty(true);
    return true;
  }
@@ -162,6 +162,29 @@ index ec29891..a52e1a9 100644
 +  return pTxtObj->GetFontSize();
 +}
 +
++FPDF_EXPORT int FPDF_CALLCONV
++FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text_object, char* result)
++{
++  if (!text_object)
++    return 0;
++
++  CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
++  CPDF_Font* pPdfFont = pTxtObj->GetFont();
++  if (!pPdfFont)
++    return 0;
++
++  CFX_Font* pFont = pPdfFont->GetFont();
++  if (!pFont)
++    return 0;
++
++  ByteString byte_str = pFont->GetFamilyName();
++  const size_t byte_str_len = byte_str.GetLength();
++
++  memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len);
++  result[byte_str_len] = '\0';
++  return byte_str_len;
++}
++
 +FPDF_EXPORT void FPDF_CALLCONV
 +FPDFTextObj_GetMatrix(FPDF_PAGEOBJECT text_object,
 +                      double* a,
@@ -495,7 +518,7 @@ index a1bbbb4..01b74c9 100644
                                                          int index,
                                                          double* left,
 diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
-index c0766a3..4351649 100644
+index c0766a3..75381bb 100644
 --- a/public/fpdf_edit.h
 +++ b/public/fpdf_edit.h
 @@ -660,6 +660,15 @@ FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object,
@@ -551,7 +574,7 @@ index c0766a3..4351649 100644
  // Create a new text object using one of the standard PDF fonts.
  //
  // document   - handle to the document.
-@@ -971,6 +1010,125 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
+@@ -971,6 +1010,135 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
                            FPDF_FONT font,
                            float font_size);
  
@@ -564,7 +587,6 @@ index c0766a3..4351649 100644
 +FPDF_EXPORT int FPDF_CALLCONV
 +FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
 +
-+
 +// Get the font size of a text object.
 +//
 +// text_object - Handle of text object returned by FPDFPageObj_NewTextObj
@@ -575,6 +597,17 @@ index c0766a3..4351649 100644
 +FPDF_EXPORT int FPDF_CALLCONV
 +FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object);
 +
++// Get the font name of a text object.
++//
++// text_object - Handle of text object returned by FPDFPageObj_NewTextObj
++//               or FPDFPageObj_NewTextObjEx.
++// result - The result in ascii.
++//
++// Return Value:
++// The number of characters / bytes written in result.
++FPDF_EXPORT int FPDF_CALLCONV
++FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text_object, char* result);
++
 +// Get the matrix of a particular text object.
 +//
 +// text_object - Handle of text object returned by FPDFPageObj_NewTextObj
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 4aa05fb30551..6855395b0ab8 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -924,6 +924,20 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
         mbFntDirty = true;
     }
 
+    std::unique_ptr<char[]> pFontName(new char[80 + 1]); // + terminating null
+    char* pCharFontName = reinterpret_cast<char*>(pFontName.get());
+    int nFontNameChars = FPDFTextObj_GetFontName(pPageObject, pCharFontName);
+    if (nFontNameChars > 0)
+    {
+        OUString sFontName = OUString::createFromAscii(pFontName.get());
+        if (sFontName != aFnt.GetFamilyName())
+        {
+            aFnt.SetFamilyName(sFontName);
+            mpVD->SetFont(aFnt);
+            mbFntDirty = true;
+        }
+    }
+
     Color aTextColor(COL_TRANSPARENT);
     unsigned int nR, nG, nB, nA;
     if (FPDFTextObj_GetColor(pPageObject, &nR, &nG, &nB, &nA))
@@ -1206,11 +1220,11 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI
 
     if (!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aPolyPoly)))
     {
-    SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
-    pPath->SetModel(mpModel);
-    SetAttributes(pPath);
-    InsertObj(pPath, false);
-}
+        SdrPathObj *pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
+        pPath->SetModel(mpModel);
+        SetAttributes(pPath);
+        InsertObj(pPath, false);
+    }
 }
 
 Point ImpSdrPdfImport::PointsToLogic(double x, double y) const
commit 274bc562b87364be315b2ec85c17ae25c96c90ef
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat May 19 21:28:31 2018 -0400

    svx: update PDFium patch and code
    
    Change-Id: I07c6a7c65d5631b70da64927a35d7a3b371eff25

diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1
index 5b23140c2069..de57d10e1be6 100644
--- a/external/pdfium/edit.patch.1
+++ b/external/pdfium/edit.patch.1
@@ -1,61 +1,10 @@
-diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp
-index 693fcf1..14e883f 100644
---- a/core/fpdfapi/page/cpdf_colorstate.cpp
-+++ b/core/fpdfapi/page/cpdf_colorstate.cpp
-@@ -124,7 +124,7 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
-                                uint32_t& rgb,
-                                CPDF_ColorSpace* pCS,
-                                float* pValue,
--                               uint32_t nValues) {
-+                               uint32_t nValues) const {
-   if (pCS)
-     color.SetColorSpace(pCS);
-   else if (color.IsNull())
-diff --git a/core/fpdfapi/page/cpdf_colorstate.h b/core/fpdfapi/page/cpdf_colorstate.h
-index 9619051..dbe9c47 100644
---- a/core/fpdfapi/page/cpdf_colorstate.h
-+++ b/core/fpdfapi/page/cpdf_colorstate.h
-@@ -64,7 +64,7 @@ class CPDF_ColorState {
-                 uint32_t& rgb,
-                 CPDF_ColorSpace* pCS,
-                 float* pValue,
--                uint32_t nValues);
-+                uint32_t nValues) const;
- 
-   SharedCopyOnWrite<ColorData> m_Ref;
- };
-diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.cpp b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
-index afd2c98..2c8e061 100644
---- a/core/fpdfapi/page/cpdf_pageobjectlist.cpp
-+++ b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
-@@ -8,6 +8,6 @@
- 
- #include "third_party/base/stl_util.h"
- 
--CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) {
-+CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) const {
-   return pdfium::IndexInBounds(*this, index) ? (*this)[index].get() : nullptr;
- }
-diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.h b/core/fpdfapi/page/cpdf_pageobjectlist.h
-index b450537..77c7d81 100644
---- a/core/fpdfapi/page/cpdf_pageobjectlist.h
-+++ b/core/fpdfapi/page/cpdf_pageobjectlist.h
-@@ -15,7 +15,7 @@ class CPDF_PageObject;
- class CPDF_PageObjectList
-     : public std::deque<std::unique_ptr<CPDF_PageObject>> {
-  public:
--  CPDF_PageObject* GetPageObjectByIndex(int index);
-+  CPDF_PageObject* GetPageObjectByIndex(int index) const;
- };
- 
- #endif  // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECTLIST_H_
 diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
-index e712549..a7973f7 100644
+index 5690698..4d7c48a 100644
 --- a/core/fpdftext/cpdf_textpage.cpp
 +++ b/core/fpdftext/cpdf_textpage.cpp
-@@ -1490,3 +1490,32 @@ bool CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1,
-   rect.Intersect(rect2);
-   return !rect.IsEmpty();
+@@ -1464,3 +1464,32 @@ Optional<PAGECHAR_INFO> CPDF_TextPage::GenerateCharInfo(wchar_t unicode) {
+                                  info.m_Origin.x, info.m_Origin.y);
+   return info;
  }
 +
 +WideString CPDF_TextPage::GetTextObjectText(CPDF_TextObject* pTextObj)
@@ -87,10 +36,10 @@ index e712549..a7973f7 100644
 +  return strText;
 +}
 diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
-index c87ab00..e5a1ba8 100644
+index 43a0312..7d5d5ec 100644
 --- a/core/fpdftext/cpdf_textpage.h
 +++ b/core/fpdftext/cpdf_textpage.h
-@@ -110,6 +110,8 @@ class CPDF_TextPage {
+@@ -105,6 +105,8 @@ class CPDF_TextPage {
    WideString GetPageText(int start, int count) const;
    WideString GetAllPageText() const { return GetPageText(0, CountChars()); }
  
@@ -99,12 +48,43 @@ index c87ab00..e5a1ba8 100644
    int CountRects(int start, int nCount);
    bool GetRect(int rectIndex, CFX_FloatRect* pRect) const;
  
-diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
-index 0d7ba56..37bdf99 100644
---- a/fpdfsdk/fpdfeditimg.cpp
-+++ b/fpdfsdk/fpdfeditimg.cpp
-@@ -167,6 +167,26 @@ FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object) {
-   return pBitmap.Leak();
+diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h
+index d93ecfc..c700592 100644
+--- a/fpdfsdk/cpdfsdk_helpers.h
++++ b/fpdfsdk/cpdfsdk_helpers.h
+@@ -40,7 +40,8 @@ class CPDF_TextPage;
+ class CPDF_TextPageFind;
+ class IPDFSDK_PauseAdapter;
+ class FX_PATHPOINT;
+-
++class CPDF_TextObject;
++class CPDF_FormObject;
+ #ifdef PDF_ENABLE_XFA
+ class CPDFXFA_Context;
+ class CPDFXFA_Page;
+@@ -204,6 +205,16 @@ inline CPDF_TextPageFind* CPDFTextPageFindFromFPDFSchHandle(
+   return reinterpret_cast<CPDF_TextPageFind*>(handle);
+ }
+ 
++inline CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(
++    FPDF_PAGEOBJECT page_object) {
++  return reinterpret_cast<CPDF_TextObject*>(page_object);
++}
++
++inline CPDF_FormObject* CPDFFormObjectFromFPDFPageObject(
++    FPDF_PAGEOBJECT page_object) {
++  return reinterpret_cast<CPDF_FormObject*>(page_object);
++}
++
+ ByteString CFXByteStringFromFPDFWideString(FPDF_WIDESTRING wide_string);
+ 
+ #ifdef PDF_ENABLE_XFA
+diff --git a/fpdfsdk/fpdf_editimg.cpp b/fpdfsdk/fpdf_editimg.cpp
+index fed1581..968b84a 100644
+--- a/fpdfsdk/fpdf_editimg.cpp
++++ b/fpdfsdk/fpdf_editimg.cpp
+@@ -186,6 +186,26 @@ FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object) {
+   return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
  }
  
 +FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV
@@ -124,18 +104,18 @@ index 0d7ba56..37bdf99 100644
 +  RetainPtr<CFX_DIBitmap> pBitmap;
 +  pBitmap = pSource->CloneConvert(FXDIB_Argb);
 +
-+  return pBitmap.Leak();
++  return FPDFBitmapFromCFXDIBitmap(pBitmap.Leak());
 +}
 +
  FPDF_EXPORT unsigned long FPDF_CALLCONV
  FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
                                   void* buffer,
-diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
-index ca2cf3f..1eaa232 100644
---- a/fpdfsdk/fpdfeditpage.cpp
-+++ b/fpdfsdk/fpdfeditpage.cpp
-@@ -11,12 +11,14 @@
- #include <utility>
+diff --git a/fpdfsdk/fpdf_editpage.cpp b/fpdfsdk/fpdf_editpage.cpp
+index ec29891..a52e1a9 100644
+--- a/fpdfsdk/fpdf_editpage.cpp
++++ b/fpdfsdk/fpdf_editpage.cpp
+@@ -12,12 +12,14 @@
+ #include <vector>
  
  #include "core/fpdfapi/edit/cpdf_pagecontentgenerator.h"
 +#include "core/fpdfapi/font/cpdf_font.h"
@@ -149,16 +129,16 @@ index ca2cf3f..1eaa232 100644
  #include "core/fpdfapi/page/cpdf_shadingobject.h"
  #include "core/fpdfapi/parser/cpdf_array.h"
  #include "core/fpdfapi/parser/cpdf_document.h"
-@@ -24,6 +26,7 @@
+@@ -25,6 +27,7 @@
  #include "core/fpdfapi/parser/cpdf_string.h"
  #include "core/fpdfdoc/cpdf_annot.h"
  #include "core/fpdfdoc/cpdf_annotlist.h"
 +#include "core/fpdftext/cpdf_textpage.h"
- #include "fpdfsdk/fsdk_define.h"
+ #include "fpdfsdk/cpdfsdk_helpers.h"
  #include "public/fpdf_formfill.h"
  #include "third_party/base/logging.h"
-@@ -363,3 +366,240 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
-   *top = bbox.top;
+@@ -624,3 +627,245 @@ FPDFPageObj_SetLineCap(FPDF_PAGEOBJECT page_object, int line_cap) {
+   pPageObj->SetDirty(true);
    return true;
  }
 +
@@ -252,7 +232,7 @@ index ca2cf3f..1eaa232 100644
 +  int ret_count = byte_str_len / sizeof(unsigned short);
 +
 +  ASSERT(ret_count <= char_count + 1);  // +1 to account for the NUL terminator.
-+  memcpy(result, byte_str.GetBuffer(byte_str_len), byte_str_len);
++  memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len);
 +  return ret_count;
 +}
 +
@@ -292,7 +272,7 @@ index ca2cf3f..1eaa232 100644
 +  int ret_count = byte_str_len / kBytesPerCharacter;
 +
 +  ASSERT(ret_count <= char_count + 1);  // +1 to account for the NUL terminator.
-+  memcpy(result, byte_str.GetBuffer(byte_str_len), byte_str_len);
++  memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len);
 +  return ret_count;
 +}
 +
@@ -335,10 +315,15 @@ index ca2cf3f..1eaa232 100644
 +      return false;
 +  }
 +
-+  const uint32_t RGB = bStroke ? pTxtObj->m_ColorState.GetStrokeRGB() : pTxtObj->m_ColorState.GetFillRGB();
-+  *R = FXSYS_GetRValue(RGB);
-+  *G = FXSYS_GetGValue(RGB);
-+  *B = FXSYS_GetBValue(RGB);
++  const CPDF_Color* pColor = bStroke ? pTxtObj->m_ColorState.GetStrokeColor() : pTxtObj->m_ColorState.GetFillColor();
++  if (pColor == nullptr)
++    return false;
++
++  int r, g, b;
++  pColor->GetRGB(&r, &g, &b);
++  *R = r;
++  *G = g;
++  *B = b;
 +  *A = static_cast<unsigned int>(
 +      (pTxtObj->m_GeneralState.GetStrokeAlpha() * 255.f) + 0.5f);
 +
@@ -368,7 +353,7 @@ index ca2cf3f..1eaa232 100644
 +    const CFX_Matrix& matrix = pFrmObj->form_matrix();
 +    const CPDF_PageObjectList* pObjectList = pFrmObj->form()->GetPageObjectList();
 +    if (pObjectList)
-+        return pObjectList->GetPageObjectByIndex(index);
++        return FPDFPageObjectFromCPDFPageObject(pObjectList->GetPageObjectByIndex(index));
 +  }
 +
 +  return nullptr;
@@ -398,11 +383,11 @@ index ca2cf3f..1eaa232 100644
 +    *f = matrix.f;
 +  }
 +}
-diff --git a/fpdfsdk/fpdfeditpath.cpp b/fpdfsdk/fpdfeditpath.cpp
-index a291987..0202284 100644
---- a/fpdfsdk/fpdfeditpath.cpp
-+++ b/fpdfsdk/fpdfeditpath.cpp
-@@ -101,6 +101,16 @@ FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width) {
+diff --git a/fpdfsdk/fpdf_editpath.cpp b/fpdfsdk/fpdf_editpath.cpp
+index aca2beb..017dbcd 100644
+--- a/fpdfsdk/fpdf_editpath.cpp
++++ b/fpdfsdk/fpdf_editpath.cpp
+@@ -117,6 +117,16 @@ FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width) {
    return true;
  }
  
@@ -419,7 +404,7 @@ index a291987..0202284 100644
  FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetFillColor(FPDF_PAGEOBJECT path,
                                                            unsigned int R,
                                                            unsigned int G,
-@@ -217,6 +227,25 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
+@@ -235,6 +245,25 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
    return true;
  }
  
@@ -445,7 +430,7 @@ index a291987..0202284 100644
  FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT path,
                                                      int line_join) {
    if (!path)
-@@ -250,6 +279,30 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT path,
+@@ -268,6 +297,30 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT path,
  }
  
  FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
@@ -476,22 +461,11 @@ index a291987..0202284 100644
  FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y) {
    auto* pPathPoint = FXPathPointFromFPDFPathSegment(segment);
    if (!pPathPoint || !x || !y)
-diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp
-index 68bf4f8..1cac9c7 100644
---- a/fpdfsdk/fpdftext.cpp
-+++ b/fpdfsdk/fpdftext.cpp
-@@ -31,10 +31,6 @@ namespace {
- 
- constexpr size_t kBytesPerCharacter = sizeof(unsigned short);
- 
--CPDF_TextPage* CPDFTextPageFromFPDFTextPage(FPDF_TEXTPAGE text_page) {
--  return static_cast<CPDF_TextPage*>(text_page);
--}
--
- CPDF_TextPageFind* CPDFTextPageFindFromFPDFSchHandle(FPDF_SCHHANDLE handle) {
-   return static_cast<CPDF_TextPageFind*>(handle);
- }
-@@ -105,6 +101,28 @@ FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
+diff --git a/fpdfsdk/fpdf_text.cpp b/fpdfsdk/fpdf_text.cpp
+index a1bbbb4..01b74c9 100644
+--- a/fpdfsdk/fpdf_text.cpp
++++ b/fpdfsdk/fpdf_text.cpp
+@@ -95,6 +95,28 @@ FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
    return charinfo.m_FontSize;
  }
  
@@ -520,65 +494,13 @@ index 68bf4f8..1cac9c7 100644
  FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page,
                                                          int index,
                                                          double* left,
-diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
-index e890aa0..09d2345 100644
---- a/fpdfsdk/fpdfview.cpp
-+++ b/fpdfsdk/fpdfview.cpp
-@@ -336,6 +336,20 @@ CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
- #endif  // PDF_ENABLE_XFA
- }
- 
-+CPDF_TextPage* CPDFTextPageFromFPDFTextPage(FPDF_TEXTPAGE text_page) {
-+  return static_cast<CPDF_TextPage*>(text_page);
-+}
-+
-+CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
-+  auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
-+  return obj ? obj->AsText() : nullptr;
-+}
-+
-+CPDF_FormObject* CPDFFormObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
-+  auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
-+  return obj ? obj->AsForm() : nullptr;
-+}
-+
- CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object) {
-   auto* obj = CPDFPageObjectFromFPDFPageObject(page_object);
-   return obj ? obj->AsPath() : nullptr;
-diff --git a/fpdfsdk/fsdk_define.h b/fpdfsdk/fsdk_define.h
-index 77c2315..e9a309a 100644
---- a/fpdfsdk/fsdk_define.h
-+++ b/fpdfsdk/fsdk_define.h
-@@ -25,6 +25,9 @@ class CPDF_Annot;
- class CPDF_Page;
- class CPDF_PageObject;
- class CPDF_PageRenderContext;
-+class CPDF_TextObject;
-+class CPDF_TextPage;
-+class CPDF_FormObject;
- class CPDF_PathObject;
- class CPDF_Stream;
- class IFSDK_PAUSE_Adapter;
-@@ -65,6 +68,12 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
- 
- CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
- 
-+CPDF_TextPage* CPDFTextPageFromFPDFTextPage(FPDF_TEXTPAGE text_page);
-+
-+CPDF_TextObject* CPDFTextObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object);
-+
-+CPDF_FormObject* CPDFFormObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object);
-+
- CPDF_PathObject* CPDFPathObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object);
- 
- CPDF_PageObject* CPDFPageObjectFromFPDFPageObject(FPDF_PAGEOBJECT page_object);
 diff --git a/public/fpdf_edit.h b/public/fpdf_edit.h
-index 54735a3..4d81aac 100644
+index c0766a3..4351649 100644
 --- a/public/fpdf_edit.h
 +++ b/public/fpdf_edit.h
-@@ -520,6 +520,15 @@ FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path,
- FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
- FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width);
+@@ -660,6 +660,15 @@ FPDFPageObj_GetStrokeColor(FPDF_PAGEOBJECT page_object,
+                            unsigned int* B,
+                            unsigned int* A);
  
 +// Get the stroke width of a path.
 +//
@@ -589,10 +511,10 @@ index 54735a3..4d81aac 100644
 +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
 +FPDFPath_GetStrokeWidth(FPDF_PAGEOBJECT path, float* width);
 +
- // Set the line join of |page_object|.
+ // Set the stroke width of a path.
  //
- // page_object  - handle to a page object.
-@@ -688,6 +697,36 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
+ // path   - the handle to the path object.
+@@ -898,6 +907,36 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path,
                                                           int fillmode,
                                                           FPDF_BOOL stroke);
  
@@ -629,7 +551,7 @@ index 54735a3..4d81aac 100644
  // Create a new text object using one of the standard PDF fonts.
  //
  // document   - handle to the document.
-@@ -761,6 +800,125 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
+@@ -971,6 +1010,125 @@ FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document,
                            FPDF_FONT font,
                            float font_size);
  
@@ -756,7 +678,7 @@ index 54735a3..4d81aac 100644
  }  // extern "C"
  #endif  // __cplusplus
 diff --git a/public/fpdf_text.h b/public/fpdf_text.h
-index 043dc16..fe3b971 100644
+index 3502337..6524cd3 100644
 --- a/public/fpdf_text.h
 +++ b/public/fpdf_text.h
 @@ -342,6 +342,26 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetSchCount(FPDF_SCHHANDLE handle);
@@ -787,10 +709,10 @@ index 043dc16..fe3b971 100644
  //          Prepare information about weblinks in a page.
  // Parameters:
 diff --git a/public/fpdfview.h b/public/fpdfview.h
-index 35e87ae..80ab0ad 100644
+index 0ccd140..b451b9c 100644
 --- a/public/fpdfview.h
 +++ b/public/fpdfview.h
-@@ -908,6 +908,9 @@ FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
+@@ -905,6 +905,9 @@ FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_CreateEx(int width,
  //          function; see the list of such formats above.
  FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetFormat(FPDF_BITMAP bitmap);
  
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index b0a06abda9e2..4aa05fb30551 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1024,7 +1024,8 @@ void ImpSdrPdfImport::MapScaling()
 
 void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
 {
-    std::unique_ptr<void, FPDFBitmapDeleter> bitmap(FPDFImageObj_GetBitmapBgra(pPageObject));
+    std::unique_ptr<std::remove_pointer<FPDF_BITMAP>::type, FPDFBitmapDeleter>
+                        bitmap(FPDFImageObj_GetBitmapBgra(pPageObject));
     if (!bitmap)
     {
         SAL_WARN("sd.filter", "Failed to get IMAGE");
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index e461c1f5e014..b4b83d9ac235 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -40,9 +40,9 @@ class SdrModel;
 class SdrPage;
 class SdrObject;
 class SvdProgressInfo;
-typedef void* FPDF_DOCUMENT;
-typedef void* FPDF_PAGEOBJECT;
-typedef void* FPDF_TEXTPAGE;
+typedef struct fpdf_document_t__* FPDF_DOCUMENT;
+typedef struct fpdf_pageobject_t__* FPDF_PAGEOBJECT;  // (text, path, etc.)
+typedef struct fpdf_textpage_t__* FPDF_TEXTPAGE;
 
 // Helper Class to import PDF
 class ImpSdrPdfImport final
commit 422b919a33e407cdd6c53f413d99cbc4fb09e0be
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon May 14 08:55:58 2018 +0200

    pdfium: update to 3426
    
    Allows dropping the ugly freetype.patch.1.
    
    Reviewed-on: https://gerrit.libreoffice.org/54294
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 56195a4d0bbb21edeed1cea7a45283141c733f18)
    
    Change-Id: Ifa8a6dac02a49a2c13572e59773261a847efad3f

diff --git a/download.lst b/download.lst
index 48cd8233db80..088b4f0f8280 100644
--- a/download.lst
+++ b/download.lst
@@ -150,9 +150,9 @@ export OWNCLOUD_ANDROID_LIB_MD5SUM := 593f0aa47bf2efc0efda2d28fae063b2
 export OWNCLOUD_ANDROID_LIB_TARBALL := owncloud-android-library-0.9.4-no-binary-deps.tar.gz
 export PAGEMAKER_MD5SUM := 5c4985a68be0b79d3f809da5e12b143c
 export PAGEMAKER_TARBALL := libpagemaker-0.0.3.tar.bz2
-export PDFIUM_MD5SUM := 68751a42676da36eaf9a40c1aaa9011b
-export PDFIUM_SHA256SUM := 0cd451fb1b301dc1df55f91e644092e505032dcddbdeaf3e2744039377d1bfd0
-export PDFIUM_TARBALL := pdfium-3358.tar.bz2
+export PDFIUM_MD5SUM := a66dbb357661c36b3e412a54de4c8fc2
+export PDFIUM_SHA256SUM := 80331b48166501a192d65476932f17044eeb5f10faa6ea50f4f175169475c957
+export PDFIUM_TARBALL := pdfium-3426.tar.bz2
 export PIXMAN_SHA256SUM := 21b6b249b51c6800dc9553b65106e1e37d0e25df942c90531d4c3997aa20a88e
 export PIXMAN_TARBALL := e80ebae4da01e77f68744319f01d52a3-pixman-0.34.0.tar.gz
 export PNG_MD5SUM := 897ccec1ebfb0922e83c2bfaa1be8748
diff --git a/external/pdfium/Library_pdfium.mk b/external/pdfium/Library_pdfium.mk
index 95ea5abfd0d0..0b81ab8c45c7 100644
--- a/external/pdfium/Library_pdfium.mk
+++ b/external/pdfium/Library_pdfium.mk
@@ -40,7 +40,6 @@ $(eval $(call gb_Library_set_generated_cxx_suffix,pdfium,cpp))
 
 # pdfium
 $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
-    UnpackedTarball/pdfium/fpdfsdk/cba_annotiterator \
     UnpackedTarball/pdfium/fpdfsdk/cfx_systemhandler \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annot \
     UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annothandlermgr \
@@ -61,22 +60,27 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/fpdfsdk/fpdf_structtree \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_sysfontinfo \
     UnpackedTarball/pdfium/fpdfsdk/fpdf_transformpage \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfdoc \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfeditimg \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfeditpage \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfeditpath \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfedittext \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfformfill \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfsave \
-    UnpackedTarball/pdfium/fpdfsdk/fpdftext \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfview \
-    UnpackedTarball/pdfium/fpdfsdk/fsdk_actionhandler \
-    UnpackedTarball/pdfium/fpdfsdk/fsdk_pauseadapter \
-    UnpackedTarball/pdfium/fpdfsdk/pdfsdk_fieldaction \
-    UnpackedTarball/pdfium/fpdfsdk/fsdk_filewriteadapter \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfannot \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfattachment \
-    UnpackedTarball/pdfium/fpdfsdk/fpdfcatalog \
+    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_actionhandler \
+    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_annotiterator \
+    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_customaccess \
+    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_fieldaction \
+    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_filewriteadapter \
+    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_helpers \
+    UnpackedTarball/pdfium/fpdfsdk/cpdfsdk_memoryaccess \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_annot \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_attachment \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_catalog \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_doc \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_editimg \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_editpage \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_editpath \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_edittext \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_formfill \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_save \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_text \
+    UnpackedTarball/pdfium/fpdfsdk/fpdf_view \
+    UnpackedTarball/pdfium/fpdfsdk/ipdfsdk_pauseadapter \
+    UnpackedTarball/pdfium/fpdfsdk/cpdf_annotcontext \
 ))
 
 # fdrm
@@ -356,7 +360,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
 
 # fxcrt
 $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
-    UnpackedTarball/pdfium/core/fxcrt/cfx_blockbuffer \
     UnpackedTarball/pdfium/core/fxcrt/cfx_memorystream \
     UnpackedTarball/pdfium/core/fxcrt/cfx_seekablestreamproxy \
     UnpackedTarball/pdfium/core/fxcrt/fx_bidi \
@@ -367,13 +370,13 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fxcrt/fx_system \
     UnpackedTarball/pdfium/core/fxcrt/fx_ucddata \
     UnpackedTarball/pdfium/core/fxcrt/fx_unicode \
-    UnpackedTarball/pdfium/core/fxcrt/xml/cxml_attritem \
-    UnpackedTarball/pdfium/core/fxcrt/xml/cxml_databufacc \
-    UnpackedTarball/pdfium/core/fxcrt/xml/cxml_element \
-    UnpackedTarball/pdfium/core/fxcrt/xml/cxml_parser \
-    UnpackedTarball/pdfium/core/fxcrt/xml/cxml_content \
-    UnpackedTarball/pdfium/core/fxcrt/xml/cxml_object \
-    UnpackedTarball/pdfium/core/fxcrt/xml/cfx_saxcontext \
+    UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmldocument \
+    UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlelement \
+    UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlparser \
+    UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlnode \
+    UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlinstruction \
+    UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmltext \
+    UnpackedTarball/pdfium/core/fxcrt/xml/cfx_xmlchardata \
     UnpackedTarball/pdfium/core/fxcrt/css/cfx_csscolorvalue \
     UnpackedTarball/pdfium/core/fxcrt/css/cfx_csscomputedstyle \
     UnpackedTarball/pdfium/core/fxcrt/css/cfx_csscustomproperty \
@@ -406,6 +409,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fxcrt/widestring \
     UnpackedTarball/pdfium/core/fxcrt/cfx_seekablemultistream \
     UnpackedTarball/pdfium/core/fxcrt/css/cfx_cssdata \
+    UnpackedTarball/pdfium/core/fxcrt/fx_codepage \
 ))
 
 # fxge
@@ -439,7 +443,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fxge/fontdata/chromefontdata/FoxitSerifMM \
     UnpackedTarball/pdfium/core/fxge/fontdata/chromefontdata/FoxitSymbol \
     UnpackedTarball/pdfium/core/fxge/freetype/fx_freetype \
-    UnpackedTarball/pdfium/core/fxge/ifx_renderdevicedriver \
+    UnpackedTarball/pdfium/core/fxge/renderdevicedriver_iface \
     UnpackedTarball/pdfium/core/fxge/agg/fx_agg_driver \
     UnpackedTarball/pdfium/core/fxge/cfx_cliprgn \
     UnpackedTarball/pdfium/core/fxge/cfx_color \
@@ -466,6 +470,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
 $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/fxjs/cjs_event_context_stub \
     UnpackedTarball/pdfium/fxjs/cjs_runtimestub \
+    UnpackedTarball/pdfium/fxjs/ijs_runtime \
 ))
 
 # pwl
@@ -546,6 +551,8 @@ $(eval $(call gb_Library_use_externals,pdfium,\
     jpeg \
     lcms2 \
     zlib \
+    icu_headers \
+    icuuc \
 ))
 
 ifeq ($(OS),LINUX)
@@ -579,10 +586,8 @@ $(eval $(call gb_Library_add_generated_cobjects,pdfium,\
     UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftbitmap \
     UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftglyph \
     UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftinit \
-    UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftlcdfil \
     UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftmm \
     UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftsystem \
-    UnpackedTarball/pdfium/third_party/freetype/src/src/base/ftfntfmt \
     UnpackedTarball/pdfium/third_party/freetype/src/src/cff/cff \
     UnpackedTarball/pdfium/third_party/freetype/src/src/cid/type1cid \
     UnpackedTarball/pdfium/third_party/freetype/src/src/psaux/psaux \
@@ -603,7 +608,6 @@ $(eval $(call gb_Library_add_generated_exception_objects,pdfium,\
     UnpackedTarball/pdfium/core/fxge/win32/cpsoutput \
     UnpackedTarball/pdfium/core/fxge/win32/fx_win32_device \
     UnpackedTarball/pdfium/core/fxge/win32/fx_win32_dib \
-    UnpackedTarball/pdfium/core/fxge/win32/fx_win32_dwrite \
     UnpackedTarball/pdfium/core/fxge/win32/fx_win32_gdipext \
     UnpackedTarball/pdfium/core/fxge/win32/fx_win32_print \
 ))
diff --git a/external/pdfium/UnpackedTarball_pdfium.mk b/external/pdfium/UnpackedTarball_pdfium.mk
index c917d63a4cdd..6a20b8f7d590 100644
--- a/external/pdfium/UnpackedTarball_pdfium.mk
+++ b/external/pdfium/UnpackedTarball_pdfium.mk
@@ -10,7 +10,7 @@
 pdfium_patches :=
 pdfium_patches += visibility.patch.1
 pdfium_patches += ubsan.patch
-pdfium_patches += freetype.patch.1
+pdfium_patches += icu.patch.1
 # Fixes build on our baseline.
 pdfium_patches += build.patch.1
 # Adds missing editing API
diff --git a/external/pdfium/build.patch.1 b/external/pdfium/build.patch.1
index b852383ff84b..89d8e5e7d8d0 100644
--- a/external/pdfium/build.patch.1
+++ b/external/pdfium/build.patch.1
@@ -19,3 +19,106 @@ index 8e01127b0..f4ce4d915 100644
    if (m_Storer.GetBitmap()->IsAlphaMask()) {
      CalcAlpha(cdata);
    } else {
+diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
+index 05694cf24..101253814 100644
+--- a/core/fxcrt/string_view_template.h
++++ b/core/fxcrt/string_view_template.h
+@@ -231,9 +231,6 @@ inline bool operator<(const T* lhs, const StringViewTemplate<T>& rhs) {
+   return rhs > lhs;
+ }
+ 
+-extern template class StringViewTemplate<char>;
+-extern template class StringViewTemplate<wchar_t>;
+-
+ using ByteStringView = StringViewTemplate<char>;
+ using WideStringView = StringViewTemplate<wchar_t>;
+ 
+diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
+index 323de4ffc..f11a0b0ad 100644
+--- a/core/fpdfdoc/cpdf_metadata.cpp
++++ b/core/fpdfdoc/cpdf_metadata.cpp
+@@ -74,7 +74,7 @@ std::vector<UnsupportedFeature> CPDF_Metadata::CheckForSharedForm() const {
+   CFX_XMLParser parser(stream);
+   std::unique_ptr<CFX_XMLDocument> doc = parser.Parse();
+   if (!doc)
+-    return {};
++    return std::vector<UnsupportedFeature>();
+ 
+   std::vector<UnsupportedFeature> unsupported;
+   CheckForSharedFormInternal(doc->GetRoot(), &unsupported);
+diff --git a/fpdfsdk/cpdf_annotcontext.cpp b/fpdfsdk/cpdf_annotcontext.cpp
+index 20c5fc343..a40cd1eae 100644
+--- a/fpdfsdk/cpdf_annotcontext.cpp
++++ b/fpdfsdk/cpdf_annotcontext.cpp
+@@ -16,12 +16,12 @@ CPDF_AnnotContext::CPDF_AnnotContext(CPDF_Dictionary* pAnnotDict,
+                                      CPDF_Page* pPage,
+                                      CPDF_Stream* pStream)
+     : m_pAnnotDict(pAnnotDict), m_pPage(pPage) {
+-  SetForm(pStream);
++  SetForm_(pStream);
+ }
+ 
+ CPDF_AnnotContext::~CPDF_AnnotContext() = default;
+ 
+-void CPDF_AnnotContext::SetForm(CPDF_Stream* pStream) {
++void CPDF_AnnotContext::SetForm_(CPDF_Stream* pStream) {
+   if (!pStream)
+     return;
+ 
+diff --git a/fpdfsdk/cpdf_annotcontext.h b/fpdfsdk/cpdf_annotcontext.h
+index 38cc91e03..7904ae044 100644
+--- a/fpdfsdk/cpdf_annotcontext.h
++++ b/fpdfsdk/cpdf_annotcontext.h
+@@ -23,7 +23,7 @@ class CPDF_AnnotContext {
+                     CPDF_Stream* pStream);
+   ~CPDF_AnnotContext();
+ 
+-  void SetForm(CPDF_Stream* pStream);
++  void SetForm_(CPDF_Stream* pStream);
+   bool HasForm() const { return !!m_pAnnotForm; }
+   CPDF_Form* GetForm() const { return m_pAnnotForm.get(); }
+   CPDF_Dictionary* GetAnnotDict() const { return m_pAnnotDict.Get(); }
+diff --git a/third_party/base/span.h b/third_party/base/span.h
+index 0fb627ba8..f71c362e2 100644
+--- a/third_party/base/span.h
++++ b/third_party/base/span.h
+@@ -214,7 +214,7 @@ class span {
+   // Conversions from spans of compatible types: this allows a span<T> to be
+   // seamlessly used as a span<const T>, but not the other way around.
+   template <typename U, typename = internal::EnableIfLegalSpanConversion<U, T>>
+-  constexpr span(const span<U>& other) : span(other.data(), other.size()) {}
++  span(const span<U>& other) : span(other.data(), other.size()) {}
+   span& operator=(const span& other) noexcept = default;
+   ~span() noexcept {
+     if (!size_) {
+diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp
+index d3bf38d31..e8aea9707 100644
+--- a/fpdfsdk/fpdf_annot.cpp
++++ b/fpdfsdk/fpdf_annot.cpp
+@@ -389,7 +389,7 @@ FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj) {
+ 
+   // Get the annotation's corresponding form object for parsing its AP stream.
+   if (!pAnnot->HasForm())
+-    pAnnot->SetForm(pStream);
++    pAnnot->SetForm_(pStream);
+ 
+   // Check that the object did not come from the same annotation. If this check
+   // succeeds, then it is assumed that the object came from
+@@ -425,7 +425,7 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot) {
+     if (!pStream)
+       return 0;
+ 
+-    pAnnot->SetForm(pStream);
++    pAnnot->SetForm_(pStream);
+   }
+   return pdfium::CollectionSize<int>(*pAnnot->GetForm()->GetPageObjectList());
+ }
+@@ -442,7 +442,7 @@ FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index) {
+     if (!pStream)
+       return nullptr;
+ 
+-    pAnnot->SetForm(pStream);
++    pAnnot->SetForm_(pStream);
+   }
+ 
+   return FPDFPageObjectFromCPDFPageObject(
diff --git a/external/pdfium/freetype.patch.1 b/external/pdfium/freetype.patch.1
deleted file mode 100644
index 90f230c54e69..000000000000
--- a/external/pdfium/freetype.patch.1
+++ /dev/null
@@ -1,18 +0,0 @@
-Upstream provides this define from the commandline, but while this define is
-needed for fxge, it breaks the build for the bundled freetype. gbuild doesn't
-support having different defines within the same Library, so just patch the
-single translation unit that actually needs the define.
-
-Long-term perhaps the solution is to enable freetype on all platforms inside
-LO, then we don't have to build freetype as part of pdfium, so we can let
-gbuild define this from the commandline.
-
-diff --git a/core/fxge/freetype/fx_freetype.cpp b/core/fxge/freetype/fx_freetype.cpp
-index 0ae207b02..879bf5ab9 100644
---- a/core/fxge/freetype/fx_freetype.cpp
-+++ b/core/fxge/freetype/fx_freetype.cpp
-@@ -1,3 +1,4 @@
-+#define DEFINE_PS_TABLES
- // Copyright 2014 PDFium Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
diff --git a/external/pdfium/icu.patch.1 b/external/pdfium/icu.patch.1
new file mode 100644
index 000000000000..85e837d9b99f
--- /dev/null
+++ b/external/pdfium/icu.patch.1
@@ -0,0 +1,13 @@
+diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h
+index ff96de0f7..0195bd06f 100644
+--- a/core/fxcrt/fx_extension.h
++++ b/core/fxcrt/fx_extension.h
+@@ -13,7 +13,7 @@
+ 
+ #include "core/fxcrt/fx_string.h"
+ #include "third_party/base/span.h"
+-#include "third_party/icu/source/common/unicode/uchar.h"
++#include <unicode/uchar.h>
+ 
+ #define FX_INVALID_OFFSET static_cast<uint32_t>(-1)
+ 
diff --git a/external/pdfium/ubsan.patch b/external/pdfium/ubsan.patch
index af39e3d95db3..91428326fc5d 100644
--- a/external/pdfium/ubsan.patch
+++ b/external/pdfium/ubsan.patch
@@ -22,22 +22,3 @@
      int rowbytes = std::min(abs(src_pitch), dest_pitch);
      for (int row = 0; row < bmheight; row++)
        memcpy(pDestBuf + row * dest_pitch, pSrcBuf + row * src_pitch, rowbytes);
---- third_party/agg23/agg_rasterizer_scanline_aa.h
-+++ third_party/agg23/agg_rasterizer_scanline_aa.h
-@@ -349,14 +349,14 @@ public:
-                     cover += cur_cell->cover;
-                 }
-                 if(area) {
--                    alpha = calculate_alpha((cover << (poly_base_shift + 1)) - area, no_smooth);
-+                    alpha = calculate_alpha(int(unsigned(cover) << (poly_base_shift + 1)) - area, no_smooth);
-                     if(alpha) {
-                         sl.add_cell(x, alpha);
-                     }
-                     x++;
-                 }
-                 if(num_cells && cur_cell->x > x) {
--                    alpha = calculate_alpha(cover << (poly_base_shift + 1), no_smooth);
-+                    alpha = calculate_alpha(unsigned(cover) << (poly_base_shift + 1), no_smooth);
-                     if(alpha) {
-                         sl.add_span(x, cur_cell->x - x, alpha);
-                     }
commit 33f4c8aaef518433e9c4b5a98dee180d7d5791a4
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Fri May 18 09:15:36 2018 -0400

    svx: cleanup pdfium importer
    
    Change-Id: Id925ba7734a2c73270e40f19d3fc50552441c34e

diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1
index a110313017da..5b23140c2069 100644
--- a/external/pdfium/edit.patch.1
+++ b/external/pdfium/edit.patch.1
@@ -1,43 +1,8 @@
 diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp
-index 693fcf1..d3e1202 100644
+index 693fcf1..14e883f 100644
 --- a/core/fpdfapi/page/cpdf_colorstate.cpp
 +++ b/core/fpdfapi/page/cpdf_colorstate.cpp
-@@ -74,6 +74,8 @@ void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
-                                    uint32_t nValues) {
-   ColorData* pData = m_Ref.GetPrivateCopy();
-   SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
-+  if (pData->m_FillRGB != 0 && pData->m_FillRGB != 0xFFFFFFFF)
-+    fprintf(stderr, "COLOR FILL!!!!> %x\n", pData->m_FillRGB);
- }
- 
- void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
-@@ -81,6 +83,8 @@ void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
-                                      uint32_t nValues) {
-   ColorData* pData = m_Ref.GetPrivateCopy();
-   SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
-+  if (pData->m_StrokeRGB != 0 && pData->m_StrokeRGB != 0xFFFFFFFF)
-+    fprintf(stderr, "COLOR STROkE!!!!> %x\n", pData->m_StrokeRGB);
- }
- 
- void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
-@@ -99,6 +103,8 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
-     }
-   }
-   pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
-+  if (pData->m_FillRGB != 0 && pData->m_FillRGB != 0xFFFFFFFF)
-+    fprintf(stderr, "COLOR FILL!!!!> %x\n", pData->m_FillRGB);
- }
- 
- void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
-@@ -118,13 +124,15 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
-   }
-   pData->m_StrokeRGB =
-       pData->m_StrokeColor.GetRGB(&R, &G, &B) ? FXSYS_RGB(R, G, B) : 0xFFFFFFFF;
-+  if (pData->m_StrokeRGB != 0 && pData->m_StrokeRGB != 0xFFFFFFFF)
-+    fprintf(stderr, "COLOR STROkE!!!!> %x\n", pData->m_StrokeRGB);
- }
- 
- void CPDF_ColorState::SetColor(CPDF_Color& color,
+@@ -124,7 +124,7 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
                                 uint32_t& rgb,
                                 CPDF_ColorSpace* pCS,
                                 float* pValue,
@@ -59,57 +24,6 @@ index 9619051..dbe9c47 100644
  
    SharedCopyOnWrite<ColorData> m_Ref;
  };
-diff --git a/core/fpdfapi/page/cpdf_imageobject.cpp b/core/fpdfapi/page/cpdf_imageobject.cpp
-index 3b5a740..416d82d 100644
---- a/core/fpdfapi/page/cpdf_imageobject.cpp
-+++ b/core/fpdfapi/page/cpdf_imageobject.cpp
-@@ -43,6 +43,7 @@ const CPDF_ImageObject* CPDF_ImageObject::AsImage() const {
- void CPDF_ImageObject::CalcBoundingBox() {
-   std::tie(m_Left, m_Right, m_Top, m_Bottom) =
-       m_Matrix.TransformRect(0.f, 1.f, 1.f, 0.f);
-+    // fprintf(stderr, "Image BB: %f, %f, %f, %f\n", m_Left, m_Right, m_Top, m_Bottom);
- }
- 
- void CPDF_ImageObject::SetImage(const RetainPtr<CPDF_Image>& pImage) {
-diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
-index ba93f4a..70d398b 100644
---- a/core/fpdfapi/page/cpdf_page.cpp
-+++ b/core/fpdfapi/page/cpdf_page.cpp
-@@ -35,12 +35,14 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
-   CFX_FloatRect mediabox = GetBox("MediaBox");
-   if (mediabox.IsEmpty())
-     mediabox = CFX_FloatRect(0, 0, 612, 792);
-+  fprintf(stderr, "Page mediabox: %f, %f, %f, %f\n", mediabox.left, mediabox.right, mediabox.top, mediabox.bottom);
- 
-   m_BBox = GetBox("CropBox");
-   if (m_BBox.IsEmpty())
-     m_BBox = mediabox;
-   else
-     m_BBox.Intersect(mediabox);
-+  fprintf(stderr, "Page cropbox: %f, %f, %f, %f\n", m_BBox.left, m_BBox.right, m_BBox.top, m_BBox.bottom);
- 
-   m_PageSize.width = m_BBox.Width();
-   m_PageSize.height = m_BBox.Height();
-@@ -48,6 +50,7 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
-   int rotate = GetPageRotation();
-   if (rotate % 2)
-     std::swap(m_PageSize.width, m_PageSize.height);
-+  fprintf(stderr, "Page rotate: %d, Page Width: %f, Page Height: %f\n", rotate, m_PageSize.width, m_PageSize.height);
- 
-   switch (rotate) {
-     case 0:
-diff --git a/core/fpdfapi/page/cpdf_pageobject.cpp b/core/fpdfapi/page/cpdf_pageobject.cpp
-index 8bb5bf5..9b5e2ce 100644
---- a/core/fpdfapi/page/cpdf_pageobject.cpp
-+++ b/core/fpdfapi/page/cpdf_pageobject.cpp
-@@ -98,5 +98,7 @@ FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const {
-   if (pMatrix)
-     rect = pMatrix->TransformRect(rect);
- 
-+  FX_RECT rc = rect.GetOuterRect();
-+  fprintf(stderr, "PageObject BB: %f, %f, %f, %f\n", rc.left, rc.right, rc.top, rc.bottom);
-   return rect.GetOuterRect();
- }
 diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.cpp b/core/fpdfapi/page/cpdf_pageobjectlist.cpp
 index afd2c98..2c8e061 100644
 --- a/core/fpdfapi/page/cpdf_pageobjectlist.cpp
@@ -135,18 +49,6 @@ index b450537..77c7d81 100644
  };
  
  #endif  // CORE_FPDFAPI_PAGE_CPDF_PAGEOBJECTLIST_H_
-diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
-index 0a01ae0..6947e3a 100644
---- a/core/fpdfapi/render/cpdf_renderstatus.cpp
-+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
-@@ -1793,6 +1793,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
-     return true;
- 
-   float font_size = textobj->m_TextState.GetFontSize();
-+//   fprintf(stderr, "Font size: %f, matrix a: %f, b: %f, c: %f, d: %f, e: %f, f: %f\n", font_size, text_matrix.a, text_matrix.b, text_matrix.c, text_matrix.d, text_matrix.e, text_matrix.f);
-   if (bPattern) {
-     DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size,
-                             &text_matrix, bFill, bStroke);
 diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
 index e712549..a7973f7 100644
 --- a/core/fpdftext/cpdf_textpage.cpp
@@ -197,26 +99,6 @@ index c87ab00..e5a1ba8 100644
    int CountRects(int start, int nCount);
    bool GetRect(int rectIndex, CFX_FloatRect* pRect) const;
  
-diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp
-index 4ac5cf6..4286de4 100644
---- a/core/fxge/cfx_pathdata.cpp
-+++ b/core/fxge/cfx_pathdata.cpp
-@@ -199,6 +199,7 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
- void CFX_PathData::AppendPoint(const CFX_PointF& point,
-                                FXPT_TYPE type,
-                                bool closeFigure) {
-+//   fprintf(stderr, "Append: %f, %f (%s)\n", point.x, point.y, closeFigure ? "CLOSE" : "OPEN");
-   m_Points.push_back(FX_PATHPOINT(point, type, closeFigure));
- }
- 
-@@ -290,6 +291,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(float line_width,
- void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
-   if (!pMatrix)
-     return;
-+//   fprintf(stderr, "XForm: %f, %f %f, %f, %f, %f\n", pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, pMatrix->e, pMatrix->f);
-   for (auto& point : m_Points)
-     point.m_Point = pMatrix->Transform(point.m_Point);
- }
 diff --git a/fpdfsdk/fpdfeditimg.cpp b/fpdfsdk/fpdfeditimg.cpp
 index 0d7ba56..37bdf99 100644
 --- a/fpdfsdk/fpdfeditimg.cpp
@@ -249,7 +131,7 @@ index 0d7ba56..37bdf99 100644
  FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
                                   void* buffer,
 diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
-index ca2cf3f..2162625 100644
+index ca2cf3f..1eaa232 100644
 --- a/fpdfsdk/fpdfeditpage.cpp
 +++ b/fpdfsdk/fpdfeditpage.cpp
 @@ -11,12 +11,14 @@
@@ -275,7 +157,7 @@ index ca2cf3f..2162625 100644
  #include "fpdfsdk/fsdk_define.h"
  #include "public/fpdf_formfill.h"
  #include "third_party/base/logging.h"
-@@ -363,3 +366,252 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
+@@ -363,3 +366,240 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
    *top = bbox.top;
    return true;
  }
@@ -363,17 +245,6 @@ index ca2cf3f..2162625 100644
 +      str += pFont->UnicodeFromCharCode(charcode);
 +  }
 +
-+//   CFX_WideTextBuf m_TextBuf;
-+//   WideString str = textpage->GetPageText(char_start, char_count);
-+//   return WideString(m_TextBuf.AsStringView().Mid(
-+//       static_cast<size_t>(text_start), static_cast<size_t>(text_count)));
-+
-+//   if (str.GetLength() > static_cast<size_t>(char_count))
-+//     str = str.Left(static_cast<size_t>(char_count));
-+
-+  // Reincode in UTF-16.
-+//   WideString str = text.UTF8Decode();
-+
 +  // UFT16LE_Encode doesn't handle surrogate pairs properly, so it is expected
 +  // the number of items to stay the same.
 +  ByteString byte_str = str.UTF16LE_Encode();
@@ -495,7 +366,6 @@ index ca2cf3f..2162625 100644
 +  if (pFrmObj)
 +  {
 +    const CFX_Matrix& matrix = pFrmObj->form_matrix();
-+    fprintf(stderr, "Form matrix a: %f, b: %f, c: %f, d: %f, e: %f, f: %f\n", matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
 +    const CPDF_PageObjectList* pObjectList = pFrmObj->form()->GetPageObjectList();
 +    if (pObjectList)
 +        return pObjectList->GetPageObjectByIndex(index);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 4059a8d8a83d..b0a06abda9e2 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -195,7 +195,6 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const Rectan
     }
 
     mnPageCount = FPDF_GetPageCount(mpPdfDocument);
-    SAL_WARN("sd.filter", "Scale Rect: " << maScaleRect);
 }
 
 ImpSdrPdfImport::~ImpSdrPdfImport()
@@ -204,11 +203,10 @@ ImpSdrPdfImport::~ImpSdrPdfImport()
     FPDF_DestroyLibrary();
 }
 
-void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport,
+void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport,
                                     int nPageIndex)
 {
     const int nPageCount = FPDF_GetPageCount(mpPdfDocument);
-    SAL_WARN("sd.filter", "Importing page " << nPageIndex << " of " << nPageCount);
     if (nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount)
     {
         // Render next page.
@@ -218,187 +216,24 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc
 
         const double dPageWidth = FPDF_GetPageWidth(pPdfPage);
         const double dPageHeight = FPDF_GetPageHeight(pPdfPage);
-        SAL_WARN("sd.filter", "Loaded page: " << nPageIndex << ", width: " << dPageWidth
-                                              << ", height: " << dPageHeight);
         SetupPageScale(dPageWidth, dPageHeight);
 
         // Load the page text to extract it when we get text elements.
         FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage);
 
         const int nPageObjectCount = FPDFPage_CountObject(pPdfPage);
+        if (pProgrInfo)
+            pProgrInfo->SetActionCount(nPageObjectCount);
+
         for (int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; ++nPageObjectIndex)
         {
             FPDF_PAGEOBJECT pPageObject = FPDFPage_GetObject(pPdfPage, nPageObjectIndex);
             ImportPdfObject(pPageObject, pTextPage, nPageObjectIndex);
-        }
-
-        FPDFText_ClosePage(pTextPage);
-
-#if 0
-        // Now do the text.
-        FPDF_TEXTPAGE pTextPage = FPDFText_LoadPage(pPdfPage);
-        if (pTextPage != nullptr)
-        {
-            SAL_WARN("sd.filter", "TEXT TEXT TEXT");
-
-            const int nChars = FPDFText_CountChars(pTextPage);
-            SAL_WARN("sd.filter", "Got page chars: " << nChars);
-
-            const int nRects = FPDFText_CountRects(pTextPage, 0, nChars);
-            SAL_WARN("sd.filter", "Got Rects: " << nRects);
-
-            std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
-            for (int nRectIndex = 0; nRectIndex < nRects; ++nRectIndex)
-            {
-                SAL_WARN("sd.filter",
-                         "Processing Text Rect #" << nRectIndex + 1 << " of " << nRects);
-
-                double left = 0;
-                double top = 0;
-                double right = 0;
-                double bottom = 0;
-                FPDFText_GetRect(pTextPage, nRectIndex, &left, &top, &right, &bottom);
-                SAL_WARN("sd.filter", "Got Text Rect: " << left << ", " << right << ", " << top
-                                                        << ", " << bottom);
-                Rectangle aRect = PointsToLogic(left, right, top, bottom);
-
-                if (right < left)
-                    std::swap(right, left);
-                if (bottom < top)
-                    std::swap(bottom, top);
-
-                SAL_WARN("sd.filter", "Got Text Rect: " << left << ", " << right << ", " << top
-                                                        << ", " << bottom);
-                SAL_WARN("sd.filter", "Logic Text Rect: " << aRect);
-
-                unsigned short* pShortText = reinterpret_cast<unsigned short*>(pText.get());
-                const int nBoundedChars = FPDFText_GetBoundedText(pTextPage, left, top, right,
-                                                                  bottom, pShortText, nChars);
-                OUString sText(pText.get(), nBoundedChars);
-                SAL_WARN("sd.filter", "Got Text #" << nRectIndex + 1 << " (" << nBoundedChars
-                                                   << "): [" << sText << "].");
-
-                const double dHalfCharWidth = (right - left) / nBoundedChars / 2.0;
-                SAL_WARN("sd.filter", "Half Char Width: " << dHalfCharWidth);
-                const int nCharIndex = FPDFText_GetCharIndexAtPos(pTextPage, left + dHalfCharWidth,
-                                                                  top + dHalfCharWidth,
-                                                                  dHalfCharWidth, dHalfCharWidth);
-                SAL_WARN("sd.filter", "Got Char Index: " << nCharIndex);
-
-                // FPDF_FONT pFont = FPDFText_GetFont(pTextPage, nCharIndex);
-                // const int nFontAscent = FPDFFont_GetAscent(pFont);
-                // const int nFontDescent = FPDFFont_GetDescent(pFont);
-                // FPDF_BYTESTRING sFontName = FPDFFont_GetName(pFont);
-                // SAL_WARN("sd.filter", "Char #" << nCharIndex << ", Got Font [" << sFontName <<
-                //                       "], Ascent: "<< nFontAscent << ", Descent: " << nFontDescent);
-
-                // FontMetric aFontMetric = mpVD->GetFontMetric();
-                // aFontMetric.SetAscent(nFontAscent);
-                // aFontMetric.SetDescent(nFontDescent);
-
-                double dFontScale = 1.0;
-                geometry::Matrix2D aMatrix;
-                if (!FPDFText_GetMatrix(pTextPage, nCharIndex, &aMatrix.m00, &aMatrix.m01,
-                                        &aMatrix.m10, &aMatrix.m11))
-                {
-                    SAL_WARN("sd.filter", "No font scale matrix, will use heuristic height of "
-                                              << aRect.GetHeight() << ".");
-                    dFontScale = aRect.GetHeight();
-                }
-                else if (aMatrix.m00 != aMatrix.m11 || aMatrix.m00 <= 0)
-                {
-                    SAL_WARN("sd.filter", "Bogus font scale matrix ("
-                                              << aMatrix.m00 << ',' << aMatrix.m11
-                                              << "), will use heuristic height of "
-                                              << aRect.GetHeight() << ".");
-                    dFontScale = aRect.GetHeight();
-                }
-                else
-                    dFontScale = aMatrix.m00;
-
-                double dFontSize = FPDFText_GetFontSize(pTextPage, nCharIndex);
-                SAL_WARN("sd.filter", "Got Font Size: " << dFontSize);
-                dFontSize *= dFontScale;
-                SAL_WARN("sd.filter", "Got Font Size Scaled: " << dFontSize);
-                dFontSize = lcl_PointToPixel(dFontSize);
-                SAL_WARN("sd.filter", "Got Font Pixel Size: " << dFontSize);
-                dFontSize = lcl_ToLogic(dFontSize);
-                SAL_WARN("sd.filter", "Got Font Logic Size: " << dFontSize);
-                vcl::Font aFnt = mpVD->GetFont();
-                aFnt.SetFontSize(Size(dFontSize, dFontSize));
-                mpVD->SetFont(aFnt);
-
-                double x = 0;
-                double y = 0;
-                FPDFText_GetCharOrigin(pTextPage, nCharIndex, &x, &y);
-                SAL_WARN("sd.filter", "Got Char Origin: " << x << ", " << y);
-                Point aPos = PointsToLogic(x, y);
-                SAL_WARN("sd.filter", "Got Char Origin Logic: " << aPos);
-                // aRect.Move(aPos.X(), aPos.Y());
-
-                // geometry::RealRectangle2D aRect;
-                // aRect.X1 = left;
-                // aRect.Y1 = top;
-                // aRect.X2 = right;
-                // aRect.Y2 = bottom;
-
-                // geometry::Matrix2D aMatrix;
-                // FPDFText_GetMatrix(pTextPage, nCharIndex, &aMatrix.m00, &aMatrix.m01, &aMatrix.m10, &aMatrix.m11);
-
-                // basegfx::B2DHomMatrix fontMatrix(
-                //     aMatrix.m00, aMatrix.m01, 0.0,
-                //     aMatrix.m10, aMatrix.m11, 0.0);
-                // fontMatrix.scale(dFontSize, dFontSize);
-
-                // x = fontMatrix.get(0, 0) * x + fontMatrix.get(1, 0) * y + x;
-                // y = fontMatrix.get(0, 1) * x + fontMatrix.get(1, 1) * y + y;
-                // SAL_WARN("sd.filter", "Char Origin after xform: " << x << ", " << y);
-
-                // basegfx::B2DHomMatrix totalTextMatrix1(fontMatrix);
-                // basegfx::B2DHomMatrix totalTextMatrix2(fontMatrix);
-                // totalTextMatrix1.translate(rRect.X1, rRect.Y1);
-                // totalTextMatrix2.translate(rRect.X2, rRect.Y2);
-
-                // basegfx::B2DHomMatrix corrMatrix;
-                // corrMatrix.scale(1.0, -1.0);
-                // // corrMatrix.translate(0.0, ascent);
-                // totalTextMatrix1 = totalTextMatrix1 * corrMatrix;
-                // totalTextMatrix2 = totalTextMatrix2 * corrMatrix;
-
-                // totalTextMatrix1 *= getCurrentContext().Transformation;
-                // totalTextMatrix2 *= getCurrentContext().Transformation;
-
-                // basegfx::B2DHomMatrix invMatrix(totalTextMatrix1);
-                // basegfx::B2DHomMatrix invPrevMatrix(prevTextMatrix);
-                // invMatrix.invert();
-                // invPrevMatrix.invert();
-                // basegfx::B2DHomMatrix offsetMatrix1(totalTextMatrix1);
-                // basegfx::B2DHomMatrix offsetMatrix2(totalTextMatrix2);
-                // offsetMatrix1 *= invPrevMatrix;
-                // offsetMatrix2 *= invMatrix;
-
-                // double charWidth = offsetMatrix2.get(0, 2);
-                // double prevSpaceWidth = offsetMatrix1.get(0, 2) - prevCharWidth;
-
-                ImportText(aRect.TopLeft(), sText);
-            }
-
-            FPDFText_ClosePage(pTextPage);
-        }
-#endif
-
-        FPDF_ClosePage(pPdfPage);
-    }
-
-    // const sal_uLong nCount(rMtf.GetActionSize());
-
-    for (sal_uLong a(0); a < 0UL; a++)
-    {
         if (pProgrInfo && pActionsToReport)
         {
             (*pActionsToReport)++;
 
-            if (*pActionsToReport >= 16) // update all 16 actions
+                if (*pActionsToReport >= 16)
             {
                 if (!pProgrInfo->ReportActions(*pActionsToReport))
                     break;
@@ -407,6 +242,10 @@ void ImpSdrPdfImport::DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pAc
             }
         }
     }
+
+        FPDFText_ClosePage(pTextPage);
+        FPDF_ClosePage(pPdfPage);
+    }
 }
 
 void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPageHeight)
@@ -419,8 +258,6 @@ void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPage
 
     Size aPageSize(lcl_ToLogic(lcl_PointToPixel(dPageWidth)),
                    lcl_ToLogic(lcl_PointToPixel(dPageHeight)));
-    SAL_WARN("sd.filter", "Logical Page Size: " << aPageSize);
-    SAL_WARN("sd.filter", "Scale Rect: " << maScaleRect);
 
     if (aPageSize.Width() && aPageSize.Height() && (!maScaleRect.IsEmpty()))
     {
@@ -455,23 +292,15 @@ void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPage
         maScaleY = Fraction(maScaleRect.GetHeight() - 1, aPageSize.Height());
         mbSize = true;
     }
-
-    //SAL_WARN("sd.filter", "ScaleX: " << maScaleX << "(" << mfScaleX << "), ScaleY: " << maScaleY
-    //                                 << "(" << mfScaleY << ")");
 }
 
 size_t ImpSdrPdfImport::DoImport(SdrObjList& rOL, size_t nInsPos, int nPageNumber,
                                  SvdProgressInfo* pProgrInfo)
 {
-    if (pProgrInfo)
-    {
-        // pProgrInfo->SetActionCount(rMtf.GetActionSize());
-    }
-
     sal_uInt32 nActionsToReport(0);
 
     // execute
-    DoLoopActions(pProgrInfo, &nActionsToReport, nPageNumber);
+    DoObjects(pProgrInfo, &nActionsToReport, nPageNumber);
 
     if (pProgrInfo)
     {
@@ -612,7 +441,6 @@ void ImpSdrPdfImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
     {
         vcl::Font aFnt(mpVD->GetFont());
         const sal_uInt32 nHeight(FRound(aFnt.GetFontSize().Height() * mfScaleY));
-        SAL_WARN("sd.filter", "Font Height: " << nHeight);
 
         mpTextAttr->Put(SvxFontItem(aFnt.GetFamilyType(), aFnt.GetFamilyName(), aFnt.GetStyleName(),
                                     aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO));
@@ -1024,10 +852,8 @@ void ImpSdrPdfImport::ImportPdfObject(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE
 }
 
 void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
-                                 int nPageObjectIndex)
+                                 int /*nPageObjectIndex*/)
 {
-    SAL_WARN("sd.filter", "Got page object FORM: " << nPageObjectIndex);
-
     // Get the form matrix to perform correct translation/scaling of the form sub-objects.
     const Matrix aOldMatrix = mCurMatrix;
 
@@ -1047,9 +873,8 @@ void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
 }
 
 void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage,
-                                 int nPageObjectIndex)
+                                 int /*nPageObjectIndex*/)
 {
-    SAL_WARN("sd.filter", "Got page object TEXT: " << nPageObjectIndex);
     float left;
     float bottom;
     float right;
@@ -1060,30 +885,14 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
     }
 
     if (left == right || top == bottom)
-    {
-        SAL_WARN("sd.filter", "Skipping empty TEXT #" << nPageObjectIndex << " left: " << left
-                                                      << ", right: " << right << ", top: " << top
-                                                      << ", bottom: " << bottom);
         return;
-    }
 
     double a, b, c, d, e, f;
     FPDFTextObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
-    // Matrix aTextMatrix(a, b, c, d, e, f);
     Matrix aTextMatrix(mCurMatrix);
-    SAL_WARN("sd.filter", "Got text matrix " << aTextMatrix.toString());
-    SAL_WARN("sd.filter", "Context matrix " << mCurMatrix.toString());
-    // aTextMatrix.Concatinate(mCurMatrix);
-    // SAL_WARN("sd.filter", "Got text matrix concat " << aTextMatrix.toString());
 
-    Point aPos = PointsToLogic(aTextMatrix.e(), aTextMatrix.f());
-    SAL_WARN("sd.filter", "Got TEXT origin: " << aPos);
-
-    const Rectangle aRect2 = PointsToLogic(left, right, top, bottom);
-    SAL_WARN("sd.filter", "Untransformed TEXT Bounds: " << aRect2);
     aTextMatrix.Transform(left, right, top, bottom);
     const Rectangle aRect = PointsToLogic(left, right, top, bottom);
-    SAL_WARN("sd.filter", "Transformed TEXT Bounds: " << aRect);
 
     const int nChars = FPDFTextObj_CountChars(pPageObject) * 2;
     std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
@@ -1093,24 +902,18 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
         = FPDFTextObj_GetTextProcessed(pPageObject, pTextPage, 0, nChars, pShortText);
     if (nActualChars <= 0)
     {
-        SAL_WARN("sd.filter", "Got no TEXT");
         return;
     }
 
     OUString sText(pText.get(), nActualChars);
-    SAL_WARN("sd.filter", "Got Text (" << nChars << "): [" << sText << "].");
 
     const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
     double dFontSizeH = fabs(sqrt2(a, c) * dFontSize);
     double dFontSizeV = fabs(sqrt2(b, d) * dFontSize);
-    SAL_WARN("sd.filter", "Got Font Size: " << dFontSize << ", Scaled Font Size H: " << dFontSizeH
-                                            << ", V: " << dFontSizeV);
     dFontSizeH = lcl_PointToPixel(dFontSizeH);
     dFontSizeV = lcl_PointToPixel(dFontSizeV);
-    SAL_WARN("sd.filter", "Got Pixel Font Size H: " << dFontSizeH << ", V: " << dFontSizeV);
     dFontSizeH = lcl_ToLogic(dFontSizeH);
     dFontSizeV = lcl_ToLogic(dFontSizeV);
-    SAL_WARN("sd.filter", "Got Logic Font Size H: " << dFontSizeH << ", V: " << dFontSizeV);
 
     const Size aFontSize(dFontSizeH, dFontSizeV);
     vcl::Font aFnt = mpVD->GetFont();
@@ -1143,26 +946,18 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const Size& rSize, const OUS
     vcl::Font aFnt(mpVD->GetFont());
     FontAlign eAlg(aFnt.GetAlignment());
 
-    sal_Int32 nTextWidth = static_cast<sal_Int32>(mpVD->GetTextWidth(rStr) * mfScaleX);
+    // sal_Int32 nTextWidth = static_cast<sal_Int32>(mpVD->GetTextWidth(rStr) * mfScaleX);
     sal_Int32 nTextHeight = static_cast<sal_Int32>(mpVD->GetTextHeight() * mfScaleY);
-    SAL_WARN("sd.filter",
-             "Unscaled text size: " << mpVD->GetTextWidth(rStr) << 'x' << mpVD->GetTextHeight()
-                                    << ", Scaled: " << nTextWidth << 'x' << nTextHeight);
 
     Point aPos(FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * mfScaleY + maOfs.Y()));
-    Size bSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * mfScaleY));
-    Size aSize(nTextWidth, nTextHeight);
+    Size aSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * mfScaleY));
 
     if (eAlg == ALIGN_BASELINE)
         aPos.Y() -= FRound(aFontMetric.GetAscent() * mfScaleY);
     else if (eAlg == ALIGN_BOTTOM)
         aPos.Y() -= nTextHeight;
 
-    SAL_WARN("sd.filter", "Final POS: " << aPos);
-    SAL_WARN("sd.filter", "Final Text Size: " << aSize);
-    SAL_WARN("sd.filter", "Final Bound Size: " << bSize);
-    Rectangle aTextRect(aPos, bSize);
-    // SAL_WARN("sd.filter", "Text Rect: " << aTextRect);
+    Rectangle aTextRect(aPos, aSize);
     SdrRectObj* pText = new SdrRectObj(OBJ_TEXT, aTextRect);
     pText->SetModel(mpModel);
 
@@ -1227,9 +1022,8 @@ void ImpSdrPdfImport::MapScaling()
     mnMapScalingOfs = nCount;
 }
 
-void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex)
+void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
 {
-    SAL_WARN("sd.filter", "Got page object IMAGE: " << nPageObjectIndex);
     std::unique_ptr<void, FPDFBitmapDeleter> bitmap(FPDFImageObj_GetBitmapBgra(pPageObject));
     if (!bitmap)
     {
@@ -1253,27 +1047,13 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
 
     switch (format)
     {
-        case FPDFBitmap_Gray:
-            SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
-                                                      << ", stride: " << nStride
-                                                      << ", format: Gray");
-            break;
         case FPDFBitmap_BGR:
-            SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
-                                                      << ", stride: " << nStride
-                                                      << ", format: BGR");
             ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N24BitTcBgr, nHeight, nStride);
             break;
         case FPDFBitmap_BGRx:
-            SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
-                                                      << ", stride: " << nStride
-                                                      << ", format: BGRx");
             ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcRgba, nHeight, nStride);
             break;
         case FPDFBitmap_BGRA:
-            SAL_WARN("sd.filter", "Got IMAGE width: " << nWidth << ", height: " << nHeight
-                                                      << ", stride: " << nStride
-                                                      << ", format: BGRA");
             ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcBgra, nHeight, nStride);
             break;
         default:
@@ -1283,18 +1063,6 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
             break;
     }
 
-    // double a, b, c, d, e, f;
-    // if (!FPDFImageObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f))
-    // {
-    //     SAL_WARN("sd.filter", "FAILED to get image Matrix");
-    // }
-    // SAL_WARN("sd.filter", "Got image Matrix: " << a << ", " << b << ", " << c << ", " << d << ", " << e << ", " << f);
-
-    // if (!FPDFImageObj_SetMatrix(pPageObject, a, b, c, d, e, f))
-    // {
-    //     SAL_WARN("sd.filter", "FAILED to set image Matrix");
-    // }
-
     float left;
     float bottom;
     float right;
@@ -1304,12 +1072,9 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
         SAL_WARN("sd.filter", "FAILED to get image bounds");
     }
 
-    SAL_WARN("sd.filter", "Got IMAGE bounds left: " << left << ", right: " << right
-                                                    << ", top: " << top << ", bottom: " << bottom);
     Rectangle aRect = PointsToLogic(left, right, top, bottom);
     aRect.MoveRight(1);
     aRect.MoveBottom(1);
-    SAL_WARN("sd.filter", "IMAGE Logical Rect FINAL: " << aRect);
 
     SdrGrafObj* pGraf = new SdrGrafObj(Graphic(aBitmap), aRect);
     pGraf->SetModel(mpModel);
@@ -1320,7 +1085,7 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
     InsertObj(pGraf);
 }
 
-void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex)
+void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectIndex*/)
 {
     double a, b, c, d, e, f;
     FPDFPath_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
@@ -1332,9 +1097,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
     std::vector<basegfx::B2DPoint> aBezier;
 
     const int nSegments = FPDFPath_CountSegments(pPageObject);
-    SAL_WARN("sd.filter",
-             "Got page object PATH: " << nPageObjectIndex << " with " << nSegments << " segments.");
-
     for (int nSegmentIndex = 0; nSegmentIndex < nSegments; ++nSegmentIndex)
     {
         FPDF_PATHSEGMENT pPathSegment = FPDFPath_GetPathSegment(pPageObject, nSegmentIndex);
@@ -1354,11 +1116,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
             if (bClose)
                 aPoly.setClosed(bClose); // TODO: Review
 
-            SAL_WARN("sd.filter", "Got " << (bClose ? "CLOSE" : "OPEN") << " point (" << fx << ", "
-                                         << fy << ") matrix (" << a << ", " << b << ", " << c
-                                         << ", " << d << ", " << e << ", " << f << ") -> (" << x
-                                         << ", " << y << ")");
-
             Point aPoint = PointsToLogic(x, y);
             x = aPoint.X();
             y = aPoint.Y();
@@ -1367,12 +1124,10 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
             switch (nSegmentType)
             {
                 case FPDF_SEGMENT_LINETO:
-                    SAL_WARN("sd.filter", "Got LineTo Segment.");
                     aPoly.append(basegfx::B2DPoint(x, y));
                     break;
 
                 case FPDF_SEGMENT_BEZIERTO:
-                    SAL_WARN("sd.filter", "Got BezierTo Segment.");
                     aBezier.emplace_back(x, y);
                     if (aBezier.size() == 3)
                     {
@@ -1382,7 +1137,6 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
                     break;
 
                 case FPDF_SEGMENT_MOVETO:
-                    SAL_WARN("sd.filter", "Got MoveTo Segment.");
                     // New Poly.
                     if (aPoly.count() > 0)
                     {
@@ -1421,15 +1175,11 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
     FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
     const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * fWidth);
     mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
-    // mnLineWidth /= 2;
-    SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth << ",  scaled: " << dWidth
-                                                << ", Logical: " << mnLineWidth);
 
     int nFillMode = FPDF_FILLMODE_ALTERNATE;
     FPDF_BOOL bStroke = true;
     if (FPDFPath_GetDrawMode(pPageObject, &nFillMode, &bStroke))
     {
-        SAL_WARN("sd.filter", "Got PATH FillMode: " << nFillMode << ", Storke: " << bStroke);
         if (nFillMode == FPDF_FILLMODE_ALTERNATE)
             mpVD->SetDrawMode(DrawModeFlags::Default);
         else if (nFillMode == FPDF_FILLMODE_WINDING)
@@ -1443,39 +1193,32 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
     unsigned int nB;
     unsigned int nA;
     FPDFPath_GetFillColor(pPageObject, &nR, &nG, &nB, &nA);
-    SAL_WARN("sd.filter", "Got PATH fill color: " << nR << ", " << nG << ", " << nB << ", " << nA);
     mpVD->SetFillColor(Color(nR, nG, nB));
 
     if (bStroke)
     {
         FPDFPath_GetStrokeColor(pPageObject, &nR, &nG, &nB, &nA);
-        SAL_WARN("sd.filter",
-                 "Got PATH stroke color: " << nR << ", " << nG << ", " << nB << ", " << nA);
         mpVD->SetLineColor(Color(nR, nG, nB));
     }
     else
         mpVD->SetLineColor(COL_TRANSPARENT);
 
-    // if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
-
+    if (!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aPolyPoly)))
+    {
     SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
     pPath->SetModel(mpModel);
     SetAttributes(pPath);
     InsertObj(pPath, false);
 }
+}
 
 Point ImpSdrPdfImport::PointsToLogic(double x, double y) const
 {
     y = correctVertOrigin(y);
-    // SAL_WARN("sd.filter", "Corrected point x: " << x << ", y: " << y);
     x = lcl_PointToPixel(x);
     y = lcl_PointToPixel(y);
 
-    // SAL_WARN("sd.filter", "Pixel point x: " << x << ", y: " << y);
-
     Point aPos(lcl_ToLogic(x), lcl_ToLogic(y));
-    // SAL_WARN("sd.filter", "Logical Pos: " << aPos);
-
     return aPos;
 }
 
@@ -1484,21 +1227,15 @@ Rectangle ImpSdrPdfImport::PointsToLogic(double left, double right, double top,
 {
     top = correctVertOrigin(top);
     bottom = correctVertOrigin(bottom);
-    // SAL_WARN("sd.filter", "Corrected bounds left: " << left << ", right: " << right
-    //                                                 << ", top: " << top << ", bottom: " << bottom);
+
     left = lcl_PointToPixel(left);
     right = lcl_PointToPixel(right);
     top = lcl_PointToPixel(top);
     bottom = lcl_PointToPixel(bottom);
 
-    // SAL_WARN("sd.filter", "Pixel bounds left: " << left << ", right: " << right << ", top: " << top
-    //                                             << ", bottom: " << bottom);
-
     Point aPos(lcl_ToLogic(left), lcl_ToLogic(top));
     Size aSize(lcl_ToLogic(right - left), lcl_ToLogic(bottom - top));
     Rectangle aRect(aPos, aSize);
-    // SAL_WARN("sd.filter", "Logical BBox: " << aRect);
-
     return aRect;
 }
 
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 09d0d680cd7d..e461c1f5e014 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -109,44 +109,34 @@ class ImpSdrPdfImport final
         /// Transform the rectangle (left, right, top, bottom) by this Matrix.
         template <typename T> void Transform(T& left, T& right, T& top, T& bottom)
         {
-            SAL_WARN("sd.filter",
-                     "Transforming: " << left << ", " << right << ", " << top << ", " << bottom);
             T leftTopX = left;
             T leftTopY = top;
             Transform(leftTopX, leftTopY);
-            SAL_WARN("sd.filter", "Left-Top: " << leftTopX << ", " << leftTopY);
 
             T leftBottomX = left;
             T leftBottomY = bottom;
             Transform(leftBottomX, leftBottomY);
-            SAL_WARN("sd.filter", "Left-Bottom: " << leftBottomX << ", " << leftBottomY);
 
             T rightTopX = right;
             T rightTopY = top;
             Transform(rightTopX, rightTopY);
-            SAL_WARN("sd.filter", "Right-Top: " << rightTopX << ", " << rightTopY);
 
             T rightBottomX = right;
             T rightBottomY = bottom;
             Transform(rightBottomX, rightBottomY);
-            SAL_WARN("sd.filter", "Right-Bottom: " << rightBottomX << ", " << rightBottomY);
 
             left = std::min(leftTopX, leftBottomX);
-            SAL_WARN("sd.filter", "left: " << left);
             right = std::max(rightTopX, rightBottomX);
-            SAL_WARN("sd.filter", "right: " << right);
 
             if (top > bottom)
                 top = std::max(leftTopY, rightTopY);
             else
                 top = std::min(leftTopY, rightTopY);
-            SAL_WARN("sd.filter", "top: " << top);
 
             if (top > bottom)
                 bottom = std::max(leftBottomY, rightBottomY);
             else
                 bottom = std::max(leftBottomY, rightBottomY);
-            SAL_WARN("sd.filter", "bottom: " << bottom);
         }
 
         std::string toString() const
@@ -233,7 +223,7 @@ class ImpSdrPdfImport final
     bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
     bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
 
-    void DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
+    void DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport, int nPageIndex);
 
     // Copy assignment is forbidden and not implemented.
     ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;
commit d5eed4392b546349b3058dc4a462fd22436a4710
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon May 14 19:57:15 2018 -0400

    svx: transform PDF text rectangles while importing
    
    Change-Id: I7675a183bfb691a8783950f33dc34826f91cb768

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 8fe06e2bc18c..4059a8d8a83d 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1067,17 +1067,23 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex
         return;
     }
 
-    const Rectangle aRect = PointsToLogic(left, right, top, bottom);
-
     double a, b, c, d, e, f;
     FPDFTextObj_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
-    Matrix aTextMatrix(a, b, c, d, e, f);
-    aTextMatrix.Concatinate(mCurMatrix);
-    SAL_WARN("sd.filter", "Got font scale matrix (" << a << ", " << b << ", " << c << ", " << d
-                                                    << ", " << e << ", " << f << ')');
-    Point aPos = PointsToLogic(e, f);
+    // Matrix aTextMatrix(a, b, c, d, e, f);
+    Matrix aTextMatrix(mCurMatrix);
+    SAL_WARN("sd.filter", "Got text matrix " << aTextMatrix.toString());
+    SAL_WARN("sd.filter", "Context matrix " << mCurMatrix.toString());
+    // aTextMatrix.Concatinate(mCurMatrix);
+    // SAL_WARN("sd.filter", "Got text matrix concat " << aTextMatrix.toString());
+
+    Point aPos = PointsToLogic(aTextMatrix.e(), aTextMatrix.f());
     SAL_WARN("sd.filter", "Got TEXT origin: " << aPos);
-    SAL_WARN("sd.filter", "Got TEXT Bounds: " << aRect);
+
+    const Rectangle aRect2 = PointsToLogic(left, right, top, bottom);
+    SAL_WARN("sd.filter", "Untransformed TEXT Bounds: " << aRect2);
+    aTextMatrix.Transform(left, right, top, bottom);
+    const Rectangle aRect = PointsToLogic(left, right, top, bottom);
+    SAL_WARN("sd.filter", "Transformed TEXT Bounds: " << aRect);
 
     const int nChars = FPDFTextObj_CountChars(pPageObject) * 2;
     std::unique_ptr<sal_Unicode[]> pText(new sal_Unicode[nChars + 1]); // + terminating null
@@ -1413,9 +1419,9 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
 
     float fWidth = 1;
     FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
-    const double dWidth = 0.5 * fabs(sqrt2(mCurMatrix.a(), mCurMatrix.c()) * fWidth);
+    const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * fWidth);
     mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
-    mnLineWidth /= 2;
+    // mnLineWidth /= 2;
     SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth << ",  scaled: " << dWidth
                                                 << ", Logical: " << mnLineWidth);
 
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index bb8dfb159b30..09d0d680cd7d 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -87,6 +87,7 @@ class ImpSdrPdfImport final
         double d() const { return md; }
         double e() const { return me; }
         double f() const { return mf; }
+
         /// Mutliply this * other.
         void Concatinate(const Matrix& other)
         {
@@ -99,12 +100,63 @@ class ImpSdrPdfImport final
         }
 
         /// Transform the point (x, y) by this Matrix.
-        void Transform(double& x, double& y)
+        template <typename T> void Transform(T& x, T& y)
         {
             x = ma * x + mc * y + me;
             y = mb * x + md * y + mf;
         }
 
+        /// Transform the rectangle (left, right, top, bottom) by this Matrix.
+        template <typename T> void Transform(T& left, T& right, T& top, T& bottom)
+        {
+            SAL_WARN("sd.filter",
+                     "Transforming: " << left << ", " << right << ", " << top << ", " << bottom);
+            T leftTopX = left;
+            T leftTopY = top;
+            Transform(leftTopX, leftTopY);
+            SAL_WARN("sd.filter", "Left-Top: " << leftTopX << ", " << leftTopY);
+
+            T leftBottomX = left;
+            T leftBottomY = bottom;
+            Transform(leftBottomX, leftBottomY);
+            SAL_WARN("sd.filter", "Left-Bottom: " << leftBottomX << ", " << leftBottomY);
+
+            T rightTopX = right;
+            T rightTopY = top;
+            Transform(rightTopX, rightTopY);
+            SAL_WARN("sd.filter", "Right-Top: " << rightTopX << ", " << rightTopY);
+
+            T rightBottomX = right;
+            T rightBottomY = bottom;
+            Transform(rightBottomX, rightBottomY);
+            SAL_WARN("sd.filter", "Right-Bottom: " << rightBottomX << ", " << rightBottomY);
+
+            left = std::min(leftTopX, leftBottomX);
+            SAL_WARN("sd.filter", "left: " << left);
+            right = std::max(rightTopX, rightBottomX);
+            SAL_WARN("sd.filter", "right: " << right);
+
+            if (top > bottom)
+                top = std::max(leftTopY, rightTopY);
+            else
+                top = std::min(leftTopY, rightTopY);
+            SAL_WARN("sd.filter", "top: " << top);
+
+            if (top > bottom)
+                bottom = std::max(leftBottomY, rightBottomY);
+            else
+                bottom = std::max(leftBottomY, rightBottomY);
+            SAL_WARN("sd.filter", "bottom: " << bottom);
+        }
+
+        std::string toString() const
+        {
+            std::ostringstream oss;
+            oss << '(' << ma << ", " << mb << ", " << mc << ", " << md << ", " << me << ", " << mf
+                << ')';
+            return oss.str();
+        }
+
     private:
         double ma, mb, mc, md, me, mf;
     };
commit 6494b909e3281765e15fc150d1b67ae5de6d9aef
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon May 14 19:01:44 2018 -0400

    svx: set the Model explicitly before using SDR objects
    
    Change-Id: I176d1c1c7f759904ab36796a47e879e45ce4a5af

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index bb241986a199..8fe06e2bc18c 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -771,6 +771,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
                 if (!aNewRange.isEmpty())
                 {
                     pObj = new SdrPathObj(aNewPoly.isClosed() ? OBJ_POLY : OBJ_PLIN, aNewPoly);
+                    pObj->SetModel(mpModel);
 
                     pObj->SetLayer(aOldLayer);
                     pObj->SetMergedItemSet(aOldItemSet);
@@ -1157,6 +1158,7 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const Size& rSize, const OUS
     Rectangle aTextRect(aPos, bSize);
     // SAL_WARN("sd.filter", "Text Rect: " << aTextRect);
     SdrRectObj* pText = new SdrRectObj(OBJ_TEXT, aTextRect);
+    pText->SetModel(mpModel);
 
     pText->SetMergedItem(makeSdrTextUpperDistItem(0));
     pText->SetMergedItem(makeSdrTextLowerDistItem(0));
@@ -1304,6 +1306,7 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
     SAL_WARN("sd.filter", "IMAGE Logical Rect FINAL: " << aRect);
 
     SdrGrafObj* pGraf = new SdrGrafObj(Graphic(aBitmap), aRect);
+    pGraf->SetModel(mpModel);
 
     // This action is not creating line and fill, set directly, do not use SetAttributes(..)
     pGraf->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
@@ -1450,6 +1453,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
     // if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
 
     SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
+    pPath->SetModel(mpModel);
     SetAttributes(pPath);
     InsertObj(pPath, false);
 }
commit 65329eb45d2f17d24120e15ba24f257204133b2c
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Apr 22 17:21:30 2018 -0400

    svx: support no fill and no stroke paths in PDF import
    
    Change-Id: Ida5daa71d469805fd52e08e804fb9fa182d7d008

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 79cd86d850c1..bb241986a199 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1410,11 +1410,24 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
 
     float fWidth = 1;
     FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
-    SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth);
-    const double dWidth = fabs(sqrt2(a, c) * fWidth);
-    SAL_WARN("sd.filter", "Path Stroke Width scaled: " << dWidth);
+    const double dWidth = 0.5 * fabs(sqrt2(mCurMatrix.a(), mCurMatrix.c()) * fWidth);
     mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
     mnLineWidth /= 2;
+    SAL_WARN("sd.filter", "Path Stroke Width: " << fWidth << ",  scaled: " << dWidth
+                                                << ", Logical: " << mnLineWidth);
+
+    int nFillMode = FPDF_FILLMODE_ALTERNATE;
+    FPDF_BOOL bStroke = true;
+    if (FPDFPath_GetDrawMode(pPageObject, &nFillMode, &bStroke))
+    {
+        SAL_WARN("sd.filter", "Got PATH FillMode: " << nFillMode << ", Storke: " << bStroke);
+        if (nFillMode == FPDF_FILLMODE_ALTERNATE)
+            mpVD->SetDrawMode(DrawModeFlags::Default);
+        else if (nFillMode == FPDF_FILLMODE_WINDING)
+            mpVD->SetDrawMode(DrawModeFlags::Default);
+        else
+            mpVD->SetDrawMode(DrawModeFlags::NoFill);
+    }
 
     unsigned int nR;
     unsigned int nG;
@@ -1424,15 +1437,15 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
     SAL_WARN("sd.filter", "Got PATH fill color: " << nR << ", " << nG << ", " << nB << ", " << nA);
     mpVD->SetFillColor(Color(nR, nG, nB));
 
-    FPDFPath_GetStrokeColor(pPageObject, &nR, &nG, &nB, &nA);
-    SAL_WARN("sd.filter",
-             "Got PATH stroke color: " << nR << ", " << nG << ", " << nB << ", " << nA);
-    mpVD->SetLineColor(Color(nR, nG, nB));
-
-    // int nFillMode = 0; // No fill.
-    // bool bStroke = false;
-    // FPDFPath_GetDrawMode(pPageObject, &nFillMode, &bStroke);
-    // mpVD->Setstroke(Color(r, g, b));
+    if (bStroke)
+    {
+        FPDFPath_GetStrokeColor(pPageObject, &nR, &nG, &nB, &nA);
+        SAL_WARN("sd.filter",
+                 "Got PATH stroke color: " << nR << ", " << nG << ", " << nB << ", " << nA);
+        mpVD->SetLineColor(Color(nR, nG, nB));
+    }
+    else
+        mpVD->SetLineColor(COL_TRANSPARENT);
 
     // if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
 
commit ab1f0fd674ac321f3ce597aebfc7fe2d97fa3cfc
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Apr 22 17:01:18 2018 -0400

    svx: support sub-paths in PDF import
    
    Change-Id: Ibcfd30383db6846e791aea7609ab196c4f3f2da4

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index c1c2e24b20b6..79cd86d850c1 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -1313,17 +1313,19 @@ void ImpSdrPdfImport::ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIn
 
 void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex)
 {
-    SAL_WARN("sd.filter", "Got page object PATH: " << nPageObjectIndex);
-
     double a, b, c, d, e, f;
     FPDFPath_GetMatrix(pPageObject, &a, &b, &c, &d, &e, &f);
     Matrix aPathMatrix(a, b, c, d, e, f);
     aPathMatrix.Concatinate(mCurMatrix);
 
+    basegfx::B2DPolyPolygon aPolyPoly;
     basegfx::B2DPolygon aPoly;
     std::vector<basegfx::B2DPoint> aBezier;
 
     const int nSegments = FPDFPath_CountSegments(pPageObject);
+    SAL_WARN("sd.filter",
+             "Got page object PATH: " << nPageObjectIndex << " with " << nSegments << " segments.");
+
     for (int nSegmentIndex = 0; nSegmentIndex < nSegments; ++nSegmentIndex)
     {
         FPDF_PATHSEGMENT pPathSegment = FPDFPath_GetPathSegment(pPageObject, nSegmentIndex);
@@ -1338,16 +1340,16 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
 
             double x = fx;
             double y = fy;
-            SAL_WARN("sd.filter", "Got point (" << x << ", " << y << ") matrix (" << a << ", " << b
-                                                << ", " << c << ", " << d << ", " << e << ", " << f
-                                                << ')');
             aPathMatrix.Transform(x, y);
-
             const bool bClose = FPDFPathSegment_GetClose(pPathSegment);
             if (bClose)
                 aPoly.setClosed(bClose); // TODO: Review
-            SAL_WARN("sd.filter",
-                     "Point corrected (" << x << ", " << y << "): " << (bClose ? "CLOSE" : "OPEN"));
+
+            SAL_WARN("sd.filter", "Got " << (bClose ? "CLOSE" : "OPEN") << " point (" << fx << ", "
+                                         << fy << ") matrix (" << a << ", " << b << ", " << c
+                                         << ", " << d << ", " << e << ", " << f << ") -> (" << x
+                                         << ", " << y << ")");
+
             Point aPoint = PointsToLogic(x, y);
             x = aPoint.X();
             y = aPoint.Y();
@@ -1372,6 +1374,13 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
 
                 case FPDF_SEGMENT_MOVETO:
                     SAL_WARN("sd.filter", "Got MoveTo Segment.");
+                    // New Poly.
+                    if (aPoly.count() > 0)
+                    {
+                        aPolyPoly.append(aPoly, 1);
+                        aPoly.clear();
+                    }
+
                     aPoly.append(basegfx::B2DPoint(x, y));
                     break;
 
@@ -1389,9 +1398,15 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
         aBezier.clear();
     }
 
+    if (aPoly.count() > 0)
+    {
+        aPolyPoly.append(aPoly, 1);
+        aPoly.clear();
+    }
+
     const basegfx::B2DHomMatrix aTransform(
         basegfx::tools::createScaleTranslateB2DHomMatrix(mfScaleX, mfScaleY, maOfs.X(), maOfs.Y()));
-    aPoly.transform(aTransform);
+    aPolyPoly.transform(aTransform);
 
     float fWidth = 1;
     FPDFPath_GetStrokeWidth(pPageObject, &fWidth);
@@ -1421,7 +1436,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectInd
 
     // if(!mbLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
 
-    SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aPoly));
+    SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aPolyPoly);
     SetAttributes(pPath);
     InsertObj(pPath, false);
 }
commit e4477eb7bb3ce80214dfe5cea1eecc9c6913438c
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Apr 22 10:48:51 2018 -0400

    svx: import processed PDF text
    
    Some PDFs don't include spaces in the text.
    Instead, they rely on the explicit positioning
    of each character to render visually separated words.
    Latex seems to be prone to this approach, though not
    exclusively.
    
    Luckily, PDFium does process text and inserts
    "generated" spaces where necessary, which is what
    we retrieve and use as the text string while importing.
    
    Change-Id: Ic21fe6c8416ecaba66f06b6260f1d6b040ff12af

diff --git a/external/pdfium/edit.patch.1 b/external/pdfium/edit.patch.1
index 270dceb871b6..a110313017da 100644
--- a/external/pdfium/edit.patch.1
+++ b/external/pdfium/edit.patch.1
@@ -147,6 +147,56 @@ index 0a01ae0..6947e3a 100644
    if (bPattern) {
      DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size,
                              &text_matrix, bFill, bStroke);
+diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
+index e712549..a7973f7 100644
+--- a/core/fpdftext/cpdf_textpage.cpp
++++ b/core/fpdftext/cpdf_textpage.cpp
+@@ -1490,3 +1490,32 @@ bool CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1,
+   rect.Intersect(rect2);
+   return !rect.IsEmpty();
+ }
++
++WideString CPDF_TextPage::GetTextObjectText(CPDF_TextObject* pTextObj)
++{
++  if (!m_bIsParsed)
++    return WideString();
++
++  float posy = 0;
++  bool IsContainPreChar = false;
++  bool IsAddLineFeed = false;
++  WideString strText;
++  for (const auto& charinfo : m_CharList) {
++    if (charinfo.m_pTextObj == pTextObj) {
++      IsContainPreChar = true;
++      IsAddLineFeed = false;
++      if (charinfo.m_Unicode)
++        strText += charinfo.m_Unicode;
++    } else if (charinfo.m_Unicode == 32) {
++      if (IsContainPreChar && charinfo.m_Unicode) {
++        strText += charinfo.m_Unicode;
++        IsContainPreChar = false;
++        IsAddLineFeed = false;
++      }
++    } else {
++      IsContainPreChar = false;
++      IsAddLineFeed = true;
++    }
++  }
++  return strText;
++}
+diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
+index c87ab00..e5a1ba8 100644
+--- a/core/fpdftext/cpdf_textpage.h
++++ b/core/fpdftext/cpdf_textpage.h
+@@ -110,6 +110,8 @@ class CPDF_TextPage {
+   WideString GetPageText(int start, int count) const;
+   WideString GetAllPageText() const { return GetPageText(0, CountChars()); }
+ 
++  WideString GetTextObjectText(CPDF_TextObject* pTextObj);
++
+   int CountRects(int start, int nCount);
+   bool GetRect(int rectIndex, CFX_FloatRect* pRect) const;
+ 
 diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp
 index 4ac5cf6..4286de4 100644
 --- a/core/fxge/cfx_pathdata.cpp
@@ -199,7 +249,7 @@ index 0d7ba56..37bdf99 100644
  FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object,
                                   void* buffer,
 diff --git a/fpdfsdk/fpdfeditpage.cpp b/fpdfsdk/fpdfeditpage.cpp
-index ca2cf3f..832a9ae 100644
+index ca2cf3f..2162625 100644
 --- a/fpdfsdk/fpdfeditpage.cpp
 +++ b/fpdfsdk/fpdfeditpage.cpp
 @@ -11,12 +11,14 @@
@@ -217,7 +267,15 @@ index ca2cf3f..832a9ae 100644
  #include "core/fpdfapi/page/cpdf_shadingobject.h"
  #include "core/fpdfapi/parser/cpdf_array.h"
  #include "core/fpdfapi/parser/cpdf_document.h"
-@@ -363,3 +365,212 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
+@@ -24,6 +26,7 @@
+ #include "core/fpdfapi/parser/cpdf_string.h"
+ #include "core/fpdfdoc/cpdf_annot.h"
+ #include "core/fpdfdoc/cpdf_annotlist.h"
++#include "core/fpdftext/cpdf_textpage.h"
+ #include "fpdfsdk/fsdk_define.h"
+ #include "public/fpdf_formfill.h"
+ #include "third_party/base/logging.h"
+@@ -363,3 +366,252 @@ FPDFPageObj_GetBounds(FPDF_PAGEOBJECT pageObject,
    *top = bbox.top;
    return true;
  }
@@ -327,6 +385,46 @@ index ca2cf3f..832a9ae 100644
 +  return ret_count;
 +}
 +
++FPDF_EXPORT int FPDF_CALLCONV
++FPDFTextObj_GetTextProcessed(FPDF_PAGEOBJECT text_object,
++                             FPDF_TEXTPAGE page,

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list