Kaydet (Commit) b45446fc authored tarafından Tamás Zolnai's avatar Tamás Zolnai

tdf#111975: Inline checkbox control's label is not saved to DOC format

This MiserableFormFieldExportHack lives from the beginning
of the git history:
7155b11b

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/41436Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst f53c9922
......@@ -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 \
......
......@@ -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: */
......@@ -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;
......
......@@ -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),
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment