diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-07-19 19:26:14 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-07-20 20:29:11 +0200 |
commit | cbc992e7370ab006ea7c0f8520896845f79f7749 (patch) | |
tree | 71000129a35f40d680279134efae7fac1c4e6a52 /svx | |
parent | 133da6ed83b278b9e6059c5c1a3d49f9f402792e (diff) |
tdf#118662 Cleanup old hack with cloned SdrCaptionObj
XclObjComment formally cloned the SdrCaptionObj for a single
reason - to suppress functionality of the UNO API implementation
in SvxShape::GetBitmap - non-inserted SdrObjects did not create
Graphic return values.
Changed this to use an exclusive flag at SdrCaptionObj, only
accessible for XclObjComment. Due to bad/undefined behaviour
of SdrObjects that are not iinserted anywhere (see old comment
in XclObjComment) there is no way to return to cloning the
SdrObjects just to have them without being added to a SdrPage.
Also improved the time eater UNO API implementation SvxShape::GetBitmap
to use more modern stuff to create the Graphics needed. All the
time constructing a full E3DView and setting SdrObjects selected
and getting the selection as graphic is way too expensive. That
way save may even get somewhat faster.
Last was to cleanup the bInserted flag in SdrObject. It is no
longer needed, being inserted now depends on being a member
of an SdrObjList (Group or Page) - sounds normal anyways and
is a synergy effect of already done AW080 cleanups.
Checked now on linux. Problem is UnitTest 'testN777345' which
checks file "n777345.docx".
First point is that this only happens
#if !defined(MACOSX)
#if !defined(_WIN32)
so it's clear why I detected no problem on Windows.
Second point is that this test takes a checksum of a Graphic
that is created using getReplacementGraphic() this value *will*
change - of course - every time creation of that graphic is
even *slightly* modified, so from my POV this UnitTest is
defined to fill quite often. It may even create different
results on different systems (!). Adaption of the test value
will be needed quite often and makes this test questionable.
Change-Id: If0918831a9cbd61b31298aeac7342e1913ee6c7a
Reviewed-on: https://gerrit.libreoffice.org/57758
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 29 | ||||
-rw-r--r-- | svx/source/svdraw/svdocapt.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdpage.cxx | 14 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 86 |
4 files changed, 90 insertions, 47 deletions
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index fdfd176b0011..89cee38cde37 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -354,7 +354,6 @@ SdrObject::SdrObject(SdrModel& rSdrModel) { bVirtObj =false; bSnapRectDirty =true; - bInserted =false; bMovProt =false; bSizProt =false; bNoPrint =false; @@ -1715,7 +1714,7 @@ bool SdrObject::Equals(const SdrObject& rOtherObj) const bIs3DObj == rOtherObj.bIs3DObj && bIsEdge == rOtherObj.bIsEdge && bClosedObj == rOtherObj.bClosedObj && bNotVisibleAsMaster == rOtherObj.bNotVisibleAsMaster && bEmptyPresObj == rOtherObj.bEmptyPresObj && mbVisible == rOtherObj.mbVisible && bNoPrint == rOtherObj.bNoPrint && bSizProt == rOtherObj.bSizProt && - bMovProt == rOtherObj.bMovProt && bInserted == rOtherObj.bInserted && bVirtObj == rOtherObj.bVirtObj && + bMovProt == rOtherObj.bMovProt && bVirtObj == rOtherObj.bVirtObj && mnLayerID == rOtherObj.mnLayerID && GetMergedItemSet().Equals(rOtherObj.GetMergedItemSet(), false) ); } @@ -2569,18 +2568,24 @@ SdrObject* SdrObject::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) co } -void SdrObject::SetInserted(bool bIns) +void SdrObject::InsertedStateChange() { - if (bIns!=IsInserted()) { - bInserted=bIns; - tools::Rectangle aBoundRect0(GetLastBoundRect()); - if (bIns) SendUserCall(SdrUserCallType::Inserted,aBoundRect0); - else SendUserCall(SdrUserCallType::Removed,aBoundRect0); + const bool bIsInserted(nullptr != getParentSdrObjListFromSdrObject()); + const tools::Rectangle aBoundRect0(GetLastBoundRect()); - if (pPlusData!=nullptr && pPlusData->pBroadcast!=nullptr) { - SdrHint aHint(bIns?SdrHintKind::ObjectInserted:SdrHintKind::ObjectRemoved, *this); - pPlusData->pBroadcast->Broadcast(aHint); - } + if(bIsInserted) + { + SendUserCall(SdrUserCallType::Inserted, aBoundRect0); + } + else + { + SendUserCall(SdrUserCallType::Removed, aBoundRect0); + } + + if(nullptr != pPlusData && nullptr != pPlusData->pBroadcast) + { + SdrHint aHint(bIsInserted ? SdrHintKind::ObjectInserted : SdrHintKind::ObjectRemoved, *this); + pPlusData->pBroadcast->Broadcast(aHint); } } diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index 4af2f1a3dfe4..7acb0bd4015c 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -193,7 +193,9 @@ SdrCaptionObj::SdrCaptionObj(SdrModel& rSdrModel) : SdrRectObj(rSdrModel, OBJ_TEXT), aTailPoly(3), // default size: 3 points = 2 lines mbSpecialTextBoxShadow(false), - mbFixedTail(false) + mbFixedTail(false), + mbSuppressGetBitmap(false), + maFixedTailPos() { } @@ -204,7 +206,9 @@ SdrCaptionObj::SdrCaptionObj( : SdrRectObj(rSdrModel, OBJ_TEXT,rRect), aTailPoly(3), // default size: 3 points = 2 lines mbSpecialTextBoxShadow(false), - mbFixedTail(false) + mbFixedTail(false), + mbSuppressGetBitmap(false), + maFixedTailPos() { aTailPoly[0]=maFixedTailPos=rTail; } diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 2573b58f0505..aefd4955a680 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -323,7 +323,7 @@ void SdrObjList::NbcInsertObject(SdrObject* pObj, size_t nPos) maSdrObjListOutRect.Union(pObj->GetCurrentBoundRect()); maSdrObjListSnapRect.Union(pObj->GetSnapRect()); } - pObj->SetInserted(true); // calls the UserCall (among others) + pObj->InsertedStateChange(); // calls the UserCall (among others) } void SdrObjList::InsertObject(SdrObject* pObj, size_t nPos) @@ -384,7 +384,7 @@ SdrObject* SdrObjList::NbcRemoveObject(size_t nObjNum) pObj->GetViewContact().flushViewObjectContacts(); DBG_ASSERT(pObj->IsInserted(),"The object does not have the status Inserted."); - pObj->SetInserted(false); // calls UserCall, among other + pObj->InsertedStateChange(); // calls UserCall, among other SetParentAtSdrObjectFromSdrObjList(*pObj, nullptr); if (!mbObjOrdNumsDirty) { @@ -426,7 +426,7 @@ SdrObject* SdrObjList::RemoveObject(size_t nObjNum) pObj->getSdrModelFromSdrObject().SetChanged(); - pObj->SetInserted(false); // calls, among other things, the UserCall + pObj->InsertedStateChange(); // calls, among other things, the UserCall SetParentAtSdrObjectFromSdrObjList(*pObj, nullptr); if (!mbObjOrdNumsDirty) @@ -463,7 +463,7 @@ SdrObject* SdrObjList::NbcReplaceObject(SdrObject* pNewObj, size_t nObjNum) DBG_ASSERT(pObj!=nullptr,"SdrObjList::ReplaceObject: Could not find object to remove."); if (pObj!=nullptr) { DBG_ASSERT(pObj->IsInserted(),"SdrObjList::ReplaceObject: the object does not have status Inserted."); - pObj->SetInserted(false); + pObj->InsertedStateChange(); SetParentAtSdrObjectFromSdrObjList(*pObj, nullptr); ReplaceObjectInContainer(*pNewObj,nObjNum); @@ -477,7 +477,7 @@ SdrObject* SdrObjList::NbcReplaceObject(SdrObject* pNewObj, size_t nObjNum) // evtl. existing parent visualisations impChildInserted(*pNewObj); - pNewObj->SetInserted(true); + pNewObj->InsertedStateChange(); SetSdrObjListRectsDirty(); } return pObj; @@ -508,7 +508,7 @@ SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum) pObj->getSdrModelFromSdrObject().Broadcast(aHint); } - pObj->SetInserted(false); + pObj->InsertedStateChange(); SetParentAtSdrObjectFromSdrObjList(*pObj, nullptr); ReplaceObjectInContainer(*pNewObj,nObjNum); @@ -522,7 +522,7 @@ SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, size_t nObjNum) // evtl. existing parent visualisations impChildInserted(*pNewObj); - pNewObj->SetInserted(true); + pNewObj->InsertedStateChange(); // TODO: We need a different broadcast here. if (pNewObj->getSdrPageFromSdrObject()!=nullptr) { diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index a8fbab8db6c7..3ac01d5df9aa 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -85,6 +85,8 @@ #include <svx/lathe3d.hxx> #include <svx/extrud3d.hxx> +#include <svx/sdr/contact/viewcontact.hxx> +#include <drawinglayer/geometry/viewinformation2d.hxx> #include <vcl/wmf.hxx> @@ -690,48 +692,80 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const DBG_TESTSOLARMUTEX(); uno::Any aAny; - if( !HasSdrObject() || !GetSdrObject()->IsInserted() || nullptr == GetSdrObject()->getSdrPageFromSdrObject() ) + if(!HasSdrObject() || nullptr == GetSdrObject()->getSdrPageFromSdrObject()) + { + return aAny; + } + + // tdf#118662 Emulate old behaviour of XclObjComment (see there) + const SdrCaptionObj* pSdrCaptionObj(dynamic_cast<SdrCaptionObj*>(GetSdrObject())); + if(nullptr != pSdrCaptionObj && pSdrCaptionObj->isSuppressGetBitmap()) + { return aAny; + } + // tdf#118662 instead of creating an E3dView instance every time to paint + // a single SdrObject, use the existing SdrObject::SingleObjectPainter to + // use less ressources and runtime ScopedVclPtrInstance< VirtualDevice > pVDev; - pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); - SdrPage* pPage = GetSdrObject()->getSdrPageFromSdrObject(); + const tools::Rectangle aBoundRect(GetSdrObject()->GetCurrentBoundRect()); - std::unique_ptr<E3dView> pView( - new E3dView( - GetSdrObject()->getSdrModelFromSdrObject(), - pVDev.get())); - pView->hideMarkHandles(); - SdrPageView* pPageView = pView->ShowSdrPage(pPage); + if(bMetaFile) + { + GDIMetaFile aMtf; - SdrObject *pTempObj = GetSdrObject(); - pView->MarkObj(pTempObj,pPageView); + pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); + pVDev->EnableOutput(false); + aMtf.Record(pVDev); + GetSdrObject()->SingleObjectPainter(*pVDev.get()); + aMtf.Stop(); + aMtf.WindStart(); + aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top()); + aMtf.SetPrefMapMode(MapMode(MapUnit::Map100thMM)); + aMtf.SetPrefSize(aBoundRect.GetSize()); - tools::Rectangle aRect(pTempObj->GetCurrentBoundRect()); - aRect.Justify(); - Size aSize(aRect.GetSize()); + SvMemoryStream aDestStrm(65535, 65535); + + ConvertGDIMetaFileToWMF( + aMtf, + aDestStrm, + nullptr, + false); - GDIMetaFile aMtf( pView->GetMarkedObjMetaFile() ); - if( bMetaFile ) - { - SvMemoryStream aDestStrm( 65535, 65535 ); - ConvertGDIMetaFileToWMF( aMtf, aDestStrm, nullptr, false ); const uno::Sequence<sal_Int8> aSeq( static_cast< const sal_Int8* >(aDestStrm.GetData()), aDestStrm.GetEndOfData()); + aAny <<= aSeq; } else { - Graphic aGraph(aMtf); - aGraph.SetPrefSize(aSize); - aGraph.SetPrefMapMode(MapMode(MapUnit::Map100thMM)); + const drawinglayer::primitive2d::Primitive2DContainer xPrimitives( + GetSdrObject()->GetViewContact().getViewIndependentPrimitive2DContainer()); - Reference< awt::XBitmap > xBmp( aGraph.GetXGraphic(), UNO_QUERY ); - aAny <<= xBmp; - } + if(!xPrimitives.empty()) + { + const drawinglayer::geometry::ViewInformation2D aViewInformation2D; + const basegfx::B2DRange aRange( + xPrimitives.getB2DRange(aViewInformation2D)); + + if(!aRange.isEmpty()) + { + const BitmapEx aBmp( + convertPrimitive2DSequenceToBitmapEx( + xPrimitives, + aRange)); + + Graphic aGraph(aBmp); - pView->UnmarkAll(); + aGraph.SetPrefSize(aBmp.GetPrefSize()); + aGraph.SetPrefMapMode(aBmp.GetPrefMapMode()); + + Reference< awt::XBitmap > xBmp( aGraph.GetXGraphic(), UNO_QUERY ); + aAny <<= xBmp; + } + } + } return aAny; } |