diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-21 17:19:23 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-02-21 18:11:00 +0100 |
commit | 1ec263e25d8606c70ac2089d5ceea22750d25daf (patch) | |
tree | 014553723a1d4bcf694665185ce406a37fb93ad4 | |
parent | Replace handwritten reference counting with shared_ptr (diff) | |
download | core-1ec263e25d8606c70ac2089d5ceea22750d25daf.tar.gz core-1ec263e25d8606c70ac2089d5ceea22750d25daf.zip |
DOCX export: initial support for the DateField form control
Before we started to import the date SDT as a form control, we exported
what is now the HelpText property on the control. So as an initial step,
export that back as plain text, without any formatting.
Change-Id: I569e6690b0c580d8073611b48d610f87974145b3
-rw-r--r-- | sw/CppunitTest_sw_ooxmlexport.mk | 1 | ||||
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/form-control.docx | bin | 0 -> 13507 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 36 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 2 |
5 files changed, 45 insertions, 2 deletions
diff --git a/sw/CppunitTest_sw_ooxmlexport.mk b/sw/CppunitTest_sw_ooxmlexport.mk index 6d09ca211495..30643b23e5d2 100644 --- a/sw/CppunitTest_sw_ooxmlexport.mk +++ b/sw/CppunitTest_sw_ooxmlexport.mk @@ -58,6 +58,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlexport,\ drawinglayer/drawinglayer \ embeddedobj/util/embobj \ filter/source/config/cache/filterconfig1 \ + forms/util/frm \ framework/util/fwk \ i18npool/util/i18npool \ linguistic/source/lng \ diff --git a/sw/qa/extras/ooxmlexport/data/form-control.docx b/sw/qa/extras/ooxmlexport/data/form-control.docx Binary files differnew file mode 100755 index 000000000000..4f6305a8ca74 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/form-control.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 025b27e2d84e..ceea5c2547ad 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2280,6 +2280,14 @@ DECLARE_OOXMLEXPORT_TEST(testDmlShapeTitle, "dml-shape-title.docx") CPPUNIT_ASSERT_EQUAL(OUString("Description"), getProperty<OUString>(getShape(1), "Description")); } +DECLARE_OOXMLEXPORT_TEST(testFormControl, "form-control.docx") +{ + if (!m_bExported) + return; + // "[Date]" was missing. + getParagraph(1, "Foo [Date] bar."); +} + DECLARE_OOXMLEXPORT_TEST(testBehinddoc, "behinddoc.docx") { xmlDocPtr pXmlDoc = parseExport("word/document.xml"); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index ab71fd93075f..8087ca71161c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -80,6 +80,8 @@ #include <editeng/editobj.hxx> #include <svx/xfillit0.hxx> #include <svx/xflgrit.hxx> +#include <svx/fmglob.hxx> +#include <svx/svdouno.hxx> #include <svl/grabbagitem.hxx> #include <sfx2/sfxbasemodel.hxx> #include <tools/datetimeutils.hxx> @@ -696,6 +698,11 @@ void DocxAttributeOutput::EndRun() m_pSerializer->endElementNS( XML_w, XML_r ); WritePostponedMath(); + + for (std::vector<const SdrObject*>::iterator it = m_aPostponedFormControls.begin(); it != m_aPostponedFormControls.end(); ++it) + WritePostponedFormControl(*it); + m_aPostponedFormControls.clear(); + WritePendingPlaceholder(); // if there is some redlining in the document, output it @@ -3311,6 +3318,26 @@ void DocxAttributeOutput::WritePostponedMath() m_postponedMath = NULL; } +void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject) +{ + if (pObject && pObject->GetObjInventor() == FmFormInventor) + { + if (SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObject)) + { + uno::Reference<awt::XControlModel> xControlModel = pFormObj->GetUnoControlModel(); + uno::Reference<lang::XServiceInfo> xInfo(xControlModel, uno::UNO_QUERY); + if (xInfo->supportsService("com.sun.star.form.component.DateField")) + { + uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY); + OUString aHelpText = xPropertySet->getPropertyValue("HelpText").get<OUString>(); + m_pSerializer->startElementNS(XML_w, XML_r, FSEND); + RunText(aHelpText); + m_pSerializer->endElementNS(XML_w, XML_r); + } + } + } +} + /* * Write w:pict hierarchy end element of w:rPr tag. */ @@ -3417,11 +3444,16 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po } } break; + case sw::Frame::eFormControl: + { + const SdrObject* pObject = rFrame.GetFrmFmt().FindRealSdrObject(); + m_aPostponedFormControls.push_back(pObject); + } + break; default: OSL_TRACE( "TODO DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& rNdTopLeft ) - frame type '%s'\n", rFrame.GetWriterType() == sw::Frame::eTxtBox? "eTxtBox": - ( rFrame.GetWriterType() == sw::Frame::eOle? "eOle": - ( rFrame.GetWriterType() == sw::Frame::eFormControl? "eFormControl": "???" ) ) ); + ( rFrame.GetWriterType() == sw::Frame::eOle? "eOle": "???" ) ); break; } diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 47ce782b8443..660776c23765 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -665,6 +665,7 @@ private: void DoWriteAnnotationMarks( ); void WritePostponedGraphic(); void WritePostponedMath(); + void WritePostponedFormControl(const SdrObject* pObject); void WritePostponedDiagram(); void WritePostponedChart(); void WritePostponedVMLDrawing(); @@ -785,6 +786,7 @@ private: const SwOLENode* m_postponedMath; const SdrObject* m_postponedChart; Size m_postponedChartSize; + std::vector<const SdrObject*> m_aPostponedFormControls; const SwField* pendingPlaceholder; /// Maps postit fields to ID's, used in commentRangeStart/End, commentReference and comment.xml. std::vector< std::pair<const SwPostItField*, sal_Int32> > m_postitFields; |