summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2023-01-12 11:18:55 -0500
committerJustin Luth <jluth@mail.com>2023-01-15 02:09:06 +0000
commitd50eca2a30bdabdc1735c590d6ec1913c6dd22fd (patch)
treef8d8a738c60fa0c69954a9fbf684a2e7640d8740
parent37e3455a13ab5741104bf41d05a80e60a4612682 (diff)
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>
-rw-r--r--filter/source/msfilter/eschesdo.cxx18
-rw-r--r--filter/source/msfilter/eschesdo.hxx2
-rw-r--r--include/filter/msfilter/escherex.hxx2
-rw-r--r--include/oox/export/vmlexport.hxx2
-rw-r--r--include/sax/fshelper.hxx2
-rw-r--r--oox/source/export/vmlexport.cxx11
-rw-r--r--sax/source/tools/fastserializer.hxx6
-rw-r--r--sax/source/tools/fshelper.cxx4
-rw-r--r--sc/source/filter/excel/xeescher.cxx4
9 files changed, 36 insertions, 15 deletions
diff --git a/filter/source/msfilter/eschesdo.cxx b/filter/source/msfilter/eschesdo.cxx
index fe16862df69a..8c39297f1e59 100644
--- a/filter/source/msfilter/eschesdo.cxx
+++ b/filter/source/msfilter/eschesdo.cxx
@@ -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 ),
diff --git a/filter/source/msfilter/eschesdo.hxx b/filter/source/msfilter/eschesdo.hxx
index cf46f49b6bee..ae3fe91ec1cd 100644
--- a/filter/source/msfilter/eschesdo.hxx
+++ b/filter/source/msfilter/eschesdo.hxx
@@ -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();
diff --git a/include/filter/msfilter/escherex.hxx b/include/filter/msfilter/escherex.hxx
index ab8c30d7b2c4..d6727bce2c12 100644
--- a/include/filter/msfilter/escherex.hxx
+++ b/include/filter/msfilter/escherex.hxx
@@ -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
diff --git a/include/oox/export/vmlexport.hxx b/include/oox/export/vmlexport.hxx
index 8e6dafff6e77..fb53ec099f7a 100644
--- a/include/oox/export/vmlexport.hxx
+++ b/include/oox/export/vmlexport.hxx
@@ -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);
diff --git a/include/sax/fshelper.hxx b/include/sax/fshelper.hxx
index 2d01066a1453..338260861132 100644
--- a/include/sax/fshelper.hxx
+++ b/include/sax/fshelper.hxx
@@ -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 );
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 4fa1e6cf7764..06f1745ab5b6 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -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;
}
diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx
index 109ada3c726f..c849e201872b 100644
--- a/sax/source/tools/fastserializer.hxx
+++ b/sax/source/tools/fastserializer.hxx
@@ -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;
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index fbf7f0672709..f5945d67a9c0 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -164,6 +164,10 @@ rtl::Reference<FastAttributeList> FastSerializerHelper::createAttrList()
return new FastAttributeList( nullptr );
}
+void FastSerializerHelper::setAllowXEscape(bool bSet)
+{
+ mpSerializer->setAllowXEscape(bSet);
+}
}
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index 0a139e820dca..00b1b53a76a1 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -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