Issue 100710

Summary: OLE object created via API crashes when selected
Product: Draw Reporter: daniel.rentz
Component: programmingAssignee: wolframgarten
Status: CLOSED FIXED QA Contact: issues@graphics <issues>
Severity: Trivial    
Priority: P2 CC: issues
Version: OOO310m7   
Target Milestone: OOo 3.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Attachments:
Description Flags
test none

Description daniel.rentz 2009-03-31 14:21:30 UTC
Load attached document, click button, the executed macro creates a linked OLE
object without replacement graphic. Select the new object -> office crashes
immediately.
Comment 1 daniel.rentz 2009-03-31 14:22:07 UTC
Regression, does not crash in OOo 3.0
Comment 2 daniel.rentz 2009-03-31 14:29:52 UTC
Created attachment 61315 [details]
test
Comment 3 clippka 2009-03-31 15:01:59 UTC
SdrOle2Obj::getFullDragClone() crashes because GetGraphic() returns null
Comment 4 Armin Le Grand 2009-03-31 16:14:31 UTC
AW: Indeed. SdrOle2Obj::getFullDragClone() is not prepared for OLEs which have
no graphic representation. In that case (if that case is legal at all) the
default OLE representation should be used to create a DragClone. It will not
even be necessary to create a SdrGrafObj clone, but a simple SdrRectObj with
bitmap filling and a gray hairline will do it.
Comment 5 Armin Le Grand 2009-03-31 16:18:59 UTC
AW: Solution is to replace the current implementation with the following:

SdrObject* SdrOle2Obj::getFullDragClone() const
{
    // special handling for OLE. The default handling works, but is too
    // slow when the whole OLE needs to be cloned. Get the Metafile and
    // create a graphic object with it
    Graphic* pOLEGraphic = GetGraphic();
    SdrObject* pClone = 0;
    
    if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
    {
        pOLEGraphic = getEmbeddedObjectRef().GetHCGraphic();
    }

    if(pOLEGraphic)
    {
        pClone = new SdrGrafObj(*pOLEGraphic, GetSnapRect());
        
        // this would be the place where to copy all attributes
        // when OLE will support fill and line style
        // pClone->SetMergedItem(pOleObject->GetMergedItemSet());
    }
    else
    {
        // #i100710# pOLEGraphic may be zero (no visualisation available),
        // so we need to use the OLE replacement graphic
        pClone = new SdrRectObj(GetSnapRect());

        // gray outline
        pClone->SetMergedItem(XLineStyleItem(XLINE_SOLID));
        const svtools::ColorConfig aColorConfig;
        const svtools::ColorConfigValue
aColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES));
        pClone->SetMergedItem(XLineColorItem(String(), aColor.nColor));

        // bitmap fill
        pClone->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
        pClone->SetMergedItem(XFillBitmapItem(String(),
GetEmtyOLEReplacementBitmap()));
        pClone->SetMergedItem(XFillBmpTileItem(false));
        pClone->SetMergedItem(XFillBmpStretchItem(false));
    }

	return pClone;
}

Also decided by UL: Not a 3.1 task, but to be planned for 3.2. Changing target.
Also wanted: To place in an own 3.2 CWS. Opening one...
Comment 6 Armin Le Grand 2009-04-01 15:26:13 UTC
AW: COmmited change, added task, building install sets.
Comment 7 Armin Le Grand 2009-04-01 16:37:57 UTC
AW->WG: Please verify. You will get a draggable object now in full drag with the
empty OLE preview bitmap.
Comment 8 wolframgarten 2009-04-03 09:42:50 UTC
Verified in CWS.
Comment 9 wolframgarten 2009-05-20 08:47:10 UTC
Tested in m48. Closed.