[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.2' - sw/inc sw/source writerfilter/source
LuboÅ¡ LuÅák
l.lunak at collabora.com
Thu May 29 06:05:22 PDT 2014
sw/inc/IDocumentSettingAccess.hxx | 3 +-
sw/inc/doc.hxx | 1
sw/source/core/doc/doc.cxx | 4 +++
sw/source/core/doc/docnew.cxx | 1
sw/source/core/text/txtfld.cxx | 31 +++++++++++++++++++++++++++
sw/source/ui/uno/SwXDocumentSettings.cxx | 16 +++++++++++++
writerfilter/source/dmapper/DomainMapper.cxx | 3 ++
writerfilter/source/dmapper/PropertyIds.cxx | 1
writerfilter/source/dmapper/PropertyIds.hxx | 1
9 files changed, 59 insertions(+), 2 deletions(-)
New commits:
commit c2ac2ced0d51200a62f7436144f0d89cfcd15eed
Author: LuboÅ¡ LuÅák <l.lunak at collabora.com>
Date: Thu May 29 14:31:20 2014 +0200
handle direct formatting for numbering in .docx (bnc#875717)
Change-Id: I3ed0f926e79f3878c5702c2becae97d99d00e201
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 6e66fd0..4e94a1e 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 7de655f..5588803 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 e1d84f3..d3c74e9 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 5385509..a97e616 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 b1743ba..6f3f6bf 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"
/*************************************************************************
@@ -383,6 +384,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
@@ -471,6 +498,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();
@@ -530,6 +559,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 c10ddfd..8a218a1 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();
}
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 01cec9b..4c5337e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -106,6 +106,9 @@ LoggedStream(dmapper_logger, "DomainMapper"),
m_pImpl->SetDocumentSettingsProperty(
PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_SURROUND_TEXT_WRAP_SMALL ),
uno::makeAny( true ) );
+ m_pImpl->SetDocumentSettingsProperty(
+ PropertyNameSupplier::GetPropertyNameSupplier().GetName( PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING ),
+ uno::makeAny( true ) );
// Don't load the default style definitions to avoid weird mix
m_pImpl->SetDocumentSettingsProperty("StylesNoDefault", uno::makeAny(true));
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 12f28aa..bacbcd3 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -345,6 +345,7 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_PARA_SHADOW_FORMAT: sName = "ParaShadowFormat"; break;
case PROP_FOOTNOTE_LINE_RELATIVE_WIDTH: sName = "FootnoteLineRelativeWidth"; break;
case PROP_HORIZONTAL_MERGE: sName = "HorizontalMerge"; break;
+ case PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING : sName = "ApplyParagraphMarkFormatToNumbering"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 9cdc085..a4e3621 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -316,6 +316,7 @@ enum PropertyIds
,PROP_PARA_TOP_MARGIN_BEFORE_AUTO_SPACING
,PROP_PARA_BOTTOM_MARGIN_AFTER_AUTO_SPACING
,PROP_HORIZONTAL_MERGE
+ ,PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
More information about the Libreoffice-commits
mailing list