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>
This commit is contained in:
parent
680e723533
commit
0d50845c42
11 changed files with 88 additions and 20 deletions
|
@ -87,16 +87,8 @@ bool SwDOCXReader::ReadGlossaries( SwTextBlocks& rBlocks, bool /* bSaveRelFiles
|
|||
aDescriptor[1].Name = "ReadGlossaries";
|
||||
aDescriptor[1].Value <<= true;
|
||||
|
||||
try
|
||||
{
|
||||
xFilter->filter( aDescriptor );
|
||||
}
|
||||
catch( uno::Exception const& e )
|
||||
{
|
||||
SAL_WARN("sw.docx", "SwDOCXReader::ReadGlossaries(): exception: " << e.Message);
|
||||
}
|
||||
|
||||
return MakeEntries( static_cast<SwDocShell*>( &xDocSh )->GetDoc(), rBlocks );
|
||||
if( xFilter->filter( aDescriptor ) )
|
||||
return MakeEntries( static_cast<SwDocShell*>( &xDocSh )->GetDoc(), rBlocks );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -110,7 +102,7 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
|
|||
bool bRet = false;
|
||||
|
||||
SwNodeIndex aDocEnd( pD->GetNodes().GetEndOfContent() );
|
||||
SwNodeIndex aStart( *aDocEnd.GetNode().StartOfSectionNode() );
|
||||
SwNodeIndex aStart( *aDocEnd.GetNode().StartOfSectionNode(), 1 );
|
||||
|
||||
if( aStart < aDocEnd && ( aDocEnd.GetIndex() - aStart.GetIndex() > 2 ) )
|
||||
{
|
||||
|
@ -144,6 +136,7 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
|
|||
}
|
||||
aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
|
||||
|
||||
// Now we have the right selection for one entry
|
||||
rBlocks.ClearDoc();
|
||||
|
||||
// TODO: correct entry name
|
||||
|
@ -174,15 +167,9 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks &rBlocks )
|
|||
rBlocks.PutDoc();
|
||||
}
|
||||
|
||||
if( aStart.GetNodes().Count() <= aStart.GetNode().GetIndex() )
|
||||
aStart = aStart.GetNode().EndOfSectionIndex() + 1;
|
||||
else
|
||||
break;
|
||||
|
||||
aStart = aStart.GetNode().EndOfSectionIndex() + 1;
|
||||
++nGlosEntry;
|
||||
|
||||
} while( aStart < aDocEnd );
|
||||
|
||||
} while( aStart < aDocEnd && aStart.GetNode().IsStartNode() );
|
||||
bRet = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -292,6 +292,12 @@ public:
|
|||
*/
|
||||
virtual void info(const std::string & info) = 0;
|
||||
|
||||
/// Receives start mark for glossary document entry.
|
||||
virtual void startGlossaryEntry() = 0;
|
||||
|
||||
/// Receives end mark for glossary document entry.
|
||||
virtual void endGlossaryEntry() = 0;
|
||||
|
||||
protected:
|
||||
~Stream() {}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1559,6 +1559,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));
|
||||
|
|
|
@ -463,6 +463,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:
|
||||
|
@ -556,6 +558,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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -641,6 +641,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());
|
||||
|
|
|
@ -163,6 +163,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();
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue