summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter/xml')
-rw-r--r--sw/source/filter/xml/wrtxml.cxx48
-rw-r--r--sw/source/filter/xml/wrtxml.hxx2
-rw-r--r--sw/source/filter/xml/xmlexp.cxx39
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx34
-rw-r--r--sw/source/filter/xml/xmlimp.cxx4
-rw-r--r--sw/source/filter/xml/xmltexti.cxx65
6 files changed, 103 insertions, 89 deletions
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 859140d9f950..a1f9625c6936 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -81,9 +81,27 @@ SwXMLWriter::~SwXMLWriter()
{
}
-ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xStatusIndicator,
- const OUString& aDocHierarchicalName )
+ErrCode SwXMLWriter::Write_(const SfxItemSet* pMediumItemSet)
{
+ uno::Reference<task::XStatusIndicator> xStatusIndicator;
+ OUString aDocHierarchicalName;
+ bool bNoEmbDS(false);
+
+ if (pMediumItemSet)
+ {
+ const SfxUnoAnyItem* pStatusBarItem = static_cast<const SfxUnoAnyItem*>(
+ pMediumItemSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL));
+ if (pStatusBarItem)
+ pStatusBarItem->GetValue() >>= xStatusIndicator;
+ const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
+ 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();
@@ -160,6 +178,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 },
+ // tdf#144532
+ { OUString("NoEmbDataSet"), 0,
+ cppu::UnoType<bool>::get(),
+ beans::PropertyAttribute::MAYBEVOID, 0 },
{ OUString(), 0, css::uno::Type(), 0, 0 }
};
uno::Reference< beans::XPropertySet > xInfoSet(
@@ -168,6 +190,8 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
xInfoSet->setPropertyValue( "TargetStorage", Any( m_xStg ) );
+ xInfoSet->setPropertyValue("NoEmbDataSet", makeAny(bNoEmbDS));
+
if (m_bShowProgress)
{
// set progress range and start status indicator
@@ -441,23 +465,12 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < task::XStatusIndicator >& xS
ErrCode SwXMLWriter::WriteStorage()
{
- return Write_( uno::Reference < task::XStatusIndicator >(), OUString() );
+ return Write_(nullptr);
}
ErrCode 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,
@@ -545,8 +558,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(
diff --git a/sw/source/filter/xml/wrtxml.hxx b/sw/source/filter/xml/wrtxml.hxx
index c82afcc97436..7b9c6fe08302 100644
--- a/sw/source/filter/xml/wrtxml.hxx
+++ b/sw/source/filter/xml/wrtxml.hxx
@@ -40,7 +40,7 @@ namespace com::sun::star {
class SwXMLWriter : public StgWriter
{
- ErrCode Write_( const css::uno::Reference < css::task::XStatusIndicator>&, const OUString& );
+ ErrCode Write_(const SfxItemSet* pMediumItemSet);
using StgWriter::Write;
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx
index 437a1a9c76f6..bcc9729ebbab 100644
--- a/sw/source/filter/xml/xmlexp.cxx
+++ b/sw/source/filter/xml/xmlexp.cxx
@@ -385,12 +385,43 @@ void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps)
void SwXMLExport::GetConfigurationSettings( Sequence < PropertyValue >& rProps)
{
Reference< XMultiServiceFactory > xFac( GetModel(), UNO_QUERY );
- if( xFac.is() )
+ if (!xFac.is())
+ return;
+
+ Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
+ if (!xProps.is())
+ return;
+
+ SvXMLUnitConverter::convertPropertySet( rProps, xProps );
+
+ // tdf#144532 if NoEmbDataSet was set, to indicate not to write an embedded
+ // database for the case of a temporary mail merge preview document, then
+ // also filter out the "EmbeddedDatabaseName" property from the document
+ // settings so that when the temp mailmerge preview document is closed it
+ // doesn't unregister the database of the same name which was registered by
+ // the document this is a copy of
+ Reference<XPropertySet> rInfoSet = getExportInfo();
+
+ if (!rInfoSet.is() || !rInfoSet->getPropertySetInfo()->hasPropertyByName(u"NoEmbDataSet"))
+ return;
+
+ Any aAny = rInfoSet->getPropertyValue(u"NoEmbDataSet");
+ bool bNoEmbDataSet = *o3tl::doAccess<bool>(aAny);
+ if (!bNoEmbDataSet)
+ return;
+
+ Sequence<PropertyValue> aFilteredProps(rProps.getLength());
+ sal_Int32 nFilteredPropLen = 0;
+ PropertyValue *pValue = rProps.getArray();
+ for (sal_Int32 i = 0; i < rProps.getLength(); ++i)
{
- Reference< XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY );
- if( xProps.is() )
- SvXMLUnitConverter::convertPropertySet( rProps, xProps );
+ if (pValue[i].Name == "EmbeddedDatabaseName")
+ continue;
+ aFilteredProps[nFilteredPropLen] = rProps[i];
+ ++nFilteredPropLen;
}
+ aFilteredProps.realloc(nFilteredPropLen);
+ std::swap(rProps, aFilteredProps);
}
sal_Int32 SwXMLExport::GetDocumentSpecificSettings( std::vector< SettingsGroup >& _out_rSettings )
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index 9dffac99c8c2..fe5e2174e7e4 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -384,7 +384,7 @@ public:
class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext
{
OUString m_sMasterPageName;
- std::unique_ptr<SfxItemSet> m_pItemSet;
+ std::optional<SfxItemSet> m_oItemSet;
SwXMLTextStyleContext_Impl *m_pTextStyle;
SvXMLStylesContext &m_rStyles;
@@ -419,7 +419,7 @@ public:
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
// The item set may be empty!
- SfxItemSet *GetItemSet() { return m_pItemSet.get(); }
+ SfxItemSet *GetItemSet() { return m_oItemSet ? &*m_oItemSet : nullptr; }
bool HasMasterPageName() const { return m_bHasMasterPageName; }
@@ -519,7 +519,7 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
sal_Int32 nElement,
const uno::Reference< xml::sax::XFastAttributeList > & xAttrList )
{
- OSL_ENSURE( !m_pItemSet,
+ OSL_ENSURE( !m_oItemSet,
"SwXMLItemSetStyleContext_Impl::CreateItemSetContext: item set exists" );
SvXMLImportContext *pContext = nullptr;
@@ -530,29 +530,29 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
switch( GetFamily() )
{
case XmlStyleFamily::TABLE_TABLE:
- m_pItemSet.reset( new SfxItemSet( rItemPool, aTableSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableSetRange );
break;
case XmlStyleFamily::TABLE_COLUMN:
- m_pItemSet.reset( new SfxItemSet( rItemPool, svl::Items<RES_FRM_SIZE, RES_FRM_SIZE> ) );
+ m_oItemSet.emplace( rItemPool, svl::Items<RES_FRM_SIZE, RES_FRM_SIZE> );
break;
case XmlStyleFamily::TABLE_ROW:
- m_pItemSet.reset( new SfxItemSet( rItemPool, aTableLineSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableLineSetRange );
break;
case XmlStyleFamily::TABLE_CELL:
- m_pItemSet.reset( new SfxItemSet( rItemPool, aTableBoxSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableBoxSetRange );
break;
default:
OSL_ENSURE( false,
"SwXMLItemSetStyleContext_Impl::CreateItemSetContext: unknown family" );
break;
}
- if( m_pItemSet )
+ if( m_oItemSet )
pContext = GetSwImport().CreateTableItemImportContext(
nElement, xAttrList, GetFamily(),
- *m_pItemSet );
+ *m_oItemSet );
if( !pContext )
{
- m_pItemSet.reset();
+ m_oItemSet.reset();
}
return pContext;
@@ -636,15 +636,15 @@ void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
if( !pPageDesc )
return;
- if( !m_pItemSet )
+ if( !m_oItemSet )
{
SfxItemPool& rItemPool = pDoc->GetAttrPool();
- m_pItemSet.reset( new SfxItemSet( rItemPool, aTableSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableSetRange );
}
const SfxPoolItem *pItem;
std::unique_ptr<SwFormatPageDesc> pFormatPageDesc;
- if( SfxItemState::SET == m_pItemSet->GetItemState( RES_PAGEDESC, false,
+ if( SfxItemState::SET == m_oItemSet->GetItemState( RES_PAGEDESC, false,
&pItem ) )
{
if( static_cast<const SwFormatPageDesc *>(pItem)->GetPageDesc() != pPageDesc )
@@ -656,7 +656,7 @@ void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
if( pFormatPageDesc )
{
pFormatPageDesc->RegisterToPageDesc( *pPageDesc );
- m_pItemSet->Put( *pFormatPageDesc );
+ m_oItemSet->Put( *pFormatPageDesc );
}
}
@@ -672,15 +672,15 @@ bool SwXMLItemSetStyleContext_Impl::ResolveDataStyleName()
// if the key is valid, insert Item into ItemSet
if( -1 != nFormat )
{
- if( !m_pItemSet )
+ if( !m_oItemSet )
{
SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
SfxItemPool& rItemPool = pDoc->GetAttrPool();
- m_pItemSet.reset( new SfxItemSet( rItemPool, aTableBoxSetRange ) );
+ m_oItemSet.emplace( rItemPool, aTableBoxSetRange );
}
SwTableBoxNumFormat aNumFormatItem(nFormat);
- m_pItemSet->Put(aNumFormatItem);
+ m_oItemSet->Put(aNumFormatItem);
}
// now resolved
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index eea1ca435720..59f9e6bea81f 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -953,10 +953,10 @@ void SwXMLImport::MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
sal_uLong index = 1;
// the last node of the main document where we have inserted a document
- const SwNodePtr node1 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + 0];
+ SwNode* const node1 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + 0];
// the first node of the inserted document
- SwNodePtr node2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index];
+ SwNode* node2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index];
if (! (node1 && node2
&& (node1->GetNodeType() == node2->GetNodeType())
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index f73ef35be731..d2d4e3e71daf 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -63,6 +63,8 @@
#include <tools/globname.hxx>
#include <tools/UnitConversion.hxx>
+#include <utility>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
@@ -71,33 +73,13 @@ using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::beans;
using namespace xml::sax;
-namespace {
-
-struct XMLServiceMapEntry_Impl
-{
- const char *sFilterService;
- sal_Int32 nFilterServiceLen;
-
- sal_uInt32 n1;
- sal_uInt16 n2, n3;
- sal_uInt8 n4, n5, n6, n7, n8, n9, n10, n11;
-};
-
-}
-
-#define SERVICE_MAP_ENTRY( app, s ) \
- { XML_IMPORT_FILTER_##app, sizeof(XML_IMPORT_FILTER_##app)-1, \
- SO3_##s##_CLASSID }
-
-const XMLServiceMapEntry_Impl aServiceMap[] =
-{
- SERVICE_MAP_ENTRY( WRITER, SW ),
- SERVICE_MAP_ENTRY( CALC, SC ),
- SERVICE_MAP_ENTRY( DRAW, SDRAW ),
- SERVICE_MAP_ENTRY( IMPRESS, SIMPRESS ),
- SERVICE_MAP_ENTRY( CHART, SCH ),
- SERVICE_MAP_ENTRY( MATH, SM ),
- { nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+const std::pair<OUString, SvGUID> aServiceMap[] = {
+ { XML_IMPORT_FILTER_WRITER, { SO3_SW_CLASSID } },
+ { XML_IMPORT_FILTER_CALC, { SO3_SC_CLASSID } },
+ { XML_IMPORT_FILTER_DRAW, { SO3_SDRAW_CLASSID } },
+ { XML_IMPORT_FILTER_IMPRESS, { SO3_SIMPRESS_CLASSID } },
+ { XML_IMPORT_FILTER_CHART, { SO3_SCH_CLASSID } },
+ { XML_IMPORT_FILTER_MATH, { SO3_SM_CLASSID } },
};
static void lcl_putHeightAndWidth ( SfxItemSet &rItemSet,
sal_Int32 nHeight, sal_Int32 nWidth,
@@ -238,8 +220,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
SAL_WARN_IF(!pTextCursor, "sw.uno", "SwXTextCursor missing");
SwDoc *pDoc = SwImport::GetDocFromXMLImport( rImport );
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END> );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
Size aTwipSize( 0, 0 );
tools::Rectangle aVisArea( 0, 0, nWidth, nHeight );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth,
@@ -251,22 +232,14 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
{
bool bInsert = false;
SvGlobalName aClassName;
- const XMLServiceMapEntry_Impl *pEntry = aServiceMap;
- while( pEntry->sFilterService )
+ for (const auto& [sFilterService, rCLASSID] : aServiceMap)
{
- if( aObjName.equalsAsciiL( pEntry->sFilterService,
- pEntry->nFilterServiceLen ) )
+ if (aObjName == sFilterService)
{
- aClassName = SvGlobalName( pEntry->n1, pEntry->n2,
- pEntry->n3, pEntry->n4,
- pEntry->n5, pEntry->n6,
- pEntry->n7, pEntry->n8,
- pEntry->n9, pEntry->n10,
- pEntry->n11 );
+ aClassName = SvGlobalName(rCLASSID);
bInsert = true;
break;
}
- pEntry++;
}
if( bInsert )
@@ -549,8 +522,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
SwDoc *pDoc = SwImport::GetDocFromXMLImport( rImport );
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END> );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
Size aTwipSize( 0, 0 );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth,
&aTwipSize );
@@ -640,8 +612,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertApplet(
OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
SwDoc *pDoc = pTextCursor->GetDoc();
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END> );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
SwApplet_Impl aAppletImpl ( aItemSet );
@@ -685,8 +656,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin(
OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
SwDoc *pDoc = pTextCursor->GetDoc();
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END> );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
// We'll need a (valid) URL, or we need a MIME type. If we don't have
@@ -765,8 +735,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra
OSL_ENSURE( pTextCursor, "SwXTextCursor missing" );
SwDoc *pDoc = pTextCursor->GetDoc();
- SfxItemSet aItemSet( pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN,
- RES_FRMATR_END> );
+ SfxItemSetFixed<RES_FRMATR_BEGIN, RES_FRMATR_END> aItemSet( pDoc->GetAttrPool() );
lcl_putHeightAndWidth( aItemSet, nHeight, nWidth);
ScrollingMode eScrollMode = ScrollingMode::Auto;