summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-06-05 10:29:25 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-06-05 12:00:08 +0200
commit3d6a7cf3eb7aa966601cbc019d1ad5fafdddd21f (patch)
treee6b0dcfcd9edb66b3d48fa7945cf7c57d0259ed6 /writerfilter/source/dmapper
parent6d51f9f948c5bf877ec8a53e3716f00fe5e81a23 (diff)
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
Diffstat (limited to 'writerfilter/source/dmapper')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx5
-rw-r--r--writerfilter/source/dmapper/ModelEventListener.cxx10
-rw-r--r--writerfilter/source/dmapper/ModelEventListener.hxx4
-rw-r--r--writerfilter/source/dmapper/SdtHelper.cxx6
-rw-r--r--writerfilter/source/dmapper/SdtHelper.hxx4
5 files changed, 24 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index f611bda02522..b0bdc589dd0b 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 8513c277b20e..8da32243252f 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 0b5cb46c6bfd..e10be8837aba 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 35f4d934a885..031b70f3cfbe 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 d2ce37220fc4..814dac0745cd 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();