[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/CppunitTest_sw_ww8export2.mk sw/qa sw/source
Tamás Zolnai
tamas.zolnai at collabora.com
Fri Aug 25 13:00:59 UTC 2017
sw/CppunitTest_sw_ww8export2.mk | 1
sw/qa/extras/ww8export/data/checkbox_control.odt |binary
sw/qa/extras/ww8export/ww8export2.cxx | 41 +++++++++++++
sw/source/filter/ww8/rtfattributeoutput.cxx | 2
sw/source/filter/ww8/wrtw8esh.cxx | 69 -----------------------
sw/source/filter/ww8/wrtww8.hxx | 1
6 files changed, 43 insertions(+), 71 deletions(-)
New commits:
commit 813cb3dabe38c5920f26f6c3ce0b32ae19393886
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date: Wed Aug 23 23:07:39 2017 +0200
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.
Reviewed-on: https://gerrit.libreoffice.org/41436
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit b45446fcb4958b13bc94e70e2d3d1940db3322e2)
Change-Id: I350b7a7595bb46334c63d9dfcf40abf9e10943bc
Reviewed-on: https://gerrit.libreoffice.org/41485
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/sw/CppunitTest_sw_ww8export2.mk b/sw/CppunitTest_sw_ww8export2.mk
index c09e528b0aa9..840d586c3679 100644
--- a/sw/CppunitTest_sw_ww8export2.mk
+++ b/sw/CppunitTest_sw_ww8export2.mk
@@ -52,6 +52,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ww8export2,\
comphelper/util/comphelp \
configmgr/source/configmgr \
dbaccess/util/dba \
+ embeddedobj/util/embobj \
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
Binary files /dev/null and b/sw/qa/extras/ww8export/data/checkbox_control.odt differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 4df5bc985212..2819fa3569dd 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -15,6 +15,10 @@
#include <com/sun/star/text/XTextFramesSupplier.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
+
#include <pagedesc.hxx>
class Test : public SwModelTestBase
@@ -120,6 +124,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 699ad22fde26..4305865397d3 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1974,7 +1974,7 @@ void RtfAttributeOutput::OutputFlyFrame_Impl(const ww8::Frame& rFrame, const Poi
m_aRun->append(OUStringToOString(OUString(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 fc68e76fcd0e..a570f9e47a15 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -387,12 +387,6 @@ bool WW8Export::MiserableFormFieldExportHack(const SwFrameFormat& rFrameFormat)
return true;
}
- if (xInfo->supportsService("com.sun.star.form.component.CheckBox"))
- {
- DoCheckBox(xPropSet);
- return true;
- }
-
return false;
}
@@ -491,69 +485,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),
- WRITEFIELD_START | WRITEFIELD_CMD_START);
- // write the refence 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(), WRITEFIELD_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 41e673c8f65b..7d721b391993 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -993,7 +993,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:
More information about the Libreoffice-commits
mailing list