// create temporary oox::Shape as target. No longer needed is to keep/remember // the original oox::Shape to do that. Use original Size and Pos from initial import // to get the same layout(s)
oox::drawingml::ShapePtr pShapePtr = std::make_shared<Shape>( "com.sun.star.drawing.GroupShape" );
pShapePtr->setDiagramType();
pShapePtr->setSize(maImportSize);
// Re-create the oox::Shapes for the diagram content
mpDiagramPtr->addTo(pShapePtr, true);
// Delete all existing shapes in that group to prepare re-creation
rTarget.getChildrenOfSdrObject()->ClearSdrObjList();
// For re-creation we need to use ::addShape functionality from the // oox import filter since currently Shape import is very tightly // coupled to Shape creation. It converts a oox::Shape representation // combined with an oox::Theme to incarnated XShapes representing the // Diagram. // To use that functionality, we have to create a temporary filter // (based on ShapeFilterBase). Problems are that this needs to know // the oox:Theme and a ComponentModel from TargetDocument. // The DiagramHelper holds/delivers the oox::Theme to use, so // it does not need to be re-imported from oox repeatedly. // The ComponentModel can be derived from the existing XShape/GroupShape // when knowing where to get it from, making it independent from app. // // NOTE: Using another (buffered) oox::Theme would allow to re-create // using another theming in the future. // NOTE: The incarnation of import filter (ShapeFilterBase) is only // used for XShape creation, no xml snippets/data gets imported // here. XShape creation may be isolated in the future.
SdrModel& rModel(rTarget.getSdrModelFromSdrObject());
uno::Reference< uno::XInterface > const & rUnoModel(rModel.getUnoModel()); const css::uno::Reference<css::uno::XComponentContext>& xContext(comphelper::getProcessComponentContext());
rtl::Reference<oox::shape::ShapeFilterBase> xFilter(new oox::shape::ShapeFilterBase(xContext));
// set oox::Theme at Filter. All LineStyle/FillStyle/Colors/Attributes // will be taken from there // also need to use theme when geometry gets self-created the first time if(UseDiagramThemeData() || !isSelfCreated())
xFilter->setCurrentTheme(getOrCreateThemePtr(xFilter));
if (isSelfCreated())
{ // already secured at import, re-apply secured data from ModelData if(UseDiagramModelData())
mpDiagramPtr->getData()->restoreDataFromShapeToModelAfterDiagramImport(*pShapePtr);
} else
{ // secure data from ModelData for the 1st time for shapes except BackgroundShape if(UseDiagramModelData())
mpDiagramPtr->getData()->secureDataFromShapeToModelAfterDiagramImport(*pShapePtr);
// note that shapes are now self-created
setSelfCreated();
}
// reset temporary buffered ModelData association lists & rebuild them // and the Diagram DataModel
mpDiagramPtr->getData()->buildDiagramDataModel(true);
// also reset temporary buffered layout data - that might // still refer to changed oox::Shape data
mpDiagramPtr->getLayout()->getPresPointShapeMap().clear();
}
// reset temporary buffered ModelData association lists & rebuild them // and the Diagram DataModel
mpDiagramPtr->getData()->buildDiagramDataModel(true);
// also reset temporary buffered layout data - that might // still refer to changed oox::Shape data
mpDiagramPtr->getLayout()->getPresPointShapeMap().clear();
}
// After Diagram import, parts of the Diagram ModelData is at the // oox::drawingml::Shape. Since these objects are temporary helpers, // secure that data at the Diagram ModelData by copying.
mpDiagramPtr->getData()->secureDataFromShapeToModelAfterDiagramImport(rRootShape);
anchorToSdrObjGroup(rTarget);
}
const std::shared_ptr< ::oox::drawingml::Theme >& AdvancedDiagramHelper::getOrCreateThemePtr( const rtl::Reference< oox::shape::ShapeFilterBase >& rxFilter) const
{ // (Re-)Use already existing Theme if existing/imported if possible. // If not, re-import Theme if data is available and thus possible if(hasDiagramData() && (ForceThemePtrRecreation() || !mpThemePtr))
{ // get the originally imported dom::XDocument const uno::Reference< css::xml::dom::XDocument >& xThemeDocument(mpDiagramPtr->getData()->getThemeDocument());
if(xThemeDocument)
{ // reset local Theme ModelData *always* to get rid of former data that would // else be added additionally const_cast<AdvancedDiagramHelper*>(this)->mpThemePtr = std::make_shared<oox::drawingml::Theme>(); auto pTheme = std::make_shared<model::Theme>();
mpThemePtr->setTheme(pTheme);
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.