[Libreoffice-commits] core.git: 3 commits - include/xmloff sw/source xmloff/source

Michael Stahl mstahl at redhat.com
Wed May 15 09:47:53 PDT 2013


 include/xmloff/xmlimp.hxx                      |    1 
 sw/source/core/bastyp/init.cxx                 |    2 -
 sw/source/core/doc/poolfmt.cxx                 |    4 ---
 sw/source/core/unocore/unoframe.cxx            |   16 ------------
 sw/source/filter/html/swhtml.cxx               |    5 +++
 sw/source/filter/ww8/ww8par.cxx                |    4 ---
 sw/source/ui/app/docshini.cxx                  |   11 --------
 xmloff/source/core/xmlimp.cxx                  |   33 +++++++++++++++++++++----
 xmloff/source/draw/XMLGraphicsDefaultStyle.cxx |    8 ++++++
 9 files changed, 43 insertions(+), 41 deletions(-)

New commits:
commit d278cc769e484b0452b1fb6000e213561d8d955d
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 15 18:33:48 2013 +0200

    sw: change pool default of RES_FOLLOW_TEXT_FLOW to "false"
    
    For a new document the default is already effectively "false" due to
    SwDocShell::InitNew() and the ODF and WW8 filters set it explicitly to
    false... which is also the appropriate value for RTF and DOCX.
    
    But only OOoXML and (perhaps) HTML (not sure) want "true" as the
    default.
    
    It is also mysteriously reset to "true" in
    SwDoc::RemoveAllFmtLanguageDependencies() (which is called after loading
    a template) for no apparent reason.
    
    Change-Id: If5ad33c99f97412cb3ad4f9cec32f47825ed6f6b

diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index e69e57f..e6af8f9 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -587,7 +587,7 @@ void _InitCore()
     aAttrTab[ RES_ROW_SPLIT - POOLATTR_BEGIN ] =            new SwFmtRowSplit;
 
     // #i18732#
-    aAttrTab[ RES_FOLLOW_TEXT_FLOW - POOLATTR_BEGIN ] =     new SwFmtFollowTextFlow( sal_True );
+    aAttrTab[ RES_FOLLOW_TEXT_FLOW - POOLATTR_BEGIN ] =     new SwFmtFollowTextFlow(false);
     // collapsing borders #i29550#
     aAttrTab[ RES_COLLAPSING_BORDERS - POOLATTR_BEGIN ] =   new SfxBoolItem( RES_COLLAPSING_BORDERS, sal_False );
     // #i28701#
diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx
index e15e044..f0ee570 100644
--- a/sw/source/core/doc/poolfmt.cxx
+++ b/sw/source/core/doc/poolfmt.cxx
@@ -2468,10 +2468,6 @@ void SwDoc::RemoveAllFmtLanguageDependencies()
         rDesc.GetLeft().SetFmtAttr( aFrameDir );
     }
 
-    // #i18732# - restore static pool default for item
-    // RES_FOLLOW_TEXT_FLOW.
-    GetAttrPool().ResetPoolDefaultItem( RES_FOLLOW_TEXT_FLOW );
-
     //#i16874# AutoKerning as default for new documents
     GetAttrPool().ResetPoolDefaultItem( RES_CHRATR_AUTOKERN );
 }
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index a4c8481..4a5387b 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -73,6 +73,7 @@
 #include <fmtclds.hxx>
 #include <fchrfmt.hxx>
 #include <fmtinfmt.hxx>
+#include <fmtfollowtextflow.hxx>
 #include <docary.hxx>
 #include <docstat.hxx>
 #include <doc.hxx>
@@ -330,6 +331,10 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
         pDoc->SetDefault( aFontHeightCJK );
         SvxFontHeightItem aFontHeightCTL(aFontHeights[2], 100, RES_CHRATR_CTL_FONTSIZE);
         pDoc->SetDefault( aFontHeightCTL );
