[Libreoffice-commits] core.git: sw/source
Luke Deller
luke at deller.id.au
Tue May 7 07:38:31 PDT 2013
sw/source/filter/ww8/writerwordglue.cxx | 2 ++
sw/source/filter/ww8/wrtw8sty.cxx | 26 +++++++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
New commits:
commit 2d3d942683d1cce738eab09b58e4fd693d5e7241
Author: Luke Deller <luke at deller.id.au>
Date: Fri May 3 00:32:22 2013 +1000
Fix style renaming confusion in ww8 filter (solves fdo#63603)
- Mapping LO default style to Word "Normal" style for docx output used a
hard coded style name, so it broke when LO's default style was renamed
in 4.0 (plus it would never have worked for non-English languages)
- This renaming did not cater for nameclashes, leading to fdo#63603
- Similar renaming when importing doc styles did cater for nameclashes,
but had a minor bug in that
Change-Id: Id23f3021c6507b474c16e93abf43ba748606ebc7
Reviewed-on: https://gerrit.libreoffice.org/3743
Reviewed-by: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Tested-by: LuboÅ¡ LuÅák <l.lunak at suse.cz>
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 8ce8bd9..7d4444e 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -300,11 +300,13 @@ namespace myImplHelpers
aName.InsertAscii("WW-" , 0);
sal_Int32 nI = 1;
+ String aBaseName = aName;
while (
0 != (pColl = maHelper.GetStyle(aName)) &&
(nI < SAL_MAX_INT32)
)
{
+ aName = aBaseName;
aName += OUString::number(nI++);
}
}
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 8397093..5e3a2c4 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -527,8 +527,32 @@ void MSWordStyles::OutputStyle( SwFmt* pFmt, sal_uInt16 nPos )
GetStyleData( pFmt, bFmtColl, nBase, nWwNext );
String aName = pFmt->GetName();
- if ( aName.EqualsAscii( "Default" ) )
+ // We want to map LO's default style to Word's "Normal" style.
+ // Word looks for this specific style name when reading docx files.
+ // (It must be the English word regardless of language settings)
+ if ( nPos == 0 ) {
+ assert( pFmt->GetPoolFmtId() == RES_POOLCOLL_STANDARD );
aName = OUString("Normal");
+ } else if (aName.EqualsIgnoreCaseAscii("Normal")) {
+ // If LO has a style named "Normal"(!) rename it to something unique
+ aName.InsertAscii("LO-" , 0);
+ String aBaseName = aName;
+ // Check if we still have a clash, in which case we add a suffix
+ for ( int nSuffix = 0; ; ++nSuffix ) {
+ bool clash=false;
+ for ( int n = 1; n < nUsedSlots; ++n )
+ if ( pFmtA[n] &&
+ pFmtA[n]->GetName().EqualsIgnoreCaseAscii(aName) )
+ {
+ clash = true;
+ break;
+ }
+ if (!clash)
+ break;
+ aName = aBaseName;
+ aName += OUString::number(++nSuffix);
+ }
+ }
m_rExport.AttrOutput().StartStyle( aName, bFmtColl,
nBase, nWwNext, GetWWId( *pFmt ), nPos,
More information about the Libreoffice-commits
mailing list