presentation placeholder rework

This commit is contained in:
Christian Lippka
2010-02-23 00:23:09 +01:00
parent 9a0e6f1451
commit 1294294cc6
11 changed files with 126 additions and 116 deletions

View File

@@ -50,6 +50,8 @@ enum PresObjKind
PRESOBJ_FOOTER,
PRESOBJ_DATETIME,
PRESOBJ_SLIDENUMBER,
PRESOBJ_CALC,
PRESOBJ_MEDIA,
PRESOBJ_MAX
};

View File

@@ -214,9 +214,6 @@ public:
/** inserts the given SdrObject into the presentation object list */
void InsertPresObj(SdrObject* pObj, PresObjKind eKind );
/** replace the given SdrObject with the new SdrObject in the presentation object list */
void ReplacePresObj(SdrObject* pOldObj, SdrObject* pNewObj, PresObjKind eNewKind );
void SetAutoLayout(AutoLayout eLayout, BOOL bInit=FALSE, BOOL bCreate=FALSE);
AutoLayout GetAutoLayout() const { return meAutoLayout; }
void CreateTitleAndLayout(BOOL bInit=FALSE, BOOL bCreate=FALSE);

View File

@@ -161,10 +161,20 @@ SdPage::~SdPage()
delete mpItems;
}
struct OrdNumSorter
{
bool operator()( SdrObject* p1, SdrObject* p2 )
{
return p1->GetOrdNum() < p2->GetOrdNum();
}
};
/** returns the nIndex'th object from the given PresObjKind, index starts with 1 */
SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearch /* = false */ )
{
int nObjFound = 0; // index of the searched object
// first sort all matching shapes with z-order
std::vector< SdrObject* > aMatches;
SdrObject* pObj = 0;
while( (pObj = maPresentationShapeList.getNextShape(pObj)) != 0 )
{
@@ -185,7 +195,9 @@ SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearc
case PRESOBJ_CHART:
case PRESOBJ_ORGCHART:
case PRESOBJ_TABLE:
case PRESOBJ_CALC:
case PRESOBJ_IMAGE:
case PRESOBJ_MEDIA:
bFound = TRUE;
break;
default:
@@ -194,13 +206,23 @@ SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearc
}
if( bFound )
{
nObjFound++; // found one
if( nObjFound == nIndex )
return pObj;
aMatches.push_back( pObj );
}
}
}
if( aMatches.size() > 1 )
{
OrdNumSorter aSortHelper;
std::sort( aMatches.begin(), aMatches.end(), aSortHelper );
}
if( nIndex > 0 )
nIndex--;
if( aMatches.size() > nIndex )
return aMatches[nIndex];
return 0;
}
@@ -276,6 +298,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, BOOL bVertical, const Rec
}
break;
case PRESOBJ_MEDIA:
case PRESOBJ_OBJECT:
{
pSdrObj = new SdrOle2Obj();
@@ -305,6 +328,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, BOOL bVertical, const Rec
}
case PRESOBJ_TABLE:
case PRESOBJ_CALC:
{
pSdrObj = new SdrOle2Obj();
( (SdrOle2Obj*) pSdrObj)->SetProgName( String( RTL_CONSTASCII_USTRINGPARAM( "StarCalc" )));
@@ -514,7 +538,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, BOOL bVertical, const Rec
if ( eObjKind == PRESOBJ_OBJECT ||
eObjKind == PRESOBJ_CHART ||
eObjKind == PRESOBJ_ORGCHART ||
eObjKind == PRESOBJ_TABLE ||
eObjKind == PRESOBJ_CALC ||
eObjKind == PRESOBJ_GRAPHIC )
{
SfxItemSet aSet( ((SdDrawDocument*) pModel)->GetPool() );
@@ -1424,6 +1448,12 @@ void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescripto
case PRESOBJ_TITLE:
bFound = eSdrObjKind == OBJ_TITLETEXT;
break;
case PRESOBJ_TABLE:
bFound = eSdrObjKind == OBJ_TABLE;
break;
case PRESOBJ_MEDIA:
bFound = eSdrObjKind == OBJ_MEDIA;
break;
case PRESOBJ_OUTLINE:
bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
@@ -1469,7 +1499,7 @@ void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescripto
}
break;
case PRESOBJ_CHART:
case PRESOBJ_TABLE:
case PRESOBJ_CALC:
if( eSdrObjKind == OBJ_OLE2 )
{
SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( pObj );
@@ -1479,7 +1509,7 @@ void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescripto
((eKind == PRESOBJ_CHART) &&
( pOle2->GetProgName().EqualsAscii( "StarChart" ) || pOle2->IsChart() ) )
||
((eKind == PRESOBJ_TABLE) &&
((eKind == PRESOBJ_CALC) &&
( pOle2->GetProgName().EqualsAscii( "StarCalc" ) || pOle2->IsCalc() ) ) )
{
bFound = true;
@@ -2199,23 +2229,6 @@ SdrObject* convertPresentationObjectImpl( SdPage& rPage, SdrObject* pSourceObj,
return pNewObj;
}
static void SetLogicRect( SdrObject* pObj, Rectangle& rLogicRect )
{
if( pObj )
{
if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
{
Rectangle aRect( rLogicRect );
aRect.setHeight( pObj->GetLogicRect().getHeight() );
pObj->SetLogicRect( aRect );
}
else
{
pObj->SetLogicRect( rLogicRect );
}
}
}
/** reuses or creates a presentation shape for an auto layout that fits the given parameter
@param eObjKind
@@ -2254,10 +2267,10 @@ SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind,
pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
}
if ( pObj->ISA(SdrGrafObj) && !pObj->IsEmptyPresObj() )
( (SdrGrafObj*) pObj)->AdjustToMaxRect( aRect, FALSE );
else
SetLogicRect( pObj, aRect );
// if ( pObj->ISA(SdrGrafObj) && !pObj->IsEmptyPresObj() )
( /*(SdrGrafObj*)*/ pObj)->AdjustToMaxRect( aRect );
// else
// SetLogicRect( pObj, aRect );
pObj->SetUserCall(this);
@@ -2338,7 +2351,7 @@ SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind,
}
if ( pObj && ( pObj->IsEmptyPresObj() || !pObj->ISA(SdrGrafObj) ) )
SetLogicRect( pObj, aRect );
pObj->AdjustToMaxRect( aRect );
return pObj;
}
@@ -2392,25 +2405,6 @@ void SdPage::InsertPresObj(SdrObject* pObj, PresObjKind eKind )
}
}
void SdPage::ReplacePresObj(SdrObject* pOldObj, SdrObject* pNewObj, PresObjKind eNewKind )
{
if( !pNewObj )
{
RemovePresObj( pOldObj );
}
else if( pOldObj )
{
SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pNewObj, true);
if( pInfo )
pInfo->mePresObjKind = eNewKind;
maPresentationShapeList.replaceShape(*pOldObj, *pNewObj);
}
else
{
InsertPresObj( pNewObj, eNewKind );
}
}
/*************************************************************************
|*
|* Text des Objektes setzen
@@ -2775,7 +2769,7 @@ String SdPage::GetPresObjText(PresObjKind eObjKind) const
{
aString = String ( SdResId( STR_PRESOBJ_ORGCHART ) );
}
else if (eObjKind == PRESOBJ_TABLE)
else if (eObjKind == PRESOBJ_CALC)
{
aString = String ( SdResId( STR_PRESOBJ_TABLE ) );
}

View File

@@ -2437,7 +2437,7 @@ SdrObject* ImplSdPPTImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pObj
case PPT_PLACEHOLDER_MEDIACLIP :
case PPT_PLACEHOLDER_OBJECT : ePresObjKind = PRESOBJ_OBJECT; break;
case PPT_PLACEHOLDER_GRAPH : ePresObjKind = PRESOBJ_CHART; break;
case PPT_PLACEHOLDER_TABLE : ePresObjKind = PRESOBJ_TABLE; break;
case PPT_PLACEHOLDER_TABLE : ePresObjKind = PRESOBJ_CALC; break;
case PPT_PLACEHOLDER_CLIPART : ePresObjKind = PRESOBJ_GRAPHIC; break;
case PPT_PLACEHOLDER_ORGANISZATIONCHART : ePresObjKind = PRESOBJ_ORGCHART; break;
}

View File

@@ -368,19 +368,8 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
if(pPage && pPage->IsPresObj(pPickObj))
{
bUndo = mpView->IsUndoEnabled();
if( bUndo )
mpView->BegUndo( SdrUndoNewObj::GetComment(*pOleObj) );
// add new PresObj to the list
pPage->InsertPresObj( pOleObj, ePresObjKind );
pOleObj->SetUserCall(pPickObj->GetUserCall());
if( bUndo )
{
mpView->AddUndo( new sd::UndoObjectPresentationKind( *pPickObj ) );
mpView->AddUndo( new sd::UndoObjectPresentationKind( *pOleObj ) );
}
pPage->ReplacePresObj(pPickObj, pOleObj, ePresObjKind);
}
}
@@ -423,11 +412,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
}
}
if( bUndo )
{
mpView->EndUndo();
}
else if( pPickObj )
if( !mpView->IsUndoEnabled() && pPickObj )
{
// replaced object must be freed if there is no undo action owning it
SdrObject::Free( pPickObj );

View File

@@ -177,26 +177,14 @@ void DrawViewShell::FuTable(SfxRequest& rReq)
apply_table_style( pObj, GetDoc(), sTableStyle );
SdrPageView* pPV = mpView->GetSdrPageView();
bool bUndo = false;
// if we have a pick obj we need to make this new ole a pres obj replacing the current pick obj
if( pPickObj )
{
SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
if(pPage && pPage->IsPresObj(pPickObj))
{
bUndo = mpView->IsUndoEnabled();
if( bUndo )
mpView->BegUndo( SdrUndoNewObj::GetComment(*pObj) );
// add new PresObj to the list
pObj->SetUserCall(pPickObj->GetUserCall());
if( bUndo )
{
mpView->AddUndo( new sd::UndoObjectPresentationKind( *pPickObj ) );
mpView->AddUndo( new sd::UndoObjectPresentationKind( *pObj ) );
}
pPage->ReplacePresObj(pPickObj, pObj, PRESOBJ_TABLE);
pObj->SetUserCall( pPickObj->GetUserCall() );
pPage->InsertPresObj( pObj, PRESOBJ_TABLE );
}
}
@@ -205,11 +193,7 @@ void DrawViewShell::FuTable(SfxRequest& rReq)
else
mpView->InsertObjectAtView(pObj, *pPV, SDRINSERT_SETDEFLAYER);
if( bUndo )
{
mpView->EndUndo();
}
else if( pPickObj )
if( !mpView->IsUndoEnabled() && pPickObj )
{
// replaced object must be freed if there is no undo action owning it
SdrObject::Free( pPickObj );

View File

@@ -1083,10 +1083,14 @@ uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( c
{
nType = OBJ_OLE2;
}
else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
else if( aType.EqualsAscii( "CalcShape", 26, 9 ) )
{
nType = OBJ_OLE2;
}
else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
{
nType = OBJ_TABLE;
}
else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) )
{
nType = OBJ_OLE2;
@@ -1115,9 +1119,9 @@ uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( c
{
nType = OBJ_TEXT;
}
else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
else if( aType.EqualsAscii( "MediaShape", 26, 10 ) )
{
nType = OBJ_TABLE;
nType = OBJ_MEDIA;
}
else
{
@@ -1168,7 +1172,7 @@ uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames(
const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
uno::Sequence< OUString > aSNS( mbImpressDoc ? (34) : (19) );
uno::Sequence< OUString > aSNS( mbImpressDoc ? (36) : (19) );
sal_uInt16 i(0);
@@ -1211,6 +1215,8 @@ uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames(
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HeaderShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SlideNumberShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.DateTimeShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.CalcShape"));
aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.MediaShape"));
}
else
{

View File

@@ -412,7 +412,7 @@ SdrObject * SdGenericDrawPage::_CreateSdrObject( const Reference< drawing::XShap
String aType( xShape->getShapeType() );
const String aPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.") );
if(aType.CompareTo( aPrefix, aPrefix.Len() ) != 0)
if( aType.CompareTo( aPrefix, aPrefix.Len() ) != 0 )
{
SdrObject* pObj = SvxFmDrawPage::_CreateSdrObject( xShape );
if( pObj && ( (pObj->GetObjInventor() != SdrInventor) || (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
@@ -448,6 +448,10 @@ SdrObject * SdGenericDrawPage::_CreateSdrObject( const Reference< drawing::XShap
{
eObjKind = PRESOBJ_CHART;
}
else if( aType.EqualsAscii( "CalcShape" ) )
{
eObjKind = PRESOBJ_CALC;
}
else if( aType.EqualsAscii( "TableShape" ) )
{
eObjKind = PRESOBJ_TABLE;
@@ -495,6 +499,10 @@ SdrObject * SdGenericDrawPage::_CreateSdrObject( const Reference< drawing::XShap
{
eObjKind = PRESOBJ_DATETIME;
}
else if( aType.EqualsAscii( "MediaShape" ) )
{
eObjKind = PRESOBJ_MEDIA;
}
Rectangle aRect( eObjKind == PRESOBJ_TITLE ? GetPage()->GetTitleRect() : GetPage()->GetLayoutRect() );
@@ -504,7 +512,22 @@ SdrObject * SdGenericDrawPage::_CreateSdrObject( const Reference< drawing::XShap
const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() );
xShape->setSize( aSize );
SdrObject *pPresObj = GetPage()->CreatePresObj( eObjKind, FALSE, aRect, sal_True );
SdrObject *pPresObj = 0;
if( (eObjKind == PRESOBJ_TABLE) || (eObjKind == PRESOBJ_MEDIA) )
{
pPresObj = SvxFmDrawPage::_CreateSdrObject( xShape );
if( pPresObj )
{
SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel();
if( pDoc )
pPresObj->NbcSetStyleSheet( pDoc->GetDefaultStyleSheet(), sal_True );
GetPage()->InsertPresObj( pPresObj, eObjKind );
}
}
else
{
pPresObj = GetPage()->CreatePresObj( eObjKind, FALSE, aRect, sal_True );
}
if( pPresObj )
pPresObj->SetUserCall( GetPage() );
@@ -1389,9 +1412,15 @@ Reference< drawing::XShape > SdGenericDrawPage::_CreateShape( SdrObject *pObj )
case PRESOBJ_ORGCHART:
aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OrgChartShape") );
break;
case PRESOBJ_CALC:
aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("CalcShape") );
break;
case PRESOBJ_TABLE:
aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TableShape") );
break;
case PRESOBJ_MEDIA:
aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("MediaShape") );
break;
case PRESOBJ_BACKGROUND:
DBG_ASSERT( sal_False, "Danger! Someone got hold of the horrible background shape!" );
break;

View File

@@ -627,7 +627,9 @@ void DrawView::DeleteMarked()
case PRESOBJ_CHART:
case PRESOBJ_ORGCHART:
case PRESOBJ_TABLE:
case PRESOBJ_CALC:
case PRESOBJ_IMAGE:
case PRESOBJ_MEDIA:
ePresObjKind = PRESOBJ_OUTLINE;
break;
default:
@@ -640,8 +642,6 @@ void DrawView::DeleteMarked()
pPage->SetObjectOrdNum( pNewObj->GetOrdNum(), pObj->GetOrdNum() );
pPage->ReplacePresObj( pObj, pNewObj, ePresObjKind );
bResetLayout = true;
}
}

View File

@@ -145,20 +145,11 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
pNewGrafObj->SetEmptyPresObj(FALSE);
}
const bool bUndo = IsUndoEnabled();
if( bUndo )
BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
if (pPage && pPage->IsPresObj(pPickObj))
{
// Neues PresObj in die Liste eintragen
pPage->InsertPresObj( pNewGrafObj, PRESOBJ_GRAPHIC );
pNewGrafObj->SetUserCall(pPickObj->GetUserCall());
if( bUndo )
{
AddUndo( new sd::UndoObjectPresentationKind( *pPickObj ) );
AddUndo( new sd::UndoObjectPresentationKind( *pNewGrafObj ) );
}
pPage->ReplacePresObj(pPickObj, pNewGrafObj, PRESOBJ_GRAPHIC);
}
if (pImageMap)
@@ -166,11 +157,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView
if( bUndo )
{
EndUndo();
}
else
if( !IsUndoEnabled() && pPickObj )
{
SdrObject::Free( pPickObj );
}
@@ -310,7 +297,7 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
SdrMediaObj* pNewMediaObj = NULL;
SdrPageView* pPV = GetSdrPageView();
SdrObject* pPickObj = NULL;
SdrObject* pPickObj = GetEmptyPresentationObject( PRESOBJ_MEDIA );
if(pPV && this->ISA(::sd::slidesorter::view::SlideSorterView ))
{
@@ -335,10 +322,35 @@ SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAc
}
else if( pPV )
{
pNewMediaObj = new SdrMediaObj( Rectangle( rPos, rSize ) );
Rectangle aRect( rPos, rSize );
if( pPickObj )
aRect = pPickObj->GetLogicRect();
if( pPV && InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER ) )
pNewMediaObj->setURL( rMediaURL );
pNewMediaObj = new SdrMediaObj( aRect );
if( pPickObj )
{
SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
if(pPage && pPage->IsPresObj(pPickObj))
{
pPage->InsertPresObj( pNewMediaObj, PRESOBJ_MEDIA );
pNewMediaObj->SetUserCall(pPickObj->GetUserCall());
}
}
if( pPickObj )
ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
else
InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER );
pNewMediaObj->setURL( rMediaURL );
if( pPickObj )
pNewMediaObj->AdjustToMaxRect( pPickObj->GetLogicRect() );
if( !IsUndoEnabled() )
SdrObject::Free( pPickObj );
}
rAction = mnAction;

View File

@@ -48,6 +48,7 @@ static bool implIsMultiPresObj( PresObjKind eKind )
case PRESOBJ_ORGCHART:
case PRESOBJ_TABLE:
case PRESOBJ_IMAGE:
case PRESOBJ_MEDIA:
return true;
default:
return false;