Kaydet (Commit) ddb881e2 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Jan Holesovsky

svx: support breaking PDFs imported as images

Change-Id: I990c2b3c3055fbffddedc407c34beb5824277b38
üst eb02d79c
......@@ -124,7 +124,7 @@ bool SdPdfFilter::Import()
Graphic aGraphic(aBitmap);
aGraphic.setPdfData(std::make_shared<uno::Sequence<sal_Int8>>(aPdfData));
aGraphic.setPageNumber(nPageNumber);
aGraphic.SetLink(aGfxLink);
aGraphic.SetGfxLink(aGfxLink);
// Create the page and insert the Graphic.
SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard);
......
......@@ -84,6 +84,7 @@ $(eval $(call gb_Library_use_externals,svxcore,\
icuuc \
icu_headers \
libxml2 \
$(if $(filter PDFIUM,$(BUILD_TYPE)),pdfium) \
))
ifeq ($(ENABLE_HEADLESS),)
$(eval $(call gb_Library_use_externals,svxcore,\
......@@ -338,6 +339,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
svx/source/svdraw/svdovirt \
svx/source/svdraw/svdpage \
svx/source/svdraw/svdpagv \
svx/source/svdraw/svdpdf \
svx/source/svdraw/svdpntv \
svx/source/svdraw/svdpoev \
svx/source/svdraw/svdsnpv \
......
......@@ -607,14 +607,18 @@ void SdrEditView::CheckPossibilities()
if (!bImportMtfPossible)
{
const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj);
if(pSdrGrafObj && ((pSdrGrafObj->HasGDIMetaFile() && !pSdrGrafObj->IsEPS()) || pSdrGrafObj->isEmbeddedVectorGraphicData()))
if (pSdrGrafObj != nullptr)
{
bImportMtfPossible = true;
if ((pSdrGrafObj->HasGDIMetaFile() && !pSdrGrafObj->IsEPS()) ||
pSdrGrafObj->isEmbeddedVectorGraphicData() ||
pSdrGrafObj->isEmbeddedPdfData())
{
bImportMtfPossible = true;
}
}
if(pSdrOle2Obj)
const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj);
if (pSdrOle2Obj)
{
bImportMtfPossible = pSdrOle2Obj->GetObjRef().is();
}
......
......@@ -30,6 +30,7 @@
#include <svx/svdoole2.hxx>
#include <svx/dialmgr.hxx>
#include "svdfmtf.hxx"
#include "svdpdf.hxx"
#include <svx/svdetc.hxx>
#include <sfx2/basedlgs.hxx>
#include <editeng/outlobj.hxx>
......@@ -2038,22 +2039,35 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo)
SdrPageView* pPV=pM->GetPageView();
SdrObjList* pOL=pObj->getParentOfSdrObject();
const size_t nInsPos=pObj->GetOrdNum()+1;
SdrGrafObj* pGraf= dynamic_cast<SdrGrafObj*>( pObj );
SdrOle2Obj* pOle2= dynamic_cast<SdrOle2Obj*>( pObj );
sal_uIntPtr nInsAnz=0;
tools::Rectangle aLogicRect;
if (pGraf && (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedVectorGraphicData()))
SdrGrafObj* pGraf = dynamic_cast<SdrGrafObj*>( pObj );
if (pGraf != nullptr)
{
GDIMetaFile aMetaFile(GetMetaFile(pGraf));
if (aMetaFile.GetActionSize())
if (pGraf->HasGDIMetaFile() || pGraf->isEmbeddedVectorGraphicData())
{
GDIMetaFile aMetaFile(GetMetaFile(pGraf));
if (aMetaFile.GetActionSize())
{
aLogicRect = pGraf->GetLogicRect();
ImpSdrGDIMetaFileImport aFilter(*mpModel, pObj->GetLayer(), aLogicRect);
nInsAnz = aFilter.DoImport(aMetaFile, *pOL, nInsPos, pProgrInfo);
}
}
else if (pGraf->isEmbeddedPdfData())
{
aLogicRect = pGraf->GetLogicRect();
ImpSdrGDIMetaFileImport aFilter(*mpModel, pObj->GetLayer(), aLogicRect);
nInsAnz = aFilter.DoImport(aMetaFile, *pOL, nInsPos, pProgrInfo);
ImpSdrPdfImport aFilter(*mpModel, pObj->GetLayer(), aLogicRect, pGraf->getEmbeddedPdfData());
if (pGraf->getEmbeddedPageNumber() < aFilter.GetPageCount())
{
nInsAnz = aFilter.DoImport(*pOL, nInsPos, pGraf->getEmbeddedPageNumber(), pProgrInfo);
}
}
}
SdrOle2Obj* pOle2 = dynamic_cast<SdrOle2Obj*>(pObj);
if (pOle2 != nullptr && pOle2->GetGraphic())
{
aLogicRect = pOle2->GetLogicRect();
......
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
#define INCLUDED_SVX_SOURCE_SVDRAW_SVDPDF_HXX
#include <sal/config.h>
#include <memory>
#include <tools/contnr.hxx>
#include <tools/fract.hxx>
#include <vcl/metaact.hxx>
#include <vcl/virdev.hxx>
#include <svx/svdobj.hxx>
#include <svx/xdash.hxx>
#include <com/sun/star/uno/Sequence.hxx>
// Forward Declarations
class SfxItemSet;
class SdrObjList;
class SdrModel;
class SdrPage;
class SdrObject;
class SvdProgressInfo;
typedef void* FPDF_DOCUMENT;
// Helper Class to import PDF
class ImpSdrPdfImport final
{
::std::vector<SdrObject*> maTmpList;
ScopedVclPtr<VirtualDevice> mpVD;
tools::Rectangle maScaleRect;
const std::shared_ptr<css::uno::Sequence<sal_Int8>> mpPdfData;
size_t mnMapScalingOfs; // from here on, not edited with MapScaling
std::unique_ptr<SfxItemSet> mpLineAttr;
std::unique_ptr<SfxItemSet> mpFillAttr;
std::unique_ptr<SfxItemSet> mpTextAttr;
SdrModel* mpModel;
SdrLayerID mnLayer;
Color maOldLineColor;
sal_Int32 mnLineWidth;
basegfx::B2DLineJoin maLineJoin;
css::drawing::LineCap maLineCap;
XDash maDash;
bool mbMov;
bool mbSize;
Point maOfs;
double mfScaleX;
double mfScaleY;
Fraction maScaleX;
Fraction maScaleY;
bool mbFntDirty;
// to optimize (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> two-in-one
bool mbLastObjWasPolyWithoutLine;
bool mbNoLine;
bool mbNoFill;
// to optimize multiple lines into a Polyline
bool mbLastObjWasLine;
// clipregion
basegfx::B2DPolyPolygon maClip;
FPDF_DOCUMENT mpPdfDocument;
int mnPageCount;
// check for clip and evtl. fill maClip
void checkClip();
bool isClip() const;
void ImportText(const Point& rPos, const OUString& rStr);
void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
void InsertObj(SdrObject* pObj, bool bScale = true);
void MapScaling();
// #i73407# reformulation to use new B2DPolygon classes
bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
void DoLoopActions(SvdProgressInfo* pProgrInfo, sal_uInt32* pActionsToReport);
// Copy assignment is forbidden and not implemented.
ImpSdrPdfImport(const ImpSdrPdfImport&) = delete;
ImpSdrPdfImport& operator=(const ImpSdrPdfImport&) = delete;
public:
ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& rRect,
const std::shared_ptr<css::uno::Sequence<sal_Int8>>& pPdfData);
~ImpSdrPdfImport();
int GetPageCount() const { return mnPageCount; }
size_t DoImport(SdrObjList& rDestList, size_t nInsPos, size_t nPageNumber,
SvdProgressInfo* pProgrInfo = nullptr);
};
#endif // INCLUDED_SVX_SOURCE_SVDRAW_SVDFMTF_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -195,12 +195,12 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
, mnPageNumber(-1)
, maVectorGraphicData(rImpGraphic.maVectorGraphicData)
, mpPdfData(rImpGraphic.mpPdfData)
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
, maLastUsed (std::chrono::high_resolution_clock::now())
, mbPrepared (rImpGraphic.mbPrepared)
, mnPageNumber(-1)
{
if( rImpGraphic.mpGfxLink )
mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink );
......@@ -224,12 +224,12 @@ ImpGraphic::ImpGraphic(ImpGraphic&& rImpGraphic)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbDummyContext(rImpGraphic.mbDummyContext)
, mnPageNumber(-1)
, maVectorGraphicData(std::move(rImpGraphic.maVectorGraphicData))
, mpPdfData(std::move(rImpGraphic.mpPdfData))
, maGraphicExternalLink(rImpGraphic.maGraphicExternalLink)
, maLastUsed (std::chrono::high_resolution_clock::now())
, mbPrepared (rImpGraphic.mbPrepared)
, mnPageNumber(-1)
{
rImpGraphic.ImplClear();
rImpGraphic.mbDummyContext = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment