summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2015-01-23 08:54:08 +0300
committerAndras Timar <andras.timar@collabora.com>2015-01-24 16:54:48 +0100
commit2fd7f3ab66a5dca2adbe491b8f471470229ebe94 (patch)
tree7fd2a856a7c0909922db188d099df4fde1373150
parent6bb208198c2a2d8a0162e67ecfc7efe0ccecc009 (diff)
fdo#68963 recognize __RefHeading__ bookmarks as TOC
LibreOffice recognizes MS Office TOC, but LO files saved as .doc format had no text showing. Now bookmarks using the LO naming convention are also imported as TOC bookmarks. Change-Id: Id2a186437fe4634a8ca85c2324c089f9387e437b Reviewed-on: https://gerrit.libreoffice.org/14124 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/filter/ww1/fltshell.cxx2
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx25
2 files changed, 17 insertions, 10 deletions
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 6fd4c3d434ca..330b2a0c5f00 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -948,7 +948,7 @@ SwFltBookmark::SwFltBookmark( const OUString& rNa, const OUString& rVa,
// otherwise: Src Charset from argument for aName
// Src Charset from filter for aVal ( Text )
- if ( IsTOCBookmark() )
+ if ( IsTOCBookmark() && ! rNa.startsWith(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()) )
{
maName = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix();
maName += rNa;
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index cac63fd0750c..a2b93e13768a 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -101,7 +101,18 @@ namespace
// #120879# - helper method to identify a bookmark name to match the internal TOC bookmark naming convention
bool IsTOCBookmarkName( const ::rtl::OUString& rName )
{
- return rName.startsWith("_Toc");
+ return rName.startsWith("_Toc") || rName.startsWith(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix());
+ }
+
+ ::rtl::OUString EnsureTOCBookmarkName( const ::rtl::OUString& rName )
+ {
+ OUString sTmp = rName;
+ if ( IsTOCBookmarkName ( rName ) )
+ {
+ if ( ! rName.startsWith(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()) )
+ sTmp = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix() + rName;
+ }
+ return sTmp;
}
}
@@ -215,7 +226,7 @@ long SwWW8ImplReader::Read_Book(WW8PLCFManResult*)
const OUString sOrigName = BookmarkToWriter(*pName);
pReffedStck->NewAttr( aStart,
- SwFltBookmark( sOrigName, aVal, pB->GetHandle(), IsTOCBookmarkName( sOrigName ) ));
+ SwFltBookmark( EnsureTOCBookmarkName( sOrigName ), aVal, pB->GetHandle(), IsTOCBookmarkName( sOrigName ) ));
return 0;
}
@@ -2065,8 +2076,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr )
OUString sBookmarkName;
if ( IsTOCBookmarkName( sName ) )
{
- sBookmarkName = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix();
- sBookmarkName += sName;
+ sBookmarkName = EnsureTOCBookmarkName(sName);
// track <sBookmarkName> as referenced TOC bookmark.
pReffedStck->aReferencedTOCBookmarks.insert( sBookmarkName );
}
@@ -2092,8 +2102,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr )
OUString sPageRefBookmarkName;
if ( IsTOCBookmarkName( sName ) )
{
- sPageRefBookmarkName = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix();
- sPageRefBookmarkName += sName;
+ sPageRefBookmarkName = EnsureTOCBookmarkName(sName);
// track <sPageRefBookmarkName> as referenced TOC bookmark.
pReffedStck->aReferencedTOCBookmarks.insert( sPageRefBookmarkName );
}
@@ -3416,9 +3425,7 @@ eF_ResT SwWW8ImplReader::Read_F_Hyperlink( WW8FieldDesc* /*pF*/, OUString& rStr
// #120879# add cross reference bookmark name prefix, if it matches internal TOC bookmark naming convention
if ( IsTOCBookmarkName( sMark ) )
{
- OUString sTmp = IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix();
- sTmp += sMark;
- sMark = sTmp;
+ sMark = EnsureTOCBookmarkName(sMark);
// track <sMark> as referenced TOC bookmark.
pReffedStck->aReferencedTOCBookmarks.insert( sMark );
}