diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-10-09 17:13:01 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-10-09 17:15:25 +0200 |
commit | d3a04fdebf65c7381f1087fbd27104a56ba08e78 (patch) | |
tree | be38ee15a13c86a1dab5d79190aedd34d96b6222 /sw | |
parent | d7418f8831acdff907d404c1701870b00e974df6 (diff) |
copy document defaults/properties for separate mailmerge result files
Also remove code duplication (that I'm not even sure why it's there).
Change-Id: I9a20fe0de9b34adbd03155712869bb19f5969f9b
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/doc.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docglos.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmoutputpage.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 30 |
4 files changed, 17 insertions, 30 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index cbc9f0d69f52..c072fd100fc4 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -914,7 +914,7 @@ public: This includes the user defined document properties! */ - void ReplaceDocumentProperties(const SwDoc& rSource); + void ReplaceDocumentProperties(const SwDoc& rSource, bool mailMerge = false); // Query if style (paragraph- / character- / frame- / page-) is used. bool IsUsed( const SwModify& ) const; diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index 390177e43fa7..150783227f05 100644 --- a/sw/source/core/doc/docglos.cxx +++ b/sw/source/core/doc/docglos.cxx @@ -88,7 +88,7 @@ void SwDoc::ReplaceUserDefinedDocumentProperties(const SwDoc& rSource) ReplaceUserDefinedDocumentProperties( xSourceDocProps ); } -void SwDoc::ReplaceDocumentProperties(const SwDoc& rSource) +void SwDoc::ReplaceDocumentProperties(const SwDoc& rSource, bool mailMerge) { uno::Reference<document::XDocumentPropertiesSupplier> xSourceDPS( rSource.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW); @@ -110,6 +110,7 @@ void SwDoc::ReplaceDocumentProperties(const SwDoc& rSource) xDocProps->setDescription(xSourceDocProps->getDescription()); xDocProps->setKeywords(xSourceDocProps->getKeywords()); xDocProps->setLanguage(xSourceDocProps->getLanguage()); + // Note: These below originally weren't copied for mailmerge, but I don't see why not. xDocProps->setModifiedBy(xSourceDocProps->getModifiedBy()); xDocProps->setModificationDate(xSourceDocProps->getModificationDate()); xDocProps->setPrintedBy(xSourceDocProps->getPrintedBy()); @@ -124,6 +125,13 @@ void SwDoc::ReplaceDocumentProperties(const SwDoc& rSource) xDocProps->setEditingCycles(xSourceDocProps->getEditingCycles()); xDocProps->setEditingDuration(xSourceDocProps->getEditingDuration()); + if( mailMerge ) // Note: Not sure this is needed. + { + // Manually set the creation date, otherwise author field isn't filled + // during MM, as it's set when saving the document the first time. + xDocProps->setCreationDate( xSourceDocProps->getModificationDate() ); + } + ReplaceUserDefinedDocumentProperties( xSourceDocProps ); } diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index f1ced0275ccb..ba2aa1e228d5 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -56,6 +56,7 @@ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/sdb/XColumn.hpp> #include <com/sun/star/task/ErrorCodeIOException.hpp> +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <dbmgr.hxx> #include <swunohelper.hxx> #include <osl/mutex.hxx> @@ -66,6 +67,7 @@ #include <dbui.hxx> #include <dbui.hrc> #include <helpid.h> +#include <doc.hxx> #include <sfx2/app.hxx> #include <statstr.hrc> #include <unomid.h> @@ -679,6 +681,9 @@ IMPL_LINK(SwMailMergeOutputPage, SaveOutputHdl_Impl, PushButton*, pButton) aOpt.SetMerge( false ); pTempView->GetDocShell()->LoadStylesFromFile( sTargetTempURL, aOpt, true ); + pTempView->GetDocShell()->GetDoc()->ReplaceCompatabilityOptions( *pTargetView->GetDocShell()->GetDoc()); + pTempView->GetDocShell()->GetDoc()->ReplaceDefaults( *pTargetView->GetDocShell()->GetDoc()); + pTempView->GetDocShell()->GetDoc()->ReplaceDocumentProperties( *pTargetView->GetDocShell()->GetDoc(), true ); pTargetView->GetWrtShell().PastePages(pTempView->GetWrtShell(), (sal_uInt16)rInfo.nStartPageInTarget, (sal_uInt16)rInfo.nEndPageInTarget ); diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 225b3cc0f11e..4d504180d832 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -776,32 +776,6 @@ static void lcl_RemoveSectionLinks( SwWrtShell& rWorkShell ) rWorkShell.SetLabelDoc( false ); } -// based on SwDoc::ReplaceDocumentProperties -static void lcl_CopyDocumentPorperties( - const uno::Reference<document::XDocumentProperties> &xSourceDocProps, - const SfxObjectShell *xTargetDocShell, SwDoc *pTargetDoc) -{ - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - xTargetDocShell->GetModel(), uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentProperties> xTargetDocProps( - xDPS->getDocumentProperties()); - OSL_ENSURE(xTargetDocProps.is(), "DocumentProperties is null"); - - xTargetDocProps->setTitle( xSourceDocProps->getTitle() ); - xTargetDocProps->setSubject( xSourceDocProps->getSubject() ); - xTargetDocProps->setDescription( xSourceDocProps->getDescription() ); - xTargetDocProps->setKeywords( xSourceDocProps->getKeywords() ); - xTargetDocProps->setAuthor( xSourceDocProps->getAuthor() ); - xTargetDocProps->setGenerator( xSourceDocProps->getGenerator() ); - xTargetDocProps->setLanguage( xSourceDocProps->getLanguage() ); - - // Manually set the creation date, otherwise author field isn't filled - // during MM, as it's set when saving the document the first time. - xTargetDocProps->setCreationDate( xSourceDocProps->getModificationDate() ); - - pTargetDoc->ReplaceUserDefinedDocumentProperties( xSourceDocProps ); -} - static void lcl_SaveDoc( SfxObjectShell *xTargetDocShell, const char *name, int no = 0 ) { @@ -989,7 +963,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, // #72821# copy dynamic defaults pTargetShell->GetDoc()->ReplaceDefaults( *pSourceShell->GetDoc()); - lcl_CopyDocumentPorperties( xSourceDocProps, xTargetDocShell, pTargetDoc ); + pTargetShell->GetDoc()->ReplaceDocumentProperties( *pSourceShell->GetDoc()); } // Progress, to prohibit KeyInputs @@ -1088,7 +1062,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, pWorkView->AttrChangedNotify( &rWorkShell );// in order for SelectShell to be called SwDoc* pWorkDoc = rWorkShell.GetDoc(); - lcl_CopyDocumentPorperties( xSourceDocProps, xWorkDocSh, pWorkDoc ); + pWorkDoc->ReplaceDocumentProperties( *pSourceDocSh->GetDoc()); if ( (nMaxDumpDocs < 0) || (nDocNo <= nMaxDumpDocs) ) lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo ); SwDBManager* pOldDBManager = pWorkDoc->GetDBManager(); |