diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-05-29 14:31:20 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-05-30 11:23:24 +0200 |
commit | 2d89b1a029514935b60fbd3f7f7c5341a329bfc8 (patch) | |
tree | b95544db9c096147700114f47e727881342669bb /sw | |
parent | a04f9501508a6b93d2f5d38a17ff77efd7a8421a (diff) |
handle direct formatting for numbering in .docx (bnc#875717)
Change-Id: I3ed0f926e79f3878c5702c2becae97d99d00e201
(cherry picked from commit c2ac2ced0d51200a62f7436144f0d89cfcd15eed)
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/IDocumentSettingAccess.hxx | 3 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/text/txtfld.cxx | 31 | ||||
-rw-r--r-- | sw/source/ui/uno/SwXDocumentSettings.cxx | 16 |
6 files changed, 54 insertions, 2 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index 6e66fd018d63..4e94a1ec3185 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -92,7 +92,8 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd STYLES_NODEFAULT, FLOATTABLE_NOMARGINS, EMBED_FONTS, - EMBED_SYSTEM_FONTS + EMBED_SYSTEM_FONTS, + APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING }; public: diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 987d0abe7f9c..b872119c6634 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -581,6 +581,7 @@ private: bool mbBackgroundParaOverDrawings; bool mbTabOverMargin; bool mbSurroundTextWrapSmall; + bool mApplyParagraphMarkFormatToNumbering; bool mbLastBrowseMode : 1; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index e1d84f3d4ce9..d3c74e96d6ff 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -206,6 +206,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const case FLOATTABLE_NOMARGINS: return mbFloattableNomargins; case EMBED_FONTS: return mEmbedFonts; case EMBED_SYSTEM_FONTS: return mEmbedSystemFonts; + case APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING: return mApplyParagraphMarkFormatToNumbering; default: OSL_FAIL("Invalid setting id"); } @@ -400,6 +401,9 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value) case EMBED_SYSTEM_FONTS: mEmbedSystemFonts = value; break; + case APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING: + mApplyParagraphMarkFormatToNumbering = value; + break; default: OSL_FAIL("Invalid setting id"); } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 53855093d33b..a97e616c7824 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -313,6 +313,7 @@ SwDoc::SwDoc() mbBackgroundParaOverDrawings(false), mbTabOverMargin(false), mbSurroundTextWrapSmall(false), + mApplyParagraphMarkFormatToNumbering(false), mbLastBrowseMode( false ), mn32DummyCompatabilityOptions1(0), mn32DummyCompatabilityOptions2(0), diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 22058c36b989..35471f413303 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -48,6 +48,7 @@ #include "pagedesc.hxx" #include <pormulti.hxx> #include "fmtmeta.hxx" +#include "fmtautofmt.hxx" /************************************************************************* @@ -382,6 +383,32 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) *************************************************************************/ +// OOXML spec says that w:rPr inside w:pPr specifies formatting for the paragraph mark symbol (i.e. the control +// character than can be configured to be shown). However, in practice MSO also uses it as direct formatting +// for numbering in that paragraph. I don't know if the problem is in the spec or in MSWord. +static void checkApplyParagraphMarkFormatToNumbering( SwFont* pNumFnt, SwTxtFormatInfo& rInf, const IDocumentSettingAccess* pIDSA ) +{ + SwTxtNode* node = rInf.GetTxtFrm()->GetTxtNode(); + if( !pIDSA->get(IDocumentSettingAccess::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING )) + return; + if( SwpHints* hints = node->GetpSwpHints()) + { + for( int i = 0; i < hints->Count(); ++i ) + { + SwTxtAttr* hint = hints->GetTextHint( i ); + // Formatting for the paragraph mark is set to apply only to the (non-existent) extra character + // the at end of the txt node. + if( hint->Which() == RES_TXTATR_AUTOFMT && hint->GetStart() != NULL && hint->GetEnd() != NULL + && *hint->GetStart() == *hint->GetEnd() && *hint->GetStart() == node->Len()) + { + boost::shared_ptr<SfxItemSet> pSet(hint->GetAutoFmt().GetStyleHandle()); + pNumFnt->SetDiffFnt( pSet.get(), pIDSA ); + } + } + } +} + + SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const { if( rInf.IsNumDone() || rInf.GetTxtStart() != nStart @@ -470,6 +497,8 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const if( pFmt ) pNumFnt->SetDiffFnt( pFmt, pIDSA ); + checkApplyParagraphMarkFormatToNumbering( pNumFnt, rInf, pIDSA ); + if ( pFmtFnt ) { const sal_uInt8 nAct = pNumFnt->GetActual(); @@ -529,6 +558,8 @@ SwNumberPortion *SwTxtFormatter::NewNumberPortion( SwTxtFormatInfo &rInf ) const if( pFmt ) pNumFnt->SetDiffFnt( pFmt, pIDSA ); + checkApplyParagraphMarkFormatToNumbering( pNumFnt, rInf, pIDSA ); + // we do not allow a vertical font pNumFnt->SetVertical( pNumFnt->GetOrientation(), pFrm->IsVertical() ); diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx index c10ddfd5812c..8a218a1225dc 100644 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ b/sw/source/ui/uno/SwXDocumentSettings.cxx @@ -123,7 +123,8 @@ enum SwDocumentSettingsPropertyHandles HANDLE_EMBED_FONTS, HANDLE_EMBED_SYSTEM_FONTS, HANDLE_TAB_OVER_MARGIN, - HANDLE_SURROUND_TEXT_WRAP_SMALL + HANDLE_SURROUND_TEXT_WRAP_SMALL, + HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING }; static MasterPropertySetInfo * lcl_createSettingsInfo() @@ -194,6 +195,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo() { RTL_CONSTASCII_STRINGPARAM("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, CPPUTYPE_BOOLEAN, 0, 0}, { RTL_CONSTASCII_STRINGPARAM("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, CPPUTYPE_BOOLEAN, 0, 0}, { RTL_CONSTASCII_STRINGPARAM("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, CPPUTYPE_BOOLEAN, 0, 0}, + { RTL_CONSTASCII_STRINGPARAM("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, CPPUTYPE_BOOLEAN, 0, 0}, /* * As OS said, we don't have a view when we need to set this, so I have to * find another solution before adding them to this property set - MTG @@ -797,6 +799,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf mpDoc->set(IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL, bTmp); } break; + case HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING: + { + bool bTmp = *(sal_Bool*)rValue.getValue(); + mpDoc->set(IDocumentSettingAccess::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, bTmp); + } + break; default: throw UnknownPropertyException(); } @@ -1217,6 +1225,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf rValue.setValue( &bTmp, ::getBooleanCppuType() ); } break; + case HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING: + { + sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ); + rValue.setValue( &bTmp, ::getBooleanCppuType() ); + } + break; default: throw UnknownPropertyException(); } |