diff options
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapper_Impl.cxx')
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 87 |
1 files changed, 80 insertions, 7 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 893d93effb17..a1b112882c9f 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -56,6 +56,7 @@ #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/awt/XControlModel.hpp> #include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/text/ControlCharacter.hpp> #include <oox/mathml/import.hxx> #ifdef DEBUG_DOMAINMAPPER @@ -152,6 +153,8 @@ DomainMapper_Impl::DomainMapper_Impl( m_bIsFirstSection( true ), m_bIsColumnBreakDeferred( false ), m_bIsPageBreakDeferred( false ), + m_bStartTOC(false), + m_bTOCPageRef(false), m_nSymboldata(-1), m_pLastSectionContext( ), m_pLastCharacterContext(), @@ -1224,14 +1227,46 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP { try { + uno::Sequence< beans::PropertyValue > pValues = pPropertyMap->GetPropertyValues(); + sal_Int32 len = pValues.getLength(); + + if (m_bStartTOC) + for( int i =0; i < len; ++i ) + { + if (pValues[i].Name == "CharHidden") + pValues[i].Value = uno::makeAny(sal_False); + } + uno::Reference< text::XTextRange > xTextRange; if (m_aTextAppendStack.top().xInsertPosition.is()) { - xTextRange = xTextAppend->insertTextPortion(rString, pPropertyMap->GetPropertyValues(), m_aTextAppendStack.top().xInsertPosition); + xTextRange = xTextAppend->insertTextPortion(rString, pValues, m_aTextAppendStack.top().xInsertPosition); m_aTextAppendStack.top().xCursor->gotoRange(xTextRange->getEnd(), false); } else - xTextRange = xTextAppend->appendTextPortion(rString, pPropertyMap->GetPropertyValues()); + { + if (m_bStartTOC) + { + uno::Reference< text::XTextCursor > xTOCTextCursor; + xTOCTextCursor = xTextAppend->getEnd()->getText( )->createTextCursor( ); + xTOCTextCursor->gotoEnd(false); + if (xTOCTextCursor.is()) + { + xTextRange = xTextAppend->insertTextPortion(rString, pValues, xTOCTextCursor); + xTOCTextCursor->gotoRange(xTextRange->getEnd(), true); + } + else + { + xTextRange = xTextAppend->appendTextPortion(rString, pValues); + xTOCTextCursor = xTextAppend->createTextCursor(); + xTOCTextCursor->gotoRange(xTextRange->getEnd(), false); + } + m_aTextAppendStack.push(TextAppendContext(xTextAppend, xTOCTextCursor)); + } + else + xTextRange = xTextAppend->appendTextPortion(rString, pValues); + } + CheckRedline( xTextRange ); m_bParaChanged = true; @@ -2776,6 +2811,7 @@ void DomainMapper_Impl::handleToc const OUString & sTOCServiceName) { OUString sValue; + m_bStartTOC = true; bool bTableOfFigures = false; bool bHyperlinks = false; bool bFromOutline = false; @@ -2972,6 +3008,25 @@ void DomainMapper_Impl::handleToc } } pContext->SetTOC( xTOC ); + + + OUString sMarker("Y"); + //insert index + uno::Reference< text::XTextContent > xToInsert( xTOC, 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->insertString(xCrsr, sMarker, sal_False); + xText->insertTextContent(uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW ), xToInsert, sal_False); + xTOCMarkerCursor = xCrsr; + } + } } @@ -3038,6 +3093,11 @@ void DomainMapper_Impl::CloseFieldCommand() default: break; } + if (m_bStartTOC && (aIt->second.eFieldId == FIELD_PAGEREF) ) + { + m_bTOCPageRef = true; + bCreateField = false; + } if( bCreateField || bCreateEnhancedField ) { @@ -3349,7 +3409,7 @@ void DomainMapper_Impl::CloseFieldCommand() break; case FIELD_PAGEREF: case FIELD_REF: - if (xFieldProperties.is()) + if (xFieldProperties.is() && !m_bStartTOC) { bool bPageRef = aIt->second.eFieldId == FIELD_PAGEREF; @@ -3693,15 +3753,22 @@ void DomainMapper_Impl::PopFieldContext() uno::Reference< text::XTextContent > xToInsert( pContext->GetTOC(), uno::UNO_QUERY ); if( xToInsert.is() ) { - xCrsr->gotoEnd( true ); - xToInsert->attach( uno::Reference< text::XTextRange >( xCrsr, uno::UNO_QUERY_THROW )); + m_bStartTOC = false; + m_aTextAppendStack.pop(); + if(xTOCMarkerCursor.is()) + { + xTOCMarkerCursor->goLeft(1,sal_True); + xTOCMarkerCursor->setString(OUString()); + xTOCMarkerCursor->goLeft(1,sal_True); + xTOCMarkerCursor->setString(OUString()); + } } else { xToInsert = uno::Reference< text::XTextContent >(pContext->GetTC(), uno::UNO_QUERY); - if( !xToInsert.is() ) + if( !xToInsert.is() && !m_bStartTOC ) xToInsert = uno::Reference< text::XTextContent >(pContext->GetTextField(), uno::UNO_QUERY); - if( xToInsert.is() ) + if( xToInsert.is() && !m_bStartTOC) { uno::Sequence<beans::PropertyValue> aValues; // Character properties of the field show up here the @@ -3738,6 +3805,12 @@ void DomainMapper_Impl::PopFieldContext() uno::Reference< beans::XPropertySet > xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW ); xCrsrProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_HYPER_LINK_U_R_L), uno:: makeAny(pContext->GetHyperlinkURL())); + + if (m_bStartTOC) { + OUString sDisplayName("Index Link"); + xCrsrProperties->setPropertyValue("VisitedCharStyleName",uno::makeAny(sDisplayName)); + xCrsrProperties->setPropertyValue("UnvisitedCharStyleName",uno::makeAny(sDisplayName)); + } } } } |