summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sd/source/core/sdpage.cxx47
-rw-r--r--sd/source/ui/func/fuinsert.cxx126
-rw-r--r--sd/source/ui/table/tablefunction.cxx68
-rw-r--r--sd/source/ui/view/sdview4.cxx11
4 files changed, 197 insertions, 55 deletions
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index f7158b2bff9e..1983205d1fe9 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -1371,16 +1371,20 @@ void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescripto
for( i = 0; (i < PRESOBJ_MAX) && (rDescriptor.meKind[i] != PRESOBJ_NONE); i++ )
{
PresObjKind eKind = rDescriptor.meKind[i];
- SdrObject* pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true );
- if( pObj )
+ SdrObject* pObj = 0;
+ while( (pObj = rPage.GetPresObj( eKind, PresObjIndex[eKind], true )) != 0 )
{
PresObjIndex[eKind]++; // on next search for eKind, find next shape with same eKind
- rShapes[i] = pObj;
+
+ if( !pObj->IsEmptyPresObj() )
+ {
+ rShapes[i] = pObj;
+ break;
+ }
}
- else
- {
+
+ if( !pObj )
bMissing = true;
- }
}
if( bMissing && bInit )
@@ -1421,7 +1425,9 @@ void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescripto
bFound = eSdrObjKind == OBJ_TITLETEXT;
break;
case PRESOBJ_OUTLINE:
- bFound = (eSdrObjKind == OBJ_OUTLINETEXT) || ((eSdrObjKind == OBJ_TEXT) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2) || (eSdrObjKind == OBJ_MEDIA) && bPresStyle);
+ bFound = (eSdrObjKind == OBJ_OUTLINETEXT) ||
+ ((eSdrObjKind == OBJ_TEXT) && bPresStyle) ||
+ (eSdrObjKind == OBJ_TABLE) || (eSdrObjKind == OBJ_MEDIA) || (eSdrObjKind == OBJ_GRAF) || (eSdrObjKind == OBJ_OLE2);
break;
case PRESOBJ_GRAPHIC:
bFound = eSdrObjKind == OBJ_GRAF;
@@ -1481,6 +1487,10 @@ void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescripto
}
break;
}
+ else if( eSdrObjKind == OBJ_TABLE )
+ {
+ bFound = true;
+ }
break;
case PRESOBJ_PAGE:
case PRESOBJ_HANDOUT:
@@ -2189,6 +2199,23 @@ 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
@@ -2230,7 +2257,7 @@ SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind,
if ( pObj->ISA(SdrGrafObj) && !pObj->IsEmptyPresObj() )
( (SdrGrafObj*) pObj)->AdjustToMaxRect( aRect, FALSE );
else
- pObj->SetLogicRect(aRect);
+ SetLogicRect( pObj, aRect );
pObj->SetUserCall(this);
@@ -2247,7 +2274,7 @@ SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind,
pTextObject->SetMergedItem(SdrTextHorzAdjustItem( bVertical ? SDRTEXTHORZADJUST_RIGHT : SDRTEXTHORZADJUST_BLOCK ));
}
- if( !mbMaster )
+ if( !mbMaster && (pTextObject->GetObjIdentifier() != OBJ_TABLE) )
{
if ( pTextObject->IsAutoGrowHeight() )
{
@@ -2311,7 +2338,7 @@ SdrObject* SdPage::InsertAutoLayoutShape( SdrObject* pObj, PresObjKind eObjKind,
}
if ( pObj && ( pObj->IsEmptyPresObj() || !pObj->ISA(SdrGrafObj) ) )
- pObj->SetLogicRect(aRect);
+ SetLogicRect( pObj, aRect );
return pObj;
}
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
index b6f368d09052..daae9f37b49f 100644
--- a/sd/source/ui/func/fuinsert.cxx
+++ b/sd/source/ui/func/fuinsert.cxx
@@ -97,6 +97,7 @@
#include "sdgrffilter.hxx"
#include "sdxfer.hxx"
#include <vcl/svapp.hxx>
+#include "undo/undoobjects.hxx"
using namespace com::sun::star;
@@ -284,6 +285,10 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
nSlotId == SID_INSERT_DIAGRAM ||
nSlotId == SID_INSERT_MATH )
{
+ PresObjKind ePresObjKind = (nSlotId == SID_INSERT_DIAGRAM) ? PRESOBJ_CHART : PRESOBJ_OBJECT;
+
+ SdrObject* pPickObj = mpView->GetEmptyPresentationObject( ePresObjKind );
+
/**********************************************************************
* Diagramm oder StarCalc-Tabelle einfuegen
**********************************************************************/
@@ -302,42 +307,90 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
if ( xObj.is() )
{
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
- awt::Size aSz;
- try
+
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
+
+ Rectangle aRect;
+ if( pPickObj )
{
- aSz = xObj->getVisualAreaSize( nAspect );
+ aRect = pPickObj->GetLogicRect();
+
+ awt::Size aSz;
+ aSz.Width = aRect.GetWidth();
+ aSz.Height = aRect.GetHeight();
+ xObj->setVisualAreaSize( nAspect, aSz );
}
- catch ( embed::NoVisualAreaSizeException& )
+ else
{
- // the default size will be set later
+ awt::Size aSz;
+ try
+ {
+ aSz = xObj->getVisualAreaSize( nAspect );
+ }
+ catch ( embed::NoVisualAreaSizeException& )
+ {
+ // the default size will be set later
+ }
+
+ Size aSize( aSz.Width, aSz.Height );
+
+ if (aSize.Height() == 0 || aSize.Width() == 0)
+ {
+ // Rechteck mit ausgewogenem Kantenverhaeltnis
+ aSize.Width() = 14100;
+ aSize.Height() = 10000;
+ Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aUnit );
+ aSz.Width = aTmp.Width();
+ aSz.Height = aTmp.Height();
+ xObj->setVisualAreaSize( nAspect, aSz );
+ }
+ else
+ {
+ aSize = OutputDevice::LogicToLogic(aSize, aUnit, MAP_100TH_MM);
+ }
+
+ Point aPos;
+ Rectangle aWinRect(aPos, mpWindow->GetOutputSizePixel() );
+ aPos = aWinRect.Center();
+ aPos = mpWindow->PixelToLogic(aPos);
+ aPos.X() -= aSize.Width() / 2;
+ aPos.Y() -= aSize.Height() / 2;
+ aRect = Rectangle(aPos, aSize);
}
- Size aSize( aSz.Width, aSz.Height );
+ SdrOle2Obj* pOleObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aObjName, aRect );
+ SdrPageView* pPV = mpView->GetSdrPageView();
- MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
- if (aSize.Height() == 0 || aSize.Width() == 0)
+ 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 )
{
- // Rechteck mit ausgewogenem Kantenverhaeltnis
- aSize.Width() = 14100;
- aSize.Height() = 10000;
- Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aUnit );
- aSz.Width = aTmp.Width();
- aSz.Height = aTmp.Height();
- xObj->setVisualAreaSize( nAspect, aSz );
+ 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
+ pOleObj->SetUserCall(pPickObj->GetUserCall());
+ if( bUndo )
+ {
+ mpView->AddUndo( new sd::UndoObjectPresentationKind( *pPickObj ) );
+ mpView->AddUndo( new sd::UndoObjectPresentationKind( *pOleObj ) );
+ }
+ pPage->ReplacePresObj(pPickObj, pOleObj, ePresObjKind);
+ }
}
+
+ bool bRet = true;
+ if( pPickObj )
+ mpView->ReplaceObjectAtView(pPickObj, *pPV, pOleObj, TRUE );
else
- aSize = OutputDevice::LogicToLogic(aSize, aUnit, MAP_100TH_MM);
-
- Point aPos;
- Rectangle aWinRect(aPos, mpWindow->GetOutputSizePixel() );
- aPos = aWinRect.Center();
- aPos = mpWindow->PixelToLogic(aPos);
- aPos.X() -= aSize.Width() / 2;
- aPos.Y() -= aSize.Height() / 2;
- Rectangle aRect (aPos, aSize);
- SdrOle2Obj* pOleObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aObjName, aRect );
- SdrPageView* pPV = mpView->GetSdrPageView();
- if( mpView->InsertObjectAtView(pOleObj, *pPV, SDRINSERT_SETDEFLAYER) )
+ bRet = mpView->InsertObjectAtView(pOleObj, *pPV, SDRINSERT_SETDEFLAYER);
+
+ if( bRet )
{
if (nSlotId == SID_INSERT_DIAGRAM)
{
@@ -354,10 +407,11 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
//HMHmpView->HideMarkHdl();
pOleObj->SetLogicRect(aRect);
- Size aTmp = OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aUnit );
- aSz.Width = aTmp.Width();
- aSz.Height = aTmp.Height();
- xObj->setVisualAreaSize( nAspect, aSz );
+ Size aTmp( OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aUnit ) );
+ awt::Size aVisualSize;
+ aVisualSize.Width = aTmp.Width();
+ aVisualSize.Height = aTmp.Height();
+ xObj->setVisualAreaSize( nAspect, aVisualSize );
mpViewShell->ActivateObject(pOleObj, SVVERB_SHOW);
if (nSlotId == SID_INSERT_DIAGRAM)
@@ -368,6 +422,16 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
mpViewShell->AdaptDefaultsForChart( xObj );
}
}
+
+ if( bUndo )
+ {
+ mpView->EndUndo();
+ }
+ else if( pPickObj )
+ {
+ // replaced object must be freed if there is no undo action owning it
+ SdrObject::Free( pPickObj );
+ }
}
else
{
diff --git a/sd/source/ui/table/tablefunction.cxx b/sd/source/ui/table/tablefunction.cxx
index 1d1d38df82bf..dc5f999ff601 100644
--- a/sd/source/ui/table/tablefunction.cxx
+++ b/sd/source/ui/table/tablefunction.cxx
@@ -73,6 +73,7 @@
#include "Window.hxx"
#include "drawview.hxx"
#include "sdresid.hxx"
+#include "undo/undoobjects.hxx"
using ::rtl::OUString;
using namespace ::sd;
@@ -150,21 +151,70 @@ void DrawViewShell::FuTable(SfxRequest& rReq)
nRows = pDlg->getRows();
}
- Size aSize( 14100, 200 );
+ Rectangle aRect;
- Point aPos;
- Rectangle aWinRect(aPos, GetActiveWindow()->GetOutputSizePixel() );
- aPos = aWinRect.Center();
- aPos = GetActiveWindow()->PixelToLogic(aPos);
- aPos.X() -= aSize.Width() / 2;
- aPos.Y() -= aSize.Height() / 2;
- Rectangle aRect (aPos, aSize);
+ SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_TABLE );
+ if( pPickObj )
+ {
+ aRect = pPickObj->GetLogicRect();
+ aRect.setHeight( 200 );
+ }
+ else
+ {
+ Size aSize( 14100, 200 );
+
+ Point aPos;
+ Rectangle aWinRect(aPos, GetActiveWindow()->GetOutputSizePixel() );
+ aPos = aWinRect.Center();
+ aPos = GetActiveWindow()->PixelToLogic(aPos);
+ aPos.X() -= aSize.Width() / 2;
+ aPos.Y() -= aSize.Height() / 2;
+ aRect = Rectangle(aPos, aSize);
+ }
::sdr::table::SdrTableObj* pObj = new ::sdr::table::SdrTableObj( GetDoc(), aRect, nColumns, nRows );
pObj->NbcSetStyleSheet( GetDoc()->GetDefaultStyleSheet(), sal_True );
apply_table_style( pObj, GetDoc(), sTableStyle );
SdrPageView* pPV = mpView->GetSdrPageView();
- mpView->InsertObjectAtView(pObj, *pPV, SDRINSERT_SETDEFLAYER);
+
+ 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);
+ }
+ }
+
+ if( pPickObj )
+ mpView->ReplaceObjectAtView(pPickObj, *pPV, pObj, TRUE );
+ else
+ mpView->InsertObjectAtView(pObj, *pPV, SDRINSERT_SETDEFLAYER);
+
+ if( bUndo )
+ {
+ mpView->EndUndo();
+ }
+ else if( pPickObj )
+ {
+ // replaced object must be freed if there is no undo action owning it
+ SdrObject::Free( pPickObj );
+ }
+
Invalidate(SID_DRAWTBX_INSERT);
rReq.Ignore();
break;
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
index 06db26cc317e..25d1b22dc633 100644
--- a/sd/source/ui/view/sdview4.cxx
+++ b/sd/source/ui/view/sdview4.cxx
@@ -159,11 +159,6 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
AddUndo( new sd::UndoObjectPresentationKind( *pNewGrafObj ) );
}
pPage->ReplacePresObj(pPickObj, pNewGrafObj, PRESOBJ_GRAPHIC);
-
- if( !bUndo )
- {
- SdrObject::Free( pPickObj );
- }
}
if (pImageMap)
@@ -172,7 +167,13 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView
if( bUndo )
+ {
EndUndo();
+ }
+ else
+ {
+ SdrObject::Free( pPickObj );
+ }
}
else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj))
{