[Libreoffice-commits] core.git: sd/source vcl/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jun 28 14:34:32 UTC 2016
sd/source/ui/inc/unoprnms.hxx | 1 +
sd/source/ui/unoidl/unopage.cxx | 15 ++++++++++++---
vcl/source/filter/ipdf/pdfread.cxx | 5 ++---
3 files changed, 15 insertions(+), 6 deletions(-)
New commits:
commit 0ffe9eb48a78bccf3d01a0effd5f2715174d38ff
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jun 28 15:52:59 2016 +0200
sd draw page: add PreviewMetafile UNO property
This allows an unnecessary GDIMetaFile -> WMF -> GDIMetaFile roundtrip,
and also avoids the odd black border at the bottom / right of the
preview metafile in the PDF import-as-graphic filter.
Change-Id: I7e3e782bbe0cf56def352e23b60864bb7773b607
Reviewed-on: https://gerrit.libreoffice.org/26743
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sd/source/ui/inc/unoprnms.hxx b/sd/source/ui/inc/unoprnms.hxx
index d0af59c..3dd438f 100644
--- a/sd/source/ui/inc/unoprnms.hxx
+++ b/sd/source/ui/inc/unoprnms.hxx
@@ -36,6 +36,7 @@
#define UNO_NAME_PAGE_WIDTH "Width"
#define UNO_NAME_PAGE_PREVIEW "Preview"
#define UNO_NAME_PAGE_PREVIEWBITMAP "PreviewBitmap"
+#define UNO_NAME_PAGE_PREVIEWMETAFILE "PreviewMetafile"
#define UNO_NAME_PAGE_VISIBLE "Visible"
#define UNO_NAME_OBJ_BOOKMARK "Bookmark"
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index cd550d8..4ca21d0 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -97,7 +97,7 @@ enum WID_PAGE
WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, WID_PAGE_DATETIMEFIXED,
WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, WID_TRANSITION_SUBTYPE,
WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, WID_TRANSITION_DURATION, WID_LOOP_SOUND,
- WID_NAVORDER
+ WID_NAVORDER, WID_PAGE_PREVIEWMETAFILE
};
static sal_Char const sEmptyPageName[sizeof("page")] = "page";
@@ -125,6 +125,7 @@ const SvxItemPropertySet* ImplGetDrawPagePropertySet( bool bImpress, PageKind eP
{ OUString(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0},
{ OUString(UNO_NAME_PAGE_PREVIEW), WID_PAGE_PREVIEW, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
{ OUString(UNO_NAME_PAGE_PREVIEWBITMAP), WID_PAGE_PREVIEWBITMAP, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
+ { OUString(UNO_NAME_PAGE_PREVIEWMETAFILE), WID_PAGE_PREVIEWMETAFILE, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},
{ OUString(UNO_NAME_PAGE_VISIBLE), WID_PAGE_VISIBLE, cppu::UnoType<bool>::get(), 0, 0},
{ OUString(UNO_NAME_OBJ_SOUNDFILE), WID_PAGE_SOUNDFILE, cppu::UnoType<Any>::get(), 0, 0},
{ OUString(sUNO_Prop_IsBackgroundVisible), WID_PAGE_BACKVIS, cppu::UnoType<bool>::get(), 0, 0},
@@ -200,6 +201,7 @@ const SvxItemPropertySet* ImplGetDrawPagePropertySet( bool bImpress, PageKind eP
{ OUString(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, ::cppu::UnoType<sal_Int32>::get(), 0, 0}, \
{ OUString(UNO_NAME_PAGE_PREVIEW), WID_PAGE_PREVIEW, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0}, \
{ OUString(UNO_NAME_PAGE_PREVIEWBITMAP), WID_PAGE_PREVIEWBITMAP, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},\
+ { OUString(UNO_NAME_PAGE_PREVIEWMETAFILE), WID_PAGE_PREVIEWMETAFILE, cppu::UnoType<css::uno::Sequence<sal_Int8>>::get(), css::beans::PropertyAttribute::READONLY, 0},\
{ OUString(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, \
{ OUString(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, ::cppu::UnoType<OUString>::get(), 0, 0}, \
{ OUString("IsBackgroundDark"), WID_PAGE_ISDARK, cppu::UnoType<bool>::get(), beans::PropertyAttribute::READONLY, 0}, \
@@ -1017,7 +1019,8 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
- switch( pEntry ? pEntry->nWID : -1 )
+ sal_Int16 nEntry = pEntry ? pEntry->nWID : -1;
+ switch (nEntry)
{
case WID_NAVORDER:
aAny = getNavigationOrder();
@@ -1100,6 +1103,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
getBackground( aAny );
break;
case WID_PAGE_PREVIEW :
+ case WID_PAGE_PREVIEWMETAFILE :
{
SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(GetPage()->GetModel());
if ( pDoc )
@@ -1126,7 +1130,12 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
xMetaFile->SetPrefSize( aSize );
SvMemoryStream aDestStrm( 65535, 65535 );
- ConvertGDIMetaFileToWMF( *xMetaFile, aDestStrm, nullptr, false );
+ if (nEntry == WID_PAGE_PREVIEW)
+ // Preview: WMF format.
+ ConvertGDIMetaFileToWMF(*xMetaFile, aDestStrm, nullptr, false);
+ else
+ // PreviewMetafile: SVM format.
+ xMetaFile->Write(aDestStrm);
Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aDestStrm.GetData()), aDestStrm.Tell() );
aAny <<= aSeq;
}
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index 6bd1f6f..4b0e1eb 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -85,7 +85,7 @@ VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
uno::Reference<beans::XPropertySet> xFirstPage(xDrawPages->getByIndex(0), uno::UNO_QUERY);
uno::Sequence<sal_Int8> aSequence;
- if (!(xFirstPage->getPropertyValue("Preview") >>= aSequence))
+ if (!(xFirstPage->getPropertyValue("PreviewMetafile") >>= aSequence))
return false;
if (!aSequence.hasElements())
@@ -96,8 +96,7 @@ VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
aPreviewStream.WriteBytes(aSequence.getArray(), aSequence.getLength());
aPreviewStream.Seek(0);
GDIMetaFile aMtf;
- if (!ConvertWMFToGDIMetaFile(aPreviewStream, aMtf))
- return false;
+ aMtf.Read(aPreviewStream);
rGraphic = aMtf;
More information about the Libreoffice-commits
mailing list