summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorC├ędric Bosdonnat <cedric.bosdonnat@free.fr>2013-07-18 15:04:00 +0200
committerFridrich Strba <fridrich@documentfoundation.org>2013-07-22 17:00:45 +0000
commitfdb5bd8e1af6796ab3436aba4fa903c0fdb6c221 (patch)
tree3b9c4c3193afc2a586523372cbe53c094f2400fc
parentf7d410edfa0866bd7759b2b977800d5744d8b544 (diff)
n#825976: handle TOC \h field for illustrations tables in writerfilter
Change-Id: I9ebc91d5f0e706dc1e316e0aa8494af7aec4da4e (cherry picked from commit 43f7bc96c0117a77610bfa5e1edfa870123f56f1) (cherry picked from commit f494d9dfd1c0c40eae7aa69a86c3aa4c45971a29) Reviewed-on: https://gerrit.libreoffice.org/5027 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx102
1 files changed, 63 insertions, 39 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c43747104a72..a1a4d6674b51 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2540,6 +2540,53 @@ void DomainMapper_Impl::handleAuthor
#undef SET_DATE
}
+uno::Sequence< beans::PropertyValues > lcl_createTOXLevelHyperlinks( bool bHyperlinks, OUString sChapterNoSeparator,
+ uno::Sequence< beans::PropertyValues >aLevel,
+ PropertyNameSupplier& rPropNameSupplier )
+{
+ //create a copy of the level and add two new entries - hyperlink start and end
+ bool bChapterNoSeparator = !sChapterNoSeparator.isEmpty();
+ sal_Int32 nAdd = (bHyperlinks && bChapterNoSeparator) ? 4 : 2;
+ uno::Sequence< beans::PropertyValues > aNewLevel( aLevel.getLength() + nAdd);
+ beans::PropertyValues* pNewLevel = aNewLevel.getArray();
+ if( bHyperlinks )
+ {
+ beans::PropertyValues aHyperlink(1);
+ aHyperlink[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
+ aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_START );
+ pNewLevel[0] = aHyperlink;
+ aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_END );
+ pNewLevel[aNewLevel.getLength() -1] = aHyperlink;
+ }
+ if( bChapterNoSeparator )
+ {
+ beans::PropertyValues aChapterNo(2);
+ aChapterNo[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
+ aChapterNo[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_CHAPTER_INFO );
+ aChapterNo[1].Name = rPropNameSupplier.GetName( PROP_CHAPTER_FORMAT );
+ //todo: is ChapterFormat::Number correct?
+ aChapterNo[1].Value <<= (sal_Int16)text::ChapterFormat::NUMBER;
+ pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 4 : 2) ] = aChapterNo;
+
+ beans::PropertyValues aChapterSeparator(2);
+ aChapterSeparator[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
+ aChapterSeparator[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_TEXT );
+ aChapterSeparator[1].Name = rPropNameSupplier.GetName( PROP_TEXT );
+ aChapterSeparator[1].Value <<= sChapterNoSeparator;
+ pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator;
+ }
+ //copy the 'old' entries except the last (page no)
+ for( sal_Int32 nToken = 0; nToken < aLevel.getLength() - 1; ++nToken)
+ {
+ pNewLevel[nToken + 1] = aLevel[nToken];
+ }
+ //copy page no entry (last or last but one depending on bHyperlinks
+ sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3);
+ pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1];
+
+ return aNewLevel;
+}
+
void DomainMapper_Impl::handleToc
(FieldContextPtr pContext,
PropertyNameSupplier& rPropNameSupplier,
@@ -2716,46 +2763,10 @@ void DomainMapper_Impl::handleToc
{
uno::Sequence< beans::PropertyValues > aLevel;
xLevelFormats->getByIndex( nLevel ) >>= aLevel;
- //create a copy of the level and add two new entries - hyperlink start and end
- bool bChapterNoSeparator = !sChapterNoSeparator.isEmpty();
- sal_Int32 nAdd = (bHyperlinks && bChapterNoSeparator) ? 4 : 2;
- uno::Sequence< beans::PropertyValues > aNewLevel( aLevel.getLength() + nAdd);
- beans::PropertyValues* pNewLevel = aNewLevel.getArray();
- if( bHyperlinks )
- {
- beans::PropertyValues aHyperlink(1);
- aHyperlink[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
- aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_START );
- pNewLevel[0] = aHyperlink;
- aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_END );
- pNewLevel[aNewLevel.getLength() -1] = aHyperlink;
- }
- if( bChapterNoSeparator )
- {
- beans::PropertyValues aChapterNo(2);
- aChapterNo[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
- aChapterNo[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_CHAPTER_INFO );
- aChapterNo[1].Name = rPropNameSupplier.GetName( PROP_CHAPTER_FORMAT );
- //todo: is ChapterFormat::Number correct?
- aChapterNo[1].Value <<= (sal_Int16)text::ChapterFormat::NUMBER;
- pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 4 : 2) ] = aChapterNo;
-
- beans::PropertyValues aChapterSeparator(2);
- aChapterSeparator[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE );
- aChapterSeparator[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_TEXT );
- aChapterSeparator[1].Name = rPropNameSupplier.GetName( PROP_TEXT );
- aChapterSeparator[1].Value <<= sChapterNoSeparator;
- pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator;
- }
- //copy the 'old' entries except the last (page no)
- for( sal_Int32 nToken = 0; nToken < aLevel.getLength() - 1; ++nToken)
- {
- pNewLevel[nToken + 1] = aLevel[nToken];
- }
- //copy page no entry (last or last but one depending on bHyperlinks
- sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3);
- pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1];
+ uno::Sequence< beans::PropertyValues > aNewLevel = lcl_createTOXLevelHyperlinks(
+ bHyperlinks, sChapterNoSeparator,
+ aLevel, rPropNameSupplier );
xLevelFormats->replaceByIndex( nLevel, uno::makeAny( aNewLevel ) );
}
}
@@ -2765,6 +2776,19 @@ void DomainMapper_Impl::handleToc
if (!sFigureSequence.isEmpty())
xTOC->setPropertyValue(rPropNameSupplier.GetName(PROP_LABEL_CATEGORY),
uno::makeAny(sFigureSequence));
+
+ if ( bHyperlinks )
+ {
+ uno::Reference< container::XIndexReplace> xLevelFormats;
+ xTOC->getPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL_FORMAT)) >>= xLevelFormats;
+ uno::Sequence< beans::PropertyValues > aLevel;
+ xLevelFormats->getByIndex( 1 ) >>= aLevel;
+
+ uno::Sequence< beans::PropertyValues > aNewLevel = lcl_createTOXLevelHyperlinks(
+ bHyperlinks, sChapterNoSeparator,
+ aLevel, rPropNameSupplier );
+ xLevelFormats->replaceByIndex( 1, uno::makeAny( aNewLevel ) );
+ }
}
pContext->SetTOC( xTOC );
}