45 css::uno::Reference< css::uno::XComponentContext >
const & xContext) :
51 m_pCurElement(nullptr),
56 m_xStatusIndicator( xStat )
80 GraphicsContextStack::value_type
const a(
m_aGCStack.back());
121 SAL_WARN(
"sdext.pdfimport",
"PDFIProcessor::setMiterLimit(): not supported by ODF");
158 FontToIdMap::const_iterator it =
m_aFontToId.find( aChangedFont );
195 double spaceDetectBoundary = 0.0;
200 OUString& glyph =
i.getGlyph();
203 if (!glyph.isEmpty())
206 if ((
ch == 0x20) || (
ch == 0xa0))
208 double spaceWidth =
i.getWidth();
209 spaceDetectBoundary = spaceWidth * 0.5;
215 if (spaceDetectBoundary == 0.0)
217 double avgGlyphWidth = 0.0;
219 avgGlyphWidth +=
i.getWidth();
221 spaceDetectBoundary = avgGlyphWidth * 0.2;
234 bool prependSpace =
false;
251 prependSpace = spaceSize > spaceDetectBoundary;
254 text->Text.append(
" ");
262 const geometry::RealRectangle2D& rRect,
263 const geometry::Matrix2D& rFontMatrix,
269 rFontMatrix.m00, rFontMatrix.m01, 0.0,
270 rFontMatrix.m10, rFontMatrix.m11, 0.0);
271 fontMatrix.
scale(fontSize, fontSize);
275 totalTextMatrix1.
translate(rRect.X1, rRect.Y1);
276 totalTextMatrix2.
translate(rRect.X2, rRect.Y2);
279 corrMatrix.
scale(1.0, -1.0);
281 totalTextMatrix1 = totalTextMatrix1 * corrMatrix;
282 totalTextMatrix2 = totalTextMatrix2 * corrMatrix;
293 offsetMatrix1 *= invPrevMatrix;
294 offsetMatrix2 *= invMatrix;
296 double charWidth = offsetMatrix2.
get(0, 2);
303 (offsetMatrix1.
get(0, 2) < 0.0) ||
330 double fRotate, fShearX;
333 const sal_Int32 nGCId =
getGCId(rGC);
336 pFrame->
x = pImageElement->
x = aTranslation.
getX();
337 pFrame->
y = pImageElement->
y = aTranslation.
getY();
338 pFrame->
w = pImageElement->
w = aScale.
getX();
339 pFrame->
h = pImageElement->
h = aScale.
getY();
363 const uno::Sequence<uno::Any>& )
370 const uno::Sequence<beans::PropertyValue>& ,
378 const uno::Sequence<beans::PropertyValue>& )
435 if( aCurClip.
count() )
448 if( aCurClip.
count() )
455 const OUString& rURI )
457 if( !rURI.isEmpty() )
462 pLink->x = rBounds.X1;
463 pLink->y = rBounds.Y1;
464 pLink->w = rBounds.X2-rBounds.X1;
465 pLink->h = rBounds.Y2-rBounds.Y1;
471 IdToFontMap::const_iterator it =
m_aIdToFont.find( nFontId );
522 if( nNextPageNr == 1 )
538#if OSL_DEBUG_LEVEL > 0
546 m_pDocument->visitedBy( *optimizingVisitor, std::list<std::unique_ptr<Element>>::const_iterator());
548#if OSL_DEBUG_LEVEL > 0
558 m_pDocument->visitedBy( *finalizingVisitor, std::list<std::unique_ptr<Element>>::const_iterator() );
566 #define OASIS_STR "urn:oasis:names:tc:opendocument:xmlns:"
567 aProps[
"xmlns:office" ] =
OASIS_STR "office:1.0" ;
568 aProps[
"xmlns:style" ] =
OASIS_STR "style:1.0" ;
569 aProps[
"xmlns:text" ] =
OASIS_STR "text:1.0" ;
570 aProps[
"xmlns:svg" ] =
OASIS_STR "svg-compatible:1.0" ;
571 aProps[
"xmlns:table" ] =
OASIS_STR "table:1.0" ;
572 aProps[
"xmlns:draw" ] =
OASIS_STR "drawing:1.0" ;
573 aProps[
"xmlns:fo" ] =
OASIS_STR "xsl-fo-compatible:1.0" ;
574 aProps[
"xmlns:xlink"] =
"http://www.w3.org/1999/xlink";
575 aProps[
"xmlns:dc"] =
"http://purl.org/dc/elements/1.1/";
576 aProps[
"xmlns:number"] =
OASIS_STR "datastyle:1.0" ;
577 aProps[
"xmlns:presentation"] =
OASIS_STR "presentation:1.0" ;
578 aProps[
"xmlns:math"] =
"http://www.w3.org/1998/Math/MathML";
579 aProps[
"xmlns:form"] =
OASIS_STR "form:1.0" ;
580 aProps[
"xmlns:script"] =
OASIS_STR "script:1.0" ;
581 aProps[
"xmlns:dom"] =
"http://www.w3.org/2001/xml-events";
582 aProps[
"xmlns:xforms"] =
"http://www.w3.org/2002/xforms";
583 aProps[
"xmlns:xsd"] =
"http://www.w3.org/2001/XMLSchema";
584 aProps[
"xmlns:xsi"] =
"http://www.w3.org/2001/XMLSchema-instance";
585 aProps[
"office:version" ] =
"1.0";
590 aStyles.
emit( aContext, *aEmittingVisitor );
592 m_pDocument->visitedBy( *aEmittingVisitor, std::list<std::unique_ptr<Element>>::const_iterator() );
603 sal_Int32
nLength = rText.getLength();
617 aStr.append( pText[
i] );
628static bool lr_tb_sort( std::unique_ptr<Element>
const & pLeft, std::unique_ptr<Element>
const & pRight )
639 double fudge_factor_left = 0.0, fudge_factor_right = 0.0;
640 if( pLeft->dynCastAsTextElement() )
641 fudge_factor_left = 0.1;
642 if( pRight->dynCastAsTextElement() )
643 fudge_factor_right = 0.1;
646 double lower_boundary_left = pLeft->y + std::max(pLeft->h, 0.0) - fabs(pLeft->h) * fudge_factor_left;
647 double lower_boundary_right = pRight->y + std::max(pRight->h, 0.0) - fabs(pRight->h) * fudge_factor_right;
648 double upper_boundary_left = pLeft->y + std::min(pLeft->h, 0.0);
649 double upper_boundary_right = pRight->y + std::min(pRight->h, 0.0);
652 if( lower_boundary_left < upper_boundary_right )
656 if( lower_boundary_right < upper_boundary_left )
660 double left_boundary_left = pLeft->y + std::min(pLeft->w, 0.0);
661 double left_boundary_right = pRight->y + std::min(pRight->w, 0.0);
662 double right_boundary_left = pLeft->y + std::max(pLeft->w, 0.0);
663 double right_boundary_right = pRight->y + std::max(pRight->w, 0.0);
669 if( right_boundary_left < left_boundary_right )
673 if( right_boundary_right < left_boundary_left )
678 if( pLeft->x < pRight->x )
680 if( pRight->x < pLeft->x )
682 if( pLeft->y < pRight->y )
703 const sal_Int32 nLen = rString.getLength();
704 OUStringBuffer aMirror(nLen);
706 for (sal_Int32
i = 0;
i < nLen;) {
707 const sal_uInt32 nCodePoint = rString.iterateCodePoints(&
i);
710 return aMirror.makeStringAndClear();
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void translate(double fX, double fY)
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
void scale(double fX, double fY)
void transform(const basegfx::B2DHomMatrix &rMatrix)
GraphicsContext & getGC()
static ParagraphElement * createParagraphElement(Element *pParent)
static FrameElement * createFrameElement(Element *pParent, sal_Int32 nGCId)
static PageElement * createPageElement(Element *pParent, sal_Int32 nPageNr)
static PolyPolyElement * createPolyPolyElement(Element *pParent, sal_Int32 nGCId, const basegfx::B2DPolyPolygon &rPolyPoly, sal_Int8 nAction)
static TextElement * createTextElement(Element *pParent, sal_Int32 nGCId, sal_Int32 nFontId)
static ImageElement * createImageElement(Element *pParent, sal_Int32 nGCId, ImageId nImage)
static HyperlinkElement * createHyperlinkElement(Element *pParent, const OUString &rURI)
ImageId addImage(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap)
Main entry from the parser.
void startIndicator(const OUString &rText)
std::vector< CharGlyph > m_GlyphsList
virtual void setLineWidth(double) override
virtual void drawColorMaskedImage(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap, const css::uno::Sequence< css::uno::Any > &xMaskColors) override
Given image must already be color-mapped and normalized to sRGB.
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual void setFlatness(double) override
virtual void setTransformation(const css::geometry::AffineMatrix2D &rMatrix) override
virtual void setMiterLimit(double) override
const GraphicsContext & getGraphicsContext(sal_Int32 nGCId) const
virtual void intersectClip(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath) override
virtual void setLineDash(const css::uno::Sequence< double > &dashes, double start) override
virtual void popState() override
virtual void hyperLink(const css::geometry::RealRectangle2D &rBounds, const OUString &rURI) override
basegfx::B2DHomMatrix prevTextMatrix
const FontAttributes & getFont(sal_Int32 nFontId) const
virtual void setPageNum(sal_Int32 nNumPages) override
Total number of pages for upcoming document.
virtual void strokePath(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath) override
sal_Int32 getFontId(const FontAttributes &rAttr) const
virtual void setLineCap(sal_Int8) override
virtual void pushState() override
void setupImage(ImageId nImage)
static void sortElements(Element *pElement)
PDFIProcessor(const css::uno::Reference< css::task::XStatusIndicator > &xStat, css::uno::Reference< css::uno::XComponentContext > const &xContext)
virtual void endPage() override
virtual void intersectEoClip(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath) override
virtual void drawMask(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap, bool bInvert) override
draws given bitmap as a mask (using current fill color)
virtual void setStrokeColor(const css::rendering::ARGBColor &rColor) override
virtual void drawMaskedImage(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap, const css::uno::Sequence< css::beans::PropertyValue > &xMask, bool bInvertMask) override
static OUString SubstituteBidiMirrored(const OUString &rString)
GraphicsContext & getCurrentContext()
virtual void setLineJoin(sal_Int8) override
virtual void setFillColor(const css::rendering::ARGBColor &rColor) override
GraphicsContextStack m_aGCStack
std::shared_ptr< DocumentElement > m_pDocument
virtual void setTextRenderMode(sal_Int32) override
virtual void eoFillPath(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath) override
sal_Int32 getGCId(const GraphicsContext &rGC)
virtual void drawGlyphs(const OUString &rGlyphs, const css::geometry::RealRectangle2D &rRect, const css::geometry::Matrix2D &rFontMatrix, double fontSize) override
virtual void drawAlphaMaskedImage(const css::uno::Sequence< css::beans::PropertyValue > &xImage, const css::uno::Sequence< css::beans::PropertyValue > &xMask) override
css::uno::Reference< css::task::XStatusIndicator > m_xStatusIndicator
virtual void startPage(const css::geometry::RealSize2D &rSize) override
virtual void endText() override
issued when a sequence of associated glyphs is drawn
virtual void setFont(const FontAttributes &rFont) override
virtual void drawImage(const css::uno::Sequence< css::beans::PropertyValue > &xBitmap) override
Given image must already be color-mapped and normalized to sRGB.
virtual void fillPath(const css::uno::Reference< css::rendering::XPolyPolygon2D > &rPath) override
void emit(XmlEmitter &rEmitter, const TreeVisitorFactory &rVisitorFactory)
void emit(EmitContext &rContext, ElementTreeVisitor &rContainedElemVisitor)
virtual void endTag(const char *pTag)=0
Close previously opened tag.
virtual void beginTag(const char *pTag, const PropertyMap &rProperties)=0
Open up a tag with the given properties.
static sal_uInt32 GetMirroredChar(sal_uInt32)
#define SAL_WARN(area, stream)
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
B2DPolyPolygon clipPolyPolygonOnPolyPolygon(const B2DPolyPolygon &rCandidate, const B2DPolyPolygon &rClip, bool bInside, bool bStroke, size_t *pPointLimit)
DstType sequenceToContainer(const css::uno::Sequence< SrcType > &i_Sequence)
std::shared_ptr< ElementTreeVisitor > ElementTreeVisitorSharedPtr
std::unordered_map< OUString, OUString > PropertyMap
static bool lr_tb_sort(std::unique_ptr< Element > const &pLeft, std::unique_ptr< Element > const &pRight)
#define PDFI_OUTDEV_RESOLUTION
virtual const TextElement * dynCastAsTextElement() const
To avoid some dynamic_cast cost.
std::list< std::unique_ptr< Element > > Children
void updateGeometryWith(const Element *pMergeFrom)
Union element geometry with given element.
css::rendering::ARGBColor FillColor
css::rendering::ARGBColor LineColor
basegfx::B2DHomMatrix Transformation
std::vector< double > DashArray
basegfx::B2DPolyPolygon Clip
Tree manipulation factory.
virtual std::shared_ptr< ElementTreeVisitor > createOptimizingVisitor(PDFIProcessor &) const =0
Create visitor that combines tree nodes.
virtual std::shared_ptr< ElementTreeVisitor > createStyleCollectingVisitor(StyleContainer &, PDFIProcessor &) const =0
Create visitor that prepares style info.
virtual std::shared_ptr< ElementTreeVisitor > createEmittingVisitor(EmitContext &) const =0
Create visitor that emits tree to an output target.
const uno::Reference< uno::XComponentContext > m_xContext