summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorAttila Bakos <bakos.attilakaroly@nisz.hu>2020-03-19 14:40:36 +0100
committerLászló Németh <nemeth@numbertext.org>2020-04-07 12:44:17 +0200
commit27d04f6dbf38aa28fb7215590d578c4567db5770 (patch)
tree1243823be2e628f88b10492ba9f68836e6793af0 /writerfilter
parent9977fbeed1461a8f5cfa8029c02e914c099f3230 (diff)
tdf#119038 DOCX: fix FollowTextFlow handling
This fix also a clean-up for the following commits: ad8857dab30e099a0cf6ec18d184a6c836b33317 (tdf#130120 DOCX: export o:allowincell) 14ad64270e4fbca3c24da6f55f260b1fb229556a (tdf#129888 DOCX shape import: handle o:allowincell) 10f29d8bf05d44ca8bc11d34d1294ec17f8ac0f1 (tdf#87569 tdf#109411 DOCX import: fix shape anchor in tables) where these patches ignored the option "Follow text flow" and there was no possibility to switch this setting on GUI. Now this is handled on GUI as well by replacing the grab-bag with UNO property "IsFollowingTextFlow". The tdf#119038 bug also fixed. Note: Unit tests for the commits mentioned above were modified for testing the new property, so new tests were not added. Change-Id: Ie35c6e280f8b33d8535ca4cd9749f110f9d592ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90753 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx33
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx37
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.hxx3
3 files changed, 21 insertions, 52 deletions
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 21570269db42..ce449a6251b2 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -270,7 +270,7 @@ public:
,nVertOrient( text::VertOrientation::NONE )
,nVertRelation( text::RelOrientation::FRAME )
,nWrap(text::WrapTextMode_NONE)
- ,bLayoutInCell(false)
+ ,bLayoutInCell(true)
,bOpaque( !rDMapper.IsInHeaderFooter() )
,bContour(false)
,bContourOutside(true)
@@ -662,7 +662,6 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
{
uno::Reference< drawing::XShape> xShape;
rValue.getAny( ) >>= xShape;
-
if ( xShape.is( ) )
{
// Is it a graphic image
@@ -847,7 +846,12 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
eAnchorType = text::TextContentAnchorType_AT_CHARACTER;
xShapeProps->setPropertyValue("AnchorType", uno::makeAny(eAnchorType));
-
+ if (m_pImpl->bLayoutInCell && bTextBox && m_pImpl->rDomainMapper.IsInTable()
+ && m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME)
+ m_pImpl->nHoriRelation = text::RelOrientation::FRAME;
+ if(m_pImpl->rDomainMapper.IsInTable())
+ xShapeProps->setPropertyValue(getPropertyName(PROP_FOLLOW_TEXT_FLOW),
+ uno::makeAny(m_pImpl->bLayoutInCell));
//only the position orientation is handled in applyPosition()
m_pImpl->applyPosition(xShapeProps);
@@ -884,25 +888,6 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(nRotation));
}
- //tdf#109411 If anchored object is in table, Word calculates its position from cell border
- //instead of page (what is set in the sample document)
- if (xShapeProps)
- {
- uno::Sequence<beans::PropertyValue> aShapeGrabBag;
- xShapeProps->getPropertyValue("InteropGrabBag") >>= aShapeGrabBag;
- beans::PropertyValue aLayInCell;
- aLayInCell.Name = "LayoutInCell";
- aLayInCell.Value <<= m_pImpl->bLayoutInCell;
- aShapeGrabBag.realloc(1 + aShapeGrabBag.size());
- aShapeGrabBag[aShapeGrabBag.size() - 1] = aLayInCell;
- xShapeProps->setPropertyValue("InteropGrabBag",
- uno::makeAny(aShapeGrabBag));
- }
- if (m_pImpl->rDomainMapper.IsInTable() && m_pImpl->bLayoutInCell &&
- m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME && IsGraphic())
- {
- m_pImpl->nHoriRelation = text::RelOrientation::FRAME;
- }
m_pImpl->applyRelativePosition(xShapeProps, /*bRelativeOnly=*/true);
@@ -1370,9 +1355,9 @@ uno::Reference<text::XTextContent> GraphicImport::createGraphicObject(uno::Refer
}
xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_SURROUND ),
uno::makeAny(static_cast<sal_Int32>(m_pImpl->nWrap)));
- if( m_pImpl->rDomainMapper.IsInTable() && m_pImpl->bLayoutInCell )
+ if( m_pImpl->rDomainMapper.IsInTable())
xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_FOLLOW_TEXT_FLOW ),
- uno::makeAny(true));
+ uno::makeAny(m_pImpl->bLayoutInCell));
xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_SURROUND_CONTOUR ),
uno::makeAny(m_pImpl->bContour));
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index e369705fc5d3..02a9c782f707 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -37,6 +37,7 @@
#include <dmapper/PropertyIds.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include <dmapper/PropertyIds.hxx>
static const sal_Unicode uCR = 0xd;
static const sal_Unicode uFtnEdnRef = 0x2;
@@ -69,7 +70,8 @@ OOXMLFastContextHandler::OOXMLFastContextHandler
mpStream(nullptr),
mnTableDepth(0),
inPositionV(false),
- mbLayoutInCell(true),
+ mbAllowInCell(true),
+ mbIsVMLfound(false),
m_xContext(context),
m_bDiscardChildren(false),
m_bTookChoice(false)
@@ -90,7 +92,8 @@ OOXMLFastContextHandler::OOXMLFastContextHandler(OOXMLFastContextHandler * pCont
mpParserState(pContext->mpParserState),
mnTableDepth(pContext->mnTableDepth),
inPositionV(pContext->inPositionV),
- mbLayoutInCell(pContext->mbLayoutInCell),
+ mbAllowInCell(pContext->mbAllowInCell),
+ mbIsVMLfound(pContext->mbIsVMLfound),
m_xContext(pContext->m_xContext),
m_bDiscardChildren(pContext->m_bDiscardChildren),
m_bTookChoice(pContext->m_bTookChoice)
@@ -1670,34 +1673,15 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t Element )
bool bIsPicture = Element == ( NMSP_dmlPicture | XML_pic );
-
//tdf#87569: Fix table layout with correcting anchoring
//If anchored object is in table, Word calculates its position from cell border
//instead of page (what is set in the sample document)
uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY);
- if(xShapePropSet && bIsPicture) //TODO make grabbag for textboxes as well
- {
- uno::Sequence<beans::PropertyValue> aShapeGrabBag;
- xShapePropSet->getPropertyValue("InteropGrabBag") >>= aShapeGrabBag;
- beans::PropertyValue aLayInCell;
- aLayInCell.Name = "LayoutInCell";
- aLayInCell.Value <<= mbLayoutInCell;
- aShapeGrabBag.realloc(1+aShapeGrabBag.size());
- aShapeGrabBag[aShapeGrabBag.size() -1] = aLayInCell;
- xShapePropSet->setPropertyValue("InteropGrabBag", uno::makeAny(aShapeGrabBag));
- }
- if (mnTableDepth > 0 && mbLayoutInCell) //if we had a table
+ if (mnTableDepth > 0 && xShapePropSet.is() && mbIsVMLfound) //if we had a table
{
- sal_Int16 nCurrentHorOriRel = {}; // spurious -Werror=maybe-uninitialized
- xShapePropSet->getPropertyValue("HoriOrientRelation") >>= nCurrentHorOriRel;
- //and the correction:
- if (nCurrentHorOriRel == com::sun::star::text::RelOrientation::PAGE_FRAME)
- {
- xShapePropSet->setPropertyValue("HoriOrientRelation",
- uno::makeAny(text::RelOrientation::FRAME));
- }
+ xShapePropSet->setPropertyValue(dmapper::getPropertyName(dmapper::PROP_FOLLOW_TEXT_FLOW),
+ uno::makeAny(mbAllowInCell));
}
-
// Notify the dmapper that the shape is ready to use
if ( !bIsPicture )
{
@@ -1748,7 +1732,7 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
bool bGroupShape = Element == Token_t(NMSP_vml | XML_group);
// drawingML version also counts as a group shape.
bGroupShape |= mrShapeContext->getStartToken() == Token_t(NMSP_wpg | XML_wgp);
-
+ mbIsVMLfound = (getNamespace(Element) == NMSP_vmlOffice) || (getNamespace(Element) == NMSP_vml);
switch (oox::getNamespace(Element))
{
case NMSP_doc:
@@ -1771,9 +1755,8 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
this);
//tdf129888 store allowincell attribute of the VML shape
- mbLayoutInCell = true;
if (Attribs->hasAttribute(NMSP_vmlOffice | XML_allowincell))
- mbLayoutInCell
+ mbAllowInCell
= !(Attribs->getValue(NMSP_vmlOffice | XML_allowincell) == "f");
if (!bGroupShape)
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index 079d49d695c2..5bc4ea382f12 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -226,7 +226,8 @@ protected:
const css::uno::Reference< css::uno::XComponentContext >& getComponentContext() const { return m_xContext;}
bool inPositionV;
- bool mbLayoutInCell; // o:allowincell
+ bool mbAllowInCell; // o:allowincell
+ bool mbIsVMLfound;
OOXMLValue::Pointer_t mpGridAfter;
private: