diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-04-16 22:34:50 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-05-25 12:31:32 +0200 |
commit | 4b4942224b550235da228655677b5c068a053254 (patch) | |
tree | a660a04a1f7a3eee910da780ece271d68942201d /svx/source/engine3d | |
parent | f8edef392245c292398a80f6a858ca19f32df9c3 (diff) |
SOSAW080: Derive SdrObjGroup from SdrObjList
Also simplify parent/child relationships, get rid
of double data (SdrPage/Parent infos in SdrObjects,
also in SdrObjList). This is all not needed - when a
SdrObject is inserted to a SdrPage, get SdrPage by
traveling over parents (no double info, member as soon
as inserted, ...).
More cleanups/reworks included, will need some more
cleanups, too.
Stabilizing: SetRectsDirty/DefaultStyleSheet
Had to correct the SetRectsDirty stuff for 3D due to
going down the hierarchy while the 2D implementation
goes the other direction -> endless loops. Added special
handling for 3D stuff for now (will be chnaged again when
SnapRect is no longer needed at SdrObject level).
Also had to adapt how the DefaultStyleSheet is set at
incarnated SdrObjects - better: their properties. Since
we now always have a SdrModel, it is possible to correctly
initialize with the correct default StyleSheet from that
SdrModel.
This needs to be done after ForceDefaultAttributes and in a
way that again deletes Items that are set in the StyleSheet.
This leads to an error in CppunitTest_sd_import_tests where
I checked tdf100491 - it is okay and thus I change the control
instance of the imported, XML-dumped file.
The less hard attributes, the better for Styles in general.
Cleanup of comments for last two commits
Corrected SvxShape::getParent()
Needed to get the direct parent, so test for SdrObject
first (to get SdrObjGroup/E3DScene), for SdrPage second
Fixed CppunitTest_sc_subsequent_export_test
Several problems arose. The used SdrCaptionObj was
Cloned, but the clone not inserted to a SdrPage. This
leads to not being able to access a UNO API imlementation
of the SdrPage (SvxPage) on lower levels.
It worked before due to SdrObject having a SdrPage*
additionally to being added to a SdrPage - this is exactly
the main cleanup this change does.
Looked for why it is cloned, could see no reasons. The
SdrCaptionObj exists during all im/export, not difference
to other SdrObjects (that do not get cloned). It is not
changed in any way. It *might* be to suppress a crash that
happened due to UNO API Service emfio/emfio not being
available in the UnitTest scenario. Interestingly it
did not crash with the cloned SdrCaptionObj, but the
Graphic exported was probably wrong.
Fixed by no longer Cloning the SdrCaptionObj and adding
emfio/emfio UNO API Service.
d139f821a5b39535a3e7b9c6261df7e18f8ae8ac
910e7f4bc628a715fda7545dffaf3369d5e76ea0
ca1de01b723051e09ac37d7ec7bba978beea41c5
3a76da1471dfe75e69847f64a6a3519ad21c8c9c
Change-Id: I986586e326b563acebf00d931a7084c6eb09e5f8
Reviewed-on: https://gerrit.libreoffice.org/54689
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'svx/source/engine3d')
-rw-r--r-- | svx/source/engine3d/helperhittest3d.cxx | 4 | ||||
-rw-r--r-- | svx/source/engine3d/obj3d.cxx | 10 | ||||
-rw-r--r-- | svx/source/engine3d/scene3d.cxx | 88 | ||||
-rw-r--r-- | svx/source/engine3d/view3d.cxx | 18 |
4 files changed, 64 insertions, 56 deletions
diff --git a/svx/source/engine3d/helperhittest3d.cxx b/svx/source/engine3d/helperhittest3d.cxx index 09dbdf45cd8d..db71e75da574 100644 --- a/svx/source/engine3d/helperhittest3d.cxx +++ b/svx/source/engine3d/helperhittest3d.cxx @@ -162,7 +162,7 @@ void getAllHit3DObjectsSortedFrontToBack( o_rResult.clear(); SdrObjList* pList = rScene.GetSubList(); - if(pList && pList->GetObjCount()) + if(nullptr != pList && 0 != pList->GetObjCount()) { // prepare relative HitPoint. To do so, get the VC of the 3DScene and from there // the Scene's 2D transformation. Multiplying with the inverse transformation @@ -175,7 +175,7 @@ void getAllHit3DObjectsSortedFrontToBack( // check if test point is inside scene's area at all if(aRelativePoint.getX() >= 0.0 && aRelativePoint.getX() <= 1.0 && aRelativePoint.getY() >= 0.0 && aRelativePoint.getY() <= 1.0) { - SdrObjListIter aIterator(*pList, SdrIterMode::DeepNoGroups); + SdrObjListIter aIterator(pList, SdrIterMode::DeepNoGroups); ::std::vector< ImplPairDephAndObject > aDepthAndObjectResults; const uno::Sequence< beans::PropertyValue > aEmptyParameters; drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters); diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx index 522bf6de5e7e..670dbb9ccd04 100644 --- a/svx/source/engine3d/obj3d.cxx +++ b/svx/source/engine3d/obj3d.cxx @@ -285,9 +285,9 @@ E3dObject* E3dObject::GetParentObj() const { E3dObject* pRetval = nullptr; - if(getParentOfSdrObject() && getParentOfSdrObject()->GetOwnerObj()) + if(getParentOfSdrObject()) { - pRetval = dynamic_cast<E3dObject*>(getParentOfSdrObject()->GetOwnerObj()); + pRetval = dynamic_cast< E3dObject* >(getParentOfSdrObject()->getSdrObjectFromSdrObjList()); } return pRetval; @@ -677,11 +677,9 @@ basegfx::B2DPolyPolygon E3dCompoundObject::TransformToScreenCoor(const basegfx:: bool E3dCompoundObject::IsAOrdNumRemapCandidate(E3dScene*& prScene) const { - if(getParentOfSdrObject() - && getParentOfSdrObject()->GetOwnerObj() - && dynamic_cast<const E3dObject*>(getParentOfSdrObject()->GetOwnerObj())) + if(getParentOfSdrObject() && getParentOfSdrObject()->getSdrObjectFromSdrObjList()) { - prScene = static_cast<E3dScene*>(getParentOfSdrObject()->GetOwnerObj()); + prScene = static_cast< E3dScene* >(getParentOfSdrObject()->getSdrObjectFromSdrObjList()); return true; } diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx index 01fa06cc1b37..465cdbd836fa 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -178,9 +178,6 @@ E3dScene::E3dScene(SdrModel& rSdrModel) bDrawOnlySelected(false), mbSkipSettingDirty(false) { - SetOwnerObj(this); - SetListKind(SdrObjListKind::GroupObj); - // Set defaults SetDefaultAttributes(); } @@ -218,6 +215,26 @@ E3dScene::~E3dScene() ImpCleanup3DDepthMapper(); } +SdrPage* E3dScene::getSdrPageFromSdrObjList() const +{ + return getSdrPageFromSdrObject(); +} + +SdrObject* E3dScene::getSdrObjectFromSdrObjList() const +{ + return const_cast< E3dScene* >(this); +} + +SdrModel& E3dScene::getSdrModelFromSdrObjList() const +{ + return getSdrModelFromSdrObject(); +} + +SdrObjList* E3dScene::getChildrenOfSdrObject() const +{ + return const_cast< E3dScene* >(this); +} + basegfx::B2DPolyPolygon E3dScene::TakeXorPoly() const { const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(GetViewContact()); @@ -467,14 +484,13 @@ void E3dScene::SetAllSceneRectsDirty() void E3dScene::RebuildLists() { // first delete - SdrLayerID nCurrLayerID = GetLayer(); - - SdrObjListIter a3DIterator(static_cast< SdrObjList& >(*this), SdrIterMode::Flat); + const SdrLayerID nCurrLayerID(GetLayer()); + SdrObjListIter a3DIterator(GetSubList(), SdrIterMode::Flat); // then examine all the objects in the scene - while ( a3DIterator.IsMore() ) + while(a3DIterator.IsMore()) { - E3dObject* p3DObj = static_cast<E3dObject*>(a3DIterator.Next()); + E3dObject* p3DObj(static_cast< E3dObject* >(a3DIterator.Next())); p3DObj->NbcSetLayer(nCurrLayerID); NewObjectInserted(p3DObj); } @@ -657,7 +673,7 @@ void E3dScene::RecalcSnapRect() bool E3dScene::IsBreakObjPossible() { // Break scene, if all members are able to break - SdrObjListIter a3DIterator(static_cast< SdrObjList& >(*this), SdrIterMode::DeepWithGroups); + SdrObjListIter a3DIterator(GetSubList(), SdrIterMode::DeepWithGroups); while ( a3DIterator.IsMore() ) { @@ -734,11 +750,8 @@ void E3dScene::SetSelected(bool bNew) void E3dScene::NbcInsertObject(SdrObject* pObj, size_t nPos) { - // Get owner - DBG_ASSERT(dynamic_cast<const E3dObject*>(GetOwnerObj()), "Insert 3D object in parent != 3DObject"); - // Is it even a 3D object? - if(pObj && nullptr != dynamic_cast< const E3dObject* >(pObj)) + if(nullptr != dynamic_cast< const E3dObject* >(pObj)) { // Normal 3D object, insert means // call parent @@ -747,14 +760,12 @@ void E3dScene::NbcInsertObject(SdrObject* pObj, size_t nPos) else { // No 3D object, inserted a page in place in a scene ... - GetOwnerObj()->GetPage()->InsertObject(pObj, nPos); + getSdrObjectFromSdrObjList()->getSdrPageFromSdrObject()->InsertObject(pObj, nPos); } } void E3dScene::InsertObject(SdrObject* pObj, size_t nPos) { - OSL_ENSURE(dynamic_cast<const E3dObject*>(GetOwnerObj()), "Insert 3D object in non-3D Parent"); - // call parent SdrObjList::InsertObject(pObj, nPos); @@ -763,8 +774,6 @@ void E3dScene::InsertObject(SdrObject* pObj, size_t nPos) SdrObject* E3dScene::NbcRemoveObject(size_t nObjNum) { - DBG_ASSERT(dynamic_cast<const E3dObject*>(GetOwnerObj()), "Remove 3D object from Parent != 3DObject"); - // call parent SdrObject* pRetval = SdrObjList::NbcRemoveObject(nObjNum); @@ -775,8 +784,6 @@ SdrObject* E3dScene::NbcRemoveObject(size_t nObjNum) SdrObject* E3dScene::RemoveObject(size_t nObjNum) { - OSL_ENSURE(dynamic_cast<const E3dObject*>(GetOwnerObj()), "3D object is removed from non-3D Parent"); - // call parent SdrObject* pRetval = SdrObjList::RemoveObject(nObjNum); @@ -785,10 +792,10 @@ SdrObject* E3dScene::RemoveObject(size_t nObjNum) return pRetval; } -void E3dScene::SetRectsDirty(bool bNotMyself) +void E3dScene::SetRectsDirty(bool bNotMyself, bool bRecursive) { // call parent - E3dObject::SetRectsDirty(bNotMyself); + E3dObject::SetRectsDirty(bNotMyself, bRecursive); for(size_t a = 0; a < GetObjCount(); ++a) { @@ -796,7 +803,7 @@ void E3dScene::SetRectsDirty(bool bNotMyself) if(pCandidate) { - pCandidate->SetRectsDirty(bNotMyself); + pCandidate->SetRectsDirty(bNotMyself, false); } } } @@ -817,21 +824,27 @@ void E3dScene::NbcSetLayer(SdrLayerID nLayer) } } -void E3dScene::setParentOfSdrObject(SdrObjList* pNewObjList) +void E3dScene::handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) { - // call parent - E3dObject::setParentOfSdrObject(pNewObjList); - - SetUpList(pNewObjList); -} + if(pOldPage != pNewPage) + { + // call parent + E3dObject::handlePageChange(pOldPage, pNewPage); -void E3dScene::SetPage(SdrPage* pNewPage) -{ - // call parent - E3dObject::SetPage(pNewPage); + for(size_t a(0); a < GetObjCount(); a++) + { + E3dObject* pCandidate = dynamic_cast< E3dObject* >(GetObj(a)); - // set at SdrObjList - SdrObjList::SetPage(pNewPage); + if(pCandidate) + { + pCandidate->handlePageChange(pOldPage, pNewPage); + } + else + { + OSL_ENSURE(false, "E3dScene::handlePageChange invalid object list (!)"); + } + } + } } SdrObjList* E3dScene::GetSubList() const @@ -842,9 +855,7 @@ SdrObjList* E3dScene::GetSubList() const void E3dScene::Insert3DObj(E3dObject* p3DObj) { DBG_ASSERT(p3DObj, "Insert3DObj with NULL-pointer!"); - SdrPage* pPg = pPage; InsertObject(p3DObj); - pPage = pPg; InvalidateBoundVolume(); NewObjectInserted(p3DObj); StructureChanged(); @@ -856,10 +867,7 @@ void E3dScene::Remove3DObj(E3dObject const * p3DObj) if(p3DObj->GetParentObj() == this) { - SdrPage* pPg = pPage; RemoveObject(p3DObj->GetOrdNum()); - pPage = pPg; - InvalidateBoundVolume(); StructureChanged(); } diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx index 7431cb2e875a..8be7aae2abe4 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -456,10 +456,10 @@ bool E3dView::Paste( return false; // Get owner of the list - SdrObject* pOwner = pDstList->GetOwnerObj(); - if(pOwner && dynamic_cast< const E3dScene* >(pOwner) != nullptr) + E3dScene* pDstScene(dynamic_cast< E3dScene* >(pDstList->getSdrObjectFromSdrObjList())); + + if(nullptr != pDstScene) { - E3dScene* pDstScene = static_cast<E3dScene*>(pOwner); BegUndo(SvxResId(RID_SVX_3D_UNDO_EXCHANGE_PASTE)); // Copy all objects from E3dScenes and insert them directly @@ -581,7 +581,6 @@ bool E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene const * pSrcScene, E3dSce pNewCompoundObj->SetTransform(aModifyingTransform * aNewObjectTrans); // fill and insert new object - pNewCompoundObj->SetPage(pDstScene->E3dObject::GetPage()); pNewCompoundObj->NbcSetLayer(pCompoundObj->GetLayer()); pNewCompoundObj->NbcSetStyleSheet(pCompoundObj->GetStyleSheet(), true); pDstScene->Insert3DObj(pNewCompoundObj); @@ -655,7 +654,7 @@ void E3dView::ImpChangeSomeAttributesFor3DConversion(SdrObject* pObj) if(rTextColorItem.GetValue() == COL_BLACK) { //For black text objects, the color set to gray - if(pObj->GetPage()) + if(pObj->getSdrPageFromSdrObject()) { // if black is only default attribute from // pattern set it hard so that it is used in undo. @@ -685,8 +684,11 @@ void E3dView::ImpChangeSomeAttributesFor3DConversion2(SdrObject* pObj) && !nLineWidth && eFillStyle != drawing::FillStyle_NONE) { - if(pObj->GetPage() && GetModel()->IsUndoEnabled() ) + if(pObj->getSdrPageFromSdrObject() && GetModel()->IsUndoEnabled() ) + { AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); + } + pObj->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE)); pObj->SetMergedItem(XLineWidthItem(0)); } @@ -1035,7 +1037,7 @@ void E3dView::DoDepthArrange(E3dScene const * pScene, double fDepth) if(pScene && pScene->GetSubList() && pScene->GetSubList()->GetObjCount() > 1) { SdrObjList* pSubList = pScene->GetSubList(); - SdrObjListIter aIter(*pSubList, SdrIterMode::Flat); + SdrObjListIter aIter(pSubList, SdrIterMode::Flat); E3dDepthLayer* pBaseLayer = nullptr; E3dDepthLayer* pLayer = nullptr; sal_Int32 nNumLayers = 0; @@ -1550,7 +1552,7 @@ void E3dView::BreakSingle3DObj(E3dObject* pObj) if(dynamic_cast< const E3dScene* >(pObj) != nullptr) { SdrObjList* pSubList = pObj->GetSubList(); - SdrObjListIter aIter(*pSubList, SdrIterMode::Flat); + SdrObjListIter aIter(pSubList, SdrIterMode::Flat); while(aIter.IsMore()) { |