+
+        // #i18732# - adjust default of option 'FollowTextFlow'
+        // TODO: not sure what the appropriate default for HTML should be?
+        pDoc->SetDefault( SwFmtFollowTextFlow(true) );
     }
 
     // Waehrend des Imports in den HTML-Modus schalten, damit die
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index a987c10..598385a 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -76,8 +76,6 @@
 #include <statstr.hrc>          // ResId fuer Statusleiste
 #include <swerror.h>            // ERR_WW8_...
 #include <swtable.hxx>          // class SwTableLines, ...
-// #i18732#
-#include <fmtfollowtextflow.hxx>
 #include <fchrfmt.hxx>
 #include <charfmt.hxx>
 
@@ -1511,8 +1509,6 @@ void SwWW8ImplReader::ImportDop()
     rDoc.set(IDocumentSettingAccess::TAB_COMPAT, true);
     // #i24363# tab stops relative to indent
     rDoc.set(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT, false);
-    // #i18732# - adjust default of option 'FollowTextFlow'
-    rDoc.SetDefault( SwFmtFollowTextFlow( sal_False ) );
 
     // Import Default-Tabs
     long nDefTabSiz = pWDop->dxaTab;
diff --git a/sw/source/ui/app/docshini.cxx b/sw/source/ui/app/docshini.cxx
index 9cf486c..2dc1dd2 100644
--- a/sw/source/ui/app/docshini.cxx
+++ b/sw/source/ui/app/docshini.cxx
@@ -79,10 +79,6 @@
 #include <wrtsh.hxx>
 #include <swerror.h>
 #include <globals.hrc>
-
-// #i18732#
-#include <fmtfollowtextflow.hxx>
-
 #include <unochart.hxx>
 
 // text grid
@@ -304,13 +300,6 @@ sal_Bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
         FRMDIR_HORI_RIGHT_TOP == GetDefaultFrameDirection(GetAppLanguage()) )
         pDoc->SetDefault( SvxAdjustItem(SVX_ADJUST_RIGHT, RES_PARATR_ADJUST ) );
 
-    // OD 09.10.2003 #i18732# - set dynamic pool default for
-    // item RES_FOLLOW_TEXT_FLOW to sal_False for *new document*.
-    // Thus, redo this change in method <SwDoc::RemoveAllFmtLanguageDependencies()>,
-    // which is called from <SwDocShell::ConvertFrom(..)> in order to restore
-    // the static pool default.
-    pDoc->SetDefault( SwFmtFollowTextFlow( sal_False ) );
-
 // #i29550#
     pDoc->SetDefault( SfxBoolItem( RES_COLLAPSING_BORDERS, sal_True ) );
 // <-- collapsing
diff --git a/xmloff/source/draw/XMLGraphicsDefaultStyle.cxx b/xmloff/source/draw/XMLGraphicsDefaultStyle.cxx
index 598309d..dafadbf 100644
--- a/xmloff/source/draw/XMLGraphicsDefaultStyle.cxx
+++ b/xmloff/source/draw/XMLGraphicsDefaultStyle.cxx
@@ -108,14 +108,12 @@ void XMLGraphicsDefaultStyle::SetDefaults()
     if ( xInfo->hasPropertyByName( sTextWordWrap ) )
         xDefaults->setPropertyValue( sTextWordWrap, Any( bWordWrapDefault ) );
 
