[Libreoffice-commits] core.git: 6 commits - sw/inc sw/source
Michael Stahl
mstahl at redhat.com
Wed Jun 12 02:36:20 PDT 2013
sw/inc/fldbas.hxx | 12
sw/inc/fmtfld.hxx | 19
sw/source/core/inc/unofield.hxx | 396 +++--
sw/source/core/unocore/unocoll.cxx | 9
sw/source/core/unocore/unocrsrhelper.cxx | 7
sw/source/core/unocore/unofield.cxx | 2159 ++++++++++++++++---------------
sw/source/core/unocore/unoportenum.cxx | 6
7 files changed, 1436 insertions(+), 1172 deletions(-)
New commits:
commit b742188982e76ed6d0c7d8de6275a18d8103b395
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Jun 12 00:18:34 2013 +0200
SwXTextField: convert some UniString
Change-Id: I17bdcdfbba8fab1ea0f3b5bf6e68d6703bf5e87b
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 28b8a11..b4a5de0 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -402,12 +402,12 @@ public:
sal_uInt16 m_nResTypeId;
- String m_sParam1; // Content / Database / NumberingSeparator
- String m_sParam2; // - /DataTablename
- String m_sParam3; // - /DataFieldName
- String m_sParam4;
- String m_sParam5; // - /DataBaseURL
- String m_sParam6; // - /DataBaseResource
+ OUString m_sParam1; // Content / Database / NumberingSeparator
+ OUString m_sParam2; // - /DataTablename
+ OUString m_sParam3; // - /DataFieldName
+ OUString m_sParam4;
+ OUString m_sParam5; // - /DataBaseURL
+ OUString m_sParam6; // - /DataBaseResource
double m_fParam1; // Value / -
sal_Int8 m_nParam1; // ChapterNumberingLevel
sal_Bool m_bParam1; // IsExpression
@@ -644,8 +644,8 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
case RES_SETEXPFLD :
{
SwSetExpFieldType aType(m_pImpl->m_pDoc, sTypeName);
- if (m_pImpl->m_sParam1.Len())
- aType.SetDelimiter(OUString(m_pImpl->m_sParam1.GetChar(0)));
+ if (!m_pImpl->m_sParam1.isEmpty())
+ aType.SetDelimiter(OUString(m_pImpl->m_sParam1[0]));
if (m_pImpl->m_nParam1 > -1 && m_pImpl->m_nParam1 < MAXLEVEL)
aType.SetOutlineLvl(m_pImpl->m_nParam1);
pType2 = m_pImpl->m_pDoc->InsertFldType(aType);
@@ -653,7 +653,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
break;
case RES_DBFLD :
{
- ::GetString( rValue, m_pImpl->m_sParam3 );
+ rValue >>= m_pImpl->m_sParam3;
pType = GetFldType();
}
break;
@@ -671,7 +671,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
{
case RES_USERFLD:
if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CONTENT)))
- ::GetString( rValue, m_pImpl->m_sParam1 );
+ rValue >>= m_pImpl->m_sParam1;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_VALUE )))
{
if(rValue.getValueType() != ::getCppuType(static_cast<const double*>(0)))
@@ -688,25 +688,27 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
break;
case RES_DBFLD:
if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME)))
- ::GetString( rValue, m_pImpl->m_sParam1 );
+ rValue >>= m_pImpl->m_sParam1;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_TABLE_NAME)))
- ::GetString( rValue, m_pImpl->m_sParam2 );
+ rValue >>= m_pImpl->m_sParam2;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COLUMN_NAME)))
- ::GetString( rValue, m_pImpl->m_sParam3 );
+ rValue >>= m_pImpl->m_sParam3;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COMMAND_TYPE)))
rValue >>= m_pImpl->m_nParam2;
if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL)))
- ::GetString( rValue, m_pImpl->m_sParam5 );
+ rValue >>= m_pImpl->m_sParam5;
- if ( (m_pImpl->m_sParam1.Len() || m_pImpl->m_sParam5.Len())
- && m_pImpl->m_sParam2.Len() && m_pImpl->m_sParam3.Len())
+ if ( ( !m_pImpl->m_sParam1.isEmpty()
+ || !m_pImpl->m_sParam5.isEmpty())
+ && !m_pImpl->m_sParam2.isEmpty()
+ && !m_pImpl->m_sParam3.isEmpty())
{
GetFldType();
}
break;
case RES_SETEXPFLD:
if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NUMBERING_SEPARATOR)))
- ::GetString( rValue, m_pImpl->m_sParam1 );
+ rValue >>= m_pImpl->m_sParam1;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAPTER_NUMBERING_LEVEL)))
rValue >>= m_pImpl->m_nParam1;
break;
@@ -718,14 +720,29 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_AUTOMATIC_UPDATE)) ? 3 : USHRT_MAX;
if(nPart < 3 )
{
- String sTmp;
- if (!m_pImpl->m_sParam1.Len())
+ if (m_pImpl->m_sParam1.isEmpty())
{
- (m_pImpl->m_sParam1 = sfx2::cTokenSeparator)
- += sfx2::cTokenSeparator;
+ m_pImpl->m_sParam1 = OUString(sfx2::cTokenSeparator)
+ + OUString(sfx2::cTokenSeparator);
}
- m_pImpl->m_sParam1.SetToken( nPart, sfx2::cTokenSeparator,
- ::GetString( rValue, sTmp ));
+ OUString sTmp;
+ rValue >>= sTmp;
+ sal_Int32 nIndex(0);
+ sal_Int32 nStart(0);
+ while (nIndex < m_pImpl->m_sParam1.getLength())
+ {
+ if (m_pImpl->m_sParam1[nIndex] == sfx2::cTokenSeparator)
+ {
+ if (0 == nPart)
+ break;
+ nStart = nIndex + 1;
+ --nPart;
+ }
+ ++nIndex;
+ }
+ assert(0 == nPart);
+ m_pImpl->m_sParam1 = m_pImpl->m_sParam1.replaceAt(
+ nStart, nIndex - nStart, sTmp);
}
else if(3 == nPart)
{
@@ -748,10 +765,10 @@ SwFieldType* SwXFieldMaster::GetFldType(bool const bDontCreate) const
// set DataSource
svx::ODataAccessDescriptor aAcc;
- if (m_pImpl->m_sParam1.Len() > 0)
- aAcc[svx::daDataSource] <<= OUString(m_pImpl->m_sParam1); // DataBaseName
- else if (m_pImpl->m_sParam5.Len() > 0)
- aAcc[svx::daDatabaseLocation] <<= OUString(m_pImpl->m_sParam5); // DataBaseURL
+ if (!m_pImpl->m_sParam1.isEmpty())
+ aAcc[svx::daDataSource] <<= m_pImpl->m_sParam1; // DataBaseName
+ else if (!m_pImpl->m_sParam5.isEmpty())
+ aAcc[svx::daDatabaseLocation] <<= m_pImpl->m_sParam5; // DataBaseURL
aData.sDataSource = aAcc.getDataSource();
aData.sCommand = m_pImpl->m_sParam2;
@@ -866,13 +883,11 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
}
else
{
- const String* pStr = 0;
- String sStr;
switch (m_pImpl->m_nResTypeId)
{
case RES_USERFLD:
if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CONTENT)) )
- pStr = &m_pImpl->m_sParam1;
+ aRet <<= m_pImpl->m_sParam1;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_VALUE )))
aRet <<= m_pImpl->m_fParam1;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_EXPRESSION )))
@@ -882,24 +897,23 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME)) ||
rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL)))
{
- pStr = 0; // only one of this properties will return
- // a non-empty string.
+ // only one of these properties returns a non-empty string.
INetURLObject aObj;
aObj.SetURL(m_pImpl->m_sParam5); // SetSmartURL
bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
if (bIsURL && rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_URL)))
- pStr = &m_pImpl->m_sParam5; // DataBaseURL
+ aRet <<= m_pImpl->m_sParam5; // DataBaseURL
else if ( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_BASE_NAME)))
- pStr = &m_pImpl->m_sParam1; // DataBaseName
+ aRet <<= m_pImpl->m_sParam1; // DataBaseName
}
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_TABLE_NAME)))
- pStr = &m_pImpl->m_sParam2;
+ aRet <<= m_pImpl->m_sParam2;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DATA_COLUMN_NAME)))
- pStr = &m_pImpl->m_sParam3;
+ aRet <<= m_pImpl->m_sParam3;
break;
case RES_SETEXPFLD:
if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_NUMBERING_SEPARATOR)))
- pStr = &m_pImpl->m_sParam1;
+ aRet <<= m_pImpl->m_sParam1;
else if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAPTER_NUMBERING_LEVEL)))
aRet <<= m_pImpl->m_nParam1;
break;
@@ -910,7 +924,7 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_DDE_COMMAND_ELEMENT)) ? 2 :
rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_IS_AUTOMATIC_UPDATE)) ? 3 : USHRT_MAX;
if(nPart < 3 )
- pStr = &(sStr = m_pImpl->m_sParam1.GetToken(nPart, sfx2::cTokenSeparator));
+ aRet <<= m_pImpl->m_sParam1.getToken(nPart, sfx2::cTokenSeparator);
else if(3 == nPart)
aRet.setValue(&m_pImpl->m_bParam1, ::getBooleanCppuType());
}
@@ -918,9 +932,6 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
default:
throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
}
-
- if( pStr )
- aRet <<= OUString( *pStr );
}
}
return aRet;
commit eef7bbe2cb3dc6c12c9f19743a2bccdebedcd529
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Jun 11 23:36:25 2013 +0200
i#105557: thread safety of SwXFieldEnumeration
add Impl class to implement SwClient
Change-Id: I2813109269a7d3d5ea44b4ce8e426457f38cfae2
diff --git a/sw/source/core/inc/unofield.hxx b/sw/source/core/inc/unofield.hxx
index 913e2ae..19685a3 100644
--- a/sw/source/core/inc/unofield.hxx
+++ b/sw/source/core/inc/unofield.hxx
@@ -30,9 +30,6 @@
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase5.hxx>
-#include <tools/string.hxx>
-
-#include <calbck.hxx>
#include <unobaseclass.hxx>
@@ -291,35 +288,44 @@ public:
};
-class SwXFieldEnumeration : public cppu::WeakImplHelper2
-<
- ::com::sun::star::container::XEnumeration,
- ::com::sun::star::lang::XServiceInfo
->,
- public SwClient
+typedef ::cppu::WeakImplHelper2
+< ::com::sun::star::container::XEnumeration
+, ::com::sun::star::lang::XServiceInfo
+> SwXFieldEnumeration_Base;
+
+class SwXFieldEnumeration
+ : public SwXFieldEnumeration_Base
{
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > > aItems;
- sal_Int32 nNextIndex; // index of next element to be returned
- SwDoc* pDoc;
+private:
+ class Impl;
+ ::sw::UnoImplPtr<Impl> m_pImpl;
-protected:
virtual ~SwXFieldEnumeration();
- //SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
+
public:
- SwXFieldEnumeration(SwDoc* pDoc);
+ explicit SwXFieldEnumeration(SwDoc & rDoc);
- //XEnumeration
- virtual sal_Bool SAL_CALL hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Any SAL_CALL nextElement(void) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(
+ const OUString& rServiceName)
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
+ getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
- //XServiceInfo
- virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
+ // XEnumeration
+ virtual sal_Bool SAL_CALL hasMoreElements()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL nextElement()
+ throw (::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 932ec8a..28b8a11 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -2815,7 +2815,7 @@ uno::Reference< container::XEnumeration > SwXTextFieldTypes::createEnumeration(
SolarMutexGuard aGuard;
if(!IsValid())
throw uno::RuntimeException();
- return new SwXFieldEnumeration(GetDoc());
+ return new SwXFieldEnumeration(*GetDoc());
}
uno::Type SwXTextFieldTypes::getElementType(void) throw( uno::RuntimeException )
@@ -2866,17 +2866,43 @@ throw (uno::RuntimeException)
/******************************************************************
* SwXFieldEnumeration
******************************************************************/
-OUString SwXFieldEnumeration::getImplementationName(void) throw( uno::RuntimeException )
+
+class SwXFieldEnumeration::Impl
+ : public SwClient
+{
+
+public:
+ SwDoc * m_pDoc;
+
+ uno::Sequence< uno::Reference<text::XTextField> > m_Items;
+ sal_Int32 m_nNextIndex; ///< index of next element to be returned
+
+ Impl(SwDoc & rDoc)
+ : SwClient(rDoc.GetPageDescFromPool(RES_POOLPAGE_STANDARD))
+ , m_pDoc(& rDoc)
+ , m_nNextIndex(0)
+ { }
+
+protected:
+ // SwClient
+ virtual void Modify(SfxPoolItem const* pOld, SfxPoolItem const* pNew);
+};
+
+OUString SAL_CALL
+SwXFieldEnumeration::getImplementationName() throw (uno::RuntimeException)
{
return OUString("SwXFieldEnumeration");
}
-sal_Bool SwXFieldEnumeration::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
+sal_Bool SAL_CALL
+SwXFieldEnumeration::supportsService(const OUString& rServiceName)
+throw (uno::RuntimeException)
{
return rServiceName == "com.sun.star.text.FieldEnumeration";
}
-uno::Sequence< OUString > SwXFieldEnumeration::getSupportedServiceNames(void) throw( uno::RuntimeException )
+uno::Sequence< OUString > SAL_CALL
+SwXFieldEnumeration::getSupportedServiceNames() throw (uno::RuntimeException)
{
uno::Sequence< OUString > aRet(1);
OUString* pArray = aRet.getArray();
@@ -2884,19 +2910,16 @@ uno::Sequence< OUString > SwXFieldEnumeration::getSupportedServiceNames(void) th
return aRet;
}
-SwXFieldEnumeration::SwXFieldEnumeration(SwDoc* pDc) :
- nNextIndex(0),
- pDoc(pDc)
+SwXFieldEnumeration::SwXFieldEnumeration(SwDoc & rDoc)
+ : m_pImpl(new Impl(rDoc))
{
- pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
-
// build sequence
sal_Int32 nSize = 32;
- aItems.realloc( nSize );
- uno::Reference< text::XTextField > *pItems = aItems.getArray();
+ m_pImpl->m_Items.realloc( nSize );
+ uno::Reference< text::XTextField > *pItems = m_pImpl->m_Items.getArray();
sal_Int32 nFillPos = 0;
//
- const SwFldTypes* pFldTypes = pDoc->GetFldTypes();
+ const SwFldTypes* pFldTypes = m_pImpl->m_pDoc->GetFldTypes();
sal_uInt16 nCount = pFldTypes->size();
for(sal_uInt16 nType = 0; nType < nCount; ++nType)
{
@@ -2911,21 +2934,21 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc* pDc) :
bool bSkip = !pTxtFld ||
!pTxtFld->GetpTxtNode()->GetNodes().IsDocNodes();
if (!bSkip)
- pItems[ nFillPos++ ] =
- SwXTextField::CreateXTextField(*pDoc, *pCurFldFmt);
+ pItems[ nFillPos++ ] = SwXTextField::CreateXTextField(
+ *m_pImpl->m_pDoc, *pCurFldFmt);
pCurFldFmt = aIter.Next();
// enlarge sequence if necessary
- if (aItems.getLength() == nFillPos)
+ if (m_pImpl->m_Items.getLength() == nFillPos)
{
- aItems.realloc( 2 * aItems.getLength() );
- pItems = aItems.getArray();
+ m_pImpl->m_Items.realloc( 2 * m_pImpl->m_Items.getLength() );
+ pItems = m_pImpl->m_Items.getArray();
}
}
}
// now handle meta-fields, which are not SwFields
const ::std::vector< uno::Reference<text::XTextField> > MetaFields(
- pDc->GetMetaFieldManager().getMetaFields() );
+ m_pImpl->m_pDoc->GetMetaFieldManager().getMetaFields() );
for (size_t i = 0; i < MetaFields.size(); ++i)
{
pItems[ nFillPos ] = MetaFields[i];
@@ -2933,51 +2956,55 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc* pDc) :
//FIXME UGLY
// enlarge sequence if necessary
- if (aItems.getLength() == nFillPos)
+ if (m_pImpl->m_Items.getLength() == nFillPos)
{
- aItems.realloc( 2 * aItems.getLength() );
- pItems = aItems.getArray();
+ m_pImpl->m_Items.realloc( 2 * m_pImpl->m_Items.getLength() );
+ pItems = m_pImpl->m_Items.getArray();
}
}
// resize sequence to actual used size
- aItems.realloc( nFillPos );
+ m_pImpl->m_Items.realloc( nFillPos );
}
SwXFieldEnumeration::~SwXFieldEnumeration()
{
-
}
-sal_Bool SwXFieldEnumeration::hasMoreElements(void)
- throw( uno::RuntimeException )
+sal_Bool SAL_CALL SwXFieldEnumeration::hasMoreElements()
+throw (uno::RuntimeException)
{
SolarMutexGuard aGuard;
- return nNextIndex < aItems.getLength();
+
+ return m_pImpl->m_nNextIndex < m_pImpl->m_Items.getLength();
}
-uno::Any SwXFieldEnumeration::nextElement(void)
- throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+uno::Any SAL_CALL SwXFieldEnumeration::nextElement()
+throw (container::NoSuchElementException, lang::WrappedTargetException,
+ uno::RuntimeException)
{
SolarMutexGuard aGuard;
- if (!(nNextIndex < aItems.getLength()))
+ if (!(m_pImpl->m_nNextIndex < m_pImpl->m_Items.getLength()))
throw container::NoSuchElementException();
#if OSL_DEBUG_LEVEL > 1
- uno::Reference< text::XTextField > *pItems = aItems.getArray();
+ uno::Reference< text::XTextField > *pItems = m_pImpl->m_Items.getArray();
(void)pItems;
#endif
- uno::Reference< text::XTextField > &rxFld = aItems.getArray()[ nNextIndex++ ];
- uno::Any aRet(&rxFld, ::getCppuType(static_cast<const uno::Reference<text::XTextField>*>(0)));
+ uno::Reference< text::XTextField > &rxFld =
+ m_pImpl->m_Items.getArray()[ m_pImpl->m_nNextIndex++ ];
+ uno::Any aRet;
+ aRet <<= rxFld;
rxFld = 0; // free memory for item that is not longer used
return aRet;
}
-void SwXFieldEnumeration::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
+void SwXFieldEnumeration::Impl::Modify(
+ SfxPoolItem const*const pOld, SfxPoolItem const*const pNew)
{
ClientModify(this, pOld, pNew);
if(!GetRegisteredIn())
- pDoc = 0;
+ m_pDoc = 0;
}
String& GetString( const uno::Any& rAny, String& rStr )
commit 9aaf9885d92585b0591fd7fc17b1bf2ae125957e
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Jun 11 22:01:02 2013 +0200
de-dent SwXTextField a bit
Change-Id: Ib775e1bf3ee0f5c52a2cda46b016d0649df90592
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 0a919c8..932ec8a 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1231,13 +1231,13 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
sal::static_int_cast< sal_IntPtr >( xMasterTunnel->getSomething( SwXFieldMaster::getUnoTunnelId()) ));
SwFieldType* pFieldType = pMaster ? pMaster->GetFldType() : 0;
- if(pFieldType && pFieldType->Which() == lcl_ServiceIdToResId(m_pImpl->m_nServiceId))
+ if (!pFieldType ||
+ pFieldType->Which() != lcl_ServiceIdToResId(m_pImpl->m_nServiceId))
{
- m_pImpl->m_sTypeName = pFieldType->GetName();
- pFieldType->Add( &m_pImpl->m_FieldTypeClient );
- }
- else
throw lang::IllegalArgumentException();
+ }
+ m_pImpl->m_sTypeName = pFieldType->GetName();
+ pFieldType->Add( &m_pImpl->m_FieldTypeClient );
}
uno::Reference< beans::XPropertySet > SAL_CALL
@@ -1298,670 +1298,665 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0;
//wurde ein FieldMaster attached, dann ist das Dokument schon festgelegt!
- if (pDoc && (!m_pImpl->m_pDoc || m_pImpl->m_pDoc == pDoc))
+ if (!pDoc || (m_pImpl->m_pDoc && m_pImpl->m_pDoc != pDoc))
+ throw lang::IllegalArgumentException();
+
+ SwUnoInternalPaM aPam(*pDoc);
+ //das muss jetzt sal_True liefern
+ ::sw::XTextRangeToSwPaM(aPam, xTextRange);
+ SwField* pFld = 0;
+ switch (m_pImpl->m_nServiceId)
{
- SwUnoInternalPaM aPam(*pDoc);
- //das muss jetzt sal_True liefern
- ::sw::XTextRangeToSwPaM(aPam, xTextRange);
- SwField* pFld = 0;
- switch (m_pImpl->m_nServiceId)
+ case SW_SERVICE_FIELDTYPE_ANNOTATION:
{
- case SW_SERVICE_FIELDTYPE_ANNOTATION:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_POSTITFLD);
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_POSTITFLD);
- DateTime aDateTime( DateTime::EMPTY );
- if (m_pImpl->m_pProps->pDateTime)
- {
- aDateTime.SetYear(m_pImpl->m_pProps->pDateTime->Year);
- aDateTime.SetMonth(m_pImpl->m_pProps->pDateTime->Month);
- aDateTime.SetDay(m_pImpl->m_pProps->pDateTime->Day);
- aDateTime.SetHour(m_pImpl->m_pProps->pDateTime->Hours);
- aDateTime.SetMin(m_pImpl->m_pProps->pDateTime->Minutes);
- aDateTime.SetSec(m_pImpl->m_pProps->pDateTime->Seconds);
- }
- pFld = new SwPostItField((SwPostItFieldType*)pFldType,
- m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
- m_pImpl->m_pProps->sPar3, m_pImpl->m_pProps->sPar4,
- aDateTime);
- if (m_pImpl->m_pTextObject)
- {
- SwPostItField *const pP(static_cast<SwPostItField *>(pFld));
- pP->SetTextObject(m_pImpl->m_pTextObject->CreateText());
- pP->SetPar2(m_pImpl->m_pTextObject->GetText());
- }
- }
- break;
- case SW_SERVICE_FIELDTYPE_SCRIPT:
+ DateTime aDateTime( DateTime::EMPTY );
+ if (m_pImpl->m_pProps->pDateTime)
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_SCRIPTFLD);
- pFld = new SwScriptField((SwScriptFieldType*)pFldType,
- m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
- m_pImpl->m_pProps->bBool1);
+ aDateTime.SetYear(m_pImpl->m_pProps->pDateTime->Year);
+ aDateTime.SetMonth(m_pImpl->m_pProps->pDateTime->Month);
+ aDateTime.SetDay(m_pImpl->m_pProps->pDateTime->Day);
+ aDateTime.SetHour(m_pImpl->m_pProps->pDateTime->Hours);
+ aDateTime.SetMin(m_pImpl->m_pProps->pDateTime->Minutes);
+ aDateTime.SetSec(m_pImpl->m_pProps->pDateTime->Seconds);
}
- break;
- case SW_SERVICE_FIELDTYPE_DATETIME:
+ pFld = new SwPostItField((SwPostItFieldType*)pFldType,
+ m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
+ m_pImpl->m_pProps->sPar3, m_pImpl->m_pProps->sPar4,
+ aDateTime);
+ if (m_pImpl->m_pTextObject)
{
- sal_uInt16 nSub = 0;
- if (m_pImpl->m_pProps->bBool1)
- nSub |= FIXEDFLD;
- if (m_pImpl->m_pProps->bBool2)
- nSub |= DATEFLD;
- else
- nSub |= TIMEFLD;
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_DATETIMEFLD);
- SwDateTimeField *const pDTField = new SwDateTimeField(
- static_cast<SwDateTimeFieldType*>(pFldType),
- nSub, m_pImpl->m_pProps->nFormat);
- pFld = pDTField;
- if (m_pImpl->m_pProps->fDouble > 0.)
- {
- pDTField->SetValue(m_pImpl->m_pProps->fDouble);
- }
- if (m_pImpl->m_pProps->pDateTime)
- {
- uno::Any aVal; aVal <<= *m_pImpl->m_pProps->pDateTime;
- pFld->PutValue( aVal, FIELD_PROP_DATE_TIME );
- }
- pDTField->SetOffset(m_pImpl->m_pProps->nSubType);
- }
- break;
- case SW_SERVICE_FIELDTYPE_FILE_NAME:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_FILENAMEFLD);
- sal_Int32 nFormat = m_pImpl->m_pProps->nFormat;
- if (m_pImpl->m_pProps->bBool2)
- nFormat |= FF_FIXED;
- SwFileNameField *const pFNField = new SwFileNameField(
- static_cast<SwFileNameFieldType*>(pFldType), nFormat);
- pFld = pFNField;
- if (!m_pImpl->m_pProps->sPar3.isEmpty())
- pFNField->SetExpansion(m_pImpl->m_pProps->sPar3);
- uno::Any aFormat;
- aFormat <<= m_pImpl->m_pProps->nFormat;
- pFld->PutValue( aFormat, FIELD_PROP_FORMAT );
+ SwPostItField *const pP(static_cast<SwPostItField *>(pFld));
+ pP->SetTextObject(m_pImpl->m_pTextObject->CreateText());
+ pP->SetPar2(m_pImpl->m_pTextObject->GetText());
}
- break;
- case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME:
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_SCRIPT:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_SCRIPTFLD);
+ pFld = new SwScriptField((SwScriptFieldType*)pFldType,
+ m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
+ m_pImpl->m_pProps->bBool1);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_DATETIME:
+ {
+ sal_uInt16 nSub = 0;
+ if (m_pImpl->m_pProps->bBool1)
+ nSub |= FIXEDFLD;
+ if (m_pImpl->m_pProps->bBool2)
+ nSub |= DATEFLD;
+ else
+ nSub |= TIMEFLD;
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_DATETIMEFLD);
+ SwDateTimeField *const pDTField = new SwDateTimeField(
+ static_cast<SwDateTimeFieldType*>(pFldType),
+ nSub, m_pImpl->m_pProps->nFormat);
+ pFld = pDTField;
+ if (m_pImpl->m_pProps->fDouble > 0.)
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_TEMPLNAMEFLD);
- pFld = new SwTemplNameField((SwTemplNameFieldType*)pFldType,
- m_pImpl->m_pProps->nFormat);
- uno::Any aFormat;
- aFormat <<= m_pImpl->m_pProps->nFormat;
- pFld->PutValue(aFormat, FIELD_PROP_FORMAT);
+ pDTField->SetValue(m_pImpl->m_pProps->fDouble);
}
- break;
- case SW_SERVICE_FIELDTYPE_CHAPTER:
+ if (m_pImpl->m_pProps->pDateTime)
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_CHAPTERFLD);
- SwChapterField *const pChapterField = new SwChapterField(
- static_cast<SwChapterFieldType*>(pFldType),
- m_pImpl->m_pProps->nUSHORT1);
- pFld = pChapterField;
- pChapterField->SetLevel(m_pImpl->m_pProps->nByte1);
- uno::Any aVal;
- aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
- pFld->PutValue(aVal, FIELD_PROP_USHORT1 );
+ uno::Any aVal; aVal <<= *m_pImpl->m_pProps->pDateTime;
+ pFld->PutValue( aVal, FIELD_PROP_DATE_TIME );
}
- break;
- case SW_SERVICE_FIELDTYPE_AUTHOR:
- {
- long nFormat = m_pImpl->m_pProps->bBool1 ? AF_NAME : AF_SHORTCUT;
- if (m_pImpl->m_pProps->bBool2)
- nFormat |= AF_FIXED;
-
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_AUTHORFLD);
- SwAuthorField *const pAuthorField = new SwAuthorField(
- static_cast<SwAuthorFieldType*>(pFldType), nFormat);
- pFld = pAuthorField;
- pAuthorField->SetExpansion(m_pImpl->m_pProps->sPar1);
- }
- break;
- case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT:
- case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_HIDDENTXTFLD);
- SwHiddenTxtField *const pHTField = new SwHiddenTxtField(
- static_cast<SwHiddenTxtFieldType*>(pFldType),
+ pDTField->SetOffset(m_pImpl->m_pProps->nSubType);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_FILE_NAME:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_FILENAMEFLD);
+ sal_Int32 nFormat = m_pImpl->m_pProps->nFormat;
+ if (m_pImpl->m_pProps->bBool2)
+ nFormat |= FF_FIXED;
+ SwFileNameField *const pFNField = new SwFileNameField(
+ static_cast<SwFileNameFieldType*>(pFldType), nFormat);
+ pFld = pFNField;
+ if (!m_pImpl->m_pProps->sPar3.isEmpty())
+ pFNField->SetExpansion(m_pImpl->m_pProps->sPar3);
+ uno::Any aFormat;
+ aFormat <<= m_pImpl->m_pProps->nFormat;
+ pFld->PutValue( aFormat, FIELD_PROP_FORMAT );
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_TEMPLNAMEFLD);
+ pFld = new SwTemplNameField((SwTemplNameFieldType*)pFldType,
+ m_pImpl->m_pProps->nFormat);
+ uno::Any aFormat;
+ aFormat <<= m_pImpl->m_pProps->nFormat;
+ pFld->PutValue(aFormat, FIELD_PROP_FORMAT);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_CHAPTER:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_CHAPTERFLD);
+ SwChapterField *const pChapterField = new SwChapterField(
+ static_cast<SwChapterFieldType*>(pFldType),
+ m_pImpl->m_pProps->nUSHORT1);
+ pFld = pChapterField;
+ pChapterField->SetLevel(m_pImpl->m_pProps->nByte1);
+ uno::Any aVal;
+ aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
+ pFld->PutValue(aVal, FIELD_PROP_USHORT1 );
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_AUTHOR:
+ {
+ long nFormat = m_pImpl->m_pProps->bBool1 ? AF_NAME : AF_SHORTCUT;
+ if (m_pImpl->m_pProps->bBool2)
+ nFormat |= AF_FIXED;
+
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_AUTHORFLD);
+ SwAuthorField *const pAuthorField = new SwAuthorField(
+ static_cast<SwAuthorFieldType*>(pFldType), nFormat);
+ pFld = pAuthorField;
+ pAuthorField->SetExpansion(m_pImpl->m_pProps->sPar1);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT:
+ case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_HIDDENTXTFLD);
+ SwHiddenTxtField *const pHTField = new SwHiddenTxtField(
+ static_cast<SwHiddenTxtFieldType*>(pFldType),
+ m_pImpl->m_pProps->sPar1,
+ m_pImpl->m_pProps->sPar2, m_pImpl->m_pProps->sPar3,
+ static_cast<sal_uInt16>(SW_SERVICE_FIELDTYPE_HIDDEN_TEXT == m_pImpl->m_nServiceId ?
+ TYP_HIDDENTXTFLD : TYP_CONDTXTFLD));
+ pFld = pHTField;
+ pHTField->SetValue(m_pImpl->m_pProps->bBool1);
+ uno::Any aVal;
+ aVal <<= m_pImpl->m_pProps->sPar4;
+ pFld->PutValue(aVal, FIELD_PROP_PAR4 );
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_HIDDEN_PARA:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_HIDDENPARAFLD);
+ SwHiddenParaField *const pHPField = new SwHiddenParaField(
+ static_cast<SwHiddenParaFieldType*>(pFldType),
+ m_pImpl->m_pProps->sPar1);
+ pFld = pHPField;
+ pHPField->SetHidden(m_pImpl->m_pProps->bBool1);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_GET_REFERENCE:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_GETREFFLD);
+ pFld = new SwGetRefField((SwGetRefFieldType*)pFldType,
m_pImpl->m_pProps->sPar1,
- m_pImpl->m_pProps->sPar2, m_pImpl->m_pProps->sPar3,
- static_cast<sal_uInt16>(SW_SERVICE_FIELDTYPE_HIDDEN_TEXT == m_pImpl->m_nServiceId ?
- TYP_HIDDENTXTFLD : TYP_CONDTXTFLD));
- pFld = pHTField;
- pHTField->SetValue(m_pImpl->m_pProps->bBool1);
- uno::Any aVal;
- aVal <<= m_pImpl->m_pProps->sPar4;
- pFld->PutValue(aVal, FIELD_PROP_PAR4 );
- }
- break;
- case SW_SERVICE_FIELDTYPE_HIDDEN_PARA:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_HIDDENPARAFLD);
- SwHiddenParaField *const pHPField = new SwHiddenParaField(
- static_cast<SwHiddenParaFieldType*>(pFldType),
- m_pImpl->m_pProps->sPar1);
- pFld = pHPField;
- pHPField->SetHidden(m_pImpl->m_pProps->bBool1);
- }
- break;
- case SW_SERVICE_FIELDTYPE_GET_REFERENCE:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_GETREFFLD);
- pFld = new SwGetRefField((SwGetRefFieldType*)pFldType,
- m_pImpl->m_pProps->sPar1,
- 0,
- 0,
- 0);
- if (!m_pImpl->m_pProps->sPar3.isEmpty())
- static_cast<SwGetRefField*>(pFld)->SetExpand(m_pImpl->m_pProps->sPar3);
- uno::Any aVal;
- aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
- pFld->PutValue(aVal, FIELD_PROP_USHORT1 );
- aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT2);
- pFld->PutValue(aVal, FIELD_PROP_USHORT2 );
- aVal <<= m_pImpl->m_pProps->nSHORT1;
- pFld->PutValue(aVal, FIELD_PROP_SHORT1 );
- }
- break;
- case SW_SERVICE_FIELDTYPE_JUMP_EDIT:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_JUMPEDITFLD);
- pFld = new SwJumpEditField((SwJumpEditFieldType*)pFldType,
- m_pImpl->m_pProps->nUSHORT1, m_pImpl->m_pProps->sPar2,
- m_pImpl->m_pProps->sPar1);
- }
- break;
- case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR :
- case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME :
- case SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME :
- case SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION :
- case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR :
- case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME :
- case SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM :
- case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR :
- case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME :
- case SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS :
- case SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT :
- case SW_SERVICE_FIELDTYPE_DOCINFO_TITLE :
- case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION :
- case SW_SERVICE_FIELDTYPE_DOC_INFO:
+ 0,
+ 0,
+ 0);
+ if (!m_pImpl->m_pProps->sPar3.isEmpty())
+ static_cast<SwGetRefField*>(pFld)->SetExpand(m_pImpl->m_pProps->sPar3);
+ uno::Any aVal;
+ aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT1);
+ pFld->PutValue(aVal, FIELD_PROP_USHORT1 );
+ aVal <<= static_cast<sal_Int16>(m_pImpl->m_pProps->nUSHORT2);
+ pFld->PutValue(aVal, FIELD_PROP_USHORT2 );
+ aVal <<= m_pImpl->m_pProps->nSHORT1;
+ pFld->PutValue(aVal, FIELD_PROP_SHORT1 );
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_JUMP_EDIT:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_JUMPEDITFLD);
+ pFld = new SwJumpEditField((SwJumpEditFieldType*)pFldType,
+ m_pImpl->m_pProps->nUSHORT1, m_pImpl->m_pProps->sPar2,
+ m_pImpl->m_pProps->sPar1);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_DESCRIPTION :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_AUTHOR :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_CUSTOM :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_AUTHOR :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_KEY_WORDS :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_SUBJECT :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_TITLE :
+ case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION :
+ case SW_SERVICE_FIELDTYPE_DOC_INFO:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_DOCINFOFLD);
+ sal_uInt16 nSubType = aDocInfoSubTypeFromService[
+ m_pImpl->m_nServiceId - SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR];
+ if (SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME == m_pImpl->m_nServiceId ||
+ SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME == m_pImpl->m_nServiceId ||
+ SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME == m_pImpl->m_nServiceId ||
+ SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME == m_pImpl->m_nServiceId)
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_DOCINFOFLD);
- sal_uInt16 nSubType = aDocInfoSubTypeFromService[
- m_pImpl->m_nServiceId - SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_AUTHOR];
- if (SW_SERVICE_FIELDTYPE_DOCINFO_CHANGE_DATE_TIME == m_pImpl->m_nServiceId ||
- SW_SERVICE_FIELDTYPE_DOCINFO_CREATE_DATE_TIME == m_pImpl->m_nServiceId ||
- SW_SERVICE_FIELDTYPE_DOCINFO_PRINT_DATE_TIME == m_pImpl->m_nServiceId ||
- SW_SERVICE_FIELDTYPE_DOCINFO_EDIT_TIME == m_pImpl->m_nServiceId)
+ if (m_pImpl->m_pProps->bBool2) //IsDate
{
- if (m_pImpl->m_pProps->bBool2) //IsDate
- {
- nSubType &= 0xf0ff;
- nSubType |= DI_SUB_DATE;
- }
- else
- {
- nSubType &= 0xf0ff;
- nSubType |= DI_SUB_TIME;
- }
+ nSubType &= 0xf0ff;
+ nSubType |= DI_SUB_DATE;
}
- if (m_pImpl->m_pProps->bBool1)
- nSubType |= DI_SUB_FIXED;
- pFld = new SwDocInfoField(
- static_cast<SwDocInfoFieldType*>(pFldType), nSubType,
- m_pImpl->m_pProps->sPar4, m_pImpl->m_pProps->nFormat);
- if (!m_pImpl->m_pProps->sPar3.isEmpty())
- static_cast<SwDocInfoField*>(pFld)->SetExpansion(m_pImpl->m_pProps->sPar3);
- }
- break;
- case SW_SERVICE_FIELDTYPE_USER_EXT:
- {
- sal_Int32 nFormat = 0;
- if (m_pImpl->m_pProps->bBool1)
- nFormat = AF_FIXED;
-
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_EXTUSERFLD);
- SwExtUserField *const pEUField = new SwExtUserField(
- static_cast<SwExtUserFieldType*>(pFldType),
- m_pImpl->m_pProps->nUSHORT1, nFormat);
- pFld = pEUField;
- pEUField->SetExpansion(m_pImpl->m_pProps->sPar1);
- }
- break;
- case SW_SERVICE_FIELDTYPE_USER:
- {
- SwFieldType* pFldType =
- pDoc->GetFldType(RES_USERFLD, m_pImpl->m_sTypeName, true);
- if(!pFldType)
- throw uno::RuntimeException();
- sal_uInt16 nUserSubType = (m_pImpl->m_pProps->bBool1)
- ? nsSwExtendedSubType::SUB_INVISIBLE : 0;
- if (m_pImpl->m_pProps->bBool2)
- nUserSubType |= nsSwExtendedSubType::SUB_CMD;
- if (m_pImpl->m_pProps->bFormatIsDefault &&
- nsSwGetSetExpType::GSE_STRING == ((SwUserFieldType*)pFldType)->GetType())
+ else
{
- m_pImpl->m_pProps->nFormat = -1;
+ nSubType &= 0xf0ff;
+ nSubType |= DI_SUB_TIME;
}
- pFld = new SwUserField((SwUserFieldType*)pFldType,
- nUserSubType,
- m_pImpl->m_pProps->nFormat);
}
- break;
- case SW_SERVICE_FIELDTYPE_REF_PAGE_SET:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_REFPAGESETFLD);
- pFld = new SwRefPageSetField( (SwRefPageSetFieldType*)pFldType,
- m_pImpl->m_pProps->nUSHORT1,
- m_pImpl->m_pProps->bBool1 );
- }
- break;
- case SW_SERVICE_FIELDTYPE_REF_PAGE_GET:
+ if (m_pImpl->m_pProps->bBool1)
+ nSubType |= DI_SUB_FIXED;
+ pFld = new SwDocInfoField(
+ static_cast<SwDocInfoFieldType*>(pFldType), nSubType,
+ m_pImpl->m_pProps->sPar4, m_pImpl->m_pProps->nFormat);
+ if (!m_pImpl->m_pProps->sPar3.isEmpty())
+ static_cast<SwDocInfoField*>(pFld)->SetExpansion(m_pImpl->m_pProps->sPar3);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_USER_EXT:
+ {
+ sal_Int32 nFormat = 0;
+ if (m_pImpl->m_pProps->bBool1)
+ nFormat = AF_FIXED;
+
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_EXTUSERFLD);
+ SwExtUserField *const pEUField = new SwExtUserField(
+ static_cast<SwExtUserFieldType*>(pFldType),
+ m_pImpl->m_pProps->nUSHORT1, nFormat);
+ pFld = pEUField;
+ pEUField->SetExpansion(m_pImpl->m_pProps->sPar1);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_USER:
+ {
+ SwFieldType* pFldType =
+ pDoc->GetFldType(RES_USERFLD, m_pImpl->m_sTypeName, true);
+ if (!pFldType)
+ throw uno::RuntimeException();
+ sal_uInt16 nUserSubType = (m_pImpl->m_pProps->bBool1)
+ ? nsSwExtendedSubType::SUB_INVISIBLE : 0;
+ if (m_pImpl->m_pProps->bBool2)
+ nUserSubType |= nsSwExtendedSubType::SUB_CMD;
+ if (m_pImpl->m_pProps->bFormatIsDefault &&
+ nsSwGetSetExpType::GSE_STRING == ((SwUserFieldType*)pFldType)->GetType())
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_REFPAGEGETFLD);
- SwRefPageGetField *const pRGField = new SwRefPageGetField(
- static_cast<SwRefPageGetFieldType*>(pFldType),
- m_pImpl->m_pProps->nUSHORT1 );
- pFld = pRGField;
- pRGField->SetText(m_pImpl->m_pProps->sPar1);
+ m_pImpl->m_pProps->nFormat = -1;
}
- break;
- case SW_SERVICE_FIELDTYPE_PAGE_NUM:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_PAGENUMBERFLD);
- SwPageNumberField *const pPNField = new SwPageNumberField(
- static_cast<SwPageNumberFieldType*>(pFldType), PG_RANDOM,
- m_pImpl->m_pProps->nFormat,
+ pFld = new SwUserField((SwUserFieldType*)pFldType,
+ nUserSubType,
+ m_pImpl->m_pProps->nFormat);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_REF_PAGE_SET:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_REFPAGESETFLD);
+ pFld = new SwRefPageSetField( (SwRefPageSetFieldType*)pFldType,
+ m_pImpl->m_pProps->nUSHORT1,
+ m_pImpl->m_pProps->bBool1 );
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_REF_PAGE_GET:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_REFPAGEGETFLD);
+ SwRefPageGetField *const pRGField = new SwRefPageGetField(
+ static_cast<SwRefPageGetFieldType*>(pFldType),
+ m_pImpl->m_pProps->nUSHORT1 );
+ pFld = pRGField;
+ pRGField->SetText(m_pImpl->m_pProps->sPar1);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_PAGE_NUM:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_PAGENUMBERFLD);
+ SwPageNumberField *const pPNField = new SwPageNumberField(
+ static_cast<SwPageNumberFieldType*>(pFldType), PG_RANDOM,
+ m_pImpl->m_pProps->nFormat,
+ m_pImpl->m_pProps->nUSHORT1);
+ pFld = pPNField;
+ pPNField->SetUserString(m_pImpl->m_pProps->sPar1);
+ uno::Any aVal;
+ aVal <<= m_pImpl->m_pProps->nSubType;
+ pFld->PutValue( aVal, FIELD_PROP_SUBTYPE );
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_DDE:
+ {
+ SwFieldType* pFldType =
+ pDoc->GetFldType(RES_DDEFLD, m_pImpl->m_sTypeName, true);
+ if (!pFldType)
+ throw uno::RuntimeException();
+ pFld = new SwDDEField( (SwDDEFieldType*)pFldType );
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_DATABASE_NAME:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_DBNAMEFLD);
+ SwDBData aData;
+ aData.sDataSource = m_pImpl->m_pProps->sPar1;
+ aData.sCommand = m_pImpl->m_pProps->sPar2;
+ aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
+ pFld = new SwDBNameField((SwDBNameFieldType*)pFldType, aData);
+ sal_uInt16 nSubType = pFld->GetSubType();
+ if (m_pImpl->m_pProps->bBool2)
+ nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
+ else
+ nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
+ pFld->SetSubType(nSubType);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET:
+ {
+ SwDBData aData;
+ aData.sDataSource = m_pImpl->m_pProps->sPar1;
+ aData.sCommand = m_pImpl->m_pProps->sPar2;
+ aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_DBNEXTSETFLD);
+ pFld = new SwDBNextSetField((SwDBNextSetFieldType*)pFldType,
+ m_pImpl->m_pProps->sPar3, aEmptyStr, aData);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET:
+ {
+ SwDBData aData;
+ aData.sDataSource = m_pImpl->m_pProps->sPar1;
+ aData.sCommand = m_pImpl->m_pProps->sPar2;
+ aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
+ pFld = new SwDBNumSetField( (SwDBNumSetFieldType*)
+ pDoc->GetSysFldType(RES_DBNUMSETFLD),
+ m_pImpl->m_pProps->sPar3,
+ OUString::number(m_pImpl->m_pProps->nFormat),
+ aData );
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM:
+ {
+ SwDBData aData;
+ aData.sDataSource = m_pImpl->m_pProps->sPar1;
+ aData.sCommand = m_pImpl->m_pProps->sPar2;
+ aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
+ SwDBSetNumberField *const pDBSNField =
+ new SwDBSetNumberField(static_cast<SwDBSetNumberFieldType*>(
+ pDoc->GetSysFldType(RES_DBSETNUMBERFLD)), aData,
m_pImpl->m_pProps->nUSHORT1);
- pFld = pPNField;
- pPNField->SetUserString(m_pImpl->m_pProps->sPar1);
- uno::Any aVal;
- aVal <<= m_pImpl->m_pProps->nSubType;
- pFld->PutValue( aVal, FIELD_PROP_SUBTYPE );
- }
- break;
- case SW_SERVICE_FIELDTYPE_DDE:
- {
- SwFieldType* pFldType =
- pDoc->GetFldType(RES_DDEFLD, m_pImpl->m_sTypeName, true);
- if(!pFldType)
- throw uno::RuntimeException();
- pFld = new SwDDEField( (SwDDEFieldType*)pFldType );
- }
- break;
- case SW_SERVICE_FIELDTYPE_DATABASE_NAME:
- {
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_DBNAMEFLD);
- SwDBData aData;
- aData.sDataSource = m_pImpl->m_pProps->sPar1;
- aData.sCommand = m_pImpl->m_pProps->sPar2;
- aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
- pFld = new SwDBNameField((SwDBNameFieldType*)pFldType, aData);
- sal_uInt16 nSubType = pFld->GetSubType();
- if (m_pImpl->m_pProps->bBool2)
- nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
- else
- nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
- pFld->SetSubType(nSubType);
- }
- break;
- case SW_SERVICE_FIELDTYPE_DATABASE_NEXT_SET:
- {
- SwDBData aData;
- aData.sDataSource = m_pImpl->m_pProps->sPar1;
- aData.sCommand = m_pImpl->m_pProps->sPar2;
- aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_DBNEXTSETFLD);
- pFld = new SwDBNextSetField((SwDBNextSetFieldType*)pFldType,
- m_pImpl->m_pProps->sPar3, aEmptyStr,
- aData);
- }
- break;
- case SW_SERVICE_FIELDTYPE_DATABASE_NUM_SET:
+ pFld = pDBSNField;
+ pDBSNField->SetSetNumber(m_pImpl->m_pProps->nFormat);
+ sal_uInt16 nSubType = pFld->GetSubType();
+ if (m_pImpl->m_pProps->bBool2)
+ nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
+ else
+ nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
+ pFld->SetSubType(nSubType);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_DATABASE:
+ {
+ SwFieldType* pFldType =
+ pDoc->GetFldType(RES_DBFLD, m_pImpl->m_sTypeName, false);
+ if (!pFldType)
+ throw uno::RuntimeException();
+ pFld = new SwDBField(static_cast<SwDBFieldType*>(pFldType),
+ m_pImpl->m_pProps->nFormat);
+ ((SwDBField*)pFld)->InitContent(m_pImpl->m_pProps->sPar1);
+ sal_uInt16 nSubType = pFld->GetSubType();
+ if (m_pImpl->m_pProps->bBool2)
+ nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
+ else
+ nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
+ pFld->SetSubType(nSubType);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_SET_EXP:
+ {
+ SwFieldType* pFldType =
+ pDoc->GetFldType(RES_SETEXPFLD, m_pImpl->m_sTypeName, true);
+ if (!pFldType)
+ throw uno::RuntimeException();
+ // detect the field type's sub type and set an appropriate number format
+ if (m_pImpl->m_pProps->bFormatIsDefault &&
+ nsSwGetSetExpType::GSE_STRING == ((SwSetExpFieldType*)pFldType)->GetType())
{
- SwDBData aData;
- aData.sDataSource = m_pImpl->m_pProps->sPar1;
- aData.sCommand = m_pImpl->m_pProps->sPar2;
- aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
- pFld = new SwDBNumSetField( (SwDBNumSetFieldType*)
- pDoc->GetSysFldType(RES_DBNUMSETFLD),
- m_pImpl->m_pProps->sPar3,
- OUString::number(m_pImpl->m_pProps->nFormat),
- aData );
+ m_pImpl->m_pProps->nFormat = -1;
}
- break;
- case SW_SERVICE_FIELDTYPE_DATABASE_SET_NUM:
+ SwSetExpField *const pSEField = new SwSetExpField(
+ static_cast<SwSetExpFieldType*>(pFldType),
+ m_pImpl->m_pProps->sPar2,
+ m_pImpl->m_pProps->nUSHORT2 != USHRT_MAX ? //#i79471# the field can have a number format or a number_ing_ format
+ m_pImpl->m_pProps->nUSHORT2 : m_pImpl->m_pProps->nFormat);
+ pFld = pSEField;
+
+ sal_uInt16 nSubType = pFld->GetSubType();
+ if (m_pImpl->m_pProps->bBool2)
+ nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
+ else
+ nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
+ if (m_pImpl->m_pProps->bBool3)
+ nSubType |= nsSwExtendedSubType::SUB_CMD;
+ else
+ nSubType &= ~nsSwExtendedSubType::SUB_CMD;
+ pFld->SetSubType(nSubType);
+ pSEField->SetSeqNumber(m_pImpl->m_pProps->nUSHORT1);
+ pSEField->SetInputFlag(m_pImpl->m_pProps->bBool1);
+ pSEField->SetPromptText(m_pImpl->m_pProps->sPar3);
+ if (!m_pImpl->m_pProps->sPar4.isEmpty())
+ pSEField->ChgExpStr(m_pImpl->m_pProps->sPar4);
+
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_GET_EXP:
+ {
+ sal_uInt16 nSubType;
+ switch (m_pImpl->m_pProps->nSubType)
{
- SwDBData aData;
- aData.sDataSource = m_pImpl->m_pProps->sPar1;
- aData.sCommand = m_pImpl->m_pProps->sPar2;
- aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
- SwDBSetNumberField *const pDBSNField =
- new SwDBSetNumberField(static_cast<SwDBSetNumberFieldType*>(
- pDoc->GetSysFldType(RES_DBSETNUMBERFLD)), aData,
- m_pImpl->m_pProps->nUSHORT1);
- pFld = pDBSNField;
- pDBSNField->SetSetNumber(m_pImpl->m_pProps->nFormat);
- sal_uInt16 nSubType = pFld->GetSubType();
- if (m_pImpl->m_pProps->bBool2)
- nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
- else
- nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
- pFld->SetSubType(nSubType);
+ case text::SetVariableType::STRING: nSubType = nsSwGetSetExpType::GSE_STRING; break;
+ case text::SetVariableType::VAR: nSubType = nsSwGetSetExpType::GSE_EXPR; break;
+ //case text::SetVariableType::SEQUENCE: nSubType = nsSwGetSetExpType::GSE_SEQ; break;
+ case text::SetVariableType::FORMULA: nSubType = nsSwGetSetExpType::GSE_FORMULA; break;
+ default:
+ OSL_FAIL("wrong value");
+ nSubType = nsSwGetSetExpType::GSE_EXPR;
}
- break;
- case SW_SERVICE_FIELDTYPE_DATABASE:
+ //make sure the SubType matches the field type
+ SwFieldType* pSetExpFld = pDoc->GetFldType(
+ RES_SETEXPFLD, m_pImpl->m_pProps->sPar1, sal_False);
+ bool bSetGetExpFieldUninitialized = false;
+ if (pSetExpFld)
{
- SwFieldType* pFldType =
- pDoc->GetFldType(RES_DBFLD, m_pImpl->m_sTypeName, false);
- if(!pFldType)
- throw uno::RuntimeException();
- pFld = new SwDBField(static_cast<SwDBFieldType*>(pFldType),
- m_pImpl->m_pProps->nFormat);
- ((SwDBField*)pFld)->InitContent(m_pImpl->m_pProps->sPar1);
- sal_uInt16 nSubType = pFld->GetSubType();
- if (m_pImpl->m_pProps->bBool2)
- nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
- else
- nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
- pFld->SetSubType(nSubType);
+ if (nSubType != nsSwGetSetExpType::GSE_STRING &&
+ static_cast< SwSetExpFieldType* >(pSetExpFld)->GetType() == nsSwGetSetExpType::GSE_STRING)
+ nSubType = nsSwGetSetExpType::GSE_STRING;
}
- break;
- case SW_SERVICE_FIELDTYPE_SET_EXP:
- {
- SwFieldType* pFldType =
- pDoc->GetFldType(RES_SETEXPFLD, m_pImpl->m_sTypeName, true);
- if(!pFldType)
- throw uno::RuntimeException();
- // detect the field type's sub type and set an appropriate number format
- if (m_pImpl->m_pProps->bFormatIsDefault &&
- nsSwGetSetExpType::GSE_STRING == ((SwSetExpFieldType*)pFldType)->GetType())
- {
- m_pImpl->m_pProps->nFormat = -1;
- }
- SwSetExpField *const pSEField = new SwSetExpField(
- static_cast<SwSetExpFieldType*>(pFldType),
- m_pImpl->m_pProps->sPar2,
- m_pImpl->m_pProps->nUSHORT2 != USHRT_MAX ? //#i79471# the field can have a number format or a number_ing_ format
- m_pImpl->m_pProps->nUSHORT2 : m_pImpl->m_pProps->nFormat);
- pFld = pSEField;
-
- sal_uInt16 nSubType = pFld->GetSubType();
- if (m_pImpl->m_pProps->bBool2)
- nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
- else
- nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
- if (m_pImpl->m_pProps->bBool3)
- nSubType |= nsSwExtendedSubType::SUB_CMD;
- else
- nSubType &= ~nsSwExtendedSubType::SUB_CMD;
- pFld->SetSubType(nSubType);
- pSEField->SetSeqNumber(m_pImpl->m_pProps->nUSHORT1);
- pSEField->SetInputFlag(m_pImpl->m_pProps->bBool1);
- pSEField->SetPromptText(m_pImpl->m_pProps->sPar3);
- if (!m_pImpl->m_pProps->sPar4.isEmpty())
- pSEField->ChgExpStr(m_pImpl->m_pProps->sPar4);
+ else
+ bSetGetExpFieldUninitialized = true; // #i82544#
- }
- break;
- case SW_SERVICE_FIELDTYPE_GET_EXP:
- {
- sal_uInt16 nSubType;
- switch (m_pImpl->m_pProps->nSubType)
- {
- case text::SetVariableType::STRING: nSubType = nsSwGetSetExpType::GSE_STRING; break;
- case text::SetVariableType::VAR: nSubType = nsSwGetSetExpType::GSE_EXPR; break;
- //case text::SetVariableType::SEQUENCE: nSubType = nsSwGetSetExpType::GSE_SEQ; break;
- case text::SetVariableType::FORMULA: nSubType = nsSwGetSetExpType::GSE_FORMULA; break;
- default:
- OSL_FAIL("wrong value");
- nSubType = nsSwGetSetExpType::GSE_EXPR;
- }
- //make sure the SubType matches the field type
- SwFieldType* pSetExpFld = pDoc->GetFldType(
- RES_SETEXPFLD, m_pImpl->m_pProps->sPar1, sal_False);
- bool bSetGetExpFieldUninitialized = false;
- if( pSetExpFld )
- {
- if( nSubType != nsSwGetSetExpType::GSE_STRING &&
- static_cast< SwSetExpFieldType* >(pSetExpFld)->GetType() == nsSwGetSetExpType::GSE_STRING )
- nSubType = nsSwGetSetExpType::GSE_STRING;
- }
- else
- bSetGetExpFieldUninitialized = true; // #i82544#
+ if (m_pImpl->m_pProps->bBool2)
+ nSubType |= nsSwExtendedSubType::SUB_CMD;
+ else
+ nSubType &= ~nsSwExtendedSubType::SUB_CMD;
+ SwGetExpField *const pGEField = new SwGetExpField(
+ static_cast<SwGetExpFieldType*>(
+ pDoc->GetSysFldType(RES_GETEXPFLD)),
+ m_pImpl->m_pProps->sPar1, nSubType,
+ m_pImpl->m_pProps->nFormat);
+ pFld = pGEField;
+ //TODO: SubType auswerten!
+ if (!m_pImpl->m_pProps->sPar4.isEmpty())
+ pGEField->ChgExpStr(m_pImpl->m_pProps->sPar4);
+ // #i82544#
+ if (bSetGetExpFieldUninitialized)
+ pGEField->SetLateInitialization();
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_INPUT_USER:
+ case SW_SERVICE_FIELDTYPE_INPUT:
+ {
+ SwFieldType* pFldType =
+ pDoc->GetFldType(RES_INPUTFLD, m_pImpl->m_sTypeName, true);
+ if (!pFldType)
+ throw uno::RuntimeException();
+ sal_uInt16 nInpSubType =
+ sal::static_int_cast<sal_uInt16>(
+ SW_SERVICE_FIELDTYPE_INPUT_USER == m_pImpl->m_nServiceId
+ ? INP_USR : INP_TXT);
+ SwInputField * pTxtField =
+ new SwInputField((SwInputFieldType*)pFldType,
+ m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
+ nInpSubType);
+ pTxtField->SetHelp(m_pImpl->m_pProps->sPar3);
+ pTxtField->SetToolTip(m_pImpl->m_pProps->sPar4);
+
+ pFld = pTxtField;
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_MACRO:
+ {
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_MACROFLD);
+ OUString aName;
- if (m_pImpl->m_pProps->bBool2)
- nSubType |= nsSwExtendedSubType::SUB_CMD;
- else
- nSubType &= ~nsSwExtendedSubType::SUB_CMD;
- SwGetExpField *const pGEField = new SwGetExpField(
- static_cast<SwGetExpFieldType*>(
- pDoc->GetSysFldType(RES_GETEXPFLD)),
- m_pImpl->m_pProps->sPar1, nSubType,
- m_pImpl->m_pProps->nFormat);
- pFld = pGEField;
- //TODO: SubType auswerten!
- if (!m_pImpl->m_pProps->sPar4.isEmpty())
- pGEField->ChgExpStr(m_pImpl->m_pProps->sPar4);
- // #i82544#
- if( bSetGetExpFieldUninitialized )
- pGEField->SetLateInitialization();
- }
- break;
- case SW_SERVICE_FIELDTYPE_INPUT_USER:
- case SW_SERVICE_FIELDTYPE_INPUT:
+ // support for Scripting Framework macros
+ if (!m_pImpl->m_pProps->sPar4.isEmpty())
{
- SwFieldType* pFldType =
- pDoc->GetFldType(RES_INPUTFLD, m_pImpl->m_sTypeName, true);
- if(!pFldType)
- throw uno::RuntimeException();
- sal_uInt16 nInpSubType =
- sal::static_int_cast<sal_uInt16>(
- SW_SERVICE_FIELDTYPE_INPUT_USER == m_pImpl->m_nServiceId
- ? INP_USR : INP_TXT);
- SwInputField * pTxtField =
- new SwInputField((SwInputFieldType*)pFldType,
- m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
- nInpSubType);
- pTxtField->SetHelp(m_pImpl->m_pProps->sPar3);
- pTxtField->SetToolTip(m_pImpl->m_pProps->sPar4);
-
- pFld = pTxtField;
+ aName = m_pImpl->m_pProps->sPar4;
}
- break;
- case SW_SERVICE_FIELDTYPE_MACRO:
+ else
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_MACROFLD);
- OUString aName;
-
- // support for Scripting Framework macros
- if (!m_pImpl->m_pProps->sPar4.isEmpty())
- {
- aName = m_pImpl->m_pProps->sPar4;
- }
- else
- {
- SwMacroField::CreateMacroString(aName,
- m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar3);
- }
- pFld = new SwMacroField((SwMacroFieldType*)pFldType, aName,
- m_pImpl->m_pProps->sPar2);
+ SwMacroField::CreateMacroString(aName,
+ m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar3);
}
- break;
- case SW_SERVICE_FIELDTYPE_PAGE_COUNT :
- case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT :
- case SW_SERVICE_FIELDTYPE_WORD_COUNT :
- case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT :
- case SW_SERVICE_FIELDTYPE_TABLE_COUNT :
- case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT :
- case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT :
+ pFld = new SwMacroField((SwMacroFieldType*)pFldType, aName,
+ m_pImpl->m_pProps->sPar2);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_PAGE_COUNT :
+ case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT :
+ case SW_SERVICE_FIELDTYPE_WORD_COUNT :
+ case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT :
+ case SW_SERVICE_FIELDTYPE_TABLE_COUNT :
+ case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT :
+ case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT :
+ {
+ sal_uInt16 nSubType = DS_PAGE;
+ switch (m_pImpl->m_nServiceId)
{
- sal_uInt16 nSubType = DS_PAGE;
- switch(m_pImpl->m_nServiceId)
- {
// case SW_SERVICE_FIELDTYPE_PAGE_COUNT : break;
- case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT : nSubType = DS_PARA;break;
- case SW_SERVICE_FIELDTYPE_WORD_COUNT : nSubType = DS_WORD;break;
- case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT : nSubType = DS_CHAR;break;
- case SW_SERVICE_FIELDTYPE_TABLE_COUNT : nSubType = DS_TBL;break;
- case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT : nSubType = DS_GRF;break;
- case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT : nSubType = DS_OLE;break;
- }
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_DOCSTATFLD);
- pFld = new SwDocStatField(
- static_cast<SwDocStatFieldType*>(pFldType),
- nSubType, m_pImpl->m_pProps->nUSHORT2);
+ case SW_SERVICE_FIELDTYPE_PARAGRAPH_COUNT : nSubType = DS_PARA; break;
+ case SW_SERVICE_FIELDTYPE_WORD_COUNT : nSubType = DS_WORD; break;
+ case SW_SERVICE_FIELDTYPE_CHARACTER_COUNT : nSubType = DS_CHAR; break;
+ case SW_SERVICE_FIELDTYPE_TABLE_COUNT : nSubType = DS_TBL; break;
+ case SW_SERVICE_FIELDTYPE_GRAPHIC_OBJECT_COUNT : nSubType = DS_GRF; break;
+ case SW_SERVICE_FIELDTYPE_EMBEDDED_OBJECT_COUNT : nSubType = DS_OLE; break;
}
- break;
- case SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY:
- {
- SwAuthorityFieldType const type(pDoc);
- pFld = new SwAuthorityField(static_cast<SwAuthorityFieldType*>(
- pDoc->InsertFldType(type)),
- aEmptyStr );
- if (m_pImpl->m_pProps->aPropSeq.getLength())
- {
- uno::Any aVal;
- aVal <<= m_pImpl->m_pProps->aPropSeq;
- pFld->PutValue( aVal, FIELD_PROP_PROP_SEQ );
- }
- }
- break;
- case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS:
- // create field
- pFld = new SwCombinedCharField( (SwCombinedCharFieldType*)
- pDoc->GetSysFldType(RES_COMBINED_CHARS),
- m_pImpl->m_pProps->sPar1);
- break;
- case SW_SERVICE_FIELDTYPE_DROPDOWN:
- {
- SwDropDownField *const pDDField = new SwDropDownField(
- static_cast<SwDropDownFieldType *>(
- pDoc->GetSysFldType(RES_DROPDOWN)));
- pFld = pDDField;
-
- pDDField->SetItems(m_pImpl->m_pProps->aStrings);
- pDDField->SetSelectedItem(m_pImpl->m_pProps->sPar1);
- pDDField->SetName(m_pImpl->m_pProps->sPar2);
- pDDField->SetHelp(m_pImpl->m_pProps->sPar3);
- pDDField->SetToolTip(m_pImpl->m_pProps->sPar4);
- }
- break;
-
- case SW_SERVICE_FIELDTYPE_TABLE_FORMULA :
+ SwFieldType* pFldType = pDoc->GetSysFldType(RES_DOCSTATFLD);
+ pFld = new SwDocStatField(
+ static_cast<SwDocStatFieldType*>(pFldType),
+ nSubType, m_pImpl->m_pProps->nUSHORT2);
+ }
+ break;
+ case SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY:
+ {
+ SwAuthorityFieldType const type(pDoc);
+ pFld = new SwAuthorityField(static_cast<SwAuthorityFieldType*>(
+ pDoc->InsertFldType(type)),
+ aEmptyStr );
+ if (m_pImpl->m_pProps->aPropSeq.getLength())
{
-
- // create field
- sal_uInt16 nType = nsSwGetSetExpType::GSE_FORMULA;
- if (m_pImpl->m_pProps->bBool1)
- {
- nType |= nsSwExtendedSubType::SUB_CMD;
- if (m_pImpl->m_pProps->bFormatIsDefault)
- m_pImpl->m_pProps->nFormat = -1;
- }
- pFld = new SwTblField( (SwTblFieldType*)
- pDoc->GetSysFldType(RES_TABLEFLD),
- m_pImpl->m_pProps->sPar2,
- nType,
- m_pImpl->m_pProps->nFormat);
- ((SwTblField*)pFld)->ChgExpStr(m_pImpl->m_pProps->sPar1);
+ uno::Any aVal;
+ aVal <<= m_pImpl->m_pProps->aPropSeq;
+ pFld->PutValue( aVal, FIELD_PROP_PROP_SEQ );
}
- break;
- default: OSL_FAIL("was ist das fuer ein Typ?");
}
- if(pFld)
+ break;
+ case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS:
+ // create field
+ pFld = new SwCombinedCharField( (SwCombinedCharFieldType*)
+ pDoc->GetSysFldType(RES_COMBINED_CHARS),
+ m_pImpl->m_pProps->sPar1);
+ break;
+ case SW_SERVICE_FIELDTYPE_DROPDOWN:
{
- pFld->SetAutomaticLanguage(!m_pImpl->m_pProps->bBool4);
- SwFmtFld aFmt( *pFld );
+ SwDropDownField *const pDDField = new SwDropDownField(
+ static_cast<SwDropDownFieldType *>(
+ pDoc->GetSysFldType(RES_DROPDOWN)));
+ pFld = pDDField;
+
+ pDDField->SetItems(m_pImpl->m_pProps->aStrings);
+ pDDField->SetSelectedItem(m_pImpl->m_pProps->sPar1);
+ pDDField->SetName(m_pImpl->m_pProps->sPar2);
+ pDDField->SetHelp(m_pImpl->m_pProps->sPar3);
+ pDDField->SetToolTip(m_pImpl->m_pProps->sPar4);
+ }
+ break;
- UnoActionContext aCont(pDoc);
- SwTxtAttr* pTxtAttr = 0;
- if (aPam.HasMark() &&
- m_pImpl->m_nServiceId != SW_SERVICE_FIELDTYPE_ANNOTATION)
+ case SW_SERVICE_FIELDTYPE_TABLE_FORMULA :
+ {
+ // create field
+ sal_uInt16 nType = nsSwGetSetExpType::GSE_FORMULA;
+ if (m_pImpl->m_pProps->bBool1)
{
- pDoc->DeleteAndJoin(aPam);
+ nType |= nsSwExtendedSubType::SUB_CMD;
+ if (m_pImpl->m_pProps->bFormatIsDefault)
+ m_pImpl->m_pProps->nFormat = -1;
}
+ pFld = new SwTblField( (SwTblFieldType*)
+ pDoc->GetSysFldType(RES_TABLEFLD),
+ m_pImpl->m_pProps->sPar2,
+ nType,
+ m_pImpl->m_pProps->nFormat);
+ ((SwTblField*)pFld)->ChgExpStr(m_pImpl->m_pProps->sPar1);
+ }
+ break;
+ default: OSL_FAIL("was ist das fuer ein Typ?");
+ }
+ if (pFld)
+ {
+ pFld->SetAutomaticLanguage(!m_pImpl->m_pProps->bBool4);
+ SwFmtFld aFmt( *pFld );
- SwXTextCursor const*const pTextCursor(
- dynamic_cast<SwXTextCursor*>(pCursor));
- const bool bForceExpandHints( (pTextCursor)
- ? pTextCursor->IsAtEndOfMeta() : false );
- const SetAttrMode nInsertFlags = (bForceExpandHints)
- ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND
- : nsSetAttrMode::SETATTR_DEFAULT;
+ UnoActionContext aCont(pDoc);
+ SwTxtAttr* pTxtAttr = 0;
+ if (aPam.HasMark() &&
+ m_pImpl->m_nServiceId != SW_SERVICE_FIELDTYPE_ANNOTATION)
+ {
+ pDoc->DeleteAndJoin(aPam);
+ }
- if (*aPam.GetPoint() != *aPam.GetMark() &&
- m_pImpl->m_nServiceId == SW_SERVICE_FIELDTYPE_ANNOTATION)
- {
- IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
- sw::mark::IFieldmark* pFieldmark = pMarksAccess->makeFieldBookmark(
- aPam,
- OUString(),
- ODF_COMMENTRANGE);
- SwPostItField* pPostItField = (SwPostItField*)aFmt.GetFld();
- if (pPostItField->GetName().isEmpty())
- // The fieldmark always has a (generated) name.
- pPostItField->SetName(pFieldmark->GetName());
- else
- // The field has a name already, use it.
- pMarksAccess->renameMark(pFieldmark, pPostItField->GetName());
+ SwXTextCursor const*const pTextCursor(
+ dynamic_cast<SwXTextCursor*>(pCursor));
+ const bool bForceExpandHints( (pTextCursor)
+ ? pTextCursor->IsAtEndOfMeta() : false );
+ const SetAttrMode nInsertFlags = (bForceExpandHints)
+ ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND
+ : nsSetAttrMode::SETATTR_DEFAULT;
- // Make sure we always insert the field at the end
- SwPaM aEnd(*aPam.End(), *aPam.End());
- pDoc->InsertPoolItem(aEnd, aFmt, nInsertFlags);
- }
+ if (*aPam.GetPoint() != *aPam.GetMark() &&
+ m_pImpl->m_nServiceId == SW_SERVICE_FIELDTYPE_ANNOTATION)
+ {
+ IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
+ sw::mark::IFieldmark* pFieldmark = pMarksAccess->makeFieldBookmark(
+ aPam,
+ OUString(),
+ ODF_COMMENTRANGE);
+ SwPostItField* pPostItField = (SwPostItField*)aFmt.GetFld();
+ if (pPostItField->GetName().isEmpty())
+ // The fieldmark always has a (generated) name.
+ pPostItField->SetName(pFieldmark->GetName());
else
- pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags);
-
- pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
- aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FIELD);
+ // The field has a name already, use it.
+ pMarksAccess->renameMark(pFieldmark, pPostItField->GetName());
- // was passiert mit dem Update der Felder ? (siehe fldmgr.cxx)
- if(pTxtAttr)
- {
- const SwFmtFld& rFld = pTxtAttr->GetFld();
- m_pImpl->m_pFmtFld = &rFld;
- }
+ // Make sure we always insert the field at the end
+ SwPaM aEnd(*aPam.End(), *aPam.End());
+ pDoc->InsertPoolItem(aEnd, aFmt, nInsertFlags);
}
- delete pFld;
+ else
+ pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags);
- m_pImpl->m_pDoc = pDoc;
- m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get());
- m_pImpl->m_bIsDescriptor = false;
- if (m_pImpl->m_FieldTypeClient.GetRegisteredIn())
+ pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt(
+ aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FIELD);
+
+ // was passiert mit dem Update der Felder ? (siehe fldmgr.cxx)
+ if (pTxtAttr)
{
- const_cast<SwModify*>(m_pImpl->m_FieldTypeClient.GetRegisteredIn())
- ->Remove(&m_pImpl->m_FieldTypeClient);
+ const SwFmtFld& rFld = pTxtAttr->GetFld();
+ m_pImpl->m_pFmtFld = &rFld;
}
- m_pImpl->m_pProps.reset();
- if (m_pImpl->m_bCallUpdate)
- update();
}
- else
- throw lang::IllegalArgumentException();
+ delete pFld;
+
+ m_pImpl->m_pDoc = pDoc;
+ m_pImpl->m_pDoc->GetUnoCallBack()->Add(m_pImpl.get());
+ m_pImpl->m_bIsDescriptor = false;
+ if (m_pImpl->m_FieldTypeClient.GetRegisteredIn())
+ {
+ const_cast<SwModify*>(m_pImpl->m_FieldTypeClient.GetRegisteredIn())
+ ->Remove(&m_pImpl->m_FieldTypeClient);
+ }
+ m_pImpl->m_pProps.reset();
+ if (m_pImpl->m_bCallUpdate)
+ update();
}
uno::Reference< text::XTextRange > SAL_CALL
SwXTextField::getAnchor() throw (uno::RuntimeException)
{
SolarMutexGuard aGuard;
- uno::Reference< text::XTextRange > aRef;
+
SwField const*const pField = m_pImpl->GetField();
- if(pField)
- {
- const SwTxtFld* pTxtFld = m_pImpl->m_pFmtFld->GetTxtFld();
- if(!pTxtFld)
- throw uno::RuntimeException();
- const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
+ if (!pField)
+ return 0;
- SwPaM aPam(rTxtNode, *pTxtFld->GetStart() + 1, rTxtNode, *pTxtFld->GetStart());
+ const SwTxtFld* pTxtFld = m_pImpl->m_pFmtFld->GetTxtFld();
+ if (!pTxtFld)
+ throw uno::RuntimeException();
+ const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
- aRef = SwXTextRange::CreateXTextRange(
- *m_pImpl->m_pDoc, *aPam.GetPoint(), aPam.GetMark());
- }
- return aRef;
+ SwPaM aPam(rTxtNode, *pTxtFld->GetStart() + 1, rTxtNode, *pTxtFld->GetStart());
+ uno::Reference<text::XTextRange> xRange = SwXTextRange::CreateXTextRange(
+ *m_pImpl->m_pDoc, *aPam.GetPoint(), aPam.GetMark());
+ return xRange;
}
void SAL_CALL SwXTextField::dispose() throw (uno::RuntimeException)
@@ -2010,19 +2005,18 @@ throw (uno::RuntimeException)
SolarMutexGuard aGuard;
//kein static
uno::Reference< beans::XPropertySetInfo > aRef;
- if (m_pImpl->m_nServiceId != USHRT_MAX)
+ if (m_pImpl->m_nServiceId == USHRT_MAX)
{
- const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(
- lcl_GetPropertyMapOfService(m_pImpl->m_nServiceId));
- uno::Reference< beans::XPropertySetInfo > xInfo = pPropSet->getPropertySetInfo();
- // extend PropertySetInfo!
- const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
- aRef = new SfxExtItemPropertySetInfo(
- aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_PARAGRAPH_EXTENSIONS),
- aPropSeq );
- }
- else
throw uno::RuntimeException();
+ }
+ const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(
+ lcl_GetPropertyMapOfService(m_pImpl->m_nServiceId));
+ uno::Reference<beans::XPropertySetInfo> xInfo = pPropSet->getPropertySetInfo();
+ // extend PropertySetInfo!
+ const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
+ aRef = new SfxExtItemPropertySetInfo(
+ aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_PARAGRAPH_EXTENSIONS),
+ aPropSeq );
return aRef;
}
commit 15f431e595d0e0bd24ab185ab552d39a56d55986
Author: Michael Stahl <mstahl at redhat.com>
Date: Tue Jun 11 21:49:44 2013 +0200
fdo#65478, i#105557: thread safety of SwXTextField
- implement SwClient on Impl class
- add a WeakReference to SwFmtFld create the SwXTextField from,
instead of racy iteration of SwModify clients
Change-Id: Ia71b4fcbfceaa367a516a8353a4b66123d72305a
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 1ea8cca..f18d31a 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -16,10 +16,15 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _FMTFLD_HXX
-#define _FMTFLD_HXX
+
+#ifndef SW_FMTFLD_HXX
+#define SW_FMTFLD_HXX
#include <list>
+
+#include <com/sun/star/text/XTextField.hpp>
+
+#include <cppuhelper/weakref.hxx>
#include <svl/poolitem.hxx>
#include <svl/brdcst.hxx>
#include <svl/smplhint.hxx>
@@ -38,6 +43,9 @@ class SW_DLLPUBLIC SwFmtFld : public SfxPoolItem, public SwClient, public SfxBro
friend class SwTxtFld;
friend void _InitCore();
+ ::com::sun::star::uno::WeakReference<
+ ::com::sun::star::text::XTextField> m_wXTextField;
+
SwField *pField;
SwTxtFld* pTxtAttr;
@@ -86,6 +94,13 @@ public:
void RegisterToFieldType( SwFieldType& );
sal_Bool IsFldInDoc() const;
sal_Bool IsProtect() const;
+
+ SW_DLLPRIVATE ::com::sun::star::uno::WeakReference<
+ ::com::sun::star::text::XTextField> const& GetXTextField() const
+ { return m_wXTextField; }
+ SW_DLLPRIVATE void SetXTextField(::com::sun::star::uno::Reference<
+ ::com::sun::star::text::XTextField> const& xTextField)
+ { m_wXTextField = xTextField; }
};
class SW_DLLPUBLIC SwFmtFldHint : public SfxHint
diff --git a/sw/source/core/inc/unofield.hxx b/sw/source/core/inc/unofield.hxx
index 3418c55..913e2ae 100644
--- a/sw/source/core/inc/unofield.hxx
+++ b/sw/source/core/inc/unofield.hxx
@@ -154,96 +154,141 @@ public:
};
-struct SwFieldProperties_Impl;
-class SwXTextField : public cppu::WeakImplHelper5
-<
- ::com::sun::star::text::XDependentTextField,
- ::com::sun::star::lang::XServiceInfo,
- ::com::sun::star::beans::XPropertySet,
- ::com::sun::star::lang::XUnoTunnel,
- ::com::sun::star::util::XUpdatable
->,
- public SwClient
+
+typedef ::cppu::WeakImplHelper5
+< ::com::sun::star::text::XDependentTextField
+, ::com::sun::star::lang::XServiceInfo
+, ::com::sun::star::beans::XPropertySet
+, ::com::sun::star::lang::XUnoTunnel
+, ::com::sun::star::util::XUpdatable
+> SwXTextField_Base;
+
+class SwXTextField
+ : public SwXTextField_Base
{
private:
class Impl;
::sw::UnoImplPtr<Impl> m_pImpl;
- const SwFmtFld* pFmtFld;
- SwDoc* m_pDoc;
- SwTextAPIObject* m_pTextObject;
-
- sal_Bool m_bIsDescriptor;
- SwClient m_aFieldTypeClient; // required to access field master of not yet inserted fields
- sal_Bool m_bCallUpdate;
- sal_uInt16 m_nServiceId;
- SwFieldProperties_Impl* m_pProps;
- String m_sTypeName;
-
-
- //SwFieldType* GetFldType() const { return (SwFieldType*)GetRegisteredIn(); }
- SwDoc* GetDoc() {return m_pDoc;}
-protected:
virtual ~SwXTextField();
- //SwClient
- virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
+
+ SwXTextField(const SwFmtFld& rFmt, SwDoc & rDoc);
public:
+ /// descriptor
SwXTextField(sal_uInt16 nServiceId, SwDoc* pDoc=0);
- SwXTextField(const SwFmtFld& rFmt, SwDoc* pDoc);
+ sal_uInt16 GetServiceId() const;
- TYPEINFO();
+ /// @return an SwXTextField, either an already existing one or a new one
+ static ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField>
+ CreateXTextField(SwDoc & rDoc, SwFmtFld const& rFmt);
static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId();
- //XUnoTunnel
- virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
-
- //XDependentTextField
- virtual void SAL_CALL attachTextFieldMaster(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xFieldMaster) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getTextFieldMaster(void) throw( ::com::sun::star::uno::RuntimeException );
-
- //XTextField
- virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand) throw( ::com::sun::star::uno::RuntimeException );
-
- //XTextContent
- virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor(void) throw( ::com::sun::star::uno::RuntimeException );
+ // XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething(
+ const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier)
+ throw (::com::sun::star::uno::RuntimeException);
- //XComponent
- virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
- virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException );
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(
+ const OUString& rServiceName)
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
+ getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
- //XPropertySet
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ // XComponent
+ virtual void SAL_CALL dispose()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener > & xListener)
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XEventListener > & xListener)
+ throw (::com::sun::star::uno::RuntimeException);
- //XServiceInfo
- virtual OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException );
- virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException );
- virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException );
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue(
+ const OUString& rPropertyName,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::beans::PropertyVetoException,
+ ::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
+ const OUString& rPropertyName)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener(
+ const OUString& rPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertyChangeListener >& xListener)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener(
+ const OUString& rPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertyChangeListener >& xListener)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener(
+ const OUString& rPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XVetoableChangeListener >& xListener)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener(
+ const OUString& rPropertyName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XVetoableChangeListener >& xListener)
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
- //XUpdatable
- virtual void SAL_CALL update( ) throw (::com::sun::star::uno::RuntimeException);
+ // XUpdatable
+ virtual void SAL_CALL update()
+ throw (::com::sun::star::uno::RuntimeException);
- void attachToRange(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange)throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException );
+ // XTextContent
+ virtual void SAL_CALL attach(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::text::XTextRange > & xTextRange)
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::text::XTextRange > SAL_CALL getAnchor()
+ throw (::com::sun::star::uno::RuntimeException);
- const SwField* GetField() const;
- const SwFmtFld* GetFldFmt(){return GetField() ? pFmtFld : 0; };
+ // XTextField
+ virtual OUString SAL_CALL getPresentation(sal_Bool bShowCommand)
+ throw (::com::sun::star::uno::RuntimeException);
- void Invalidate();
+ // XDependentTextField
+ virtual void SAL_CALL attachTextFieldMaster(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > & xFieldMaster)
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet> SAL_CALL getTextFieldMaster()
+ throw (::com::sun::star::uno::RuntimeException);
- /// @return an SwXTextField, either an already existing one or a new one
- static SwXTextField* CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt);
- sal_uInt16 GetServiceId();
};
class SwXFieldEnumeration : public cppu::WeakImplHelper2
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index d949481..f2b3a5d 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -525,9 +525,10 @@ bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry
{
if( pAny )
{
- SwXTextField* pField = SwXTextField::CreateSwXTextField(*rPam.GetDoc(),
- pTxtAttr->GetFld());
- *pAny <<= uno::Reference< XTextField >( pField );
+ uno::Reference<text::XTextField> const xField(
+ SwXTextField::CreateXTextField(*rPam.GetDoc(),
+ pTxtAttr->GetFld()));
+ *pAny <<= xField;
}
}
else
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index c473b0e..0a919c8 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -636,7 +636,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
case RES_DDEFLD :
{
SwDDEFieldType aType(sTypeName, m_pImpl->m_sParam1,
- sal::static_int_cast< sal_uInt16 >((m_pImpl->m_bParam1)
+ sal::static_int_cast<sal_uInt16>((m_pImpl->m_bParam1)
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list