summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2021-11-10 14:10:11 +0100
committerLászló Németh <nemeth@numbertext.org>2022-01-03 14:28:15 +0100
commit2951cbdf3a6e2b62461665546b47e1d253fcb834 (patch)
treed09834b7f1e68e7b3664ed03c5d2ed3c73de552d /oox
parentcce57fd94e9335c5dd5f3725a5fe54f5d3929e8d (diff)
tdf#143574 OOXML export/import of textboxes in group shapes
In this part, oox module has been modified in order to prepare for WPG handling during OOXML import. Note: Wpg is the drawingML equivalent of v:group, supporting text boxes in the group. 1) Added new parameter for WpgContext to support nested Wpg shapes, and WPS enabled for the WPG member shapes. 2) A bug has fixed, where group member line shape and connector shapes have wrong positions before in the group. 3) Unit tests had to be modified, and 3 of them disabled temporarily due to missing Writerfilter implementation (what will be the next commit) Now group shapes can have textboxes and the text is imported for that, but complex content is still missing (this will be fixed in writerfilter by the next commit). Known issue: WPG shapes with textboxes in floating table have issues during import at floating table conversion, so until this is not fixed this function is disabled for shapes in tables (will be fixed a follow-up commit later). Follow-up to commit 19394a924fdc486202ca27e318385287eb0df26f "tdf#143574 sw: textboxes in group shapes -- part 4". Change-Id: I71032187697807087bd8f27f7c3a7b052e174bd7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124964 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/drawingml/shape.cxx2
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx8
-rw-r--r--oox/source/shape/WpgContext.cxx45
-rw-r--r--oox/source/shape/WpgContext.hxx8
4 files changed, 48 insertions, 15 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 78a27f8a0c9c..fd9eb691b2e8 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1531,7 +1531,7 @@ Reference< XShape > const & Shape::createAndInsert(
// These can have a custom geometry, so position should be set here,
// after creation but before custom shape handling, using the position
// we got from the caller.
- if (mbWps && aServiceName == "com.sun.star.drawing.LineShape")
+ if (mbWps && aServiceName == "com.sun.star.drawing.LineShape" && !pParentGroupShape)
mxShape->setPosition(maPosition);
if( bIsCustomShape )
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 5404cc82fe81..3454c0e03f87 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -47,7 +47,9 @@ using namespace drawingml;
ShapeContextHandler::ShapeContextHandler(const rtl::Reference<ShapeFilterBase>& xFilterBase) :
mnStartToken(0),
+ m_bFullWPGSUpport(false),
mxShapeFilterBase(xFilterBase)
+
{
}
@@ -139,8 +141,12 @@ uno::Reference<xml::sax::XFastContextHandler> const & ShapeContextHandler::getWp
switch (getBaseToken(nElement))
{
case XML_wgp:
- mxWpgContext.set(static_cast<oox::core::ContextHandler*>(new WpgContext(*rFragmentHandler)));
+ {
+ rtl::Reference<WpgContext> rContext = new WpgContext(*rFragmentHandler, oox::drawingml::ShapePtr());
+ rContext->setFullWPGSupport(m_bFullWPGSUpport);
+ mxWpgContext.set(static_cast<oox::core::ContextHandler*>(rContext.get()));
break;
+ }
default:
break;
}
diff --git a/oox/source/shape/WpgContext.cxx b/oox/source/shape/WpgContext.cxx
index 7896f8a4c81d..cf65491e0f26 100644
--- a/oox/source/shape/WpgContext.cxx
+++ b/oox/source/shape/WpgContext.cxx
@@ -8,6 +8,7 @@
*/
#include "WpgContext.hxx"
+#include "WpsContext.hxx"
#include <sal/log.hxx>
#include <drawingml/shapepropertiescontext.hxx>
#include <oox/drawingml/shapegroupcontext.hxx>
@@ -19,11 +20,14 @@ using namespace com::sun::star;
namespace oox::shape
{
-WpgContext::WpgContext(FragmentHandler2 const& rParent)
+WpgContext::WpgContext(FragmentHandler2 const& rParent, oox::drawingml::ShapePtr pMaster)
: FragmentHandler2(rParent)
+ , m_bFullWPGSupport(false)
{
mpShape = std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape");
mpShape->setWps(true);
+ if (pMaster)
+ pMaster->addChild(mpShape);
}
WpgContext::~WpgContext() = default;
@@ -39,14 +43,22 @@ oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken
return new oox::drawingml::ShapePropertiesContext(*this, *mpShape);
case XML_wsp:
{
- // Don't set default character height, Writer has its own way to set
- // the default, and if we don't set it here, editeng properly inherits
- // it.
- oox::drawingml::ShapePtr pShape = std::make_shared<oox::drawingml::Shape>(
- "com.sun.star.drawing.CustomShape", /*bDefaultHeight=*/false);
- return new oox::drawingml::ShapeContext(*this, mpShape, pShape);
- // return new oox::shape::WpsContext(*this, uno::Reference<drawing::XShape>(),
- // mpShape, pShape);
+ if (m_bFullWPGSupport)
+ {
+ oox::drawingml::ShapePtr pShape = std::make_shared<oox::drawingml::Shape>(
+ "com.sun.star.drawing.CustomShape", /*bDefaultHeight=*/false);
+ return new oox::shape::WpsContext(*this, uno::Reference<drawing::XShape>(), mpShape,
+ pShape);
+ }
+ else
+ {
+ // Don't set default character height, Writer has its own way to set
+ // the default, and if we don't set it here, editeng properly inherits
+ // it.
+ oox::drawingml::ShapePtr pShape = std::make_shared<oox::drawingml::Shape>(
+ "com.sun.star.drawing.CustomShape", /*bDefaultHeight=*/false);
+ return new oox::drawingml::ShapeContext(*this, mpShape, pShape);
+ }
}
case XML_pic:
return new oox::drawingml::GraphicShapeContext(
@@ -54,9 +66,18 @@ oox::core::ContextHandlerRef WpgContext::onCreateContext(sal_Int32 nElementToken
std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GraphicObjectShape"));
case XML_grpSp:
{
- return new oox::drawingml::ShapeGroupContext(
- *this, mpShape,
- std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape"));
+ if (m_bFullWPGSupport)
+ {
+ rtl::Reference<WpgContext> pWPGShape = new oox::shape::WpgContext(*this, mpShape);
+ pWPGShape->setFullWPGSupport(m_bFullWPGSupport);
+ return pWPGShape;
+ }
+ else
+ {
+ return new oox::drawingml::ShapeGroupContext(
+ *this, mpShape,
+ std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape"));
+ }
}
case XML_graphicFrame:
{
diff --git a/oox/source/shape/WpgContext.hxx b/oox/source/shape/WpgContext.hxx
index c4b511a923d3..6da13d9663be 100644
--- a/oox/source/shape/WpgContext.hxx
+++ b/oox/source/shape/WpgContext.hxx
@@ -19,7 +19,8 @@ namespace oox::shape
class WpgContext final : public oox::core::FragmentHandler2
{
public:
- explicit WpgContext(oox::core::FragmentHandler2 const& rParent);
+ explicit WpgContext(oox::core::FragmentHandler2 const& rParent,
+ oox::drawingml::ShapePtr pMaster);
~WpgContext() override;
oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElementToken,
@@ -27,8 +28,13 @@ public:
const oox::drawingml::ShapePtr& getShape() const { return mpShape; }
+ const bool& isFullWPGSupport() { return m_bFullWPGSupport; };
+ void setFullWPGSupport(const bool& rbUse) { m_bFullWPGSupport = rbUse; };
+
private:
oox::drawingml::ShapePtr mpShape;
+
+ bool m_bFullWPGSupport;
};
}