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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 15 07:52:29 PDT 2012


 sw/source/filter/rtf/swparrtf.cxx                 |    4 +++-
 writerfilter/inc/dmapper/DomainMapper.hxx         |    3 ++-
 writerfilter/source/dmapper/DomainMapper.cxx      |    5 +++--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   11 +++++++++--
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    8 +++++++-
 writerfilter/source/dmapper/PropertyMap.cxx       |    6 ++++--
 writerfilter/source/filter/RtfFilter.cxx          |    3 ++-
 7 files changed, 30 insertions(+), 10 deletions(-)

New commits:
commit 4f1ba0486241bd239e46b71405662db8e10d9b96
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Mon Oct 15 16:42:15 2012 +0200

    fdo#46669 sw: RTF paste should not change page styles
    
    Change-Id: Ic163a639fae9de838258b3cca9567a29ab875a35

diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index 875beef..24eee1e 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -151,10 +151,12 @@ sal_uLong SwRTFReader::Read( SwDoc &rDoc, const String& /*rBaseURL*/, SwPaM& /*r
     xImporter->setTargetDocument(xDstDoc);
 
     uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
-    uno::Sequence<beans::PropertyValue> aDescriptor(1);
+    uno::Sequence<beans::PropertyValue> aDescriptor(2);
     aDescriptor[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream"));
     uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStrm));
     aDescriptor[0].Value <<= xStream;
+    aDescriptor[1].Name = "IsNewDoc";
+    aDescriptor[1].Value <<= sal_False;
     xFilter->filter(aDescriptor);
 
     return 0;
diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx
index 1d9b2f0..87e28d2 100644
--- a/writerfilter/inc/dmapper/DomainMapper.hxx
+++ b/writerfilter/inc/dmapper/DomainMapper.hxx
@@ -81,7 +81,8 @@ public:
                                 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xInputStream,
                                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xModel,
                                 bool bRepairStorage,
-                                SourceDocumentType eDocumentType);
+                                SourceDocumentType eDocumentType,
+                                bool bIsNewDoc = true);
     virtual ~DomainMapper();
 
     // Stream
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 089ba5e..c71854e 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -86,11 +86,12 @@ DomainMapper::DomainMapper( const uno::Reference< uno::XComponentContext >& xCon
                             uno::Reference< io::XInputStream > xInputStream,
                             uno::Reference< lang::XComponent > xModel,
                             bool bRepairStorage,
-                            SourceDocumentType eDocumentType ) :
+                            SourceDocumentType eDocumentType,
+                            bool bIsNewDoc ) :
 LoggedProperties(dmapper_logger, "DomainMapper"),
 LoggedTable(dmapper_logger, "DomainMapper"),
 LoggedStream(dmapper_logger, "DomainMapper"),
-    m_pImpl( new DomainMapper_Impl( *this, xContext, xModel, eDocumentType )),
+    m_pImpl( new DomainMapper_Impl( *this, xContext, xModel, eDocumentType, bIsNewDoc )),
     mnBackgroundColor(0), mbIsHighlightSet(false)
 {
     // #i24363# tab stops relative to indent
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9349f7f..4ea9983 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -155,7 +155,8 @@ DomainMapper_Impl::DomainMapper_Impl(
             DomainMapper& rDMapper,
             uno::Reference < uno::XComponentContext >  xContext,
             uno::Reference< lang::XComponent >  xModel,
-            SourceDocumentType eDocumentType) :
+            SourceDocumentType eDocumentType,
+            bool bIsNewDoc) :
         m_eDocumentType( eDocumentType ),
         m_rDMapper( rDMapper ),
         m_xTextDocument( xModel, uno::UNO_QUERY ),
@@ -182,7 +183,8 @@ DomainMapper_Impl::DomainMapper_Impl(
         m_bIsLastParaInSection( false ),
         m_bParaSectpr( false ),
         m_bUsingEnhancedFields( false ),
-        m_bSdt(false)
+        m_bSdt(false),
+        m_bIsNewDoc(bIsNewDoc)
 {
     appendTableManager( );
     GetBodyText();
@@ -3797,6 +3799,11 @@ sal_Int32 DomainMapper_Impl::getCurrentNumberingProperty(OUString aProp)
     return nRet;
 }
 
+bool DomainMapper_Impl::IsNewDoc()
+{
+    return m_bIsNewDoc;
+}
+
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 5f722f8..a842093 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -373,12 +373,15 @@ private:
 
     std::map< sal_Int32, com::sun::star::uno::Any > deferredCharacterProperties;
 
+    bool m_bIsNewDoc;
+
 public:
     DomainMapper_Impl(
             DomainMapper& rDMapper,
             uno::Reference < uno::XComponentContext >  xContext,
             uno::Reference< lang::XComponent >  xModel,
-            SourceDocumentType eDocumentType );
+            SourceDocumentType eDocumentType,
+            bool bIsNewDoc );
     DomainMapper_Impl();
     virtual ~DomainMapper_Impl();
 
@@ -654,6 +657,9 @@ public:
 
     /// Get a property of the current numbering style's current level.
     sal_Int32 getCurrentNumberingProperty(OUString aProp);
+
+    /// If we're importing into a new document, or just pasting to an existing one.
+    bool IsNewDoc();
 };
 } //namespace dmapper
 } //namespace writerfilter
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index e1258cc..22f680b 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -970,7 +970,8 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
 
         operator[](PropertyDefinition(PROP_GRID_MODE, false)) = uno::makeAny(nGridMode);
 
-        _ApplyProperties( xFollowPageStyle );
+        if (rDM_Impl.IsNewDoc())
+            _ApplyProperties( xFollowPageStyle );
 
         //todo: creating a "First Page" style depends on HasTitlePage und _fFacingPage_
         if( m_bTitlePage )
@@ -979,7 +980,8 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
             PrepareHeaderFooterProperties( true );
             uno::Reference< beans::XPropertySet > xFirstPageStyle = GetPageStyle(
                                 rDM_Impl.GetPageStyles(), rDM_Impl.GetTextFactory(), true );
-            _ApplyProperties( xFirstPageStyle );
+            if (rDM_Impl.IsNewDoc())
+                _ApplyProperties( xFirstPageStyle );
 
             sal_Int32 nPaperBin = m_nFirstPaperBin >= 0 ? m_nFirstPaperBin : m_nPaperBin >= 0 ? m_nPaperBin : 0;
             if( nPaperBin )
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index 080f8ad..22f7108 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -67,6 +67,7 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
     {
         MediaDescriptor aMediaDesc( aDescriptor );
         bool bRepairStorage = aMediaDesc.getUnpackedValueOrDefault( "RepairPackage", false );
+        bool bIsNewDoc = aMediaDesc.getUnpackedValueOrDefault( "IsNewDoc", true );
 #ifdef DEBUG_IMPORT
         OUString sURL = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
         ::std::string sURLc = OUStringToOString(sURL, RTL_TEXTENCODING_ASCII_US).getStr();
@@ -88,7 +89,7 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri
                 uno::Reference<task::XStatusIndicator>());
 
         writerfilter::Stream::Pointer_t pStream(
-                new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, writerfilter::dmapper::DOCUMENT_RTF));
+                new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, writerfilter::dmapper::DOCUMENT_RTF, bIsNewDoc));
         writerfilter::rtftok::RTFDocument::Pointer_t const pDocument(
                 writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator));
         pDocument->resolve(*pStream);


More information about the Libreoffice-commits mailing list