Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
f1552a8b
Kaydet (Commit)
f1552a8b
authored
Mar 28, 2019
tarafından
Jan Holesovsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Revert "pdfium: Keep the PDF data in memory, so that we can really share them."
This reverts commit
6a96ea63
.
üst
cec4b94d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
93 deletions
+73
-93
pdfread.hxx
include/vcl/pdfread.hxx
+0
-5
pdfread.cxx
vcl/source/filter/ipdf/pdfread.cxx
+57
-64
impgraph.cxx
vcl/source/gdi/impgraph.cxx
+16
-24
No files found.
include/vcl/pdfread.hxx
Dosyayı görüntüle @
f1552a8b
...
@@ -16,11 +16,6 @@
...
@@ -16,11 +16,6 @@
namespace
vcl
namespace
vcl
{
{
/// Fills the rBitmaps vector with rendered pages.
VCL_DLLPUBLIC
size_t
RenderPDFBitmaps
(
const
void
*
pBuffer
,
int
nSize
,
std
::
vector
<
Bitmap
>&
rBitmaps
,
const
size_t
nFirstPage
=
0
,
int
nPages
=
1
,
const
double
fResolutionDPI
=
96.
);
/// Imports a PDF stream into rGraphic as a GDIMetaFile.
/// Imports a PDF stream into rGraphic as a GDIMetaFile.
VCL_DLLPUBLIC
bool
ImportPDF
(
SvStream
&
rStream
,
Bitmap
&
rBitmap
,
size_t
nPageIndex
,
VCL_DLLPUBLIC
bool
ImportPDF
(
SvStream
&
rStream
,
Bitmap
&
rBitmap
,
size_t
nPageIndex
,
css
::
uno
::
Sequence
<
sal_Int8
>&
rPdfData
,
css
::
uno
::
Sequence
<
sal_Int8
>&
rPdfData
,
...
...
vcl/source/filter/ipdf/pdfread.cxx
Dosyayı görüntüle @
f1552a8b
...
@@ -63,12 +63,68 @@ size_t generatePreview(SvStream& rStream, std::vector<Bitmap>& rBitmaps,
...
@@ -63,12 +63,68 @@ size_t generatePreview(SvStream& rStream, std::vector<Bitmap>& rBitmaps,
const
size_t
nFirstPage
=
0
,
int
nPages
=
1
,
const
size_t
nFirstPage
=
0
,
int
nPages
=
1
,
const
double
fResolutionDPI
=
96.
)
const
double
fResolutionDPI
=
96.
)
{
{
FPDF_LIBRARY_CONFIG
aConfig
;
aConfig
.
version
=
2
;
aConfig
.
m_pUserFontPaths
=
nullptr
;
aConfig
.
m_pIsolate
=
nullptr
;
aConfig
.
m_v8EmbedderSlot
=
0
;
FPDF_InitLibraryWithConfig
(
&
aConfig
);
// Read input into a buffer.
// Read input into a buffer.
SvMemoryStream
aInBuffer
;
SvMemoryStream
aInBuffer
;
rStream
.
Seek
(
nPos
);
rStream
.
Seek
(
nPos
);
aInBuffer
.
WriteStream
(
rStream
,
nSize
);
aInBuffer
.
WriteStream
(
rStream
,
nSize
);
return
vcl
::
RenderPDFBitmaps
(
aInBuffer
.
GetData
(),
aInBuffer
.
GetSize
(),
rBitmaps
,
nFirstPage
,
nPages
,
fResolutionDPI
);
// Load the buffer using pdfium.
FPDF_DOCUMENT
pPdfDocument
=
FPDF_LoadMemDocument
(
aInBuffer
.
GetData
(),
aInBuffer
.
GetSize
(),
/*password=*/
nullptr
);
if
(
!
pPdfDocument
)
return
0
;
const
int
nPageCount
=
FPDF_GetPageCount
(
pPdfDocument
);
if
(
nPages
<=
0
)
nPages
=
nPageCount
;
const
size_t
nLastPage
=
std
::
min
<
int
>
(
nPageCount
,
nFirstPage
+
nPages
)
-
1
;
for
(
size_t
nPageIndex
=
nFirstPage
;
nPageIndex
<=
nLastPage
;
++
nPageIndex
)
{
// Render next page.
FPDF_PAGE
pPdfPage
=
FPDF_LoadPage
(
pPdfDocument
,
nPageIndex
);
if
(
!
pPdfPage
)
break
;
// Returned unit is points, convert that to pixel.
const
size_t
nPageWidth
=
pointToPixel
(
FPDF_GetPageWidth
(
pPdfPage
),
fResolutionDPI
);
const
size_t
nPageHeight
=
pointToPixel
(
FPDF_GetPageHeight
(
pPdfPage
),
fResolutionDPI
);
FPDF_BITMAP
pPdfBitmap
=
FPDFBitmap_Create
(
nPageWidth
,
nPageHeight
,
/*alpha=*/
1
);
if
(
!
pPdfBitmap
)
break
;
const
FPDF_DWORD
nColor
=
FPDFPage_HasTransparency
(
pPdfPage
)
?
0x00000000
:
0xFFFFFFFF
;
FPDFBitmap_FillRect
(
pPdfBitmap
,
0
,
0
,
nPageWidth
,
nPageHeight
,
nColor
);
FPDF_RenderPageBitmap
(
pPdfBitmap
,
pPdfPage
,
/*start_x=*/
0
,
/*start_y=*/
0
,
nPageWidth
,
nPageHeight
,
/*rotate=*/
0
,
/*flags=*/
0
);
// Save the buffer as a bitmap.
Bitmap
aBitmap
(
Size
(
nPageWidth
,
nPageHeight
),
24
);
{
Bitmap
::
ScopedWriteAccess
pWriteAccess
(
aBitmap
);
const
auto
pPdfBuffer
=
static_cast
<
ConstScanline
>
(
FPDFBitmap_GetBuffer
(
pPdfBitmap
));
const
int
nStride
=
FPDFBitmap_GetStride
(
pPdfBitmap
);
for
(
size_t
nRow
=
0
;
nRow
<
nPageHeight
;
++
nRow
)
{
ConstScanline
pPdfLine
=
pPdfBuffer
+
(
nStride
*
nRow
);
// pdfium byte order is BGRA.
pWriteAccess
->
CopyScanline
(
nRow
,
pPdfLine
,
ScanlineFormat
::
N32BitTcBgra
,
nStride
);
}
}
rBitmaps
.
emplace_back
(
std
::
move
(
aBitmap
));
FPDFBitmap_Destroy
(
pPdfBitmap
);
FPDF_ClosePage
(
pPdfPage
);
}
FPDF_CloseDocument
(
pPdfDocument
);
FPDF_DestroyLibrary
();
return
rBitmaps
.
size
();
}
}
/// Decide if PDF data is old enough to be compatible.
/// Decide if PDF data is old enough to be compatible.
...
@@ -155,69 +211,6 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream,
...
@@ -155,69 +211,6 @@ bool getCompatibleStream(SvStream& rInStream, SvStream& rOutStream,
namespace
vcl
namespace
vcl
{
{
size_t
RenderPDFBitmaps
(
const
void
*
pBuffer
,
int
nSize
,
std
::
vector
<
Bitmap
>&
rBitmaps
,
const
size_t
nFirstPage
,
int
nPages
,
const
double
fResolutionDPI
)
{
FPDF_LIBRARY_CONFIG
aConfig
;
aConfig
.
version
=
2
;
aConfig
.
m_pUserFontPaths
=
nullptr
;
aConfig
.
m_pIsolate
=
nullptr
;
aConfig
.
m_v8EmbedderSlot
=
0
;
FPDF_InitLibraryWithConfig
(
&
aConfig
);
// Load the buffer using pdfium.
FPDF_DOCUMENT
pPdfDocument
=
FPDF_LoadMemDocument
(
pBuffer
,
nSize
,
/*password=*/
nullptr
);
if
(
!
pPdfDocument
)
return
0
;
const
int
nPageCount
=
FPDF_GetPageCount
(
pPdfDocument
);
if
(
nPages
<=
0
)
nPages
=
nPageCount
;
const
size_t
nLastPage
=
std
::
min
<
int
>
(
nPageCount
,
nFirstPage
+
nPages
)
-
1
;
for
(
size_t
nPageIndex
=
nFirstPage
;
nPageIndex
<=
nLastPage
;
++
nPageIndex
)
{
// Render next page.
FPDF_PAGE
pPdfPage
=
FPDF_LoadPage
(
pPdfDocument
,
nPageIndex
);
if
(
!
pPdfPage
)
break
;
// Returned unit is points, convert that to pixel.
const
size_t
nPageWidth
=
pointToPixel
(
FPDF_GetPageWidth
(
pPdfPage
),
fResolutionDPI
);
const
size_t
nPageHeight
=
pointToPixel
(
FPDF_GetPageHeight
(
pPdfPage
),
fResolutionDPI
);
FPDF_BITMAP
pPdfBitmap
=
FPDFBitmap_Create
(
nPageWidth
,
nPageHeight
,
/*alpha=*/
1
);
if
(
!
pPdfBitmap
)
break
;
const
FPDF_DWORD
nColor
=
FPDFPage_HasTransparency
(
pPdfPage
)
?
0x00000000
:
0xFFFFFFFF
;
FPDFBitmap_FillRect
(
pPdfBitmap
,
0
,
0
,
nPageWidth
,
nPageHeight
,
nColor
);
FPDF_RenderPageBitmap
(
pPdfBitmap
,
pPdfPage
,
/*start_x=*/
0
,
/*start_y=*/
0
,
nPageWidth
,
nPageHeight
,
/*rotate=*/
0
,
/*flags=*/
0
);
// Save the buffer as a bitmap.
Bitmap
aBitmap
(
Size
(
nPageWidth
,
nPageHeight
),
24
);
{
Bitmap
::
ScopedWriteAccess
pWriteAccess
(
aBitmap
);
const
auto
pPdfBuffer
=
static_cast
<
ConstScanline
>
(
FPDFBitmap_GetBuffer
(
pPdfBitmap
));
const
int
nStride
=
FPDFBitmap_GetStride
(
pPdfBitmap
);
for
(
size_t
nRow
=
0
;
nRow
<
nPageHeight
;
++
nRow
)
{
ConstScanline
pPdfLine
=
pPdfBuffer
+
(
nStride
*
nRow
);
// pdfium byte order is BGRA.
pWriteAccess
->
CopyScanline
(
nRow
,
pPdfLine
,
ScanlineFormat
::
N32BitTcBgra
,
nStride
);
}
}
rBitmaps
.
emplace_back
(
std
::
move
(
aBitmap
));
FPDFBitmap_Destroy
(
pPdfBitmap
);
FPDF_ClosePage
(
pPdfPage
);
}
FPDF_CloseDocument
(
pPdfDocument
);
FPDF_DestroyLibrary
();
return
rBitmaps
.
size
();
}
bool
ImportPDF
(
SvStream
&
rStream
,
Bitmap
&
rBitmap
,
bool
ImportPDF
(
SvStream
&
rStream
,
Bitmap
&
rBitmap
,
size_t
nPageIndex
,
size_t
nPageIndex
,
css
::
uno
::
Sequence
<
sal_Int8
>&
rPdfData
,
css
::
uno
::
Sequence
<
sal_Int8
>&
rPdfData
,
...
...
vcl/source/gdi/impgraph.cxx
Dosyayı görüntüle @
f1552a8b
...
@@ -37,7 +37,6 @@
...
@@ -37,7 +37,6 @@
#include <impgraph.hxx>
#include <impgraph.hxx>
#include <com/sun/star/ucb/CommandAbortedException.hpp>
#include <com/sun/star/ucb/CommandAbortedException.hpp>
#include <vcl/dibtools.hxx>
#include <vcl/dibtools.hxx>
#include <map>
#include <memory>
#include <memory>
#include <o3tl/make_unique.hxx>
#include <o3tl/make_unique.hxx>
#include <vcl/gdimetafiletools.hxx>
#include <vcl/gdimetafiletools.hxx>
...
@@ -1476,7 +1475,6 @@ bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const
...
@@ -1476,7 +1475,6 @@ bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const
return
bResult
;
return
bResult
;
}
}
static
std
::
map
<
BitmapChecksum
,
std
::
shared_ptr
<
css
::
uno
::
Sequence
<
sal_Int8
>>>
sPdfDataCache
;
void
ReadImpGraphic
(
SvStream
&
rIStm
,
ImpGraphic
&
rImpGraphic
)
void
ReadImpGraphic
(
SvStream
&
rIStm
,
ImpGraphic
&
rImpGraphic
)
{
{
...
@@ -1625,25 +1623,23 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
...
@@ -1625,25 +1623,23 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
else
if
(
nMagic
==
nPdfMagic
)
else
if
(
nMagic
==
nPdfMagic
)
{
{
// Stream in PDF data.
// Stream in PDF data.
BitmapChecksum
nPdfId
=
0
;
sal_uInt32
nPdfDataLength
=
0
;
rIStm
.
ReadUInt64
(
nPdfId
);
rIStm
.
ReadUInt32
(
nPdfDataLength
);
rImpGraphic
.
mnPageNumber
=
0
;
rIStm
.
ReadInt32
(
rImpGraphic
.
mnPageNumber
);
auto
it
=
sPdfDataCache
.
find
(
nPdfId
);
assert
(
it
!=
sPdfDataCache
.
end
());
rImpGraphic
.
mpPdfData
=
it
->
second
;
Bitmap
aBitmap
;
Bitmap
aBitmap
;
rImpGraphic
.
maEx
=
aBitmap
;
std
::
vector
<
Bitmap
>
aBitmaps
;
if
(
nPdfDataLength
&&
!
rIStm
.
GetError
())
if
(
vcl
::
RenderPDFBitmaps
(
rImpGraphic
.
mpPdfData
->
getConstArray
(),
rImpGraphic
.
mpPdfData
->
getLength
(),
aBitmaps
,
rImpGraphic
.
mnPageNumber
,
1
)
==
1
)
{
rImpGraphic
.
maEx
=
aBitmaps
[
0
];
if
(
!
rImpGraphic
.
mpPdfData
)
rImpGraphic
.
mpPdfData
.
reset
(
new
uno
::
Sequence
<
sal_Int8
>
());
rImpGraphic
.
meType
=
GraphicType
::
Bitmap
;
if
(
vcl
::
ImportPDF
(
rIStm
,
aBitmap
,
rImpGraphic
.
mnPageNumber
,
*
rImpGraphic
.
mpPdfData
,
rIStm
.
Tell
(),
nPdfDataLength
))
{
rImpGraphic
.
maEx
=
aBitmap
;
rImpGraphic
.
meType
=
GraphicType
::
Bitmap
;
}
}
}
}
else
else
{
{
...
@@ -1734,14 +1730,10 @@ void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
...
@@ -1734,14 +1730,10 @@ void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
}
}
else
if
(
rImpGraphic
.
hasPdfData
())
else
if
(
rImpGraphic
.
hasPdfData
())
{
{
BitmapChecksum
nPdfId
=
vcl_get_checksum
(
0
,
rImpGraphic
.
mpPdfData
->
getConstArray
(),
rImpGraphic
.
mpPdfData
->
getLength
());
if
(
sPdfDataCache
.
find
(
nPdfId
)
==
sPdfDataCache
.
end
())
sPdfDataCache
.
emplace
(
nPdfId
,
rImpGraphic
.
mpPdfData
);
// Stream out PDF data.
// Stream out PDF data.
rOStm
.
WriteUInt32
(
nPdfMagic
);
rOStm
.
WriteUInt32
(
nPdfMagic
);
rOStm
.
WriteUInt
64
(
nPdfId
);
rOStm
.
WriteUInt
32
(
rImpGraphic
.
mpPdfData
->
getLength
()
);
rOStm
.
Write
Int32
(
rImpGraphic
.
mnPageNumber
);
rOStm
.
Write
Bytes
(
rImpGraphic
.
mpPdfData
->
getConstArray
(),
rImpGraphic
.
mpPdfData
->
getLength
()
);
}
}
else
if
(
rImpGraphic
.
ImplIsAnimated
())
else
if
(
rImpGraphic
.
ImplIsAnimated
())
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment