summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-07-04 15:50:31 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-07-04 16:40:51 +0200
commit4f40bf6a79de6d60da0a5090cdfeda6242e889f0 (patch)
tree3ae655257328ca70c26debbacbdc183f80f93185
parentad8f4c4432e0c5c052b6f87977d1ad8663debe09 (diff)
sw: insert image: set anchor to as-char by default
See the mailing list thread at https://www.mail-archive.com/search?l=mid&q=999e55c8-5d15-1014-e6f9-9f3d19d003af@collabora.com (minutes of ESC call ..., 2019-05-09) for motivation, this is meant to improve Word compatibility, by not defaulting to the at-paragraph anchor type, which is unavailable in Word. See tdf#45778 and tdf#87720 for related bugs. Change-Id: I2699ce04dce02e8436dc3af3b2cc8778f8dc476c Reviewed-on: https://gerrit.libreoffice.org/75091 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx13
-rw-r--r--sw/source/uibase/frmdlg/frmmgr.cxx5
2 files changed, 18 insertions, 0 deletions
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index 31c7571b7153..ae042c1210a3 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -27,6 +27,8 @@
#include <PostItMgr.hxx>
#include <postithelper.hxx>
#include <AnnotationWin.hxx>
+#include <flyfrm.hxx>
+#include <fmtanchr.hxx>
using namespace ::com::sun::star;
@@ -521,6 +523,17 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testPasteListener)
OUString aGraphicURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "test.jpg";
rView.InsertGraphic(aGraphicURL, OUString(), /*bAsLink=*/false,
&GraphicFilter::GetGraphicFilter());
+
+ // Test that the pasted image is anchored as-char.
+ SwFlyFrame* pFly = pWrtShell->GetSelectedFlyFrame();
+ CPPUNIT_ASSERT(pFly);
+ SwFrameFormat* pFlyFormat = pFly->GetFormat();
+ CPPUNIT_ASSERT(pFlyFormat);
+ RndStdIds eFlyAnchor = pFlyFormat->GetAnchor().GetAnchorId();
+ // Without the working image listener in place, this test would have
+ // failed, eFlyAnchor was FLY_AT_PARA.
+ CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AS_CHAR, eFlyAnchor);
+
pTransfer->Cut();
pListener->GetString().clear();
SwTransferable::Paste(*pWrtShell, aHelper);
diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx
index 5dbca0fcfe59..2c2205b1597c 100644
--- a/sw/source/uibase/frmdlg/frmmgr.cxx
+++ b/sw/source/uibase/frmdlg/frmmgr.cxx
@@ -85,6 +85,11 @@ SwFlyFrameAttrMgr::SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, Frmmgr_Type nT
m_aSet.Put( SwFormatFrameSize( ATT_MIN_SIZE, DFLT_WIDTH, DFLT_HEIGHT ));
if ( 0 != ::GetHtmlMode(pSh->GetView().GetDocShell()) )
m_aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::PRINT_AREA ) );
+
+ if (nType == Frmmgr_Type::GRF || nType == Frmmgr_Type::OLE)
+ {
+ m_aSet.Put(SwFormatAnchor(RndStdIds::FLY_AS_CHAR));
+ }
}
else if ( nType == Frmmgr_Type::NONE )
{