-    if (!GetImport().IsOOoXML()
+    if (GetImport().IsOOoXML()
         && xInfo->hasPropertyByName("IsFollowingTextFlow"))
     {
-        // MSO does not support "style:flow-with-text" so "false" is the better
-        // default (which may be overridden by the FillPropertySet below).
-        // Do not do this for OOoXML format: OOo 1.x only supported "true"
-        // so that is the more appropriate default.
-        xDefaults->setPropertyValue("IsFollowingTextFlow", uno::makeAny(false));
+        // OOo 1.x only supported "true" so that is the more appropriate
+        // default for OOoXML format documents.
+        xDefaults->setPropertyValue("IsFollowingTextFlow", uno::makeAny(true));
     }
 
     FillPropertySet( xDefaults );
commit da9bb77e99fede9f7e67b42f1d3ed9b4f235755c
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 15 17:10:00 2013 +0200

    i#119922: reverse engineer 9a37613b5e8f08fae585d54a5745e887eb08f8ce
    
    It is not quite obvious what that commit attempts to do... especially
    since the bugdoc attachment does not actually exercise the code that was
    added in the commit, which changes the handling of the
    "IsFollowingTextFlow" property.
    
    The corresponding ODF attribute is style:flow-with-text, which has been
    added in OOo 2.0.  Investigation revels that MSO's ODF filter  does not
    support this attribute and acts as if it always had value "false".
    
    The code in FillBaseProperties effectively acts as a default if the
    value is not set; the ODF spec does not specify what the default should
    be.  But when an ODF document was written by MSO, "false" makes more
    sense than the previous "true" default.  Except when the document is not
    ODF but OOoXML format, which indicates it's likely written by OOo 1.x
    which did not support the attribute and acts as if it always had value
    "true".
    
    The Writer UNO API implementation is however not the right place for
    format specific handling, so replace that with an addition to the
    function reading the default graphic style that sets the
    "IsFollowingTextFlow" property to false as a default, which should
    have the same effect because all styles inherit from it.
    
    Note: MSO 2010 Word always writes a default graphic style into ODF docs.
    
    This has a side effect for loaded ODF documents: various newly
    inserted objects have the property turned off then.  But it turns out
    this is actually an advantage, since the same behavior already exists
    for _new_ documents (see SwDocShell::InitNew) so it is more consistent
    now.
    
    Change-Id: Iba6444a0515fd583398ff052fc5018254da31c30

diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 2f255e1..d3d5ed5 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -99,8 +99,6 @@
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
 #include <sfx2/printer.hxx>
-#include <sfx2/docfile.hxx>
-#include <sfx2/docfilt.hxx>
 #include <SwStyleNameMapper.hxx>
 #include <editeng/xmlcnitm.hxx>
 #include <poolfmt.hxx>
@@ -559,20 +557,6 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SwDoc* pDoc, SfxItemSet& rToSe
         aFmtFollowTextFlow.PutValue(*pFollowTextFlow, 0);
         rToSet.Put(aFmtFollowTextFlow);
     }
-    else
-    {
-        // #i119922# Set default value for "Follow text flow" to false if a
-        // previous version didn't support "Follow text flow"
-        SfxMedium* pMedium = NULL;
-        const SfxFilter * pFilter = NULL;
-        if ( ( pMedium = pDoc->GetDocShell()->GetMedium() ) &&
-                ( pFilter = pMedium->GetFilter() ) )
-        {
-            bool bOasis = pFilter->GetVersion() > SOFFICE_FILEFORMAT_60;
-            if (bOasis)
-                rToSet.Put( SwFmtFollowTextFlow() );
-        }
-    }
 
     // #i28701# - RES_WRAP_INFLUENCE_ON_OBJPOS
     const ::uno::Any* pWrapInfluenceOnObjPos = 0;
diff --git a/xmloff/source/draw/XMLGraphicsDefaultStyle.cxx b/xmloff/source/draw/XMLGraphicsDefaultStyle.cxx
index 761b070..598309d 100644
--- a/xmloff/source/draw/XMLGraphicsDefaultStyle.cxx
+++ b/xmloff/source/draw/XMLGraphicsDefaultStyle.cxx
@@ -108,6 +108,16 @@ void XMLGraphicsDefaultStyle::SetDefaults()
     if ( xInfo->hasPropertyByName( sTextWordWrap ) )
         xDefaults->setPropertyValue( sTextWordWrap, Any( bWordWrapDefault ) );
 
