[Libreoffice-commits] core.git: sw/inc sw/source writerfilter/source

Luboš Luňák l.lunak at collabora.com
Thu May 29 05:35:14 PDT 2014


 sw/inc/IDocumentSettingAccess.hxx             |    3 +-
 sw/source/core/doc/DocumentSettingManager.cxx |    5 ++++
 sw/source/core/inc/DocumentSettingManager.hxx |    1 
 sw/source/core/text/txtfld.cxx                |   31 ++++++++++++++++++++++++++
 sw/source/uibase/uno/SwXDocumentSettings.cxx  |   16 ++++++++++++-
 writerfilter/source/dmapper/DomainMapper.cxx  |    3 ++
 writerfilter/source/dmapper/PropertyIds.cxx   |    1 
 writerfilter/source/dmapper/PropertyIds.hxx   |    1 
 8 files changed, 59 insertions(+), 2 deletions(-)

New commits:
commit df07d6cb9f62c0a2c4b29bd850d4efb4fcd4790b
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/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 66043f5..1f2b377 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 82a47f4..2e8ab4b 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 4b9db82..4f39e52 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 94ad4b5..a9cfec8 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 da9bfcf..3c6b220 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 ac7fc43..66e1773 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 3366071..4106e32 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


More information about the Libreoffice-commits mailing list