diff options
Diffstat (limited to 'svx/source/unodraw')
-rw-r--r-- | svx/source/unodraw/SvxXTextColumns.cxx | 4 | ||||
-rw-r--r-- | svx/source/unodraw/UnoGraphicExporter.cxx | 92 | ||||
-rw-r--r-- | svx/source/unodraw/unoshap2.cxx | 3 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 9 | ||||
-rw-r--r-- | svx/source/unodraw/unoshtxt.cxx | 5 |
5 files changed, 45 insertions, 68 deletions
diff --git a/svx/source/unodraw/SvxXTextColumns.cxx b/svx/source/unodraw/SvxXTextColumns.cxx index 00971bc7bc87..a0e399bd4cbb 100644 --- a/svx/source/unodraw/SvxXTextColumns.cxx +++ b/svx/source/unodraw/SvxXTextColumns.cxx @@ -210,7 +210,7 @@ void SvxXTextColumns::setPropertyValue(const OUString& rPropertyName, const css: sal_Int32 nTmp; if (!(aValue >>= nTmp) || nTmp < 0) throw css::lang::IllegalArgumentException(); - m_nSepLineWidth = o3tl::toTwips(nTmp, o3tl::Length::mm100); + m_nSepLineWidth = nTmp; break; } case WID_TXTCOL_LINE_COLOR: @@ -271,7 +271,7 @@ css::uno::Any SvxXTextColumns::getPropertyValue(const OUString& rPropertyName) switch (pEntry->nWID) { case WID_TXTCOL_LINE_WIDTH: - aRet <<= o3tl::narrowing<sal_Int32>(convertTwipToMm100(m_nSepLineWidth)); + aRet <<= m_nSepLineWidth; break; case WID_TXTCOL_LINE_COLOR: aRet <<= m_nSepLineColor; diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 73d77cb54ea8..b807154f9d67 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -178,7 +178,7 @@ namespace { /** creates a bitmap that is optionally transparent from a metafile */ - BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf,bool bIsSelection, const Size* pSize ) + BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf, const Size* pSize ) { // use new primitive conversion tooling basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0)); @@ -204,51 +204,7 @@ namespace { aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); } - // get hairline and full bound rect to evtl. correct logic size by the - // equivalent of one pixel to make those visible at right and bottom - tools::Rectangle aHairlineRect; - const tools::Rectangle aRect(rMtf.GetBoundRect(*Application::GetDefaultDevice(), &aHairlineRect)); - - if(!aRect.IsEmpty()) - { - GDIMetaFile aMtf(rMtf); - - if (bIsSelection) - { - // tdf#105998 Correct the Metafile using information from it's real sizes measured - // using rMtf.GetBoundRect above and a copy - const Size aOnePixelInMtf( - Application::GetDefaultDevice()->PixelToLogic( - Size(1, 1), - rMtf.GetPrefMapMode())); - const Size aHalfPixelInMtf( - (aOnePixelInMtf.getWidth() + 1) / 2, - (aOnePixelInMtf.getHeight() + 1) / 2); - const bool bHairlineBR( - !aHairlineRect.IsEmpty() && (aRect.Right() == aHairlineRect.Right() || aRect.Bottom() == aHairlineRect.Bottom())); - - // Move the content to (0,0), usually TopLeft ist slightly - // negative. For better visualization, add a half pixel, too - aMtf.Move( - aHalfPixelInMtf.getWidth() - aRect.Left(), - aHalfPixelInMtf.getHeight() - aRect.Top()); - - // Do not Scale, but set the PrefSize. Some levels deeper the - // MetafilePrimitive will add a mapping to the decomposition - // (and possibly a clipping) to map the graphic content to - // a unit coordinate system. - // Size is the measured size plus one pixel if needed (bHairlineBR) - // and the moved half pixwel from above - aMtf.SetPrefSize( - Size( - aRect.getWidth() + (bHairlineBR ? aOnePixelInMtf.getWidth() : 0) + aHalfPixelInMtf.getWidth(), - aRect.getHeight() + (bHairlineBR ? aOnePixelInMtf.getHeight() : 0) + aHalfPixelInMtf.getHeight())); - } - - return convertMetafileToBitmapEx(aMtf, aRange, nMaximumQuadraticPixels); - } - - return BitmapEx(); + return convertMetafileToBitmapEx(rMtf, aRange, nMaximumQuadraticPixels); } Size* CalcSize( sal_Int32 nWidth, sal_Int32 nHeight, const Size& aBoundSize, Size& aOutSize ) @@ -775,7 +731,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr if( rSettings.mbTranslucent ) { Size aOutSize; - aGraphic = GetBitmapFromMetaFile( aGraphic.GetGDIMetaFile(), false, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aNewSize, aOutSize ) ); + aGraphic = GetBitmapFromMetaFile( aGraphic.GetGDIMetaFile(), CalcSize( rSettings.mnWidth, rSettings.mnHeight, aNewSize, aOutSize ) ); } } } @@ -899,16 +855,22 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr ScopedVclPtrInstance< VirtualDevice > aOut; // calculate bound rect for all shapes - tools::Rectangle aBound; + // tdf#126319 I did not convert all rendering to primities, + // that would be to much for this fix. But I did so for the + // range calculation to get a valid high quality range. + // Based on that the conversion is reliable. With the BoundRect + // fetched from the Metafile it was just not possible to get the + // examples from the task handled in a way to fit all cases - + // due to bad-quality range data from it. + basegfx::B2DRange aBound; + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; { for( SdrObject* pObj : aShapes ) { - tools::Rectangle aR1(pObj->GetCurrentBoundRect()); - if (aBound.IsEmpty()) - aBound=aR1; - else - aBound.Union(aR1); + drawinglayer::primitive2d::Primitive2DContainer aSequence; + aSequence = pObj->GetViewContact().getViewIndependentPrimitive2DContainer(); + aBound.expand(aSequence.getB2DRange(aViewInformation2D)); } } @@ -922,7 +884,20 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr aMtf.Record( aOut ); MapMode aOutMap( aMap ); - aOutMap.SetOrigin( Point( -aBound.Left(), -aBound.Top() ) ); + const Size aOnePixelInMtf( + Application::GetDefaultDevice()->PixelToLogic( + Size(1, 1), + aMap)); + const Size aHalfPixelInMtf( + (aOnePixelInMtf.getWidth() + 1) / 2, + (aOnePixelInMtf.getHeight() + 1) / 2); + + // tdf#126319 Immediately add needed offset to create metafile, + // that avoids to do it later by Metafile::Move what would be expensive + aOutMap.SetOrigin( + Point( + basegfx::fround(-aBound.getMinX() - aHalfPixelInMtf.getWidth()), + basegfx::fround(-aBound.getMinY() - aHalfPixelInMtf.getHeight()) ) ); aOut->SetRelativeMapMode( aOutMap ); sdr::contact::DisplayInfo aDisplayInfo; @@ -951,9 +926,10 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr aMtf.Stop(); aMtf.WindStart(); - const Size aExtSize( aOut->PixelToLogic( Size( 0, 0 ) ) ); - Size aBoundSize( aBound.GetWidth() + ( aExtSize.Width() ), - aBound.GetHeight() + ( aExtSize.Height() ) ); + // tdf#126319 Immediately add needed size to target's PrefSize + const Size aBoundSize( + basegfx::fround(aBound.getWidth() + aHalfPixelInMtf.getWidth()), + basegfx::fround(aBound.getHeight() + aHalfPixelInMtf.getHeight())); aMtf.SetPrefMapMode( aMap ); aMtf.SetPrefSize( aBoundSize ); @@ -961,7 +937,7 @@ bool GraphicExporter::GetGraphic( ExportSettings const & rSettings, Graphic& aGr if( !bVectorType ) { Size aOutSize; - aGraphic = GetBitmapFromMetaFile( aMtf, true, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aBoundSize, aOutSize ) ); + aGraphic = GetBitmapFromMetaFile( aMtf, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aBoundSize, aOutSize ) ); } else { diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index 415ddf95eeb9..839094c6d556 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -1461,7 +1461,8 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte Reference<graphic::XGraphic> xGraphic; auto pSdrGraphicObject = static_cast<SdrGrafObj*>(GetSdrObject()); - if (pSdrGraphicObject->GetGraphicObject().GetType() != GraphicType::NONE) + if (pSdrGraphicObject + && pSdrGraphicObject->GetGraphicObject().GetType() != GraphicType::NONE) xGraphic = pSdrGraphicObject->GetGraphic().GetXGraphic(); rValue <<= xGraphic; break; diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 98a104c49fc8..ee3e58dd0190 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -1286,10 +1286,6 @@ void SAL_CALL SvxShape::dispose() if ( pObject->IsInserted() && pObject->getSdrPageFromSdrObject() ) { - OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" ); - // normally, we are allowed to free the SdrObject only if we have its ownership. - // Why isn't this checked here? - SdrPage* pPage = pObject->getSdrPageFromSdrObject(); // delete the SdrObject from the page const size_t nCount = pPage->GetObjCount(); @@ -1298,7 +1294,10 @@ void SAL_CALL SvxShape::dispose() if ( pPage->GetObj( nNum ) == pObject ) { OSL_VERIFY( pPage->RemoveObject( nNum ) == pObject ); - bFreeSdrObject = true; + if (HasSdrObjectOwnership()) + { + bFreeSdrObject = true; + } break; } } diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx index cfb01211c129..8ccf0e8e47b8 100644 --- a/svx/source/unodraw/unoshtxt.cxx +++ b/svx/source/unodraw/unoshtxt.cxx @@ -661,8 +661,9 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder() { // tdf#123470 if the text edit mode of the shape is active, then we // cannot trust a previously cached TextForwarder state as the text may - // be out of date, so force a refetch in that case. - if (IsEditMode()) + // be out of date, so force a refetch in that case, unless locked against + // changes + if (IsEditMode() && mpTextForwarder && !mbIsLocked) { assert(!mbForwarderIsEditMode); // because without a view there is no other option except !mbForwarderIsEditMode bool bTextEditActive = false; |