+    if (!GetImport().IsOOoXML()
+        && xInfo->hasPropertyByName("IsFollowingTextFlow"))
+    {
+        // MSO does not support "style:flow-with-text" so "false" is the better
+        // default (which may be overridden by the FillPropertySet below).
+        // Do not do this for OOoXML format: OOo 1.x only supported "true"
+        // so that is the more appropriate default.
+        xDefaults->setPropertyValue("IsFollowingTextFlow", uno::makeAny(false));
+    }
+
     FillPropertySet( xDefaults );
 }
 
commit 3905bd92b038374d22e4ff9f74480decb116d727
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed May 15 17:09:16 2013 +0200

    factor out SvXMLImport::IsOOoXML()
    
    Change-Id: I9ccfe565bde1112f9f3cb8c666e901bf121862dc

diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 750f567..d8a72d5 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -338,6 +338,7 @@ public:
     bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
 
     OUString GetODFVersion() const;
+    bool IsOOoXML() const; // legacy non-ODF format?
 
     /**
      * Record an error condition that occurred during import. The
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 1b08933..d76eefe 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -270,6 +270,8 @@ public:
 
     OUString aODFVersion;
 
+    bool mbIsOOoXML;
+
     // Boolean, indicating that position attributes
     // of shapes are given in horizontal left-to-right layout. This is the case
     // for the OpenOffice.org file format. (#i28749#)
@@ -289,7 +291,7 @@ public:
         , hMathFontConv( 0 )
         , mbOwnGraphicResolver( false )
         , mbOwnEmbeddedResolver( false )
-        , mStreamName()
+        , mbIsOOoXML(false)
         // Convert drawing object positions from OOo file format to OASIS (#i28749#)
         , mbShapePositionInHoriL2R( sal_False )
         , mbTextDocInOOoFileFormat( sal_False )
@@ -831,7 +833,25 @@ void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XCompo
     mxModel = uno::Reference< frame::XModel >::query( xDoc );
     if( !mxModel.is() )
         throw lang::IllegalArgumentException();
-    if (mxModel.is() && !mxEventListener.is())
+
+    try
+    {
+        uno::Reference<document::XStorageBasedDocument> const xSBDoc(mxModel,
+                uno::UNO_QUERY_THROW);
+        uno::Reference<embed::XStorage> const xStor(
+                xSBDoc->getDocumentStorage());
+        if (xStor.is())
+        {
+            mpImpl->mbIsOOoXML =
+                ::comphelper::OStorageHelper::GetXStorageFormat(xStor)
+                   < SOFFICE_FILEFORMAT_8;
+        }
+    }
+    catch (uno::Exception const& e)
+    {
+        SAL_WARN("xmloff.core", "exception caught: " << e.Message);
+    }
+    if (!mxEventListener.is())
     {
         mxEventListener.set(new SvXMLImportEventListener(this));
         mxModel->addEventListener(mxEventListener);
@@ -1577,9 +1597,7 @@ sal_Bool SvXMLImport::IsODFVersionConsistent( const OUString& aODFVersion )
             uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW );
 
             // the check should be done only for OASIS format
-            OUString aMediaType;
-            xStorProps->getPropertyValue( "MediaType" ) >>= aMediaType;
-            if ( ::comphelper::OStorageHelper::GetXStorageFormat( xStor ) >= SOFFICE_FILEFORMAT_8 )
+            if (!IsOOoXML())
             {
                 sal_Bool bRepairPackage = sal_False;
                 try
@@ -1846,6 +1864,11 @@ OUString SvXMLImport::GetODFVersion() const
     return mpImpl->aODFVersion;
 }
 
+bool SvXMLImport::IsOOoXML() const
+{
+    return mpImpl->mbIsOOoXML;
+}
+
 // xml:id for RDF metadata
 void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
     OUString const & i_rXmlId)


More information about the Libreoffice-commits mailing list