summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapper_Impl.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapper_Impl.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx101
1 files changed, 87 insertions, 14 deletions
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