sw/qa/extras/odfexport/data/framebackgrounds.odt |binary sw/qa/extras/odfexport/data/redlineTextFrame.odt |binary sw/qa/extras/odfexport/odfexport.cxx | 135 +++++++++++++++++++++++ sw/source/core/txtnode/atrflyin.cxx | 21 ++- sw/source/core/txtnode/thints.cxx | 39 ------ 5 files changed, 156 insertions(+), 39 deletions(-)
New commits: commit 0862b439a3040fed41bc7b5e786ea0652589f664 Author: Varun <[email protected]> Date: Fri Jun 12 21:31:26 2015 +0530 Added test for redline with as-char frame fixed by commits 4dd2e61 and fae87e0 Change-Id: Ib6ca689af61187b32283753f80abaed96406f409 Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit f36ac1aa3bef5ba218f3dae24f260ce7e4afba95) Signed-off-by: Michael Stahl <[email protected]> diff --git a/sw/qa/extras/odfexport/data/redlineTextFrame.odt b/sw/qa/extras/odfexport/data/redlineTextFrame.odt new file mode 100644 index 0000000..0986c37 Binary files /dev/null and b/sw/qa/extras/odfexport/data/redlineTextFrame.odt differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index fbdd3c0..6cfd040 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -197,6 +197,15 @@ DECLARE_ODFEXPORT_TEST(testFramebackgrounds, "framebackgrounds.odt") } } +DECLARE_ODFEXPORT_TEST(testredlineTextFrame, "redlineTextFrame.odt") +{ + //Note this is for a crash test + //Counting the Number of Frames and checking with the expected count + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); +} + DECLARE_ODFEXPORT_TEST(testFdo38244, "fdo38244.odt") { // See ooxmlexport's testFdo38244(). commit f21bf5984269c4d96d5290e8127b383f26c36e08 Author: Michael Stahl <[email protected]> Date: Fri Jun 12 17:04:45 2015 +0200 tdf#91228: need to check the format's IsLockModified(), not the node's commit 9f01951b858453684f2622541af0eb85d4544fc6 also did the extra Remove/Add for Draw fly objects, and it turns out that that's actually wrong because SwTextFlyCnt::SetAnchor() will set the anchor without locking anything if it's a Draw object. Replace it with a different hack in SetAnchor() that applies only if it calls LockModify(). Thanks to Varun Dhall for creating a reproducer document. Not sure if the LockModify() could be replaced completely, perhaps it's just an optimization to avoid re-creating layout frames for the fly. (cherry picked from commit fae87e03ea3829718ec0381ed3b04ceb52c23720) Conflicts: sw/source/core/txtnode/atrflyin.cxx Change-Id: Ib3236f289c2c4202d48ac378a53ce02130d4ce2c diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index bca151d..7894854 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -150,13 +150,19 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode ) SwPosition aPos( *pNode->StartOfSectionNode(), aIdx ); SwFrameFormat* pFormat = GetFlyCnt().GetFrameFormat(); SwFormatAnchor aAnchor( pFormat->GetAnchor() ); + SwNode *const pOldNode(aAnchor.GetContentAnchor() + ? &aAnchor.GetContentAnchor()->nNode.GetNode() + : nullptr); - if( !aAnchor.GetContentAnchor() || - !aAnchor.GetContentAnchor()->nNode.GetNode().GetNodes().IsDocNodes() || - &aAnchor.GetContentAnchor()->nNode.GetNode() != (SwNode*)pNode ) + if (!pOldNode || !pOldNode->GetNodes().IsDocNodes() || + pOldNode != static_cast<SwNode const *>(pNode)) + { aPos.nNode = *pNode; + } else - aPos.nNode = aAnchor.GetContentAnchor()->nNode; + { + aPos.nNode = *pOldNode; + } aAnchor.SetType( FLY_AS_CHAR ); // default! aAnchor.SetAnchor( &aPos ); @@ -186,10 +192,17 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode ) { pFormat->LockModify(); pFormat->SetFormatAttr( aAnchor ); // nur den Anker neu setzen + // tdf#91228 must notify the anchor nodes despite LockModify + assert(pOldNode); + pOldNode->RemoveAnchoredFly(pFormat); + aPos.nNode.GetNode().AddAnchoredFly(pFormat); pFormat->UnlockModify(); } else + { + assert(!pFormat->IsModifyLocked()); // need to notify anchor node pFormat->SetFormatAttr( aAnchor ); // nur den Anker neu setzen + } // Am Node haengen u.a. abhaengige CntFrms. // Fuer jeden CntFrm wird ein SwFlyInCntFrm angelegt. diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 2fb71d2..452ae53 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1276,45 +1276,19 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode ) { SwTextFlyCnt *pFly = static_cast<SwTextFlyCnt *>(pAttr); SwFrameFormat* pFormat = pAttr->GetFlyCnt().GetFrameFormat(); - - // In order to maintain data coherency, if the hint is a fly - // moved from a text node to another, we have to remove it from - // the first textnode then to add it to the new (this) textnode - const SwFormatAnchor* pAnchor = 0; - pFormat->GetItemState( RES_ANCHOR, false, - reinterpret_cast<const SfxPoolItem**>(&pAnchor) ); - - SwIndex aIdx( this, pAttr->GetStart() ); - - bool bChangeFlyParentNode( false ); - if (pAnchor && - pAnchor->GetAnchorId() == FLY_AS_CHAR && - pAnchor->GetContentAnchor() && - pAnchor->GetContentAnchor()->nNode != *this) - { - assert(pAnchor->GetContentAnchor()->nNode.GetNode().IsTextNode()); - SwTextNode* textNode = pAnchor->GetContentAnchor()->nNode.GetNode().GetTextNode(); - - if ( textNode->IsModifyLocked() ) - { - // Fly parent has changed but the FlyFormat is locked, so it will - // not be updated by SetAnchor (that calls Modify that updates - // relationships) - textNode->RemoveAnchoredFly( pFormat ); - bChangeFlyParentNode = true; - } - } - if( !(SetAttrMode::NOTXTATRCHR & nInsMode) ) { - // Wir muessen zuerst einfuegen, da in SetAnchor() // dem FlyFrm GetStart() uebermittelt wird. //JP 11.05.98: falls das Anker-Attribut schon richtig // gesetzt ist, dann korrigiere dieses nach dem Einfuegen // des Zeichens. Sonst muesste das immer ausserhalb // erfolgen (Fehleranfaellig !) + const SwFormatAnchor* pAnchor = 0; + pFormat->GetItemState( RES_ANCHOR, false, + reinterpret_cast<const SfxPoolItem**>(&pAnchor) ); + SwIndex aIdx( this, pAttr->GetStart() ); const OUString c(GetCharOfTextAttr(*pAttr)); OUString const ins( InsertText(c, aIdx, nInsertFlags) ); if (ins.isEmpty()) @@ -1378,11 +1352,6 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode ) return false; } } - - // Finish relationships update now that SetAnchor has fixed part of it. - if (bChangeFlyParentNode) - AddAnchoredFly( pFormat ); - break; } commit 662ec2f1a7bc5472bd73b75f101786afa33dad7c Author: Michael Stahl <[email protected]> Date: Wed Jun 10 22:47:48 2015 +0200 tdf#90640: add a unit test for this Change-Id: I72aecb66d0de4ba2bc3a44f664aab8170ffb3d0f (cherry picked from commit dc4d9481f36a18db1dfe3b931780edbe32266e5f) diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index aeb72e5..fbdd3c0 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -184,6 +184,17 @@ DECLARE_ODFEXPORT_TEST(testFramebackgrounds, "framebackgrounds.odt") CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xTextFrame, "FillBitmapTile")); aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, "FillTransparenceGradient"); CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style); + + if (xmlDocPtr pXmlDoc = parseExport("content.xml")) + { + // check that there are 3 background-image elements + assertXPath(pXmlDoc, "//style:style[@style:parent-style-name='Frame' and @style:family='graphic']/style:graphic-properties[@draw:fill='bitmap']/style:background-image[@style:repeat='stretch']", 3); + // tdf#90640: check that one of them is 55% opaque + assertXPath(pXmlDoc, "//style:style[@style:parent-style-name='Frame' and @style:family='graphic']/style:graphic-properties[@draw:fill='bitmap' and @fo:background-color='transparent' and @draw:opacity='55%']/style:background-image[@style:repeat='stretch' and @draw:opacity='55%']", 1); + // tdf#90640: check that one of them is 43% opaque + // (emulated - hopefully not with rounding errors) + assertXPath(pXmlDoc, "//style:style[@style:parent-style-name='Frame' and @style:family='graphic']/style:graphic-properties[@draw:fill='bitmap' and @fo:background-color='transparent' and @draw:opacity-name='Transparency_20_1']/style:background-image[@style:repeat='stretch' and @draw:opacity='43%']", 1); + } } DECLARE_ODFEXPORT_TEST(testFdo38244, "fdo38244.odt") commit 3e4ed2fc59451177f34e0689ef15d869555912c5 Author: Varun Dhall <[email protected]> Date: Wed May 27 13:58:23 2015 +0200 add test for frame backgrounds Change-Id: I39766373811a48a683706c391aa46a9bf89b3462 Reviewed-on: https://gerrit.libreoffice.org/15924 Reviewed-by: Björn Michaelsen <[email protected]> Tested-by: Björn Michaelsen <[email protected]> (cherry picked from commit da79caf3e1d28cfc418073ff398270a384c162a5) Signed-off-by: Michael Stahl <[email protected]> diff --git a/sw/qa/extras/odfexport/data/framebackgrounds.odt b/sw/qa/extras/odfexport/data/framebackgrounds.odt new file mode 100644 index 0000000..9ad338c Binary files /dev/null and b/sw/qa/extras/odfexport/data/framebackgrounds.odt differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 848bec8..aeb72e5 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -71,6 +71,121 @@ public: } }; +DECLARE_ODFEXPORT_TEST(testFramebackgrounds, "framebackgrounds.odt") +{ + //Counting the Number of Frames and checking with the expected count + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(16), xIndexAccess->getCount()); + uno::Reference<drawing::XShape> xTextFrame; + awt::Gradient aGradientxTextFrame; + //Frame 1 + xTextFrame = getShape(1); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + //Frame 2 + xTextFrame = getShape(2); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x006600), getProperty<util::Color>(xTextFrame, "FillColor")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + //Frame 3 + xTextFrame = getShape(3); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x006600), getProperty<util::Color>(xTextFrame, "FillColor")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + //Frame 4 + xTextFrame = getShape(4); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x579D1C), getProperty<util::Color>(xTextFrame, "FillColor")); + aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, "FillTransparenceGradient"); + CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style); + //Frame 5 + xTextFrame = getShape(5); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + CPPUNIT_ASSERT_EQUAL(OUString("Subtle Tango Green"), getProperty<OUString>(xTextFrame, "FillGradientName")); + //Frame 6 + xTextFrame = getShape(6); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Subtle Tango Green"), getProperty<OUString>(xTextFrame, "FillGradientName")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + //Frame 7 + xTextFrame = getShape(7); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Subtle Tango Green"), getProperty<OUString>(xTextFrame, "FillGradientName")); + aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, "FillTransparenceGradient"); + CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style); + //Frame 8 + xTextFrame = getShape(8); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty<OUString>(xTextFrame, "FillHatchName")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty<sal_Bool>(xTextFrame, "FillBackground")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + //Frame 9 + xTextFrame = getShape(9); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty<OUString>(xTextFrame, "FillHatchName")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xTextFrame, "FillBackground")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + //Frame 10 + xTextFrame = getShape(10); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty<OUString>(xTextFrame, "FillHatchName")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty<sal_Bool>(xTextFrame, "FillBackground")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + //Frame 11 + xTextFrame = getShape(11); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty<OUString>(xTextFrame, "FillHatchName")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xTextFrame, "FillBackground")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + //Frame 12 + xTextFrame = getShape(12); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty<OUString>(xTextFrame, "FillHatchName")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(false), getProperty<sal_Bool>(xTextFrame, "FillBackground")); + aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, "FillTransparenceGradient"); + CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style); + //Frame 13 + xTextFrame = getShape(13); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_HATCH, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Black 0 Degrees"), getProperty<OUString>(xTextFrame, "FillHatchName")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xTextFrame, "FillBackground")); + aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, "FillTransparenceGradient"); + CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style); + //Frame 14 + xTextFrame = getShape(14); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty<OUString>(xTextFrame, "FillBitmapName")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapPositionOffsetX")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapPositionOffsetY")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapOffsetX")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapOffsetY")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xTextFrame, "FillBitmapTile")); + //Frame 15 + xTextFrame = getShape(15); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty<OUString>(xTextFrame, "FillBitmapName")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(45), getProperty<sal_Int32>(xTextFrame, "FillTransparence")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapPositionOffsetX")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapPositionOffsetY")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapOffsetX")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapOffsetY")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xTextFrame, "FillBitmapTile")); + //Frame 16 + xTextFrame = getShape(16); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xTextFrame, "FillStyle")); + CPPUNIT_ASSERT_EQUAL(OUString("Sky"), getProperty<OUString>(xTextFrame, "FillBitmapName")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapPositionOffsetX")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapPositionOffsetY")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapOffsetX")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xTextFrame, "FillBitmapOffsetY")); + CPPUNIT_ASSERT_EQUAL(sal_Bool(true), getProperty<sal_Bool>(xTextFrame, "FillBitmapTile")); + aGradientxTextFrame = getProperty<awt::Gradient>(xTextFrame, "FillTransparenceGradient"); + CPPUNIT_ASSERT_EQUAL(css::awt::GradientStyle_LINEAR, aGradientxTextFrame.Style); +} + DECLARE_ODFEXPORT_TEST(testFdo38244, "fdo38244.odt") { // See ooxmlexport's testFdo38244().
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
