summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-05-29 14:31:20 +0200
committerLuboš Luňák <l.lunak@collabora.com>2014-05-29 14:34:50 +0200
commitdf07d6cb9f62c0a2c4b29bd850d4efb4fcd4790b (patch)
tree76d6acc673479866a71f64c1e89756b589c689b4
parentee0d7d4c52fe93ef2ac73d403f61b642f1ae2716 (diff)
handle direct formatting for numbering in .docx (bnc#875717)
Change-Id: I3ed0f926e79f3878c5702c2becae97d99d00e201
-rw-r--r--sw/inc/IDocumentSettingAccess.hxx3
-rw-r--r--sw/source/core/doc/DocumentSettingManager.cxx5
-rw-r--r--sw/source/core/inc/DocumentSettingManager.hxx1
-rw-r--r--sw/source/core/text/txtfld.cxx31
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.cxx16
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx3
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx1
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
8 files changed, 59 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/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 66043f571543..1f2b3775a1d6 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -75,6 +75,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
mbBackgroundParaOverDrawings(false),
mbTabOverMargin(false),
mbSurroundTextWrapSmall(false),
+ mApplyParagraphMarkFormatToNumbering(false),
mbLastBrowseMode( false )
// COMPATIBILITY FLAGS END
@@ -162,6 +163,7 @@ bool sw::DocumentSettingManager::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");
}
@@ -357,6 +359,9 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
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/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index 82a47f41a1fe..2e8ab4bdf3a3 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -85,6 +85,7 @@ class DocumentSettingManager :
bool mbBackgroundParaOverDrawings;
bool mbTabOverMargin;
bool mbSurroundTextWrapSmall;
+ bool mApplyParagraphMarkFormatToNumbering;
bool mbLastBrowseMode : 1;
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 4b9db82590f2..4f39e5269ae4 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -50,6 +50,7 @@
#include "fmtmeta.hxx"
#include "reffld.hxx"
#include "flddat.hxx"
+#include "fmtautofmt.hxx"
static bool lcl_IsInBody( SwFrm *pFrm )
{
@@ -401,6 +402,32 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf )
return pRet;
}
+// 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
@@ -487,6 +514,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();
@@ -544,6 +573,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/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 94ad4b52bdab..a9cfec80d3b3 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -122,7 +122,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()
@@ -193,6 +194,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
{ OUString("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, cppu::UnoType<bool>::get(), 0, 0},
{ OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0, 0},
{ OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType<bool>::get(), 0, 0},
+ { OUString("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, cppu::UnoType<bool>::get(), 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
@@ -793,6 +795,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();
}
@@ -1216,6 +1224,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 da9bfcf1dab6..3c6b220ef7dc 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -108,6 +108,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 ac7fc4364c32..66e1773e6e0d 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -391,6 +391,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_INDEX_ENTRY_TYPE : sName = "IndexEntryType"; break;
case PROP_CELL_INTEROP_GRAB_BAG : sName = "CellInteropGrabBag"; break;
case PROP_TABLE_INTEROP_GRAB_BAG : sName = "TableInteropGrabBag"; 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 3366071c6ce8..4106e32e5ee7 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -363,6 +363,7 @@ enum PropertyIds
,PROP_CELL_INTEROP_GRAB_BAG
,PROP_TABLE_INTEROP_GRAB_BAG
,PROP_INDEX_ENTRY_TYPE
+ ,PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier