[Libreoffice-commits] core.git: oox/source sc/qa sc/source
oox/source/export/vmlexport.cxx| 18 +++--- sc/qa/unit/subsequent_export_test2.cxx |5 - sc/source/filter/excel/xeescher.cxx|9 - 3 files changed, 23 insertions(+), 9 deletions(-) New commits: commit 245912dc42bfc13cbf0db3f04f2411f3dede9615 Author: Justin Luth AuthorDate: Sat Jan 21 17:00:26 2023 -0500 Commit: Justin Luth CommitDate: Tue Jan 24 02:09:55 2023 + tdf#117266 tdf#120374 sc oox: export correct vml button name #2 So the actual name is more important than I knew. For example, VBA maps click macros based on the button name. So use the MS-provided name and use the SPID to connect to the shape id. Of the existing unit tests that were affected by this: -macro-button-form-control.xlsm: button now launches hello macro -tdf117266_macroButton.xlsm - same file as ^^^ -button-form-control.xls nearly same file as ^^^ -tdf134769.xlsx - checkbox still exists on round-trip -tdf106181.ods - checkbox still exists, but link to cell still lost. -checkbox-form-control.xlsx - nearly same as ^^^ All looks good. Change-Id: If83cf17d60b73c46d55a21b1a46ed320513044cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145961 Tested-by: Jenkins Reviewed-by: Justin Luth diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 339187fbe4d2..6da57bdd8be8 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -187,20 +187,24 @@ void VMLExport::AddShape( sal_uInt32 nShapeType, ShapeFlag nShapeFlags, sal_uInt m_nShapeFlags = nShapeFlags; m_sShapeId = ShapeIdString( nShapeId ); -// If shape is a watermark object - should keep the original shape's name -// because Microsoft detects if it is a watermark by the actual name -if (!IsWaterMarkShape(m_pSdrObject->GetName())) +if (m_sShapeId.startsWith("_x_")) { -// Not a watermark object -m_pShapeAttrList->add( XML_id, m_sShapeId ); +// xml_id must be set elsewhere. The id is critical for matching VBA macros etc, +// and the spid is critical to link to the shape number elsewhere. +m_pShapeAttrList->addNS( XML_o, XML_spid, m_sShapeId ); } -else +else if (IsWaterMarkShape(m_pSdrObject->GetName())) { -// A watermark object - store the optional shape ID +// Shape is a watermark object - keep the original shape's name +// because Microsoft detects if it is a watermark by the actual name m_pShapeAttrList->add( XML_id, m_pSdrObject->GetName() ); // also ('o:spid') m_pShapeAttrList->addNS( XML_o, XML_spid, m_sShapeId ); } +else +{ +m_pShapeAttrList->add(XML_id, m_sShapeId); +} } bool VMLExport::IsWaterMarkShape(std::u16string_view rStr) diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 16188c90bbfa..3093e63500dd 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -542,7 +542,10 @@ void ScExportTest2::testTdf117266() xmlDocUniquePtr pVmlDrawing = parseExport("xl/drawings/vmlDrawing1.vml"); OUString sName = getXPath(pVmlDrawing, "/xml/v:shape", "id"); -CPPUNIT_ASSERT(sName.startsWith("_x_s")); +CPPUNIT_ASSERT_EQUAL(OUString("Button 1001"), sName); + +OUString sSpid = getXPath(pVmlDrawing, "/xml/v:shape", "spid"); +CPPUNIT_ASSERT(sSpid.startsWith("_x_s")); assertXPathContent(pVmlDrawing, "/xml/v:shape/v:textbox/div/font", "Button 1 \"y\" z"); // Why the xx:, I have no idea..., but it certainly doesn't work with just x:. diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 00b1b53a76a1..c0c15fda599a 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1093,12 +1093,14 @@ class VmlFormControlExporter : public oox::vml::VMLExport sal_uInt16 m_nObjType; tools::Rectangle m_aAreaFrom; tools::Rectangle m_aAreaTo; +OUString m_sControlName; OUString m_aLabel; OUString m_aMacroName; public: VmlFormControlExporter(const sax_fastparser::FSHelperPtr& p, sal_uInt16 nObjType, const tools::Rectangle& rAreaFrom, const tools::Rectangle& rAreaTo, + const OUString& sControlName, OUString aLabel, OUString aMacroName); protected: @@ -1112,11 +1114,13 @@ VmlFormControlExporter::VmlFormControlExporter(const sax_fastparser::FSHelperPtr sal_uInt16 nObjType, const tools::Rectangle& rAreaFrom, const tools::Rectangle& rAreaTo, + const OUString& sControlName, OUSt
[Libreoffice-commits] core.git: oox/source sc/qa sc/source
oox/source/token/tokens.txt |5 ++ sc/qa/unit/data/xlsx/button-form-control.xlsx |binary sc/qa/unit/subsequent_export-test2.cxx| 25 ++ sc/source/filter/excel/xeescher.cxx | 63 +- sc/source/filter/xcl97/xcl97rec.cxx |1 5 files changed, 93 insertions(+), 1 deletion(-) New commits: commit 1e3263a677b61c718d0fd1be15c066b933f7de18 Author: Miklos Vajna AuthorDate: Thu Jul 1 12:34:52 2021 +0200 Commit: Miklos Vajna CommitDate: Thu Jul 1 17:15:30 2021 +0200 XLSX export: handle button form controls This builds on top of commit 94678a7b9c6b7e577c15adacc885e03551bcf17b (XLSX export: improve handling of checkbox (form controls), 2021-06-30), so now both checkboxes and buttons are handled during export. Change-Id: I278b4925414d29399401cc15ab3d944db88ee0c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118219 Reviewed-by: Miklos Vajna Tested-by: Jenkins diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt index 4d2fb881f0bc..997b3e8b3b25 100644 --- a/oox/source/token/tokens.txt +++ b/oox/source/token/tokens.txt @@ -713,6 +713,7 @@ autoLoad autoNoTable autoPage autoPageBreaks +autoPict autoRecover autoRedefine autoRepublish @@ -1403,6 +1404,7 @@ contributors control control1 control2 +controlPr controls convMailMergeEsc convex @@ -2372,6 +2374,7 @@ forcedash foredepth forestGreen forgetLastTabAlignment +formControlPr formFld formLetters formProt @@ -3179,6 +3182,7 @@ location lock lockRevision lockStructure +lockText lockWindows locked lockedCanvas @@ -3661,6 +3665,7 @@ objOverTx objTx object objectDefaults +objectType objects obliqueBottom obliqueBottomLeft diff --git a/sc/qa/unit/data/xlsx/button-form-control.xlsx b/sc/qa/unit/data/xlsx/button-form-control.xlsx new file mode 100644 index ..c5e9fe65a245 Binary files /dev/null and b/sc/qa/unit/data/xlsx/button-form-control.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test2.cxx b/sc/qa/unit/subsequent_export-test2.cxx index 6036bddd8369..d23145c67cf2 100644 --- a/sc/qa/unit/subsequent_export-test2.cxx +++ b/sc/qa/unit/subsequent_export-test2.cxx @@ -188,6 +188,7 @@ public: void testTdf126541_SheetVisibilityImportXlsx(); void testTdf140431(); void testCheckboxFormControlXlsxExport(); +void testButtonFormControlXlsxExport(); CPPUNIT_TEST_SUITE(ScExportTest2); @@ -284,6 +285,7 @@ public: CPPUNIT_TEST(testTdf126541_SheetVisibilityImportXlsx); CPPUNIT_TEST(testTdf140431); CPPUNIT_TEST(testCheckboxFormControlXlsxExport); +CPPUNIT_TEST(testButtonFormControlXlsxExport); CPPUNIT_TEST_SUITE_END(); @@ -2323,6 +2325,29 @@ void ScExportTest2::testCheckboxFormControlXlsxExport() assertXPathContent(pDoc, "/xml/v:shape/xx:ClientData/xx:Anchor", "1, 22, 3, 3, 3, 30, 6, 1"); } +void ScExportTest2::testButtonFormControlXlsxExport() +{ +// Given a document that has a checkbox form control: +ScDocShellRef xShell = loadDoc(u"button-form-control.", FORMAT_XLSX); +CPPUNIT_ASSERT(xShell.is()); + +// When exporting to XLSX: +std::shared_ptr pXPathFile += ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX); + +// Then make sure its control markup is written and it has a correct position + size: +xmlDocUniquePtr pDoc += XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml"); +CPPUNIT_ASSERT(pDoc); +// Without the fix in place, this test would have failed with: +// - XPath '//x:anchor/x:from/xdr:col' not found +// i.e. the control markup was missing, the button was lost on export. +assertXPathContent(pDoc, "//x:anchor/x:from/xdr:col", "1"); +assertXPathContent(pDoc, "//x:anchor/x:from/xdr:row", "3"); +assertXPathContent(pDoc, "//x:anchor/x:to/xdr:col", "3"); +assertXPathContent(pDoc, "//x:anchor/x:to/xdr:row", "7"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 2f1253c0a16e..fcffbd7534b2 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1144,6 +1144,9 @@ void VmlFormControlExporter::EndShape(sal_Int32 nShapeElement) case EXC_OBJTYPE_CHECKBOX: aObjectType = "Checkbox"; break; +case EXC_OBJTYPE_BUTTON: +aObjectType = "Button"; +break; } pVmlDrawing->startElement(FSNS(XML_x, XML_ClientData), XML_ObjectType, aObjectType); OString aAnchor = OString::number(m_aAreaFrom.Left()); @@ -1156,7 +1159,11 @@ void VmlFormControlExporter::EndShape(sal_Int32 nShapeElement) aAnchor += ", " + OString::number(m_aAreaTo.Bottom()); XclXmlUtils::WriteElement(pVmlDrawing, FSNS(XML_x, XML_Anchor), aAnchor); -// XclExpOcxControlObj::WriteSubRecs() has the same f
[Libreoffice-commits] core.git: oox/source sc/qa sc/source
oox/source/ole/axcontrol.cxx |9 + oox/source/vml/vmldrawing.cxx| 55 +++ sc/qa/unit/subsequent_filters-test.cxx | 27 +++ sc/source/filter/oox/drawingfragment.cxx |3 + 4 files changed, 86 insertions(+), 8 deletions(-) New commits: commit 048b8e45813f6a19a4ff56e1d676fe9450325cd2 Author: Justin Luth AuthorDate: Sat Sep 29 14:38:31 2018 +0300 Commit: Miklos Vajna CommitDate: Thu Oct 11 09:48:03 2018 +0200 tdf#111980 oox optionbutton autoGroup inside GroupBox The area of a GroupBox indicates which radio buttons are considered to be part of the same group. The button needs to be fully inside of the groupbox in order to participate. This patch resolves the last worry of commit 9f969799629fe6bdf8b922d8cb922846aa646ece Change-Id: Ie6057337c63bf9eb173a0615e30c8d4e4d0c7a19 Reviewed-on: https://gerrit.libreoffice.org/61131 Tested-by: Jenkins Reviewed-by: Justin Luth Reviewed-by: Miklos Vajna diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 350fe0e315f9..563cf06e5a54 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -1555,13 +1555,8 @@ void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const Contr rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); if ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON ) { -// Form Radio Controls (non-ActiveX) have no group name, but autoGroup -// with their group box, or frame, or sheet, or document. -// So ensure that SOME name is given for a group name -// TODO: ActiveX controls without a Group name shouldn't autogroup -//with non-ActiveX option buttons. -// TODO: each application should test if control's area is fully inside -//a GroupBox, and give those a separate group name. +// If unspecified, radio buttons autoGroup in the same document/sheet +// NOTE: form controls should not autoGroup with ActiveX controls - see drawingfragment.cxx OUString sGroupName = !maGroupName.isEmpty() ? maGroupName : "autoGroup_"; rPropMap.setProperty( PROP_GroupName, sGroupName ); } diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx index ab2a9f8a42d5..0d5698eab0c9 100644 --- a/oox/source/vml/vmldrawing.cxx +++ b/oox/source/vml/vmldrawing.cxx @@ -35,6 +35,8 @@ #include #include #include +#include +#include namespace oox { namespace vml { @@ -146,6 +148,59 @@ void Drawing::convertAndInsert() const { Reference< XShapes > xShapes( mxDrawPage, UNO_QUERY ); mxShapes->convertAndInsert( xShapes ); + +// Group together form control radio buttons that are in the same groupBox +std::map GroupBoxMap; +std::map, tools::Rectangle> RadioButtonMap; +for ( sal_Int32 i = 0; i < xShapes->getCount(); ++i ) +{ +try +{ +Reference< XControlShape > xCtrlShape( xShapes->getByIndex(i), UNO_QUERY_THROW ); +Reference< XControlModel > xCtrlModel( xCtrlShape->getControl(), UNO_SET_THROW ); +Reference< XServiceInfo > xModelSI (xCtrlModel, UNO_QUERY_THROW ); +Reference< XPropertySet > aProps( xCtrlModel, UNO_QUERY_THROW ); + +OUString sName; +aProps->getPropertyValue("Name") >>= sName; +const ::Point aPoint( xCtrlShape->getPosition().X, xCtrlShape->getPosition().Y ); +const ::Size aSize( xCtrlShape->getSize().Width, xCtrlShape->getSize().Height ); +const tools::Rectangle aRect( aPoint, aSize ); +if ( !sName.isEmpty() + && xModelSI->supportsService("com.sun.star.awt.UnoControlGroupBoxModel") ) +{ +GroupBoxMap[sName] = aRect; +} +else if ( xModelSI->supportsService("com.sun.star.awt.UnoControlRadioButtonModel") ) +{ +OUString sGroupName; +aProps->getPropertyValue("GroupName") >>= sGroupName; +// only Form Controls are affected by Group Boxes - see drawingfragment.cxx +if ( sGroupName == "autoGroup_formControl" ) +RadioButtonMap[aProps] = aRect; +} +} +catch (uno::Exception&) +{ +DBG_UNHANDLED_EXCEPTION("oox.vml"); +} +} +for ( auto& BoxItr : GroupBoxMap ) +{ +const uno::Any aGroup( OUString("autoGroup_").concat(BoxItr.first) ); +for ( auto RadioItr = RadioButtonMap.begin(); RadioItr != RadioButtonMap.end(); ) +{ +if ( BoxItr.second.IsInside(RadioItr->second) ) +{ +RadioItr->first->setPropertyValue("GroupName", aGroup ); +// If conflict, first created GroupBox wins +RadioButtonMap.erase( RadioItr++ ); +} +else +Rad
[Libreoffice-commits] core.git: oox/source sc/qa sc/source
oox/source/core/fragmenthandler2.cxx |1 oox/source/core/xmlfilterbase.cxx |5 + oox/source/token/namespaces-strict.txt |1 oox/source/token/namespaces.hxx.tail |1 oox/source/token/namespaces.txt|1 oox/source/token/tokens.txt|1 sc/qa/unit/bugfix-test.cxx | 50 +- sc/qa/unit/data/xlsx/tdf104310-2.xlsx |binary sc/source/filter/inc/worksheetfragment.hxx | 41 +++ sc/source/filter/oox/worksheetfragment.cxx | 77 + 10 files changed, 155 insertions(+), 23 deletions(-) New commits: commit ce17ebb69500530c978767b1389c9e8341acb9bf Author: Mike Kaganski Date: Fri Dec 2 03:31:22 2016 +0300 tdf#104310: Accept x12ac lists and fallbacks in dataValidations Change-Id: I42cf20fcfe3ec03ebd09923be509a9d11e0b40da Reviewed-on: https://gerrit.libreoffice.org/31516 Tested-by: Jenkins Reviewed-by: Kohei Yoshida diff --git a/oox/source/core/fragmenthandler2.cxx b/oox/source/core/fragmenthandler2.cxx index 9a708d5..ba3f880 100644 --- a/oox/source/core/fragmenthandler2.cxx +++ b/oox/source/core/fragmenthandler2.cxx @@ -76,6 +76,7 @@ bool FragmentHandler2::prepareMceContext( sal_Int32 nElement, const AttributeLis { "p14", "p15", +"x12ac", }; if (std::find(aSupportedNS.begin(), aSupportedNS.end(), aRequires) != aSupportedNS.end()) diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index fae720f..952bf5e 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -146,7 +146,10 @@ struct NamespaceIds: public rtl::StaticWithInit< {"http://schemas.microsoft.com/office/powerpoint/2010/main";, NMSP_p14}, {"http://schemas.microsoft.com/office/powerpoint/2012/main";, - NMSP_p15}}; + NMSP_p15}, +{"http://schemas.microsoft.com/office/spreadsheetml/2011/1/ac";, + NMSP_x12ac}, +}; } }; diff --git a/oox/source/token/namespaces-strict.txt b/oox/source/token/namespaces-strict.txt index f9a4633..0f606f7 100644 --- a/oox/source/token/namespaces-strict.txt +++ b/oox/source/token/namespaces-strict.txt @@ -83,6 +83,7 @@ p14 http://schemas.microsoft.com/office/powerpoint/2010/main # MSO 2012/2013 extensions - p15 http://schemas.microsoft.com/office/powerpoint/2012/main +x12ac http://schemas.microsoft.com/office/spreadsheetml/2011/1/ac # extlst namespaces diff --git a/oox/source/token/namespaces.hxx.tail b/oox/source/token/namespaces.hxx.tail index 89f8c1c..17770dc 100644 --- a/oox/source/token/namespaces.hxx.tail +++ b/oox/source/token/namespaces.hxx.tail @@ -46,6 +46,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; } #define R_TOKEN( token )OOX_TOKEN( officeRel, token ) #define VML_TOKEN( token ) OOX_TOKEN( vml, token ) #define VMLX_TOKEN( token ) OOX_TOKEN( vmlExcel, token ) +#define X12AC_TOKEN( token )OOX_TOKEN( x12ac, token ) #define XDR_TOKEN( token ) OOX_TOKEN( dmlSpreadDr, token ) #define XLS_TOKEN( token ) OOX_TOKEN( xls, token ) #define XLS14_TOKEN( token )OOX_TOKEN( xls14Lst, token ) diff --git a/oox/source/token/namespaces.txt b/oox/source/token/namespaces.txt index 7920572..4b6f49a 100644 --- a/oox/source/token/namespaces.txt +++ b/oox/source/token/namespaces.txt @@ -83,6 +83,7 @@ p14 http://schemas.microsoft.com/office/powerpoint/2010/main # MSO 2012/2013 extensions - p15 http://schemas.microsoft.com/office/powerpoint/2012/main +x12ac http://schemas.microsoft.com/office/spreadsheetml/2011/1/ac # extlst namespaces diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt index b113c84..6d4fcb8 100644 --- a/oox/source/token/tokens.txt +++ b/oox/source/token/tokens.txt @@ -5781,6 +5781,7 @@ writeProtection wsDr wsp x +x12ac x14 xAlign xIllusions diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx index 9b7f2b7..3499109 100644 --- a/sc/qa/unit/bugfix-test.cxx +++ b/sc/qa/unit/bugfix-test.cxx @@ -242,20 +242,42 @@ void ScFiltersTest::testRhbz1390776() void ScFiltersTest::testTdf104310() { -ScDocShellRef xDocSh = loadDoc("tdf104310.", FORMAT_XLSX); -ScDocument& rDoc = xDocSh->GetDocument(); - -const ScValidationData* pData = rDoc.GetValidationEntry(1); -CPPUNIT_ASSERT(pData); - -// Make sure the list is correct. -std::vector aList; -pData->FillSelectionList(aList, ScAddress(0, 1, 0)); -CPPUNIT_ASSERT_EQUAL(size_t(5), aList.size()); -for (size_t i = 0; i < 5; ++i) -