[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source xmloff/source
sw/qa/extras/globalfilter/data/date_form_field.odt |binary sw/qa/extras/globalfilter/globalfilter.cxx | 97 + sw/source/core/doc/docbm.cxx |6 - sw/source/filter/ww8/docxattributeoutput.cxx | 93 sw/source/filter/ww8/docxattributeoutput.hxx |2 sw/source/filter/ww8/fields.hxx|3 sw/source/filter/ww8/wrtw8nds.cxx | 40 +--- xmloff/source/text/XMLTextMarkImportContext.cxx|5 - 8 files changed, 228 insertions(+), 18 deletions(-) New commits: commit 865bfe5cc95c11ab7273bd3ac74cd4f4bd9e097e Author: Tamás Zolnai AuthorDate: Fri Jun 21 20:40:27 2019 +0200 Commit: Tamás Zolnai CommitDate: Fri Jul 12 03:17:36 2019 +0200 MSForms: DOCX export of date content control Change-Id: I546af6d552e5e3801925285d0095fc8502896a15 Reviewed-on: https://gerrit.libreoffice.org/75446 Tested-by: Jenkins Reviewed-by: Tamás Zolnai diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index e5167a264f41..0ccf7001c0e1 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -239,6 +239,7 @@ public: m_pSerializer->endElementNS( XML_w, XML_checkBox ); writeFinish(); } + void WriteFormText( const OUString& rName, const OUString& rEntryMacro, const OUString& rExitMacro, @@ -1877,6 +1878,84 @@ void DocxAttributeOutput::WriteFFData( const FieldInfos& rInfos ) } } +void DocxAttributeOutput::WriteFormDate(const OUString& sCurrentDate, const OUString& sDateFormat, const OUString& sLang) +{ +m_pSerializer->startElementNS(XML_w, XML_sdt); +m_pSerializer->startElementNS(XML_w, XML_sdtPr); + +if (!sCurrentDate.isEmpty()) +{ +OString sDate = sCurrentDate.toUtf8() + "T00:00:00Z"; +m_pSerializer->startElementNS(XML_w, XML_date, FSNS(XML_w, XML_fullDate), sDate); +} +else +m_pSerializer->startElementNS(XML_w, XML_date); + +m_pSerializer->singleElementNS(XML_w, XML_dateFormat, + FSNS(XML_w, XML_val), sDateFormat.toUtf8()); +m_pSerializer->singleElementNS(XML_w, XML_lid, + FSNS(XML_w, XML_val), sLang.toUtf8()); +m_pSerializer->singleElementNS(XML_w, XML_storeMappedDataAs, + FSNS(XML_w, XML_val), "dateTime"); +m_pSerializer->singleElementNS(XML_w, XML_calendar, + FSNS(XML_w, XML_val), "gregorian"); + +m_pSerializer->endElementNS(XML_w, XML_date); +m_pSerializer->endElementNS(XML_w, XML_sdtPr); + +m_pSerializer->startElementNS(XML_w, XML_sdtContent); +m_pSerializer->startElementNS(XML_w, XML_r); + +if (!sCurrentDate.isEmpty()) +{ +// Convert the current date to the right format +if (!sCurrentDate.isEmpty()) +{ +SvNumberFormatter* pFormatter = m_rExport.m_pDoc->GetNumberFormatter(); + +double dCurrentDate = 0.0; +// First get the date internal double representation +sal_uInt32 nFormat = pFormatter->GetEntryKey(ODF_FORMDATE_CURRENTDATE_FORMAT, ODF_FORMDATE_CURRENTDATE_LANGUAGE);if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) +if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) +{ +sal_Int32 nCheckPos = 0; +SvNumFormatType nType; +OUString sFormat = ODF_FORMDATE_CURRENTDATE_FORMAT; +pFormatter->PutEntry(sFormat, + nCheckPos, + nType, + nFormat, + ODF_FORMDATE_CURRENTDATE_LANGUAGE); +} +pFormatter->IsNumberFormat(sCurrentDate, nFormat, dCurrentDate); + +// Then convert the date to a fromatter string +OUString sOutput; +Color* pCol = nullptr; +nFormat = pFormatter->GetEntryKey(sDateFormat, LanguageTag(sLang).getLanguageType()); +if (nFormat == NUMBERFORMAT_ENTRY_NOT_FOUND) +{ +sal_Int32 nCheckPos = 0; +SvNumFormatType nType; +OUString sNonConstDateFormat = sDateFormat; +pFormatter->PutEntry(sNonConstDateFormat, + nCheckPos, + nType, + nFormat, + LanguageTag(sLang).getLanguageType()); +} +pFormatter->GetOutputString(dCurrentDate, nFormat, sOutput, , false); + +RunText(sOutput); +} +} + +m_pSerializer->endElementNS(XML_w, XML_r); +m_pSerializer->endElementNS(XML_w, XML_sdtContent); + +
[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source xmloff/source
sw/qa/extras/odfexport/odfexport.cxx |5 + sw/source/core/docnode/node.cxx |3 +++ sw/source/filter/xml/xmltble.cxx | 34 ++ sw/source/filter/xml/xmltbli.cxx |4 +++- xmloff/source/text/txtimp.cxx|1 + 5 files changed, 34 insertions(+), 13 deletions(-) New commits: commit e4de5b40eb7220da2d337eb98d7905a98dc12c72 Author: Miklos Vajna vmik...@collabora.co.uk Date: Sat Dec 27 12:11:43 2014 +0100 fdo#84714 ODT export: write loext:table inside draw:custom-shape Change-Id: I543ec24f8825bcc7c35acc106402f4fc6b4b5d79 diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 41c4ed9..194fc34 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -400,6 +400,11 @@ DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, textbox-rounded-corners.odt) uno::Referencetext::XTextTable xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY); uno::Referencetext::XTextRange xCell(xTable-getCellByName(A1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString(a), xCell-getString()); + +// Table inside a textbox should be in the extension namespace. +if (xmlDocPtr pXmlDoc = parseExport(content.xml)) +// This failed, as draw:custom-shape had a table:table child. +assertXPath(pXmlDoc, //draw:custom-shape/loext:table, name, Table1); } DECLARE_ODFEXPORT_TEST(testFdo86963, fdo86963.odt) diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 98126b7..14af4ce 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -717,6 +717,9 @@ SwFrmFmt* SwNode::GetFlyFmt() const for( size_t n = 0; n rFrmFmtTbl.size(); ++n ) { SwFrmFmt* pFmt = rFrmFmtTbl[n]; +// Only Writer fly frames can contain Writer nodes. +if (pFmt-Which() != RES_FLYFRMFMT) +continue; const SwFmtCntnt rCntnt = pFmt-GetCntnt(); if( rCntnt.GetCntntIdx() rCntnt.GetCntntIdx()-GetNode() == pSttNd ) diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index d426787..a698c94 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -50,6 +50,7 @@ #include xmlexp.hxx #include boost/foreach.hpp #include o3tl/sorted_vector.hxx +#include textboxhelper.hxx using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -461,10 +462,11 @@ class SwXMLTableInfo_Impl const SwTable *pTable; Reference XTextSection xBaseSection; bool bBaseSectionValid; +sal_uInt32 m_nPrefix; public: -inline SwXMLTableInfo_Impl( const SwTable *pTbl ); +inline SwXMLTableInfo_Impl( const SwTable *pTbl, sal_uInt16 nPrefix ); const SwTable *GetTable() const { return pTable; } const SwFrmFmt *GetTblFmt() const { return pTable-GetFrmFmt(); } @@ -472,11 +474,14 @@ public: bool IsBaseSectionValid() const { return bBaseSectionValid; } const Reference XTextSection GetBaseSection() const { return xBaseSection; } inline void SetBaseSection( const Reference XTextSection rBase ); +/// The namespace (table or loext) that should be used for the elements. +sal_uInt16 GetPrefix() const { return m_nPrefix; } }; -inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl( const SwTable *pTbl ) : +inline SwXMLTableInfo_Impl::SwXMLTableInfo_Impl( const SwTable *pTbl, sal_uInt16 nPrefix ) : pTable( pTbl ), -bBaseSectionValid( false ) +bBaseSectionValid( false ), +m_nPrefix(nPrefix) { } @@ -719,7 +724,7 @@ void SwXMLExport::ExportTableAutoStyles( const SwTableNode rTblNd ) SwXMLTableColumnsSortByWidth_Impl aExpCols; SwXMLTableFrmFmtsSort_Impl aExpRows; SwXMLTableFrmFmtsSort_Impl aExpCells; -SwXMLTableInfo_Impl aTblInfo( rTbl ); +SwXMLTableInfo_Impl aTblInfo( rTbl, XML_NAMESPACE_TABLE ); ExportTableLinesAutoStyles( rTbl.GetTabLines(), nAbsWidth, nBaseWidth, pTblFmt-GetName(), aExpCols, aExpRows, aExpCells, aTblInfo, true); @@ -828,7 +833,7 @@ void SwXMLExport::ExportTableBox( const SwTableBox rBox, } // export cell element -SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, +SvXMLElementExport aElem( *this, rTblInfo.GetPrefix(), XML_TABLE_CELL, true, true ); // export cell content @@ -879,8 +884,7 @@ void SwXMLExport::ExportTableLine( const SwTableLine rLine, } { -SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, - XML_TABLE_ROW, true, true ); +SvXMLElementExport aElem( *this, rTblInfo.GetPrefix(), XML_TABLE_ROW, true, true ); const
[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source xmloff/source
sw/qa/extras/odfexport/data/fdo60769.odt |binary sw/qa/extras/odfexport/odfexport.cxx | 28 sw/source/core/unocore/unoportenum.cxx | 12 xmloff/source/text/txtparae.cxx | 20 4 files changed, 52 insertions(+), 8 deletions(-) New commits: commit 19802872052aaed9d3deff02b882b2043239a406 Author: Miklos Vajna vmik...@suse.cz Date: Wed Mar 20 10:43:57 2013 +0100 fdo#60769 implement odf export of multi-paragraph comment ranges Change-Id: Ifb850438586eb6589fde79d10ed9eef727368f42 diff --git a/sw/qa/extras/odfexport/data/fdo60769.odt b/sw/qa/extras/odfexport/data/fdo60769.odt new file mode 100644 index 000..b3c3937 Binary files /dev/null and b/sw/qa/extras/odfexport/data/fdo60769.odt differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 4ed23f1..e121c2f 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -35,6 +35,7 @@ public: void testFdo38244(); void testFirstHeaderFooter(); void testTextframeGradient(); +void testFdo60769(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) !defined(WNT) @@ -52,6 +53,7 @@ void Test::run() {fdo38244.odt, Test::testFdo38244}, {first-header-footer.odt, Test::testFirstHeaderFooter}, {textframe-gradient.odt, Test::testTextframeGradient}, +{fdo60769.odt, Test::testFdo60769}, }; header(); for (unsigned int i = 0; i SAL_N_ELEMENTS(aMethods); ++i) @@ -133,6 +135,32 @@ void Test::testTextframeGradient() CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); } +void Test::testFdo60769() +{ +// Test multi-paragraph comment range feature. +uno::Referencetext::XTextDocument xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Referencecontainer::XEnumerationAccess xParaEnumAccess(xTextDocument-getText(), uno::UNO_QUERY); +uno::Referencecontainer::XEnumeration xParaEnum = xParaEnumAccess-createEnumeration(); +uno::Referencecontainer::XEnumerationAccess xRunEnumAccess(xParaEnum-nextElement(), uno::UNO_QUERY); +uno::Referencecontainer::XEnumeration xRunEnum = xRunEnumAccess-createEnumeration(); +while (xRunEnum-hasMoreElements()) +{ +uno::Referencebeans::XPropertySet xPropertySet(xRunEnum-nextElement(), uno::UNO_QUERY); +OUString aType = getPropertyOUString(xPropertySet, TextPortionType); +// First paragraph: no field end, no anchor +CPPUNIT_ASSERT(aType == Text || aType == TextFieldStart); +} + +xRunEnumAccess.set(xParaEnum-nextElement(), uno::UNO_QUERY); +while (xRunEnum-hasMoreElements()) +{ +uno::Referencebeans::XPropertySet xPropertySet(xRunEnum-nextElement(), uno::UNO_QUERY); +OUString aType = getPropertyOUString(xPropertySet, TextPortionType); +// Second paragraph: no field start +CPPUNIT_ASSERT(aType == Text || aType == TextFieldEnd || aType == TextFieldEnd); +} +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index 44f7e4d..cf8dcc8 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -2194,7 +2194,6 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( static const OUString sMeta(InContentMetadata); static const OUString sFieldMarkName(__FieldMark_); bool bPrevCharIsSpace = bPrvChrIsSpc; -bool bAnnotationStarted = false; /* This is used for exporting to strict OpenDocument 1.2, in which case traditional * bookmarks are used instead of fieldmarks. */ @@ -2218,11 +2217,17 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( } else if( sType.equals(sTextField)) { -if (bAnnotationStarted) +Reference ::com::sun::star::text::XFormField xFormField; +try { -bAnnotationStarted = false; +xFormField.set(xPropSet-getPropertyValue(sBookmark), UNO_QUERY); } -else +catch( const uno::Exception ) +{ +SAL_WARN(xmloff, unexpected bookmark exception); +} + +if (!xFormField.is() || xFormField-getFieldType() != ODF_COMMENTRANGE) { exportTextField( xTxtRange, bAutoStyles, bIsProgress ); bPrevCharIsSpace = false; @@ -2287,10 +2292,9 @@ void XMLTextParagraphExport::exportTextRangeEnumeration( else if (sType.equals(sTextFieldStart)) { Reference ::com::sun::star::text::XFormField xFormField(xPropSet-getPropertyValue(sBookmark), UNO_QUERY); -if (xFormField-getFieldType() == ODF_COMMENTRANGE) +if (xFormField.is()