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@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
parent
9308f35318
commit
0ffe9eb48a
@ -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"
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user