sw/qa/extras/ooxmlimport/data/n820509.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 19 +++++++++++++++++++ writerfilter/source/dmapper/DomainMapper.cxx | 10 ++++++---- writerfilter/source/dmapper/ModelEventListener.cxx | 10 ++++++++-- writerfilter/source/dmapper/ModelEventListener.hxx | 4 +++- writerfilter/source/dmapper/SdtHelper.cxx | 6 ++++++ writerfilter/source/dmapper/SdtHelper.hxx | 4 ++++ 7 files changed, 46 insertions(+), 7 deletions(-)
New commits: commit a9e0ec2b87a99c93b77a210a916b4df44ece454a Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Jun 5 11:44:10 2013 +0200 bnc#820509 testcase Change-Id: Iee9909e9c42014ab10ceaa2f8f8e554c25e89157 diff --git a/sw/qa/extras/ooxmlimport/data/n820509.docx b/sw/qa/extras/ooxmlimport/data/n820509.docx new file mode 100755 index 0000000..a6da1e1 Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n820509.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 601f154..b30ebd6 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/style/ParagraphAdjust.hpp> #include <com/sun/star/table/ShadowFormat.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/view/XFormLayerAccess.hpp> #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/TableBorder2.hpp> #include <com/sun/star/text/SizeType.hpp> @@ -116,6 +117,7 @@ public: void testWatermark(); void testPageBorderShadow(); void testN816593(); + void testN820509(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -200,6 +202,7 @@ void Test::run() {"watermark.docx", &Test::testWatermark}, {"page-border-shadow.docx", &Test::testPageBorderShadow}, {"n816593.docx", &Test::testN816593}, + {"n820509.docx", &Test::testN820509}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1432,6 +1435,22 @@ void Test::testN816593() CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount()); } +void Test::testN820509() +{ + // Design mode was enabled. + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<view::XFormLayerAccess> xFormLayerAccess(xModel->getCurrentController(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(false, bool(xFormLayerAccess->isFormDesignMode())); + + // M.d.yyyy date format was unhandled. + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + uno::Reference<drawing::XControlShape> xControlShape(xDraws->getByIndex(0), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY); + uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int16(8), getProperty<sal_Int16>(xPropertySet, "DateFormat")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit 58197c3692df0d0fccb5bc7abddaf6d9667565f6 Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Jun 5 11:22:33 2013 +0200 bnc#820509 DOCX import: handle M.d.yyyy date format in w:sdt Change-Id: Iae233c24a9580ffc8ea4680276161a543171f63c diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index b0bdc58..2e571d9 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3343,8 +3343,9 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType break; case NS_ooxml::LN_CT_SdtDate_dateFormat: { - if (sStringValue == "M/d/yyyy") - // See com/sun/star/awt/UnoControlDateFieldModel.idl, DateFormat; sadly there are no constants for this. + // See com/sun/star/awt/UnoControlDateFieldModel.idl, DateFormat; sadly there are no constants for this. + if (sStringValue == "M/d/yyyy" || sStringValue == "M.d.yyyy") + // Approximate with MM.dd.yyy m_pImpl->m_pSdtHelper->getDateFormat().reset(8); else { commit 3d6a7cf3eb7aa966601cbc019d1ad5fafdddd21f Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Jun 5 10:29:25 2013 +0200 bnc#820509 DOCX import: try harder to disable form design mode Previously this only worked if we had indexes in the document as well, but actually these are independent. Change-Id: I28afa60d2606230c901948d4c1da8f5a7c50a9f7 diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index f611bda..b0bdc58 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -143,11 +143,12 @@ DomainMapper::~DomainMapper() xEnumeration->nextElement(); } } - if( nIndexes ) + if( nIndexes || m_pImpl->m_pSdtHelper->hasElements()) { //index update has to wait until first view is created uno::Reference< document::XEventBroadcaster > xBroadcaster(xIndexesSupplier, uno::UNO_QUERY); - xBroadcaster->addEventListener(uno::Reference< document::XEventListener >(new ModelEventListener)); + if (xBroadcaster.is()) + xBroadcaster->addEventListener(uno::Reference< document::XEventListener >(new ModelEventListener(nIndexes, m_pImpl->m_pSdtHelper->hasElements()))); } diff --git a/writerfilter/source/dmapper/ModelEventListener.cxx b/writerfilter/source/dmapper/ModelEventListener.cxx index 8513c27..8da3224 100644 --- a/writerfilter/source/dmapper/ModelEventListener.cxx +++ b/writerfilter/source/dmapper/ModelEventListener.cxx @@ -38,7 +38,9 @@ using namespace ::com::sun::star; -ModelEventListener::ModelEventListener() +ModelEventListener::ModelEventListener(bool bIndexes, bool bControls) + : m_bIndexes(bIndexes), + m_bControls(bControls) { } @@ -50,7 +52,7 @@ ModelEventListener::~ModelEventListener() void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException) { - if ( rEvent.EventName == "OnFocus" ) + if ( rEvent.EventName == "OnFocus" && m_bIndexes) { try { @@ -101,6 +103,10 @@ void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) thro { SAL_WARN("writerfilter", "exception while updating indexes: " << rEx.Message); } + } + + if ( rEvent.EventName == "OnFocus" && m_bControls) + { // Form design mode is enabled by default in Writer, not in Word. uno::Reference<frame::XModel> xModel(rEvent.Source, uno::UNO_QUERY); diff --git a/writerfilter/source/dmapper/ModelEventListener.hxx b/writerfilter/source/dmapper/ModelEventListener.hxx index 0b5cb46..e10be88 100644 --- a/writerfilter/source/dmapper/ModelEventListener.hxx +++ b/writerfilter/source/dmapper/ModelEventListener.hxx @@ -30,8 +30,10 @@ namespace dmapper{ class WRITERFILTER_DLLPRIVATE ModelEventListener : public cppu::WeakImplHelper1< ::com::sun::star::document::XEventListener > { + bool m_bIndexes; + bool m_bControls; public: - ModelEventListener(); + ModelEventListener(bool bIndexes, bool bControls); ~ModelEventListener(); virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx index 35f4d93..031b70f 100644 --- a/writerfilter/source/dmapper/SdtHelper.cxx +++ b/writerfilter/source/dmapper/SdtHelper.cxx @@ -111,6 +111,7 @@ void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControl uno::Reference<text::XTextContent> xTextContent(xControlShape, uno::UNO_QUERY); m_rDM_Impl.appendTextContent(xTextContent, uno::Sequence< beans::PropertyValue >()); + m_bHasElements = true; } std::vector<OUString>& SdtHelper::getDropDownItems() @@ -128,6 +129,11 @@ boost::optional<sal_Int16>& SdtHelper::getDateFormat() return m_oDateFormat; } +bool SdtHelper::hasElements() +{ + return m_bHasElements; +} + } // namespace dmapper } // namespace writerfilter diff --git a/writerfilter/source/dmapper/SdtHelper.hxx b/writerfilter/source/dmapper/SdtHelper.hxx index d2ce372..814dac0 100644 --- a/writerfilter/source/dmapper/SdtHelper.hxx +++ b/writerfilter/source/dmapper/SdtHelper.hxx @@ -44,6 +44,8 @@ namespace writerfilter { /// Date format, see com/sun/star/awt/UnoControlDateFieldModel.idl boost::optional<sal_Int16> m_oDateFormat; + bool m_bHasElements; + /// Create and append the drawing::XControlShape, containing the various models. void createControlShape(com::sun::star::awt::Size aSize, com::sun::star::uno::Reference<com::sun::star::awt::XControlModel>); public: @@ -53,6 +55,8 @@ namespace writerfilter { std::vector<OUString>& getDropDownItems(); OUStringBuffer& getSdtTexts(); boost::optional<sal_Int16>& getDateFormat(); + /// If createControlShape() was ever called. + bool hasElements(); /// Create drop-down control from w:sdt's w:dropDownList. void createDropDownControl(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits