20#ifndef INCLUDED_OOX_EXPORT_DRAWINGML_HXX
21#define INCLUDED_OOX_EXPORT_DRAWINGML_HXX
26#include <unordered_map>
30#include <com/sun/star/beans/PropertyState.hpp>
31#include <com/sun/star/uno/Any.hxx>
32#include <com/sun/star/uno/Reference.hxx>
33#include <com/sun/star/uno/Sequence.hxx>
34#include <com/sun/star/style/ParagraphAdjust.hpp>
35#include <com/sun/star/drawing/Hatch.hpp>
36#include <com/sun/star/i18n/ScriptType.hpp>
39#include <oox/token/tokens.hxx>
41#include <rtl/string.hxx>
42#include <rtl/ustring.hxx>
61 struct FontDescriptor;
71 struct EnhancedCustomShapeParameterPair;
72 struct EnhancedCustomShapeParameter;
116 virtual OUString getTransformedString(
const OUString& rURL)
const;
118 virtual bool isExternalURL(
const OUString& rURL)
const;
125 return ((21600000 - input.
get() * 600) % 21600000);
134 virtual void WriteTextBox(css::uno::Reference<css::drawing::XShape> xShape) = 0;
137 css::uno::Reference<css::drawing::XShape> xShape) = 0;
145 switch (eDocumentType)
157 switch (eDocumentType)
181 mnImageCounter.push(1);
182 maExportGraphics.emplace();
183 mnWdpImageCounter.push(1);
184 maWdpCache.emplace();
189 mnImageCounter.pop();
190 maExportGraphics.pop();
191 mnWdpImageCounter.pop();
197 return !maExportGraphics.empty();
202 maExportGraphics.top()[aChecksum] = sPath;
208 if (!hasExportGraphics())
211 auto aIterator = maExportGraphics.top().find(aChecksum);
212 if (aIterator != maExportGraphics.top().end())
213 sPath = aIterator->second;
219 sal_Int32
nCount = mnImageCounter.top();
220 mnImageCounter.top()++;
226 return !maWdpCache.empty();
234 auto aCachedItem = maWdpCache.top().find(rFileId);
235 if (aCachedItem != maWdpCache.top().end())
236 aPath = aCachedItem->second;
243 maWdpCache.top()[rFileId] = rId;
248 sal_Int32
nCount = mnWdpImageCounter.top();
249 mnWdpImageCounter.top()++;
268 OUString
writeBlip(
Graphic const& rGraphic, std::vector<model::BlipEffect>
const& rEffects,
bool bRelPathToMedia =
false);
296 bool GetProperty(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
const OUString& aName );
297 bool GetPropertyAndState(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
298 const css::uno::Reference< css::beans::XPropertyState >& rXPropState,
299 const OUString& aName, css::beans::PropertyState& eState );
300 OUString GetFieldValue(
const css::uno::Reference< css::text::XTextRange >& rRun,
bool& bIsURLField );
305 static OUString GetDatetimeTypeFromDate(
SvxDateFormat eDate);
310 static OUString GetDatetimeTypeFromTime(
SvxTimeFormat eTime);
319 void WriteMediaNonVisualProperties(
const css::uno::Reference<css::drawing::XShape>& xShape);
321 void WriteStyleProperties( sal_Int32 nTokenId,
const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
323 const char* GetComponentDir()
const;
324 const char* GetRelationCompPrefix()
const;
326 static bool EqualGradients(
const css::awt::Gradient2& rGradient1,
const css::awt::Gradient2& rGradient2 );
327 bool IsFontworkShape(
const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
329 void WriteGlowEffect(
const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
330 void WriteSoftEdgeEffect(
const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
331 void WriteCustomGeometryPoint(
const css::drawing::EnhancedCustomShapeParameterPair& rParamPair,
333 const bool bReplaceGeoWidth,
const bool bReplaceGeoHeight);
334 bool WriteCustomGeometrySegment(
335 const sal_Int16 eCommand,
const sal_Int32
nCount,
336 const css::uno::Sequence<css::drawing::EnhancedCustomShapeParameterPair>& rPairs,
337 sal_Int32& rnPairIndex,
double& rfCurrentX,
double& rfCurrentY,
bool& rbCurrentValid,
339 const bool bReplaceGeoWidth,
const bool bReplaceGeoHeight);
343 : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS(
std::move( pFS )), mpFB( pFB ), mbIsBackgroundDark( false ), mbPlaceholder(false) {}
345 const ::sax_fastparser::FSHelperPtr&
GetFS()
const {
return mpFS; }
353 OUString WriteImage(
const Graphic &rGraphic ,
bool bRelPathToMedia =
false );
356 void WriteColor(
const OUString& sColorSchemeName,
const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha =
MAX_PERCENT );
357 void WriteColor( const ::Color nColor,
const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha =
MAX_PERCENT );
358 void WriteColorTransformations(
const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha =
MAX_PERCENT );
360 void WriteLineArrow(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
bool bLineStart );
361 void WriteConnectorConnections( sal_Int32 nStartGlueId, sal_Int32 nEndGlueId, sal_Int32 nStartID, sal_Int32 nEndID );
363 bool WriteCharColor(
const css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
364 bool WriteSchemeColor(OUString
const& rPropertyName,
const css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
367 void WriteSolidFill(
const OUString& sSchemeName,
const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha =
MAX_PERCENT );
368 void WriteSolidFill( const ::Color nColor,
const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha =
MAX_PERCENT );
369 void WriteSolidFill(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
378 void WriteGradientFill(
382 void WriteGrabBagGradientFill(
const css::uno::Sequence< css::beans::PropertyValue >& aGradientStops,
const basegfx::BGradient& rGradient);
384 void WriteBlipOrNormalFill(
const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
385 const OUString& rURLPropName,
const css::awt::Size& rSize = {});
386 void WriteBlipFill(
const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
387 const OUString& sURLPropName,
const css::awt::Size& rSize = {});
388 void WriteBlipFill(
const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
389 const css::awt::Size& rSize,
const OUString& sURLPropName,
390 sal_Int32 nXmlNamespace);
392 void WriteXGraphicBlipFill(css::uno::Reference<css::beans::XPropertySet>
const & rXPropSet,
393 css::uno::Reference<css::graphic::XGraphic>
const & rxGraphic,
394 sal_Int32 nXmlNamespace,
bool bWriteMode,
395 bool bRelPathToMedia =
false, css::awt::Size
const& rSize = {});
397 void WritePattFill(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
398 void WritePattFill(
const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
399 const css::drawing::Hatch& rHatch);
401 void WriteGraphicCropProperties(css::uno::Reference<css::beans::XPropertySet>
const & rxPropertySet,
402 Size const & rOriginalSize,
MapMode const & rMapMode);
404 void WriteSrcRectXGraphic(css::uno::Reference<css::beans::XPropertySet>
const & rxPropertySet,
405 css::uno::Reference<css::graphic::XGraphic>
const & rxGraphic);
407 void WriteOutline(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
408 css::uno::Reference< css::frame::XModel>
const & xModel =
nullptr );
410 void WriteXGraphicStretch(css::uno::Reference<css::beans::XPropertySet>
const & rXPropSet,
411 css::uno::Reference<css::graphic::XGraphic>
const & rxGraphic);
413 void WriteXGraphicTile(css::uno::Reference<css::beans::XPropertySet>
const& rXPropSet,
414 css::uno::Reference<css::graphic::XGraphic>
const& rxGraphic,
415 css::awt::Size
const& rSize);
417 void WriteXGraphicCustomPosition(css::uno::Reference<css::beans::XPropertySet>
const& rXPropSet,
418 css::uno::Reference<css::graphic::XGraphic>
const& rxGraphic,
419 css::awt::Size
const& rSize);
421 void WriteLinespacing(
const css::style::LineSpacing& rLineSpacing,
float fFirstCharHeight);
423 OUString WriteXGraphicBlip(css::uno::Reference<css::beans::XPropertySet>
const & rXPropSet,
424 css::uno::Reference<css::graphic::XGraphic>
const & rxGraphic,
425 bool bRelPathToMedia);
427 void WriteImageBrightnessContrastTransparence(css::uno::Reference<css::beans::XPropertySet>
const & rXPropSet);
429 void WriteXGraphicBlipMode(css::uno::Reference<css::beans::XPropertySet>
const& rXPropSet,
430 css::uno::Reference<css::graphic::XGraphic>
const& rxGraphic,
431 css::awt::Size
const& rSize);
433 void WriteShapeTransformation(
const css::uno::Reference< css::drawing::XShape >& rXShape,
434 sal_Int32 nXmlNamespace,
bool bFlipH =
false,
bool bFlipV =
false,
bool bSuppressRotation =
false,
bool bSuppressFlipping =
false,
bool bFlippedBeforeRotation =
false);
435 void WriteTransformation(
const css::uno::Reference< css::drawing::XShape >& xShape,
const tools::Rectangle& rRectangle,
436 sal_Int32 nXmlNamespace,
bool bFlipH =
false,
bool bFlipV =
false, sal_Int32 nRotation = 0,
bool bIsGroupShape =
false);
438 void WriteText(
const css::uno::Reference< css::uno::XInterface >& rXIface,
bool bBodyPr,
bool bText =
true, sal_Int32 nXmlNamespace = 0,
bool bWritePropertiesAsLstStyles =
false);
441 void WriteLstStyles(
const css::uno::Reference<css::text::XTextContent>& rParagraph,
442 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
443 const css::uno::Reference<css::beans::XPropertySet>& rXShapePropSet);
444 void WriteParagraph(
const css::uno::Reference< css::text::XTextContent >& rParagraph,
445 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
450 bool WriteParagraphProperties(
const css::uno::Reference< css::text::XTextContent >& rParagraph,
float fFirstCharHeight, sal_Int32 nElement);
451 void WriteParagraphNumbering(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,
float fFirstCharHeight,
453 void WriteParagraphTabStops(
const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
454 void WriteRun(
const css::uno::Reference< css::text::XTextRange >& rRun,
455 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
456 const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet);
457 void WriteRunProperties(
const css::uno::Reference< css::beans::XPropertySet >& rRun,
bool bIsField, sal_Int32 nElement,
bool bCheckDirect,
458 bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
459 sal_Int16 nScriptType = css::i18n::ScriptType::LATIN,
460 const css::uno::Reference< css::beans::XPropertySet >& rXShapePropSet = {});
462 void WritePresetShape(
const OString& pShape , std::vector< std::pair<sal_Int32,sal_Int32>> & rAvList );
463 void WritePresetShape(
const OString& pShape );
464 void WritePresetShape(
const OString& pShape,
MSO_SPT eShapeType,
bool bPredefinedHandlesUsed,
const css::beans::PropertyValue& rProp );
465 bool WriteCustomGeometry(
466 const css::uno::Reference<css::drawing::XShape>& rXShape,
468 void WriteEmptyCustomGeometry();
469 void WritePolyPolygon(
const css::uno::Reference<css::drawing::XShape>& rXShape,
471 void WriteFill(
const css::uno::Reference<css::beans::XPropertySet>& xPropSet,
472 const css::awt::Size& rSize = {});
473 void WriteShapeStyle(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
474 void WriteShapeEffects(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
475 void WriteShapeEffect( std::u16string_view
sName,
const css::uno::Sequence< css::beans::PropertyValue >& aEffectProps );
480 void Write3DEffects(
const css::uno::Reference<css::beans::XPropertySet>& rXPropSet,
bool bIsText);
481 void WriteArtisticEffect(
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
482 OString WriteWdpPicture(
const OUString& rFileId,
const css::uno::Sequence< sal_Int8 >& rPictureData );
483 void WriteDiagram(
const css::uno::Reference<css::drawing::XShape>& rXShape,
int nDiagramId);
484 void writeDiagramRels(
const css::uno::Sequence<css::uno::Sequence<css::uno::Any>>& xRelSeq,
485 const css::uno::Reference<css::io::XOutputStream>& xOutStream,
486 std::u16string_view sGrabBagProperyName,
int nDiagramId);
487 static void WriteFromTo(
const css::uno::Reference<css::drawing::XShape>& rXShape,
const css::awt::Size& aPageSize,
490 static bool IsGroupShape(
const css::uno::Reference< css::drawing::XShape >& rXShape );
491 sal_Int32 getBulletMarginIndentation (
const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, std::u16string_view propName);
493 static void ResetMlCounters();
500 static sal_Int16 GetScriptType(
const OUString& rStr);
504 static ::Color ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity );
506 static const char* GetAlignment( css::style::ParagraphAdjust nAlignment );
509 const OUString& sFullStream,
510 std::u16string_view sRelativeStream,
511 const css::uno::Reference< css::io::XOutputStream >& xParentRelation,
512 const OUString& sContentType,
513 const OUString& sRelationshipType,
514 OUString* pRelationshipId );
sal_uInt64 BitmapChecksum
Interface to be implemented by the parent exporter that knows how to handle shape text.
virtual void WriteTextBox(css::uno::Reference< css::drawing::XShape > xShape)=0
Write the contents of the textbox that is associated to this shape.
virtual css::uno::Reference< css::text::XTextFrame > GetUnoTextFrame(css::uno::Reference< css::drawing::XShape > xShape)=0
Get textbox which belongs to the shape.
virtual void WriteOutliner(const OutlinerParaObject &rParaObj)=0
DrawingML(::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase *pFB, DocumentType eDocumentType=DOCUMENT_PPTX, DMLTextExport *pTextExport=nullptr)
static sal_Int32 getNewDrawingUniqueId()
::oox::core::XmlFilterBase * mpFB
bool WriteCharColor(const css::uno::Reference< css::beans::XPropertySet > &xPropertySet)
static sal_Int32 mnDrawingMLCount
static sal_Int32 mnChartCount
void WriteGradientFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
void WriteSolidFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
DMLTextExport * GetTextExport()
The application-specific text exporter callback, if there is one.
void WritePresetShape(const OString &pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, const css::beans::PropertyValue &rProp)
::sax_fastparser::FSHelperPtr mpFS
static sal_Int32 mnVmlCount
DocumentType meDocumentType
To specify where write eg. the images to (like 'ppt', or 'word' - according to the OPC).
static bool EqualGradients(const css::awt::Gradient2 &rGradient1, const css::awt::Gradient2 &rGradient2)
void SetFS(::sax_fastparser::FSHelperPtr pFS)
void WriteBlipFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet, const OUString &sURLPropName, const css::awt::Size &rSize={})
const ::sax_fastparser::FSHelperPtr & GetFS() const
::oox::core::XmlFilterBase * GetFB()
DocumentType GetDocumentType() const
void WriteColor(const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue > &aTransformations, sal_Int32 nAlpha=MAX_PERCENT)
static sal_Int32 getNewVMLUniqueId()
css::uno::Reference< css::drawing::XShape > m_xParent
If set, this is the parent of the currently handled shape.
void WriteSolidFill(const ::Color nColor, const css::uno::Sequence< css::beans::PropertyValue > &aTransformations, sal_Int32 nAlpha=MAX_PERCENT)
void WriteBlipFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet, const css::awt::Size &rSize, const OUString &sURLPropName, sal_Int32 nXmlNamespace)
void WriteColor(const OUString &sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue > &aTransformations, sal_Int32 nAlpha=MAX_PERCENT)
void WritePattFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet)
void WritePattFill(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet, const css::drawing::Hatch &rHatch)
static sal_Int32 getNewChartUniqueId()
bool mbPlaceholder
True when exporting presentation placeholder shape.
void SetBackgroundDark(bool bIsDark)
void WriteSolidFill(const OUString &sSchemeName, const css::uno::Sequence< css::beans::PropertyValue > &aTransformations, sal_Int32 nAlpha=MAX_PERCENT)
DMLTextExport * mpTextExport
Parent exporter, used for text callback.
std::stack< std::map< OUString, OUString > > maWdpCache
OUString findExportGraphics(BitmapChecksum aChecksum)
void addToWdpCache(OUString const &rFileId, OUString const &rId)
GraphicExportCache()=default
std::stack< sal_Int32 > mnWdpImageCounter
std::stack< std::unordered_map< BitmapChecksum, OUString > > maExportGraphics
sal_Int32 nextImageCount()
OUString findWdpID(OUString const &rFileId)
void addExportGraphics(BitmapChecksum aChecksum, OUString const &sPath)
std::stack< sal_Int32 > mnImageCounter
sal_Int32 nextWdpImageCount()
OUString writeBlip(Graphic const &rGraphic, std::vector< model::BlipEffect > const &rEffects, bool bRelPathToMedia=false)
DocumentType meDocumentType
sax_fastparser::FSHelperPtr mpFS
GraphicExport(sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase *pFilterBase, DocumentType eDocumentType)
oox::core::XmlFilterBase * mpFilterBase
OUString writeToStorage(Graphic const &rGraphic, bool bRelPathToMedia=false)
class SAL_NO_VTABLE XPropertySet
constexpr const char * getComponentDir(DocumentType eDocumentType)
sal_Int32 ExportRotateClockwisify(Degree100 input)
constexpr const char * getRelationCompPrefix(DocumentType eDocumentType)
const sal_Int32 MAX_PERCENT
std::shared_ptr< FastSerializerHelper > FSHelperPtr
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
UNOTOOLS_DLLPUBLIC css::uno::Any GetProperty(OUString const &url, OUString const &property)
UNDERLYING_TYPE get() const