tdf#117266 sc oox: export vml button with a correct name

Without a correctly formatted ID, LO was unable to import
the shape into the spreadsheet. Now at least the button
shows up and can be pressed.

MS Word already showed the button before the patch,
so nothing there has changed. That suggests that our
problem may be more during import.

This code path is also followed by DOC and DOCX formats,
but they do completely different things with the results.
This is super nasty code...

Change-Id: I383736a7de9c3e94b427d5747e5949c0348dcecd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145509
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
This commit is contained in:
Justin Luth
2023-01-12 11:18:55 -05:00
committed by Justin Luth
parent 37e3455a13
commit d50eca2a30
9 changed files with 36 additions and 15 deletions

View File

@@ -430,13 +430,17 @@ sal_uInt32 ImplEESdrWriter::ImplWriteShape( ImplEESdrObject& rObj,
}
mpEscherEx->OpenContainer( ESCHER_SpContainer );
if(bInline)
nShapeType = bInline ? ESCHER_ShpInst_PictureFrame : ESCHER_ShpInst_HostControl;
const ShapeFlag nFlags = ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor;
nShapeID = rObj.GetShapeId();
if (nShapeID)
{
addShape( ESCHER_ShpInst_PictureFrame, ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor );
mpEscherEx->AddShape(nShapeType, nFlags, nShapeID );
rSolverContainer.AddShape(rObj.GetShapeRef(), nShapeID);
}
else
{
addShape( ESCHER_ShpInst_HostControl, ShapeFlag::HaveShapeProperty | ShapeFlag::HaveAnchor );
addShape(nShapeType, nFlags);
}
}
else
@@ -946,9 +950,9 @@ void EscherEx::AddUnoShapes( const Reference< XShapes >& rxShapes, bool ooxmlExp
mpImplEESdrWriter->ImplWriteCurrentPage(ooxmlExport);
}
sal_uInt32 EscherEx::AddSdrObject( const SdrObject& rObj, bool ooxmlExport )
sal_uInt32 EscherEx::AddSdrObject(const SdrObject& rObj, bool ooxmlExport, sal_uInt32 nId)
{
ImplEESdrObject aObj( *mpImplEESdrWriter, rObj, mbOOXML );
ImplEESdrObject aObj(*mpImplEESdrWriter, rObj, mbOOXML , nId);
if( aObj.IsValid() )
return mpImplEESdrWriter->ImplWriteTheShape( aObj, ooxmlExport );
return 0;
@@ -995,8 +999,8 @@ const SdrObject* EscherEx::GetSdrObject( const Reference< XShape >& rShape )
ImplEESdrObject::ImplEESdrObject( ImplEESdrWriter& rEx,
const SdrObject& rObj, bool bOOXML ) :
mnShapeId( 0 ),
const SdrObject& rObj, bool bOOXML, sal_uInt32 nId) :
mnShapeId(nId),
mnTextSize( 0 ),
mnAngle( 0 ),
mbValid( false ),

View File

@@ -45,7 +45,7 @@ class ImplEESdrObject
public:
css::uno::Reference< css::beans::XPropertySet > mXPropSet;
ImplEESdrObject( ImplEESdrWriter& rEx, const SdrObject& rObj, bool bOOXML );
ImplEESdrObject(ImplEESdrWriter& rEx, const SdrObject& rObj, bool bOOXML, sal_uInt32 nId = 0);
ImplEESdrObject( const css::uno::Reference< css::drawing::XShape >& rShape );
~ImplEESdrObject();

View File

@@ -1162,7 +1162,7 @@ public:
void AddUnoShapes( const css::uno::Reference< css::drawing::XShapes >& rxShapes, bool ooxmlExport = false );
/// returns the ShapeID
sal_uInt32 AddSdrObject( const SdrObject& rObj, bool ooxmlExport = false );
sal_uInt32 AddSdrObject(const SdrObject& rObj, bool ooxmlExport = false, sal_uInt32 nId = 0);
virtual void AddSdrObjectVMLObject( const SdrObject& /*rObj*/)
{
// Required for Exporting VML shape

View File

@@ -142,7 +142,7 @@ public:
sal_Int16 eHOri = -1, sal_Int16 eVOri = -1, sal_Int16 eHRel = -1,
sal_Int16 eVRel = -1,
sax_fastparser::FastAttributeList* pWrapAttrList = nullptr,
const bool bOOxmlExport = false );
const bool bOOxmlExport = false, sal_uInt32 nId = 0);
OString const & AddInlineSdrObject( const SdrObject& rObj, const bool bOOxmlExport );
virtual void AddSdrObjectVMLObject( const SdrObject& rObj) override;
static bool IsWaterMarkShape(std::u16string_view rStr);

