diff options
Diffstat (limited to 'sw/source/filter/xml/wrtxml.cxx')
-rw-r--r-- | sw/source/filter/xml/wrtxml.cxx | 84 |
1 files changed, 47 insertions, 37 deletions
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx index 859140d9f950..17bffab2ca10 100644 --- a/sw/source/filter/xml/wrtxml.cxx +++ b/sw/source/filter/xml/wrtxml.cxx @@ -27,7 +27,6 @@ #include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/frame/XModule.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <officecfg/Office/Common.hxx> #include <comphelper/fileformat.h> @@ -35,11 +34,10 @@ #include <comphelper/genericpropertyset.hxx> #include <comphelper/propertysetinfo.hxx> #include <vcl/errinf.hxx> +#include <osl/diagnose.h> #include <sal/log.hxx> -#include <o3tl/any.hxx> #include <svx/xmlgrhlp.hxx> #include <svx/xmleohlp.hxx> -#include <unotools/saveopt.hxx> #include <svl/stritem.hxx> #include <sfx2/frame.hxx> #include <sfx2/docfile.hxx> @@ -67,7 +65,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::container; using namespace ::com::sun::star::document; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; @@ -81,9 +78,27 @@ SwXMLWriter::~SwXMLWriter() { } -ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xStatusIndicator, - const OUString& aDocHierarchicalName ) +ErrCodeMsg SwXMLWriter::Write_(const SfxItemSet* pMediumItemSet) { + uno::Reference<task::XStatusIndicator> xStatusIndicator; + OUString aDocHierarchicalName; + bool bNoEmbDS(false); + + if (pMediumItemSet) + { + const SfxUnoAnyItem* pStatusBarItem = + pMediumItemSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL); + if (pStatusBarItem) + pStatusBarItem->GetValue() >>= xStatusIndicator; + const SfxStringItem* pDocHierarchItem = + pMediumItemSet->GetItem(SID_DOC_HIERARCHICALNAME); + if (pDocHierarchItem) + aDocHierarchicalName = pDocHierarchItem->GetValue(); + const SfxBoolItem* pNoEmbDS = pMediumItemSet->GetItem(SID_NO_EMBEDDED_DS); + if (pNoEmbDS) + bNoEmbDS = pNoEmbDS->GetValue(); + } + // Get service factory uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); @@ -113,7 +128,7 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS // the user. // create XPropertySet with three properties for status indicator - comphelper::PropertyMapEntry const aInfoMap[] = + static comphelper::PropertyMapEntry const aInfoMap[] = { { OUString("ProgressRange"), 0, ::cppu::UnoType<sal_Int32>::get(), @@ -160,7 +175,10 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS beans::PropertyAttribute::MAYBEVOID, 0 }, { OUString("TargetStorage"),0, cppu::UnoType<embed::XStorage>::get(), css::beans::PropertyAttribute::MAYBEVOID, 0 }, - { OUString(), 0, css::uno::Type(), 0, 0 } + // tdf#144532 + { OUString("NoEmbDataSet"), 0, + cppu::UnoType<bool>::get(), + beans::PropertyAttribute::MAYBEVOID, 0 }, }; uno::Reference< beans::XPropertySet > xInfoSet( comphelper::GenericPropertySet_CreateInstance( @@ -168,6 +186,8 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS xInfoSet->setPropertyValue( "TargetStorage", Any( m_xStg ) ); + xInfoSet->setPropertyValue("NoEmbDataSet", Any(bNoEmbDS)); + if (m_bShowProgress) { // set progress range and start status indicator @@ -182,7 +202,7 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS xInfoSet->setPropertyValue("ProgressMax", Any(static_cast < sal_Int32 >( -1 ))); } - xInfoSet->setPropertyValue( "UsePrettyPrinting", makeAny(officecfg::Office::Common::Save::Document::PrettyPrinting::get()) ); + xInfoSet->setPropertyValue( "UsePrettyPrinting", Any(officecfg::Office::Common::Save::Document::PrettyPrinting::get()) ); uno::Reference<lang::XComponent> const xModelComp(m_pDoc->GetDocShell()->GetModel()); uno::Reference<drawing::XDrawPageSupplier> const xDPS(xModelComp, uno::UNO_QUERY); @@ -196,14 +216,14 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS // TODO: ideally this would be stored per-view... SwRootFrame const*const pLayout(m_pDoc->getIDocumentLayoutAccess().GetCurrentLayout()); isShowChanges = pLayout == nullptr || !pLayout->IsHideRedlines(); - xInfoSet->setPropertyValue("ShowChanges", makeAny(isShowChanges)); + xInfoSet->setPropertyValue("ShowChanges", Any(isShowChanges)); // ... and hide redlines for export nRedlineFlags &= ~RedlineFlags::ShowMask; nRedlineFlags |= RedlineFlags::ShowInsert; m_pDoc->getIDocumentRedlineAccess().SetRedlineFlags( nRedlineFlags ); // Set base URI - xInfoSet->setPropertyValue( "BaseURI", makeAny( GetBaseURL() ) ); + xInfoSet->setPropertyValue( "BaseURI", Any( GetBaseURL() ) ); if( SfxObjectCreateMode::EMBEDDED == m_pDoc->GetDocShell()->GetCreateMode() ) { @@ -211,12 +231,12 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS ? aDocHierarchicalName : OUString( "dummyObjectName" ) ); - xInfoSet->setPropertyValue( "StreamRelPath", makeAny( aName ) ); + xInfoSet->setPropertyValue( "StreamRelPath", Any( aName ) ); } if( m_bBlock ) { - xInfoSet->setPropertyValue( "AutoTextMode", makeAny(true) ); + xInfoSet->setPropertyValue( "AutoTextMode", Any(true) ); } // #i69627# @@ -224,7 +244,7 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS if ( bOASIS && docfunc::HasOutlineStyleToBeWrittenAsNormalListStyle( *m_pDoc ) ) { - xInfoSet->setPropertyValue( "OutlineStyleAsNormalListStyle", makeAny( true ) ); + xInfoSet->setPropertyValue( "OutlineStyleAsNormalListStyle", Any( true ) ); } // filter arguments @@ -424,14 +444,14 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS if( bErr ) { if( !sErrFile.isEmpty() ) - return *new StringErrorInfo( ERR_WRITE_ERROR_FILE, sErrFile, + return ErrCodeMsg( ERR_WRITE_ERROR_FILE, sErrFile, DialogMask::ButtonsOk | DialogMask::MessageError ); return ERR_SWG_WRITE_ERROR; } else if( bWarn ) { if( !sWarnFile.isEmpty() ) - return *new StringErrorInfo( WARN_WRITE_ERROR_FILE, sWarnFile, + return ErrCodeMsg( WARN_WRITE_ERROR_FILE, sWarnFile, DialogMask::ButtonsOk | DialogMask::MessageError ); return WARN_SWG_FEATURES_LOST; } @@ -439,28 +459,17 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS return ERRCODE_NONE; } -ErrCode SwXMLWriter::WriteStorage() +ErrCodeMsg SwXMLWriter::WriteStorage() { - return Write_( uno::Reference < task::XStatusIndicator >(), OUString() ); + return Write_(nullptr); } -ErrCode SwXMLWriter::WriteMedium( SfxMedium& aTargetMedium ) +ErrCodeMsg SwXMLWriter::WriteMedium( SfxMedium& aTargetMedium ) { - uno::Reference < task::XStatusIndicator > xStatusIndicator; - OUString aName; - const SfxUnoAnyItem* pStatusBarItem = static_cast<const SfxUnoAnyItem*>( - aTargetMedium.GetItemSet()->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) ); - if ( pStatusBarItem ) - pStatusBarItem->GetValue() >>= xStatusIndicator; - const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>( - aTargetMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) ); - if ( pDocHierarchItem ) - aName = pDocHierarchItem->GetValue(); - - return Write_( xStatusIndicator, aName ); + return Write_(&aTargetMedium.GetItemSet()); } -ErrCode SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed, +ErrCodeMsg SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed, const OUString* pFileName ) { return IsStgWriter() @@ -497,7 +506,7 @@ bool SwXMLWriter::WriteThroughComponent( xSet->setPropertyValue("MediaType", Any(OUString("text/xml")) ); // even plain stream should be encrypted in encrypted documents - xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", makeAny(true) ); + xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", Any(true) ); // set buffer and create outputstream uno::Reference< io::XOutputStream > xOutputStream = xStream->getOutputStream(); @@ -509,7 +518,7 @@ bool SwXMLWriter::WriteThroughComponent( OSL_ENSURE( xInfoSet.is(), "missing property set" ); if( xInfoSet.is() ) { - xInfoSet->setPropertyValue( "StreamName", makeAny( sStreamName ) ); + xInfoSet->setPropertyValue( "StreamName", Any( sStreamName ) ); } // write the stuff @@ -545,8 +554,9 @@ bool SwXMLWriter::WriteThroughComponent( // prepare arguments (prepend doc handler to given arguments) Sequence<Any> aArgs( 1 + rArguments.getLength() ); - aArgs[0] <<= xSaxWriter; - std::copy(rArguments.begin(), rArguments.end(), std::next(aArgs.begin())); + auto pArgs = aArgs.getArray(); + *pArgs <<= xSaxWriter; + std::copy(rArguments.begin(), rArguments.end(), std::next(pArgs)); // get filter component uno::Reference< document::XExporter > xExporter( @@ -567,7 +577,7 @@ bool SwXMLWriter::WriteThroughComponent( } void GetXMLWriter( - [[maybe_unused]] const OUString& /*rName*/, const OUString& rBaseURL, WriterRef& xRet ) + [[maybe_unused]] std::u16string_view /*rName*/, const OUString& rBaseURL, WriterRef& xRet ) { xRet = new SwXMLWriter( rBaseURL ); } |