/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
uno::Reference<drawing::XShape> xShape; // No element happens in case of pretty-printed XML, bodyPr is the case when we are called again after <wps:txbx>. if (!nElement || nElement == WPS_TOKEN(bodyPr)) // Assume that this is just a continuation of the previous shape.
xShape = mxSavedShape;
switch (getNamespace( nStartToken ))
{ case NMSP_doc: case NMSP_vml:
xResult.set(getDrawingShapeContext()); break; case NMSP_dmlDiagram:
xResult.set(getDiagramShapeContext()); break; case NMSP_dmlLockedCanvas:
xResult.set(getLockedCanvasContext(nStartToken)); break; case NMSP_dmlChart:
xResult.set(getChartShapeContext(nStartToken)); break; case NMSP_wps:
xResult.set(getWpsContext(nStartToken, nElement)); break; case NMSP_wpg:
xResult.set(getWpgContext(nStartToken)); break; case NMSP_wpc:
xResult.set(getWordprocessingCanvasContext(nStartToken)); break; default:
xResult.set(getGraphicShapeContext(nStartToken)); break;
}
if (Element == DGM_TOKEN(relIds) || Element == LC_TOKEN(lockedCanvas) || Element == C_TOKEN(chart) ||
Element == WPS_TOKEN(wsp) || Element == WPG_TOKEN(wgp) || Element == OOX_TOKEN(dmlPicture, pic)
|| Element == WPC_TOKEN(wpc))
{ // Parse the theme relation, if available; the diagram won't have colors without it. if (!mpThemePtr && !msRelationFragmentPath.isEmpty())
{ // Get Target for Type = "officeDocument" from _rels/.rels file // aOfficeDocumentFragmentPath is pointing to "word/document.xml" for docx & to "ppt/presentation.xml" for pptx
FragmentHandlerRef rFragmentHandlerRef(new ShapeFragmentHandler(*mxShapeFilterBase, u"/"_ustr));
OUString aOfficeDocumentFragmentPath = rFragmentHandlerRef->getFragmentPathFromFirstTypeFromOfficeDoc( u"officeDocument" );
// Get the theme DO NOT use msRelationFragmentPath for getting theme as for a document there is a single theme in document.xml.rels // and the same is used by header and footer as well.
FragmentHandlerRef rFragmentHandler(new ShapeFragmentHandler(*mxShapeFilterBase, aOfficeDocumentFragmentPath));
OUString aThemeFragmentPath = rFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc( u"theme" );
// Entering VML block (startFastElement() is called for the outermost tag), // handle possible recursion. if ( getContextHandler() == getDrawingShapeContext() )
mpDrawing->getShapes().pushMark();
if (xContextHandler.is())
xContextHandler->endFastElement(Element); // In case a textbox is sent, and later we get additional properties for // the textbox, then the wps context is not cleared, so do that here. if (Element != (NMSP_wps | XML_wsp)) return;
if (mxShapeFilterBase && xShapes.is())
{ if ( getContextHandler() == getDrawingShapeContext() )
{
mpDrawing->finalizeFragmentImport(); if( std::shared_ptr< vml::ShapeBase > pShape = mpDrawing->getShapes().takeLastShape() )
xResult = pShape->convertAndInsert( xShapes ); // Only now remove the recursion mark, because getShape() is called in writerfilter // after endFastElement().
mpDrawing->getShapes().popMark();
} elseif (mxDiagramShapeContext.is())
{
basegfx::B2DHomMatrix aMatrix; if (mpShape->getExtDrawings().empty())
{
mpShape->addShape( *mxShapeFilterBase, mpThemePtr.get(), xShapes, aMatrix, mpShape->getFillProperties() );
xResult = mpShape->getXShape();
} else
{ // Prerendered diagram output is available, then use that, and throw away the original result. for (autoconst& extDrawing : mpShape->getExtDrawings())
{
OUString aFragmentPath(mxDiagramShapeContext->getFragmentPathFromRelId(extDrawing));
oox::drawingml::ShapePtr pShapePtr = std::make_shared<Shape>( "com.sun.star.drawing.GroupShape" );
pShapePtr->setDiagramType();
mxShapeFilterBase->importFragment(new ShapeDrawingFragmentHandler(*mxShapeFilterBase, aFragmentPath, pShapePtr));
pShapePtr->setDiagramDoms(mpShape->getDiagramDoms());
pShapePtr->keepDiagramDrawing(*mxShapeFilterBase, aFragmentPath);
if (mpShape->getFontRefColorForNodes().isUsed())
applyFontRefColor(pShapePtr, mpShape->getFontRefColorForNodes());
// migrate IDiagramHelper to new oox::Shape (from mpShape which was loaded // to pShapePtr where the geometry is now constructed)
mpShape->migrateDiagramHelperToNewShape(pShapePtr);
if (!mpShape->getChildren().empty())
{ // first child is diagram background - we want to keep it, as drawingML fallback doesn't contain it auto& aChildren = pShapePtr->getChildren();
ShapePtr pBackground = mpShape->getChildren().front();
aChildren.insert(aChildren.begin(), pBackground);
}
// create a flat map of all shapes in the drawing canvas group.
oox::drawingml::ShapeIdMap aShapeMap;
lcl_createShapeMap(pShape, aShapeMap);
// Traverse aShapeMap and generate edge related properties. for (auto& rIt : aShapeMap)
{ if ((rIt.second)->getServiceName() == "com.sun.star.drawing.ConnectorShape")
{
ConnectorHelper::applyConnections(rIt.second, aShapeMap);
if (rIt.second->getConnectorName() == u"bentConnector3"_ustr
|| rIt.second->getConnectorName() == u"bentConnector4"_ustr
|| rIt.second->getConnectorName() == u"bentConnector5"_ustr)
{
ConnectorHelper::applyBentHandleAdjustments(rIt.second);
} elseif (rIt.second->getConnectorName() == u"curvedConnector3"_ustr
|| rIt.second->getConnectorName() == u"curvedConnector4"_ustr
|| rIt.second->getConnectorName() == u"curvedConnector5"_ustr)
{
ConnectorHelper::applyCurvedHandleAdjustments(rIt.second);
} // else use the default path of LibreOffice. // curveConnector2 and bentConnector2 do not have handles.
}
}
xResult = pShape->getXShape();
mxWordprocessingCanvasContext.clear();
}
} //NMSP_dmlChart == getNamespace( mnStartToken ) check is introduced to make sure that //mnStartToken is set as NMSP_dmlChart in setStartToken. //Only in case it is set then only the below block of code for ChartShapeContext should be executed. elseif (mxChartShapeContext.is() && (NMSP_dmlChart == getNamespace( getStartToken() )))
{
basegfx::B2DHomMatrix aMatrix;
oox::drawingml::ShapePtr xShapePtr( mxChartShapeContext->getShape()); // See SwXTextDocument::createInstance(), ODF import uses the same hack.
xShapePtr->setServiceName(u"com.sun.star.drawing.temporaryForXMLImportOLE2Shape"_ustr);
xShapePtr->addShape( *mxShapeFilterBase, mpThemePtr.get(), xShapes, aMatrix, xShapePtr->getFillProperties() );
xResult = xShapePtr->getXShape();
mxChartShapeContext.clear();
} elseif (mxWpsContext.is())
{
ShapePtr pShape = mxWpsContext->getShape(); if (pShape)
{
basegfx::B2DHomMatrix aMatrix;
pShape->setPosition(maPosition);
pShape->addShape(*mxShapeFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
xResult = pShape->getXShape();
mxSavedShape = xResult;
mxWpsContext.clear();
}
} elseif (mxWpgContext.is())
{
ShapePtr pShape = mxWpgContext->getShape(); if (pShape)
{
basegfx::B2DHomMatrix aMatrix;
pShape->setPosition(maPosition);
pShape->addShape(*mxShapeFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
xResult = pShape->getXShape();
mxSavedShape = xResult;
mxWpgContext.clear();
}
} elseif (mpShape)
{
basegfx::B2DHomMatrix aTransformation;
if (maPosition.X != 0 || maPosition.Y != 0)
{ // We got a position from writerfilter/, store that in the shape, otherwise the // position won't be set.
mpShape->setWps(true);
mpShape->setPosition(maPosition);
}
sal_Int32 ShapeContextHandler::getStartToken() const
{
assert(mnStartTokenStack.size() && "This stack must not be empty!"); return mnStartTokenStack.top();
}
void ShapeContextHandler::popStartToken()
{ if (mnStartTokenStack.size() > 1)
mnStartTokenStack.pop();
}
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.