summaryrefslogtreecommitdiffstats
path: root/sw/source/filter
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/html/htmlatr.cxx40
-rw-r--r--sw/source/filter/html/htmlctxt.cxx3
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx41
-rw-r--r--sw/source/filter/ww8/ww8par.cxx43
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx30
5 files changed, 93 insertions, 64 deletions
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index c880082018..f298f93dc5 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -1524,8 +1524,9 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart,
for (auto it = items.begin(); it != items.end();)
{
- HTMLStartEndPos* pTest = *it;
- sal_Int32 nTestEnd = pTest->GetEnd();
+ auto itTest = it++; // forward early, allow 'continue', and keep a copy for 'erase'
+ HTMLStartEndPos* pTest = *itTest;
+ const sal_Int32 nTestEnd = pTest->GetEnd();
if (nTestEnd <= nStart)
continue;
@@ -1533,28 +1534,25 @@ void HTMLEndPosLst::SplitItem( const SfxPoolItem& rItem, sal_Int32 nStart,
const SfxPoolItem& rTestItem = pTest->GetItem();
// only the corresponding OnTag attributes have to be considered
- if (rTestItem.Which() == nWhich && HTML_ON_VALUE == GetHTMLItemState(rTestItem))
- {
- // if necessary, insert the second part of the split
- // attribute
- if (nTestEnd > nEnd)
- InsertItem(pTest->GetItem(), nEnd, nTestEnd);
+ if (rTestItem.Which() != nWhich || HTML_ON_VALUE != GetHTMLItemState(rTestItem))
+ continue;
- if (nTestStart >= nStart)
- {
- // the Test item only starts after the new end of the
- // attribute. Therefore, it can be completely erased.
- it = items.erase(it);
- std::erase(m_aEndLst[pTest->GetEnd()], pTest);
- delete pTest;
- continue;
- }
+ // if necessary, insert the second part of the split attribute
+ if (nTestEnd > nEnd)
+ InsertItem(rTestItem, nEnd, nTestEnd);
- // the start of the new attribute corresponds to the new
- // end of the attribute
- FixSplittedItem(pTest, nStart);
+ if (nTestStart >= nStart)
+ {
+ // the Test item only starts after the new end of the
+ // attribute. Therefore, it can be completely erased.
+ it = items.erase(itTest);
+ std::erase(m_aEndLst[nTestEnd], pTest);
+ delete pTest;
+ continue;
}
- ++it;
+
+ // the start of the new attribute corresponds to the new end of the attribute
+ FixSplittedItem(pTest, nStart);
}
}
}
diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx
index 80245ba2ea..0e87b83644 100644
--- a/sw/source/filter/html/htmlctxt.cxx
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -656,7 +656,8 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
}
#endif
- for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
+ SfxItemIter aIter2(rItemSet);
+ for (const SfxPoolItem* pItem = aIter2.GetCurItem(); pItem; pItem = aIter2.NextItem())
{
HTMLAttr **ppAttr = nullptr;
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 68437c9529..e33e8708f4 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -2658,33 +2658,36 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
assert(pFieldmark);
- if (pFieldmark->GetFieldname() == ODF_FORMDATE)
+ if (pFieldmark)
{
- if(GetExportFormat() == MSWordExportBase::ExportFormat::DOCX) // supported by DOCX only
+ if (pFieldmark->GetFieldname() == ODF_FORMDATE)
{
- OutputField( nullptr, ww::eFORMDATE, OUString(), FieldFlags::Close );
+ if(GetExportFormat() == MSWordExportBase::ExportFormat::DOCX) // supported by DOCX only
+ {
+ OutputField( nullptr, ww::eFORMDATE, OUString(), FieldFlags::Close );
+ }
}
- }
- else
- {
- ww::eField eFieldId = lcl_getFieldId( pFieldmark );
- if (pFieldmark->GetFieldname() == ODF_UNHANDLED)
+ else
{
- IFieldmark::parameter_map_t::const_iterator it = pFieldmark->GetParameters()->find( ODF_ID_PARAM );
- if ( it != pFieldmark->GetParameters()->end() )
+ ww::eField eFieldId = lcl_getFieldId( pFieldmark );
+ if (pFieldmark->GetFieldname() == ODF_UNHANDLED)
{
- OUString sFieldId;
- it->second >>= sFieldId;
- eFieldId = static_cast<ww::eField>(sFieldId.toInt32());
+ IFieldmark::parameter_map_t::const_iterator it = pFieldmark->GetParameters()->find( ODF_ID_PARAM );
+ if ( it != pFieldmark->GetParameters()->end() )
+ {
+ OUString sFieldId;
+ it->second >>= sFieldId;
+ eFieldId = static_cast<ww::eField>(sFieldId.toInt32());
+ }
}
- }
- OutputField( nullptr, eFieldId, OUString(), FieldFlags::Close );
+ OutputField( nullptr, eFieldId, OUString(), FieldFlags::Close );
- if (pFieldmark->GetFieldname() == ODF_FORMTEXT
- && GetExportFormat() != MSWordExportBase::ExportFormat::DOCX )
- {
- AppendBookmark( pFieldmark->GetName() );
+ if (pFieldmark->GetFieldname() == ODF_FORMTEXT
+ && GetExportFormat() != MSWordExportBase::ExportFormat::DOCX )
+ {
+ AppendBookmark( pFieldmark->GetName() );
+ }
}
}
}
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 10ccaa4878..976a68b88a 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/packages/XPackageEncryption.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <i18nlangtag/languagetag.hxx>
@@ -4808,27 +4809,35 @@ void SwWW8ImplReader::ReadDocVars()
aDocVarStrings, &aDocVarStringIds, &aDocValueStrings);
if (m_bVer67) return;
- uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
- m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
- uno::Reference<document::XDocumentProperties> xDocProps(
- xDPS->getDocumentProperties());
- OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
- uno::Reference<beans::XPropertyContainer> xUserDefinedProps =
- xDocProps->getUserDefinedProperties();
- OSL_ENSURE(xUserDefinedProps.is(), "UserDefinedProperties is null");
-
- for(size_t i=0; i<aDocVarStrings.size(); i++)
+ uno::Reference< text::XTextFieldsSupplier > xFieldsSupplier(m_pDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<css::lang::XMultiServiceFactory> xTextFactory(m_pDocShell->GetModel(), uno::UNO_QUERY);
+ uno::Reference< container::XNameAccess > xFieldMasterAccess = xFieldsSupplier->getTextFieldMasters();
+ for(size_t i = 0; i < aDocVarStrings.size(); i++)
{
const OUString &rName = aDocVarStrings[i];
uno::Any aValue;
- aValue <<= rName;
- try {
- xUserDefinedProps->addProperty( rName,
- beans::PropertyAttribute::REMOVABLE,
- aValue );
- } catch (const uno::Exception &) {
- // ignore
+ if (aDocValueStrings.size() > i)
+ {
+ OUString value = aDocValueStrings[i];
+ value = value.replaceAll("\r\n", "\n");
+ value = value.replaceAll("\r", "\n");
+ aValue <<= value;
+ }
+
+ uno::Reference< beans::XPropertySet > xMaster;
+ OUString sFieldMasterService("com.sun.star.text.FieldMaster.User." + rName);
+
+ // Find or create Field Master
+ if (xFieldMasterAccess->hasByName(sFieldMasterService))
+ {
+ xMaster.set(xFieldMasterAccess->getByName(sFieldMasterService), uno::UNO_QUERY_THROW);
+ }
+ else
+ {
+ xMaster.set(xTextFactory->createInstance("com.sun.star.text.FieldMaster.User"), uno::UNO_QUERY_THROW);
+ xMaster->setPropertyValue("Name", uno::Any(rName));
}
+ xMaster->setPropertyValue("Content", aValue);
}
}
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index c87c33dde0..6750fa21ae 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -58,6 +58,7 @@
#include <IDocumentState.hxx>
#include <flddat.hxx>
#include <docufld.hxx>
+#include <usrfld.hxx>
#include <reffld.hxx>
#include <IMark.hxx>
#include <expfld.hxx>
@@ -1831,12 +1832,29 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
aData = aData.replaceAll("\"", "");
}
- const auto pType(static_cast<SwDocInfoFieldType*>(
- m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo)));
- SwDocInfoField aField(pType, nSub|nReg, aData, GetFieldResult(pF), nFormat);
- if (bDateTime)
- ForceFieldLanguage(aField, nLang);
- m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
+ bool bDone = false;
+ if (DI_CUSTOM == nSub)
+ {
+ const auto pType(static_cast<SwUserFieldType*>(
+ m_rDoc.getIDocumentFieldsAccess().GetFieldType(SwFieldIds::User, aData, false)));
+ if (pType)
+ {
+ SwUserField aField(pType, 0, nFormat);
+ if (bDateTime)
+ ForceFieldLanguage(aField, nLang);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
+ bDone = true;
+ }
+ }
+ if (!bDone)
+ {
+ const auto pType(static_cast<SwDocInfoFieldType*>(
+ m_rDoc.getIDocumentFieldsAccess().GetSysFieldType(SwFieldIds::DocInfo)));
+ SwDocInfoField aField(pType, nSub|nReg, aData, GetFieldResult(pF), nFormat);
+ if (bDateTime)
+ ForceFieldLanguage(aField, nLang);
+ m_rDoc.getIDocumentContentOperations().InsertPoolItem(*m_pPaM, SwFormatField(aField));
+ }
return eF_ResT::OK;
}