[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - 3 commits - sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Wed Jun 5 04:03:27 PDT 2013
sw/qa/extras/ooxmlimport/data/n820509.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 20 ++++++++++++++++++++
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, 47 insertions(+), 7 deletions(-)
New commits:
commit 01508a6172617659d74175d512bb29181a54a336
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jun 5 11:44:10 2013 +0200
bnc#820509 testcase
Change-Id: Iee9909e9c42014ab10ceaa2f8f8e554c25e89157
(cherry picked from commit a9e0ec2b87a99c93b77a210a916b4df44ece454a)
Conflicts:
sw/qa/extras/ooxmlimport/ooxmlimport.cxx
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 8f24b40..bd85ca2 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
@@ -49,6 +50,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>
@@ -121,6 +123,7 @@ public:
void testPageBackground();
void testWatermark();
void testPageBorderShadow();
+ void testN820509();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -194,6 +197,7 @@ void Test::run()
{"page-background.docx", &Test::testPageBackground},
{"watermark.docx", &Test::testWatermark},
{"page-border-shadow.docx", &Test::testPageBorderShadow},
+ {"n820509.docx", &Test::testN820509},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
@@ -1226,6 +1230,22 @@ void Test::testPageBorderShadow()
CPPUNIT_ASSERT_EQUAL(sal_Int16(TWIP_TO_MM100(48/8*20)), aShadow.ShadowWidth);
}
+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 3ab23b633f540f690622a097334b669c85aee89f
Author: Miklos Vajna <vmiklos at 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
(cherry picked from commit 58197c3692df0d0fccb5bc7abddaf6d9667565f6)
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 113f636..dc459bd 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3318,8 +3318,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 73b023c77c73206df7f0373fc046d623f4c8ee6d
Author: Miklos Vajna <vmiklos at 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
(cherry picked from commit 3d6a7cf3eb7aa966601cbc019d1ad5fafdddd21f)
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 48b0cdb..113f636 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -144,11 +144,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();
More information about the Libreoffice-commits
mailing list