summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2018-10-01 03:21:59 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-01-07 17:49:44 +0100
commit3272c1eb5563f3bda2caa24f32b1018372622109 (patch)
treeb4b948fd36ed53b1d8399babf2dbe701469da412 /sw
parent5dfd5755c709e91d2903bd7be4582f7832e89780 (diff)
related tdf#100074: prepare group shapes text input via writerfilter
Put various preps into place, that enable us to read txbxContent from group shape children via the writerfilter parser, which gets us much more features Also: - store shapecontexthandler on wrapper class in writerfilter - move adding children shapes to ctor, not dtor - remove RuntimeException in Writer's XShapes::add(), aligns this with Draw/Impress API semantics, and helps here when trying to add the same shape a 2nd time (which we then simply ignore) - make oox's Shape notion of 'inside group' less ad-hoc - make SwTextBoxHelper::getTextRectangle() cope with more than CustomShape - so passing in a group shape will also yield some sensible bounding box - have SwTextBoxHelper handle group content, too - derive WpsContext from ShapeContext, so we can later substitute it for that inside WpgContext - keep WpgContext::onCreateContext() _for the moment_ with the old delegation to ShapeContext (needs to use WpsContext to enable writerfilter text input) Change-Id: I2b0f0583e21137f3321a8dc13823058b14d19773 Reviewed-on: https://gerrit.libreoffice.org/65914 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/textboxhelper.cxx14
-rw-r--r--sw/source/core/unocore/unodraw.cxx18
2 files changed, 19 insertions, 13 deletions
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 686485ff33e5..2eda7911a320 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -292,7 +292,8 @@ tools::Rectangle SwTextBoxHelper::getTextRectangle(SwFrameFormat* pShape, bool b
{
tools::Rectangle aRet;
aRet.SetEmpty();
- auto pCustomShape = dynamic_cast<SdrObjCustomShape*>(pShape->FindRealSdrObject());
+ auto pSdrShape = pShape->FindRealSdrObject();
+ auto pCustomShape = dynamic_cast<SdrObjCustomShape*>(pSdrShape);
if (pCustomShape)
{
// Need to temporarily release the lock acquired in
@@ -307,12 +308,17 @@ tools::Rectangle SwTextBoxHelper::getTextRectangle(SwFrameFormat* pShape, bool b
if (nLocks)
xLockable->setActionLocks(nLocks);
}
+ else if (pSdrShape)
+ {
+ // fallback - get *any* bound rect we can possibly get hold of
+ aRet = pSdrShape->GetCurrentBoundRect();
+ }
- if (!bAbsolute && pCustomShape)
+ if (!bAbsolute && pSdrShape)
{
// Relative, so count the logic (reference) rectangle, see the EnhancedCustomShape2d ctor.
- Point aPoint(pCustomShape->GetSnapRect().Center());
- Size aSize(pCustomShape->GetLogicRect().GetSize());
+ Point aPoint(pSdrShape->GetSnapRect().Center());
+ Size aSize(pSdrShape->GetLogicRect().GetSize());
aPoint.AdjustX(-(aSize.Width() / 2));
aPoint.AdjustY(-(aSize.Height() / 2));
tools::Rectangle aLogicRect(aPoint, aSize);
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 1235469996ec..9652f7914370 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -585,16 +585,16 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
}
- if(!pShape || pShape->GetRegisteredIn() || !pShape->m_bDescriptor )
- {
- uno::RuntimeException aExcept;
- if(pShape)
- aExcept.Message = "object already inserted";
- else
- aExcept.Message = "illegal object";
- throw aExcept;
- }
+ // this is not a writer shape
+ if(!pShape)
+ throw uno::RuntimeException("illegal object",
+ static_cast< cppu::OWeakObject * > ( this ) );
+
+ // we're already registered in the model / SwXDrawPage::add() already called
+ if(pShape->GetRegisteredIn() || !pShape->m_bDescriptor )
+ return;
+ // we're inserted elsewhere already
if ( pSvxShape->GetSdrObject() )
{
if ( pSvxShape->GetSdrObject()->IsInserted() )