tdf#130362 sw: fix anchoring of inline math objects
Regression from a7528cd6f17ea5c5b29e7d607e54c62de0d9e7db (sw: insert image: set anchor to at-char by default, 2019-11-18), that defaulted to at-char anchoring for charts and images. What was not considered is that math objects had a previous as-char default (not to-para), and that is supposed to be unchanged. Change-Id: I2a91af6425035b48a0e47ad9b10939945855cd16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87976 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
parent
7ffd38fc54
commit
a2f85c062a
72
sw/CppunitTest_sw_core_doc.mk
Normal file
72
sw/CppunitTest_sw_core_doc.mk
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
|
||||||
|
#*************************************************************************
|
||||||
|
#
|
||||||
|
# This file is part of the LibreOffice project.
|
||||||
|
#
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
#
|
||||||
|
#*************************************************************************
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_CppunitTest,sw_core_doc))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_doc))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_doc, \
|
||||||
|
sw/qa/core/doc/doc \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_libraries,sw_core_doc, \
|
||||||
|
comphelper \
|
||||||
|
cppu \
|
||||||
|
cppuhelper \
|
||||||
|
sal \
|
||||||
|
sfx \
|
||||||
|
sw \
|
||||||
|
test \
|
||||||
|
unotest \
|
||||||
|
utl \
|
||||||
|
vcl \
|
||||||
|
svt \
|
||||||
|
tl \
|
||||||
|
svl \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_externals,sw_core_doc,\
|
||||||
|
boost_headers \
|
||||||
|
libxml2 \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_set_include,sw_core_doc,\
|
||||||
|
-I$(SRCDIR)/sw/inc \
|
||||||
|
-I$(SRCDIR)/sw/source/core/inc \
|
||||||
|
-I$(SRCDIR)/sw/source/uibase/inc \
|
||||||
|
-I$(SRCDIR)/sw/qa/inc \
|
||||||
|
$$(INCLUDE) \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_api,sw_core_doc,\
|
||||||
|
udkapi \
|
||||||
|
offapi \
|
||||||
|
oovbaapi \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_ure,sw_core_doc))
|
||||||
|
$(eval $(call gb_CppunitTest_use_vcl,sw_core_doc))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_rdb,sw_core_doc,services))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_doc,\
|
||||||
|
officecfg/registry \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_configuration,sw_core_doc))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_doc, \
|
||||||
|
modules/swriter \
|
||||||
|
))
|
||||||
|
|
||||||
|
$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_doc))
|
||||||
|
|
||||||
|
# vim: set noet sw=4 ts=4:
|
@ -105,6 +105,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
|
|||||||
CppunitTest_sw_apitests \
|
CppunitTest_sw_apitests \
|
||||||
CppunitTest_sw_unowriter \
|
CppunitTest_sw_unowriter \
|
||||||
CppunitTest_sw_core_text \
|
CppunitTest_sw_core_text \
|
||||||
|
CppunitTest_sw_core_doc \
|
||||||
CppunitTest_sw_uibase_shells \
|
CppunitTest_sw_uibase_shells \
|
||||||
CppunitTest_sw_core_accessibilitycheck \
|
CppunitTest_sw_core_accessibilitycheck \
|
||||||
))
|
))
|
||||||
|
@ -180,7 +180,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual SwFlyFrameFormat* InsertEmbObject(
|
virtual SwFlyFrameFormat* InsertEmbObject(
|
||||||
const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
|
const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
|
||||||
const SfxItemSet* pFlyAttrSet) = 0;
|
SfxItemSet* pFlyAttrSet) = 0;
|
||||||
|
|
||||||
virtual SwFlyFrameFormat* InsertOLE(
|
virtual SwFlyFrameFormat* InsertOLE(
|
||||||
const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect,
|
const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect,
|
||||||
|
@ -626,7 +626,7 @@ public:
|
|||||||
bool GetPageNumber( long nYPos, bool bAtCursorPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, OUString &rDisplay ) const;
|
bool GetPageNumber( long nYPos, bool bAtCursorPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, OUString &rDisplay ) const;
|
||||||
|
|
||||||
SwFlyFrameFormat* InsertObject( const svt::EmbeddedObjectRef&,
|
SwFlyFrameFormat* InsertObject( const svt::EmbeddedObjectRef&,
|
||||||
const SfxItemSet* pFlyAttrSet );
|
SfxItemSet* pFlyAttrSet );
|
||||||
bool FinishOLEObj(); ///< Shutdown server.
|
bool FinishOLEObj(); ///< Shutdown server.
|
||||||
|
|
||||||
void GetTableAttr( SfxItemSet & ) const;
|
void GetTableAttr( SfxItemSet & ) const;
|
||||||
|
65
sw/qa/core/doc/doc.cxx
Normal file
65
sw/qa/core/doc/doc.cxx
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* This file is part of the LibreOffice project.
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <swmodeltestbase.hxx>
|
||||||
|
|
||||||
|
#include <vcl/gdimtf.hxx>
|
||||||
|
#include <comphelper/classids.hxx>
|
||||||
|
#include <tools/globname.hxx>
|
||||||
|
#include <svtools/embedhlp.hxx>
|
||||||
|
|
||||||
|
#include <wrtsh.hxx>
|
||||||
|
#include <fmtanchr.hxx>
|
||||||
|
|
||||||
|
static char const DATA_DIRECTORY[] = "/sw/qa/core/doc/data/";
|
||||||
|
|
||||||
|
/// Covers sw/source/core/doc/ fixes.
|
||||||
|
class SwCoreDocTest : public SwModelTestBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SwDoc* createDoc(const char* pName = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
SwDoc* SwCoreDocTest::createDoc(const char* pName)
|
||||||
|
{
|
||||||
|
if (!pName)
|
||||||
|
loadURL("private:factory/swriter", nullptr);
|
||||||
|
else
|
||||||
|
load(DATA_DIRECTORY, pName);
|
||||||
|
|
||||||
|
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
|
||||||
|
CPPUNIT_ASSERT(pTextDoc);
|
||||||
|
return pTextDoc->GetDocShell()->GetDoc();
|
||||||
|
}
|
||||||
|
|
||||||
|
CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testMathInsertAnchorType)
|
||||||
|
{
|
||||||
|
// Given an empty document.
|
||||||
|
SwDoc* pDoc = createDoc();
|
||||||
|
|
||||||
|
// When inserting an a math object.
|
||||||
|
SwWrtShell* pShell = pDoc->GetDocShell()->GetWrtShell();
|
||||||
|
SvGlobalName aGlobalName(SO3_SM_CLASSID);
|
||||||
|
pShell->InsertObject(svt::EmbeddedObjectRef(), &aGlobalName);
|
||||||
|
|
||||||
|
// Then the anchor type should be as-char.
|
||||||
|
SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
|
||||||
|
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rFormats.size());
|
||||||
|
const SwFrameFormat& rFormat = *rFormats[0];
|
||||||
|
const SwFormatAnchor& rAnchor = rFormat.GetAnchor();
|
||||||
|
// Without the accompanying fix in place, this test would have failed with:
|
||||||
|
// - Expected: 1
|
||||||
|
// - Actual : 4
|
||||||
|
// i.e. the anchor type was at-char, not as-char.
|
||||||
|
CPPUNIT_ASSERT_EQUAL(RndStdIds::FLY_AS_CHAR, rAnchor.GetAnchorId());
|
||||||
|
}
|
||||||
|
|
||||||
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@ -2856,14 +2856,22 @@ SwFlyFrameFormat* DocumentContentOperationsManager::InsertGraphicObject(
|
|||||||
|
|
||||||
SwFlyFrameFormat* DocumentContentOperationsManager::InsertEmbObject(
|
SwFlyFrameFormat* DocumentContentOperationsManager::InsertEmbObject(
|
||||||
const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
|
const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
|
||||||
const SfxItemSet* pFlyAttrSet)
|
SfxItemSet* pFlyAttrSet)
|
||||||
{
|
{
|
||||||
sal_uInt16 nId = RES_POOLFRM_OLE;
|
sal_uInt16 nId = RES_POOLFRM_OLE;
|
||||||
if (xObj.is())
|
if (xObj.is())
|
||||||
{
|
{
|
||||||
SvGlobalName aClassName( xObj->getClassID() );
|
SvGlobalName aClassName( xObj->getClassID() );
|
||||||
if (SotExchange::IsMath(aClassName))
|
if (SotExchange::IsMath(aClassName))
|
||||||
|
{
|
||||||
nId = RES_POOLFRM_FORMEL;
|
nId = RES_POOLFRM_FORMEL;
|
||||||
|
if (pFlyAttrSet && pFlyAttrSet->HasItem(RES_ANCHOR))
|
||||||
|
{
|
||||||
|
// Clear the at-char anchor set in the SwFlyFrameAttrMgr ctor, so the as-char one
|
||||||
|
// set later in pFrameFormat is considered.
|
||||||
|
pFlyAttrSet->ClearItem(RES_ANCHOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SwFrameFormat* pFrameFormat = m_rDoc.getIDocumentStylePoolAccess().GetFrameFormatFromPool( nId );
|
SwFrameFormat* pFrameFormat = m_rDoc.getIDocumentStylePoolAccess().GetFrameFormatFromPool( nId );
|
||||||
|
@ -881,7 +881,7 @@ void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SwFlyFrameFormat* SwFEShell::InsertObject( const svt::EmbeddedObjectRef& xObj,
|
SwFlyFrameFormat* SwFEShell::InsertObject( const svt::EmbeddedObjectRef& xObj,
|
||||||
const SfxItemSet* pFlyAttrSet )
|
SfxItemSet* pFlyAttrSet )
|
||||||
{
|
{
|
||||||
SwFlyFrameFormat* pFormat = nullptr;
|
SwFlyFrameFormat* pFormat = nullptr;
|
||||||
SET_CURR_SHELL( this );
|
SET_CURR_SHELL( this );
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
SwDrawFrameFormat* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) override;
|
SwDrawFrameFormat* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) override;
|
||||||
|
|
||||||
SwFlyFrameFormat* InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet) override;
|
SwFlyFrameFormat* InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, SfxItemSet* pFlyAttrSet) override;
|
||||||
|
|
||||||
SwFlyFrameFormat* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
|
SwFlyFrameFormat* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
|
||||||
const SfxItemSet* pGrfAttrSet) override;
|
const SfxItemSet* pGrfAttrSet) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user