From 7413cc96d239f5fd5a588f13784ccb82b6968bac Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 11 Jun 2021 11:41:41 +0200 Subject: sw image anchor type: consider a style-based custom value The anchor type is determined during insertion, it's stored as direct formatting after that. We used to have a user-profile default for the anchor type. This commit allows customizing the Graphics or OLE styles: if they specify a custom anchor type, then that is user instead of the user profile setting. This allows creating templates where the default depends on the used template and not on the user profile. The UI for this was added in commit 5951da5175b9d7e5b3b47bd0d90989d2ef528c79 (sw image anchor type: add style UI for this, 2021-06-10). Change-Id: Id05342a5f38dc6267cdbe68b248dc50b87854ce2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117040 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- sw/source/uibase/frmdlg/frmmgr.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'sw/source') diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx index fa5991baac56..2146b05d44e9 100644 --- a/sw/source/uibase/frmdlg/frmmgr.cxx +++ b/sw/source/uibase/frmdlg/frmmgr.cxx @@ -92,7 +92,19 @@ SwFlyFrameAttrMgr::SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, Frmmgr_Type nT { // Default anchor for new graphics and objects is at-char, except for Math objects. SwViewOption aViewOpt(*pSh->GetViewOptions()); - m_aSet.Put(SwFormatAnchor(aViewOpt.GetDefaultAnchorType()));//RndStdIds::FLY_AT_CHAR + + RndStdIds eAnchorType = aViewOpt.GetDefaultAnchorType(); + + const SwFormatAnchor rStyleAnchor + = m_pOwnSh->GetFormatFromPool(nId)->GetAttrSet().GetAnchor(); + if (rStyleAnchor.GetAnchorId() != RndStdIds::FLY_AT_PARA) + { + // The style has a custom anchor type, prefer that over the user profile + // default. + eAnchorType = rStyleAnchor.GetAnchorId(); + } + + m_aSet.Put(SwFormatAnchor(eAnchorType)); } } } -- cgit v1.2.3