From abb13e9c635aac37b56f294110b966be44120f1c Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 25 Oct 2011 15:10:53 -0400 Subject: fdo#41369: Use the 'Default' style as the parent style. Some buggy XLS documents such as those generated by 1C (app used in Russia) don't include built-in style definitions, and the cell formats in those docs are not associated with any style at all. Let's associate them with the 'Default' style in such cases. --- sc/source/filter/excel/xistyle.cxx | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx index 926294009575..f49b469c3066 100644 --- a/sc/source/filter/excel/xistyle.cxx +++ b/sc/source/filter/excel/xistyle.cxx @@ -69,6 +69,7 @@ #include "root.hxx" #include "colrowst.hxx" #include "svl/poolcach.hxx" +#include "rsc/rscsfx.hxx" #include @@ -1297,10 +1298,31 @@ void XclImpXF::ApplyPatternToAttrList( // insert into document ScDocument& rDoc = GetDoc(); - if (IsCellXF() && mpStyleSheet) + if (IsCellXF()) { - // Apply style sheet. Don't clear the direct formats. - rPat.SetStyleSheet(mpStyleSheet, false); + if (mpStyleSheet) + { + // Apply style sheet. Don't clear the direct formats. + rPat.SetStyleSheet(mpStyleSheet, false); + } + else + { + // When the cell format is not associated with any style, use the + // 'Default' style. Some buggy XLS docs generated by apps other + // than Excel (such as 1C) may not have any built-in styles at + // all. + ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool(); + if (pStylePool) + { + ScStyleSheet* pStyleSheet = static_cast( + pStylePool->Find( + ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA)); + + if (pStyleSheet) + rPat.SetStyleSheet(pStyleSheet, false); + } + + } } if (nForceScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND) -- cgit