View File

@@ -155,6 +155,8 @@ public:
void mergeTopMarks(sal_Int32 nTag,
MergeMarks eMergeType = MergeMarks::APPEND );
void setAllowXEscape(bool bSet);
private:
void pushAttributeValue( sal_Int32 attribute, const char* value );
void pushAttributeValue( sal_Int32 attribute, const OString& value );

View File

@@ -1001,6 +1001,8 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const tools::Rectangle&
if (!IsWaterMarkShape(m_pSdrObject->GetName()) && !m_bSkipwzName)
m_pShapeAttrList->add(XML_ID, idStr);
// note that XML_ID is different from XML_id (although it looks like a LO
// implementation distinction without valid justification to me).
bAlreadyWritten[ESCHER_Prop_wzName] = true;
}
break;
@@ -1383,8 +1385,13 @@ sal_Int32 VMLExport::StartShape()
"_x0000_t" + OString::number( m_nShapeType ) );
}
// allow legacy id (which in form controls and textboxes
// by definition seems to have this otherwise illegal name).
m_pSerializer->setAllowXEscape(!m_sShapeIDPrefix.startsWith("_x0000_"));
// start of the shape
m_pSerializer->startElementNS( XML_v, nShapeElement, m_pShapeAttrList );
m_pSerializer->setAllowXEscape(true);
OString const textboxStyle(m_TextboxStyle.makeStringAndClear());
@@ -1492,7 +1499,7 @@ OString const & VMLExport::AddSdrObject( const SdrObject& rObj,
bool const bIsFollowingTextFlow,
sal_Int16 eHOri, sal_Int16 eVOri, sal_Int16 eHRel, sal_Int16 eVRel,
FastAttributeList* pWrapAttrList,
const bool bOOxmlExport )
const bool bOOxmlExport, sal_uInt32 nId)
{
m_pSdrObject = &rObj;
m_eHOri = eHOri;
@@ -1502,7 +1509,7 @@ OString const & VMLExport::AddSdrObject( const SdrObject& rObj,
m_pWrapAttrList = pWrapAttrList;
m_bInline = false;
m_IsFollowingTextFlow = bIsFollowingTextFlow;
EscherEx::AddSdrObject(rObj, bOOxmlExport);
EscherEx::AddSdrObject(rObj, bOOxmlExport, nId);
return m_sShapeId;
}

View File

@@ -116,6 +116,9 @@ public:
void write( const OString& s, bool bEscape = false );
void write( const char* pStr, sal_Int32 nLen, bool bEscape = false );
// strings with _xHHHH_ are escaped with _x005F unless this is disabled
void setAllowXEscape(bool bSet) { mbXescape = bSet; }
public:
/** From now on, don't write directly to the stream, but to top of a stack.
@@ -230,8 +233,7 @@ private:
sal_Int32 mnDoubleStrCapacity;
TokenValueList maTokenValues;
bool mbXescape; ///< whether to escape invalid XML characters as _xHHHH_ in write(const char*,sal_Int32,true)
/* TODO: make that configurable from the outside for
* some specific cases? */
#ifdef DBG_UTIL
std::stack<sal_Int32> m_DebugStartedElements;

View File

@@ -164,6 +164,10 @@ rtl::Reference<FastAttributeList> FastSerializerHelper::createAttrList()
return new FastAttributeList( nullptr );
}
void FastSerializerHelper::setAllowXEscape(bool bSet)
{
mpSerializer->setAllowXEscape(bSet);
}
}

View File

@@ -1187,9 +1187,11 @@ void XclExpTbxControlObj::SaveVml(XclExpXmlStream& rStrm)
lcl_GetFromTo(mrRoot, pObj->GetLogicRect(), GetTab(), aAreaFrom, aAreaTo);
VmlFormControlExporter aFormControlExporter(rStrm.GetCurrentStream(), GetObjType(), aAreaFrom,
aAreaTo, msLabel, GetMacroName());
aFormControlExporter.SetSkipwzName(true); // use XML_id for legacyid, not XML_ID
aFormControlExporter.OverrideShapeIDGen(true, "_x0000_s");
aFormControlExporter.AddSdrObject(*pObj, /*bIsFollowingTextFlow=*/false, /*eHOri=*/-1,
/*eVOri=*/-1, /*eHRel=*/-1, /*eVRel=*/-1,
/*pWrapAttrList=*/nullptr, /*bOOxmlExport=*/true);
/*pWrapAttrList=*/nullptr, /*bOOxmlExport=*/true, mnShapeId);
}
// save into xl\drawings\drawing1.xml