diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-04-28 21:00:23 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2017-05-04 13:19:56 +0200 |
commit | d294c6d749c1f3281df0b384a3793a2ed681e4b4 (patch) | |
tree | 48565a90f69c0cf0c07312e7de86f81e174a7b7a /writerfilter/source | |
parent | AutoText: handle Delete key in the dialog (diff) | |
download | core-d294c6d749c1f3281df0b384a3793a2ed681e4b4.tar.gz core-d294c6d749c1f3281df0b384a3793a2ed681e4b4.zip |
AutoText: Reading multiple entries
+ each entry is placed in a separate section
+ extended model and dmapper to react on docPart mark
Change-Id: I7e5213a09ae7352d1d09369bd0a209b6d4e18e82
Reviewed-on: https://gerrit.libreoffice.org/37107
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'writerfilter/source')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 11 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 5 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.hxx | 10 | ||||
-rw-r--r-- | writerfilter/source/dmapper/LoggedResources.cxx | 26 | ||||
-rw-r--r-- | writerfilter/source/dmapper/LoggedResources.hxx | 4 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/ooxml/OOXMLFastContextHandler.hxx | 2 | ||||
-rw-r--r-- | writerfilter/source/ooxml/model.xml | 5 |
9 files changed, 76 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index f2dfd37e727c..94116020c8c6 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3427,6 +3427,17 @@ void DomainMapper::lcl_info(const std::string & /*info_*/) { } +void DomainMapper::lcl_startGlossaryEntry() +{ + uno::Reference< text::XTextRange > xTextRange = GetCurrentTextRange(); + m_pImpl->setGlossaryEntryStart(xTextRange); +} + +void DomainMapper::lcl_endGlossaryEntry() +{ + m_pImpl->appendGlossaryEntry(); +} + void DomainMapper::handleUnderlineType(const Id nId, const ::std::shared_ptr<PropertyMap>& rContext) { sal_Int16 nUnderline = awt::FontUnderline::NONE; diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx index 4f05118b1190..7a346884d642 100644 --- a/writerfilter/source/dmapper/DomainMapper.hxx +++ b/writerfilter/source/dmapper/DomainMapper.hxx @@ -146,6 +146,8 @@ private: virtual void lcl_substream(Id name, ::writerfilter::Reference<Stream>::Pointer_t ref) override; virtual void lcl_info(const std::string & info) override; + virtual void lcl_startGlossaryEntry() override; + virtual void lcl_endGlossaryEntry() override; // Properties virtual void lcl_attribute(Id Name, Value & val) override; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index a9473ef74c68..8e261740a400 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1536,6 +1536,11 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendTextSectionAfter( return xRet; } +uno::Reference< beans::XPropertySet > DomainMapper_Impl::appendGlossaryEntry() +{ + return appendTextSectionAfter(m_xGlossaryEntryStart); +} + void DomainMapper_Impl::PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType) { m_aHeaderFooterStack.push(HeaderFooterContext(m_bTextInserted)); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 7ec425151ee9..b86938df337f 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -464,6 +464,8 @@ private: std::map<sal_Int32, css::uno::Any> deferredCharacterProperties; SmartTagHandler m_aSmartTagHandler; + css::uno::Reference<css::text::XTextRange> m_xGlossaryEntryStart; + public: css::uno::Reference<css::text::XTextRange> m_xInsertTextRange; private: @@ -557,6 +559,14 @@ public: void appendStarMath( const Value& v ); css::uno::Reference<css::beans::XPropertySet> appendTextSectionAfter(css::uno::Reference<css::text::XTextRange>& xBefore); + /// AutoText import: each entry is placed in the separate section + css::uno::Reference<css::beans::XPropertySet> appendGlossaryEntry(); + /// Remember where entry was started + void setGlossaryEntryStart( css::uno::Reference<css::text::XTextRange>& xStart ) + { + m_xGlossaryEntryStart = xStart; + } + // push the new properties onto the stack and make it the 'current' property map void PushProperties(ContextType eId); void PushStyleProperties(const PropertyMapPtr& pStyleProperties); diff --git a/writerfilter/source/dmapper/LoggedResources.cxx b/writerfilter/source/dmapper/LoggedResources.cxx index 55ade5a41138..33744b9765e7 100644 --- a/writerfilter/source/dmapper/LoggedResources.cxx +++ b/writerfilter/source/dmapper/LoggedResources.cxx @@ -301,6 +301,32 @@ void LoggedStream::info(const std::string & _info) #endif } +void LoggedStream::startGlossaryEntry() +{ +#ifdef DEBUG_WRITERFILTER + mHelper.startElement("startGlossaryEntry"); +#endif + + lcl_startGlossaryEntry(); + +#ifdef DEBUG_WRITERFILTER + LoggedResourcesHelper::endElement("startGlossaryEntry"); +#endif +} + +void LoggedStream::endGlossaryEntry() +{ +#ifdef DEBUG_WRITERFILTER + mHelper.startElement("endGlossaryEntry"); +#endif + + lcl_endGlossaryEntry(); + +#ifdef DEBUG_WRITERFILTER + LoggedResourcesHelper::endElement("endGlossaryEntry"); +#endif +} + // class LoggedProperties LoggedProperties::LoggedProperties( #ifdef DEBUG_WRITERFILTER diff --git a/writerfilter/source/dmapper/LoggedResources.hxx b/writerfilter/source/dmapper/LoggedResources.hxx index 0c466448a85b..c5d59a68a9ec 100644 --- a/writerfilter/source/dmapper/LoggedResources.hxx +++ b/writerfilter/source/dmapper/LoggedResources.hxx @@ -69,6 +69,8 @@ public: void table(Id name, writerfilter::Reference<Table>::Pointer_t ref) override; void substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref) override; void info(const std::string & info) override; + void startGlossaryEntry() override; + void endGlossaryEntry() override; protected: virtual void lcl_startSectionGroup() = 0; @@ -89,6 +91,8 @@ protected: virtual void lcl_table(Id name, writerfilter::Reference<Table>::Pointer_t ref) = 0; virtual void lcl_substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref) = 0; virtual void lcl_info(const std::string & info) = 0; + virtual void lcl_startGlossaryEntry() { } + virtual void lcl_endGlossaryEntry() { } #ifdef DEBUG_WRITERFILTER LoggedResourcesHelper mHelper; diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx index 0715e0ed828f..bb5ff5fa98fb 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx @@ -652,6 +652,18 @@ void OOXMLFastContextHandler::positivePercentage(const OUString& rText) mpStream->positivePercentage(rText); } +void OOXMLFastContextHandler::startGlossaryEntry() +{ + if (isForwardEvents()) + mpStream->startGlossaryEntry(); +} + +void OOXMLFastContextHandler::endGlossaryEntry() +{ + if (isForwardEvents()) + mpStream->endGlossaryEntry(); +} + void OOXMLFastContextHandler::propagateCharacterProperties() { mpParserState->setCharacterProperties(getPropertySet()); diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx index d0df17fcb30d..f986c76029ae 100644 --- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx +++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx @@ -168,6 +168,8 @@ public: void alignH(const OUString & sText); void alignV(const OUString & sText); void positivePercentage(const OUString& rText); + void startGlossaryEntry(); + void endGlossaryEntry(); void startTxbxContent(); void endTxbxContent(); void propagateCharacterProperties(); diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index cfd6d527d4bc..1b9b0933611d 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -19058,7 +19058,10 @@ <resource name="CT_Document" resource="Stream"/> <resource name="CT_GlossaryDocument" resource="Stream"/> <resource name="CT_DocParts" resource="Stream"/> - <resource name="CT_DocPart" resource="Stream"/> + <resource name="CT_DocPart" resource="Stream"> + <action name="start" action="startGlossaryEntry"/> + <action name="end" action="endGlossaryEntry"/> + </resource> <resource name="document" resource="Stream"/> <resource name="glossaryDocument" resource="Stream"/> <resource name="CT_TxbxContent" resource="Stream"> |