Kaydet (Commit) 3d6a7cf3 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 6d51f9f9
...@@ -143,11 +143,12 @@ DomainMapper::~DomainMapper() ...@@ -143,11 +143,12 @@ DomainMapper::~DomainMapper()
xEnumeration->nextElement(); xEnumeration->nextElement();
} }
} }
if( nIndexes ) if( nIndexes || m_pImpl->m_pSdtHelper->hasElements())
{ {
//index update has to wait until first view is created //index update has to wait until first view is created
uno::Reference< document::XEventBroadcaster > xBroadcaster(xIndexesSupplier, uno::UNO_QUERY); 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())));
} }
......
...@@ -38,7 +38,9 @@ using namespace ::com::sun::star; ...@@ -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() ...@@ -50,7 +52,7 @@ ModelEventListener::~ModelEventListener()
void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException) void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException)
{ {
if ( rEvent.EventName == "OnFocus" ) if ( rEvent.EventName == "OnFocus" && m_bIndexes)
{ {
try try
{ {
...@@ -101,6 +103,10 @@ void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) thro ...@@ -101,6 +103,10 @@ void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) thro
{ {
SAL_WARN("writerfilter", "exception while updating indexes: " << rEx.Message); 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. // Form design mode is enabled by default in Writer, not in Word.
uno::Reference<frame::XModel> xModel(rEvent.Source, uno::UNO_QUERY); uno::Reference<frame::XModel> xModel(rEvent.Source, uno::UNO_QUERY);
......
...@@ -30,8 +30,10 @@ namespace dmapper{ ...@@ -30,8 +30,10 @@ namespace dmapper{
class WRITERFILTER_DLLPRIVATE ModelEventListener : class WRITERFILTER_DLLPRIVATE ModelEventListener :
public cppu::WeakImplHelper1< ::com::sun::star::document::XEventListener > public cppu::WeakImplHelper1< ::com::sun::star::document::XEventListener >
{ {
bool m_bIndexes;
bool m_bControls;
public: public:
ModelEventListener(); ModelEventListener(bool bIndexes, bool bControls);
~ModelEventListener(); ~ModelEventListener();
virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL notifyEvent( const ::com::sun::star::document::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
......
...@@ -111,6 +111,7 @@ void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControl ...@@ -111,6 +111,7 @@ void SdtHelper::createControlShape(awt::Size aSize, uno::Reference<awt::XControl
uno::Reference<text::XTextContent> xTextContent(xControlShape, uno::UNO_QUERY); uno::Reference<text::XTextContent> xTextContent(xControlShape, uno::UNO_QUERY);
m_rDM_Impl.appendTextContent(xTextContent, uno::Sequence< beans::PropertyValue >()); m_rDM_Impl.appendTextContent(xTextContent, uno::Sequence< beans::PropertyValue >());
m_bHasElements = true;
} }
std::vector<OUString>& SdtHelper::getDropDownItems() std::vector<OUString>& SdtHelper::getDropDownItems()
...@@ -128,6 +129,11 @@ boost::optional<sal_Int16>& SdtHelper::getDateFormat() ...@@ -128,6 +129,11 @@ boost::optional<sal_Int16>& SdtHelper::getDateFormat()
return m_oDateFormat; return m_oDateFormat;
} }
bool SdtHelper::hasElements()
{
return m_bHasElements;
}
} // namespace dmapper } // namespace dmapper
} // namespace writerfilter } // namespace writerfilter
......
...@@ -44,6 +44,8 @@ namespace writerfilter { ...@@ -44,6 +44,8 @@ namespace writerfilter {
/// Date format, see com/sun/star/awt/UnoControlDateFieldModel.idl /// Date format, see com/sun/star/awt/UnoControlDateFieldModel.idl
boost::optional<sal_Int16> m_oDateFormat; boost::optional<sal_Int16> m_oDateFormat;
bool m_bHasElements;
/// Create and append the drawing::XControlShape, containing the various models. /// 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>); void createControlShape(com::sun::star::awt::Size aSize, com::sun::star::uno::Reference<com::sun::star::awt::XControlModel>);
public: public:
...@@ -53,6 +55,8 @@ namespace writerfilter { ...@@ -53,6 +55,8 @@ namespace writerfilter {
std::vector<OUString>& getDropDownItems(); std::vector<OUString>& getDropDownItems();
OUStringBuffer& getSdtTexts(); OUStringBuffer& getSdtTexts();
boost::optional<sal_Int16>& getDateFormat(); boost::optional<sal_Int16>& getDateFormat();
/// If createControlShape() was ever called.
bool hasElements();
/// Create drop-down control from w:sdt's w:dropDownList. /// Create drop-down control from w:sdt's w:dropDownList.
void createDropDownControl(); void createDropDownControl();
......
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