summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2017-08-22 23:40:56 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2017-08-23 00:18:46 +0200
commitb45446fcb4958b13bc94e70e2d3d1940db3322e2 (patch)
tree8b78ac9b3a205b2137851c0a562c6bbbc525f421
parentf53c9922c653123b43e039ff70bbd515c97db252 (diff)
tdf#111975: Inline checkbox control's label is not saved to DOC format
This MiserableFormFieldExportHack lives from the beginning of the git history: 7155b11b7eac65e242aca1efaf29ffcfa28f2564 So it might be a workaround of an old issue. By now when the checkbox is not inline, but a floating one, it is exported as ActiveX control, which works nicely. So just remove this workaround and let the code export also inline checkboxes as ActiveX controls. Change-Id: I350b7a7595bb46334c63d9dfcf40abf9e10943bc Reviewed-on: https://gerrit.libreoffice.org/41436 Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com> Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r--sw/CppunitTest_sw_ww8export2.mk2
-rwxr-xr-xsw/qa/extras/ww8export/data/checkbox_control.odtbin0 -> 9601 bytes
-rw-r--r--sw/qa/extras/ww8export/ww8export2.cxx39
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx2
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx69
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx1
6 files changed, 42 insertions, 71 deletions
diff --git a/sw/CppunitTest_sw_ww8export2.mk b/sw/CppunitTest_sw_ww8export2.mk
index 20f7df957a61..99551b36750e 100644
--- a/sw/CppunitTest_sw_ww8export2.mk
+++ b/sw/CppunitTest_sw_ww8export2.mk
@@ -52,6 +52,8 @@ $(eval $(call gb_CppunitTest_use_components,sw_ww8export2,\
comphelper/util/comphelp \
configmgr/source/configmgr \
dbaccess/util/dba \
+ embeddedobj/util/embobj \
+ emfio/emfio \
filter/source/config/cache/filterconfig1 \
filter/source/storagefilterdetect/storagefd \
forms/util/frm \
diff --git a/sw/qa/extras/ww8export/data/checkbox_control.odt b/sw/qa/extras/ww8export/data/checkbox_control.odt
new file mode 100755
index 000000000000..b5281b30eecd
--- /dev/null
+++ b/sw/qa/extras/ww8export/data/checkbox_control.odt
Binary files differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index cb6155cf444a..066b680d01dd 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -16,6 +16,8 @@
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
#include <com/sun/star/text/XFootnote.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
#include <ftninfo.hxx>
#include <pagedesc.hxx>
@@ -229,6 +231,43 @@ DECLARE_WW8EXPORT_TEST(testTdf111480, "tdf111480.doc")
CPPUNIT_ASSERT(xText->getSize().Width > 11000);
}
+DECLARE_WW8EXPORT_TEST( testActiveXCheckbox, "checkbox_control.odt" )
+{
+ // First check box anchored as a floating object
+ uno::Reference<drawing::XControlShape> xControlShape;
+ if(!mbExported)
+ xControlShape.set(getShape(1), uno::UNO_QUERY);
+ else
+ xControlShape.set(getShape(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xControlShape.is());
+
+ // Check whether we have the right control
+ uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
+ uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService( "com.sun.star.form.component.CheckBox")));
+ CPPUNIT_ASSERT_EQUAL(OUString("Floating Checkbox"), getProperty<OUString>(xPropertySet, "Label"));
+
+ // Check anchor type
+ uno::Reference<beans::XPropertySet> xPropertySet2(xControlShape, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
+
+ // Second check box anchored inline / as character
+ if(!mbExported)
+ xControlShape.set(getShape(2), uno::UNO_QUERY);
+ else
+ xControlShape.set(getShape(1), uno::UNO_QUERY);
+
+ // Check whether we have the right control
+ xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
+ xServiceInfo.set(xPropertySet, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.CheckBox")));
+ CPPUNIT_ASSERT_EQUAL(OUString("Inline Checkbox"), getProperty<OUString>(xPropertySet, "Label"));
+
+ // Check anchor type
+ xPropertySet2.set(xControlShape, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index e0020a473856..5a1cd9252921 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1967,7 +1967,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
m_aRun->append(OUStringToOString(FieldString(ww::eFORMCHECKBOX), m_rExport.m_eCurrentEncoding));
m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFTYPE "1"); // 1 = checkbox
- // checkbox size in half points, this seems to be always 20, see WW8Export::DoCheckBox()
+ // checkbox size in half points, this seems to be always 20
m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFHPS "20");
OUString aStr;
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index f29a568a27a5..f5450722ce38 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -384,12 +384,6 @@ bool WW8Export::MiserableFormFieldExportHack(const SwFrameFormat& rFrameFormat)
return true;
}
- if (xInfo->supportsService("com.sun.star.form.component.CheckBox"))
- {
- DoCheckBox(xPropSet);
- return true;
- }
-
return false;
}
@@ -488,69 +482,6 @@ void WW8Export::DoComboBox(const OUString &rName,
aFFData.Write(pDataStrm);
}
-void WW8Export::DoCheckBox(uno::Reference<beans::XPropertySet> const & xPropSet)
-{
- uno::Reference<beans::XPropertySetInfo> xPropSetInfo =
- xPropSet->getPropertySetInfo();
-
- OutputField(nullptr, ww::eFORMCHECKBOX, FieldString(ww::eFORMCHECKBOX),
- FieldFlags::Start | FieldFlags::CmdStart);
- // write the reference to the "picture" structure
- sal_uLong nDataStt = pDataStrm->Tell();
- m_pChpPlc->AppendFkpEntry( Strm().Tell() );
-
- WriteChar( 0x01 );
- static sal_uInt8 aArr1[] = {
- 0x03, 0x6a, 0,0,0,0, // sprmCPicLocation
-
- 0x06, 0x08, 0x01, // sprmCFData
- 0x55, 0x08, 0x01, // sprmCFSpec
- 0x02, 0x08, 0x01 // sprmCFFieldVanish
- };
- sal_uInt8* pDataAdr = aArr1 + 2;
- Set_UInt32( pDataAdr, nDataStt );
-
- m_pChpPlc->AppendFkpEntry(Strm().Tell(),
- sizeof( aArr1 ), aArr1 );
-
- ::sw::WW8FFData aFFData;
-
- aFFData.setType(1);
- aFFData.setCheckboxHeight(0x14);
-
- sal_Int16 nTemp = 0;
- xPropSet->getPropertyValue("DefaultState") >>= nTemp;
- aFFData.setDefaultResult(nTemp);
-
- xPropSet->getPropertyValue("State") >>= nTemp;
- aFFData.setResult(nTemp);
-
- OUString aStr;
- static const char sName[] = "Name";
- if (xPropSetInfo->hasPropertyByName(sName))
- {
- xPropSet->getPropertyValue(sName) >>= aStr;
- aFFData.setName(aStr);
- }
-
- static const char sHelpText[] = "HelpText";
- if (xPropSetInfo->hasPropertyByName(sHelpText))
- {
- xPropSet->getPropertyValue(sHelpText) >>= aStr;
- aFFData.setHelp(aStr);
- }
- static const char sHelpF1Text[] = "HelpF1Text";
- if (xPropSetInfo->hasPropertyByName(sHelpF1Text))
- {
- xPropSet->getPropertyValue(sHelpF1Text) >>= aStr;
- aFFData.setStatus(aStr);
- }
-
- aFFData.Write(pDataStrm);
-
- OutputField(nullptr, ww::eFORMCHECKBOX, OUString(), FieldFlags::Close);
-}
-
void WW8Export::DoFormText(const SwInputField * pField)
{
OutputField(nullptr, ww::eFORMTEXT, FieldString(ww::eFORMTEXT),
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index ffa7221bdb90..e726231442fa 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -998,7 +998,6 @@ private:
void RestoreMacroCmds();
void DoComboBox(css::uno::Reference<css::beans::XPropertySet> const & xPropSet);
- void DoCheckBox(css::uno::Reference<css::beans::XPropertySet> const & xPropSet);
public: