22#include <rtl/ustrbuf.hxx>
29#include <com/sun/star/beans/XPropertyState.hpp>
30#include <com/sun/star/drawing/FillStyle.hpp>
31#include <com/sun/star/drawing/LineStyle.hpp>
34#include <unordered_set>
49 if(!rShapePtr && bCreateOnDemand)
51 const_cast<ShapePtr&
>(rShapePtr) = std::make_shared<Shape>();
58 return rShapePtr.get();
69 TextBodyPtr aNewTextBody(std::make_shared<TextBody>());
71 TextRunPtr pTextRun = std::make_shared<TextRun>();
72 pTextRun->getText() = rPoint.
msTextBody->msText;
73 aNewTextBody->addParagraph().addRun(pTextRun);
77 oox::PropertyMap& rTargetMap(aNewTextBody->getTextProperties().maPropertyMap);
79 for (
auto const& prop : rPoint.
msTextBody->maTextProps)
90 const css::uno::Reference< css::beans::XPropertySetInfo >& xInfo,
91 std::vector< std::pair< OUString, css::uno::Any >>& rTarget,
92 const css::uno::Reference< css::beans::XPropertySet >& xPropSet )
94 if(xInfo->hasPropertyByName(rName))
95 rTarget.push_back(std::pair(OUString(rName), xPropSet->getPropertyValue(rName)));
100 const std::vector< ShapePtr >& rChildren(rShape.
getChildren());
102 if(!rChildren.empty())
105 for (
auto& child : rChildren)
115 const css::uno::Reference< css::drawing::XShape > &rXShape(rShape.
getXShape());
127 if(bIsBackgroundShape)
142 pTarget =
point.msPointStylePtr.get();
151 if(
nullptr == pTarget)
157 const css::uno::Reference< css::beans::XPropertyState > xAllPropStates(rXShape, css::uno::UNO_QUERY);
158 const css::uno::Reference< css::beans::XPropertySet > xAllPropSet( rXShape, css::uno::UNO_QUERY );
159 const css::uno::Sequence< css::beans::Property > allSequence(xAllPropSet->getPropertySetInfo()->getProperties());
160 std::vector< std::pair< OUString, css::uno::Any >> allSetProps;
161 for (
auto& rProp : allSequence)
165 if (xAllPropStates->getPropertyState(rProp.Name) == css::beans::PropertyState::PropertyState_DIRECT_VALUE)
167 css::uno::Any aValue(xAllPropSet->getPropertyValue(rProp.Name));
168 if(aValue.hasValue())
169 allSetProps.push_back(std::pair(rProp.Name, aValue));
178 const css::uno::Reference< css::beans::XPropertySet > xPropSet( rXShape, css::uno::UNO_QUERY );
182 const css::uno::Reference< css::lang::XServiceInfo > xServiceInfo( rXShape, css::uno::UNO_QUERY );
186 const css::uno::Reference< css::beans::XPropertySetInfo > xInfo(xPropSet->getPropertySetInfo());
209 if(!bIsBackgroundShape
210 && xServiceInfo->supportsService(
"com.sun.star.drawing.TextProperties"))
219 if(xServiceInfo->supportsService(
"com.sun.star.drawing.FillProperties"))
221 css::drawing::FillStyle eFillStyle(css::drawing::FillStyle_NONE);
225 if(css::drawing::FillStyle_NONE != eFillStyle)
231 case css::drawing::FillStyle_SOLID:
237 case css::drawing::FillStyle_NONE:
238 case css::drawing::FillStyle_GRADIENT:
239 case css::drawing::FillStyle_HATCH:
240 case css::drawing::FillStyle_BITMAP:
247 if(!bIsBackgroundShape
248 && xServiceInfo->supportsService(
"com.sun.star.drawing.LineProperties"))
250 css::drawing::LineStyle eLineStyle(css::drawing::LineStyle_NONE);
254 if(css::drawing::LineStyle_NONE != eLineStyle)
262 case css::drawing::LineStyle_SOLID:
265 case css::drawing::LineStyle_NONE:
266 case css::drawing::LineStyle_DASH:
275 const std::vector< ShapePtr >& rChildren(rRootShape.
getChildren());
277 for (
auto& child : rChildren)
291 if(
nullptr != pShapeCandidate)
297 const uno::Sequence< beans::PropertyValue > aTextProps(
298 pShapeCandidate->
getTextBody()->getTextProperties().maPropertyMap.makePropertyValueSequence());
300 for (
auto const& prop : aTextProps)
301 point.msTextBody->maTextProps.push_back(std::pair(prop.Name, prop.Value));
311 ShapePtr aNew(std::make_shared<Shape>());
328 const std::vector< ShapePtr >& rChildren(rShape.
getChildren());
330 if(!rChildren.empty())
333 for (
auto& child : rChildren)
343 const css::uno::Reference< css::drawing::XShape > &rXShape(rShape.
getXShape());
368 pSource =
point.msPointStylePtr.get();
377 if(
nullptr == pSource)
381 css::uno::Reference<css::beans::XPropertySet> xPropSet(rXShape, css::uno::UNO_QUERY);
388 xPropSet->setPropertyValue(prop.first, prop.second);
394 const std::vector< ShapePtr >& rChildren(rRootShape.
getChildren());
396 for (
auto& child : rChildren)
416 "cnx modelId " << rConnection.
msModelId <<
", srcId " << rConnection.
msSourceId <<
", dstId "
426 "pt text " << pShape <<
", cnxId " << rPoint.
msCnxId <<
", modelId "
436 SAL_INFO(
"oox.drawingml",
"Dgm: DiagramData # of pt: " <<
maPoints.size() );
457 for (
auto &
point : rPoints)
A helper that maps property identifiers to property values.
bool setAnyProperty(sal_Int32 nPropId, const css::uno::Any &rValue)
Sets the specified property to the passed value.
static sal_Int32 getPropertyId(std::u16string_view sPropName)
Returns the property identifier of the passed name.
virtual void dump() const
void secureDataFromShapeToModelAfterDiagramImport(::oox::drawingml::Shape &rRootShape)
void restoreDataFromShapeToModelAfterDiagramImport(::oox::drawingml::Shape &rRootShape)
static void restoreDataFromModelToShapeAfterReCreation(const svx::diagram::Point &rPoint, Shape &rNewShape)
void restoreStyleDataFromShapeToModel(::oox::drawingml::Shape &rShape)
PointShapeMap maPointShapeMap
Shape * getOrCreateAssociatedShape(const svx::diagram::Point &rPoint, bool bCreateOnDemand=false) const
virtual void buildDiagramDataModel(bool bClearOoxShapes)
void secureStyleDataFromShapeToModel(::oox::drawingml::Shape &rShape)
std::vector< ShapePtr > & getChildren()
const OUString & getDiagramDataModelID() const
const css::uno::Reference< css::drawing::XShape > & getXShape() const
const TextBodyPtr & getTextBody() const
void setTextBody(const TextBodyPtr &pTextBody)
PointStylePtr maBackgroundShapeStyle
virtual void buildDiagramDataModel(bool bClearOoxShapes)
OUString msBackgroundShapeModelID
Connections maConnections
#define SAL_INFO(area, stream)
std::shared_ptr< T > make_shared(Args &&... args)
static void Connection_dump(const svx::diagram::Connection &rConnection)
std::shared_ptr< Shape > ShapePtr
std::shared_ptr< TextRun > TextRunPtr
static void addProperty(const OUString &rName, const css::uno::Reference< css::beans::XPropertySetInfo > &xInfo, std::vector< std::pair< OUString, css::uno::Any > > &rTarget, const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
static void Point_dump(const svx::diagram::Point &rPoint, const Shape *pShape)
std::shared_ptr< TextBody > TextBodyPtr
std::vector< Point > Points
std::vector< std::pair< OUString, css::uno::Any > > maProperties
constexpr OUStringLiteral UNO_NAME_FILLCOLOR
constexpr OUStringLiteral UNO_NAME_CHAR_SHADOWED
constexpr OUStringLiteral UNO_NAME_LINESTYLE
constexpr OUStringLiteral UNO_NAME_LINEWIDTH
constexpr OUStringLiteral UNO_NAME_FILLSTYLE
constexpr OUStringLiteral UNO_NAME_CHAR_COLOR
constexpr OUStringLiteral UNO_NAME_CHAR_HEIGHT
constexpr OUStringLiteral UNO_NAME_LINECOLOR
constexpr OUStringLiteral UNO_NAME_CHAR_WEIGHT