sw/inc/IDocumentSettingAccess.hxx | 2 ++ sw/source/core/doc/DocumentSettingManager.cxx | 10 ++++++++++ sw/source/core/doc/notxtfrm.cxx | 5 ++++- sw/source/core/inc/DocumentSettingManager.hxx | 1 + sw/source/core/layout/fly.cxx | 18 ++++++++++++++---- sw/source/core/unocore/unoframe.cxx | 8 ++++++-- sw/source/uibase/uno/SwXDocumentSettings.cxx | 18 +++++++++++++++++- sw/source/writerfilter/dmapper/DomainMapper.cxx | 2 ++ sw/source/writerfilter/filter/WriterFilter.cxx | 2 ++ 9 files changed, 58 insertions(+), 8 deletions(-)
New commits: commit 3800ab58355385dcb482d3089accc7ce141f5ee9 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Tue Sep 24 16:10:15 2024 +0200 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Fri Oct 4 00:05:42 2024 +0200 tdf#161233 paint pictures completely also with contour wrap Pictures/shapes with contour wrap are clipped in Writer. Word paints the pictures completely while the text flows above around the contour. This is implemented here for imported documents. Change-Id: I2a5fd89c18cbb3e88b65bc63e8105cc07b95af82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173869 Tested-by: Jenkins Tested-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 67a7657a7021..9c053e845441 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -141,6 +141,8 @@ enum class DocumentSettingId MIN_ROW_HEIGHT_INCL_BORDER, // tdf#129808 MS Word always includes ext leading for text grid line height MS_WORD_COMP_GRID_METRICS, + // tdf#161233 pictures with wrap polygon should not be clipped + NO_CLIPPING_WITH_WRAP_POLYGON, }; /** Provides access to settings of a document diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index d638d2f25356..942272abc3b6 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -277,6 +277,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const case DocumentSettingId::MIN_ROW_HEIGHT_INCL_BORDER: return mbMinRowHeightInclBorder; // tdf#129808 case DocumentSettingId::MS_WORD_COMP_GRID_METRICS: return mbMsWordCompGridMetrics; + case DocumentSettingId::NO_CLIPPING_WITH_WRAP_POLYGON: return mbNoClippingWithWrapPolygon; default: OSL_FAIL("Invalid setting id"); } @@ -606,6 +607,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo case DocumentSettingId::MS_WORD_COMP_GRID_METRICS: mbMsWordCompGridMetrics = value; break; + case DocumentSettingId::NO_CLIPPING_WITH_WRAP_POLYGON: + mbNoClippingWithWrapPolygon = value; + break; default: OSL_FAIL("Invalid setting id"); } @@ -786,6 +790,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti mbDropCapPunctuation = rSource.mbDropCapPunctuation; mbUseVariableWidthNBSP = rSource.mbUseVariableWidthNBSP; mbMsWordCompGridMetrics = rSource.mbMsWordCompGridMetrics; + mbNoClippingWithWrapPolygon = rSource.mbNoClippingWithWrapPolygon; } sal_uInt32 sw::DocumentSettingManager::Getn32DummyCompatibilityOptions1() const @@ -1177,6 +1182,11 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const BAD_CAST(OString::boolean(mbMsWordCompGridMetrics).getStr())); (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbNoClippingWithWrapPolygon")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), + BAD_CAST(OString::boolean(mbNoClippingWithWrapPolygon).getStr())); + (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 34ad78e64cdb..6a310a478221 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -261,7 +261,10 @@ void SwNoTextFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect cons FindFlyFrame()->GetContour( aPoly, true ) ) { - rRenderContext.SetClipRegion(vcl::Region(aPoly)); + // don't clip if related compatibility flag is set + const IDocumentSettingAccess& rIDSA = pSh->GetDoc()->getIDocumentSettingAccess(); + if (!rIDSA.get(DocumentSettingId::NO_CLIPPING_WITH_WRAP_POLYGON)) + rRenderContext.SetClipRegion(vcl::Region(aPoly)); bClip = false; } diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx index d7e0c8876ae1..f7ca013b77f1 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -189,6 +189,7 @@ class DocumentSettingManager final : bool mbPaintHellOverHeaderFooter : 1; // tdf#160198 bool mbMinRowHeightInclBorder : 1; // tdf#155229 bool mbMsWordCompGridMetrics : 1; // tdf#129808 + bool mbNoClippingWithWrapPolygon : 1; // tdf#161233 public: diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 051c049d02f2..e33617ef8f31 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -443,7 +443,16 @@ void SwFlyFrame::InitDrawObj(SwFrame& rAnchorFrame) if (!rAnchorFrame.FindFooterOrHeader()) nHellId = rIDDMA.GetHeaderFooterHellId(); } + bool bNoClippingWithWrapPolygon = rIDSA.get(DocumentSettingId::NO_CLIPPING_WITH_WRAP_POLYGON); + if (bNoClippingWithWrapPolygon && isOpaque) + { + if (GetFrameFormat()->GetSurround().IsContour()) + { + GetVirtDrawObj()->SetLayer(nHellId); + return; + } + } GetVirtDrawObj()->SetLayer( isOpaque ? nHeavenId :nHellId ); } @@ -1050,10 +1059,11 @@ void SwFlyFrame::UpdateAttr_( const SfxPoolItem *pOld, const SfxPoolItem *pNew, { nHellId = rIDDMA.GetHeaderFooterHellId(); } - - const SdrLayerID nId = GetFormat()->GetOpaque().GetValue() ? - rIDDMA.GetHeavenId() : - nHellId; + bool bNoClippingWithWrapPolygon = rIDSA.get(DocumentSettingId::NO_CLIPPING_WITH_WRAP_POLYGON); + SdrLayerID nId = nHellId; + if (GetFormat()->GetOpaque().GetValue() && + !(bNoClippingWithWrapPolygon && GetFrameFormat()->GetSurround().IsContour())) + nId = rIDDMA.GetHeavenId(); GetVirtDrawObj()->SetLayer( nId ); if ( Lower() ) diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index e29f71ed7851..a2a5e95ccf41 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1363,9 +1363,13 @@ SdrObject *SwXFrame::GetOrCreateSdrObject(SwFlyFrameFormat &rFormat) const ::SwFormatSurround& rSurround = rFormat.GetSurround(); const IDocumentSettingAccess& rIDSA = pDoc->getIDocumentSettingAccess(); bool isPaintHellOverHF = rIDSA.get(DocumentSettingId::PAINT_HELL_OVER_HEADER_FOOTER); + bool bNoClippingWithWrapPolygon = rIDSA.get(DocumentSettingId::NO_CLIPPING_WITH_WRAP_POLYGON); - //TODO: HeaderFooterHellId only appropriate if object is anchored in body - pObject->SetLayer( + if (bNoClippingWithWrapPolygon && rSurround.IsContour()) + pObject->SetLayer(pDoc->getIDocumentDrawModelAccess().GetHellId()); + else + //TODO: HeaderFooterHellId only appropriate if object is anchored in body + pObject->SetLayer( ( css::text::WrapTextMode_THROUGH == rSurround.GetSurround() && !rFormat.GetOpaque().GetValue() ) ? isPaintHellOverHF diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index 0220a281679e..dccd520f5245 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -165,7 +165,8 @@ enum SwDocumentSettingsPropertyHandles HANDLE_DO_NOT_MIRROR_RTL_DRAW_OBJS, HANDLE_PAINT_HELL_OVER_HEADER_FOOTER, HANDLE_MIN_ROW_HEIGHT_INCL_BORDER, - HANDLE_MS_WORD_COMP_GRID_METRICS + HANDLE_MS_WORD_COMP_GRID_METRICS, + HANDLE_NO_CLIPPING_WITH_WRAP_POLYGON, }; } @@ -278,6 +279,7 @@ static rtl::Reference<MasterPropertySetInfo> lcl_createSettingsInfo() { u"PaintHellOverHeaderFooter"_ustr, HANDLE_PAINT_HELL_OVER_HEADER_FOOTER, cppu::UnoType<bool>::get(), 0 }, { u"MinRowHeightInclBorder"_ustr, HANDLE_MIN_ROW_HEIGHT_INCL_BORDER, cppu::UnoType<bool>::get(), 0 }, { u"MsWordCompGridMetrics"_ustr, HANDLE_MS_WORD_COMP_GRID_METRICS, cppu::UnoType<bool>::get(), 0 }, + { u"NoClippingWithWrapPolygon"_ustr, HANDLE_NO_CLIPPING_WITH_WRAP_POLYGON, cppu::UnoType<bool>::get(), 0 }, /* * As OS said, we don't have a view when we need to set this, so I have to @@ -1204,6 +1206,14 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf } } break; + case HANDLE_NO_CLIPPING_WITH_WRAP_POLYGON: + bool bTmp; + if (rValue >>= bTmp) + { + mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::NO_CLIPPING_WITH_WRAP_POLYGON, + bTmp); + } + break; default: throw UnknownPropertyException(OUString::number(rInfo.mnHandle)); } @@ -1809,6 +1819,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf DocumentSettingId::MS_WORD_COMP_GRID_METRICS); } break; + case HANDLE_NO_CLIPPING_WITH_WRAP_POLYGON: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get( + DocumentSettingId::NO_CLIPPING_WITH_WRAP_POLYGON); + } + break; default: throw UnknownPropertyException(OUString::number(rInfo.mnHandle)); } diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx b/sw/source/writerfilter/dmapper/DomainMapper.cxx index 280fcd89231b..b03ef9364cfe 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx @@ -157,6 +157,8 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon // tdf#129808 Enable compatible grid font metrics for documents with noLeading m_pImpl->SetDocumentSettingsProperty(u"MsWordCompGridMetrics"_ustr, uno::Any(true)); + // tdf#161233 pictures with wrap polygon should not be clipped + m_pImpl->SetDocumentSettingsProperty(u"NoClippingWithWrapPolygon"_ustr, uno::Any(true)); } // Initialize RDF metadata, to be able to add statements during the import. diff --git a/sw/source/writerfilter/filter/WriterFilter.cxx b/sw/source/writerfilter/filter/WriterFilter.cxx index 9225c6a5662d..7c93a79b0163 100644 --- a/sw/source/writerfilter/filter/WriterFilter.cxx +++ b/sw/source/writerfilter/filter/WriterFilter.cxx @@ -337,6 +337,8 @@ void WriterFilter::setTargetDocument(const uno::Reference<lang::XComponent>& xDo xSettings->setPropertyValue(u"DoNotMirrorRtlDrawObjs"_ustr, uno::Any(true)); xSettings->setPropertyValue(u"ContinuousEndnotes"_ustr, uno::Any(true)); + // tdf#161233 pictures with wrap polygon should not be clipped + xSettings->setPropertyValue(u"NoClippingWithWrapPolygon"_ustr, uno::Any(true)); } void WriterFilter::setSourceDocument(const uno::Reference<lang::XComponent>& xDoc)