73#include <osl/diagnose.h>
85 , maDash(css::
drawing::DashStyle_RECT, 0, 0, 0, 0, 0)
94 , mbLastObjWasPolyWithoutLine(false)
99 , mpPDFium(
vcl::pdf::PDFiumLibrary::
get())
101 mpVD->EnableOutput(
false);
102 mpVD->SetLineColor();
103 mpVD->SetFillColor();
105 mpLineAttr = std::make_unique<SfxItemSetFixed<XATTR_LINE_FIRST, XATTR_LINE_LAST>>(
107 mpFillAttr = std::make_unique<SfxItemSetFixed<XATTR_FILL_FIRST, XATTR_FILL_LAST>>(
110 = std::make_unique<SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END>>(rModel.
GetItemPool());
116 auto*
pData = rVectorGraphicData->getBinaryDataContainer().getData();
117 sal_Int32 nSize = rVectorGraphicData->getBinaryDataContainer().getSize();
131 if (!(nPageCount > 0 && nPageIndex >= 0 && nPageIndex < nPageCount))
144 auto pTextPage = pPdfPage->getTextPage();
146 const int nPageObjectCount = pPdfPage->getObjectCount();
150 for (
int nPageObjectIndex = 0; nPageObjectIndex < nPageObjectCount; ++nPageObjectIndex)
152 auto pPageObject = pPdfPage->getObject(nPageObjectIndex);
154 if (pProgrInfo && pActionsToReport)
156 (*pActionsToReport)++;
158 if (*pActionsToReport >= 16)
163 *pActionsToReport = 0;
185 /
static_cast<double>(aPageSize.
Width());
191 /
static_cast<double>(aPageSize.
Height());
216 sal_uInt32 nActionsToReport(0);
219 DoObjects(pProgrInfo, &nActionsToReport, nPageNumber);
224 nActionsToReport = 0;
242 nActionsToReport = 0;
256 if (nActionsToReport >= 32)
259 nActionsToReport = 0;
277 bool bLine(!bForceTextAttr);
278 bool bFill(!pObj || (pObj->
IsClosedObj() && !bForceTextAttr));
294 if (
mpVD->IsLineColor())
327 if (
mpVD->IsFillColor())
417 const SfxItemSet aOldItemSet(pObj->GetMergedItemSet());
421 if (pSdrTextObj && pSdrTextObj->
HasText())
432 if (!aClipRange.
overlaps(aTextRange))
462 OSL_ENSURE(pCandidate &&
dynamic_cast<SdrObjGroup*
>(pCandidate) ==
nullptr,
463 "SdrObjListIter with SdrIterMode::DeepNoGroups error (!)");
473 OSL_ENSURE(
false,
"SdrObject::Clone() failed (!)");
505 pObj->SetLayer(aOldLayer);
506 pObj->SetMergedItemSet(aOldItemSet);
513 const double fScaleY(
520 aTrans.
scale(fScaleX, fScaleY);
524 const Point aClipTopLeft(
527 const Size aClipSize(
529 static_cast<double>(aOrigSizePixel.
Width()), aPixel.
getWidth()))),
531 ceil(std::min(
static_cast<double>(aOrigSizePixel.
Height()),
533 const BitmapEx aClippedBitmap(aBitmapEx, aClipTopLeft, aClipSize);
552 if (pObj->HasLineStyle())
557 if (!
bVisible && pObj->HasFillStyle())
566 if (pTextObj && pTextObj->
HasText())
591 const bool bClosed(pObj->IsClosedObj());
631 if (
mpVD->IsClipRegion())
633 maClip =
mpVD->GetClipRegion().GetAsB2DPolyPolygon();
647 std::unique_ptr<vcl::pdf::PDFiumPageObject>
const& pPageObject,
648 std::unique_ptr<vcl::pdf::PDFiumTextPage>
const& pTextPage,
int nPageObjectIndex)
654 switch (ePageObjectType)
657 ImportText(pPageObject, pTextPage, nPageObjectIndex);
666 SAL_WARN(
"sd.filter",
"Got page object SHADING: " << nPageObjectIndex);
669 ImportForm(pPageObject, pTextPage, nPageObjectIndex);
672 SAL_WARN(
"sd.filter",
"Unknown PDF page object #" << nPageObjectIndex <<
" of type: "
673 <<
static_cast<int>(ePageObjectType));
679 std::unique_ptr<vcl::pdf::PDFiumTextPage>
const& pTextPage,
687 const int nCount = pPageObject->getFormObjectCount();
690 auto pFormObject = pPageObject->getFormObject(
nIndex);
700 std::unique_ptr<vcl::pdf::PDFiumTextPage>
const& pTextPage,
708 aTextRect *= aTextMatrix;
712 OUString sText = pPageObject->getText(pTextPage);
714 const double dFontSize = pPageObject->getFontSize();
715 double dFontSizeH = fabs(std::hypot(aMatrix.
a(), aMatrix.
c()) * dFontSize);
716 double dFontSizeV = fabs(std::hypot(aMatrix.
b(), aMatrix.
d()) * dFontSize);
721 const Size aFontSize(dFontSizeH, dFontSizeV);
730 OUString sFontName = pPageObject->getFontName();
731 if (!sFontName.isEmpty() && sFontName != aFnt.
GetFamilyName())
741 switch (pPageObject->getTextRenderMode())
760 Color aColor = bFill ? pPageObject->getFillColor() : pPageObject->getStrokeColor();
765 if (aTextColor !=
mpVD->GetTextColor())
767 mpVD->SetTextColor(aTextColor);
783 sal_Int32 nTextHeight =
static_cast<sal_Int32
>(
mpVD->GetTextHeight() *
mfScaleY);
792 aPosition.
AdjustY(-nTextHeight);
815 pText->NbcSetText(rStr);
817 pText->SetSnapRect(aTextRect);
824 pText->SetMergedItemSet(aAttr);
828 pText->SdrAttrObj::NbcRotate(aPosition, nAngle);
837 bool bMov2(aMapOrg.
X() != 0 || aMapOrg.
Y() != 0);
855 std::unique_ptr<vcl::pdf::PDFiumBitmap> bitmap = pPageObject->getImageBitmap();
858 SAL_WARN(
"sd.filter",
"Failed to get IMAGE");
865 SAL_WARN(
"sd.filter",
"Failed to get IMAGE format");
869 const unsigned char* pBuf = bitmap->getBuffer();
870 const int nWidth = bitmap->getWidth();
871 const int nHeight = bitmap->getHeight();
872 const int nStride = bitmap->getStride();
878 ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N24BitTcBgr, nHeight, nStride);
881 ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcRgba, nHeight, nStride);
884 ReadRawDIB(aBitmap, pBuf, ScanlineFormat::N32BitTcBgra, nHeight, nStride);
887 SAL_WARN(
"sd.filter",
"Got IMAGE width: " << nWidth <<
", height: " << nHeight
888 <<
", stride: " << nStride
889 <<
", format: " <<
static_cast<int>(format));
915 auto aPathMatrix = pPageObject->getMatrix();
921 std::vector<basegfx::B2DPoint> aBezier;
923 const int nSegments = pPageObject->getPathSegmentCount();
924 for (
int nSegmentIndex = 0; nSegmentIndex < nSegments; ++nSegmentIndex)
926 auto pPathSegment = pPageObject->getPathSegment(nSegmentIndex);
927 if (pPathSegment !=
nullptr)
930 aB2DPoint *= aPathMatrix;
932 const bool bClose = pPathSegment->isClosed();
937 aB2DPoint.
setX(aPoint.
X());
938 aB2DPoint.
setY(aPoint.
Y());
941 switch (eSegmentType)
948 aBezier.emplace_back(aB2DPoint.
getX(), aB2DPoint.
getY());
949 if (aBezier.size() == 3)
958 if (aPoly.
count() > 0)
960 aPolyPoly.
append(aPoly, 1);
969 SAL_WARN(
"sd.filter",
"Unknown path segment type in PDF: "
970 <<
static_cast<int>(eSegmentType));
976 if (aBezier.size() == 3)
982 if (aPoly.
count() > 0)
984 aPolyPoly.
append(aPoly, 1);
992 float fWidth = pPageObject->getStrokeWidth();
993 const double dWidth = 0.5 * fabs(std::hypot(aPathMatrix.a(), aPathMatrix.c()) * fWidth);
998 if (pPageObject->getDrawMode(nFillMode, bStroke))
1001 mpVD->SetDrawMode(DrawModeFlags::Default);
1003 mpVD->SetDrawMode(DrawModeFlags::Default);
1005 mpVD->SetDrawMode(DrawModeFlags::NoFill);
1008 mpVD->SetFillColor(pPageObject->getFillColor());
1012 mpVD->SetLineColor(pPageObject->getStrokeColor());
1035 double bottom)
const
constexpr auto convertPointToMm100(N n)
const Size & GetSizePixel() const
Color GetRGBColor() const
void SetRed(sal_uInt8 nRed)
tools::Long GetAscent() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
const std::shared_ptr< VectorGraphicData > & getVectorGraphicData() const
std::unique_ptr< SfxItemSet > mpFillAttr
void ImportText(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, std::unique_ptr< vcl::pdf::PDFiumTextPage > const &pTextPage, int nPageObjectIndex)
std::unique_ptr< SfxItemSet > mpTextAttr
std::unique_ptr< vcl::pdf::PDFiumDocument > mpPdfDocument
ImpSdrPdfImport(const ImpSdrPdfImport &)=delete
tools::Rectangle PointsToLogic(double left, double right, double top, double bottom) const
Convert PDF points to logic (twips).
void ImportPath(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, int nPageObjectIndex)
void InsertObj(SdrObject *pObj, bool bScale=true)
void InsertTextObject(const Point &rPos, const Size &rSize, const OUString &rStr)
std::unique_ptr< SfxItemSet > mpLineAttr
ScopedVclPtr< VirtualDevice > mpVD
bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon &rPolyPolygon)
void ImportPdfObject(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, std::unique_ptr< vcl::pdf::PDFiumTextPage > const &pTextPage, int nPageObjectIndex)
void DoObjects(SvdProgressInfo *pProgrInfo, sal_uInt32 *pActionsToReport, int nPageIndex)
size_t DoImport(SdrObjList &rDestList, size_t nInsPos, int nPageNumber, SvdProgressInfo *pProgrInfo=nullptr)
void SetAttributes(SdrObject *pObj, bool bForceTextAttr=false)
bool mbLastObjWasPolyWithoutLine
void ImportForm(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, std::unique_ptr< vcl::pdf::PDFiumTextPage > const &pTextPage, int nPageObjectIndex)
basegfx::B2DHomMatrix maCurrentMatrix
The current transformation matrix, typically used with Form objects.
void SetupPageScale(const double dPageWidth, const double dPageHeight)
double correctVertOrigin(double offsetPts) const
Correct the vertical coordinate to start at the top.
static constexpr css::drawing::LineCap gaLineCap
std::vector< rtl::Reference< SdrObject > > maTmpList
tools::Rectangle maScaleRect
std::shared_ptr< vcl::pdf::PDFium > mpPDFium
void ImportImage(std::unique_ptr< vcl::pdf::PDFiumPageObject > const &pPageObject, int nPageObjectIndex)
basegfx::B2DPolyPolygon maClip
const Point & GetOrigin() const
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long X() const
This class represents an embedded or linked bitmap graphic object.
const Graphic & GetGraphic() const
const SfxItemPool & GetItemPool() const
size_t GetObjCount() const
virtual void NbcInsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
virtual OutlinerParaObject * GetOutlinerParaObject() const
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
rtl::Reference< SdrObject > ConvertToPolyObj(bool bBezier, bool bLineToArea) const
SdrModel & getSdrModelFromSdrObject() const
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const =0
void SetMergedItem(const SfxPoolItem &rItem)
virtual void SetLayer(SdrLayerID nLayer)
virtual void NbcMove(const Size &rSiz)
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
const basegfx::B2DPolyPolygon & GetPathPoly() const
Rectangle objects (rectangle, circle, ...)
virtual basegfx::B2DPolyPolygon TakeContour() const override
contour for TextToContour
virtual bool HasText() const override
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
Helper class for the communication between the dialog In order to break open Metafiles (sd/source/ui/...
void ReportInserts(size_t nInsertCount)
void SetActionCount(size_t _nActionCount)
bool ReportActions(size_t nActionCount)
void SetInsertCount(size_t _nInsertCount)
void ReportRescales(size_t nRescaleCount)
double GetDashLen() const
double GetDistance() const
sal_uInt16 GetDots() const
sal_uInt16 GetDashes() const
void translate(double fX, double fY)
void scale(double fX, double fY)
void append(const B2DPolygon &rPolygon, sal_uInt32 nCount=1)
void transform(const basegfx::B2DHomMatrix &rMatrix)
B2DRange getB2DRange() const
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void setClosed(bool bNew)
void appendBezierSegment(const basegfx::B2DPoint &rNextControlPoint, const basegfx::B2DPoint &rPrevControlPoint, const basegfx::B2DPoint &rPoint)
BASEGFX_DLLPUBLIC void transform(const B2DHomMatrix &rMatrix)
bool isInside(const Tuple2D< TYPE > &rTuple) const
bool overlaps(const Range2D &rRange) const
void SetFontSize(const Size &)
FontFamily GetFamilyType()
const OUString & GetStyleName() const
FontStrikeout GetStrikeout() const
FontLineStyle GetOverline() const
bool IsTransparent() const
const OUString & GetFamilyName() const
TextAlign GetAlignment() const
const Size & GetFontSize() const
void SetFamilyName(const OUString &rFamilyName)
FontLineStyle GetUnderline() const
rtl_TextEncoding GetCharSet() const
bool IsWordLineMode() const
Degree10 GetOrientation() const
const Color & GetFillColor() const
tools::Long GetAverageFontWidth() const
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
constexpr TypedWhichId< SvxCharScaleWidthItem > EE_CHAR_FONTWIDTH(EE_CHAR_START+3)
constexpr TypedWhichId< SvxWordLineModeItem > EE_CHAR_WLM(EE_CHAR_START+13)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
tools::Long FRound(double fVal)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
B2DHomMatrix createScaleTranslateB2DHomMatrix(double fScaleX, double fScaleY, double fTranslateX, double fTranslateY)
bool isRectangle(const B2DPolygon &rPoly)
B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon &rCandidate, const B2DPolyPolygon &rClip, bool bInside, bool bStroke, size_t *pPointLimit)
B2IRange fround(const B2DRange &rRange)
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
SdrMetricItem makeSdrTextUpperDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextRightDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextLowerDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextLeftDistItem(tools::Long mnHeight)
constexpr TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_AUTOGROWWIDTH(SDRATTR_MISC_FIRST+12)
SdrTextObj * DynCastSdrTextObj(SdrObject *pObj)
@ Text
closed free-hand line
@ PolyLine
polygon, PolyPolygon