// Offset the children from their default z-order stacking, if necessary. for (size_t i = 0; i < rChildren.size(); ++i)
rChildren[i]->setZOrder(i);
for (size_t i = 0; i < rChildren.size(); ++i)
{ const ShapePtr& pChild = rChildren[i];
sal_Int32 nZOrderOff = pChild->getZOrderOff(); if (nZOrderOff <= 0) continue;
// Increase my ZOrder by nZOrderOff.
pChild->setZOrder(pChild->getZOrder() + nZOrderOff);
pChild->setZOrderOff(0);
for (sal_Int32 j = 0; j < nZOrderOff; ++j)
{
size_t nIndex = i + j + 1; if (nIndex >= rChildren.size()) break;
// Decrease the ZOrder of the next nZOrderOff elements by one. const ShapePtr& pNext = rChildren[nIndex];
pNext->setZOrder(pNext->getZOrder() - 1);
}
}
// Now that the ZOrders are adjusted, sort the children.
std::sort(rChildren.begin(), rChildren.end(),
[](const ShapePtr& a, const ShapePtr& b) { return a->getZOrder() < b->getZOrder(); });
// Apply also for children. for (constauto& rChild : rChildren)
sortChildrenByZOrder(rChild);
}
/// Removes empty group shapes, now that their spacing influenced the layout. staticvoid removeUnneededGroupShapes(const ShapePtr& pShape)
{
std::vector<ShapePtr>& rChildren = pShape->getChildren();
// layout shapes - now all shapes are created
ShapeLayoutingVisitor aLayoutingVisitor(*this, pRootPoint);
mpLayout->getNode()->accept(aLayoutingVisitor);
// create and set ModelID for BackgroundShape to allow later association
getData()->setBackgroundShapeModelID(OStringToOUString(comphelper::xml::generateGUIDString(), RTL_TEXTENCODING_UTF8));
pBackground->setDiagramDataModelID(getData()->getBackgroundShapeModelID());
using ShapePairs
= std::map<std::shared_ptr<drawingml::Shape>, css::uno::Reference<css::drawing::XShape>>;
void Diagram::syncDiagramFontHeights()
{ // Each name represents a group of shapes, for which the font height should have the same // scaling. for (constauto& rNameAndPairs : maDiagramFontHeights)
{ // Find out the minimum scale within this group. const ShapePairs& rShapePairs = rNameAndPairs.second; double fMinFontScale = 100.0; double fMinSpacingScale = 100.0; for (constauto& rShapePair : rShapePairs)
{
uno::Reference<beans::XPropertySet> xPropertySet(rShapePair.second, uno::UNO_QUERY); if (xPropertySet.is())
{ double fFontScale = 0.0; double fSpacingScale = 0.0;
xPropertySet->getPropertyValue(u"TextFitToSizeFontScale"_ustr) >>= fFontScale;
xPropertySet->getPropertyValue(u"TextFitToSizeSpacingScale"_ustr) >>= fSpacingScale;
// Set that minimum scale for all members of the group. if (fMinFontScale < 100.0 || fMinSpacingScale < 100.0)
{ for (constauto& rShapePair : rShapePairs)
{
uno::Reference<beans::XPropertySet> xPropertySet(rShapePair.second, uno::UNO_QUERY); if (xPropertySet.is())
{
xPropertySet->setPropertyValue(u"TextFitToSizeFontScale"_ustr, uno::Any(fMinFontScale));
xPropertySet->setPropertyValue(u"TextFitToSizeSpacingScale"_ustr, uno::Any(fMinSpacingScale));
}
}
}
}
// no longer needed after processing
maDiagramFontHeights.clear();
}
static uno::Reference<xml::dom::XDocument> loadFragment(
core::XmlFilterBase& rFilter, const OUString& rFragmentPath )
{ // load diagramming fragments into DOM representation, that later // gets serialized back to SAX events and parsed return rFilter.importFragment( rFragmentPath );
}
// Pass the info to pShape for (autoconst& extDrawing : pData->getExtDrawings())
{
OUString aFragmentPath = rRelations.getFragmentPathFromRelId(extDrawing); // Ignore RelIds which don't resolve to a fragment path. if (aFragmentPath.isEmpty()) continue;
sal_Int32 nCounter = 0;
rtl::Reference<core::FragmentHandler> xCounter( new DiagramShapeCounter(rFilter, aFragmentPath, nCounter));
rFilter.importFragment(xCounter); // Ignore ext drawings which don't actually have any shapes. if (nCounter == 0) continue;
pShape->addExtDrawingRelId(extDrawing);
}
}
// Layout: always import to allow editing in the future. It's needed for // AdvancedDiagramHelper::reLayout to re-create the oox::Shape(s) for the // model. Without importing these the diagram model will be not complete. // NOTE: This also adds the DomMaps to rMainDomMap, so the lines // DiagramDomMap& rMainDomMap = pDiagram->getDomMap(); // rMainDomMap[u"OOXLayout"_ustr] = loadFragment(rFilter,rLayoutPath); // rMainDomMap[u"OOXStyle"_ustr] = loadFragment(rFilter,rQStylePath); // which were used before if !pShape->getExtDrawings().empty() are not // needed if (!rLayoutPath.isEmpty())
{
rtl::Reference< core::FragmentHandler > xRefLayout( new DiagramLayoutFragmentHandler( rFilter, rLayoutPath,
std::move(pLayout) ));
if( !pData->getExtDrawings().empty() )
{ const DiagramColorMap::const_iterator aColor = pDiagram->getColors().find(u"node0"_ustr); if( aColor != pDiagram->getColors().end() && !aColor->second.maTextFillColors.empty())
{ // TODO(F1): well, actually, there might be *several* color // definitions in it, after all it's called list.
pShape->setFontRefColorForNodes(DiagramColor::getColorByIndex(aColor->second.maTextFillColors, -1));
}
}
// collect data, init maps // for Diagram import, do - for now - NOT clear all oox::drawingml::Shape
pData->buildDiagramDataModel(false);
// diagram loaded. now lump together & attach to shape // create own geometry if extLst is not present (no geometric // representation is available in file). This will - if false - // just create the BackgroundShape. // NOTE: Need to use pShape->getExtDrawings() here, this is the // already *filtered* version, see usage of DiagramShapeCounter // above. Moving to local bool, there might more conditions show // up constbool bCreate(pShape->getExtDrawings().empty());
pDiagram->addTo(pShape, bCreate);
pShape->setDiagramDoms(pDiagram->getDomsAsPropertyValues());
// Get the oox::Theme definition and - if available - move/secure the // original ImportData directly to the Diagram ModelData
std::shared_ptr<::oox::drawingml::Theme> aTheme(rFilter.getCurrentThemePtr()); if(aTheme)
pData->setThemeDocument(aTheme->getFragment()); //getTempFile());
// Prepare support for the advanced DiagramHelper using Diagram & Theme data
pShape->prepareDiagramHelper(pDiagram, rFilter.getCurrentThemePtr(), bCreate);
} catch (...)
{ // unset DiagramFontHeights at filter if there was a failure // to avoid dangling pointer
rFilter.setDiagramFontHeights(nullptr); throw;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.