Kaydet (Commit) aafafca6 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Aron Budea

tdf#122942 sw: update shape insert UI for the AddVerticalFrameOffsets option

Regression from commit 50223ea6
(tdf#98987 sw: add AddVerticalFrameOffsets compat mode, 2016-03-31),
SwFEShell::ImpEndCreate() was not adapted to call
SwTextFrame::GetBaseVertOffsetForFly() when determining the vertical
position of the inserted shape.

The call can be unconditional, the returned value is already 0 when the
DocumentSettingId::ADD_VERTICAL_FLY_OFFSETS compat setting is false.

(cherry picked from commit 4218caf1)

Conflicts:
	sw/qa/extras/uiwriter/uiwriter2.cxx

Change-Id: Iec6af5a6d1ff3466e08377853cc8ca84f33a76d1
Reviewed-on: https://gerrit.libreoffice.org/71126Reviewed-by: 's avatarAron Budea <aron.budea@collabora.com>
Tested-by: 's avatarAron Budea <aron.budea@collabora.com>
üst 3e949896
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <fmtornt.hxx> #include <fmtornt.hxx>
#include <xmloff/odffields.hxx> #include <xmloff/odffields.hxx>
#include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/DispatchHelper.hpp>
#include <fmtornt.hxx>
namespace namespace
{ {
...@@ -43,6 +44,7 @@ public: ...@@ -43,6 +44,7 @@ public:
void testCheckboxFormFieldInsertion(); void testCheckboxFormFieldInsertion();
void testDropDownFormFieldInsertion(); void testDropDownFormFieldInsertion();
void testMixedFormFieldInsertion(); void testMixedFormFieldInsertion();
void testTdf122942();
CPPUNIT_TEST_SUITE(SwUiWriterTest2); CPPUNIT_TEST_SUITE(SwUiWriterTest2);
CPPUNIT_TEST(testTdf101534); CPPUNIT_TEST(testTdf101534);
...@@ -54,6 +56,7 @@ public: ...@@ -54,6 +56,7 @@ public:
CPPUNIT_TEST(testCheckboxFormFieldInsertion); CPPUNIT_TEST(testCheckboxFormFieldInsertion);
CPPUNIT_TEST(testDropDownFormFieldInsertion); CPPUNIT_TEST(testDropDownFormFieldInsertion);
CPPUNIT_TEST(testMixedFormFieldInsertion); CPPUNIT_TEST(testMixedFormFieldInsertion);
CPPUNIT_TEST(testTdf122942);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -67,14 +70,17 @@ SwDoc* SwUiWriterTest2::createDoc(const char* pName) ...@@ -67,14 +70,17 @@ SwDoc* SwUiWriterTest2::createDoc(const char* pName)
else else
load(DATA_DIRECTORY, pName); load(DATA_DIRECTORY, pName);
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDoc); CPPUNIT_ASSERT(pTextDoc);
return pTextDoc->GetDocShell()->GetDoc(); return pTextDoc->GetDocShell()->GetDoc();
} }
static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rPropertyValues) static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent,
const OUString& rCommand,
const uno::Sequence<beans::PropertyValue>& rPropertyValues)
{ {
uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController(); uno::Reference<frame::XController> xController
= uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController();
CPPUNIT_ASSERT(xController.is()); CPPUNIT_ASSERT(xController.is());
uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY);
CPPUNIT_ASSERT(xFrame.is()); CPPUNIT_ASSERT(xFrame.is());
...@@ -425,6 +431,37 @@ void SwUiWriterTest2::testMixedFormFieldInsertion() ...@@ -425,6 +431,37 @@ void SwUiWriterTest2::testMixedFormFieldInsertion()
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pMarkAccess->getAllMarksCount()); CPPUNIT_ASSERT_EQUAL(sal_Int32(3), pMarkAccess->getAllMarksCount());
} }
void SwUiWriterTest2::testTdf122942()
{
load(DATA_DIRECTORY, "tdf122942.odt");
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
// Do the moral equivalent of mouse button down, move and up.
// Start creating a custom shape that overlaps with the rounded rectangle
// already present in the document.
Point aStartPos(8000, 3000);
pWrtShell->BeginCreate(static_cast<sal_uInt16>(OBJ_CUSTOMSHAPE), aStartPos);
// Set its size.
Point aMovePos(10000, 5000);
pWrtShell->MoveCreate(aMovePos);
// Finish creation.
pWrtShell->EndCreate(SdrCreateCmd::ForceEnd);
// Make sure that the shape is inserted.
SwDoc* pDoc = pWrtShell->GetDoc();
const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size());
// Without the accompanying fix in place, this test would have failed with
// 'Expected less than: 0; Actual : 1030', i.e. the shape was below the
// paragraph mark, not above it.
const SwFormatVertOrient& rVert = rFormats[1]->GetVertOrient();
CPPUNIT_ASSERT_LESS(static_cast<SwTwips>(0), rVert.GetPos());
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2); CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1936,17 +1936,22 @@ bool SwFEShell::ImpEndCreate() ...@@ -1936,17 +1936,22 @@ bool SwFEShell::ImpEndCreate()
nXOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right(); nXOffset = pAnch->getFrameArea().Left()+pAnch->getFrameArea().Width()-rBound.Right();
else else
nXOffset = rBound.Left() - pAnch->getFrameArea().Left(); nXOffset = rBound.Left() - pAnch->getFrameArea().Left();
if( pAnch->IsTextFrame() && static_cast<const SwTextFrame*>(pAnch)->IsFollow() ) if (pAnch->IsTextFrame())
{ {
const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch); const SwTextFrame* pTmp = static_cast<const SwTextFrame*>(pAnch);
do { if (pTmp->IsFollow())
pTmp = pTmp->FindMaster(); {
OSL_ENSURE( pTmp, "Where's my Master?" ); do {
// OD 2004-03-30 #i26791# - correction: add frame area height pTmp = pTmp->FindMaster();
// of master frames. OSL_ENSURE(pTmp, "Where's my Master?");
nYOffset += pTmp->IsVertical() ? // OD 2004-03-30 #i26791# - correction: add frame area height
pTmp->getFrameArea().Width() : pTmp->getFrameArea().Height(); // of master frames.
} while ( pTmp->IsFollow() ); nYOffset += pTmp->IsVertical() ?
pTmp->getFrameArea().Width() : pTmp->getFrameArea().Height();
} while (pTmp->IsFollow());
}
nYOffset -= pTmp->GetBaseVertOffsetForFly(false);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment