summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2013-05-03 00:32:22 +1000
committerLuboš Luňák <l.lunak@suse.cz>2013-05-27 11:16:58 +0000
commitd414e84c438f0b0dd935d1ba1d351f7af27d49a8 (patch)
treeaedf563527338dce934f8a301e919612daf5650b
parent9201a4829bca821f1691f1749d1917c005b8137e (diff)
Fix style renaming confusion in ww8 filter (solves fdo#63603)
(cherry pick my fix from master 2d3d942683d1cce738eab09b58e4fd693d5e7241) - 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: Icd4f27fb1760f0c1ca068c742c48ebcd71d1eb15 Reviewed-on: https://gerrit.libreoffice.org/4039 Reviewed-by: Luboš Luňák <l.lunak@suse.cz> Tested-by: Luboš Luňák <l.lunak@suse.cz>
-rw-r--r--sw/source/filter/ww8/writerwordglue.cxx2
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx28
2 files changed, 28 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 12e9a1c9a3b6..663e1e17fd53 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -296,11 +296,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 += String::CreateFromInt32(nI++);
}
}
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index d83718145192..b0371ffbefaa 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -526,8 +526,32 @@ void MSWordStyles::OutputStyle( SwFmt* pFmt, sal_uInt16 nPos )
GetStyleData( pFmt, bFmtColl, nBase, nWwNext );
String aName = pFmt->GetName();
- if ( aName.EqualsAscii( "Default" ) )
- aName = rtl::OUString("Normal");
+ // 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,