2010-10-12 08:56:41 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-16 11:32:30 -05:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2008-01-17 01:06:10 -06:00
|
|
|
|
2019-04-29 06:30:42 -05:00
|
|
|
#include <oox/drawingml/diagram/diagram.hxx>
|
|
|
|
#include "diagram.hxx"
|
2008-03-05 11:37:58 -06:00
|
|
|
#include <com/sun/star/awt/Point.hpp>
|
|
|
|
#include <com/sun/star/awt/Size.hpp>
|
2019-04-29 06:30:42 -05:00
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
2019-07-22 08:04:15 -05:00
|
|
|
#include <com/sun/star/drawing/XShape.hpp>
|
2019-04-29 06:30:42 -05:00
|
|
|
#include <com/sun/star/drawing/XShapes.hpp>
|
2011-08-12 08:53:12 -05:00
|
|
|
#include <com/sun/star/xml/dom/XDocument.hpp>
|
|
|
|
#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
|
2018-07-27 15:33:55 -05:00
|
|
|
#include <sal/log.hxx>
|
2013-09-03 03:13:22 -05:00
|
|
|
#include <editeng/unoprnms.hxx>
|
2017-10-23 15:35:15 -05:00
|
|
|
#include <drawingml/fillproperties.hxx>
|
2019-05-08 14:49:34 -05:00
|
|
|
#include <drawingml/customshapeproperties.hxx>
|
2021-02-13 04:55:22 -06:00
|
|
|
#include <o3tl/unit_conversion.hxx>
|
2018-10-18 07:43:23 -05:00
|
|
|
#include <oox/token/namespaces.hxx>
|
2019-04-29 06:30:42 -05:00
|
|
|
#include <basegfx/matrix/b2dhommatrix.hxx>
|
2019-07-22 08:04:15 -05:00
|
|
|
#include <svx/svdpage.hxx>
|
2022-02-18 09:07:28 -06:00
|
|
|
#include <oox/ppt/pptimport.hxx>
|
2022-04-19 04:37:57 -05:00
|
|
|
#include <comphelper/xmltools.hxx>
|
2008-01-17 01:06:10 -06:00
|
|
|
|
2011-08-12 08:53:12 -05:00
|
|
|
#include "diagramlayoutatoms.hxx"
|
2017-06-26 09:55:49 -05:00
|
|
|
#include "layoutatomvisitors.hxx"
|
2011-08-12 08:53:12 -05:00
|
|
|
#include "diagramfragmenthandler.hxx"
|
|
|
|
|
2008-03-05 11:37:58 -06:00
|
|
|
using namespace ::com::sun::star;
|
2008-01-17 01:06:10 -06:00
|
|
|
|
2020-01-14 12:53:45 -06:00
|
|
|
namespace oox::drawingml {
|
2008-01-17 01:06:10 -06:00
|
|
|
|
2019-05-28 06:36:59 -05:00
|
|
|
static void sortChildrenByZOrder(const ShapePtr& pShape)
|
|
|
|
{
|
|
|
|
std::vector<ShapePtr>& rChildren = pShape->getChildren();
|
|
|
|
|
|
|
|
// 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.
|
2019-08-20 02:32:35 -05:00
|
|
|
for (const auto& rChild : rChildren)
|
2019-05-28 06:36:59 -05:00
|
|
|
sortChildrenByZOrder(rChild);
|
|
|
|
}
|
|
|
|
|
2020-07-31 04:04:02 -05:00
|
|
|
/// Removes empty group shapes, now that their spacing influenced the layout.
|
|
|
|
static void removeUnneededGroupShapes(const ShapePtr& pShape)
|
|
|
|
{
|
|
|
|
std::vector<ShapePtr>& rChildren = pShape->getChildren();
|
|
|
|
|
|
|
|
rChildren.erase(std::remove_if(rChildren.begin(), rChildren.end(),
|
|
|
|
[](const ShapePtr& aChild) {
|
|
|
|
return aChild->getServiceName()
|
|
|
|
== "com.sun.star.drawing.GroupShape"
|
|
|
|
&& aChild->getChildren().empty();
|
|
|
|
}),
|
|
|
|
rChildren.end());
|
|
|
|
|
|
|
|
for (const auto& pChild : rChildren)
|
|
|
|
{
|
|
|
|
removeUnneededGroupShapes(pChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-13 10:17:35 -05:00
|
|
|
|
2008-03-05 11:37:58 -06:00
|
|
|
void Diagram::addTo( const ShapePtr & pParentShape )
|
2008-01-17 01:06:10 -06:00
|
|
|
{
|
2017-06-30 06:30:27 -05:00
|
|
|
if (pParentShape->getSize().Width == 0 || pParentShape->getSize().Height == 0)
|
|
|
|
SAL_WARN("oox.drawingml", "Diagram cannot be correctly laid out. Size: "
|
|
|
|
<< pParentShape->getSize().Width << "x" << pParentShape->getSize().Height);
|
|
|
|
|
2017-06-23 08:11:08 -05:00
|
|
|
pParentShape->setChildSize(pParentShape->getSize());
|
|
|
|
|
2022-03-28 05:43:42 -05:00
|
|
|
const svx::diagram::Point* pRootPoint = mpData->getRootPoint();
|
2019-06-26 03:42:28 -05:00
|
|
|
if (mpLayout->getNode() && pRootPoint)
|
2017-06-30 06:30:27 -05:00
|
|
|
{
|
|
|
|
// create Shape hierarchy
|
2019-06-26 03:42:28 -05:00
|
|
|
ShapeCreationVisitor aCreationVisitor(*this, pRootPoint, pParentShape);
|
2017-06-30 06:30:27 -05:00
|
|
|
mpLayout->getNode()->setExistingShape(pParentShape);
|
2017-07-13 11:39:42 -05:00
|
|
|
mpLayout->getNode()->accept(aCreationVisitor);
|
|
|
|
|
|
|
|
// layout shapes - now all shapes are created
|
2019-06-26 03:42:28 -05:00
|
|
|
ShapeLayoutingVisitor aLayoutingVisitor(*this, pRootPoint);
|
2017-07-13 11:39:42 -05:00
|
|
|
mpLayout->getNode()->accept(aLayoutingVisitor);
|
2019-05-28 06:36:59 -05:00
|
|
|
|
|
|
|
sortChildrenByZOrder(pParentShape);
|
2020-07-31 04:04:02 -05:00
|
|
|
removeUnneededGroupShapes(pParentShape);
|
2017-06-30 06:30:27 -05:00
|
|
|
}
|
2019-05-08 14:49:34 -05:00
|
|
|
|
2020-01-24 00:31:14 -06:00
|
|
|
ShapePtr pBackground = std::make_shared<Shape>("com.sun.star.drawing.CustomShape");
|
2019-05-08 14:49:34 -05:00
|
|
|
pBackground->setSubType(XML_rect);
|
|
|
|
pBackground->getCustomShapeProperties()->setShapePresetType(XML_rect);
|
|
|
|
pBackground->setSize(pParentShape->getSize());
|
2022-04-19 04:37:57 -05:00
|
|
|
pBackground->getFillProperties() = *mpData->getBackgroundShapeFillProperties();
|
2019-05-08 14:49:34 -05:00
|
|
|
pBackground->setLocked(true);
|
2022-04-19 04:37:57 -05:00
|
|
|
|
|
|
|
// create and set ModelID for BackgroundShape to allow later association
|
|
|
|
getData()->setBackgroundShapeModelID(OStringToOUString(comphelper::xml::generateGUIDString(), RTL_TEXTENCODING_UTF8));
|
|
|
|
pBackground->setDiagramDataModelID(getData()->getBackgroundShapeModelID());
|
|
|
|
|
2019-05-08 14:49:34 -05:00
|
|
|
auto& aChildren = pParentShape->getChildren();
|
|
|
|
aChildren.insert(aChildren.begin(), pBackground);
|
2013-09-03 03:13:22 -05:00
|
|
|
}
|
|
|
|
|
2022-03-04 09:51:07 -06:00
|
|
|
Diagram::Diagram()
|
|
|
|
: maDiagramFontHeights()
|
2020-09-11 10:30:27 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-09-03 03:13:22 -05:00
|
|
|
uno::Sequence<beans::PropertyValue> Diagram::getDomsAsPropertyValues() const
|
|
|
|
{
|
|
|
|
sal_Int32 length = maMainDomMap.size();
|
|
|
|
|
2017-08-17 02:52:17 -05:00
|
|
|
if (maDataRelsMap.hasElements())
|
2014-02-25 01:43:11 -06:00
|
|
|
++length;
|
|
|
|
|
2013-09-03 03:13:22 -05:00
|
|
|
uno::Sequence<beans::PropertyValue> aValue(length);
|
|
|
|
beans::PropertyValue* pValue = aValue.getArray();
|
2018-03-30 15:14:59 -05:00
|
|
|
for (auto const& mainDom : maMainDomMap)
|
2013-09-03 03:13:22 -05:00
|
|
|
{
|
2018-03-30 15:14:59 -05:00
|
|
|
pValue->Name = mainDom.first;
|
|
|
|
pValue->Value <<= mainDom.second;
|
2013-09-03 03:13:22 -05:00
|
|
|
++pValue;
|
|
|
|
}
|
|
|
|
|
2017-08-17 02:52:17 -05:00
|
|
|
if (maDataRelsMap.hasElements())
|
2014-02-25 01:43:11 -06:00
|
|
|
{
|
2017-08-17 02:52:17 -05:00
|
|
|
pValue->Name = "OOXDiagramDataRels";
|
|
|
|
pValue->Value <<= maDataRelsMap;
|
2014-02-25 01:43:11 -06:00
|
|
|
++pValue;
|
|
|
|
}
|
|
|
|
|
2013-09-03 03:13:22 -05:00
|
|
|
return aValue;
|
2008-01-17 01:06:10 -06:00
|
|
|
}
|
|
|
|
|
2022-03-04 09:51:07 -06:00
|
|
|
using ShapePairs
|
|
|
|
= std::map<std::shared_ptr<drawingml::Shape>, css::uno::Reference<css::drawing::XShape>>;
|
|
|
|
|
|
|
|
void Diagram::syncDiagramFontHeights()
|
2022-02-22 12:39:04 -06:00
|
|
|
{
|
2022-03-04 09:51:07 -06:00
|
|
|
// Each name represents a group of shapes, for which the font height should have the same
|
|
|
|
// scaling.
|
|
|
|
for (const auto& rNameAndPairs : maDiagramFontHeights)
|
|
|
|
{
|
|
|
|
// Find out the minimum scale within this group.
|
|
|
|
const ShapePairs& rShapePairs = rNameAndPairs.second;
|
|
|
|
sal_Int16 nMinScale = 100;
|
|
|
|
for (const auto& rShapePair : rShapePairs)
|
|
|
|
{
|
|
|
|
uno::Reference<beans::XPropertySet> xPropertySet(rShapePair.second, uno::UNO_QUERY);
|
|
|
|
if (xPropertySet.is())
|
|
|
|
{
|
|
|
|
sal_Int16 nTextFitToSizeScale = 0;
|
|
|
|
xPropertySet->getPropertyValue("TextFitToSizeScale") >>= nTextFitToSizeScale;
|
|
|
|
if (nTextFitToSizeScale > 0 && nTextFitToSizeScale < nMinScale)
|
|
|
|
{
|
|
|
|
nMinScale = nTextFitToSizeScale;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set that minimum scale for all members of the group.
|
|
|
|
if (nMinScale < 100)
|
|
|
|
{
|
|
|
|
for (const auto& rShapePair : rShapePairs)
|
|
|
|
{
|
|
|
|
uno::Reference<beans::XPropertySet> xPropertySet(rShapePair.second, uno::UNO_QUERY);
|
|
|
|
if (xPropertySet.is())
|
|
|
|
{
|
2022-05-04 00:04:48 -05:00
|
|
|
xPropertySet->setPropertyValue("TextFitToSizeScale", uno::Any(nMinScale));
|
2022-03-04 09:51:07 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// no longer needed after processing
|
|
|
|
maDiagramFontHeights.clear();
|
2022-02-22 12:39:04 -06:00
|
|
|
}
|
|
|
|
|
2018-09-15 12:13:19 -05:00
|
|
|
static uno::Reference<xml::dom::XDocument> loadFragment(
|
2011-08-12 08:53:12 -05:00
|
|
|
core::XmlFilterBase& rFilter,
|
2013-09-03 03:13:22 -05:00
|
|
|
const OUString& rFragmentPath )
|
2011-08-12 08:53:12 -05:00
|
|
|
{
|
|
|
|
// load diagramming fragments into DOM representation, that later
|
|
|
|
// gets serialized back to SAX events and parsed
|
2013-09-03 03:13:22 -05:00
|
|
|
return rFilter.importFragment( rFragmentPath );
|
|
|
|
}
|
|
|
|
|
2018-09-15 12:13:19 -05:00
|
|
|
static uno::Reference<xml::dom::XDocument> loadFragment(
|
2013-09-03 03:13:22 -05:00
|
|
|
core::XmlFilterBase& rFilter,
|
|
|
|
const rtl::Reference< core::FragmentHandler >& rxHandler )
|
|
|
|
{
|
|
|
|
return loadFragment( rFilter, rxHandler->getFragmentPath() );
|
2011-08-12 08:53:12 -05:00
|
|
|
}
|
|
|
|
|
2018-09-15 12:13:19 -05:00
|
|
|
static void importFragment( core::XmlFilterBase& rFilter,
|
2011-08-12 08:53:12 -05:00
|
|
|
const uno::Reference<xml::dom::XDocument>& rXDom,
|
2019-12-26 01:39:29 -06:00
|
|
|
const OUString& rDocName,
|
2013-09-03 03:13:22 -05:00
|
|
|
const DiagramPtr& pDiagram,
|
2011-08-12 08:53:12 -05:00
|
|
|
const rtl::Reference< core::FragmentHandler >& rxHandler )
|
|
|
|
{
|
2013-09-03 03:13:22 -05:00
|
|
|
DiagramDomMap& rMainDomMap = pDiagram->getDomMap();
|
2019-12-26 01:39:29 -06:00
|
|
|
rMainDomMap[rDocName] = rXDom;
|
2013-09-03 03:13:22 -05:00
|
|
|
|
2011-08-12 08:53:12 -05:00
|
|
|
uno::Reference<xml::sax::XFastSAXSerializable> xSerializer(
|
|
|
|
rXDom, uno::UNO_QUERY_THROW);
|
|
|
|
|
|
|
|
// now serialize DOM tree into internal data structures
|
|
|
|
rFilter.importFragment( rxHandler, xSerializer );
|
|
|
|
}
|
|
|
|
|
2018-10-18 07:43:23 -05:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* A fragment handler that just counts the number of <dsp:sp> elements in a
|
|
|
|
* fragment.
|
|
|
|
*/
|
|
|
|
class DiagramShapeCounter : public oox::core::FragmentHandler2
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DiagramShapeCounter(oox::core::XmlFilterBase& rFilter, const OUString& rFragmentPath,
|
|
|
|
sal_Int32& nCounter);
|
|
|
|
oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement,
|
|
|
|
const AttributeList& rAttribs) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
sal_Int32& m_nCounter;
|
|
|
|
};
|
|
|
|
|
|
|
|
DiagramShapeCounter::DiagramShapeCounter(oox::core::XmlFilterBase& rFilter,
|
|
|
|
const OUString& rFragmentPath, sal_Int32& nCounter)
|
|
|
|
: FragmentHandler2(rFilter, rFragmentPath)
|
|
|
|
, m_nCounter(nCounter)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
oox::core::ContextHandlerRef DiagramShapeCounter::onCreateContext(sal_Int32 nElement,
|
|
|
|
const AttributeList& /*rAttribs*/)
|
|
|
|
{
|
|
|
|
switch (nElement)
|
|
|
|
{
|
|
|
|
case DSP_TOKEN(drawing):
|
|
|
|
case DSP_TOKEN(spTree):
|
|
|
|
return this;
|
|
|
|
case DSP_TOKEN(sp):
|
|
|
|
++m_nCounter;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-31 02:28:51 -05:00
|
|
|
void loadDiagram( ShapePtr const & pShape,
|
2011-08-12 08:53:12 -05:00
|
|
|
core::XmlFilterBase& rFilter,
|
2012-12-06 17:55:58 -06:00
|
|
|
const OUString& rDataModelPath,
|
|
|
|
const OUString& rLayoutPath,
|
|
|
|
const OUString& rQStylePath,
|
2018-10-18 07:43:23 -05:00
|
|
|
const OUString& rColorStylePath,
|
|
|
|
const oox::core::Relations& rRelations )
|
2011-08-12 08:53:12 -05:00
|
|
|
{
|
2022-03-04 09:51:07 -06:00
|
|
|
DiagramPtr pDiagram = std::make_shared<Diagram>();
|
2011-08-12 08:53:12 -05:00
|
|
|
|
2022-03-30 04:48:08 -05:00
|
|
|
OoxDiagramDataPtr pData = std::make_shared<DiagramData>();
|
2011-08-12 08:53:12 -05:00
|
|
|
pDiagram->setData( pData );
|
|
|
|
|
2020-01-24 00:31:14 -06:00
|
|
|
DiagramLayoutPtr pLayout = std::make_shared<DiagramLayout>(*pDiagram);
|
2011-08-12 08:53:12 -05:00
|
|
|
pDiagram->setLayout( pLayout );
|
|
|
|
|
2022-03-04 09:51:07 -06:00
|
|
|
// set DiagramFontHeights at filter
|
|
|
|
rFilter.setDiagramFontHeights(&pDiagram->getDiagramFontHeights());
|
|
|
|
|
2011-08-12 08:53:12 -05:00
|
|
|
// data
|
2012-01-01 08:55:53 -06:00
|
|
|
if( !rDataModelPath.isEmpty() )
|
2011-08-12 08:53:12 -05:00
|
|
|
{
|
2013-09-03 03:13:22 -05:00
|
|
|
rtl::Reference< core::FragmentHandler > xRefDataModel(
|
|
|
|
new DiagramDataFragmentHandler( rFilter, rDataModelPath, pData ));
|
2011-08-12 08:53:12 -05:00
|
|
|
|
|
|
|
importFragment(rFilter,
|
2013-09-03 03:13:22 -05:00
|
|
|
loadFragment(rFilter,xRefDataModel),
|
|
|
|
"OOXData",
|
|
|
|
pDiagram,
|
|
|
|
xRefDataModel);
|
2014-02-25 01:43:11 -06:00
|
|
|
|
2014-03-06 04:22:47 -06:00
|
|
|
pDiagram->getDataRelsMap() = pShape->resolveRelationshipsOfTypeFromOfficeDoc( rFilter,
|
2020-12-28 10:56:40 -06:00
|
|
|
xRefDataModel->getFragmentPath(), u"image" );
|
2014-02-25 01:43:11 -06:00
|
|
|
|
2011-12-30 04:39:42 -06:00
|
|
|
// Pass the info to pShape
|
2018-03-30 15:14:59 -05:00
|
|
|
for (auto const& extDrawing : pData->getExtDrawings())
|
2018-10-18 07:43:23 -05:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2011-08-12 08:53:12 -05:00
|
|
|
}
|
|
|
|
|
2012-06-25 08:55:52 -05:00
|
|
|
// extLst is present, lets bet on that and ignore the rest of the data from here
|
2018-10-18 07:43:23 -05:00
|
|
|
if( pShape->getExtDrawings().empty() )
|
2011-08-12 08:53:12 -05:00
|
|
|
{
|
2012-06-25 08:55:52 -05:00
|
|
|
// layout
|
|
|
|
if( !rLayoutPath.isEmpty() )
|
|
|
|
{
|
2013-09-03 03:13:22 -05:00
|
|
|
rtl::Reference< core::FragmentHandler > xRefLayout(
|
2012-06-25 08:55:52 -05:00
|
|
|
new DiagramLayoutFragmentHandler( rFilter, rLayoutPath, pLayout ));
|
2013-09-03 03:13:22 -05:00
|
|
|
|
2012-06-25 08:55:52 -05:00
|
|
|
importFragment(rFilter,
|
2013-09-03 03:13:22 -05:00
|
|
|
loadFragment(rFilter,xRefLayout),
|
|
|
|
"OOXLayout",
|
|
|
|
pDiagram,
|
|
|
|
xRefLayout);
|
2012-06-25 08:55:52 -05:00
|
|
|
}
|
2011-08-12 08:53:12 -05:00
|
|
|
|
2012-06-25 08:55:52 -05:00
|
|
|
// style
|
|
|
|
if( !rQStylePath.isEmpty() )
|
|
|
|
{
|
2013-09-03 03:13:22 -05:00
|
|
|
rtl::Reference< core::FragmentHandler > xRefQStyle(
|
2012-06-25 08:55:52 -05:00
|
|
|
new DiagramQStylesFragmentHandler( rFilter, rQStylePath, pDiagram->getStyles() ));
|
2013-09-03 03:13:22 -05:00
|
|
|
|
2012-06-25 08:55:52 -05:00
|
|
|
importFragment(rFilter,
|
2013-09-03 03:13:22 -05:00
|
|
|
loadFragment(rFilter,xRefQStyle),
|
|
|
|
"OOXStyle",
|
|
|
|
pDiagram,
|
|
|
|
xRefQStyle);
|
2012-06-25 08:55:52 -05:00
|
|
|
}
|
2017-08-17 02:52:17 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-03 03:13:22 -05:00
|
|
|
// We still want to add the XDocuments to the DiagramDomMap
|
|
|
|
DiagramDomMap& rMainDomMap = pDiagram->getDomMap();
|
2013-11-20 08:21:34 -06:00
|
|
|
rMainDomMap[OUString("OOXLayout")] = loadFragment(rFilter,rLayoutPath);
|
|
|
|
rMainDomMap[OUString("OOXStyle")] = loadFragment(rFilter,rQStylePath);
|
2014-06-06 03:16:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// colors
|
|
|
|
if( !rColorStylePath.isEmpty() )
|
|
|
|
{
|
|
|
|
rtl::Reference< core::FragmentHandler > xRefColorStyle(
|
|
|
|
new ColorFragmentHandler( rFilter, rColorStylePath, pDiagram->getColors() ));
|
|
|
|
|
|
|
|
importFragment(rFilter,
|
|
|
|
loadFragment(rFilter,xRefColorStyle),
|
|
|
|
"OOXColor",
|
|
|
|
pDiagram,
|
|
|
|
xRefColorStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !pData->getExtDrawings().empty() )
|
|
|
|
{
|
|
|
|
const DiagramColorMap::const_iterator aColor = pDiagram->getColors().find("node0");
|
2020-05-22 10:58:22 -05:00
|
|
|
if( aColor != pDiagram->getColors().end() && !aColor->second.maTextFillColors.empty())
|
2014-06-06 03:16:39 -05:00
|
|
|
{
|
2020-05-22 10:58:22 -05:00
|
|
|
// 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));
|
2014-06-06 03:16:39 -05:00
|
|
|
}
|
2011-08-12 08:53:12 -05:00
|
|
|
}
|
|
|
|
|
2019-07-22 08:04:15 -05:00
|
|
|
// collect data, init maps
|
2022-03-25 10:34:30 -05:00
|
|
|
// for Diagram import, do - for now - NOT clear all oox::drawingml::Shape
|
2022-04-04 09:57:08 -05:00
|
|
|
pData->buildDiagramDataModel(false);
|
2019-07-22 08:04:15 -05:00
|
|
|
|
2011-08-12 08:53:12 -05:00
|
|
|
// diagram loaded. now lump together & attach to shape
|
|
|
|
pDiagram->addTo(pShape);
|
2019-07-22 08:04:15 -05:00
|
|
|
pShape->setDiagramDoms(pDiagram->getDomsAsPropertyValues());
|
2022-02-18 09:07:28 -06:00
|
|
|
|
2022-04-08 10:38:12 -05:00
|
|
|
// 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());
|
|
|
|
|
2022-02-18 09:07:28 -06:00
|
|
|
// Prepare support for the advanced DiagramHelper using Diagram & Theme data
|
2022-02-22 12:39:04 -06:00
|
|
|
pShape->prepareDiagramHelper(pDiagram, rFilter.getCurrentThemePtr());
|
2011-08-12 08:53:12 -05:00
|
|
|
}
|
|
|
|
|
2020-05-22 10:58:22 -05:00
|
|
|
const oox::drawingml::Color&
|
|
|
|
DiagramColor::getColorByIndex(const std::vector<oox::drawingml::Color>& rColors, sal_Int32 nIndex)
|
|
|
|
{
|
|
|
|
assert(!rColors.empty());
|
|
|
|
if (nIndex == -1)
|
|
|
|
{
|
|
|
|
return rColors[rColors.size() - 1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rColors[nIndex % rColors.size()];
|
|
|
|
}
|
2020-01-14 12:53:45 -06:00
|
|
|
}
|
2010-10-12 08:56:41 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|