diff options
-rw-r--r-- | offapi/com/sun/star/text/ContentControl.idl | 2 | ||||
-rw-r--r-- | schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng | 5 | ||||
-rw-r--r-- | sw/qa/core/unocore/unocore.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 19 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 4 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx | 4 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx | bin | 5391 -> 5405 bytes | |||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 4 | ||||
-rw-r--r-- | xmloff/qa/unit/data/content-control-alias.fodt | 2 | ||||
-rw-r--r-- | xmloff/qa/unit/text.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/text/txtparae.cxx | 7 | ||||
-rw-r--r-- | xmloff/source/text/xmlcontentcontrolcontext.cxx | 13 | ||||
-rw-r--r-- | xmloff/source/text/xmlcontentcontrolcontext.hxx | 1 |
15 files changed, 64 insertions, 12 deletions
diff --git a/offapi/com/sun/star/text/ContentControl.idl b/offapi/com/sun/star/text/ContentControl.idl index 3b6e86b1ac1c..c2fe46757656 100644 --- a/offapi/com/sun/star/text/ContentControl.idl +++ b/offapi/com/sun/star/text/ContentControl.idl @@ -111,12 +111,14 @@ service ContentControl [optional, property] boolean DropDown; /** The alias: kind of a human-readable title / description, show up on the UI. + -also used by VBA to group controls into a smaller, indexed collection @since LibreOffice 7.5 */ [optional, property] string Alias; /** The tag: similar to Alias, but is meant to be machine-readable. + -also used by VBA to group controls into a smaller, indexed collection @since LibreOffice 7.5 */ diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng index e326b8913646..0a8aadad1ba3 100644 --- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng +++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng @@ -2977,6 +2977,11 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. </rng:attribute> </rng:optional> <rng:optional> + <rng:attribute name="loext:id"> + <rng:ref name="integer"/> + </rng:attribute> + </rng:optional> + <rng:optional> <rng:attribute name="loext:tab-index"> <rng:ref name="nonNegativeInteger"/> </rng:attribute> diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index af31044e4190..0c2da1b0524a 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -633,6 +633,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate) xContentControlProps->setPropertyValue("Color", uno::Any(OUString("008000"))); xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("myalias"))); xContentControlProps->setPropertyValue("Tag", uno::Any(OUString("mytag"))); + xContentControlProps->setPropertyValue("Id", uno::Any(static_cast<sal_Int32>(123))); xContentControlProps->setPropertyValue("TabIndex", uno::Any(sal_uInt32(1))); xContentControlProps->setPropertyValue("Lock", uno::Any(OUString("sdtContentLocked"))); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); @@ -660,6 +661,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate) CPPUNIT_ASSERT_EQUAL(OUString("008000"), pContentControl->GetColor()); CPPUNIT_ASSERT_EQUAL(OUString("myalias"), pContentControl->GetAlias()); CPPUNIT_ASSERT_EQUAL(OUString("mytag"), pContentControl->GetTag()); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(123), pContentControl->GetId()); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(1), pContentControl->GetTabIndex()); CPPUNIT_ASSERT_EQUAL(OUString("sdtContentLocked"), pContentControl->GetLock()); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 04795920a0db..a04a7813f9c6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -425,6 +425,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport) xContentControlProps->setPropertyValue("Appearance", uno::Any(OUString("hidden"))); xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("myalias"))); xContentControlProps->setPropertyValue("Tag", uno::Any(OUString("mytag"))); + xContentControlProps->setPropertyValue("Id", uno::Any(static_cast<sal_Int32>(123))); xContentControlProps->setPropertyValue("TabIndex", uno::Any(sal_uInt32(2))); xContentControlProps->setPropertyValue("Lock", uno::Any(OUString("sdtLocked"))); @@ -451,6 +452,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport) assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w15:appearance", "val", "hidden"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:alias", "val", "myalias"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:tag", "val", "mytag"); + assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:id", "val", "123"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:tabIndex", "val", "2"); assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:lock", "val", "sdtLocked"); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index b495e62902fa..e27a1f085b11 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -106,6 +106,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf149551_mongolianVert) DECLARE_OOXMLEXPORT_TEST(testTdf151912, "tdf151912.docx") { // For now just ensure roundtrip is successful + + //tdf#151548 - ensure block SDT preserves id (instead of random re-assignment) + if (!isExported()) + return; + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + assertXPath(pXmlDoc, "//w:sdt//w:sdtPr/w:id", "val", "1802566103"); } DECLARE_OOXMLEXPORT_TEST(testTdf147724, "tdf147724.docx") diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 88c3cb8a2d24..03b73dbaee84 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -626,13 +626,13 @@ void SdtBlockHelper::DeleteAndResetTheLists() if (!m_aAppearance.isEmpty()) m_aAppearance.clear(); m_bShowingPlaceHolder = false; + m_nId = 0; m_nTabIndex = 0; - m_bHasId = false; } void SdtBlockHelper::WriteSdtBlock(const ::sax_fastparser::FSHelperPtr& pSerializer, bool bRunTextIsOn, bool bParagraphHasDrawing) { - if (m_nSdtPrToken <= 0 && !m_pDataBindingAttrs.is() && !m_bHasId) + if (m_nSdtPrToken <= 0 && !m_pDataBindingAttrs.is() && !m_nId) return; // sdt start mark @@ -692,10 +692,10 @@ void SdtBlockHelper::WriteSdtBlock(const ::sax_fastparser::FSHelperPtr& pSeriali void SdtBlockHelper::WriteExtraParams(const ::sax_fastparser::FSHelperPtr& pSerializer) { - if (m_nSdtPrToken == FSNS(XML_w, XML_id) || m_bHasId) - //Word won't open a document with an empty id tag, we fill it with a random number - pSerializer->singleElementNS(XML_w, XML_id, FSNS(XML_w, XML_val), - OString::number(comphelper::rng::uniform_int_distribution(0, std::numeric_limits<int>::max()))); + if (m_nId) + { + pSerializer->singleElementNS(XML_w, XML_id, FSNS(XML_w, XML_val), OString::number(m_nId)); + } if (m_pDataBindingAttrs.is()) { @@ -860,6 +860,11 @@ void SdtBlockHelper::GetSdtParamsFromGrabBag(const uno::Sequence<beans::Property if (!(aPropertyValue.Value >>= m_aTag)) SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt tag value"); } + else if (aPropertyValue.Name == "ooxml:CT_SdtPr_id") + { + if (!(aPropertyValue.Value >>= m_nId)) + SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt id value"); + } else if (aPropertyValue.Name == "ooxml:CT_SdtPr_tabIndex" && !m_nTabIndex) { if (!(aPropertyValue.Value >>= m_nTabIndex)) @@ -870,8 +875,6 @@ void SdtBlockHelper::GetSdtParamsFromGrabBag(const uno::Sequence<beans::Property if (!(aPropertyValue.Value >>= m_aLock)) SAL_WARN("sw.ww8", "DocxAttributeOutput::GrabBag: unexpected sdt lock value"); } - else if (aPropertyValue.Name == "ooxml:CT_SdtPr_id") - m_bHasId = true; else if (aPropertyValue.Name == "ooxml:CT_SdtPr_citation") m_nSdtPrToken = FSNS(XML_w, XML_citation); else if (aPropertyValue.Name == "ooxml:CT_SdtPr_docPartObj" || diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index c4f152b85e5c..989a76268e81 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -128,14 +128,14 @@ class SdtBlockHelper { public: SdtBlockHelper() - : m_bHasId(false) + : m_nId(0) , m_bStartedSdt(false) , m_bShowingPlaceHolder(false) , m_nTabIndex(0) , m_nSdtPrToken(0) {} - bool m_bHasId; + sal_Int32 m_nId; bool m_bStartedSdt; rtl::Reference<sax_fastparser::FastAttributeList> m_pTokenChildren; rtl::Reference<sax_fastparser::FastAttributeList> m_pTokenAttributes; diff --git a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx index 7b27ff66d08c..fc99cd2e3416 100644 --- a/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx +++ b/writerfilter/qa/cppunittests/dmapper/SdtHelper.cxx @@ -71,6 +71,10 @@ CPPUNIT_TEST_FIXTURE(Test, testSdtRunRichText) xContentControlProps->getPropertyValue("Tag") >>= aTag; // This was empty. CPPUNIT_ASSERT_EQUAL(OUString("mytag"), aTag); + sal_Int32 nId = 0; + xContentControlProps->getPropertyValue("Id") >>= nId; + // This was 0. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2147483647), nId); sal_uInt32 nTabIndex = 0; xContentControlProps->getPropertyValue("TabIndex") >>= nTabIndex; // This was 0 diff --git a/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx b/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx Binary files differindex ca980abb0356..d5644f33e9d9 100644 --- a/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx +++ b/writerfilter/qa/cppunittests/dmapper/data/sdt-run-rich-text.docx diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index ab7cfeb401f0..61b4d6d114d4 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3023,13 +3023,15 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext ) } else if (nSprmId == NS_ooxml::LN_CT_SdtPr_showingPlcHdr) { + // Grabbag boolean values beans::PropertyValue aValue; aValue.Name = sName; aValue.Value <<= bool(nIntValue); m_pImpl->m_pSdtHelper->appendToInteropGrabBag(aValue); } - else if (nSprmId == NS_ooxml::LN_CT_SdtPr_tabIndex) + else if (nSprmId == NS_ooxml::LN_CT_SdtPr_id || nSprmId == NS_ooxml::LN_CT_SdtPr_tabIndex) { + // Grabbag integer values beans::PropertyValue aValue; aValue.Name = sName; aValue.Value <<= nIntValue; diff --git a/xmloff/qa/unit/data/content-control-alias.fodt b/xmloff/qa/unit/data/content-control-alias.fodt index 48fdc7b9436c..0742610ca63a 100644 --- a/xmloff/qa/unit/data/content-control-alias.fodt +++ b/xmloff/qa/unit/data/content-control-alias.fodt @@ -2,7 +2,7 @@ <office:document xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> <office:body> <office:text> - <text:p><loext:content-control loext:alias="my alias" loext:tag="my tag" loext:tab-index="4" loext:lock="sdtContentLocked">test</loext:content-control></text:p> + <text:p><loext:content-control loext:alias="my alias" loext:tag="my tag" loext:id="2147483647" loext:tab-index="4" loext:lock="sdtContentLocked">test</loext:content-control></text:p> </office:text> </office:body> </office:document> diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 9ae9e5cc1d22..f7155f546df3 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -781,6 +781,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAliasContentControlExport) uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY); xContentControlProps->setPropertyValue("Alias", uno::Any(OUString("my alias"))); xContentControlProps->setPropertyValue("Tag", uno::Any(OUString("my tag"))); + xContentControlProps->setPropertyValue("Id", uno::Any(static_cast<sal_Int32>(-2147483648))); xContentControlProps->setPropertyValue("TabIndex", uno::Any(sal_uInt32(3))); xContentControlProps->setPropertyValue("Lock", uno::Any(OUString("unlocked"))); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); @@ -796,6 +797,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAliasContentControlExport) // i.e. alias was lost on export. assertXPath(pXmlDoc, "//loext:content-control", "alias", "my alias"); assertXPath(pXmlDoc, "//loext:content-control", "tag", "my tag"); + assertXPath(pXmlDoc, "//loext:content-control", "id", "-2147483648"); assertXPath(pXmlDoc, "//loext:content-control", "tab-index", "3"); assertXPath(pXmlDoc, "//loext:content-control", "lock", "unlocked"); } @@ -857,6 +859,9 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAliasContentControlImport) OUString aTag; xContentControlProps->getPropertyValue("Tag") >>= aTag; CPPUNIT_ASSERT_EQUAL(OUString("my tag"), aTag); + sal_Int32 nId = 0; + xContentControlProps->getPropertyValue("Id") >>= nId; + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2147483647), nId); sal_uInt32 nTabIndex; xContentControlProps->getPropertyValue("TabIndex") >>= nTabIndex; CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(4), nTabIndex); diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 2c922a6242af..5f874c50c4cf 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -4072,6 +4072,13 @@ void XMLTextParagraphExport::ExportContentControl( GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_TAG, aTag); } + sal_Int32 nId = 0; + xPropertySet->getPropertyValue("Id") >>= nId; + if (nId) + { + GetExport().AddAttribute(XML_NAMESPACE_LO_EXT, XML_ID, OUString::number(nId)); + } + sal_uInt32 nTabIndex; xPropertySet->getPropertyValue("TabIndex") >>= nTabIndex; if (nTabIndex) diff --git a/xmloff/source/text/xmlcontentcontrolcontext.cxx b/xmloff/source/text/xmlcontentcontrolcontext.cxx index caf1af04b8d7..2a7ef5b2eebe 100644 --- a/xmloff/source/text/xmlcontentcontrolcontext.cxx +++ b/xmloff/source/text/xmlcontentcontrolcontext.cxx @@ -152,6 +152,14 @@ void XMLContentControlContext::startFastElement( m_aTag = rIter.toString(); break; } + case XML_ELEMENT(LO_EXT, XML_ID): + { + if (sax::Converter::convertNumber(nTmp, rIter.toView())) + { + m_nId = nTmp; + } + break; + } case XML_ELEMENT(LO_EXT, XML_TAB_INDEX): { if (sax::Converter::convertNumber(nTmp, rIter.toView())) @@ -276,6 +284,11 @@ void XMLContentControlContext::endFastElement(sal_Int32) xPropertySet->setPropertyValue("Tag", uno::Any(m_aTag)); } + if (m_nId) + { + xPropertySet->setPropertyValue("Id", uno::Any(m_nId)); + } + if (m_nTabIndex) { xPropertySet->setPropertyValue("TabIndex", uno::Any(m_nTabIndex)); diff --git a/xmloff/source/text/xmlcontentcontrolcontext.hxx b/xmloff/source/text/xmlcontentcontrolcontext.hxx index 44abe71d6a08..13c1e50f23fa 100644 --- a/xmloff/source/text/xmlcontentcontrolcontext.hxx +++ b/xmloff/source/text/xmlcontentcontrolcontext.hxx @@ -53,6 +53,7 @@ class XMLContentControlContext : public SvXMLImportContext bool m_bDropDown = false; OUString m_aAlias; OUString m_aTag; + sal_Int32 m_nId = 0; sal_uInt32 m_nTabIndex = 0; OUString m_aLock; |