summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx24
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx101
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx11
-rw-r--r--writerfilter/source/dmapper/FieldTypes.hxx7
4 files changed, 119 insertions, 24 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 02b234eb5d25..61d32d80655a 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2423,19 +2423,25 @@ void DomainMapper::data(const sal_uInt8* /*buf*/, size_t /*len*/,
void DomainMapper::lcl_startSectionGroup()
{
- m_pImpl->PushProperties(CONTEXT_SECTION);
+ if (!m_pImpl->isInIndexContext())
+ {
+ m_pImpl->PushProperties(CONTEXT_SECTION);
+ }
}
void DomainMapper::lcl_endSectionGroup()
{
- m_pImpl->CheckUnregisteredFrameConversion();
- m_pImpl->ExecuteFrameConversion();
- PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_SECTION);
- SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() );
- OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
- if(pSectionContext)
- pSectionContext->CloseSectionGroup( *m_pImpl );
- m_pImpl->PopProperties(CONTEXT_SECTION);
+ if (!m_pImpl->isInIndexContext())
+ {
+ m_pImpl->CheckUnregisteredFrameConversion();
+ m_pImpl->ExecuteFrameConversion();
+ PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_SECTION);
+ SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() );
+ OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
+ if(pSectionContext)
+ pSectionContext->CloseSectionGroup( *m_pImpl );
+ m_pImpl->PopProperties(CONTEXT_SECTION);
+ }
}
void DomainMapper::lcl_startParagraphGroup()
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index deb4fdd7616b..d67b9eb130e1 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -146,6 +146,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bIsPageBreakDeferred( false ),
m_bStartTOC(false),
m_bStartedTOC(false),
+ m_bStartIndex(false),
m_bTOCPageRef(false),
m_pLastSectionContext( ),
m_pLastCharacterContext(),
@@ -172,6 +173,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_aAnnotationPositions(),
m_xInsertTextRange(xInsertTextRange),
m_bIsNewDoc(bIsNewDoc),
+ m_bIndexMarkerAdded(false),
m_bInTableStyleRunProps(false),
m_pSdtHelper(0),
m_nTableDepth(0),
@@ -1122,7 +1124,7 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP
uno::Sequence< beans::PropertyValue > pValues = pPropertyMap->GetPropertyValues();
sal_Int32 len = pValues.getLength();
- if (m_bStartTOC)
+ if (m_bStartTOC || m_bStartIndex)
for( int i =0; i < len; ++i )
{
if (pValues[i].Name == "CharHidden")
@@ -1133,11 +1135,11 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP
if (m_aTextAppendStack.top().xInsertPosition.is())
{
xTextRange = xTextAppend->insertTextPortion(rString, pValues, m_aTextAppendStack.top().xInsertPosition);
- m_aTextAppendStack.top().xCursor->gotoRange(xTextRange->getEnd(), false);
+ m_aTextAppendStack.top().xCursor->gotoRange(xTextRange->getEnd(), true);
}
else
{
- if (m_bStartTOC)
+ if (m_bStartTOC || m_bStartIndex)
{
m_bStartedTOC = true;
uno::Reference< text::XTextCursor > xTOCTextCursor;
@@ -1145,8 +1147,11 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP
xTOCTextCursor->gotoEnd(false);
if (xTOCTextCursor.is())
{
+ if (m_bStartIndex)
+ xTOCTextCursor->goLeft(1, false);
xTextRange = xTextAppend->insertTextPortion(rString, pValues, xTOCTextCursor);
xTOCTextCursor->gotoRange(xTextRange->getEnd(), true);
+ mxTOCTextCursor = xTOCTextCursor;
}
else
{
@@ -2318,6 +2323,8 @@ if(!bFilled)
{OUString("NUMCHARS"), "CharacterCount", "", FIELD_NUMCHARS},
{OUString("NUMWORDS"), "WordCount", "", FIELD_NUMWORDS},
{OUString("NUMPAGES"), "PageCount", "", FIELD_NUMPAGES},
+ {OUString("INDEX"), "com.sun.star.text.DocumentIndex", "", FIELD_INDEX},
+ {OUString("XE"), "com.sun.star.text.DocumentIndexMark", "", FIELD_XE},
// {OUString(""), "", "", FIELD_},
@@ -2855,7 +2862,29 @@ void DomainMapper_Impl::handleToc
}
}
}
+void DomainMapper_Impl::handleIndex
+ (FieldContextPtr pContext,
+ PropertyNameSupplier& rPropNameSupplier,
+ uno::Reference< uno::XInterface > & /*xFieldInterface*/,
+ uno::Reference< beans::XPropertySet > /*xFieldProperties*/,
+ const OUString & sTOCServiceName)
+{
+ uno::Reference< beans::XPropertySet > xTOC;
+ m_bStartTOC = true;
+ m_bStartIndex = true;
+ if (m_xTextFactory.is())
+ xTOC.set(
+ m_xTextFactory->createInstance(
+ sTOCServiceName),
+ uno::UNO_QUERY_THROW);
+ if (xTOC.is())
+ xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ), uno::makeAny(OUString()));
+ pContext->SetTOC( xTOC );
+
+ uno::Reference< text::XTextContent > xToInsert( xTOC, uno::UNO_QUERY );
+ appendTextContent(xToInsert, uno::Sequence< beans::PropertyValue >() );
+}
/*-------------------------------------------------------------------------
//the field command has to be closed (0x14 appeared)
@@ -2893,6 +2922,8 @@ void DomainMapper_Impl::CloseFieldCommand()
case FIELD_HYPERLINK:
case FIELD_DOCPROPERTY:
case FIELD_TOC:
+ case FIELD_INDEX:
+ case FIELD_XE:
case FIELD_TC:
case FIELD_EQ:
bCreateField = false;
@@ -3374,10 +3405,39 @@ void DomainMapper_Impl::CloseFieldCommand()
break;
case FIELD_USERADDRESS : //todo: user address collects street, city ...
break;
+ case FIELD_INDEX:
+ handleIndex(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties,
+ OUString::createFromAscii(aIt->second.cFieldServiceName));
+ break;
case FIELD_TOC:
handleToc(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties,
OUString::createFromAscii(aIt->second.cFieldServiceName));
break;
+ case FIELD_XE:
+ {
+ uno::Reference< beans::XPropertySet > xTC(
+ m_xTextFactory->createInstance(
+ OUString::createFromAscii(aIt->second.cFieldServiceName)),
+ uno::UNO_QUERY_THROW);
+ OUString sTCText = lcl_ExtractParameter(pContext->GetCommand(), sizeof("XE ") );
+ if( !sTCText.isEmpty())
+ xTC->setPropertyValue("PrimaryKey",
+ uno::makeAny(sTCText));
+ uno::Reference< text::XTextContent > xToInsert( xTC, uno::UNO_QUERY );
+ uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend;
+ if (xTextAppend.is())
+ {
+ uno::Reference< text::XTextCursor > xCrsr = xTextAppend->getText()->createTextCursor();
+
+ uno::Reference< text::XText > xText = xTextAppend->getText();
+ if(xCrsr.is() && xText.is())
+ {
+ xCrsr->gotoEnd(false);
+ xText->insertTextContent(uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW ), xToInsert, sal_False);
+ }
+ }
+ }
+ break;
case FIELD_TC :
{
uno::Reference< beans::XPropertySet > xTC(
@@ -3560,26 +3620,39 @@ void DomainMapper_Impl::PopFieldContext()
uno::Reference< text::XTextContent > xToInsert( pContext->GetTOC(), uno::UNO_QUERY );
if( xToInsert.is() )
{
- m_bStartTOC = false;
- if (m_bStartedTOC)
+ if(xTOCMarkerCursor.is() || m_bStartIndex)
{
- m_aTextAppendStack.pop();
- m_bStartedTOC = false;
+ if (m_bStartIndex)
+ {
+ if (mxTOCTextCursor.is())
+ {
+ mxTOCTextCursor->goLeft(1,true);
+ mxTOCTextCursor->setString(OUString());
+ }
+ xTextAppend->finishParagraph( uno::Sequence< beans::PropertyValue >() );
+ }
+ else
+ {
+ xTOCMarkerCursor->goLeft(1,sal_True);
+ xTOCMarkerCursor->setString(OUString());
+ xTOCMarkerCursor->goLeft(1,sal_True);
+ xTOCMarkerCursor->setString(OUString());
+ }
}
- if(xTOCMarkerCursor.is())
+ if (m_bStartedTOC || m_bStartIndex)
{
- xTOCMarkerCursor->goLeft(1,sal_True);
- xTOCMarkerCursor->setString(OUString());
- xTOCMarkerCursor->goLeft(1,sal_True);
- xTOCMarkerCursor->setString(OUString());
+ m_bStartedTOC = false;
+ m_aTextAppendStack.pop();
}
+ m_bStartTOC = false;
+ m_bStartIndex = false;
}
else
{
xToInsert = uno::Reference< text::XTextContent >(pContext->GetTC(), uno::UNO_QUERY);
- if( !xToInsert.is() && !m_bStartTOC )
+ if( !xToInsert.is() && !m_bStartTOC && !m_bStartIndex )
xToInsert = uno::Reference< text::XTextContent >(pContext->GetTextField(), uno::UNO_QUERY);
- if( xToInsert.is() && !m_bStartTOC)
+ if( xToInsert.is() && !m_bStartTOC && !m_bStartIndex)
{
uno::Sequence<beans::PropertyValue> aValues;
// Character properties of the field show up here the
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index e08fa97d329b..c0a47ad43dd5 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -315,6 +315,7 @@ private:
bool m_bStartTOC;
/// If we got any text that is the pre-rendered result of the TOC field.
bool m_bStartedTOC;
+ bool m_bStartIndex;
bool m_bTOCPageRef;
LineNumberSettings m_aLineNumberSettings;
@@ -379,6 +380,7 @@ private:
bool m_bIsFirstRun;
uno::Reference< text::XTextCursor > xTOCMarkerCursor;
+ uno::Reference< text::XTextCursor > mxTOCTextCursor;
//annotation import
uno::Reference< beans::XPropertySet > m_xAnnotationField;
@@ -400,7 +402,7 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xInsertTextRange;
private:
bool m_bIsNewDoc;
-
+ bool m_bIndexMarkerAdded;
public:
DomainMapper_Impl(
DomainMapper& rDMapper,
@@ -583,6 +585,12 @@ public:
uno::Reference< uno::XInterface > & xFieldInterface,
uno::Reference< beans::XPropertySet > xFieldProperties,
const OUString & sTOCServiceName);
+ void handleIndex
+ (FieldContextPtr pContext,
+ PropertyNameSupplier& rPropNameSupplier,
+ uno::Reference< uno::XInterface > & xFieldInterface,
+ uno::Reference< beans::XPropertySet > xFieldProperties,
+ const OUString & sTOCServiceName);
//the field command has to be closed (0x14 appeared)
void CloseFieldCommand();
//the _current_ fields require a string type result while TOCs accept richt results
@@ -747,6 +755,7 @@ public:
/// ST_PositivePercentage values we received
std::queue<OUString> m_aPositivePercentages;
+ bool isInIndexContext() { return m_bStartIndex;}
};
} //namespace dmapper
} //namespace writerfilter
diff --git a/writerfilter/source/dmapper/FieldTypes.hxx b/writerfilter/source/dmapper/FieldTypes.hxx
index 35effc319273..e61e31e04eea 100644
--- a/writerfilter/source/dmapper/FieldTypes.hxx
+++ b/writerfilter/source/dmapper/FieldTypes.hxx
@@ -287,6 +287,13 @@ enum FieldId
/* document statistic - number of pages
*/
,FIELD_NUMPAGES
+ /* Document alphabetical index
+ */
+ ,FIELD_INDEX
+ /* Document alphabetical index marks
+ */
+ ,FIELD_XE
+
};
}}