diff options
Diffstat (limited to 'sd/source/core/sdpage.cxx')
-rw-r--r-- | sd/source/core/sdpage.cxx | 229 |
1 files changed, 112 insertions, 117 deletions
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index aaf209a63fe8..5c4eab5ee78c 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -51,7 +51,7 @@ #include <svx/sdtagitm.hxx> #include <svx/sdtcfitm.hxx> #include <svx/xfillit0.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <com/sun/star/animations/XAnimationNode.hpp> #include <com/sun/star/animations/XTimeContainer.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> @@ -63,8 +63,10 @@ #include <sal/log.hxx> #include <o3tl/enumarray.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/sorted_vector.hxx> #include <xmloff/autolayout.hxx> +#include <Annotation.hxx> #include <Outliner.hxx> #include <app.hrc> #include <createunopageimpl.hxx> @@ -128,7 +130,7 @@ SdPage::SdPage(SdDrawDocument& rNewDoc, bool bMasterPage) // The name of the layout of the page is used by SVDRAW to determine the // presentation template of the outline objects. Therefore, it already // contains the designator for the outline (STR_LAYOUT_OUTLINE). - maLayoutName = SdResId(STR_LAYOUT_DEFAULT_NAME)+ SD_LT_SEPARATOR STR_LAYOUT_OUTLINE; + maLayoutName = SdResId(STR_LAYOUT_DEFAULT_NAME)+ SD_LT_SEPARATOR + STR_LAYOUT_OUTLINE; // Stuff that former SetModel did also: ConnectLink(); @@ -175,8 +177,15 @@ SdPage::~SdPage() clearChildNodes(mxAnimationNode); - // clear SdrObjects with broadcasting - ClearSdrObjList(); + // disconnect the UserCall link, so we don't get calls + // back into this dying object when the child objects die + SdrObjListIter aIter( this, SdrIterMode::DeepWithGroups ); + while( aIter.IsMore() ) + { + SdrObject* pChild = aIter.Next(); + if( pChild->GetUserCall() == this ) + pChild->SetUserCall(nullptr); + } } namespace { @@ -278,7 +287,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager()); const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); - SdrObject* pSdrObj = nullptr; + rtl::Reference<SdrObject> pSdrObj; bool bForceText = false; // forces the shape text to be set even if it's empty bool bEmptyPresObj = true; @@ -287,7 +296,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t { case PresObjKind::Title: { - pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TITLETEXT); + pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::TitleText); if (mbMaster) { @@ -298,7 +307,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t case PresObjKind::Outline: { - pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_OUTLINETEXT); + pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::OutlineText); if (mbMaster) { @@ -309,7 +318,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t case PresObjKind::Notes: { - pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT); + pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::Text); if (mbMaster) { @@ -320,7 +329,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t case PresObjKind::Text: { - pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT); + pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::Text); } break; @@ -349,27 +358,27 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage()); BitmapEx aBmpEx(BMP_PRESOBJ_OBJECT); Graphic aGraphic( aBmpEx ); - static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic); + static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic); } break; case PresObjKind::Chart: { pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage()); - static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarChart" ); + static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarChart" ); BitmapEx aBmpEx(BMP_PRESOBJ_CHART); Graphic aGraphic( aBmpEx ); - static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic); + static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic); } break; case PresObjKind::OrgChart: { pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage()); - static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarOrg" ); + static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarOrg" ); BitmapEx aBmpEx(BMP_PRESOBJ_ORGCHART); Graphic aGraphic( aBmpEx ); - static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic); + static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic); } break; @@ -377,10 +386,10 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t case PresObjKind::Calc: { pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage()); - static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarCalc" ); + static_cast<SdrOle2Obj*>(pSdrObj.get())->SetProgName( "StarCalc" ); BitmapEx aBmpEx(BMP_PRESOBJ_TABLE); Graphic aGraphic( aBmpEx ); - static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic); + static_cast<SdrOle2Obj*>(pSdrObj.get())->SetGraphic(aGraphic); } break; @@ -422,7 +431,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t case PresObjKind::DateTime: case PresObjKind::SlideNumber: { - pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT); + pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), SdrObjKind::Text); bEmptyPresObj = false; bForceText = true; } @@ -436,9 +445,9 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t pSdrObj->SetEmptyPresObj(bEmptyPresObj); pSdrObj->SetLogicRect(rRect); - InsertObject(pSdrObj); + InsertObject(pSdrObj.get()); - if ( auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj ) ) + if ( auto pTextObj = DynCastSdrTextObj( pSdrObj.get() ) ) { // Tell the object EARLY that it is vertical to have the // defaults for AutoGrowWidth/Height reversed @@ -486,11 +495,11 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t OUString aString = GetPresObjText(eObjKind); if(!aString.isEmpty() || bForceText) - if (auto pTextObj = dynamic_cast<SdrTextObj *>( pSdrObj ) ) + if (auto pTextObj = DynCastSdrTextObj( pSdrObj.get() ) ) { SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner(); - OutlinerMode nOutlMode = pOutliner->GetMode(); + OutlinerMode nOutlMode = pOutliner->GetOutlinerMode(); pOutliner->Init( OutlinerMode::TextObject ); pOutliner->SetStyleSheet( 0, nullptr ); pOutliner->SetVertical( bVertical ); @@ -579,13 +588,13 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t pUndoManager->AddUndoAction( std::make_unique<UndoObjectUserCall>(*pSdrObj) ); } - InsertPresObj(pSdrObj, eObjKind); + InsertPresObj(pSdrObj.get(), eObjKind); pSdrObj->SetUserCall(this); pSdrObj->RecalcBoundRect(); } - return pSdrObj; + return pSdrObj.get(); } /************************************************************************* @@ -671,7 +680,7 @@ SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const if( nIndex != -1 ) aStyleName = aStyleName.copy(0, nIndex + aSep.getLength()); - const char *pNameId; + OUString pNameId; bool bOutline = false; switch( nHelpId ) { @@ -694,7 +703,7 @@ SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const OSL_FAIL( "SdPage::getPresentationStyle(), illegal argument!" ); return nullptr; } - aStyleName += OUString::createFromAscii(pNameId); + aStyleName += pNameId; if (bOutline) { aStyleName += " " + @@ -815,8 +824,8 @@ void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate ) // handout template // delete all available handout presentation objects - SdrObject *pObj=nullptr; - while( (pObj = pMasterPage->GetPresObj(PresObjKind::Handout)) != nullptr ) + rtl::Reference<SdrObject> pObj; + while( (pObj = pMasterPage->GetPresObj(PresObjKind::Handout)) ) { pMasterPage->RemoveObject(pObj->GetOrdNum()); @@ -824,10 +833,7 @@ void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate ) { pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); } - else - { - SdrObject::Free( pObj ); - } + pObj.clear(); } std::vector< ::tools::Rectangle > aAreas; @@ -962,7 +968,7 @@ void getPresObjProp( const SdPage& rPage, const char* sObjKind, const char* sPag } -SdrObject* SdPage::CreateDefaultPresObj(PresObjKind eObjKind) +rtl::Reference<SdrObject> SdPage::CreateDefaultPresObj(PresObjKind eObjKind) { if( eObjKind == PresObjKind::Title ) { @@ -1059,9 +1065,6 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind) pDoc->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject)); SdrObjList* pOL = pObject->getParentSdrObjListFromSdrObject(); pOL->RemoveObject(pObject->GetOrdNumDirect()); - - if( !bUndo ) - SdrObject::Free(pObject); } } @@ -1089,7 +1092,7 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind) const char* sPageKind = PageKindVector[mePageKind]; if (mePageKind == PageKind::Standard) - { + { getPresObjProp( *this , "PRESOBJ_TITLE" ,sPageKind, propvalue); aTitlePos.AdjustX(::tools::Long( aTitleSize.Width() * propvalue[2] ) ); aTitlePos.AdjustY(::tools::Long( aTitleSize.Height() * propvalue[3] ) ); @@ -1224,8 +1227,8 @@ struct LayoutDescriptor LayoutDescriptor::LayoutDescriptor( PresObjKind k0, PresObjKind k1, PresObjKind k2, PresObjKind k3, PresObjKind k4, PresObjKind k5, PresObjKind k6 ) { - auto removeVertical = [&] (PresObjKind k) { return static_cast<PresObjKind>(static_cast<int>(k) & ~VERTICAL); }; - auto isVertical = [&] (PresObjKind k) { return bool(static_cast<int>(k) & VERTICAL); }; + auto removeVertical = [] (PresObjKind k) { return static_cast<PresObjKind>(static_cast<int>(k) & ~VERTICAL); }; + auto isVertical = [] (PresObjKind k) { return bool(static_cast<int>(k) & VERTICAL); }; meKind[0] = removeVertical(k0); mbVertical[0] = isVertical(k0); meKind[1] = removeVertical(k1); mbVertical[1] = isVertical(k1); meKind[2] = removeVertical(k2); mbVertical[2] = isVertical(k2); @@ -1427,19 +1430,19 @@ static void CalcAutoLayoutRectangles( SdPage const & rPage,::tools::Rectangle* r if(count == 0) { Size aSize ( aTitleRect.GetSize() ); - aSize.setHeight( basegfx::fround(aSize.Height() * propvalue[0]) ); - aSize.setWidth( basegfx::fround(aSize.Width() * propvalue[1]) ); - Point aPos( basegfx::fround(aTitlePos.X() +(aSize.Width() * propvalue[2])), - basegfx::fround(aTitlePos.Y() + (aSize.Height() * propvalue[3])) ); + aSize.setHeight( basegfx::fround<::tools::Long>(aSize.Height() * propvalue[0]) ); + aSize.setWidth( basegfx::fround<::tools::Long>(aSize.Width() * propvalue[1]) ); + Point aPos( basegfx::fround<::tools::Long>(aTitlePos.X() +(aSize.Width() * propvalue[2])), + basegfx::fround<::tools::Long>(aTitlePos.Y() + (aSize.Height() * propvalue[3])) ); rRectangle[count] = ::tools::Rectangle(aPos, aSize); count = count+1; } else { - Size aSize( basegfx::fround(aLayoutSize.Width() * propvalue[1]), - basegfx::fround(aLayoutSize.Height() * propvalue[0]) ); - Point aPos( basegfx::fround(aLayoutPos.X() +(aSize.Width() * propvalue[2])), - basegfx::fround(aLayoutPos.Y() + (aSize.Height() * propvalue[3])) ); + Size aSize( basegfx::fround<::tools::Long>(aLayoutSize.Width() * propvalue[1]), + basegfx::fround<::tools::Long>(aLayoutSize.Height() * propvalue[0]) ); + Point aPos( basegfx::fround<::tools::Long>(aLayoutPos.X() +(aSize.Width() * propvalue[2])), + basegfx::fround<::tools::Long>(aLayoutPos.Y() + (aSize.Height() * propvalue[3])) ); rRectangle[count] = ::tools::Rectangle (aPos, aSize); count = count+1; } @@ -1511,24 +1514,24 @@ static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDe switch( eKind ) { case PresObjKind::Title: - bFound = eSdrObjKind == OBJ_TITLETEXT; + bFound = eSdrObjKind == SdrObjKind::TitleText; break; case PresObjKind::Table: - bFound = eSdrObjKind == OBJ_TABLE; + bFound = eSdrObjKind == SdrObjKind::Table; break; case PresObjKind::Media: - bFound = eSdrObjKind == OBJ_MEDIA; + bFound = eSdrObjKind == SdrObjKind::Media; break; case PresObjKind::Outline: - bFound = (eSdrObjKind == OBJ_OUTLINETEXT) || - ((eSdrObjKind == OBJ_TEXT) && bPresStyle) || - (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2); + bFound = (eSdrObjKind == SdrObjKind::OutlineText) || + ((eSdrObjKind == SdrObjKind::Text) && bPresStyle) || + (eSdrObjKind == SdrObjKind::Table) || (eSdrObjKind == SdrObjKind::Media) || (eSdrObjKind == SdrObjKind::Graphic) || (eSdrObjKind == SdrObjKind::OLE2); break; case PresObjKind::Graphic: - bFound = eSdrObjKind == OBJ_GRAF; + bFound = eSdrObjKind == SdrObjKind::Graphic; break; case PresObjKind::Object: - if( eSdrObjKind == OBJ_OLE2 ) + if( eSdrObjKind == SdrObjKind::OLE2 ) { SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj ); if( pOle2 ) @@ -1560,12 +1563,12 @@ static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDe } } } - } + } } break; case PresObjKind::Chart: case PresObjKind::Calc: - if( eSdrObjKind == OBJ_OLE2 ) + if( eSdrObjKind == SdrObjKind::OLE2 ) { SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj ); if( pOle2 ) @@ -1582,18 +1585,18 @@ static void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDe } break; } - else if( eSdrObjKind == OBJ_TABLE ) + else if( eSdrObjKind == SdrObjKind::Table ) { bFound = true; } break; case PresObjKind::Page: case PresObjKind::Handout: - bFound = eSdrObjKind == OBJ_PAGE; + bFound = eSdrObjKind == SdrObjKind::Page; break; case PresObjKind::Notes: case PresObjKind::Text: - bFound = (bPresStyle && (eSdrObjKind == OBJ_TEXT)) || (eSdrObjKind == OBJ_OUTLINETEXT); + bFound = (bPresStyle && (eSdrObjKind == SdrObjKind::Text)) || (eSdrObjKind == SdrObjKind::OutlineText); break; default: break; @@ -1649,12 +1652,12 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate ) if( !bInit ) return; - SdrObject* pObj = nullptr; maPresentationShapeList.seekShape(0); + rtl::Reference<SdrObject> pObj; while( (pObj = maPresentationShapeList.getNextShape()) ) { - if( aUsedPresentationObjects.count(pObj) == 0 ) + if( aUsedPresentationObjects.count(pObj.get()) == 0 ) { if( pObj->IsEmptyPresObj() ) @@ -1663,9 +1666,7 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate ) pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); RemoveObject( pObj->GetOrdNum() ); - - if( !bUndo ) - SdrObject::Free( pObj ); + pObj.clear(); } /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */ } @@ -1703,7 +1704,7 @@ void SdPage::NbcInsertObject(SdrObject* pObj, size_t nPos) |* \************************************************************************/ -SdrObject* SdPage::RemoveObject(size_t nObjNum) +rtl::Reference<SdrObject> SdPage::RemoveObject(size_t nObjNum) { onRemoveObject(GetObj( nObjNum )); return FmFormPage::RemoveObject(nObjNum); @@ -1715,7 +1716,7 @@ SdrObject* SdPage::RemoveObject(size_t nObjNum) |* \************************************************************************/ -SdrObject* SdPage::NbcRemoveObject(size_t nObjNum) +rtl::Reference<SdrObject> SdPage::NbcRemoveObject(size_t nObjNum) { onRemoveObject(GetObj( nObjNum )); return FmFormPage::NbcRemoveObject(nObjNum); @@ -1723,7 +1724,7 @@ SdrObject* SdPage::NbcRemoveObject(size_t nObjNum) // Also override ReplaceObject methods to realize when // objects are removed with this mechanism instead of RemoveObject -SdrObject* SdPage::ReplaceObject(SdrObject* pNewObj, size_t nObjNum) +rtl::Reference<SdrObject> SdPage::ReplaceObject(SdrObject* pNewObj, size_t nObjNum) { onRemoveObject(GetObj( nObjNum )); return FmFormPage::ReplaceObject(pNewObj, nObjNum); @@ -1809,7 +1810,6 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rN sd::ScopeLockGuard aGuard( maLockAutoLayoutArrangement ); mbScaleObjects = bScaleAllObj; - SdrObject* pObj = nullptr; Point aRefPnt(0, 0); Size aNewPageSize(rNewPageSize); sal_Int32 nLeft = rNewBorderRect.Left(); @@ -1859,16 +1859,16 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rN Fraction aFractX(aNewPageSize.Width(), nOldWidth); Fraction aFractY(aNewPageSize.Height(), nOldHeight); - const size_t nObjCnt = (mbScaleObjects ? GetObjCount() : 0); + if (!mbScaleObjects) + return; - for (size_t nObj = 0; nObj < nObjCnt; ++nObj) + for (const rtl::Reference<SdrObject>& pObj : *this) { bool bIsPresObjOnMaster = false; // all Objects - pObj = GetObj(nObj); - if (mbMaster && IsPresObj(pObj)) + if (mbMaster && IsPresObj(pObj.get())) { // There is a presentation object on the master page bIsPresObjOnMaster = true; @@ -2010,9 +2010,9 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rN } } } - else if ( eObjKind != OBJ_TITLETEXT && - eObjKind != OBJ_OUTLINETEXT && - dynamic_cast< const SdrTextObj *>( pObj ) != nullptr && + else if ( eObjKind != SdrObjKind::TitleText && + eObjKind != SdrObjKind::OutlineText && + DynCastSdrTextObj( pObj.get() ) != nullptr && pObj->GetOutlinerParaObject() ) { /****************************************************** @@ -2060,7 +2060,7 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rN } } -static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect) +static rtl::Reference<SdrObject> convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect) { SdDrawDocument& rModel(static_cast< SdDrawDocument& >(rPage.getSdrModelFromSdrPage())); if( !pSourceObj ) @@ -2069,8 +2069,8 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc SfxUndoManager* pUndoManager = rModel.GetUndoManager(); const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted(); - SdrObject* pNewObj = pSourceObj; - if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() == OBJ_TEXT) ) + rtl::Reference<SdrObject> pNewObj = pSourceObj; + if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() == SdrObjKind::Text) ) { pNewObj = rPage.CreatePresObj(PresObjKind::Outline, bVertical, rRect); @@ -2083,9 +2083,8 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc SdOutliner* pOutl = rModel.GetInternalOutliner(); pOutl->Clear(); pOutl->SetText( *pOutlParaObj ); - std::unique_ptr<OutlinerParaObject> pNew = pOutl->CreateParaObject(); - pOutlParaObj = pNew.get(); - pNewObj->SetOutlinerParaObject( std::move(pNew) ); + pNewObj->SetOutlinerParaObject( pOutl->CreateParaObject() ); + pOutlParaObj = pNewObj->GetOutlinerParaObject(); pOutl->Clear(); pNewObj->SetEmptyPresObj(false); @@ -2105,7 +2104,7 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc } // Remove LRSpace item - SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} ); + SfxItemSetFixed<EE_PARA_LRSPACE, EE_PARA_LRSPACE> aSet(rModel.GetPool()); aSet.Put(pNewObj->GetMergedItemSet()); @@ -2118,12 +2117,9 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc // Remove outline shape from page rPage.RemoveObject( pSourceObj->GetOrdNum() ); - - if( !bUndo ) - SdrObject::Free( pSourceObj ); } } - else if((eObjKind == PresObjKind::Text) && (pSourceObj->GetObjIdentifier() == OBJ_OUTLINETEXT) ) + else if((eObjKind == PresObjKind::Text) && (pSourceObj->GetObjIdentifier() == SdrObjKind::OutlineText) ) { // is there an outline shape we can use to replace empty subtitle shape? pNewObj = rPage.CreatePresObj(PresObjKind::Text, bVertical, rRect); @@ -2142,7 +2138,7 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc pNewObj->SetEmptyPresObj(false); // reset left indent - SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} ); + SfxItemSetFixed<EE_PARA_LRSPACE, EE_PARA_LRSPACE> aSet(rModel.GetPool()); aSet.Put(pNewObj->GetMergedItemSet()); @@ -2162,19 +2158,16 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc pUndoManager->AddUndoAction(rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj)); rPage.RemoveObject( pSourceObj->GetOrdNum() ); - - if( !bUndo ) - SdrObject::Free( pSourceObj ); } } - else if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() != OBJ_OUTLINETEXT) ) + else if((eObjKind == PresObjKind::Outline) && (pSourceObj->GetObjIdentifier() != SdrObjKind::OutlineText) ) { switch( pSourceObj->GetObjIdentifier() ) { - case OBJ_TABLE: eObjKind = PresObjKind::Table; break; - case OBJ_MEDIA: eObjKind = PresObjKind::Media; break; - case OBJ_GRAF: eObjKind = PresObjKind::Graphic; break; - case OBJ_OLE2: eObjKind = PresObjKind::Object; break; + case SdrObjKind::Table: eObjKind = PresObjKind::Table; break; + case SdrObjKind::Media: eObjKind = PresObjKind::Media; break; + case SdrObjKind::Graphic: eObjKind = PresObjKind::Graphic; break; + case SdrObjKind::OLE2: eObjKind = PresObjKind::Object; break; default: break; } } @@ -2198,8 +2191,9 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc @returns A presentation shape that was either found or created with the given parameters */ -SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit) +SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj1, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit) { + rtl::Reference<SdrObject> pObj = pObj1; SfxUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager()); const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted(); @@ -2211,7 +2205,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, { // convert object if shape type does not match kind (f.e. converting outline text to subtitle text) if( bInit ) - pObj = convertPresentationObjectImpl(*this, pObj, eObjKind, bVertical, rRect); + pObj = convertPresentationObjectImpl(*this, pObj.get(), eObjKind, bVertical, rRect); if( bUndo ) { @@ -2224,7 +2218,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, pObj->SetUserCall(this); - SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >(pObj); + SdrTextObj* pTextObject = DynCastSdrTextObj(pObj.get()); if( pTextObject ) { if( pTextObject->IsVerticalWriting() != bVertical ) @@ -2237,7 +2231,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK )); } - if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) ) + if( !mbMaster && (pTextObject->GetObjIdentifier() != SdrObjKind::Table) ) { if ( pTextObject->IsAutoGrowHeight() ) { @@ -2277,12 +2271,12 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, if(pObj && bInit ) { - if( !IsPresObj( pObj ) ) + if( !IsPresObj( pObj.get() ) ) { if( bUndo ) pUndoManager->AddUndoAction( std::make_unique<UndoObjectPresentationKind>( *pObj ) ); - InsertPresObj( pObj, eObjKind ); + InsertPresObj( pObj.get(), eObjKind ); } // make adjustments for vertical title and outline shapes @@ -2300,10 +2294,10 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, } } - if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || dynamic_cast< const SdrGrafObj *>( pObj ) == nullptr ) ) + if ( pObj && (pObj->GetUserCall() || bInit) && ( pObj->IsEmptyPresObj() || dynamic_cast< const SdrGrafObj *>( pObj.get() ) == nullptr ) ) pObj->AdjustToMaxRect(rRect); - return pObj; + return pObj.get(); } /************************************************************************* @@ -2375,13 +2369,12 @@ void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eO pOutl->SetEditTextObjectPool(pPool); pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool())); pOutl->EnableUndo(false); - pOutl->SetUpdateMode( false ); + pOutl->SetUpdateLayout( false ); } - OutlinerMode nOutlMode = pOutl->GetMode(); + OutlinerMode nOutlMode = pOutl->GetOutlinerMode(); Size aPaperSize = pOutl->GetPaperSize(); - bool bUpdateMode = pOutl->GetUpdateMode(); - pOutl->SetUpdateMode(false); + bool bUpdateMode = pOutl->SetUpdateLayout(false); pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() ); // Always set the object's StyleSheet at the Outliner to @@ -2481,7 +2474,7 @@ void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eO // restore the outliner pOutl->Init( nOutlMode ); pOutl->SetParaAttribs( 0, pOutl->GetEmptyItemSet() ); - pOutl->SetUpdateMode( bUpdateMode ); + pOutl->SetUpdateLayout( bUpdateMode ); pOutl->SetPaperSize( aPaperSize ); } } @@ -2519,9 +2512,10 @@ const OUString& SdPage::GetName() const // default name for handout pages sal_uInt16 nNum = (GetPageNum() + 1) / 2; - aCreatedPageName = SdResId(STR_PAGE) + " "; if (static_cast<SdDrawDocument&>(getSdrModelFromSdrPage()).GetDocumentType() == DocumentType::Draw ) aCreatedPageName = SdResId(STR_PAGE_NAME) + " "; + else + aCreatedPageName = SdResId(STR_PAGE) + " "; if( getSdrModelFromSdrPage().GetPageNumType() == css::style::NumberingType::NUMBER_NONE ) { @@ -2690,7 +2684,7 @@ SdPage* SdPage::getImplementation( const css::uno::Reference< css::drawing::XDra { try { - auto pUnoPage = comphelper::getUnoTunnelImplementation<SvxDrawPage>(xPage); + auto pUnoPage = comphelper::getFromUnoTunnel<SvxDrawPage>(xPage); if( pUnoPage ) return static_cast< SdPage* >( pUnoPage->GetSdrPage() ); } @@ -2808,13 +2802,14 @@ bool SdPage::checkVisibility( const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage); // empty presentation objects only visible during edit mode - if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() ) + if( (bIsPrinting || !bEdit || bIsInsidePageObj ) && pObj->IsEmptyPresObj() && !(pObj->HasFillStyle() || pObj->HasLineStyle()) ) { - if( (pObj->GetObjInventor() != SdrInventor::Default) || ( (pObj->GetObjIdentifier() != OBJ_RECT) && (pObj->GetObjIdentifier() != OBJ_PAGE) ) ) + if( (pObj->GetObjInventor() != SdrInventor::Default) || ( (pObj->GetObjIdentifier() != SdrObjKind::Rectangle) && + (pObj->GetObjIdentifier() != SdrObjKind::Page) ) ) return false; } - if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_TEXT ) ) + if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == SdrObjKind::Text ) ) { const SdPage* pCheckPage = dynamic_cast< const SdPage* >(pObj->getSdrPageFromSdrObject()); @@ -2861,7 +2856,7 @@ bool SdPage::checkVisibility( } // i63977, do not print SdrpageObjs from master pages - if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == OBJ_PAGE ) ) + if( ( pObj->GetObjInventor() == SdrInventor::Default ) && ( pObj->GetObjIdentifier() == SdrObjKind::Page ) ) { if( pObj->getSdrPageFromSdrObject() && pObj->getSdrPageFromSdrObject()->IsMasterPage() ) return false; @@ -2874,7 +2869,7 @@ bool SdPage::RestoreDefaultText( SdrObject* pObj ) { bool bRet = false; - SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj ); + SdrTextObj* pTextObj = DynCastSdrTextObj( pObj ); if( pTextObj ) { @@ -2892,7 +2887,7 @@ bool SdPage::RestoreDefaultText( SdrObject* pObj ) bool bVertical = false; OutlinerParaObject* pOldPara = pTextObj->GetOutlinerParaObject(); if( pOldPara ) - bVertical = pOldPara->IsVertical(); // is old para object vertical? + bVertical = pOldPara->IsEffectivelyVertical(); // is old para object vertical? SetObjText( pTextObj, nullptr, ePresObjKind, aString ); @@ -2903,7 +2898,7 @@ bool SdPage::RestoreDefaultText( SdrObject* pObj ) // AutoGrowWidth/Height items still exist in the // not changed object. if(pTextObj->GetOutlinerParaObject() - && pTextObj->GetOutlinerParaObject()->IsVertical() != bVertical) + && pTextObj->GetOutlinerParaObject()->IsEffectivelyVertical() != bVertical) { ::tools::Rectangle aObjectRect = pTextObj->GetSnapRect(); pTextObj->GetOutlinerParaObject()->SetVertical(bVertical); |