summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-08-13 16:14:34 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-08-14 11:17:26 -0400
commit8f6a1b509125e4c0a4ebfb12b42c2a072912fa01 (patch)
tree5ebf6f36c6a46b6cc25a78ea8e890aeb544b2570 /svx
parentbe0de8b9db9c428de5c65be51be2eef17947e4dc (diff)
Scope reduction by early bailout.
Change-Id: If66f732265505a97990cf6c75ff53797a1d91b7a
Diffstat (limited to 'svx')
-rw-r--r--svx/source/unodraw/unopage.cxx150
-rw-r--r--svx/source/unodraw/unoshap2.cxx62
2 files changed, 108 insertions, 104 deletions
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
index f8d91c27712c..cfad41b4c34c 100644
--- a/svx/source/unodraw/unopage.cxx
+++ b/svx/source/unodraw/unopage.cxx
@@ -499,91 +499,91 @@ SdrObject *SvxDrawPage::_CreateSdrObject(const Reference< drawing::XShape > & xS
sal_uInt32 nInventor = 0;
GetTypeAndInventor( nType, nInventor, xShape->getShapeType() );
+ if (!nType)
+ return NULL;
+
SdrObject* pNewObj = 0;
- if( nType != 0 )
+ awt::Size aSize = xShape->getSize();
+ aSize.Width += 1;
+ aSize.Height += 1;
+ awt::Point aPos = xShape->getPosition();
+ Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
+
+ // special cases
+ if( nInventor == SdrInventor )
{
- awt::Size aSize = xShape->getSize();
- aSize.Width += 1;
- aSize.Height += 1;
- awt::Point aPos = xShape->getPosition();
- Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
-
- // special cases
- if( nInventor == SdrInventor )
+ switch( nType )
{
- switch( nType )
+ case OBJ_MEASURE:
{
- case OBJ_MEASURE:
- {
- pNewObj = new SdrMeasureObj( aRect.TopLeft(), aRect.BottomRight() );
- break;
- }
- case OBJ_LINE:
- {
- basegfx::B2DPolygon aPoly;
- aPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
- aPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
- pNewObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
- break;
- }
+ pNewObj = new SdrMeasureObj( aRect.TopLeft(), aRect.BottomRight() );
+ break;
+ }
+ case OBJ_LINE:
+ {
+ basegfx::B2DPolygon aPoly;
+ aPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
+ aPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
+ pNewObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
+ break;
}
}
+ }
- if( pNewObj == NULL )
- pNewObj = SdrObjFactory::MakeNewObject( nInventor, nType, mpPage );
+ if( pNewObj == NULL )
+ pNewObj = SdrObjFactory::MakeNewObject( nInventor, nType, mpPage );
- if(pNewObj)
- {
- pNewObj->SetSnapRect(aRect);
+ if (!pNewObj)
+ return NULL;
- if( pNewObj->ISA(E3dPolyScene))
- {
- // Szene initialisieren
- E3dScene* pScene = (E3dScene*)pNewObj;
-
- double fW = (double)aSize.Width;
- double fH = (double)aSize.Height;
-
- Camera3D aCam(pScene->GetCamera());
- aCam.SetAutoAdjustProjection(false);
- aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
- basegfx::B3DPoint aLookAt;
- basegfx::B3DPoint aCamPos(0.0, 0.0, 10000.0);
- aCam.SetPosAndLookAt(aCamPos, aLookAt);
- aCam.SetFocalLength(100.0);
- aCam.SetDefaults(aCamPos, aLookAt, 10000.0);
- pScene->SetCamera(aCam);
-
- pScene->SetRectsDirty();
- }
- else if(pNewObj->ISA(E3dExtrudeObj))
- {
- E3dExtrudeObj* pObj = (E3dExtrudeObj*)pNewObj;
- basegfx::B2DPolygon aNewPolygon;
- aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
- aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
- aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
- aNewPolygon.setClosed(true);
- pObj->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon));
-
- // #107245# pObj->SetExtrudeCharacterMode(sal_True);
- pObj->SetMergedItem(Svx3DCharacterModeItem(true));
- }
- else if(pNewObj->ISA(E3dLatheObj))
- {
- E3dLatheObj* pObj = (E3dLatheObj*)pNewObj;
- basegfx::B2DPolygon aNewPolygon;
- aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
- aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
- aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
- aNewPolygon.setClosed(true);
- pObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
-
- // #107245# pObj->SetLatheCharacterMode(sal_True);
- pObj->SetMergedItem(Svx3DCharacterModeItem(true));
- }
- }
+ pNewObj->SetSnapRect(aRect);
+
+ if( pNewObj->ISA(E3dPolyScene))
+ {
+ // Szene initialisieren
+ E3dScene* pScene = (E3dScene*)pNewObj;
+
+ double fW = (double)aSize.Width;
+ double fH = (double)aSize.Height;
+
+ Camera3D aCam(pScene->GetCamera());
+ aCam.SetAutoAdjustProjection(false);
+ aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
+ basegfx::B3DPoint aLookAt;
+ basegfx::B3DPoint aCamPos(0.0, 0.0, 10000.0);
+ aCam.SetPosAndLookAt(aCamPos, aLookAt);
+ aCam.SetFocalLength(100.0);
+ aCam.SetDefaults(aCamPos, aLookAt, 10000.0);
+ pScene->SetCamera(aCam);
+
+ pScene->SetRectsDirty();
+ }
+ else if(pNewObj->ISA(E3dExtrudeObj))
+ {
+ E3dExtrudeObj* pObj = (E3dExtrudeObj*)pNewObj;
+ basegfx::B2DPolygon aNewPolygon;
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
+ aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
+ aNewPolygon.setClosed(true);
+ pObj->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon));
+
+ // #107245# pObj->SetExtrudeCharacterMode(sal_True);
+ pObj->SetMergedItem(Svx3DCharacterModeItem(true));
+ }
+ else if(pNewObj->ISA(E3dLatheObj))
+ {
+ E3dLatheObj* pObj = (E3dLatheObj*)pNewObj;
+ basegfx::B2DPolygon aNewPolygon;
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
+ aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
+ aNewPolygon.setClosed(true);
+ pObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
+
+ // #107245# pObj->SetLatheCharacterMode(sal_True);
+ pObj->SetMergedItem(Svx3DCharacterModeItem(true));
}
return pNewObj;
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 3449f8d98531..faeeebc87847 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -188,40 +188,44 @@ void SAL_CALL SvxShapeGroup::leaveGroup( ) throw(uno::RuntimeException, std::ex
void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape, sal_uIntPtr nPos )
{
- SvxShape* pShape = SvxShape::getImplementation( xShape );
-
- if( mpObj.is()&& mxPage.is() && pShape )
+ if (!mpObj.is() || !mxPage.is())
{
- SdrObject* pSdrShape = pShape->GetSdrObject();
- if( pSdrShape == NULL )
- pSdrShape = mxPage->_CreateSdrObject( xShape );
-
- if( pSdrShape->IsInserted() )
- pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
-
- mpObj->GetSubList()->InsertObject(pSdrShape, nPos);
- pSdrShape->SetModel(mpObj->GetModel());
-
- // #85922# It makes no sense to set the layer asked
- // from the group object since these is an iteration
- // over the contained objects. In consequence, this
- // statement erases all layer information from the draw
- // objects. Layers need to be set at draw objects directly
- // and have nothing to do with grouping at all.
- // pSdrShape->SetLayer(pObject->GetLayer());
-
- // Establish connection between new SdrObject and its wrapper before
- // inserting the new shape into the group. There a new wrapper
- // would be created when this connection would not already exist.
- pShape->Create( pSdrShape, mxPage.get() );
-
- if( mpModel )
- mpModel->SetChanged();
+ OSL_FAIL("could not add XShape to group shape!");
+ return;
}
- else
+
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+ if (!pShape)
{
OSL_FAIL("could not add XShape to group shape!");
+ return;
}
+
+ SdrObject* pSdrShape = pShape->GetSdrObject();
+ if( pSdrShape == NULL )
+ pSdrShape = mxPage->_CreateSdrObject( xShape );
+
+ if( pSdrShape->IsInserted() )
+ pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
+
+ mpObj->GetSubList()->InsertObject(pSdrShape, nPos);
+ pSdrShape->SetModel(mpObj->GetModel());
+
+ // #85922# It makes no sense to set the layer asked
+ // from the group object since these is an iteration
+ // over the contained objects. In consequence, this
+ // statement erases all layer information from the draw
+ // objects. Layers need to be set at draw objects directly
+ // and have nothing to do with grouping at all.
+ // pSdrShape->SetLayer(pObject->GetLayer());
+
+ // Establish connection between new SdrObject and its wrapper before
+ // inserting the new shape into the group. There a new wrapper
+ // would be created when this connection would not already exist.
+ pShape->Create( pSdrShape, mxPage.get() );
+
+ if( mpModel )
+ mpModel->SetChanged();
}
// XShapes