summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorValentin Kettner <vakevk+libreoffice@gmail.com>2014-07-24 16:46:12 +0200
committerValentin Kettner <vakevk+libreoffice@gmail.com>2014-08-12 23:26:36 +0200
commit69e5f335abcd838ad6dac04f8e2d14f39856dc43 (patch)
tree19b7e1a929576ec4da8ca981d8aee7a519b119bd /sw/source/core
parent274f1811b92b870b8d450423d9b280b0889ca130 (diff)
Refactored IDocumentFieldsAccess out of SwDoc.
Into the new class DocumentFieldsManager. Removed SwDoc::_MakeFldList because it is not defined anywhere. Also moved a few non interface methods that belong to the manager. Change-Id: Icefd7ca7adcbb05a18d6fae0529fc54150b862fd
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/attr/format.cxx2
-rw-r--r--sw/source/core/bastyp/calc.cxx3
-rw-r--r--sw/source/core/crsr/annotationmark.cxx3
-rw-r--r--sw/source/core/crsr/crstrvl.cxx7
-rw-r--r--sw/source/core/doc/CntntIdxStore.cxx6
-rw-r--r--sw/source/core/doc/DocumentFieldsManager.cxx1667
-rw-r--r--sw/source/core/doc/DocumentTimerManager.cxx21
-rw-r--r--sw/source/core/doc/doc.cxx68
-rw-r--r--sw/source/core/doc/docdesc.cxx5
-rw-r--r--sw/source/core/doc/docfld.cxx1567
-rw-r--r--sw/source/core/doc/docfmt.cxx3
-rw-r--r--sw/source/core/doc/docftn.cxx5
-rw-r--r--sw/source/core/doc/docglos.cxx11
-rw-r--r--sw/source/core/doc/doclay.cxx9
-rw-r--r--sw/source/core/doc/docnew.cxx21
-rw-r--r--sw/source/core/doc/docnum.cxx3
-rw-r--r--sw/source/core/doc/docsort.cxx3
-rw-r--r--sw/source/core/doc/doctxm.cxx5
-rw-r--r--sw/source/core/doc/tblcpy.cxx7
-rw-r--r--sw/source/core/doc/tblrwcl.cxx7
-rw-r--r--sw/source/core/docnode/ndcopy.cxx5
-rw-r--r--sw/source/core/docnode/ndnum.cxx3
-rw-r--r--sw/source/core/docnode/ndsect.cxx5
-rw-r--r--sw/source/core/docnode/ndtbl.cxx47
-rw-r--r--sw/source/core/docnode/node.cxx4
-rw-r--r--sw/source/core/docnode/nodedump.cxx5
-rw-r--r--sw/source/core/docnode/nodes.cxx11
-rw-r--r--sw/source/core/docnode/section.cxx9
-rw-r--r--sw/source/core/edit/edfld.cxx31
-rw-r--r--sw/source/core/edit/edfldexp.cxx3
-rw-r--r--sw/source/core/edit/edglss.cxx9
-rw-r--r--sw/source/core/edit/editsh.cxx3
-rw-r--r--sw/source/core/edit/edtab.cxx5
-rw-r--r--sw/source/core/fields/authfld.cxx5
-rw-r--r--sw/source/core/fields/dbfld.cxx5
-rw-r--r--sw/source/core/fields/ddetbl.cxx3
-rw-r--r--sw/source/core/fields/docufld.cxx3
-rw-r--r--sw/source/core/fields/expfld.cxx11
-rw-r--r--sw/source/core/fields/fldlst.cxx5
-rw-r--r--sw/source/core/fields/reffld.cxx11
-rw-r--r--sw/source/core/fields/usrfld.cxx3
-rw-r--r--sw/source/core/frmedt/fecopy.cxx33
-rw-r--r--sw/source/core/inc/DocumentFieldsManager.hxx106
-rw-r--r--sw/source/core/layout/flowfrm.cxx5
-rw-r--r--sw/source/core/layout/frmtool.cxx3
-rw-r--r--sw/source/core/layout/newfrm.cxx1
-rw-r--r--sw/source/core/layout/pagechg.cxx7
-rw-r--r--sw/source/core/layout/tabfrm.cxx3
-rw-r--r--sw/source/core/layout/wsfrm.cxx3
-rw-r--r--sw/source/core/table/swtable.cxx3
-rw-r--r--sw/source/core/text/txtfrm.cxx1
-rw-r--r--sw/source/core/txtnode/atrfld.cxx2
-rw-r--r--sw/source/core/txtnode/thints.cxx17
-rw-r--r--sw/source/core/txtnode/txtedt.cxx2
-rw-r--r--sw/source/core/undo/SwUndoField.cxx15
-rw-r--r--sw/source/core/undo/rolbck.cxx7
-rw-r--r--sw/source/core/undo/unsect.cxx3
-rw-r--r--sw/source/core/undo/untbl.cxx19
-rw-r--r--sw/source/core/unocore/unocoll.cxx5
-rw-r--r--sw/source/core/unocore/unofield.cxx95
-rw-r--r--sw/source/core/unocore/unotbl.cxx5
-rw-r--r--sw/source/core/view/printdata.cxx2
-rw-r--r--sw/source/core/view/viewsh.cxx15
-rw-r--r--sw/source/core/view/vnew.cxx5
-rw-r--r--sw/source/core/view/vprint.cxx3
65 files changed, 2117 insertions, 1852 deletions
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 9af7f6a9cc20..2779e7456018 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -766,7 +766,7 @@ IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return & GetDoc
const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return & GetDoc()->getIDocumentTimerAccess(); }
-IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
+IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return &GetDoc()->getIDocumentFieldsAccess(); }
IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return & GetDoc()->getIDocumentChartDataProviderAccess(); }
void SwFmt::GetGrabBagItem(uno::Any& rVal) const
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 5e637d0fd29c..5b95e33a17b4 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -32,6 +32,7 @@
#include <docfld.hxx>
#include <docstat.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <editeng/langitem.hxx>
#include <editeng/scripttypeitem.hxx>
#include <editeng/unolingu.hxx>
@@ -456,7 +457,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, sal_uInt16 ins )
if( !pFnd )
{
// then check doc
- SwHash** ppDocTbl = rDoc.GetUpdtFlds().GetFldTypeTable();
+ SwHash** ppDocTbl = rDoc.getIDocumentFieldsAccess().GetUpdtFlds().GetFldTypeTable();
for( SwHash* pEntry = *(ppDocTbl+ii); pEntry; pEntry = pEntry->pNext )
{
if( aStr == pEntry->aStr )
diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx
index 95faaa52fe90..faa379ccfa52 100644
--- a/sw/source/core/crsr/annotationmark.cxx
+++ b/sw/source/core/crsr/annotationmark.cxx
@@ -21,6 +21,7 @@
#include <doc.hxx>
#include <IDocumentMarkAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <fldbas.hxx>
#include <switerator.hxx>
#include <fmtfld.hxx>
@@ -88,7 +89,7 @@ namespace sw { namespace mark
SwFmtFld* pAnnotationFmtFld = NULL;
- SwFieldType* pType = pDoc->GetFldType( RES_POSTITFLD, OUString(), false );
+ SwFieldType* pType = pDoc->getIDocumentFieldsAccess().GetFldType( RES_POSTITFLD, OUString(), false );
SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld != NULL; pFmtFld = aIter.Next() )
{
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 856a5265ff3f..161b10f1081e 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -28,6 +28,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <pagefrm.hxx>
#include <cntfrm.hxx>
#include <rootfrm.hxx>
@@ -628,7 +629,7 @@ bool SwCrsrShell::MoveFldType(
if( RES_INPUTFLD == pFldType->Which() && bAddSetExpressionFldsToInputFlds )
{
// there are hidden input fields in the set exp. fields
- const SwFldTypes& rFldTypes = *mpDoc->GetFldTypes();
+ const SwFldTypes& rFldTypes = *mpDoc->getIDocumentFieldsAccess().GetFldTypes();
const size_t nSize = rFldTypes.size();
for( size_t i=0; i < nSize; ++i )
{
@@ -642,7 +643,7 @@ bool SwCrsrShell::MoveFldType(
}
else
{
- const SwFldTypes& rFldTypes = *mpDoc->GetFldTypes();
+ const SwFldTypes& rFldTypes = *mpDoc->getIDocumentFieldsAccess().GetFldTypes();
const size_t nSize = rFldTypes.size();
for( size_t i=0; i < nSize; ++i )
{
@@ -675,7 +676,7 @@ bool SwCrsrShell::MoveFldType(
{
// create dummy for the search
SwFmtFld* pFmtFld = new SwFmtFld( SwDateTimeField(
- (SwDateTimeFieldType*)mpDoc->GetSysFldType( RES_DATETIMEFLD ) ) );
+ (SwDateTimeFieldType*)mpDoc->getIDocumentFieldsAccess().GetSysFldType( RES_DATETIMEFLD ) ) );
pTxtFld = new SwTxtFld( *pFmtFld, rPos.nContent.GetIndex(),
mpDoc->IsClipBoard() );
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index ee22f8690e51..ffbd356f236f 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -23,6 +23,7 @@
#include <boost/make_shared.hpp>
#include <cntfrm.hxx>
#include <doc.hxx>
+#include <IDocumentRedlineAccess.hxx>
#include <docary.hxx>
#include <editsh.hxx>
#include <fmtanchr.hxx>
@@ -264,8 +265,9 @@ void CntntIdxStoreImpl::RestoreBkmks(SwDoc* pDoc, updater_t& rUpdater)
void CntntIdxStoreImpl::SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
{
+ SwRedlineTbl const & pRedlineTbl = pDoc->getIDocumentRedlineAccess().GetRedlineTbl();
long int nIdx = 0;
- BOOST_FOREACH(const SwRangeRedline* pRdl, pDoc->GetRedlineTbl())
+ BOOST_FOREACH(const SwRangeRedline* pRdl, std::make_pair(pRedlineTbl.begin(), pRedlineTbl.end()))
{
int nPointPos = lcl_RelativePosition( *pRdl->GetPoint(), nNode, nCntnt );
int nMarkPos = pRdl->HasMark() ? lcl_RelativePosition( *pRdl->GetMark(), nNode, nCntnt ) :
@@ -291,7 +293,7 @@ void CntntIdxStoreImpl::SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCn
void CntntIdxStoreImpl::RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater)
{
- const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
+ const SwRedlineTbl& rRedlTbl = pDoc->getIDocumentRedlineAccess().GetRedlineTbl();
BOOST_FOREACH(const MarkEntry& aEntry, m_aRedlineEntries)
{
SwPosition* const pPos = (SwPosition*)( aEntry.m_bOther
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
new file mode 100644
index 000000000000..ddd557b11a63
--- /dev/null
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -0,0 +1,1667 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with &m_rSwdoc work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <DocumentFieldsManager.hxx>
+#include <config_features.h>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <dbmgr.hxx>
+#include <chpfld.hxx>
+#include <dbfld.hxx>
+#include <reffld.hxx>
+#include <flddropdown.hxx>
+#include <poolfmt.hrc>
+#include <SwUndoField.hxx>
+#include <flddat.hxx>
+#include <cntfrm.hxx>
+#include <dbfld.hxx>
+#include <section.hxx>
+#include <docufld.hxx>
+#include <switerator.hxx>
+#include <cellatr.hxx>
+#include <swtable.hxx>
+#include <frmfmt.hxx>
+#include <fmtfld.hxx>
+#include <ndtxt.hxx>
+#include <txtfld.hxx>
+#include <docfld.hxx>
+#include <hints.hxx>
+#include <docary.hxx>
+#include <fldbas.hxx>
+#include <expfld.hxx>
+#include <ddefld.hxx>
+#include <authfld.hxx>
+#include <usrfld.hxx>
+#include <unotools/transliterationwrapper.hxx>
+#include <com/sun/star/uno/Any.hxx>
+
+using namespace ::com::sun::star::uno;
+
+namespace
+{
+ #if HAVE_FEATURE_DBCONNECTIVITY
+
+ static OUString lcl_GetDBVarName( SwDoc& rDoc, SwDBNameInfField& rDBFld )
+ {
+ SwDBData aDBData( rDBFld.GetDBData( &rDoc ));
+ OUString sDBNumNm;
+ SwDBData aDocData = rDoc.GetDBData();
+
+ if( aDBData != aDocData )
+ {
+ sDBNumNm = aDBData.sDataSource;
+ sDBNumNm += OUString(DB_DELIM);
+ sDBNumNm += aDBData.sCommand;
+ sDBNumNm += OUString(DB_DELIM);
+ }
+ sDBNumNm += SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD);
+
+ return sDBNumNm;
+ }
+
+ #endif
+
+ static void lcl_CalcFld( SwDoc& rDoc, SwCalc& rCalc, const _SetGetExpFld& rSGEFld,
+ SwDBManager* pMgr )
+ {
+ const SwTxtFld* pTxtFld = rSGEFld.GetTxtFld();
+ if( !pTxtFld )
+ return ;
+
+ const SwField* pFld = pTxtFld->GetFmtFld().GetField();
+ const sal_uInt16 nFldWhich = pFld->GetTyp()->Which();
+
+ if( RES_SETEXPFLD == nFldWhich )
+ {
+ SwSbxValue aValue;
+ if( nsSwGetSetExpType::GSE_EXPR & pFld->GetSubType() )
+ aValue.PutDouble( ((SwSetExpField*)pFld)->GetValue() );
+ else
+ // Extension to calculate with Strings
+ aValue.PutString( ((SwSetExpField*)pFld)->GetExpStr() );
+
+ // set the new value in Calculator
+ rCalc.VarChange( pFld->GetTyp()->GetName(), aValue );
+ }
+ else if( pMgr )
+ {
+ #if !HAVE_FEATURE_DBCONNECTIVITY
+ (void) rDoc;
+ #else
+ switch( nFldWhich )
+ {
+ case RES_DBNUMSETFLD:
+ {
+ SwDBNumSetField* pDBFld = (SwDBNumSetField*)pFld;
+
+ SwDBData aDBData(pDBFld->GetDBData(&rDoc));
+
+ if( pDBFld->IsCondValid() &&
+ pMgr->OpenDataSource( aDBData.sDataSource, aDBData.sCommand ))
+ rCalc.VarChange( lcl_GetDBVarName( rDoc, *pDBFld),
+ pDBFld->GetFormat() );
+ }
+ break;
+ case RES_DBNEXTSETFLD:
+ {
+ SwDBNextSetField* pDBFld = (SwDBNextSetField*)pFld;
+ SwDBData aDBData(pDBFld->GetDBData(&rDoc));
+ if( !pDBFld->IsCondValid() ||
+ !pMgr->OpenDataSource( aDBData.sDataSource, aDBData.sCommand ))
+ break;
+
+ OUString sDBNumNm(lcl_GetDBVarName( rDoc, *pDBFld));
+ SwCalcExp* pExp = rCalc.VarLook( sDBNumNm );
+ if( pExp )
+ rCalc.VarChange( sDBNumNm, pExp->nValue.GetLong() + 1 );
+ }
+ break;
+
+ }
+ #endif
+ }
+ }
+}
+
+namespace sw
+{
+
+DocumentFieldsManager::DocumentFieldsManager( SwDoc& i_rSwdoc ) : m_rSwdoc( i_rSwdoc ),
+ mbNewFldLst(true),
+ mpUpdtFlds( new SwDocUpdtFld( &m_rSwdoc ) ),
+ mpFldTypes( new SwFldTypes() ),
+ mnLockExpFld( 0 )
+{
+}
+
+const SwFldTypes* DocumentFieldsManager::GetFldTypes() const
+{
+ return mpFldTypes;
+}
+
+/** Insert field types
+ *
+ * @param rFldTyp ???
+ * @return Always returns a pointer to the type, if it's new or already added.
+ */
+SwFieldType* DocumentFieldsManager::InsertFldType(const SwFieldType &rFldTyp)
+{
+ sal_uInt16 nSize = mpFldTypes->size(),
+ nFldWhich = rFldTyp.Which();
+
+ sal_uInt16 i = INIT_FLDTYPES;
+
+ switch( nFldWhich )
+ {
+ case RES_SETEXPFLD:
+ //JP 29.01.96: SequenceFields start at INIT_FLDTYPES - 3!!
+ // Or we get doubble number circles!!
+ //MIB 14.03.95: From now on also the SW3-Reader relies on &m_rSwdoc, when
+ //constructing string pools and when reading SetExp fields
+ if( nsSwGetSetExpType::GSE_SEQ & ((SwSetExpFieldType&)rFldTyp).GetType() )
+ i -= INIT_SEQ_FLDTYPES;
+ // no break;
+ case RES_DBFLD:
+ case RES_USERFLD:
+ case RES_DDEFLD:
+ {
+ const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
+ OUString sFldNm( rFldTyp.GetName() );
+ for( ; i < nSize; ++i )
+ if( nFldWhich == (*mpFldTypes)[i]->Which() &&
+ rSCmp.isEqual( sFldNm, (*mpFldTypes)[i]->GetName() ))
+ return (*mpFldTypes)[i];
+ }
+ break;
+
+ case RES_AUTHORITY:
+ for( ; i < nSize; ++i )
+ if( nFldWhich == (*mpFldTypes)[i]->Which() )
+ return (*mpFldTypes)[i];
+ break;
+
+ default:
+ for( i = 0; i < nSize; ++i )
+ if( nFldWhich == (*mpFldTypes)[i]->Which() )
+ return (*mpFldTypes)[i];
+ }
+
+ SwFieldType* pNew = rFldTyp.Copy();
+ switch( nFldWhich )
+ {
+ case RES_DDEFLD:
+ ((SwDDEFieldType*)pNew)->SetDoc( &m_rSwdoc );
+ break;
+
+ case RES_DBFLD:
+ case RES_TABLEFLD:
+ case RES_DATETIMEFLD:
+ case RES_GETEXPFLD:
+ ((SwValueFieldType*)pNew)->SetDoc( &m_rSwdoc );
+ break;
+
+ case RES_USERFLD:
+ case RES_SETEXPFLD:
+ ((SwValueFieldType*)pNew)->SetDoc( &m_rSwdoc );
+ // JP 29.07.96: Optionally prepare FieldList for Calculator:
+ mpUpdtFlds->InsertFldType( *pNew );
+ break;
+ case RES_AUTHORITY :
+ ((SwAuthorityFieldType*)pNew)->SetDoc( &m_rSwdoc );
+ break;
+ }
+
+ mpFldTypes->insert( mpFldTypes->begin() + nSize, pNew );
+ m_rSwdoc.SetModified();
+
+ return (*mpFldTypes)[ nSize ];
+}
+
+/// @returns the field type of the Doc
+SwFieldType *DocumentFieldsManager::GetSysFldType( const sal_uInt16 eWhich ) const
+{
+ for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i )
+ if( eWhich == (*mpFldTypes)[i]->Which() )
+ return (*mpFldTypes)[i];
+ return 0;
+}
+
+/// Find first type with ResId and name
+SwFieldType* DocumentFieldsManager::GetFldType(
+ sal_uInt16 nResId,
+ const OUString& rName,
+ bool bDbFieldMatching // used in some UNO calls for RES_DBFLD to use different string matching code #i51815#
+ ) const
+{
+ sal_uInt16 nSize = mpFldTypes->size(), i = 0;
+ const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
+
+ switch( nResId )
+ {
+ case RES_SETEXPFLD:
+ //JP 29.01.96: SequenceFields start at INIT_FLDTYPES - 3!!
+ // Or we get doubble number circles!!
+ //MIB 14.03.95: From now on also the SW3-Reader relies on &m_rSwdoc, when
+ //constructing string pools and when reading SetExp fields
+ i = INIT_FLDTYPES - INIT_SEQ_FLDTYPES;
+ break;
+
+ case RES_DBFLD:
+ case RES_USERFLD:
+ case RES_DDEFLD:
+ case RES_AUTHORITY:
+ i = INIT_FLDTYPES;
+ break;
+ }
+
+ SwFieldType* pRet = 0;
+ for( ; i < nSize; ++i )
+ {
+ SwFieldType* pFldType = (*mpFldTypes)[i];
+
+ OUString aFldName( pFldType->GetName() );
+ if (bDbFieldMatching && nResId == RES_DBFLD) // #i51815#
+ aFldName = aFldName.replace(DB_DELIM, '.');
+
+ if( nResId == pFldType->Which() &&
+ rSCmp.isEqual( rName, aFldName ))
+ {
+ pRet = pFldType;
+ break;
+ }
+ }
+ return pRet;
+}
+
+/// Remove field type
+void DocumentFieldsManager::RemoveFldType(sal_uInt16 nFld)
+{
+ OSL_ENSURE( INIT_FLDTYPES <= nFld, "don't remove InitFlds" );
+ /*
+ * Dependent fields present -> ErrRaise
+ */
+ sal_uInt16 nSize = mpFldTypes->size();
+ if(nFld < nSize)
+ {
+ SwFieldType* pTmp = (*mpFldTypes)[nFld];
+
+ // JP 29.07.96: Optionally prepare FldLst for Calculator
+ sal_uInt16 nWhich = pTmp->Which();
+ switch( nWhich )
+ {
+ case RES_SETEXPFLD:
+ case RES_USERFLD:
+ mpUpdtFlds->RemoveFldType( *pTmp );
+ // no break;
+ case RES_DDEFLD:
+ if( pTmp->GetDepends() && !m_rSwdoc.IsUsed( *pTmp ) )
+ {
+ if( RES_SETEXPFLD == nWhich )
+ ((SwSetExpFieldType*)pTmp)->SetDeleted( true );
+ else if( RES_USERFLD == nWhich )
+ ((SwUserFieldType*)pTmp)->SetDeleted( true );
+ else
+ ((SwDDEFieldType*)pTmp)->SetDeleted( true );
+ nWhich = 0;
+ }
+ break;
+ }
+
+ if( nWhich )
+ {
+ OSL_ENSURE( !pTmp->GetDepends(), "Dependent fields present!" );
+ // delete field type
+ delete pTmp;
+ }
+ mpFldTypes->erase( mpFldTypes->begin() + nFld );
+ m_rSwdoc.SetModified();
+ }
+}
+
+// All have to be re-evaluated.
+void DocumentFieldsManager::UpdateFlds( SfxPoolItem *pNewHt, bool bCloseDB )
+{
+ // Call Modify() for every field type,
+ // dependent SwTxtFld get notified ...
+
+ for( sal_uInt16 i=0; i < mpFldTypes->size(); ++i)
+ {
+ switch( (*mpFldTypes)[i]->Which() )
+ {
+ // Update table fields second to last
+ // Update references last
+ case RES_GETREFFLD:
+ case RES_TABLEFLD:
+ case RES_DBFLD:
+ case RES_JUMPEDITFLD:
+ case RES_REFPAGESETFLD: // are never expanded!
+ break;
+
+ case RES_DDEFLD:
+ {
+ if( !pNewHt )
+ {
+ SwMsgPoolItem aUpdateDDE( RES_UPDATEDDETBL );
+ (*mpFldTypes)[i]->ModifyNotification( 0, &aUpdateDDE );
+ }
+ else
+ (*mpFldTypes)[i]->ModifyNotification( 0, pNewHt );
+ break;
+ }
+ case RES_GETEXPFLD:
+ case RES_SETEXPFLD:
+ case RES_HIDDENTXTFLD:
+ case RES_HIDDENPARAFLD:
+ // Expression fields are treated separately
+ if( !pNewHt )
+ break;
+ default:
+ (*mpFldTypes)[i]->ModifyNotification ( 0, pNewHt );
+ }
+ }
+
+ if( !IsExpFldsLocked() )
+ UpdateExpFlds( 0, false ); // update expression fields
+
+ // Tables
+ UpdateTblFlds(pNewHt);
+
+ // References
+ UpdateRefFlds(pNewHt);
+ if( bCloseDB )
+ {
+#if HAVE_FEATURE_DBCONNECTIVITY
+ m_rSwdoc.GetDBManager()->CloseAll();
+#endif
+ }
+ // Only evaluate on full update
+ m_rSwdoc.SetModified();
+}
+
+void DocumentFieldsManager::InsDeletedFldType( SwFieldType& rFldTyp )
+{
+ // The FldType was marked as deleted and removed from the array.
+ // One has to look &m_rSwdoc up again, now.
+ // - If it's not present, it can be re-inserted.
+ // - If the same type is found, the deleted one has to be renamed.
+
+ sal_uInt16 nSize = mpFldTypes->size(), nFldWhich = rFldTyp.Which();
+ sal_uInt16 i = INIT_FLDTYPES;
+
+ OSL_ENSURE( RES_SETEXPFLD == nFldWhich ||
+ RES_USERFLD == nFldWhich ||
+ RES_DDEFLD == nFldWhich, "Wrong FldType" );
+
+ const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
+ const OUString& rFldNm = rFldTyp.GetName();
+ SwFieldType* pFnd;
+
+ for( ; i < nSize; ++i )
+ if( nFldWhich == (pFnd = (*mpFldTypes)[i])->Which() &&
+ rSCmp.isEqual( rFldNm, pFnd->GetName() ) )
+ {
+ // find new name
+ sal_uInt16 nNum = 1;
+ do {
+ OUString sSrch = rFldNm + OUString::number( nNum );
+ for( i = INIT_FLDTYPES; i < nSize; ++i )
+ if( nFldWhich == (pFnd = (*mpFldTypes)[i])->Which() &&
+ rSCmp.isEqual( sSrch, pFnd->GetName() ) )
+ break;
+
+ if( i >= nSize ) // not found
+ {
+ ((OUString&)rFldNm) = sSrch;
+ break; // exit while loop
+ }
+ ++nNum;
+ } while( true );
+ break;
+ }
+
+ // not found, so insert and delete flag
+ mpFldTypes->insert( mpFldTypes->begin() + nSize, &rFldTyp );
+ switch( nFldWhich )
+ {
+ case RES_SETEXPFLD:
+ ((SwSetExpFieldType&)rFldTyp).SetDeleted( false );
+ break;
+ case RES_USERFLD:
+ ((SwUserFieldType&)rFldTyp).SetDeleted( false );
+ break;
+ case RES_DDEFLD:
+ ((SwDDEFieldType&)rFldTyp).SetDeleted( false );
+ break;
+ }
+}
+
+bool DocumentFieldsManager::PutValueToField(const SwPosition & rPos,
+ const Any& rVal, sal_uInt16 nWhich)
+{
+ Any aOldVal;
+ SwField * pField = GetFieldAtPos(rPos);
+
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo() &&
+ pField->QueryValue(aOldVal, nWhich))
+ {
+ SwUndo *const pUndo(new SwUndoFieldFromAPI(rPos, aOldVal, rVal, nWhich));
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+
+ return pField->PutValue(rVal, nWhich);
+}
+
+bool DocumentFieldsManager::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld,
+ SwMsgPoolItem * pMsgHnt,
+ bool bUpdateFlds)
+{
+ OSL_ENSURE(pDstTxtFld, "no field to update!");
+
+ bool bTblSelBreak = false;
+
+ SwFmtFld * pDstFmtFld = (SwFmtFld*)&pDstTxtFld->GetFmtFld();
+ SwField * pDstFld = pDstFmtFld->GetField();
+ sal_uInt16 nFldWhich = rSrcFld.GetTyp()->Which();
+ SwNodeIndex aTblNdIdx(pDstTxtFld->GetTxtNode());
+
+ if (pDstFld->GetTyp()->Which() ==
+ rSrcFld.GetTyp()->Which())
+ {
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ SwPosition aPosition( pDstTxtFld->GetTxtNode() );
+ aPosition.nContent = pDstTxtFld->GetStart();
+
+ SwUndo *const pUndo( new SwUndoFieldFromDoc( aPosition, *pDstFld, rSrcFld, pMsgHnt, bUpdateFlds) );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+
+ SwField * pNewFld = rSrcFld.CopyField();
+ pDstFmtFld->SetField(pNewFld);
+
+ switch( nFldWhich )
+ {
+ case RES_SETEXPFLD:
+ case RES_GETEXPFLD:
+ case RES_HIDDENTXTFLD:
+ case RES_HIDDENPARAFLD:
+ UpdateExpFlds( pDstTxtFld, true );
+ break;
+
+ case RES_TABLEFLD:
+ {
+ const SwTableNode* pTblNd =
+ m_rSwdoc.IsIdxInTbl(aTblNdIdx);
+ if( pTblNd )
+ {
+ SwTableFmlUpdate aTblUpdate( &pTblNd->
+ GetTable() );
+ if (bUpdateFlds)
+ UpdateTblFlds( &aTblUpdate );
+ else
+ pNewFld->GetTyp()->ModifyNotification(0, &aTblUpdate);
+
+ if (! bUpdateFlds)
+ bTblSelBreak = true;
+ }
+ }
+ break;
+
+ case RES_MACROFLD:
+ if( bUpdateFlds && pDstTxtFld->GetpTxtNode() )
+ (pDstTxtFld->GetpTxtNode())->
+ ModifyNotification( 0, pDstFmtFld );
+ break;
+
+ case RES_DBNAMEFLD:
+ case RES_DBNEXTSETFLD:
+ case RES_DBNUMSETFLD:
+ case RES_DBSETNUMBERFLD:
+ m_rSwdoc.ChgDBData(((SwDBNameInfField*) pNewFld)->GetRealDBData());
+ pNewFld->GetTyp()->UpdateFlds();
+
+ break;
+
+ case RES_DBFLD:
+#if HAVE_FEATURE_DBCONNECTIVITY
+ {
+ // JP 10.02.96: call ChgValue, so that the style change sets the
+ // ContentString correctly
+ SwDBField* pDBFld = (SwDBField*)pNewFld;
+ if (pDBFld->IsInitialized())
+ pDBFld->ChgValue( pDBFld->GetValue(), true );
+
+ pDBFld->ClearInitialized();
+ pDBFld->InitContent();
+ }
+#endif
+ // no break;
+
+ default:
+ pDstFmtFld->ModifyNotification( 0, pMsgHnt );
+ }
+
+ // The fields we can calculate here are being triggered for an update
+ // here explicitly.
+ if( nFldWhich == RES_USERFLD )
+ UpdateUsrFlds();
+ }
+
+ return bTblSelBreak;
+}
+
+/// Update reference and table fields
+void DocumentFieldsManager::UpdateRefFlds( SfxPoolItem* pHt )
+{
+ SwFieldType* pFldType;
+ for( sal_uInt16 i = 0; i < mpFldTypes->size(); ++i )
+ if( RES_GETREFFLD == ( pFldType = (*mpFldTypes)[i] )->Which() )
+ pFldType->ModifyNotification( 0, pHt );
+}
+
+void DocumentFieldsManager::UpdateTblFlds( SfxPoolItem* pHt )
+{
+ OSL_ENSURE( !pHt || RES_TABLEFML_UPDATE == pHt->Which(),
+ "What MessageItem is &m_rSwdoc?" );
+
+ SwFieldType* pFldType(0);
+
+ for (sal_uInt16 i = 0; i < mpFldTypes->size(); ++i)
+ {
+ if( RES_TABLEFLD == ( pFldType = (*mpFldTypes)[i] )->Which() )
+ {
+ SwTableFmlUpdate* pUpdtFld = 0;
+ if( pHt && RES_TABLEFML_UPDATE == pHt->Which() )
+ pUpdtFld = (SwTableFmlUpdate*)pHt;
+
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
+ for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
+ {
+ if( pFmtFld->GetTxtFld() )
+ {
+ SwTblField* pFld = (SwTblField*)pFmtFld->GetField();
+
+ if( pUpdtFld )
+ {
+ // table where &m_rSwdoc field is located
+ const SwTableNode* pTblNd;
+ const SwTxtNode& rTxtNd = pFmtFld->GetTxtFld()->GetTxtNode();
+ if( !rTxtNd.GetNodes().IsDocNodes() ||
+ 0 == ( pTblNd = rTxtNd.FindTableNode() ) )
+ continue;
+
+ switch( pUpdtFld->eFlags )
+ {
+ case TBL_CALC:
+ // re-set the value flag
+ // JP 17.06.96: internal representation of all formulas
+ // (reference to other table!!!)
+ if( nsSwExtendedSubType::SUB_CMD & pFld->GetSubType() )
+ pFld->PtrToBoxNm( pUpdtFld->pTbl );
+ else
+ pFld->ChgValid( false );
+ break;
+ case TBL_BOXNAME:
+ // is &m_rSwdoc the wanted table?
+ if( &pTblNd->GetTable() == pUpdtFld->pTbl )
+ // to the external representation
+ pFld->PtrToBoxNm( pUpdtFld->pTbl );
+ break;
+ case TBL_BOXPTR:
+ // to the internal representation
+ // JP 17.06.96: internal representation on all formulas
+ // (reference to other table!!!)
+ pFld->BoxNmToPtr( pUpdtFld->pTbl );
+ break;
+ case TBL_RELBOXNAME:
+ // is &m_rSwdoc the wanted table?
+ if( &pTblNd->GetTable() == pUpdtFld->pTbl )
+ // to the relative representation
+ pFld->ToRelBoxNm( pUpdtFld->pTbl );
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ // reset the value flag for all
+ pFld->ChgValid( false );
+ }
+ }
+
+ break;
+ }
+ pFldType = 0;
+ }
+
+ // process all table box formuals
+ const SfxPoolItem* pItem;
+ sal_uInt32 nMaxItems = m_rSwdoc.GetAttrPool().GetItemCount2( RES_BOXATR_FORMULA );
+ for (sal_uInt32 i = 0; i < nMaxItems; ++i)
+ {
+ if( 0 != (pItem = m_rSwdoc.GetAttrPool().GetItem2( RES_BOXATR_FORMULA, i ) ) &&
+ ((SwTblBoxFormula*)pItem)->GetDefinedIn() )
+ {
+ ((SwTblBoxFormula*)pItem)->ChangeState( pHt );
+ }
+ }
+
+ // all fields/boxes are now invalid, so we can start to calculate
+ if( pHt && ( RES_TABLEFML_UPDATE != pHt->Which() ||
+ TBL_CALC != ((SwTableFmlUpdate*)pHt)->eFlags ))
+ return ;
+
+ SwCalc* pCalc = 0;
+
+ if( pFldType )
+ {
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
+ for( SwFmtFld* pFmtFld = aIter.Last(); pFmtFld; pFmtFld = aIter.Previous() )
+ {
+ // start calculation at the end
+ // new fields are inserted at the beginning of the modify chain
+ // that gives faster calculation on import
+ // mba: do we really need &m_rSwdoc "optimization"? Is it still valid?
+ SwTblField* pFld;
+ if( !pFmtFld->GetTxtFld() || (nsSwExtendedSubType::SUB_CMD &
+ (pFld = (SwTblField*)pFmtFld->GetField())->GetSubType() ))
+ continue;
+
+ // needs to be recalculated
+ if( !pFld->IsValid() )
+ {
+ // table where &m_rSwdoc field is located
+ const SwTxtNode& rTxtNd = pFmtFld->GetTxtFld()->GetTxtNode();
+ if( !rTxtNd.GetNodes().IsDocNodes() )
+ continue;
+ const SwTableNode* pTblNd = rTxtNd.FindTableNode();
+ if( !pTblNd )
+ continue;
+
+ // if &m_rSwdoc field is not in the to-be-updated table, skip it
+ if( pHt && &pTblNd->GetTable() !=
+ ((SwTableFmlUpdate*)pHt)->pTbl )
+ continue;
+
+ if( !pCalc )
+ pCalc = new SwCalc( m_rSwdoc );
+
+ // get the values of all SetExpression fields that are valid
+ // until the table
+ SwFrm* pFrm = 0;
+ if( pTblNd->GetIndex() < m_rSwdoc.GetNodes().GetEndOfExtras().GetIndex() )
+ {
+ // is in the special section, that's expensive!
+ Point aPt; // return the first frame of the layout - Tab.Headline!!
+ pFrm = rTxtNd.getLayoutFrm( m_rSwdoc.GetCurrentLayout(), &aPt );
+ if( pFrm )
+ {
+ SwPosition aPos( *pTblNd );
+ if( GetBodyTxtNode( m_rSwdoc, aPos, *pFrm ) )
+ FldsToCalc( *pCalc, _SetGetExpFld(
+ aPos.nNode, pFmtFld->GetTxtFld(),
+ &aPos.nContent ));
+ else
+ pFrm = 0;
+ }
+ }
+ if( !pFrm )
+ {
+ // create index to determine the TextNode
+ SwNodeIndex aIdx( rTxtNd );
+ FldsToCalc( *pCalc,
+ _SetGetExpFld( aIdx, pFmtFld->GetTxtFld() ));
+ }
+
+ SwTblCalcPara aPara( *pCalc, pTblNd->GetTable() );
+ pFld->CalcField( aPara );
+ if( aPara.IsStackOverflow() )
+ {
+ bool const bResult = aPara.CalcWithStackOverflow();
+ if (bResult)
+ {
+ pFld->CalcField( aPara );
+ }
+ OSL_ENSURE(bResult,
+ "the chained formula could no be calculated");
+ }
+ pCalc->SetCalcError( CALC_NOERR );
+ }
+ pFmtFld->ModifyNotification( 0, pHt );
+ }
+ }
+
+ // calculate the formula at the boxes
+ for (sal_uInt32 i = 0; i < nMaxItems; ++i )
+ {
+ if( 0 != (pItem = m_rSwdoc.GetAttrPool().GetItem2( RES_BOXATR_FORMULA, i ) ) &&
+ ((SwTblBoxFormula*)pItem)->GetDefinedIn() &&
+ !((SwTblBoxFormula*)pItem)->IsValid() )
+ {
+ SwTblBoxFormula* pFml = (SwTblBoxFormula*)pItem;
+ SwTableBox* pBox = pFml->GetTableBox();
+ if( pBox && pBox->GetSttNd() &&
+ pBox->GetSttNd()->GetNodes().IsDocNodes() )
+ {
+ const SwTableNode* pTblNd = pBox->GetSttNd()->FindTableNode();
+ if( !pHt || &pTblNd->GetTable() ==
+ ((SwTableFmlUpdate*)pHt)->pTbl )
+ {
+ double nValue;
+ if( !pCalc )
+ pCalc = new SwCalc( m_rSwdoc );
+
+ // get the values of all SetExpression fields that are valid
+ // until the table
+ SwFrm* pFrm = 0;
+ if( pTblNd->GetIndex() < m_rSwdoc.GetNodes().GetEndOfExtras().GetIndex() )
+ {
+ // is in the special section, that's expensive!
+ Point aPt; // return the first frame of the layout - Tab.Headline!!
+ SwNodeIndex aCNdIdx( *pTblNd, +2 );
+ SwCntntNode* pCNd = aCNdIdx.GetNode().GetCntntNode();
+ if( !pCNd )
+ pCNd = m_rSwdoc.GetNodes().GoNext( &aCNdIdx );
+
+ if( pCNd && 0 != (pFrm = pCNd->getLayoutFrm( m_rSwdoc.GetCurrentLayout(), &aPt )) )
+ {
+ SwPosition aPos( *pCNd );
+ if( GetBodyTxtNode( m_rSwdoc, aPos, *pFrm ) )
+ FldsToCalc( *pCalc, _SetGetExpFld( aPos.nNode ));
+ else
+ pFrm = 0;
+ }
+ }
+ if( !pFrm )
+ {
+ // create index to determine the TextNode
+ SwNodeIndex aIdx( *pTblNd );
+ FldsToCalc( *pCalc, _SetGetExpFld( aIdx ));
+ }
+
+ SwTblCalcPara aPara( *pCalc, pTblNd->GetTable() );
+ pFml->Calc( aPara, nValue );
+
+ if( aPara.IsStackOverflow() )
+ {
+ bool const bResult = aPara.CalcWithStackOverflow();
+ if (bResult)
+ {
+ pFml->Calc( aPara, nValue );
+ }
+ OSL_ENSURE(bResult,
+ "the chained formula could no be calculated");
+ }
+
+ SwFrmFmt* pFmt = pBox->ClaimFrmFmt();
+ SfxItemSet aTmp( m_rSwdoc.GetAttrPool(),
+ RES_BOXATR_BEGIN,RES_BOXATR_END-1 );
+
+ if( pCalc->IsCalcError() )
+ nValue = DBL_MAX;
+ aTmp.Put( SwTblBoxValue( nValue ));
+ if( SFX_ITEM_SET != pFmt->GetItemState( RES_BOXATR_FORMAT ))
+ aTmp.Put( SwTblBoxNumFormat( 0 ));
+ pFmt->SetFmtAttr( aTmp );
+
+ pCalc->SetCalcError( CALC_NOERR );
+ }
+ }
+ }
+ }
+
+ delete pCalc;
+}
+
+void DocumentFieldsManager::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds )
+{
+ if( IsExpFldsLocked() || m_rSwdoc.IsInReading() )
+ return;
+
+ bool bOldInUpdateFlds = mpUpdtFlds->IsInUpdateFlds();
+ mpUpdtFlds->SetInUpdateFlds( true );
+
+ mpUpdtFlds->MakeFldList( m_rSwdoc, true, GETFLD_ALL );
+ mbNewFldLst = false;
+
+ if( mpUpdtFlds->GetSortLst()->empty() )
+ {
+ if( bUpdRefFlds )
+ UpdateRefFlds(NULL);
+
+ mpUpdtFlds->SetInUpdateFlds( bOldInUpdateFlds );
+ mpUpdtFlds->SetFieldsDirty( false );
+ return ;
+ }
+
+ sal_uInt16 nWhich, n;
+
+ // Hash table for all string replacements is filled on-the-fly.
+ // Try to fabricate an uneven number.
+ sal_uInt16 nStrFmtCnt = (( mpFldTypes->size() / 7 ) + 1 ) * 7;
+ SwHash** pHashStrTbl = new SwHash*[ nStrFmtCnt ];
+ memset( pHashStrTbl, 0, sizeof( _HashStr* ) * nStrFmtCnt );
+
+ {
+ const SwFieldType* pFldType;
+ // process separately:
+ for( n = mpFldTypes->size(); n; )
+ switch( ( pFldType = (*mpFldTypes)[ --n ] )->Which() )
+ {
+ case RES_USERFLD:
+ {
+ // Entry present?
+ sal_uInt16 nPos;
+ const OUString& rNm = pFldType->GetName();
+ OUString sExpand(((SwUserFieldType*)pFldType)->Expand(nsSwGetSetExpType::GSE_STRING, 0, 0));
+ SwHash* pFnd = Find( rNm, pHashStrTbl, nStrFmtCnt, &nPos );
+ if( pFnd )
+ // modify entry in the hash table
+ ((_HashStr*)pFnd)->aSetStr = sExpand;
+ else
+ // insert the new entry
+ *(pHashStrTbl + nPos ) = new _HashStr( rNm, sExpand,
+ (_HashStr*)*(pHashStrTbl + nPos) );
+ }
+ break;
+ case RES_SETEXPFLD:
+ ((SwSetExpFieldType*)pFldType)->SetOutlineChgNd( 0 );
+ break;
+ }
+ }
+
+ // The array is filled with all fields; start calculation.
+ SwCalc aCalc( m_rSwdoc );
+
+#if HAVE_FEATURE_DBCONNECTIVITY
+ OUString sDBNumNm( SwFieldType::GetTypeStr( TYP_DBSETNUMBERFLD ) );
+
+ // already set the current record number
+ SwDBManager* pMgr = m_rSwdoc.GetDBManager();
+ pMgr->CloseAll(false);
+#endif
+
+ // Make sure we don't hide all sections, which would lead to a crash. First, count how many of them do we have.
+ int nShownSections = 0;
+ for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin(); it != mpUpdtFlds->GetSortLst()->end(); ++it )
+ {
+ SwSection* pSect = (SwSection*)(*it)->GetSection();
+ if ( pSect && !pSect->IsCondHidden())
+ nShownSections++;
+ }
+
+ OUString aNew;
+ for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin(); it != mpUpdtFlds->GetSortLst()->end(); ++it )
+ {
+ SwSection* pSect = (SwSection*)(*it)->GetSection();
+ if( pSect )
+ {
+
+ SwSbxValue aValue = aCalc.Calculate(
+ pSect->GetCondition() );
+ if(!aValue.IsVoidValue())
+ {
+ // Do we want to hide this one?
+ bool bHide = aValue.GetBool();
+ if (bHide && !pSect->IsCondHidden())
+ {
+ // This section will be hidden, but it wasn't before
+ if (nShownSections == 1)
+ {
+ // Is the last node part of a section?
+ SwPaM aPam(m_rSwdoc.GetNodes());
+ aPam.Move(fnMoveForward, fnGoDoc);
+ if (aPam.Start()->nNode.GetNode().StartOfSectionNode()->IsSectionNode())
+ {
+ // This would be the last section, so set its condition to false, and avoid hiding it.
+ OUString aCond("0");
+ pSect->SetCondition(aCond);
+ bHide = false;
+ }
+ }
+ nShownSections--;
+ }
+ pSect->SetCondHidden( bHide );
+ }
+ continue;
+ }
+
+ SwTxtFld* pTxtFld = (SwTxtFld*)(*it)->GetTxtFld();
+ if( !pTxtFld )
+ {
+ OSL_ENSURE( false, "what's wrong now'" );
+ continue;
+ }
+
+ SwFmtFld* pFmtFld = (SwFmtFld*)&pTxtFld->GetFmtFld();
+ const SwField* pFld = pFmtFld->GetField();
+
+ switch( nWhich = pFld->GetTyp()->Which() )
+ {
+ case RES_HIDDENTXTFLD:
+ {
+ SwHiddenTxtField* pHFld = (SwHiddenTxtField*)pFld;
+ SwSbxValue aValue = aCalc.Calculate( pHFld->GetPar1() );
+ bool bValue = !aValue.GetBool();
+ if(!aValue.IsVoidValue())
+ {
+ pHFld->SetValue( bValue );
+ // evaluate field
+ pHFld->Evaluate(&m_rSwdoc);
+ }
+ }
+ break;
+ case RES_HIDDENPARAFLD:
+ {
+ SwHiddenParaField* pHPFld = (SwHiddenParaField*)pFld;
+ SwSbxValue aValue = aCalc.Calculate( pHPFld->GetPar1() );
+ bool bValue = aValue.GetBool();
+ if(!aValue.IsVoidValue())
+ pHPFld->SetHidden( bValue );
+ }
+ break;
+ case RES_DBSETNUMBERFLD:
+#if HAVE_FEATURE_DBCONNECTIVITY
+ {
+ ((SwDBSetNumberField*)pFld)->Evaluate(&m_rSwdoc);
+ aCalc.VarChange( sDBNumNm, ((SwDBSetNumberField*)pFld)->GetSetNumber());
+ }
+#endif
+ break;
+ case RES_DBNEXTSETFLD:
+ case RES_DBNUMSETFLD:
+#if HAVE_FEATURE_DBCONNECTIVITY
+ {
+ UpdateDBNumFlds( *(SwDBNameInfField*)pFld, aCalc );
+ }
+#endif
+ break;
+ case RES_DBFLD:
+ {
+#if HAVE_FEATURE_DBCONNECTIVITY
+ // evaluate field
+ ((SwDBField*)pFld)->Evaluate();
+
+ SwDBData aTmpDBData(((SwDBField*)pFld)->GetDBData());
+
+ if( pMgr->IsDataSourceOpen(aTmpDBData.sDataSource, aTmpDBData.sCommand, false))
+ aCalc.VarChange( sDBNumNm, pMgr->GetSelectedRecordId(aTmpDBData.sDataSource, aTmpDBData.sCommand, aTmpDBData.nCommandType));
+
+ const OUString& rName = pFld->GetTyp()->GetName();
+
+ // Add entry to hash table
+ // Entry present?
+ sal_uInt16 nPos;
+ SwHash* pFnd = Find( rName, pHashStrTbl, nStrFmtCnt, &nPos );
+ OUString const value(pFld->ExpandField(m_rSwdoc.IsClipBoard()));
+ if( pFnd )
+ {
+ // Modify entry in the hash table
+ static_cast<_HashStr*>(pFnd)->aSetStr = value;
+ }
+ else
+ {
+ // insert new entry
+ *(pHashStrTbl + nPos ) = new _HashStr( rName,
+ value, static_cast<_HashStr *>(*(pHashStrTbl + nPos)));
+ }
+#endif
+ }
+ break;
+ case RES_GETEXPFLD:
+ case RES_SETEXPFLD:
+ {
+ if( nsSwGetSetExpType::GSE_STRING & pFld->GetSubType() ) // replace String
+ {
+ if( RES_GETEXPFLD == nWhich )
+ {
+ SwGetExpField* pGFld = (SwGetExpField*)pFld;
+
+ if( (!pUpdtFld || pUpdtFld == pTxtFld )
+ && pGFld->IsInBodyTxt() )
+ {
+ aNew = LookString( pHashStrTbl, nStrFmtCnt,
+ pGFld->GetFormula() );
+ pGFld->ChgExpStr( aNew );
+ }
+ }
+ else
+ {
+ SwSetExpField* pSFld = (SwSetExpField*)pFld;
+ // is the "formula" a field?
+ aNew = LookString( pHashStrTbl, nStrFmtCnt,
+ pSFld->GetFormula() );
+
+ if( aNew.isEmpty() ) // nothing found then the formula is the new value
+ aNew = pSFld->GetFormula();
+
+ // only update one field
+ if( !pUpdtFld || pUpdtFld == pTxtFld )
+ pSFld->ChgExpStr( aNew );
+
+ // lookup the field's name
+ aNew = ((SwSetExpFieldType*)pSFld->GetTyp())->GetSetRefName();
+ // Entry present?
+ sal_uInt16 nPos;
+ SwHash* pFnd = Find( aNew, pHashStrTbl, nStrFmtCnt, &nPos );
+ if( pFnd )
+ // Modify entry in the hash table
+ ((_HashStr*)pFnd)->aSetStr = pSFld->GetExpStr();
+ else
+ // insert new entry
+ *(pHashStrTbl + nPos ) = pFnd = new _HashStr( aNew,
+ pSFld->GetExpStr(),
+ (_HashStr*)*(pHashStrTbl + nPos) );
+
+ // Extension for calculation with Strings
+ SwSbxValue aValue;
+ aValue.PutString( ((_HashStr*)pFnd)->aSetStr );
+ aCalc.VarChange( aNew, aValue );
+ }
+ }
+ else // recalculate formula
+ {
+ if( RES_GETEXPFLD == nWhich )
+ {
+ SwGetExpField* pGFld = (SwGetExpField*)pFld;
+
+ if( (!pUpdtFld || pUpdtFld == pTxtFld )
+ && pGFld->IsInBodyTxt() )
+ {
+ SwSbxValue aValue = aCalc.Calculate(
+ pGFld->GetFormula());
+ if(!aValue.IsVoidValue())
+ pGFld->SetValue(aValue.GetDouble() );
+ }
+ }
+ else
+ {
+ SwSetExpField* pSFld = (SwSetExpField*)pFld;
+ SwSetExpFieldType* pSFldTyp = (SwSetExpFieldType*)pFld->GetTyp();
+ aNew = pSFldTyp->GetName();
+
+ SwNode* pSeqNd = 0;
+
+ if( pSFld->IsSequenceFld() )
+ {
+ const sal_uInt8 nLvl = pSFldTyp->GetOutlineLvl();
+ if( MAXLEVEL > nLvl )
+ {
+ // test if the Number needs to be updated
+ pSeqNd = m_rSwdoc.GetNodes()[ (*it)->GetNode() ];
+
+ const SwTxtNode* pOutlNd = pSeqNd->
+ FindOutlineNodeOfLevel( nLvl );
+ if( pSFldTyp->GetOutlineChgNd() != pOutlNd )
+ {
+ pSFldTyp->SetOutlineChgNd( pOutlNd );
+ aCalc.VarChange( aNew, 0 );
+ }
+ }
+ }
+
+ aNew += "=";
+ aNew += pSFld->GetFormula();
+
+ SwSbxValue aValue = aCalc.Calculate( aNew );
+ double nErg = aValue.GetDouble();
+ // only update one field
+ if( !aValue.IsVoidValue() && (!pUpdtFld || pUpdtFld == pTxtFld) )
+ {
+ pSFld->SetValue( nErg );
+
+ if( pSeqNd )
+ pSFldTyp->SetChapter( *pSFld, *pSeqNd );
+ }
+ }
+ }
+ }
+ } // switch
+
+ pFmtFld->ModifyNotification( 0, 0 ); // trigger formatting
+
+ if( pUpdtFld == pTxtFld ) // if only &m_rSwdoc one is updated
+ {
+ if( RES_GETEXPFLD == nWhich || // only GetField or
+ RES_HIDDENTXTFLD == nWhich || // HiddenTxt?
+ RES_HIDDENPARAFLD == nWhich) // HiddenParaFld?
+ break; // quit
+ pUpdtFld = 0; // update all from here on
+ }
+ }
+
+#if HAVE_FEATURE_DBCONNECTIVITY
+ pMgr->CloseAll(false);
+#endif
+ // delete hash table
+ ::DeleteHashTable( pHashStrTbl, nStrFmtCnt );
+
+ // update reference fields
+ if( bUpdRefFlds )
+ UpdateRefFlds(NULL);
+
+ mpUpdtFlds->SetInUpdateFlds( bOldInUpdateFlds );
+ mpUpdtFlds->SetFieldsDirty( false );
+}
+
+/// Insert field type that was marked as deleted
+void DocumentFieldsManager::UpdateUsrFlds()
+{
+ SwCalc* pCalc = 0;
+ const SwFieldType* pFldType;
+ for( sal_uInt16 i = INIT_FLDTYPES; i < mpFldTypes->size(); ++i )
+ if( RES_USERFLD == ( pFldType = (*mpFldTypes)[i] )->Which() )
+ {
+ if( !pCalc )
+ pCalc = new SwCalc( m_rSwdoc );
+ ((SwUserFieldType*)pFldType)->GetValue( *pCalc );
+ }
+
+ if( pCalc )
+ {
+ delete pCalc;
+ m_rSwdoc.SetModified();
+ }
+}
+
+void DocumentFieldsManager::UpdatePageFlds( SfxPoolItem* pMsgHnt )
+{
+ SwFieldType* pFldType;
+ for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i )
+ switch( ( pFldType = (*mpFldTypes)[ i ] )->Which() )
+ {
+ case RES_PAGENUMBERFLD:
+ case RES_CHAPTERFLD:
+ case RES_GETEXPFLD:
+ case RES_REFPAGEGETFLD:
+ pFldType->ModifyNotification( 0, pMsgHnt );
+ break;
+ case RES_DOCSTATFLD:
+ pFldType->ModifyNotification( 0, 0 );
+ break;
+ }
+ SetNewFldLst(true);
+}
+
+void DocumentFieldsManager::LockExpFlds()
+{
+ ++mnLockExpFld;
+}
+
+void DocumentFieldsManager::UnlockExpFlds()
+{
+ if( mnLockExpFld )
+ --mnLockExpFld;
+}
+
+bool DocumentFieldsManager::IsExpFldsLocked() const
+{
+ return 0 != mnLockExpFld;
+}
+
+SwDocUpdtFld& DocumentFieldsManager::GetUpdtFlds() const
+{
+ return *mpUpdtFlds;
+}
+
+bool DocumentFieldsManager::SetFieldsDirty( bool b, const SwNode* pChk, sal_uLong nLen )
+{
+ // See if the supplied nodes actually contain fields.
+ // If they don't, the flag doesn't need to be changed.
+ bool bFldsFnd = false;
+ if( b && pChk && !GetUpdtFlds().IsFieldsDirty() && !m_rSwdoc.IsInDtor()
+ // ?? what's up with Undo, this is also wanted there!
+ /*&& &pChk->GetNodes() == &GetNodes()*/ )
+ {
+ b = false;
+ if( !nLen )
+ ++nLen;
+ sal_uLong nStt = pChk->GetIndex();
+ const SwNodes& rNds = pChk->GetNodes();
+ while( nLen-- )
+ {
+ const SwTxtNode* pTNd = rNds[ nStt++ ]->GetTxtNode();
+ if( pTNd )
+ {
+ if( pTNd->GetAttrOutlineLevel() != 0 )
+ // update chapter fields
+ b = true;
+ else if( pTNd->GetpSwpHints() && pTNd->GetSwpHints().Count() )
+ {
+ const size_t nEnd = pTNd->GetSwpHints().Count();
+ for( size_t n = 0 ; n < nEnd; ++n )
+ {
+ const SwTxtAttr* pAttr = pTNd->GetSwpHints()[ n ];
+ if ( pAttr->Which() == RES_TXTATR_FIELD )
+ {
+ b = true;
+ break;
+ }
+ }
+ }
+
+ if( b )
+ break;
+ }
+ }
+ bFldsFnd = b;
+ }
+ GetUpdtFlds().SetFieldsDirty( b );
+ return bFldsFnd;
+}
+
+void DocumentFieldsManager::SetFixFields( bool bOnlyTimeDate, const DateTime* pNewDateTime )
+{
+ bool bIsModified = m_rSwdoc.IsModified();
+
+ sal_Int32 nDate;
+ sal_Int64 nTime;
+ if( pNewDateTime )
+ {
+ nDate = pNewDateTime->GetDate();
+ nTime = pNewDateTime->GetTime();
+ }
+ else
+ {
+ nDate = Date( Date::SYSTEM ).GetDate();
+ nTime = Time( Time::SYSTEM ).GetTime();
+ }
+
+ sal_uInt16 aTypes[5] = {
+ /*0*/ RES_DOCINFOFLD,
+ /*1*/ RES_AUTHORFLD,
+ /*2*/ RES_EXTUSERFLD,
+ /*3*/ RES_FILENAMEFLD,
+ /*4*/ RES_DATETIMEFLD }; // MUST be at the end!
+
+ sal_uInt16 nStt = bOnlyTimeDate ? 4 : 0;
+
+ for( ; nStt < 5; ++nStt )
+ {
+ SwFieldType* pFldType = GetSysFldType( aTypes[ nStt ] );
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
+ for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
+ {
+ if( pFmtFld && pFmtFld->GetTxtFld() )
+ {
+ bool bChgd = false;
+ switch( aTypes[ nStt ] )
+ {
+ case RES_DOCINFOFLD:
+ if( ((SwDocInfoField*)pFmtFld->GetField())->IsFixed() )
+ {
+ bChgd = true;
+ SwDocInfoField* pDocInfFld = (SwDocInfoField*)pFmtFld->GetField();
+ pDocInfFld->SetExpansion( ((SwDocInfoFieldType*)
+ pDocInfFld->GetTyp())->Expand(
+ pDocInfFld->GetSubType(),
+ pDocInfFld->GetFormat(),
+ pDocInfFld->GetLanguage(),
+ pDocInfFld->GetName() ) );
+ }
+ break;
+
+ case RES_AUTHORFLD:
+ if( ((SwAuthorField*)pFmtFld->GetField())->IsFixed() )
+ {
+ bChgd = true;
+ SwAuthorField* pAuthorFld = (SwAuthorField*)pFmtFld->GetField();
+ pAuthorFld->SetExpansion( ((SwAuthorFieldType*)
+ pAuthorFld->GetTyp())->Expand(
+ pAuthorFld->GetFormat() ) );
+ }
+ break;
+
+ case RES_EXTUSERFLD:
+ if( ((SwExtUserField*)pFmtFld->GetField())->IsFixed() )
+ {
+ bChgd = true;
+ SwExtUserField* pExtUserFld = (SwExtUserField*)pFmtFld->GetField();
+ pExtUserFld->SetExpansion( ((SwExtUserFieldType*)
+ pExtUserFld->GetTyp())->Expand(
+ pExtUserFld->GetSubType(),
+ pExtUserFld->GetFormat()));
+ }
+ break;
+
+ case RES_DATETIMEFLD:
+ if( ((SwDateTimeField*)pFmtFld->GetField())->IsFixed() )
+ {
+ bChgd = true;
+ ((SwDateTimeField*)pFmtFld->GetField())->SetDateTime(
+ DateTime(Date(nDate), Time(nTime)) );
+ }
+ break;
+
+ case RES_FILENAMEFLD:
+ if( ((SwFileNameField*)pFmtFld->GetField())->IsFixed() )
+ {
+ bChgd = true;
+ SwFileNameField* pFileNameFld =
+ (SwFileNameField*)pFmtFld->GetField();
+ pFileNameFld->SetExpansion( ((SwFileNameFieldType*)
+ pFileNameFld->GetTyp())->Expand(
+ pFileNameFld->GetFormat() ) );
+ }
+ break;
+ }
+
+ // Trigger formatting
+ if( bChgd )
+ pFmtFld->ModifyNotification( 0, 0 );
+ }
+ }
+ }
+
+ if( !bIsModified )
+ m_rSwdoc.ResetModified();
+}
+
+void DocumentFieldsManager::FldsToCalc( SwCalc& rCalc, const _SetGetExpFld& rToThisFld )
+{
+ // create the sorted list of all SetFields
+ mpUpdtFlds->MakeFldList( m_rSwdoc, mbNewFldLst, GETFLD_CALC );
+ mbNewFldLst = false;
+
+#if !HAVE_FEATURE_DBCONNECTIVITY
+ SwDBManager* pMgr = NULL;
+#else
+ SwDBManager* pMgr = m_rSwdoc.GetDBManager();
+ pMgr->CloseAll(false);
+#endif
+
+ if( !mpUpdtFlds->GetSortLst()->empty() )
+ {
+ _SetGetExpFlds::const_iterator const itLast =
+ mpUpdtFlds->GetSortLst()->upper_bound(
+ const_cast<_SetGetExpFld*>(&rToThisFld));
+ for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin(); it != itLast; ++it )
+ lcl_CalcFld( m_rSwdoc, rCalc, **it, pMgr );
+ }
+#if HAVE_FEATURE_DBCONNECTIVITY
+ pMgr->CloseAll(false);
+#endif
+}
+
+void DocumentFieldsManager::FldsToCalc( SwCalc& rCalc, sal_uLong nLastNd, sal_uInt16 nLastCnt )
+{
+ // create the sorted list of all SetFields
+ mpUpdtFlds->MakeFldList( m_rSwdoc, mbNewFldLst, GETFLD_CALC );
+ mbNewFldLst = false;
+
+#if !HAVE_FEATURE_DBCONNECTIVITY
+ SwDBManager* pMgr = NULL;
+#else
+ SwDBManager* pMgr = m_rSwdoc.GetDBManager();
+ pMgr->CloseAll(false);
+#endif
+
+ for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin();
+ it != mpUpdtFlds->GetSortLst()->end() &&
+ ( (*it)->GetNode() < nLastNd ||
+ ( (*it)->GetNode() == nLastNd && (*it)->GetCntnt() <= nLastCnt )
+ );
+ ++it )
+ {
+ lcl_CalcFld( m_rSwdoc, rCalc, **it, pMgr );
+ }
+
+#if HAVE_FEATURE_DBCONNECTIVITY
+ pMgr->CloseAll(false);
+#endif
+}
+
+void DocumentFieldsManager::FldsToExpand( SwHash**& ppHashTbl, sal_uInt16& rTblSize,
+ const _SetGetExpFld& rToThisFld )
+{
+ // create the sorted list of all SetFields
+ mpUpdtFlds->MakeFldList( m_rSwdoc, mbNewFldLst, GETFLD_EXPAND );
+ mbNewFldLst = false;
+
+ // Hash table for all string replacements is filled on-the-fly.
+ // Try to fabricate an uneven number.
+ rTblSize = (( mpUpdtFlds->GetSortLst()->size() / 7 ) + 1 ) * 7;
+ ppHashTbl = new SwHash*[ rTblSize ];
+ memset( ppHashTbl, 0, sizeof( _HashStr* ) * rTblSize );
+
+ _SetGetExpFlds::const_iterator const itLast =
+ mpUpdtFlds->GetSortLst()->upper_bound(
+ const_cast<_SetGetExpFld*>(&rToThisFld));
+
+ for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin(); it != itLast; ++it )
+ {
+ const SwTxtFld* pTxtFld = (*it)->GetTxtFld();
+ if( !pTxtFld )
+ continue;
+
+ const SwField* pFld = pTxtFld->GetFmtFld().GetField();
+ switch( pFld->GetTyp()->Which() )
+ {
+ case RES_SETEXPFLD:
+ if( nsSwGetSetExpType::GSE_STRING & pFld->GetSubType() )
+ {
+ // set the new value in the hash table
+ // is the formula a field?
+ SwSetExpField* pSFld = (SwSetExpField*)pFld;
+ OUString aNew = LookString( ppHashTbl, rTblSize, pSFld->GetFormula() );
+
+ if( aNew.isEmpty() ) // nothing found, then the formula is
+ aNew = pSFld->GetFormula(); // the new value
+
+ // #i3141# - update expression of field as in method
+ // <SwDoc::UpdateExpFlds(..)> for string/text fields
+ pSFld->ChgExpStr( aNew );
+
+ // look up the field's name
+ aNew = ((SwSetExpFieldType*)pSFld->GetTyp())->GetSetRefName();
+ // Entry present?
+ sal_uInt16 nPos;
+ SwHash* pFnd = Find( aNew, ppHashTbl, rTblSize, &nPos );
+ if( pFnd )
+ // modify entry in the hash table
+ ((_HashStr*)pFnd)->aSetStr = pSFld->GetExpStr();
+ else
+ // insert the new entry
+ *(ppHashTbl + nPos ) = new _HashStr( aNew,
+ pSFld->GetExpStr(), (_HashStr*)*(ppHashTbl + nPos) );
+ }
+ break;
+ case RES_DBFLD:
+ {
+ const OUString& rName = pFld->GetTyp()->GetName();
+
+ // Insert entry in the hash table
+ // Entry present?
+ sal_uInt16 nPos;
+ SwHash* pFnd = Find( rName, ppHashTbl, rTblSize, &nPos );
+ OUString const value(pFld->ExpandField(m_rSwdoc.IsClipBoard()));
+ if( pFnd )
+ {
+ // modify entry in the hash table
+ static_cast<_HashStr*>(pFnd)->aSetStr = value;
+ }
+ else
+ {
+ // insert the new entry
+ *(ppHashTbl + nPos ) = new _HashStr( rName,
+ value, static_cast<_HashStr *>(*(ppHashTbl + nPos)));
+ }
+ }
+ break;
+ }
+ }
+}
+
+
+bool DocumentFieldsManager::IsNewFldLst() const
+{
+ return mbNewFldLst;
+}
+
+void DocumentFieldsManager::SetNewFldLst(bool bFlag)
+{
+ mbNewFldLst = bFlag;
+}
+
+void DocumentFieldsManager::InsDelFldInFldLst( bool bIns, const SwTxtFld& rFld )
+{
+ if( !mbNewFldLst || !m_rSwdoc.IsInDtor() )
+ mpUpdtFlds->InsDelFldInFldLst( bIns, rFld );
+}
+
+SwField * DocumentFieldsManager::GetFieldAtPos(const SwPosition & rPos)
+{
+ SwTxtFld * const pAttr = GetTxtFldAtPos(rPos);
+
+ return (pAttr) ? const_cast<SwField *>( pAttr->GetFmtFld().GetField() ) : 0;
+}
+
+SwTxtFld * DocumentFieldsManager::GetTxtFldAtPos(const SwPosition & rPos)
+{
+ SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode();
+
+ return (pNode != NULL)
+ ? pNode->GetFldTxtAttrAt( rPos.nContent.GetIndex(), true )
+ : 0;
+}
+
+/// @note For simplicity assume that all field types have updatable contents so
+/// optimization currently only available when no fields exist.
+bool DocumentFieldsManager::containsUpdatableFields()
+{
+ for (sal_uInt16 i = 0; i < mpFldTypes->size(); ++i)
+ {
+ SwFieldType* pFldType = (*mpFldTypes)[i];
+ SwIterator<SwFmtFld,SwFieldType> aIter(*pFldType);
+ if (aIter.First())
+ return true;
+ }
+ return false;
+}
+
+/// Remove all unreferenced field types of a document
+void DocumentFieldsManager::GCFieldTypes()
+{
+ for( sal_uInt16 n = mpFldTypes->size(); n > INIT_FLDTYPES; )
+ if( !(*mpFldTypes)[ --n ]->GetDepends() )
+ RemoveFldType( n );
+}
+
+void DocumentFieldsManager::_InitFieldTypes() // is being called by the CTOR
+{
+ // Field types
+ mpFldTypes->push_back( new SwDateTimeFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwChapterFieldType );
+ mpFldTypes->push_back( new SwPageNumberFieldType );
+ mpFldTypes->push_back( new SwAuthorFieldType );
+ mpFldTypes->push_back( new SwFileNameFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwDBNameFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwGetExpFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwGetRefFieldType( &m_rSwdoc ) );
+ mpFldTypes->push_back( new SwHiddenTxtFieldType );
+ mpFldTypes->push_back( new SwPostItFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwDocStatFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwDocInfoFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwInputFieldType( &m_rSwdoc ) );
+ mpFldTypes->push_back( new SwTblFieldType( &m_rSwdoc ) );
+ mpFldTypes->push_back( new SwMacroFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwHiddenParaFieldType );
+ mpFldTypes->push_back( new SwDBNextSetFieldType );
+ mpFldTypes->push_back( new SwDBNumSetFieldType );
+ mpFldTypes->push_back( new SwDBSetNumberFieldType );
+ mpFldTypes->push_back( new SwTemplNameFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwTemplNameFieldType(&m_rSwdoc) );
+ mpFldTypes->push_back( new SwExtUserFieldType );
+ mpFldTypes->push_back( new SwRefPageSetFieldType );
+ mpFldTypes->push_back( new SwRefPageGetFieldType( &m_rSwdoc ) );
+ mpFldTypes->push_back( new SwJumpEditFieldType( &m_rSwdoc ) );
+ mpFldTypes->push_back( new SwScriptFieldType( &m_rSwdoc ) );
+ mpFldTypes->push_back( new SwCombinedCharFieldType );
+ mpFldTypes->push_back( new SwDropDownFieldType );
+
+ // Types have to be at the end!
+ // We expect &m_rSwdoc in the InsertFldType!
+ // MIB 14.04.95: In Sw3StringPool::Setup (sw3imp.cxx) and
+ // lcl_sw3io_InSetExpField (sw3field.cxx) now also
+ mpFldTypes->push_back( new SwSetExpFieldType(&m_rSwdoc,
+ SW_RESSTR(STR_POOLCOLL_LABEL_ABB), nsSwGetSetExpType::GSE_SEQ) );
+ mpFldTypes->push_back( new SwSetExpFieldType(&m_rSwdoc,
+ SW_RESSTR(STR_POOLCOLL_LABEL_TABLE), nsSwGetSetExpType::GSE_SEQ) );
+ mpFldTypes->push_back( new SwSetExpFieldType(&m_rSwdoc,
+ SW_RESSTR(STR_POOLCOLL_LABEL_FRAME), nsSwGetSetExpType::GSE_SEQ) );
+ mpFldTypes->push_back( new SwSetExpFieldType(&m_rSwdoc,
+ SW_RESSTR(STR_POOLCOLL_LABEL_DRAWING), nsSwGetSetExpType::GSE_SEQ) );
+
+ assert( mpFldTypes->size() == INIT_FLDTYPES );
+}
+
+void DocumentFieldsManager::ClearFieldTypes()
+{
+ for(SwFldTypes::const_iterator it = mpFldTypes->begin() + INIT_FLDTYPES;
+ it != mpFldTypes->end(); ++it)
+ delete *it;
+ mpFldTypes->erase( mpFldTypes->begin() + INIT_FLDTYPES, mpFldTypes->end() );
+}
+
+void DocumentFieldsManager::UpdateDBNumFlds( SwDBNameInfField& rDBFld, SwCalc& rCalc )
+{
+#if !HAVE_FEATURE_DBCONNECTIVITY
+ (void) rDBFld;
+ (void) rCalc;
+#else
+ SwDBManager* pMgr = m_rSwdoc.GetDBManager();
+
+ sal_uInt16 nFldType = rDBFld.Which();
+
+ bool bPar1 = rCalc.Calculate( rDBFld.GetPar1() ).GetBool();
+
+ if( RES_DBNEXTSETFLD == nFldType )
+ ((SwDBNextSetField&)rDBFld).SetCondValid( bPar1 );
+ else
+ ((SwDBNumSetField&)rDBFld).SetCondValid( bPar1 );
+
+ if( !rDBFld.GetRealDBData().sDataSource.isEmpty() )
+ {
+ // Edit a certain database
+ if( RES_DBNEXTSETFLD == nFldType )
+ ((SwDBNextSetField&)rDBFld).Evaluate(&m_rSwdoc);
+ else
+ ((SwDBNumSetField&)rDBFld).Evaluate(&m_rSwdoc);
+
+ SwDBData aTmpDBData( rDBFld.GetDBData(&m_rSwdoc) );
+
+ if( pMgr->OpenDataSource( aTmpDBData.sDataSource, aTmpDBData.sCommand, -1, false ))
+ rCalc.VarChange( lcl_GetDBVarName( m_rSwdoc, rDBFld),
+ pMgr->GetSelectedRecordId(aTmpDBData.sDataSource, aTmpDBData.sCommand, aTmpDBData.nCommandType) );
+ }
+ else
+ {
+ OSL_FAIL("TODO: what should happen with unnamed DBFields?");
+ }
+#endif
+}
+
+DocumentFieldsManager::~DocumentFieldsManager()
+{
+ delete mpUpdtFlds;
+ delete mpFldTypes;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx b/sw/source/core/doc/DocumentTimerManager.cxx
index d99f3da39115..3acbaf973a80 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -20,6 +20,7 @@
#include <doc.hxx>
#include <DocumentSettingManager.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <rootfrm.hxx>
#include <viewsh.hxx>
#include <unotools/lingucfg.hxx>
@@ -125,20 +126,20 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer *, pTimer )
SwFldUpdateFlags nFldUpdFlag = m_rSwdoc.GetDocumentSettingManager().getFieldUpdateFlags(true);
if( ( AUTOUPD_FIELD_ONLY == nFldUpdFlag
|| AUTOUPD_FIELD_AND_CHARTS == nFldUpdFlag ) &&
- m_rSwdoc.GetUpdtFlds().IsFieldsDirty()
+ m_rSwdoc.getIDocumentFieldsAccess().GetUpdtFlds().IsFieldsDirty()
// If we switch the field name the Fields are not updated.
// So the "backgorund update" should always be carried out
/* && !pStartSh->GetViewOptions()->IsFldName()*/ )
{
- if ( m_rSwdoc.GetUpdtFlds().IsInUpdateFlds() ||
- m_rSwdoc.IsExpFldsLocked() )
+ if ( m_rSwdoc.getIDocumentFieldsAccess().GetUpdtFlds().IsInUpdateFlds() ||
+ m_rSwdoc.getIDocumentFieldsAccess().IsExpFldsLocked() )
{
pTimer->Start();
return 0;
}
// Action brackets!
- m_rSwdoc.GetUpdtFlds().SetInUpdateFlds( true );
+ m_rSwdoc.getIDocumentFieldsAccess().GetUpdtFlds().SetInUpdateFlds( true );
pTmpRoot->StartAllAction();
@@ -146,17 +147,17 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer *, pTimer )
const bool bOldLockView = pStartSh->IsViewLocked();
pStartSh->LockView( true );
- m_rSwdoc.GetSysFldType( RES_CHAPTERFLD )->ModifyNotification( 0, 0 ); // ChapterField
- m_rSwdoc.UpdateExpFlds( 0, false ); // Updates ExpressionFields
- m_rSwdoc.UpdateTblFlds(NULL); // Tables
- m_rSwdoc.UpdateRefFlds(NULL); // References
+ m_rSwdoc.getIDocumentFieldsAccess().GetSysFldType( RES_CHAPTERFLD )->ModifyNotification( 0, 0 ); // ChapterField
+ m_rSwdoc.getIDocumentFieldsAccess().UpdateExpFlds( 0, false ); // Updates ExpressionFields
+ m_rSwdoc.getIDocumentFieldsAccess().UpdateTblFlds(NULL); // Tables
+ m_rSwdoc.getIDocumentFieldsAccess().UpdateRefFlds(NULL); // References
pTmpRoot->EndAllAction();
pStartSh->LockView( bOldLockView );
- m_rSwdoc.GetUpdtFlds().SetInUpdateFlds( false );
- m_rSwdoc.GetUpdtFlds().SetFieldsDirty( false );
+ m_rSwdoc.getIDocumentFieldsAccess().GetUpdtFlds().SetInUpdateFlds( false );
+ m_rSwdoc.getIDocumentFieldsAccess().GetUpdtFlds().SetFieldsDirty( false );
}
}
#ifdef TIMELOG
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index a7034e405865..3e5a3209bdcf 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -29,6 +29,7 @@
#include <DocumentOutlineNodesManager.hxx>
#include <DocumentContentOperationsManager.hxx>
#include <DocumentRedlineManager.hxx>
+#include <DocumentFieldsManager.hxx>
#include <UndoManager.hxx>
#include <hintids.hxx>
#include <tools/shl.hxx>
@@ -383,6 +384,28 @@ IDocumentRedlineAccess& SwDoc::getIDocumentRedlineAccess()
return *m_pDocumentRedlineManager;
}
+//IDocumentFieldsAccess
+
+IDocumentFieldsAccess const & SwDoc::getIDocumentFieldsAccess() const
+{
+ return *m_pDocumentFieldsManager;
+}
+
+IDocumentFieldsAccess & SwDoc::getIDocumentFieldsAccess()
+{
+ return *m_pDocumentFieldsManager;
+}
+
+::sw::DocumentFieldsManager const & SwDoc::GetDocumentFieldsMAnager() const
+{
+ return *m_pDocumentFieldsManager;
+}
+
+::sw::DocumentFieldsManager & SwDoc::GetDocumentFieldsManager()
+{
+ return *m_pDocumentFieldsManager;
+}
+
/* Implementations the next Interface here */
/*
@@ -396,20 +419,11 @@ void SwDoc::ChgDBData(const SwDBData& rNewData)
maDBData = rNewData;
SetModified();
}
- GetSysFldType(RES_DBNAMEFLD)->UpdateFlds();
+ getIDocumentFieldsAccess().GetSysFldType(RES_DBNAMEFLD)->UpdateFlds();
}
-/// @returns the field type of the Doc
-SwFieldType *SwDoc::GetSysFldType( const sal_uInt16 eWhich ) const
-{
- for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i )
- if( eWhich == (*mpFldTypes)[i]->Which() )
- return (*mpFldTypes)[i];
- return 0;
-}
-
void SwDoc::SetDocStat( const SwDocStat& rStat )
{
*mpDocStat = rStat;
@@ -1006,7 +1020,7 @@ bool SwDoc::IncrementalDocStatCalculate(long nChars, bool bFields)
// #i93174#: notes contain paragraphs that are not nodes
{
- SwFieldType * const pPostits( GetSysFldType(RES_POSTITFLD) );
+ SwFieldType * const pPostits( getIDocumentFieldsAccess().GetSysFldType(RES_POSTITFLD) );
SwIterator<SwFmtFld,SwFieldType> aIter( *pPostits );
for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
{
@@ -1068,7 +1082,7 @@ bool SwDoc::IncrementalDocStatCalculate(long nChars, bool bFields)
// optionally update stat. fields
if (bFields)
{
- SwFieldType *pType = GetSysFldType(RES_DOCSTATFLD);
+ SwFieldType *pType = getIDocumentFieldsAccess().GetSysFldType(RES_DOCSTATFLD);
pType->UpdateFlds();
}
@@ -1104,8 +1118,8 @@ void SwDoc::UpdateDocStat( bool bCompleteAsync, bool bFields )
void SwDoc::DocInfoChgd( )
{
- GetSysFldType( RES_DOCINFOFLD )->UpdateFlds();
- GetSysFldType( RES_TEMPLNAMEFLD )->UpdateFlds();
+ getIDocumentFieldsAccess().GetSysFldType( RES_DOCINFOFLD )->UpdateFlds();
+ getIDocumentFieldsAccess().GetSysFldType( RES_TEMPLNAMEFLD )->UpdateFlds();
SetModified();
}
@@ -1456,7 +1470,7 @@ bool SwDoc::RemoveInvisibleContent()
{
SwTxtNode* pTxtNd;
- SwIterator<SwFmtFld,SwFieldType> aIter( *GetSysFldType( RES_HIDDENPARAFLD ) );
+ SwIterator<SwFmtFld,SwFieldType> aIter( *getIDocumentFieldsAccess().GetSysFldType( RES_HIDDENPARAFLD ) );
for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
{
if( pFmtFld->GetTxtFld() &&
@@ -1620,7 +1634,7 @@ bool SwDoc::HasInvisibleContent() const
{
bool bRet = false;
- SwClientIter aIter( *GetSysFldType( RES_HIDDENPARAFLD ) );
+ SwClientIter aIter( *getIDocumentFieldsAccess().GetSysFldType( RES_HIDDENPARAFLD ) );
if( aIter.First( TYPE( SwFmtFld ) ) )
bRet = true;
@@ -1676,10 +1690,10 @@ bool SwDoc::RestoreInvisibleContent()
bool SwDoc::ConvertFieldsToText()
{
bool bRet = false;
- LockExpFlds();
+ getIDocumentFieldsAccess().LockExpFlds();
GetIDocumentUndoRedo().StartUndo( UNDO_UI_REPLACE, NULL );
- const SwFldTypes* pMyFldTypes = GetFldTypes();
+ const SwFldTypes* pMyFldTypes = getIDocumentFieldsAccess().GetFldTypes();
sal_uInt16 nCount = pMyFldTypes->size();
//go backward, field types are removed
for(sal_uInt16 nType = nCount; nType > 0; --nType)
@@ -1747,7 +1761,7 @@ bool SwDoc::ConvertFieldsToText()
if( bRet )
SetModified();
GetIDocumentUndoRedo().EndUndo( UNDO_UI_REPLACE, NULL );
- UnlockExpFlds();
+ getIDocumentFieldsAccess().UnlockExpFlds();
return bRet;
}
@@ -1834,22 +1848,6 @@ OUString SwDoc::GetPaMDescr(const SwPaM & rPam) const
return OUString("??");
}
-SwField * SwDoc::GetFieldAtPos(const SwPosition & rPos)
-{
- SwTxtFld * const pAttr = GetTxtFldAtPos(rPos);
-
- return (pAttr) ? const_cast<SwField *>( pAttr->GetFmtFld().GetField() ) : 0;
-}
-
-SwTxtFld * SwDoc::GetTxtFldAtPos(const SwPosition & rPos)
-{
- SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode();
-
- return (pNode != NULL)
- ? pNode->GetFldTxtAttrAt( rPos.nContent.GetIndex(), true )
- : 0;
-}
-
bool SwDoc::ContainsHiddenChars() const
{
for( sal_uLong n = GetNodes().Count(); n; )
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 96305436f079..e10e9aa1c2c5 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -34,6 +34,7 @@
#include <mdiexp.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <DocumentContentOperationsManager.hxx>
#include <docary.hxx>
#include <rootfrm.hxx>
@@ -395,8 +396,8 @@ void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
{
pDesc->SetNumType( rChged.GetNumType() );
// Notify page number fields that NumFormat has changed
- GetSysFldType( RES_PAGENUMBERFLD )->UpdateFlds();
- GetSysFldType( RES_REFPAGEGETFLD )->UpdateFlds();
+ getIDocumentFieldsAccess().GetSysFldType( RES_PAGENUMBERFLD )->UpdateFlds();
+ getIDocumentFieldsAccess().GetSysFldType( RES_REFPAGEGETFLD )->UpdateFlds();
// If the numbering scheme has changed we could have QuoVadis/ErgoSum texts
// that refer to a changed page, so we invalidate foot notes.
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 82ef087a2933..241c66b954d7 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -30,6 +30,7 @@
#include <unotools/transliterationwrapper.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <cntfrm.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -63,653 +64,6 @@
using namespace ::com::sun::star::uno;
-/** Insert field types
- *
- * @param rFldTyp ???
- * @return Always returns a pointer to the type, if it's new or already added.
- */
-SwFieldType* SwDoc::InsertFldType(const SwFieldType &rFldTyp)
-{
- sal_uInt16 nSize = mpFldTypes->size(),
- nFldWhich = rFldTyp.Which();
-
- sal_uInt16 i = INIT_FLDTYPES;
-
- switch( nFldWhich )
- {
- case RES_SETEXPFLD:
- //JP 29.01.96: SequenceFields start at INIT_FLDTYPES - 3!!
- // Or we get doubble number circles!!
- //MIB 14.03.95: From now on also the SW3-Reader relies on this, when
- //constructing string pools and when reading SetExp fields
- if( nsSwGetSetExpType::GSE_SEQ & ((SwSetExpFieldType&)rFldTyp).GetType() )
- i -= INIT_SEQ_FLDTYPES;
- // no break;
- case RES_DBFLD:
- case RES_USERFLD:
- case RES_DDEFLD:
- {
- const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
- OUString sFldNm( rFldTyp.GetName() );
- for( ; i < nSize; ++i )
- if( nFldWhich == (*mpFldTypes)[i]->Which() &&
- rSCmp.isEqual( sFldNm, (*mpFldTypes)[i]->GetName() ))
- return (*mpFldTypes)[i];
- }
- break;
-
- case RES_AUTHORITY:
- for( ; i < nSize; ++i )
- if( nFldWhich == (*mpFldTypes)[i]->Which() )
- return (*mpFldTypes)[i];
- break;
-
- default:
- for( i = 0; i < nSize; ++i )
- if( nFldWhich == (*mpFldTypes)[i]->Which() )
- return (*mpFldTypes)[i];
- }
-
- SwFieldType* pNew = rFldTyp.Copy();
- switch( nFldWhich )
- {
- case RES_DDEFLD:
- ((SwDDEFieldType*)pNew)->SetDoc( this );
- break;
-
- case RES_DBFLD:
- case RES_TABLEFLD:
- case RES_DATETIMEFLD:
- case RES_GETEXPFLD:
- ((SwValueFieldType*)pNew)->SetDoc( this );
- break;
-
- case RES_USERFLD:
- case RES_SETEXPFLD:
- ((SwValueFieldType*)pNew)->SetDoc( this );
- // JP 29.07.96: Optionally prepare FieldList for Calculator:
- mpUpdtFlds->InsertFldType( *pNew );
- break;
- case RES_AUTHORITY :
- ((SwAuthorityFieldType*)pNew)->SetDoc( this );
- break;
- }
-
- mpFldTypes->insert( mpFldTypes->begin() + nSize, pNew );
- SetModified();
-
- return (*mpFldTypes)[ nSize ];
-}
-
-/// Insert field type that was marked as deleted
-void SwDoc::InsDeletedFldType( SwFieldType& rFldTyp )
-{
- // The FldType was marked as deleted and removed from the array.
- // One has to look this up again, now.
- // - If it's not present, it can be re-inserted.
- // - If the same type is found, the deleted one has to be renamed.
-
- sal_uInt16 nSize = mpFldTypes->size(), nFldWhich = rFldTyp.Which();
- sal_uInt16 i = INIT_FLDTYPES;
-
- OSL_ENSURE( RES_SETEXPFLD == nFldWhich ||
- RES_USERFLD == nFldWhich ||
- RES_DDEFLD == nFldWhich, "Wrong FldType" );
-
- const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
- const OUString& rFldNm = rFldTyp.GetName();
- SwFieldType* pFnd;
-
- for( ; i < nSize; ++i )
- if( nFldWhich == (pFnd = (*mpFldTypes)[i])->Which() &&
- rSCmp.isEqual( rFldNm, pFnd->GetName() ) )
- {
- // find new name
- sal_uInt16 nNum = 1;
- do {
- OUString sSrch = rFldNm + OUString::number( nNum );
- for( i = INIT_FLDTYPES; i < nSize; ++i )
- if( nFldWhich == (pFnd = (*mpFldTypes)[i])->Which() &&
- rSCmp.isEqual( sSrch, pFnd->GetName() ) )
- break;
-
- if( i >= nSize ) // not found
- {
- ((OUString&)rFldNm) = sSrch;
- break; // exit while loop
- }
- ++nNum;
- } while( true );
- break;
- }
-
- // not found, so insert and delete flag
- mpFldTypes->insert( mpFldTypes->begin() + nSize, &rFldTyp );
- switch( nFldWhich )
- {
- case RES_SETEXPFLD:
- ((SwSetExpFieldType&)rFldTyp).SetDeleted( false );
- break;
- case RES_USERFLD:
- ((SwUserFieldType&)rFldTyp).SetDeleted( false );
- break;
- case RES_DDEFLD:
- ((SwDDEFieldType&)rFldTyp).SetDeleted( false );
- break;
- }
-}
-
-/// Remove field type
-void SwDoc::RemoveFldType(sal_uInt16 nFld)
-{
- OSL_ENSURE( INIT_FLDTYPES <= nFld, "don't remove InitFlds" );
- /*
- * Dependent fields present -> ErrRaise
- */
- sal_uInt16 nSize = mpFldTypes->size();
- if(nFld < nSize)
- {
- SwFieldType* pTmp = (*mpFldTypes)[nFld];
-
- // JP 29.07.96: Optionally prepare FldLst for Calculator
- sal_uInt16 nWhich = pTmp->Which();
- switch( nWhich )
- {
- case RES_SETEXPFLD:
- case RES_USERFLD:
- mpUpdtFlds->RemoveFldType( *pTmp );
- // no break;
- case RES_DDEFLD:
- if( pTmp->GetDepends() && !IsUsed( *pTmp ) )
- {
- if( RES_SETEXPFLD == nWhich )
- ((SwSetExpFieldType*)pTmp)->SetDeleted( true );
- else if( RES_USERFLD == nWhich )
- ((SwUserFieldType*)pTmp)->SetDeleted( true );
- else
- ((SwDDEFieldType*)pTmp)->SetDeleted( true );
- nWhich = 0;
- }
- break;
- }
-
- if( nWhich )
- {
- OSL_ENSURE( !pTmp->GetDepends(), "Dependent fields present!" );
- // delete field type
- delete pTmp;
- }
- mpFldTypes->erase( mpFldTypes->begin() + nFld );
- SetModified();
- }
-}
-
-const SwFldTypes* SwDoc::GetFldTypes() const
-{
- return mpFldTypes;
-}
-
-/// Find first type with ResId and name
-SwFieldType* SwDoc::GetFldType(
- sal_uInt16 nResId,
- const OUString& rName,
- bool bDbFieldMatching // used in some UNO calls for RES_DBFLD to use different string matching code #i51815#
- ) const
-{
- sal_uInt16 nSize = mpFldTypes->size(), i = 0;
- const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore();
-
- switch( nResId )
- {
- case RES_SETEXPFLD:
- //JP 29.01.96: SequenceFields start at INIT_FLDTYPES - 3!!
- // Or we get doubble number circles!!
- //MIB 14.03.95: From now on also the SW3-Reader relies on this, when
- //constructing string pools and when reading SetExp fields
- i = INIT_FLDTYPES - INIT_SEQ_FLDTYPES;
- break;
-
- case RES_DBFLD:
- case RES_USERFLD:
- case RES_DDEFLD:
- case RES_AUTHORITY:
- i = INIT_FLDTYPES;
- break;
- }
-
- SwFieldType* pRet = 0;
- for( ; i < nSize; ++i )
- {
- SwFieldType* pFldType = (*mpFldTypes)[i];
-
- OUString aFldName( pFldType->GetName() );
- if (bDbFieldMatching && nResId == RES_DBFLD) // #i51815#
- aFldName = aFldName.replace(DB_DELIM, '.');
-
- if( nResId == pFldType->Which() &&
- rSCmp.isEqual( rName, aFldName ))
- {
- pRet = pFldType;
- break;
- }
- }
- return pRet;
-}
-
-// All have to be re-evaluated.
-void SwDoc::UpdateFlds( SfxPoolItem *pNewHt, bool bCloseDB )
-{
- // Call Modify() for every field type,
- // dependent SwTxtFld get notified ...
-
- for( sal_uInt16 i=0; i < mpFldTypes->size(); ++i)
- {
- switch( (*mpFldTypes)[i]->Which() )
- {
- // Update table fields second to last
- // Update references last
- case RES_GETREFFLD:
- case RES_TABLEFLD:
- case RES_DBFLD:
- case RES_JUMPEDITFLD:
- case RES_REFPAGESETFLD: // are never expanded!
- break;
-
- case RES_DDEFLD:
- {
- if( !pNewHt )
- {
- SwMsgPoolItem aUpdateDDE( RES_UPDATEDDETBL );
- (*mpFldTypes)[i]->ModifyNotification( 0, &aUpdateDDE );
- }
- else
- (*mpFldTypes)[i]->ModifyNotification( 0, pNewHt );
- break;
- }
- case RES_GETEXPFLD:
- case RES_SETEXPFLD:
- case RES_HIDDENTXTFLD:
- case RES_HIDDENPARAFLD:
- // Expression fields are treated separately
- if( !pNewHt )
- break;
- default:
- (*mpFldTypes)[i]->ModifyNotification ( 0, pNewHt );
- }
- }
-
- if( !IsExpFldsLocked() )
- UpdateExpFlds( 0, false ); // update expression fields
-
- // Tables
- UpdateTblFlds(pNewHt);
-
- // References
- UpdateRefFlds(pNewHt);
- if( bCloseDB )
- {
-#if HAVE_FEATURE_DBCONNECTIVITY
- GetDBManager()->CloseAll();
-#endif
- }
- // Only evaluate on full update
- SetModified();
-}
-
-void SwDoc::UpdateUsrFlds()
-{
- SwCalc* pCalc = 0;
- const SwFieldType* pFldType;
- for( sal_uInt16 i = INIT_FLDTYPES; i < mpFldTypes->size(); ++i )
- if( RES_USERFLD == ( pFldType = (*mpFldTypes)[i] )->Which() )
- {
- if( !pCalc )
- pCalc = new SwCalc( *this );
- ((SwUserFieldType*)pFldType)->GetValue( *pCalc );
- }
-
- if( pCalc )
- {
- delete pCalc;
- SetModified();
- }
-}
-
-/// Update reference and table fields
-void SwDoc::UpdateRefFlds( SfxPoolItem* pHt )
-{
- SwFieldType* pFldType;
- for( sal_uInt16 i = 0; i < mpFldTypes->size(); ++i )
- if( RES_GETREFFLD == ( pFldType = (*mpFldTypes)[i] )->Which() )
- pFldType->ModifyNotification( 0, pHt );
-}
-
-/// @note For simplicity assume that all field types have updatable contents so
-/// optimization currently only available when no fields exist.
-bool SwDoc::containsUpdatableFields()
-{
- for (sal_uInt16 i = 0; i < mpFldTypes->size(); ++i)
- {
- SwFieldType* pFldType = (*mpFldTypes)[i];
- SwIterator<SwFmtFld,SwFieldType> aIter(*pFldType);
- if (aIter.First())
- return true;
- }
- return false;
-}
-
-void SwDoc::UpdateTblFlds( SfxPoolItem* pHt )
-{
- OSL_ENSURE( !pHt || RES_TABLEFML_UPDATE == pHt->Which(),
- "What MessageItem is this?" );
-
- SwFieldType* pFldType(0);
-
- for (sal_uInt16 i = 0; i < mpFldTypes->size(); ++i)
- {
- if( RES_TABLEFLD == ( pFldType = (*mpFldTypes)[i] )->Which() )
- {
- SwTableFmlUpdate* pUpdtFld = 0;
- if( pHt && RES_TABLEFML_UPDATE == pHt->Which() )
- pUpdtFld = (SwTableFmlUpdate*)pHt;
-
- SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
- for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
- {
- if( pFmtFld->GetTxtFld() )
- {
- SwTblField* pFld = (SwTblField*)pFmtFld->GetField();
-
- if( pUpdtFld )
- {
- // table where this field is located
- const SwTableNode* pTblNd;
- const SwTxtNode& rTxtNd = pFmtFld->GetTxtFld()->GetTxtNode();
- if( !rTxtNd.GetNodes().IsDocNodes() ||
- 0 == ( pTblNd = rTxtNd.FindTableNode() ) )
- continue;
-
- switch( pUpdtFld->eFlags )
- {
- case TBL_CALC:
- // re-set the value flag
- // JP 17.06.96: internal representation of all formulas
- // (reference to other table!!!)
- if( nsSwExtendedSubType::SUB_CMD & pFld->GetSubType() )
- pFld->PtrToBoxNm( pUpdtFld->pTbl );
- else
- pFld->ChgValid( false );
- break;
- case TBL_BOXNAME:
- // is this the wanted table?
- if( &pTblNd->GetTable() == pUpdtFld->pTbl )
- // to the external representation
- pFld->PtrToBoxNm( pUpdtFld->pTbl );
- break;
- case TBL_BOXPTR:
- // to the internal representation
- // JP 17.06.96: internal representation on all formulas
- // (reference to other table!!!)
- pFld->BoxNmToPtr( pUpdtFld->pTbl );
- break;
- case TBL_RELBOXNAME:
- // is this the wanted table?
- if( &pTblNd->GetTable() == pUpdtFld->pTbl )
- // to the relative representation
- pFld->ToRelBoxNm( pUpdtFld->pTbl );
- break;
- default:
- break;
- }
- }
- else
- // reset the value flag for all
- pFld->ChgValid( false );
- }
- }
-
- break;
- }
- pFldType = 0;
- }
-
- // process all table box formuals
- const SfxPoolItem* pItem;
- sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_BOXATR_FORMULA );
- for (sal_uInt32 i = 0; i < nMaxItems; ++i)
- {
- if( 0 != (pItem = GetAttrPool().GetItem2( RES_BOXATR_FORMULA, i ) ) &&
- ((SwTblBoxFormula*)pItem)->GetDefinedIn() )
- {
- ((SwTblBoxFormula*)pItem)->ChangeState( pHt );
- }
- }
-
- // all fields/boxes are now invalid, so we can start to calculate
- if( pHt && ( RES_TABLEFML_UPDATE != pHt->Which() ||
- TBL_CALC != ((SwTableFmlUpdate*)pHt)->eFlags ))
- return ;
-
- SwCalc* pCalc = 0;
-
- if( pFldType )
- {
- SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
- for( SwFmtFld* pFmtFld = aIter.Last(); pFmtFld; pFmtFld = aIter.Previous() )
- {
- // start calculation at the end
- // new fields are inserted at the beginning of the modify chain
- // that gives faster calculation on import
- // mba: do we really need this "optimization"? Is it still valid?
- SwTblField* pFld;
- if( !pFmtFld->GetTxtFld() || (nsSwExtendedSubType::SUB_CMD &
- (pFld = (SwTblField*)pFmtFld->GetField())->GetSubType() ))
- continue;
-
- // needs to be recalculated
- if( !pFld->IsValid() )
- {
- // table where this field is located
- const SwTxtNode& rTxtNd = pFmtFld->GetTxtFld()->GetTxtNode();
- if( !rTxtNd.GetNodes().IsDocNodes() )
- continue;
- const SwTableNode* pTblNd = rTxtNd.FindTableNode();
- if( !pTblNd )
- continue;
-
- // if this field is not in the to-be-updated table, skip it
- if( pHt && &pTblNd->GetTable() !=
- ((SwTableFmlUpdate*)pHt)->pTbl )
- continue;
-
- if( !pCalc )
- pCalc = new SwCalc( *this );
-
- // get the values of all SetExpression fields that are valid
- // until the table
- SwFrm* pFrm = 0;
- if( pTblNd->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() )
- {
- // is in the special section, that's expensive!
- Point aPt; // return the first frame of the layout - Tab.Headline!!
- pFrm = rTxtNd.getLayoutFrm( GetCurrentLayout(), &aPt );
- if( pFrm )
- {
- SwPosition aPos( *pTblNd );
- if( GetBodyTxtNode( *this, aPos, *pFrm ) )
- FldsToCalc( *pCalc, _SetGetExpFld(
- aPos.nNode, pFmtFld->GetTxtFld(),
- &aPos.nContent ));
- else
- pFrm = 0;
- }
- }
- if( !pFrm )
- {
- // create index to determine the TextNode
- SwNodeIndex aIdx( rTxtNd );
- FldsToCalc( *pCalc,
- _SetGetExpFld( aIdx, pFmtFld->GetTxtFld() ));
- }
-
- SwTblCalcPara aPara( *pCalc, pTblNd->GetTable() );
- pFld->CalcField( aPara );
- if( aPara.IsStackOverflow() )
- {
- bool const bResult = aPara.CalcWithStackOverflow();
- if (bResult)
- {
- pFld->CalcField( aPara );
- }
- OSL_ENSURE(bResult,
- "the chained formula could no be calculated");
- }
- pCalc->SetCalcError( CALC_NOERR );
- }
- pFmtFld->ModifyNotification( 0, pHt );
- }
- }
-
- // calculate the formula at the boxes
- for (sal_uInt32 i = 0; i < nMaxItems; ++i )
- {
- if( 0 != (pItem = GetAttrPool().GetItem2( RES_BOXATR_FORMULA, i ) ) &&
- ((SwTblBoxFormula*)pItem)->GetDefinedIn() &&
- !((SwTblBoxFormula*)pItem)->IsValid() )
- {
- SwTblBoxFormula* pFml = (SwTblBoxFormula*)pItem;
- SwTableBox* pBox = pFml->GetTableBox();
- if( pBox && pBox->GetSttNd() &&
- pBox->GetSttNd()->GetNodes().IsDocNodes() )
- {
- const SwTableNode* pTblNd = pBox->GetSttNd()->FindTableNode();
- if( !pHt || &pTblNd->GetTable() ==
- ((SwTableFmlUpdate*)pHt)->pTbl )
- {
- double nValue;
- if( !pCalc )
- pCalc = new SwCalc( *this );
-
- // get the values of all SetExpression fields that are valid
- // until the table
- SwFrm* pFrm = 0;
- if( pTblNd->GetIndex() < GetNodes().GetEndOfExtras().GetIndex() )
- {
- // is in the special section, that's expensive!
- Point aPt; // return the first frame of the layout - Tab.Headline!!
- SwNodeIndex aCNdIdx( *pTblNd, +2 );
- SwCntntNode* pCNd = aCNdIdx.GetNode().GetCntntNode();
- if( !pCNd )
- pCNd = GetNodes().GoNext( &aCNdIdx );
-
- if( pCNd && 0 != (pFrm = pCNd->getLayoutFrm( GetCurrentLayout(), &aPt )) )
- {
- SwPosition aPos( *pCNd );
- if( GetBodyTxtNode( *this, aPos, *pFrm ) )
- FldsToCalc( *pCalc, _SetGetExpFld( aPos.nNode ));
- else
- pFrm = 0;
- }
- }
- if( !pFrm )
- {
- // create index to determine the TextNode
- SwNodeIndex aIdx( *pTblNd );
- FldsToCalc( *pCalc, _SetGetExpFld( aIdx ));
- }
-
- SwTblCalcPara aPara( *pCalc, pTblNd->GetTable() );
- pFml->Calc( aPara, nValue );
-
- if( aPara.IsStackOverflow() )
- {
- bool const bResult = aPara.CalcWithStackOverflow();
- if (bResult)
- {
- pFml->Calc( aPara, nValue );
- }
- OSL_ENSURE(bResult,
- "the chained formula could no be calculated");
- }
-
- SwFrmFmt* pFmt = pBox->ClaimFrmFmt();
- SfxItemSet aTmp( GetAttrPool(),
- RES_BOXATR_BEGIN,RES_BOXATR_END-1 );
-
- if( pCalc->IsCalcError() )
- nValue = DBL_MAX;
- aTmp.Put( SwTblBoxValue( nValue ));
- if( SFX_ITEM_SET != pFmt->GetItemState( RES_BOXATR_FORMAT ))
- aTmp.Put( SwTblBoxNumFormat( 0 ));
- pFmt->SetFmtAttr( aTmp );
-
- pCalc->SetCalcError( CALC_NOERR );
- }
- }
- }
- }
-
- delete pCalc;
-}
-
-void SwDoc::UpdatePageFlds( SfxPoolItem* pMsgHnt )
-{
- SwFieldType* pFldType;
- for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i )
- switch( ( pFldType = (*mpFldTypes)[ i ] )->Which() )
- {
- case RES_PAGENUMBERFLD:
- case RES_CHAPTERFLD:
- case RES_GETEXPFLD:
- case RES_REFPAGEGETFLD:
- pFldType->ModifyNotification( 0, pMsgHnt );
- break;
- case RES_DOCSTATFLD:
- pFldType->ModifyNotification( 0, 0 );
- break;
- }
- SetNewFldLst(true);
-}
-
-/// Remove all unreferenced field types of a document
-void SwDoc::GCFieldTypes()
-{
- for( sal_uInt16 n = mpFldTypes->size(); n > INIT_FLDTYPES; )
- if( !(*mpFldTypes)[ --n ]->GetDepends() )
- RemoveFldType( n );
-}
-
-void SwDoc::LockExpFlds()
-{
- ++mnLockExpFld;
-}
-
-void SwDoc::UnlockExpFlds()
-{
- if( mnLockExpFld )
- --mnLockExpFld;
-}
-
-bool SwDoc::IsExpFldsLocked() const
-{
- return 0 != mnLockExpFld;
-}
-
-SwDocUpdtFld& SwDoc::GetUpdtFlds() const
-{
- return *mpUpdtFlds;
-}
-
-bool SwDoc::IsNewFldLst() const
-{
- return mbNewFldLst;
-}
-
-void SwDoc::SetNewFldLst(bool bFlag)
-{
- mbNewFldLst = bFlag;
-}
-
// the StartIndex can be supplied optionally (e.g. if it was queried before - is a virtual
// method otherwise!)
_SetGetExpFld::_SetGetExpFld(
@@ -998,647 +352,6 @@ OUString LookString( SwHash** ppTbl, sal_uInt16 nSize, const OUString& rName,
return OUString();
}
-#if HAVE_FEATURE_DBCONNECTIVITY
-
-static OUString lcl_GetDBVarName( SwDoc& rDoc, SwDBNameInfField& rDBFld )
-{
- SwDBData aDBData( rDBFld.GetDBData( &rDoc ));
- OUString sDBNumNm;
- SwDBData aDocData = rDoc.GetDBData();
-
- if( aDBData != aDocData )
- {
- sDBNumNm = aDBData.sDataSource;
- sDBNumNm += OUString(DB_DELIM);
- sDBNumNm += aDBData.sCommand;
- sDBNumNm += OUString(DB_DELIM);
- }
- sDBNumNm += SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD);
-
- return sDBNumNm;
-}
-
-#endif
-
-static void lcl_CalcFld( SwDoc& rDoc, SwCalc& rCalc, const _SetGetExpFld& rSGEFld,
- SwDBManager* pMgr )
-{
- const SwTxtFld* pTxtFld = rSGEFld.GetTxtFld();
- if( !pTxtFld )
- return ;
-
- const SwField* pFld = pTxtFld->GetFmtFld().GetField();
- const sal_uInt16 nFldWhich = pFld->GetTyp()->Which();
-
- if( RES_SETEXPFLD == nFldWhich )
- {
- SwSbxValue aValue;
- if( nsSwGetSetExpType::GSE_EXPR & pFld->GetSubType() )
- aValue.PutDouble( ((SwSetExpField*)pFld)->GetValue() );
- else
- // Extension to calculate with Strings
- aValue.PutString( ((SwSetExpField*)pFld)->GetExpStr() );
-
- // set the new value in Calculator
- rCalc.VarChange( pFld->GetTyp()->GetName(), aValue );
- }
- else if( pMgr )
- {
-#if !HAVE_FEATURE_DBCONNECTIVITY
- (void) rDoc;
-#else
- switch( nFldWhich )
- {
- case RES_DBNUMSETFLD:
- {
- SwDBNumSetField* pDBFld = (SwDBNumSetField*)pFld;
-
- SwDBData aDBData(pDBFld->GetDBData(&rDoc));
-
- if( pDBFld->IsCondValid() &&
- pMgr->OpenDataSource( aDBData.sDataSource, aDBData.sCommand ))
- rCalc.VarChange( lcl_GetDBVarName( rDoc, *pDBFld),
- pDBFld->GetFormat() );
- }
- break;
- case RES_DBNEXTSETFLD:
- {
- SwDBNextSetField* pDBFld = (SwDBNextSetField*)pFld;
- SwDBData aDBData(pDBFld->GetDBData(&rDoc));
- if( !pDBFld->IsCondValid() ||
- !pMgr->OpenDataSource( aDBData.sDataSource, aDBData.sCommand ))
- break;
-
- OUString sDBNumNm(lcl_GetDBVarName( rDoc, *pDBFld));
- SwCalcExp* pExp = rCalc.VarLook( sDBNumNm );
- if( pExp )
- rCalc.VarChange( sDBNumNm, pExp->nValue.GetLong() + 1 );
- }
- break;
-
- }
-#endif
- }
-}
-
-void SwDoc::FldsToCalc( SwCalc& rCalc, const _SetGetExpFld& rToThisFld )
-{
- // create the sorted list of all SetFields
- mpUpdtFlds->MakeFldList( *this, mbNewFldLst, GETFLD_CALC );
- mbNewFldLst = false;
-
-#if !HAVE_FEATURE_DBCONNECTIVITY
- SwDBManager* pMgr = NULL;
-#else
- SwDBManager* pMgr = GetDBManager();
- pMgr->CloseAll(false);
-#endif
-
- if( !mpUpdtFlds->GetSortLst()->empty() )
- {
- _SetGetExpFlds::const_iterator const itLast =
- mpUpdtFlds->GetSortLst()->upper_bound(
- const_cast<_SetGetExpFld*>(&rToThisFld));
- for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin(); it != itLast; ++it )
- lcl_CalcFld( *this, rCalc, **it, pMgr );
- }
-#if HAVE_FEATURE_DBCONNECTIVITY
- pMgr->CloseAll(false);
-#endif
-}
-
-void SwDoc::FldsToCalc( SwCalc& rCalc, sal_uLong nLastNd, sal_uInt16 nLastCnt )
-{
- // create the sorted list of all SetFields
- mpUpdtFlds->MakeFldList( *this, mbNewFldLst, GETFLD_CALC );
- mbNewFldLst = false;
-
-#if !HAVE_FEATURE_DBCONNECTIVITY
- SwDBManager* pMgr = NULL;
-#else
- SwDBManager* pMgr = GetDBManager();
- pMgr->CloseAll(false);
-#endif
-
- for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin();
- it != mpUpdtFlds->GetSortLst()->end() &&
- ( (*it)->GetNode() < nLastNd ||
- ( (*it)->GetNode() == nLastNd && (*it)->GetCntnt() <= nLastCnt )
- );
- ++it )
- {
- lcl_CalcFld( *this, rCalc, **it, pMgr );
- }
-
-#if HAVE_FEATURE_DBCONNECTIVITY
- pMgr->CloseAll(false);
-#endif
-}
-
-void SwDoc::FldsToExpand( SwHash**& ppHashTbl, sal_uInt16& rTblSize,
- const _SetGetExpFld& rToThisFld )
-{
- // create the sorted list of all SetFields
- mpUpdtFlds->MakeFldList( *this, mbNewFldLst, GETFLD_EXPAND );
- mbNewFldLst = false;
-
- // Hash table for all string replacements is filled on-the-fly.
- // Try to fabricate an uneven number.
- rTblSize = (( mpUpdtFlds->GetSortLst()->size() / 7 ) + 1 ) * 7;
- ppHashTbl = new SwHash*[ rTblSize ];
- memset( ppHashTbl, 0, sizeof( _HashStr* ) * rTblSize );
-
- _SetGetExpFlds::const_iterator const itLast =
- mpUpdtFlds->GetSortLst()->upper_bound(
- const_cast<_SetGetExpFld*>(&rToThisFld));
-
- for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin(); it != itLast; ++it )
- {
- const SwTxtFld* pTxtFld = (*it)->GetTxtFld();
- if( !pTxtFld )
- continue;
-
- const SwField* pFld = pTxtFld->GetFmtFld().GetField();
- switch( pFld->GetTyp()->Which() )
- {
- case RES_SETEXPFLD:
- if( nsSwGetSetExpType::GSE_STRING & pFld->GetSubType() )
- {
- // set the new value in the hash table
- // is the formula a field?
- SwSetExpField* pSFld = (SwSetExpField*)pFld;
- OUString aNew = LookString( ppHashTbl, rTblSize, pSFld->GetFormula() );
-
- if( aNew.isEmpty() ) // nothing found, then the formula is
- aNew = pSFld->GetFormula(); // the new value
-
- // #i3141# - update expression of field as in method
- // <SwDoc::UpdateExpFlds(..)> for string/text fields
- pSFld->ChgExpStr( aNew );
-
- // look up the field's name
- aNew = ((SwSetExpFieldType*)pSFld->GetTyp())->GetSetRefName();
- // Entry present?
- sal_uInt16 nPos;
- SwHash* pFnd = Find( aNew, ppHashTbl, rTblSize, &nPos );
- if( pFnd )
- // modify entry in the hash table
- ((_HashStr*)pFnd)->aSetStr = pSFld->GetExpStr();
- else
- // insert the new entry
- *(ppHashTbl + nPos ) = new _HashStr( aNew,
- pSFld->GetExpStr(), (_HashStr*)*(ppHashTbl + nPos) );
- }
- break;
- case RES_DBFLD:
- {
- const OUString& rName = pFld->GetTyp()->GetName();
-
- // Insert entry in the hash table
- // Entry present?
- sal_uInt16 nPos;
- SwHash* pFnd = Find( rName, ppHashTbl, rTblSize, &nPos );
- OUString const value(pFld->ExpandField(IsClipBoard()));
- if( pFnd )
- {
- // modify entry in the hash table
- static_cast<_HashStr*>(pFnd)->aSetStr = value;
- }
- else
- {
- // insert the new entry
- *(ppHashTbl + nPos ) = new _HashStr( rName,
- value, static_cast<_HashStr *>(*(ppHashTbl + nPos)));
- }
- }
- break;
- }
- }
-}
-
-void SwDoc::UpdateExpFlds( SwTxtFld* pUpdtFld, bool bUpdRefFlds )
-{
- if( IsExpFldsLocked() || IsInReading() )
- return;
-
- bool bOldInUpdateFlds = mpUpdtFlds->IsInUpdateFlds();
- mpUpdtFlds->SetInUpdateFlds( true );
-
- mpUpdtFlds->MakeFldList( *this, true, GETFLD_ALL );
- mbNewFldLst = false;
-
- if( mpUpdtFlds->GetSortLst()->empty() )
- {
- if( bUpdRefFlds )
- UpdateRefFlds(NULL);
-
- mpUpdtFlds->SetInUpdateFlds( bOldInUpdateFlds );
- mpUpdtFlds->SetFieldsDirty( false );
- return ;
- }
-
- sal_uInt16 nWhich, n;
-
- // Hash table for all string replacements is filled on-the-fly.
- // Try to fabricate an uneven number.
- sal_uInt16 nStrFmtCnt = (( mpFldTypes->size() / 7 ) + 1 ) * 7;
- SwHash** pHashStrTbl = new SwHash*[ nStrFmtCnt ];
- memset( pHashStrTbl, 0, sizeof( _HashStr* ) * nStrFmtCnt );
-
- {
- const SwFieldType* pFldType;
- // process separately:
- for( n = mpFldTypes->size(); n; )
- switch( ( pFldType = (*mpFldTypes)[ --n ] )->Which() )
- {
- case RES_USERFLD:
- {
- // Entry present?
- sal_uInt16 nPos;
- const OUString& rNm = pFldType->GetName();
- OUString sExpand(((SwUserFieldType*)pFldType)->Expand(nsSwGetSetExpType::GSE_STRING, 0, 0));
- SwHash* pFnd = Find( rNm, pHashStrTbl, nStrFmtCnt, &nPos );
- if( pFnd )
- // modify entry in the hash table
- ((_HashStr*)pFnd)->aSetStr = sExpand;
- else
- // insert the new entry
- *(pHashStrTbl + nPos ) = new _HashStr( rNm, sExpand,
- (_HashStr*)*(pHashStrTbl + nPos) );
- }
- break;
- case RES_SETEXPFLD:
- ((SwSetExpFieldType*)pFldType)->SetOutlineChgNd( 0 );
- break;
- }
- }
-
- // The array is filled with all fields; start calculation.
- SwCalc aCalc( *this );
-
-#if HAVE_FEATURE_DBCONNECTIVITY
- OUString sDBNumNm( SwFieldType::GetTypeStr( TYP_DBSETNUMBERFLD ) );
-
- // already set the current record number
- SwDBManager* pMgr = GetDBManager();
- pMgr->CloseAll(false);
-#endif
-
- // Make sure we don't hide all sections, which would lead to a crash. First, count how many of them do we have.
- int nShownSections = 0;
- for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin(); it != mpUpdtFlds->GetSortLst()->end(); ++it )
- {
- SwSection* pSect = (SwSection*)(*it)->GetSection();
- if ( pSect && !pSect->IsCondHidden())
- nShownSections++;
- }
-
- OUString aNew;
- for( _SetGetExpFlds::const_iterator it = mpUpdtFlds->GetSortLst()->begin(); it != mpUpdtFlds->GetSortLst()->end(); ++it )
- {
- SwSection* pSect = (SwSection*)(*it)->GetSection();
- if( pSect )
- {
-
- SwSbxValue aValue = aCalc.Calculate(
- pSect->GetCondition() );
- if(!aValue.IsVoidValue())
- {
- // Do we want to hide this one?
- bool bHide = aValue.GetBool();
- if (bHide && !pSect->IsCondHidden())
- {
- // This section will be hidden, but it wasn't before
- if (nShownSections == 1)
- {
- // Is the last node part of a section?
- SwPaM aPam(GetNodes());
- aPam.Move(fnMoveForward, fnGoDoc);
- if (aPam.Start()->nNode.GetNode().StartOfSectionNode()->IsSectionNode())
- {
- // This would be the last section, so set its condition to false, and avoid hiding it.
- OUString aCond("0");
- pSect->SetCondition(aCond);
- bHide = false;
- }
- }
- nShownSections--;
- }
- pSect->SetCondHidden( bHide );
- }
- continue;
- }
-
- SwTxtFld* pTxtFld = (SwTxtFld*)(*it)->GetTxtFld();
- if( !pTxtFld )
- {
- OSL_ENSURE( false, "what's wrong now'" );
- continue;
- }
-
- SwFmtFld* pFmtFld = (SwFmtFld*)&pTxtFld->GetFmtFld();
- const SwField* pFld = pFmtFld->GetField();
-
- switch( nWhich = pFld->GetTyp()->Which() )
- {
- case RES_HIDDENTXTFLD:
- {
- SwHiddenTxtField* pHFld = (SwHiddenTxtField*)pFld;
- SwSbxValue aValue = aCalc.Calculate( pHFld->GetPar1() );
- bool bValue = !aValue.GetBool();
- if(!aValue.IsVoidValue())
- {
- pHFld->SetValue( bValue );
- // evaluate field
- pHFld->Evaluate(this);
- }
- }
- break;
- case RES_HIDDENPARAFLD:
- {
- SwHiddenParaField* pHPFld = (SwHiddenParaField*)pFld;
- SwSbxValue aValue = aCalc.Calculate( pHPFld->GetPar1() );
- bool bValue = aValue.GetBool();
- if(!aValue.IsVoidValue())
- pHPFld->SetHidden( bValue );
- }
- break;
- case RES_DBSETNUMBERFLD:
-#if HAVE_FEATURE_DBCONNECTIVITY
- {
- ((SwDBSetNumberField*)pFld)->Evaluate(this);
- aCalc.VarChange( sDBNumNm, ((SwDBSetNumberField*)pFld)->GetSetNumber());
- }
-#endif
- break;
- case RES_DBNEXTSETFLD:
- case RES_DBNUMSETFLD:
-#if HAVE_FEATURE_DBCONNECTIVITY
- {
- UpdateDBNumFlds( *(SwDBNameInfField*)pFld, aCalc );
- }
-#endif
- break;
- case RES_DBFLD:
- {
-#if HAVE_FEATURE_DBCONNECTIVITY
- // evaluate field
- ((SwDBField*)pFld)->Evaluate();
-
- SwDBData aTmpDBData(((SwDBField*)pFld)->GetDBData());
-
- if( pMgr->IsDataSourceOpen(aTmpDBData.sDataSource, aTmpDBData.sCommand, false))
- aCalc.VarChange( sDBNumNm, pMgr->GetSelectedRecordId(aTmpDBData.sDataSource, aTmpDBData.sCommand, aTmpDBData.nCommandType));
-
- const OUString& rName = pFld->GetTyp()->GetName();
-
- // Add entry to hash table
- // Entry present?
- sal_uInt16 nPos;
- SwHash* pFnd = Find( rName, pHashStrTbl, nStrFmtCnt, &nPos );
- OUString const value(pFld->ExpandField(IsClipBoard()));
- if( pFnd )
- {
- // Modify entry in the hash table
- static_cast<_HashStr*>(pFnd)->aSetStr = value;
- }
- else
- {
- // insert new entry
- *(pHashStrTbl + nPos ) = new _HashStr( rName,
- value, static_cast<_HashStr *>(*(pHashStrTbl + nPos)));
- }
-#endif
- }
- break;
- case RES_GETEXPFLD:
- case RES_SETEXPFLD:
- {
- if( nsSwGetSetExpType::GSE_STRING & pFld->GetSubType() ) // replace String
- {
- if( RES_GETEXPFLD == nWhich )
- {
- SwGetExpField* pGFld = (SwGetExpField*)pFld;
-
- if( (!pUpdtFld || pUpdtFld == pTxtFld )
- && pGFld->IsInBodyTxt() )
- {
- aNew = LookString( pHashStrTbl, nStrFmtCnt,
- pGFld->GetFormula() );
- pGFld->ChgExpStr( aNew );
- }
- }
- else
- {
- SwSetExpField* pSFld = (SwSetExpField*)pFld;
- // is the "formula" a field?
- aNew = LookString( pHashStrTbl, nStrFmtCnt,
- pSFld->GetFormula() );
-
- if( aNew.isEmpty() ) // nothing found then the formula is the new value
- aNew = pSFld->GetFormula();
-
- // only update one field
- if( !pUpdtFld || pUpdtFld == pTxtFld )
- pSFld->ChgExpStr( aNew );
-
- // lookup the field's name
- aNew = ((SwSetExpFieldType*)pSFld->GetTyp())->GetSetRefName();
- // Entry present?
- sal_uInt16 nPos;
- SwHash* pFnd = Find( aNew, pHashStrTbl, nStrFmtCnt, &nPos );
- if( pFnd )
- // Modify entry in the hash table
- ((_HashStr*)pFnd)->aSetStr = pSFld->GetExpStr();
- else
- // insert new entry
- *(pHashStrTbl + nPos ) = pFnd = new _HashStr( aNew,
- pSFld->GetExpStr(),
- (_HashStr*)*(pHashStrTbl + nPos) );
-
- // Extension for calculation with Strings
- SwSbxValue aValue;
- aValue.PutString( ((_HashStr*)pFnd)->aSetStr );
- aCalc.VarChange( aNew, aValue );
- }
- }
- else // recalculate formula
- {
- if( RES_GETEXPFLD == nWhich )
- {
- SwGetExpField* pGFld = (SwGetExpField*)pFld;
-
- if( (!pUpdtFld || pUpdtFld == pTxtFld )
- && pGFld->IsInBodyTxt() )
- {
- SwSbxValue aValue = aCalc.Calculate(
- pGFld->GetFormula());
- if(!aValue.IsVoidValue())
- pGFld->SetValue(aValue.GetDouble() );
- }
- }
- else
- {
- SwSetExpField* pSFld = (SwSetExpField*)pFld;
- SwSetExpFieldType* pSFldTyp = (SwSetExpFieldType*)pFld->GetTyp();
- aNew = pSFldTyp->GetName();
-
- SwNode* pSeqNd = 0;
-
- if( pSFld->IsSequenceFld() )
- {
- const sal_uInt8 nLvl = pSFldTyp->GetOutlineLvl();
- if( MAXLEVEL > nLvl )
- {
- // test if the Number needs to be updated
- pSeqNd = GetNodes()[ (*it)->GetNode() ];
-
- const SwTxtNode* pOutlNd = pSeqNd->
- FindOutlineNodeOfLevel( nLvl );
- if( pSFldTyp->GetOutlineChgNd() != pOutlNd )
- {
- pSFldTyp->SetOutlineChgNd( pOutlNd );
- aCalc.VarChange( aNew, 0 );
- }
- }
- }
-
- aNew += "=";
- aNew += pSFld->GetFormula();
-
- SwSbxValue aValue = aCalc.Calculate( aNew );
- double nErg = aValue.GetDouble();
- // only update one field
- if( !aValue.IsVoidValue() && (!pUpdtFld || pUpdtFld == pTxtFld) )
- {
- pSFld->SetValue( nErg );
-
- if( pSeqNd )
- pSFldTyp->SetChapter( *pSFld, *pSeqNd );
- }
- }
- }
- }
- } // switch
-
- pFmtFld->ModifyNotification( 0, 0 ); // trigger formatting
-
- if( pUpdtFld == pTxtFld ) // if only this one is updated
- {
- if( RES_GETEXPFLD == nWhich || // only GetField or
- RES_HIDDENTXTFLD == nWhich || // HiddenTxt?
- RES_HIDDENPARAFLD == nWhich) // HiddenParaFld?
- break; // quit
- pUpdtFld = 0; // update all from here on
- }
- }
-
-#if HAVE_FEATURE_DBCONNECTIVITY
- pMgr->CloseAll(false);
-#endif
- // delete hash table
- ::DeleteHashTable( pHashStrTbl, nStrFmtCnt );
-
- // update reference fields
- if( bUpdRefFlds )
- UpdateRefFlds(NULL);
-
- mpUpdtFlds->SetInUpdateFlds( bOldInUpdateFlds );
- mpUpdtFlds->SetFieldsDirty( false );
-}
-
-void SwDoc::UpdateDBNumFlds( SwDBNameInfField& rDBFld, SwCalc& rCalc )
-{
-#if !HAVE_FEATURE_DBCONNECTIVITY
- (void) rDBFld;
- (void) rCalc;
-#else
- SwDBManager* pMgr = GetDBManager();
-
- sal_uInt16 nFldType = rDBFld.Which();
-
- bool bPar1 = rCalc.Calculate( rDBFld.GetPar1() ).GetBool();
-
- if( RES_DBNEXTSETFLD == nFldType )
- ((SwDBNextSetField&)rDBFld).SetCondValid( bPar1 );
- else
- ((SwDBNumSetField&)rDBFld).SetCondValid( bPar1 );
-
- if( !rDBFld.GetRealDBData().sDataSource.isEmpty() )
- {
- // Edit a certain database
- if( RES_DBNEXTSETFLD == nFldType )
- ((SwDBNextSetField&)rDBFld).Evaluate(this);
- else
- ((SwDBNumSetField&)rDBFld).Evaluate(this);
-
- SwDBData aTmpDBData( rDBFld.GetDBData(this) );
-
- if( pMgr->OpenDataSource( aTmpDBData.sDataSource, aTmpDBData.sCommand, -1, false ))
- rCalc.VarChange( lcl_GetDBVarName( *this, rDBFld),
- pMgr->GetSelectedRecordId(aTmpDBData.sDataSource, aTmpDBData.sCommand, aTmpDBData.nCommandType) );
- }
- else
- {
- OSL_FAIL("TODO: what should happen with unnamed DBFields?");
- }
-#endif
-}
-
-void SwDoc::_InitFieldTypes() // is being called by the CTOR
-{
- // Field types
- mpFldTypes->push_back( new SwDateTimeFieldType(this) );
- mpFldTypes->push_back( new SwChapterFieldType );
- mpFldTypes->push_back( new SwPageNumberFieldType );
- mpFldTypes->push_back( new SwAuthorFieldType );
- mpFldTypes->push_back( new SwFileNameFieldType(this) );
- mpFldTypes->push_back( new SwDBNameFieldType(this) );
- mpFldTypes->push_back( new SwGetExpFieldType(this) );
- mpFldTypes->push_back( new SwGetRefFieldType( this ) );
- mpFldTypes->push_back( new SwHiddenTxtFieldType );
- mpFldTypes->push_back( new SwPostItFieldType(this) );
- mpFldTypes->push_back( new SwDocStatFieldType(this) );
- mpFldTypes->push_back( new SwDocInfoFieldType(this) );
- mpFldTypes->push_back( new SwInputFieldType( this ) );
- mpFldTypes->push_back( new SwTblFieldType( this ) );
- mpFldTypes->push_back( new SwMacroFieldType(this) );
- mpFldTypes->push_back( new SwHiddenParaFieldType );
- mpFldTypes->push_back( new SwDBNextSetFieldType );
- mpFldTypes->push_back( new SwDBNumSetFieldType );
- mpFldTypes->push_back( new SwDBSetNumberFieldType );
- mpFldTypes->push_back( new SwTemplNameFieldType(this) );
- mpFldTypes->push_back( new SwTemplNameFieldType(this) );
- mpFldTypes->push_back( new SwExtUserFieldType );
- mpFldTypes->push_back( new SwRefPageSetFieldType );
- mpFldTypes->push_back( new SwRefPageGetFieldType( this ) );
- mpFldTypes->push_back( new SwJumpEditFieldType( this ) );
- mpFldTypes->push_back( new SwScriptFieldType( this ) );
- mpFldTypes->push_back( new SwCombinedCharFieldType );
- mpFldTypes->push_back( new SwDropDownFieldType );
-
- // Types have to be at the end!
- // We expect this in the InsertFldType!
- // MIB 14.04.95: In Sw3StringPool::Setup (sw3imp.cxx) and
- // lcl_sw3io_InSetExpField (sw3field.cxx) now also
- mpFldTypes->push_back( new SwSetExpFieldType(this,
- SW_RESSTR(STR_POOLCOLL_LABEL_ABB), nsSwGetSetExpType::GSE_SEQ) );
- mpFldTypes->push_back( new SwSetExpFieldType(this,
- SW_RESSTR(STR_POOLCOLL_LABEL_TABLE), nsSwGetSetExpType::GSE_SEQ) );
- mpFldTypes->push_back( new SwSetExpFieldType(this,
- SW_RESSTR(STR_POOLCOLL_LABEL_FRAME), nsSwGetSetExpType::GSE_SEQ) );
- mpFldTypes->push_back( new SwSetExpFieldType(this,
- SW_RESSTR(STR_POOLCOLL_LABEL_DRAWING), nsSwGetSetExpType::GSE_SEQ) );
-
- assert( mpFldTypes->size() == INIT_FLDTYPES );
-}
-
-void SwDoc::InsDelFldInFldLst( bool bIns, const SwTxtFld& rFld )
-{
- if( !mbNewFldLst || !IsInDtor() )
- mpUpdtFlds->InsDelFldInFldLst( bIns, rFld );
-}
-
SwDBData SwDoc::GetDBData()
{
return GetDBDesc();
@@ -1649,10 +362,10 @@ const SwDBData& SwDoc::GetDBDesc()
#if HAVE_FEATURE_DBCONNECTIVITY
if(maDBData.sDataSource.isEmpty())
{
- const sal_uInt16 nSize = mpFldTypes->size();
+ const sal_uInt16 nSize = getIDocumentFieldsAccess().GetFldTypes()->size();
for(sal_uInt16 i = 0; i < nSize && maDBData.sDataSource.isEmpty(); ++i)
{
- SwFieldType& rFldType = *((*mpFldTypes)[i]);
+ SwFieldType& rFldType = *((*getIDocumentFieldsAccess().GetFldTypes())[i]);
sal_uInt16 nWhich = rFldType.Which();
if(IsUsed(rFldType))
{
@@ -1924,7 +637,7 @@ void SwDoc::ChangeDBFields( const std::vector<OUString>& rOldNames,
{
SwDBFieldType* pOldTyp = (SwDBFieldType*)pFld->GetTyp();
- SwDBFieldType* pTyp = (SwDBFieldType*)InsertFldType(
+ SwDBFieldType* pTyp = (SwDBFieldType*)getIDocumentFieldsAccess().InsertFldType(
SwDBFieldType(this, pOldTyp->GetColumnName(), aNewDBData));
pFmtFld->RegisterToFieldType( *pTyp );
@@ -2040,166 +753,13 @@ bool SwDoc::IsNameInArray( const std::vector<OUString>& rArr, const OUString& rN
return false;
}
-void SwDoc::SetFixFields( bool bOnlyTimeDate, const DateTime* pNewDateTime )
-{
- bool bIsModified = IsModified();
-
- sal_Int32 nDate;
- sal_Int64 nTime;
- if( pNewDateTime )
- {
- nDate = pNewDateTime->GetDate();
- nTime = pNewDateTime->GetTime();
- }
- else
- {
- nDate = Date( Date::SYSTEM ).GetDate();
- nTime = Time( Time::SYSTEM ).GetTime();
- }
-
- sal_uInt16 aTypes[5] = {
- /*0*/ RES_DOCINFOFLD,
- /*1*/ RES_AUTHORFLD,
- /*2*/ RES_EXTUSERFLD,
- /*3*/ RES_FILENAMEFLD,
- /*4*/ RES_DATETIMEFLD }; // MUST be at the end!
-
- sal_uInt16 nStt = bOnlyTimeDate ? 4 : 0;
-
- for( ; nStt < 5; ++nStt )
- {
- SwFieldType* pFldType = GetSysFldType( aTypes[ nStt ] );
- SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
- for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
- {
- if( pFmtFld && pFmtFld->GetTxtFld() )
- {
- bool bChgd = false;
- switch( aTypes[ nStt ] )
- {
- case RES_DOCINFOFLD:
- if( ((SwDocInfoField*)pFmtFld->GetField())->IsFixed() )
- {
- bChgd = true;
- SwDocInfoField* pDocInfFld = (SwDocInfoField*)pFmtFld->GetField();
- pDocInfFld->SetExpansion( ((SwDocInfoFieldType*)
- pDocInfFld->GetTyp())->Expand(
- pDocInfFld->GetSubType(),
- pDocInfFld->GetFormat(),
- pDocInfFld->GetLanguage(),
- pDocInfFld->GetName() ) );
- }
- break;
-
- case RES_AUTHORFLD:
- if( ((SwAuthorField*)pFmtFld->GetField())->IsFixed() )
- {
- bChgd = true;
- SwAuthorField* pAuthorFld = (SwAuthorField*)pFmtFld->GetField();
- pAuthorFld->SetExpansion( ((SwAuthorFieldType*)
- pAuthorFld->GetTyp())->Expand(
- pAuthorFld->GetFormat() ) );
- }
- break;
-
- case RES_EXTUSERFLD:
- if( ((SwExtUserField*)pFmtFld->GetField())->IsFixed() )
- {
- bChgd = true;
- SwExtUserField* pExtUserFld = (SwExtUserField*)pFmtFld->GetField();
- pExtUserFld->SetExpansion( ((SwExtUserFieldType*)
- pExtUserFld->GetTyp())->Expand(
- pExtUserFld->GetSubType(),
- pExtUserFld->GetFormat()));
- }
- break;
-
- case RES_DATETIMEFLD:
- if( ((SwDateTimeField*)pFmtFld->GetField())->IsFixed() )
- {
- bChgd = true;
- ((SwDateTimeField*)pFmtFld->GetField())->SetDateTime(
- DateTime(Date(nDate), Time(nTime)) );
- }
- break;
-
- case RES_FILENAMEFLD:
- if( ((SwFileNameField*)pFmtFld->GetField())->IsFixed() )
- {
- bChgd = true;
- SwFileNameField* pFileNameFld =
- (SwFileNameField*)pFmtFld->GetField();
- pFileNameFld->SetExpansion( ((SwFileNameFieldType*)
- pFileNameFld->GetTyp())->Expand(
- pFileNameFld->GetFormat() ) );
- }
- break;
- }
-
- // Trigger formatting
- if( bChgd )
- pFmtFld->ModifyNotification( 0, 0 );
- }
- }
- }
-
- if( !bIsModified )
- ResetModified();
-}
-
-bool SwDoc::SetFieldsDirty( bool b, const SwNode* pChk, sal_uLong nLen )
-{
- // See if the supplied nodes actually contain fields.
- // If they don't, the flag doesn't need to be changed.
- bool bFldsFnd = false;
- if( b && pChk && !GetUpdtFlds().IsFieldsDirty() && !IsInDtor()
- // ?? what's up with Undo, this is also wanted there!
- /*&& &pChk->GetNodes() == &GetNodes()*/ )
- {
- b = false;
- if( !nLen )
- ++nLen;
- sal_uLong nStt = pChk->GetIndex();
- const SwNodes& rNds = pChk->GetNodes();
- while( nLen-- )
- {
- const SwTxtNode* pTNd = rNds[ nStt++ ]->GetTxtNode();
- if( pTNd )
- {
- if( pTNd->GetAttrOutlineLevel() != 0 )
- // update chapter fields
- b = true;
- else if( pTNd->GetpSwpHints() && pTNd->GetSwpHints().Count() )
- {
- const size_t nEnd = pTNd->GetSwpHints().Count();
- for( size_t n = 0 ; n < nEnd; ++n )
- {
- const SwTxtAttr* pAttr = pTNd->GetSwpHints()[ n ];
- if ( pAttr->Which() == RES_TXTATR_FIELD )
- {
- b = true;
- break;
- }
- }
- }
-
- if( b )
- break;
- }
- }
- bFldsFnd = b;
- }
- GetUpdtFlds().SetFieldsDirty( b );
- return bFldsFnd;
-}
-
void SwDoc::ChangeAuthorityData( const SwAuthEntry* pNewData )
{
- const sal_uInt16 nSize = mpFldTypes->size();
+ const sal_uInt16 nSize = getIDocumentFieldsAccess().GetFldTypes()->size();
for( sal_uInt16 i = INIT_FLDTYPES; i < nSize; ++i )
{
- SwFieldType* pFldType = (*mpFldTypes)[i];
+ SwFieldType* pFldType = (*getIDocumentFieldsAccess().GetFldTypes())[i];
if( RES_AUTHORITY == pFldType->Which() )
{
SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)pFldType;
@@ -2626,119 +1186,4 @@ SwDocUpdtFld::~SwDocUpdtFld()
delete aFldTypeTable[n];
}
-bool SwDoc::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld,
- SwMsgPoolItem * pMsgHnt,
- bool bUpdateFlds)
-{
- OSL_ENSURE(pDstTxtFld, "no field to update!");
-
- bool bTblSelBreak = false;
-
- SwFmtFld * pDstFmtFld = (SwFmtFld*)&pDstTxtFld->GetFmtFld();
- SwField * pDstFld = pDstFmtFld->GetField();
- sal_uInt16 nFldWhich = rSrcFld.GetTyp()->Which();
- SwNodeIndex aTblNdIdx(pDstTxtFld->GetTxtNode());
-
- if (pDstFld->GetTyp()->Which() ==
- rSrcFld.GetTyp()->Which())
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwPosition aPosition( pDstTxtFld->GetTxtNode() );
- aPosition.nContent = pDstTxtFld->GetStart();
-
- SwUndo *const pUndo( new SwUndoFieldFromDoc( aPosition, *pDstFld, rSrcFld, pMsgHnt, bUpdateFlds) );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
-
- SwField * pNewFld = rSrcFld.CopyField();
- pDstFmtFld->SetField(pNewFld);
-
- switch( nFldWhich )
- {
- case RES_SETEXPFLD:
- case RES_GETEXPFLD:
- case RES_HIDDENTXTFLD:
- case RES_HIDDENPARAFLD:
- UpdateExpFlds( pDstTxtFld, true );
- break;
-
- case RES_TABLEFLD:
- {
- const SwTableNode* pTblNd =
- IsIdxInTbl(aTblNdIdx);
- if( pTblNd )
- {
- SwTableFmlUpdate aTblUpdate( &pTblNd->
- GetTable() );
- if (bUpdateFlds)
- UpdateTblFlds( &aTblUpdate );
- else
- pNewFld->GetTyp()->ModifyNotification(0, &aTblUpdate);
-
- if (! bUpdateFlds)
- bTblSelBreak = true;
- }
- }
- break;
-
- case RES_MACROFLD:
- if( bUpdateFlds && pDstTxtFld->GetpTxtNode() )
- (pDstTxtFld->GetpTxtNode())->
- ModifyNotification( 0, pDstFmtFld );
- break;
-
- case RES_DBNAMEFLD:
- case RES_DBNEXTSETFLD:
- case RES_DBNUMSETFLD:
- case RES_DBSETNUMBERFLD:
- ChgDBData(((SwDBNameInfField*) pNewFld)->GetRealDBData());
- pNewFld->GetTyp()->UpdateFlds();
-
- break;
-
- case RES_DBFLD:
-#if HAVE_FEATURE_DBCONNECTIVITY
- {
- // JP 10.02.96: call ChgValue, so that the style change sets the
- // ContentString correctly
- SwDBField* pDBFld = (SwDBField*)pNewFld;
- if (pDBFld->IsInitialized())
- pDBFld->ChgValue( pDBFld->GetValue(), true );
-
- pDBFld->ClearInitialized();
- pDBFld->InitContent();
- }
-#endif
- // no break;
-
- default:
- pDstFmtFld->ModifyNotification( 0, pMsgHnt );
- }
-
- // The fields we can calculate here are being triggered for an update
- // here explicitly.
- if( nFldWhich == RES_USERFLD )
- UpdateUsrFlds();
- }
-
- return bTblSelBreak;
-}
-
-bool SwDoc::PutValueToField(const SwPosition & rPos,
- const Any& rVal, sal_uInt16 nWhich)
-{
- Any aOldVal;
- SwField * pField = GetFieldAtPos(rPos);
-
- if (GetIDocumentUndoRedo().DoesUndo() &&
- pField->QueryValue(aOldVal, nWhich))
- {
- SwUndo *const pUndo(new SwUndoFieldFromAPI(rPos, aOldVal, rVal, nWhich));
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
-
- return pField->PutValue(rVal, nWhich);
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index cf594d229f1a..1fe1f3cd36fa 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -38,6 +38,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <DocumentContentOperationsManager.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <rootfrm.hxx>
#include <pagefrm.hxx>
#include <hints.hxx>
@@ -1722,7 +1723,7 @@ SwTblNumFmtMerge::SwTblNumFmtMerge( const SwDoc& rSrc, SwDoc& rDest )
( pNFmt = rDest.GetNumberFormatter( true ))->MergeFormatter( *pN );
if( &rSrc != &rDest )
- ((SwGetRefFieldType*)rSrc.GetSysFldType( RES_GETREFFLD ))->
+ ((SwGetRefFieldType*)rSrc.getIDocumentFieldsAccess().GetSysFldType( RES_GETREFFLD ))->
MergeWithOtherDoc( rDest );
}
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index 54f0469fa010..eb7dad4b3acc 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -28,6 +28,7 @@
#include <hints.hxx>
#include <rolbck.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <IDocumentUndoRedo.hxx>
#include <ndtxt.hxx>
#include <poolfmt.hxx>
@@ -308,7 +309,7 @@ void SwDoc::SetFtnInfo(const SwFtnInfo& rInfo)
// #i81002# no update during loading
if ( !IsInReading() )
{
- UpdateRefFlds(NULL);
+ getIDocumentFieldsAccess().UpdateRefFlds(NULL);
}
SetModified();
}
@@ -376,7 +377,7 @@ void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo)
// #i81002# no update during loading
if ( !IsInReading() )
{
- UpdateRefFlds(NULL);
+ getIDocumentFieldsAccess().UpdateRefFlds(NULL);
}
SetModified();
}
diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx
index 79cfe2aeef70..593e25742cba 100644
--- a/sw/source/core/doc/docglos.cxx
+++ b/sw/source/core/doc/docglos.cxx
@@ -24,6 +24,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <shellio.hxx>
#include <pam.hxx>
#include <swundo.hxx>
@@ -126,10 +127,10 @@ bool SwDoc::InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry,
xGlosDPS->getDocumentProperties() );
lcl_copyDocumentProperties(xDocProps, xGlosDocProps);
}
- pGDoc->SetFixFields(false, NULL);
+ pGDoc->getIDocumentFieldsAccess().SetFixFields(false, NULL);
// StartAllAction();
- LockExpFlds();
+ getIDocumentFieldsAccess().LockExpFlds();
SwNodeIndex aStt( pGDoc->GetNodes().GetEndOfExtras(), 1 );
SwCntntNode* pCntntNd = pGDoc->GetNodes().GoNext( &aStt );
@@ -172,9 +173,9 @@ bool SwDoc::InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry,
__pStartCrsr );
GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL );
- UnlockExpFlds();
- if( !IsExpFldsLocked() )
- UpdateExpFlds(NULL, true);
+ getIDocumentFieldsAccess().UnlockExpFlds();
+ if( !getIDocumentFieldsAccess().IsExpFldsLocked() )
+ getIDocumentFieldsAccess().UpdateExpFlds(NULL, true);
bRet = true;
}
mbInsOnlyTxtGlssry = bSav_IsInsGlossary;
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 3595506b482d..3d858708bd18 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -66,6 +66,7 @@
#include <DocumentSettingManager.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <DocumentContentOperationsManager.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <rootfrm.hxx>
#include <pagefrm.hxx>
#include <cntfrm.hxx>
@@ -1043,9 +1044,9 @@ lcl_InsertLabel(SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl,
bool bTable = false; // To save some code.
// Get the field first, because we retrieve the TxtColl via the field's name
- OSL_ENSURE( nId == USHRT_MAX || nId < rDoc.GetFldTypes()->size(),
+ OSL_ENSURE( nId == USHRT_MAX || nId < rDoc.getIDocumentFieldsAccess().GetFldTypes()->size(),
"FldType index out of bounds." );
- SwFieldType *pType = (nId != USHRT_MAX) ? (*rDoc.GetFldTypes())[nId] : NULL;
+ SwFieldType *pType = (nId != USHRT_MAX) ? (*rDoc.getIDocumentFieldsAccess().GetFldTypes())[nId] : NULL;
OSL_ENSURE(!pType || pType->Which() == RES_SETEXPFLD, "wrong Id for Label");
SwTxtFmtColl * pColl = NULL;
@@ -1392,9 +1393,9 @@ lcl_InsertDrawLabel( SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl,
::sw::DrawUndoGuard const drawUndoGuard(rDoc.GetIDocumentUndoRedo());
// Because we get by the TxtColl's name, we need to create the field first.
- OSL_ENSURE( nId == USHRT_MAX || nId < rDoc.GetFldTypes()->size(),
+ OSL_ENSURE( nId == USHRT_MAX || nId < rDoc.getIDocumentFieldsAccess().GetFldTypes()->size(),
"FldType index out of bounds" );
- SwFieldType *pType = nId != USHRT_MAX ? (*rDoc.GetFldTypes())[nId] : 0;
+ SwFieldType *pType = nId != USHRT_MAX ? (*rDoc.getIDocumentFieldsAccess().GetFldTypes())[nId] : 0;
OSL_ENSURE( !pType || pType->Which() == RES_SETEXPFLD, "Wrong label id" );
SwTxtFmtColl *pColl = NULL;
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 23ea7e02093d..444e46ccd2d3 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -98,6 +98,7 @@
#include <DocumentOutlineNodesManager.hxx>
#include <DocumentContentOperationsManager.hxx>
#include <DocumentRedlineManager.hxx>
+#include <DocumentFieldsManager.hxx>
#include <unochart.hxx>
#include <fldbas.hxx>
@@ -211,6 +212,7 @@ SwDoc::SwDoc()
m_pDocumentListsManager( new ::sw::DocumentListsManager( *this ) ),
m_pDocumentOutlineNodesManager( new ::sw::DocumentOutlineNodesManager( *this ) ),
m_pDocumentContentOperationsManager( new ::sw::DocumentContentOperationsManager( *this ) ),
+ m_pDocumentFieldsManager( new ::sw::DocumentFieldsManager( *this ) ),
mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ),
mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ),
@@ -227,8 +229,6 @@ SwDoc::SwDoc()
mpTOXTypes( new SwTOXTypes() ),
mpDefTOXBases( new SwDefTOXBase_Impl() ),
mpCurrentView( 0 ),
- mpUpdtFlds( new SwDocUpdtFld( this ) ),
- mpFldTypes( new SwFldTypes() ),
mpGlossaryDoc( 0 ),
mpOutlineRule( 0 ),
mpFtnInfo( new SwFtnInfo ),
@@ -251,7 +251,6 @@ SwDoc::SwDoc()
mpGrammarContact(createGrammarContact()),
m_pXmlIdRegistry(),
mReferenceCount(0),
- mnLockExpFld( 0 ),
mbGlossDoc(false),
mbModified(false),
mbDtor(false),
@@ -259,7 +258,6 @@ SwDoc::SwDoc()
mbLoaded(false),
mbUpdateExpFld(false),
mbNewDoc(false),
- mbNewFldLst(true),
mbCopyIsMove(false),
mbInReading(false),
mbInXMLImport(false),
@@ -322,7 +320,7 @@ SwDoc::SwDoc()
// Set BodyFmt for columns
mpColumnContFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) );
- _InitFieldTypes();
+ GetDocumentFieldsManager()._InitFieldTypes();
// Create a default OutlineNumRule (for Filters)
mpOutlineRule = new SwNumRule( SwNumRule::GetOutlineRuleName(),
@@ -473,7 +471,6 @@ SwDoc::~SwDoc()
getIDocumentRedlineAccess().GetExtraRedlineTbl().DeleteAndDestroyAll();
delete mpUnoCrsrTbl;
- delete mpUpdtFlds;
delete mpACEWord;
// Release the BaseLinks
@@ -622,7 +619,6 @@ SwDoc::~SwDoc()
delete mpEndNoteInfo;
delete mpLineNumberInfo;
delete mpFtnIdxs;
- delete mpFldTypes;
delete mpTOXTypes;
delete mpDocStat;
delete mpEmptyPageFmt;
@@ -774,10 +770,7 @@ void SwDoc::ClearDoc()
mxForbiddenCharsTable.clear();
- for(SwFldTypes::const_iterator it = mpFldTypes->begin() + INIT_FLDTYPES;
- it != mpFldTypes->end(); ++it)
- delete *it;
- mpFldTypes->erase( mpFldTypes->begin() + INIT_FLDTYPES, mpFldTypes->end() );
+ GetDocumentFieldsManager().ClearFieldTypes();
delete mpNumberFormatter, mpNumberFormatter = 0;
@@ -948,7 +941,7 @@ void SwDoc::Paste( const SwDoc& rSource )
aCpyPam.Move( fnMoveForward, fnGoDoc );
this->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL );
- this->LockExpFlds();
+ this->getIDocumentFieldsAccess().LockExpFlds();
{
SwPosition& rInsPos = *aInsertPam.GetPoint();
@@ -1000,8 +993,8 @@ void SwDoc::Paste( const SwDoc& rSource )
this->GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL );
- UnlockExpFlds();
- UpdateFlds(NULL, false);
+ getIDocumentFieldsAccess().UnlockExpFlds();
+ getIDocumentFieldsAccess().UpdateFlds(NULL, false);
}
sal_uInt16 SwTxtFmtColls::GetPos(const SwTxtFmtColl* p) const
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index decdb5a7b0a7..04e6b2ddc559 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -27,6 +27,7 @@
#include <IDocumentUndoRedo.hxx>
#include <IDocumentListsAccess.hxx>
#include <DocumentRedlineManager.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
#include <doctxm.hxx>
@@ -140,7 +141,7 @@ void SwDoc::SetOutlineNumRule( const SwNumRule& rRule )
if( !GetFtnIdxs().empty() && FTNNUM_CHAPTER == GetFtnInfo().eNum )
GetFtnIdxs().UpdateAllFtn();
- UpdateExpFlds(NULL, true);
+ getIDocumentFieldsAccess().UpdateExpFlds(NULL, true);
SetModified();
}
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index 687cc7885c17..fa3fa254daeb 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -32,6 +32,7 @@
#include <frmfmt.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <node.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -522,7 +523,7 @@ bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt)
// Switch to relative Formulas
SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
aMsgHnt.eFlags = TBL_RELBOXNAME;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
// Table as a flat array structure
FlatFndBox aFlatBox(this, aFndBox);
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index 7cb16d3e4c56..b635e8d2fde4 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -38,6 +38,7 @@
#include <IDocumentUndoRedo.hxx>
#include <DocumentSettingManager.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <pagefrm.hxx>
#include <ndtxt.hxx>
#include <swtable.hxx>
@@ -1261,7 +1262,7 @@ void SwTOXBaseSection::UpdateTemplate( const SwTxtNode* pOwnChapterNode )
void SwTOXBaseSection::UpdateSequence( const SwTxtNode* pOwnChapterNode )
{
SwDoc* pDoc = (SwDoc*)GetFmt()->GetDoc();
- SwFieldType* pSeqFld = pDoc->GetFldType(RES_SETEXPFLD, GetSequenceName(), false);
+ SwFieldType* pSeqFld = pDoc->getIDocumentFieldsAccess().GetFldType(RES_SETEXPFLD, GetSequenceName(), false);
if(!pSeqFld)
return;
@@ -1303,7 +1304,7 @@ void SwTOXBaseSection::UpdateSequence( const SwTxtNode* pOwnChapterNode )
void SwTOXBaseSection::UpdateAuthorities( const SwTOXInternational& rIntl )
{
SwDoc* pDoc = (SwDoc*)GetFmt()->GetDoc();
- SwFieldType* pAuthFld = pDoc->GetFldType(RES_AUTHORITY, OUString(), false);
+ SwFieldType* pAuthFld = pDoc->getIDocumentFieldsAccess().GetFldType(RES_AUTHORITY, OUString(), false);
if(!pAuthFld)
return;
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index bcf61c1099ac..e6bc6ef44afe 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -25,6 +25,7 @@
#include <IDocumentUndoRedo.hxx>
#include <DocumentContentOperationsManager.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <cntfrm.hxx>
#include <pam.hxx>
#include <swtable.hxx>
@@ -697,7 +698,7 @@ bool SwTable::InsNewTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes,
// Change table formulas into relative representation
SwTableFmlUpdate aMsgHnt( &rCpyTbl );
aMsgHnt.eFlags = TBL_RELBOXNAME;
- pCpyDoc->UpdateTblFlds( &aMsgHnt );
+ pCpyDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
}
// delete frames
@@ -747,7 +748,7 @@ bool SwTable::InsTable( const SwTable& rCpyTbl, const SwNodeIndex& rSttBox,
// Convert Table formulas to their relative representation
SwTableFmlUpdate aMsgHnt( &rCpyTbl );
aMsgHnt.eFlags = TBL_RELBOXNAME;
- pCpyDoc->UpdateTblFlds( &aMsgHnt );
+ pCpyDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
}
SwTblNumFmtMerge aTNFM( *pCpyDoc, *pDoc );
@@ -995,7 +996,7 @@ bool SwTable::InsTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes,
// Convert Table formulas to their relative representation
SwTableFmlUpdate aMsgHnt( &rCpyTbl );
aMsgHnt.eFlags = TBL_RELBOXNAME;
- pCpyDoc->UpdateTblFlds( &aMsgHnt );
+ pCpyDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
}
// Delete the Frames
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 7101be27602f..2575f19fea8a 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -33,6 +33,7 @@
#include <IDocumentChartDataProviderAccess.hxx>
#include <DocumentContentOperationsManager.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <cntfrm.hxx>
#include <tabfrm.hxx>
#include <frmtool.hxx>
@@ -2092,7 +2093,7 @@ bool SwTable::CopyHeadlineIntoTable( SwTableNode& rTblNd )
// Convert Table formulas to their relative representation
SwTableFmlUpdate aMsgHnt( this );
aMsgHnt.eFlags = TBL_RELBOXNAME;
- GetFrmFmt()->GetDoc()->UpdateTblFlds( &aMsgHnt );
+ GetFrmFmt()->GetDoc()->getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
}
_CpyTabFrms aCpyFmt;
@@ -2159,7 +2160,7 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos,
{
// A DDE-Table is being copied
// Does the new Document actually have it's FieldType?
- SwFieldType* pFldType = pInsDoc->InsertFldType(
+ SwFieldType* pFldType = pInsDoc->getIDocumentFieldsAccess().InsertFldType(
*((SwDDETable*)this)->GetDDEFldType() );
OSL_ENSURE( pFldType, "unknown FieldType" );
@@ -2179,7 +2180,7 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos,
// Conver the Table formulas to their relative representation
SwTableFmlUpdate aMsgHnt( this );
aMsgHnt.eFlags = TBL_RELBOXNAME;
- pSrcDoc->UpdateTblFlds( &aMsgHnt );
+ pSrcDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
}
SwTblNumFmtMerge aTNFM( *pSrcDoc, *pInsDoc );
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index d403e16b7ee6..37ad94d5baea 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <node.hxx>
#include <frmfmt.hxx>
#include <swtable.hxx>
@@ -271,9 +272,9 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
// Is the field type available in the new document?
pDDEType = ((SwDDETable&)GetTable()).GetDDEFldType();
if( pDDEType->IsDeleted() )
- pDoc->InsDeletedFldType( *pDDEType );
+ pDoc->getIDocumentFieldsAccess().InsDeletedFldType( *pDDEType );
else
- pDDEType = (SwDDEFieldType*)pDoc->InsertFldType( *pDDEType );
+ pDDEType = (SwDDEFieldType*)pDoc->getIDocumentFieldsAccess().InsertFldType( *pDDEType );
OSL_ENSURE( pDDEType, "unknown FieldType" );
// Swap the table pointers in the node
diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx
index efe0567088a0..270c7d4656b3 100644
--- a/sw/source/core/docnode/ndnum.cxx
+++ b/sw/source/core/docnode/ndnum.cxx
@@ -19,6 +19,7 @@
#include <node.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
#include <fldbas.hxx>
@@ -68,7 +69,7 @@ void SwNodes::UpdateOutlineNode(SwNode & rNd)
pTxtNd->UpdateOutlineState();
// update the structure fields
- GetDoc()->GetSysFldType( RES_CHAPTERFLD )->UpdateFlds();
+ GetDoc()->getIDocumentFieldsAccess().GetSysFldType( RES_CHAPTERFLD )->UpdateFlds();
}
}
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 5f3312e6ec10..1084d95420d6 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -29,6 +29,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentLinksAdministration.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <rootfrm.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -339,7 +340,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData,
SwCalc aCalc( *this );
if( ! IsInReading() )
{
- FldsToCalc( aCalc, pNewSectNode->GetIndex(), USHRT_MAX );
+ getIDocumentFieldsAccess().FldsToCalc( aCalc, pNewSectNode->GetIndex(), USHRT_MAX );
}
SwSection& rNewSect = pNewSectNode->GetSection();
rNewSect.SetCondHidden( aCalc.Calculate( rNewSect.GetCondition() ).GetBool() );
@@ -715,7 +716,7 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData,
SwCalc aCalc( *this );
if( !pIdx )
pIdx = pFmt->GetCntnt().GetCntntIdx();
- FldsToCalc( aCalc, pIdx->GetIndex(), USHRT_MAX );
+ getIDocumentFieldsAccess().FldsToCalc( aCalc, pIdx->GetIndex(), USHRT_MAX );
/// Because on using SwSection::operator=() to set up <pSection>
/// with <rNewData> and the above given note, the hidden condition flag
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 380ba88fd77d..c52b0de866bb 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -43,6 +43,7 @@
#include <DocumentSettingManager.hxx>
#include <IDocumentChartDataProviderAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <cntfrm.hxx>
#include <pam.hxx>
#include <swcrsr.hxx>
@@ -871,7 +872,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
}
SetModified();
- SetFieldsDirty(true, NULL, 0);
+ getIDocumentFieldsAccess().SetFieldsDirty(true, NULL, 0);
return pNdTbl;
}
@@ -1225,7 +1226,7 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
aNode2Layout.RestoreUpperFrms( GetNodes(), nIdx, nIdx + 1 );
SetModified();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
return pNdTbl;
}
@@ -1433,7 +1434,7 @@ bool SwDoc::TableToText( const SwTableNode* pTblNd, sal_Unicode cCh )
SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
aMsgHnt.eFlags = TBL_BOXNAME;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
bool bRet = GetNodes().TableToText( aRg, cCh, pUndo );
if( pUndoRg )
@@ -1702,14 +1703,14 @@ bool SwDoc::InsertCol( const SwSelBoxes& rBoxes, sal_uInt16 nCnt, bool bBehind )
SwTableFmlUpdate aMsgHnt( &rTbl );
aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
bRet = rTbl.InsertCol( this, rBoxes, nCnt, bBehind );
if (bRet)
{
SetModified();
::ClearFEShellTabCols();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
}
}
@@ -1764,14 +1765,14 @@ bool SwDoc::InsertRow( const SwSelBoxes& rBoxes, sal_uInt16 nCnt, bool bBehind )
SwTableFmlUpdate aMsgHnt( &rTbl );
aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
bRet = rTbl.InsertRow( this, rBoxes, nCnt, bBehind );
if (bRet)
{
SetModified();
::ClearFEShellTabCols();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
}
}
@@ -2076,7 +2077,7 @@ bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn )
getIDocumentContentOperations().DeleteSection( pTblNd );
}
SetModified();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
return true;
}
@@ -2093,7 +2094,7 @@ bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn )
SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
if (rTable.IsNewModel())
{
@@ -2107,7 +2108,7 @@ bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn )
if (bRet)
{
SetModified();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
}
}
@@ -2165,7 +2166,7 @@ bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, bool bVert, sal_uInt16 nCnt,
SwTableFmlUpdate aMsgHnt( &rTbl );
aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
if (bVert)
bRet = rTbl.SplitCol( this, rBoxes, nCnt );
@@ -2175,7 +2176,7 @@ bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, bool bVert, sal_uInt16 nCnt,
if (bRet)
{
SetModified();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
}
}
@@ -2276,13 +2277,13 @@ sal_uInt16 SwDoc::MergeTbl( SwPaM& rPam )
// Merge them
SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
if( pTblNd->GetTable().Merge( this, aBoxes, aMerged, pMergeBox, pUndo ))
{
nRet = TBLMERGE_OK;
SetModified();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
if( pUndo )
{
GetIDocumentUndoRedo().AppendUndo( pUndo );
@@ -3125,7 +3126,7 @@ bool SwDoc::SplitTable( const SwPosition& rPos, sal_uInt16 eHdlnMode,
OUString sNewTblNm( GetUniqueTblName() );
aMsgHnt.DATA.pNewTblNm = &sNewTblNm;
aMsgHnt.eFlags = TBL_SPLITTBL;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
}
// Find Lines for the Layout update
@@ -3222,7 +3223,7 @@ bool SwDoc::SplitTable( const SwPosition& rPos, sal_uInt16 eHdlnMode,
// TL_CHART2: need to inform chart of probably changed cell names
UpdateCharts( rTbl.GetFrmFmt()->GetName() );
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
return 0 != pNew;
}
@@ -3478,7 +3479,7 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool bWithPrev, sal_uInt16 nMode
aMsgHnt.DATA.pDelTbl = &pDelTblNd->GetTable();
aMsgHnt.eFlags = TBL_MERGETBL;
aMsgHnt.pHistory = pHistory;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
// The actual merge
SwNodeIndex aIdx( bWithPrev ? *pTblNd : *pDelTblNd );
@@ -3493,7 +3494,7 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool bWithPrev, sal_uInt16 nMode
if( bRet )
{
SetModified();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
}
return bRet;
}
@@ -3766,7 +3767,7 @@ bool SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& rNe
}
SetModified();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
return true;
}
@@ -3921,7 +3922,7 @@ bool SwDoc::SetColRowWidthHeight( SwTableBox& rAktBox, sal_uInt16 eType,
SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
bool const bUndo(GetIDocumentUndoRedo().DoesUndo());
bool bRet = false;
@@ -3957,7 +3958,7 @@ bool SwDoc::SetColRowWidthHeight( SwTableBox& rAktBox, sal_uInt16 eType,
{
SetModified();
if( nsTblChgWidthHeightType::WH_FLAG_INSDEL & eType )
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
}
return bRet;
}
@@ -4093,7 +4094,7 @@ void SwDoc::ChkBoxNumFmt( SwTableBox& rBox, bool bCallUpdate )
if( bCallUpdate )
{
SwTableFmlUpdate aTblUpdate( &pTblNd->GetTable() );
- UpdateTblFlds( &aTblUpdate );
+ getIDocumentFieldsAccess().UpdateTblFlds( &aTblUpdate );
// TL_CHART2: update charts (when cursor leaves cell and
// automatic update is enabled)
@@ -4365,7 +4366,7 @@ bool SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
if( bRet )
{
SetModified();
- SetFieldsDirty( true, NULL, 0 );
+ getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
}
return bRet;
}
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 8d31f7f0d3a0..16e04f73af52 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1919,8 +1919,8 @@ const IDocumentLayoutAccess* SwNode::getIDocumentLayoutAccess() const { return G
IDocumentLayoutAccess* SwNode::getIDocumentLayoutAccess() { return GetDoc(); }
const IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() const { return &GetDoc()->getIDocumentLinksAdministration(); }
IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() { return &GetDoc()->getIDocumentLinksAdministration(); }
-const IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() const { return GetDoc(); }
-IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() { return GetDoc(); }
+const IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() const { return &GetDoc()->getIDocumentFieldsAccess(); }
+IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() { return &GetDoc()->getIDocumentFieldsAccess(); }
IDocumentContentOperations* SwNode::getIDocumentContentOperations() { return &GetDoc()->getIDocumentContentOperations(); }
IDocumentListItems& SwNode::getIDocumentListItems() { return GetDoc()->getIDocumentListItems(); } // #i83479#
diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx
index 23f61fb3e24f..b5267ef84833 100644
--- a/sw/source/core/docnode/nodedump.cxx
+++ b/sw/source/core/docnode/nodedump.cxx
@@ -11,6 +11,7 @@
#include "drawdoc.hxx"
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <UndoManager.hxx>
#include "ndtxt.hxx"
#include "MarkManager.hxx"
@@ -184,7 +185,7 @@ void SwDoc::dumpAsXml( xmlTextWriterPtr w )
m_pNodes->dumpAsXml( writer );
mpMarkManager->dumpAsXml( writer );
m_pUndoManager->dumpAsXml(writer);
- mpFldTypes->dumpAsXml( writer );
+ getIDocumentFieldsAccess().GetFldTypes()->dumpAsXml( writer );
mpTxtFmtCollTbl->dumpAsXml( writer );
mpCharFmtTbl->dumpAsXml( writer );
mpFrmFmtTbl->dumpAsXml( writer, "frmFmtTbl" );
@@ -242,7 +243,7 @@ void MarkManager::dumpAsXml( xmlTextWriterPtr w )
} // namespace mark
} // namespace sw
-void SwFldTypes::dumpAsXml( xmlTextWriterPtr w )
+void SwFldTypes::dumpAsXml( xmlTextWriterPtr w ) const
{
WriterHelper writer(w);
writer.startElement("swfldtypes");
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 032ddd5cb8ba..140f2b12c142 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -22,6 +22,7 @@
#include <node.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <pam.hxx>
#include <txtfld.hxx>
#include <fmtfld.hxx>
@@ -118,9 +119,9 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
// declare all fields as invalid, updating will happen
// in the idle-handler of the doc
- if( GetDoc()->SetFieldsDirty( true, &rDelPos.GetNode(), nSz ) &&
+ if( GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty( true, &rDelPos.GetNode(), nSz ) &&
rNds.GetDoc() != GetDoc() )
- rNds.GetDoc()->SetFieldsDirty( true, NULL, 0 );
+ rNds.GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
// NEVER include nodes from the RedLineArea
sal_uLong nNd = rInsPos.GetIndex();
@@ -268,7 +269,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
case RES_TXTATR_INPUTFIELD:
{
SwTxtFld* pTxtFld = static_cast<SwTxtFld*>(pAttr);
- rNds.GetDoc()->InsDelFldInFldLst( !bToUndo, *pTxtFld );
+ rNds.GetDoc()->getIDocumentFieldsAccess().InsDelFldInFldLst( !bToUndo, *pTxtFld );
const SwFieldType* pTyp = pTxtFld->GetFmtFld().GetField()->GetTyp();
if ( RES_POSTITFLD == pTyp->Which() )
@@ -345,9 +346,9 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
// declare all fields as invalid, updating will happen
// in the idle-handler of the doc
- GetDoc()->SetFieldsDirty( true, NULL, 0 );
+ GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
if( rNds.GetDoc() != GetDoc() )
- rNds.GetDoc()->SetFieldsDirty( true, NULL, 0 );
+ rNds.GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
if( bNewFrms )
bNewFrms = &GetDoc()->GetNodes() == (const SwNodes*)&rNds &&
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 0e570565dec2..feefc0ec7473 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -36,6 +36,7 @@
#include <DocumentLinksAdministrationManager.hxx>
#include <DocumentContentOperationsManager.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <node.hxx>
#include <pam.hxx>
#include <frmtool.hxx>
@@ -1194,7 +1195,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
SwPaM* pPam;
SwViewShell* pVSh = 0;
SwEditShell* pESh = pDoc->GetEditShell( &pVSh );
- pDoc->LockExpFlds();
+ pDoc->getIDocumentFieldsAccess().LockExpFlds();
{
// Insert an empty TextNode at the Section's start
SwNodeIndex aIdx( *pSectNd, +1 );
@@ -1419,9 +1420,9 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
pDoc->GetIDocumentUndoRedo().DoUndo(bWasUndo);
pDoc->getIDocumentLinksAdministration().SetVisibleLinks( bWasVisibleLinks );
- pDoc->UnlockExpFlds();
- if( !pDoc->IsExpFldsLocked() )
- pDoc->UpdateExpFlds(NULL, true);
+ pDoc->getIDocumentFieldsAccess().UnlockExpFlds();
+ if( !pDoc->getIDocumentFieldsAccess().IsExpFldsLocked() )
+ pDoc->getIDocumentFieldsAccess().UpdateExpFlds(NULL, true);
if( pESh )
pESh->EndAllAction();
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index cf95961d7266..d25a72f2da33 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -23,6 +23,7 @@
#include <editsh.hxx>
#include <fldbas.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <fmtfld.hxx>
#include <txtfld.hxx>
@@ -42,7 +43,7 @@
/// count field types with a ResId, if 0 count all
sal_uInt16 SwEditShell::GetFldTypeCount(sal_uInt16 nResId, bool bUsed ) const
{
- const SwFldTypes* pFldTypes = GetDoc()->GetFldTypes();
+ const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const sal_uInt16 nSize = pFldTypes->size();
if(nResId == USHRT_MAX)
@@ -75,7 +76,7 @@ sal_uInt16 SwEditShell::GetFldTypeCount(sal_uInt16 nResId, bool bUsed ) const
/// get field types with a ResId, if 0 get all
SwFieldType* SwEditShell::GetFldType(sal_uInt16 nFld, sal_uInt16 nResId, bool bUsed ) const
{
- const SwFldTypes* pFldTypes = GetDoc()->GetFldTypes();
+ const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const sal_uInt16 nSize = pFldTypes->size();
if(nResId == USHRT_MAX && nFld < nSize)
@@ -118,7 +119,7 @@ SwFieldType* SwEditShell::GetFldType(sal_uInt16 nFld, sal_uInt16 nResId, bool bU
/// get first type with given ResId and name
SwFieldType* SwEditShell::GetFldType(sal_uInt16 nResId, const OUString& rName) const
{
- return GetDoc()->GetFldType( nResId, rName, false );
+ return GetDoc()->getIDocumentFieldsAccess().GetFldType( nResId, rName, false );
}
/// delete field type
@@ -126,11 +127,11 @@ void SwEditShell::RemoveFldType(sal_uInt16 nFld, sal_uInt16 nResId)
{
if( USHRT_MAX == nResId )
{
- GetDoc()->RemoveFldType(nFld);
+ GetDoc()->getIDocumentFieldsAccess().RemoveFldType(nFld);
return;
}
- const SwFldTypes* pFldTypes = GetDoc()->GetFldTypes();
+ const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const sal_uInt16 nSize = pFldTypes->size();
sal_uInt16 nIdx = 0;
for( sal_uInt16 i = 0; i < nSize; ++i )
@@ -138,7 +139,7 @@ void SwEditShell::RemoveFldType(sal_uInt16 nFld, sal_uInt16 nResId)
if( (*pFldTypes)[i]->Which() == nResId &&
nIdx++ == nFld )
{
- GetDoc()->RemoveFldType( i );
+ GetDoc()->getIDocumentFieldsAccess().RemoveFldType( i );
return;
}
}
@@ -146,7 +147,7 @@ void SwEditShell::RemoveFldType(sal_uInt16 nFld, sal_uInt16 nResId)
/// delete field type based on its name
void SwEditShell::RemoveFldType(sal_uInt16 nResId, const OUString& rStr)
{
- const SwFldTypes* pFldTypes = GetDoc()->GetFldTypes();
+ const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const sal_uInt16 nSize = pFldTypes->size();
const CharClass& rCC = GetAppCharClass();
@@ -160,7 +161,7 @@ void SwEditShell::RemoveFldType(sal_uInt16 nResId, const OUString& rStr)
{
if( aTmp == rCC.lowercase( pFldType->GetName() ) )
{
- GetDoc()->RemoveFldType(i);
+ GetDoc()->getIDocumentFieldsAccess().RemoveFldType(i);
return;
}
}
@@ -270,7 +271,7 @@ void SwEditShell::UpdateFlds( SwField &rFld )
pTxtFld = lcl_FindInputFld( GetDoc(), rFld);
if (pTxtFld != 0)
- GetDoc()->UpdateFld(pTxtFld, rFld, pMsgHnt, true);
+ GetDoc()->getIDocumentFieldsAccess().UpdateFld(pTxtFld, rFld, pMsgHnt, true);
}
// bOkay (instead of return because of EndAllAction) becomes false,
@@ -318,7 +319,7 @@ void SwEditShell::UpdateFlds( SwField &rFld )
rFld.GetTyp()->Which() )
bOkay = false;
- bTblSelBreak = GetDoc()->UpdateFld(pTxtFld, rFld,
+ bTblSelBreak = GetDoc()->getIDocumentFieldsAccess().UpdateFld(pTxtFld, rFld,
pMsgHnt, false);
}
// The search area is reduced by the found area:
@@ -367,7 +368,7 @@ void SwEditShell::UpdateExpFlds(bool bCloseDB)
{
SET_CURR_SHELL( this );
StartAllAction();
- GetDoc()->UpdateExpFlds(NULL, true);
+ GetDoc()->getIDocumentFieldsAccess().UpdateExpFlds(NULL, true);
if (bCloseDB)
{
#if HAVE_FEATURE_DBCONNECTIVITY
@@ -389,17 +390,17 @@ SwDBManager* SwEditShell::GetDBManager() const
/// insert field type
SwFieldType* SwEditShell::InsertFldType(const SwFieldType& rFldType)
{
- return GetDoc()->InsertFldType(rFldType);
+ return GetDoc()->getIDocumentFieldsAccess().InsertFldType(rFldType);
}
void SwEditShell::LockExpFlds()
{
- GetDoc()->LockExpFlds();
+ GetDoc()->getIDocumentFieldsAccess().LockExpFlds();
}
void SwEditShell::UnlockExpFlds()
{
- GetDoc()->UnlockExpFlds();
+ GetDoc()->getIDocumentFieldsAccess().UnlockExpFlds();
}
void SwEditShell::SetFldUpdateFlags( SwFldUpdateFlags eFlags )
@@ -429,7 +430,7 @@ void SwEditShell::ChangeAuthorityData(const SwAuthEntry* pNewData)
bool SwEditShell::IsAnyDatabaseFieldInDoc()const
{
- const SwFldTypes * pFldTypes = GetDoc()->GetFldTypes();
+ const SwFldTypes * pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const sal_uInt16 nSize = pFldTypes->size();
for(sal_uInt16 i = 0; i < nSize; ++i)
{
diff --git a/sw/source/core/edit/edfldexp.cxx b/sw/source/core/edit/edfldexp.cxx
index e24e66b67db4..86e3a1b7e14d 100644
--- a/sw/source/core/edit/edfldexp.cxx
+++ b/sw/source/core/edit/edfldexp.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/sdb/DatabaseContext.hpp>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <txtfld.hxx>
#include <fmtfld.hxx>
@@ -36,7 +37,7 @@ using namespace com::sun::star;
bool SwEditShell::IsFieldDataSourceAvailable(OUString& rUsedDataSource) const
{
- const SwFldTypes * pFldTypes = GetDoc()->GetFldTypes();
+ const SwFldTypes * pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const sal_uInt16 nSize = pFldTypes->size();
uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
uno::Reference<sdb::XDatabaseContext> xDBContext = sdb::DatabaseContext::create(xContext);
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index e3ab17944f7d..755a4892562c 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -23,6 +23,7 @@
#include <svl/urihelper.hxx>
#include <doc.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <pam.hxx>
#include <docary.hxx>
#include <editsh.hxx>
@@ -176,7 +177,7 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
bool bRet = false;
SET_CURR_SHELL( this );
- pInsDoc->LockExpFlds();
+ pInsDoc->getIDocumentFieldsAccess().LockExpFlds();
if( IsTableMode() )
{
@@ -249,9 +250,9 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
}
}
- pInsDoc->UnlockExpFlds();
- if( !pInsDoc->IsExpFldsLocked() )
- pInsDoc->UpdateExpFlds(NULL, true);
+ pInsDoc->getIDocumentFieldsAccess().UnlockExpFlds();
+ if( !pInsDoc->getIDocumentFieldsAccess().IsExpFldsLocked() )
+ pInsDoc->getIDocumentFieldsAccess().UpdateExpFlds(NULL, true);
// set the saved Node position back to the correct Node
if( bRet && pSttNd )
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 4db32ab381e5..be5174f694dc 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -33,6 +33,7 @@
#include <IDocumentUndoRedo.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentLinksAdministration.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <editsh.hxx>
#include <frame.hxx>
@@ -565,7 +566,7 @@ OUString SwEditShell::Calculate()
{
if( !bValidFlds )
{
- GetDoc()->FldsToCalc( aCalc,
+ GetDoc()->getIDocumentFieldsAccess().FldsToCalc( aCalc,
pStart->nNode.GetIndex(),
pStart->nContent.GetIndex() );
bValidFlds = true;
diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx
index 145d565565d3..7e95ed4f5076 100644
--- a/sw/source/core/edit/edtab.cxx
+++ b/sw/source/core/edit/edtab.cxx
@@ -32,6 +32,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentChartDataProviderAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <cntfrm.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -253,7 +254,7 @@ void SwEditShell::UpdateTable()
StartUndo();
EndAllTblBoxEdit();
SwTableFmlUpdate aTblUpdate( (SwTable*)&pTblNd->GetTable() );
- GetDoc()->UpdateTblFlds( &aTblUpdate );
+ GetDoc()->getIDocumentFieldsAccess().UpdateTblFlds( &aTblUpdate );
if( DoesUndo() )
EndUndo();
EndAllAction();
@@ -319,7 +320,7 @@ bool SwEditShell::GetTblBoxFormulaAttrs( SfxItemSet& rSet ) const
SwTableFmlUpdate aTblUpdate( (SwTable*)&rTbl );
aTblUpdate.eFlags = TBL_BOXNAME;
- ((SwDoc*)GetDoc())->UpdateTblFlds( &aTblUpdate );
+ ((SwDoc*)GetDoc())->getIDocumentFieldsAccess().UpdateTblFlds( &aTblUpdate );
rSet.Put( pTblFmt->GetAttrSet() );
}
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx
index 2eff387c12a6..3a4bb733ce64 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -35,6 +35,7 @@
#include <txtfld.hxx>
#include <ndtxt.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <unofldmid.h>
#include <unoprnms.hxx>
#include <switerator.hxx>
@@ -552,7 +553,7 @@ OUString SwAuthorityField::ConditionalExpand(ToxAuthorityField eField) const
if( pAuthType->IsSequence() )
{
- if(!pAuthType->GetDoc()->IsExpFldsLocked())
+ if(!pAuthType->GetDoc()->getIDocumentFieldsAccess().IsExpFldsLocked())
m_nTempSequencePos = pAuthType->GetSequencePos( m_nHandle );
if( m_nTempSequencePos >= 0 )
sRet += OUString::number( m_nTempSequencePos );
@@ -576,7 +577,7 @@ OUString SwAuthorityField::ExpandCitation(ToxAuthorityField eField) const
if( pAuthType->IsSequence() )
{
- if(!pAuthType->GetDoc()->IsExpFldsLocked())
+ if(!pAuthType->GetDoc()->getIDocumentFieldsAccess().IsExpFldsLocked())
m_nTempSequencePos = pAuthType->GetSequencePos( m_nHandle );
if( m_nTempSequencePos >= 0 )
sRet += OUString::number( m_nTempSequencePos );
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index 0a1d8a6e1be8..9318e0927604 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -26,6 +26,7 @@
#include <fmtfld.hxx>
#include <txtfld.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <frame.hxx>
#include <fldbas.hxx>
@@ -88,11 +89,11 @@ void SwDBFieldType::ReleaseRef()
if (--nRefCnt <= 0)
{
- sal_uInt16 nPos = GetDoc()->GetFldTypes()->GetPos(this);
+ sal_uInt16 nPos = GetDoc()->getIDocumentFieldsAccess().GetFldTypes()->GetPos(this);
if (nPos != USHRT_MAX)
{
- GetDoc()->RemoveFldType(nPos);
+ GetDoc()->getIDocumentFieldsAccess().RemoveFldType(nPos);
delete this;
}
}
diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx
index e52463e5d3b0..43e5485a0010 100644
--- a/sw/source/core/fields/ddetbl.cxx
+++ b/sw/source/core/fields/ddetbl.cxx
@@ -21,6 +21,7 @@
#include <frmfmt.hxx>
#include <doc.hxx>
#include <IDocumentSettingAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <index.hxx>
#include <ndtxt.hxx>
#include <swtable.hxx>
@@ -133,7 +134,7 @@ void SwDDETable::ChangeContent()
const IDocumentSettingAccess* pIDSA = GetFrmFmt()->getIDocumentSettingAccess();
SwDoc* pDoc = GetFrmFmt()->GetDoc();
if( AUTOUPD_FIELD_AND_CHARTS == pIDSA->getFieldUpdateFlags(true) )
- pDoc->SetFieldsDirty( true, NULL, 0 );
+ pDoc->getIDocumentFieldsAccess().SetFieldsDirty( true, NULL, 0 );
}
SwDDEFieldType* SwDDETable::GetDDEFldType()
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index db0fd8e7dca7..8551b87326c8 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -72,6 +72,7 @@
#include <pagedesc.hxx>
#include <fmtpdsc.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <rootfrm.hxx>
#include <pagefrm.hxx>
#include <cntfrm.hxx>
@@ -2113,7 +2114,7 @@ void SwRefPageGetFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem*
sal_uInt16 SwRefPageGetFieldType::MakeSetList( _SetGetExpFlds& rTmpLst )
{
- SwIterator<SwFmtFld,SwFieldType> aIter(*pDoc->GetSysFldType( RES_REFPAGESETFLD));
+ SwIterator<SwFmtFld,SwFieldType> aIter(*pDoc->getIDocumentFieldsAccess().GetSysFldType( RES_REFPAGESETFLD));
for ( SwFmtFld* pFmtFld = aIter.First(); pFmtFld; pFmtFld = aIter.Next() )
{
// update only the GetRef fields
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 0d2afb79ddcb..8433e6738531 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -35,6 +35,7 @@
#include <fmtanchr.hxx>
#include <txtftn.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <layfrm.hxx>
#include <pagefrm.hxx>
#include <cntfrm.hxx>
@@ -340,7 +341,7 @@ void SwGetExpField::ChangeExpansion( const SwFrm& rFrm, const SwTxtFld& rFld )
// #i82544#
if( bLateInitialization )
{
- SwFieldType* pSetExpFld = rDoc.GetFldType(RES_SETEXPFLD, GetFormula(), false);
+ SwFieldType* pSetExpFld = rDoc.getIDocumentFieldsAccess().GetFldType(RES_SETEXPFLD, GetFormula(), false);
if( pSetExpFld )
{
bLateInitialization = false;
@@ -355,7 +356,7 @@ void SwGetExpField::ChangeExpansion( const SwFrm& rFrm, const SwTxtFld& rFld )
{
SwHash** ppHashTbl;
sal_uInt16 nSize;
- rDoc.FldsToExpand( ppHashTbl, nSize, aEndFld );
+ rDoc.getIDocumentFieldsAccess().FldsToExpand( ppHashTbl, nSize, aEndFld );
sExpand = LookString( ppHashTbl, nSize, GetFormula() );
::DeleteHashTable( ppHashTbl, nSize );
}
@@ -363,7 +364,7 @@ void SwGetExpField::ChangeExpansion( const SwFrm& rFrm, const SwTxtFld& rFld )
{
// fill calculator with values
SwCalc aCalc( rDoc );
- rDoc.FldsToCalc(aCalc, aEndFld);
+ rDoc.getIDocumentFieldsAccess().FldsToCalc(aCalc, aEndFld);
// calculate value
SetValue(aCalc.Calculate(GetFormula()).GetDouble());
@@ -1171,7 +1172,7 @@ void SwInputField::applyFieldContent( const OUString& rNewFieldContent )
else if( (nSubType & 0x00ff) == INP_USR )
{
SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>(
- static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->GetFldType( RES_USERFLD, getContent(), false ) );
+ static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->getIDocumentFieldsAccess().GetFldType( RES_USERFLD, getContent(), false ) );
if( pUserTyp )
{
pUserTyp->SetContent( rNewFieldContent );
@@ -1224,7 +1225,7 @@ OUString SwInputField::Expand() const
if( (nSubType & 0x00ff) == INP_USR )
{
SwUserFieldType* pUserTyp = static_cast<SwUserFieldType*>(
- static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->GetFldType( RES_USERFLD, getContent(), false ) );
+ static_cast<SwInputFieldType*>(GetTyp())->GetDoc()->getIDocumentFieldsAccess().GetFldType( RES_USERFLD, getContent(), false ) );
if( pUserTyp )
return pUserTyp->GetContent();
}
diff --git a/sw/source/core/fields/fldlst.cxx b/sw/source/core/fields/fldlst.cxx
index eae9d35eca70..e0fd57633305 100644
--- a/sw/source/core/fields/fldlst.cxx
+++ b/sw/source/core/fields/fldlst.cxx
@@ -20,6 +20,7 @@
#include "switerator.hxx"
#include "editsh.hxx"
#include "doc.hxx"
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <fmtfld.hxx>
#include <txtfld.hxx>
@@ -37,7 +38,7 @@ SwInputFieldList::SwInputFieldList( SwEditShell* pShell, bool bBuildTmpLst )
// create sorted list of all input fields
pSrtLst = new _SetGetExpFlds();
- const SwFldTypes& rFldTypes = *pSh->GetDoc()->GetFldTypes();
+ const SwFldTypes& rFldTypes = *pSh->GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const size_t nSize = rFldTypes.size();
// iterate over all types
@@ -125,7 +126,7 @@ void SwInputFieldList::GotoFieldPos(size_t nId)
*/
bool SwInputFieldList::BuildSortLst()
{
- const SwFldTypes& rFldTypes = *pSh->GetDoc()->GetFldTypes();
+ const SwFldTypes& rFldTypes = *pSh->GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const size_t nSize = rFldTypes.size();
// iterate over all types
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index c62db3d913c0..4741564e6609 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -25,6 +25,7 @@
#include <comphelper/string.hxx>
#include <editeng/unolingu.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <pam.hxx>
#include <cntfrm.hxx>
#include <pagefrm.hxx>
@@ -748,7 +749,7 @@ void SwGetRefField::ConvertProgrammaticToUIName()
SwDoc* pDoc = ((SwGetRefFieldType*)GetTyp())->GetDoc();
const OUString rPar1 = GetPar1();
// don't convert when the name points to an existing field type
- if(!pDoc->GetFldType(RES_SETEXPFLD, rPar1, false))
+ if(!pDoc->getIDocumentFieldsAccess().GetFldType(RES_SETEXPFLD, rPar1, false))
{
sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromProgName( rPar1, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
sal_uInt16 nResId = USHRT_MAX;
@@ -834,7 +835,7 @@ SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const OUString& rRefMark,
case REF_SEQUENCEFLD:
{
- SwFieldType* pFldType = pDoc->GetFldType( RES_SETEXPFLD, rRefMark, false );
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetFldType( RES_SETEXPFLD, rRefMark, false );
if( pFldType && pFldType->GetDepends() &&
nsSwGetSetExpType::GSE_SEQ & ((SwSetExpFieldType*)pFldType)->GetType() )
{
@@ -948,7 +949,7 @@ typedef boost::ptr_vector<_RefIdsMap> _RefIdsMaps;
/// @param[in,out] rIds The list of IDs found in the document.
void _RefIdsMap::GetFieldIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds)
{
- SwFieldType *const pType = rDoc.GetFldType(RES_SETEXPFLD, aName, false);
+ SwFieldType *const pType = rDoc.getIDocumentFieldsAccess().GetFldType(RES_SETEXPFLD, aName, false);
if (!pType)
return;
@@ -996,7 +997,7 @@ void _RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, bool bField )
AddId( GetFirstUnusedId(aIds), *pIt );
// Change the Sequence number of all SetExp fields in the source document
- SwFieldType* pType = rDoc.GetFldType( RES_SETEXPFLD, aName, false );
+ SwFieldType* pType = rDoc.getIDocumentFieldsAccess().GetFldType( RES_SETEXPFLD, aName, false );
if( pType )
{
SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
@@ -1090,7 +1091,7 @@ void SwGetRefFieldType::MergeWithOtherDoc( SwDoc& rDestDoc )
{
// when copying _to_ clipboard, expectation is that no fields exist
// so no re-mapping is required to avoid collisions
- assert(!rDestDoc.GetSysFldType(RES_GETREFFLD)->GetDepends());
+ assert(!rDestDoc.getIDocumentFieldsAccess().GetSysFldType(RES_GETREFFLD)->GetDepends());
return; // don't modify the fields in the source doc
}
diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx
index b58306a5c0d9..760167644647 100644
--- a/sw/source/core/fields/usrfld.cxx
+++ b/sw/source/core/fields/usrfld.cxx
@@ -26,6 +26,7 @@
#include <calc.hxx>
#include <usrfld.hxx>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <IDocumentUndoRedo.hxx>
#include <editsh.hxx>
#include <dpage.hxx>
@@ -207,7 +208,7 @@ void SwUserFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
if ( !IsModifyLocked() )
{
LockModify();
- GetDoc()->GetSysFldType( RES_INPUTFLD )->UpdateFlds();
+ GetDoc()->getIDocumentFieldsAccess().GetSysFldType( RES_INPUTFLD )->UpdateFlds();
UnlockModify();
}
}
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index d66182b25eb5..aeea08370c87 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -56,6 +56,7 @@
#include <IDocumentUndoRedo.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <DocumentFieldsManager.hxx>
#include <rootfrm.hxx>
#include <ndtxt.hxx>
#include <pam.hxx>
@@ -104,7 +105,7 @@ bool SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpTxt )
SwFlyFrmFmt* pFly = (SwFlyFrmFmt*)(*pClpDoc->GetSpzFrmFmts())[n];
pClpDoc->DelLayoutFmt( pFly );
}
- pClpDoc->GCFieldTypes(); // delete the FieldTypes
+ pClpDoc->GetDocumentFieldsManager().GCFieldTypes(); // delete the FieldTypes
// if a string was passed, copy it to the clipboard-
// document. Then also the Calculator can use the internal
@@ -115,7 +116,7 @@ bool SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpTxt )
return true; // das wars.
}
- pClpDoc->LockExpFlds();
+ pClpDoc->getIDocumentFieldsAccess().LockExpFlds();
pClpDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( nsRedlineMode_t::REDLINE_DELETE_REDLINES );
bool bRet;
@@ -216,9 +217,9 @@ bool SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpTxt )
bRet = _CopySelToDoc( pClpDoc, 0 ); // copy the selections
pClpDoc->getIDocumentRedlineAccess().SetRedlineMode_intern((RedlineMode_t)0 );
- pClpDoc->UnlockExpFlds();
- if( !pClpDoc->IsExpFldsLocked() )
- pClpDoc->UpdateExpFlds(NULL, true);
+ pClpDoc->getIDocumentFieldsAccess().UnlockExpFlds();
+ if( !pClpDoc->getIDocumentFieldsAccess().IsExpFldsLocked() )
+ pClpDoc->getIDocumentFieldsAccess().UpdateExpFlds(NULL, true);
return bRet;
}
@@ -449,7 +450,7 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
SET_CURR_SHELL( pDestShell );
pDestShell->StartAllAction();
- pDestShell->GetDoc()->LockExpFlds();
+ pDestShell->GetDoc()->getIDocumentFieldsAccess().LockExpFlds();
// Shift references
bool bCopyIsMove = mpDoc->IsCopyIsMove();
@@ -463,7 +464,7 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
// If there are table formulas in the area, then display the table first
// so that the table formula can calculate a new value first
// (individual boxes in the area are retrieved via the layout)
- SwFieldType* pTblFldTyp = pDestShell->GetDoc()->GetSysFldType( RES_TABLEFLD );
+ SwFieldType* pTblFldTyp = pDestShell->GetDoc()->getIDocumentFieldsAccess().GetSysFldType( RES_TABLEFLD );
if( IsFrmSelected() )
{
@@ -654,8 +655,8 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
for( ; nActCnt; --nActCnt )
pDestShell->StartAllAction();
}
- pDestShell->GetDoc()->UnlockExpFlds();
- pDestShell->GetDoc()->UpdateFlds(NULL, false);
+ pDestShell->GetDoc()->getIDocumentFieldsAccess().UnlockExpFlds();
+ pDestShell->GetDoc()->getIDocumentFieldsAccess().UpdateFlds(NULL, false);
pDestShell->EndAllAction();
return bRet;
@@ -681,7 +682,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
// If there are table formulas in the area, then display the table first
// so that the table formula can calculate a new value first
// (individual boxes in the area are retrieved via the layout)
- SwFieldType* pTblFldTyp = GetDoc()->GetSysFldType( RES_TABLEFLD );
+ SwFieldType* pTblFldTyp = GetDoc()->getIDocumentFieldsAccess().GetSysFldType( RES_TABLEFLD );
SwTableNode *pDestNd, *pSrcNd = aCpyPam.GetNode().GetTableNode();
if( !pSrcNd ) // TabellenNode ?
@@ -699,7 +700,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
bool bRet = true, bDelTbl = true;
StartAllAction();
GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL );
- GetDoc()->LockExpFlds();
+ GetDoc()->getIDocumentFieldsAccess().LockExpFlds();
// When the clipboard content has been created by a rectangular selection
// the pasting is more sophisticated:
@@ -1106,8 +1107,8 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
for( ; nActCnt; --nActCnt )
StartAllAction();
}
- GetDoc()->UnlockExpFlds();
- GetDoc()->UpdateFlds(NULL, false);
+ GetDoc()->getIDocumentFieldsAccess().UnlockExpFlds();
+ GetDoc()->getIDocumentFieldsAccess().UpdateFlds(NULL, false);
EndAllAction();
return bRet;
@@ -1156,7 +1157,7 @@ bool SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1
SET_CURR_SHELL( this );
StartAllAction();
- GetDoc()->LockExpFlds();
+ GetDoc()->getIDocumentFieldsAccess().LockExpFlds();
SetSelection(aCpyPam);
// copy the text of the selection
SwEditShell::Copy(&rToFill);
@@ -1192,8 +1193,8 @@ bool SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1
rToFill.GetDoc()->CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
}
}
- GetDoc()->UnlockExpFlds();
- GetDoc()->UpdateFlds(NULL, false);
+ GetDoc()->getIDocumentFieldsAccess().UnlockExpFlds();
+ GetDoc()->getIDocumentFieldsAccess().UpdateFlds(NULL, false);
Pop(false);
EndAllAction();
diff --git a/sw/source/core/inc/DocumentFieldsManager.hxx b/sw/source/core/inc/DocumentFieldsManager.hxx
new file mode 100644
index 000000000000..acc1bde75cd9
--- /dev/null
+++ b/sw/source/core/inc/DocumentFieldsManager.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTFIELDSMANAGER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTFIELDSMANAGER_HXX
+
+#include <IDocumentFieldsAccess.hxx>
+#include <boost/utility.hpp>
+#include <sal/types.h>
+
+class SwDoc;
+class SwDBNameInfField;
+
+namespace sw {
+
+class DocumentFieldsManager : public IDocumentFieldsAccess,
+ public ::boost::noncopyable
+{
+
+public:
+
+ DocumentFieldsManager( SwDoc& i_rSwdoc );
+
+ virtual const SwFldTypes *GetFldTypes() const SAL_OVERRIDE;
+ virtual SwFieldType *InsertFldType(const SwFieldType &) SAL_OVERRIDE;
+ virtual SwFieldType *GetSysFldType( const sal_uInt16 eWhich ) const SAL_OVERRIDE;
+ virtual SwFieldType* GetFldType(sal_uInt16 nResId, const OUString& rName, bool bDbFieldMatching) const SAL_OVERRIDE;
+ virtual void RemoveFldType(sal_uInt16 nFld) SAL_OVERRIDE;
+ virtual void UpdateFlds( SfxPoolItem* pNewHt, bool bCloseDB) SAL_OVERRIDE;
+ virtual void InsDeletedFldType(SwFieldType &) SAL_OVERRIDE;
+ virtual bool PutValueToField(const SwPosition & rPos, const com::sun::star::uno::Any& rVal, sal_uInt16 nWhich) SAL_OVERRIDE;
+ virtual bool UpdateFld(SwTxtFld * rDstFmtFld, SwField & rSrcFld, SwMsgPoolItem * pMsgHnt, bool bUpdateTblFlds) SAL_OVERRIDE;
+ virtual void UpdateRefFlds(SfxPoolItem* pHt) SAL_OVERRIDE;
+ virtual void UpdateTblFlds(SfxPoolItem* pHt) SAL_OVERRIDE;
+ virtual void UpdateExpFlds(SwTxtFld* pFld, bool bUpdateRefFlds) SAL_OVERRIDE;
+ virtual void UpdateUsrFlds() SAL_OVERRIDE;
+ virtual void UpdatePageFlds(SfxPoolItem*) SAL_OVERRIDE;
+ virtual void LockExpFlds() SAL_OVERRIDE;
+ virtual void UnlockExpFlds() SAL_OVERRIDE;
+ virtual bool IsExpFldsLocked() const SAL_OVERRIDE;
+ virtual SwDocUpdtFld& GetUpdtFlds() const SAL_OVERRIDE;
+ virtual bool SetFieldsDirty(bool b, const SwNode* pChk, sal_uLong nLen) SAL_OVERRIDE;
+ virtual void SetFixFields(bool bOnlyTimeDate, const DateTime* pNewDateTime) SAL_OVERRIDE;
+ virtual void FldsToCalc(SwCalc& rCalc, sal_uLong nLastNd, sal_uInt16 nLastCnt) SAL_OVERRIDE;
+ virtual void FldsToCalc(SwCalc& rCalc, const _SetGetExpFld& rToThisFld) SAL_OVERRIDE;
+ virtual void FldsToExpand(SwHash**& ppTbl, sal_uInt16& rTblSize, const _SetGetExpFld& rToThisFld) SAL_OVERRIDE;
+ virtual bool IsNewFldLst() const SAL_OVERRIDE;
+ virtual void SetNewFldLst( bool bFlag) SAL_OVERRIDE;
+ virtual void InsDelFldInFldLst(bool bIns, const SwTxtFld& rFld) SAL_OVERRIDE;
+
+ //Non Interface methods
+
+ /** Returns the field at a certain position.
+ @param rPos position to search at
+ @return pointer to field at the given position or NULL in case no field is found
+ */
+ static SwField* GetFieldAtPos(const SwPosition& rPos);
+
+ /** Returns the field at a certain position.
+ @param rPos position to search at
+ @return pointer to field at the given position or NULL in case no field is found
+ */
+ static SwTxtFld* GetTxtFldAtPos(const SwPosition& rPos);
+
+ bool containsUpdatableFields();
+
+ // Delete all unreferenced field types.
+ void GCFieldTypes();
+
+ void _InitFieldTypes();
+
+ void ClearFieldTypes();
+
+ void UpdateDBNumFlds( SwDBNameInfField& rDBFld, SwCalc& rCalc );
+
+ virtual ~DocumentFieldsManager();
+
+private:
+
+ SwDoc& m_rSwdoc;
+
+ bool mbNewFldLst; //< TRUE: Rebuild field-list.
+ SwDocUpdtFld *mpUpdtFlds; //< Struct for updating fields
+ SwFldTypes *mpFldTypes;
+ sal_Int8 mnLockExpFld; //< If != 0 UpdateExpFlds() has no effect!
+};
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 687409235738..6653210cf382 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -23,6 +23,7 @@
#include "viewimp.hxx"
#include "viewopt.hxx"
#include "frmtool.hxx"
+#include <IDocumentFieldsAccess.hxx>
#include "dcontact.hxx"
#include <editeng/formatbreakitem.hxx>
#include <editeng/keepitem.hxx>
@@ -1935,7 +1936,7 @@ bool SwFlowFrm::MoveFwd( bool bMakePage, bool bPageBreak, bool bMoveAlways )
{
SwViewShell *pSh = m_rThis.getRootFrm()->GetCurrShell();
if ( pSh && !pSh->Imp()->IsUpdateExpFlds() )
- pSh->GetDoc()->SetNewFldLst(true); // Will be done by CalcLayout() later on!
+ pSh->GetDoc()->getIDocumentFieldsAccess().SetNewFldLst(true); // Will be done by CalcLayout() later on!
pNewPage->InvalidateSpelling();
pNewPage->InvalidateSmartTags();
@@ -2467,7 +2468,7 @@ bool SwFlowFrm::MoveBwd( bool &rbReformat )
m_rThis.Prepare( PREP_BOSS_CHGD, (const void*)pOldPage, false );
SwViewShell *pSh = m_rThis.getRootFrm()->GetCurrShell();
if ( pSh && !pSh->Imp()->IsUpdateExpFlds() )
- pSh->GetDoc()->SetNewFldLst(true); // Will be done by CalcLayout() later on
+ pSh->GetDoc()->getIDocumentFieldsAccess().SetNewFldLst(true); // Will be done by CalcLayout() later on
pNewPage->InvalidateSpelling();
pNewPage->InvalidateSmartTags();
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 965bda821a63..49bde440469b 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -64,6 +64,7 @@
#include <DocumentSettingManager.hxx>
#include <IDocumentTimerAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
//UUUU
#include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
@@ -1310,7 +1311,7 @@ void _InsertCnt( SwLayoutFrm *pLay, SwDoc *pDoc,
// all table formulas to internal (BOXPTR) representation.
SwTableFmlUpdate aMsgHnt( &pTblNode->GetTable() );
aMsgHnt.eFlags = TBL_BOXPTR;
- pDoc->UpdateTblFlds( &aMsgHnt );
+ pDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
pTblNode->GetTable().GCLines();
pFrm = pTblNode->MakeFrm( pLay );
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 23ab1796eae6..a052114ff6cf 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -36,6 +36,7 @@
#include <viewopt.hxx>
#include <set>
#include <IDocumentSettingAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
SwLayVout *SwRootFrm::pVout = 0;
bool SwRootFrm::bInPaint = false;
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 45c3f51635ea..61488fe6af71 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -46,6 +46,7 @@
#include "doc.hxx"
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDrawModelAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include "fesh.hxx"
#include "dview.hxx"
#include "dflyobj.hxx"
@@ -1128,7 +1129,7 @@ void SwFrm::CheckPageDescs( SwPageFrm *pStart, bool bNotifyFields, SwPageFrm** p
if ( bNotifyFields && (!pImp || !pImp->IsUpdateExpFlds()) )
{
SwDocPosUpdate aMsgHnt( nDocPos );
- pDoc->UpdatePageFlds( &aMsgHnt );
+ pDoc->getIDocumentFieldsAccess().UpdatePageFlds( &aMsgHnt );
}
#if OSL_DEBUG_LEVEL > 0
@@ -1257,7 +1258,7 @@ SwPageFrm *SwFrm::InsertPage( SwPageFrm *pPrevPage, bool bFtn )
if ( !pSh || !pSh->Imp()->IsUpdateExpFlds() )
{
SwDocPosUpdate aMsgHnt( pPrevPage->Frm().Top() );
- pDoc->UpdatePageFlds( &aMsgHnt );
+ pDoc->getIDocumentFieldsAccess().UpdatePageFlds( &aMsgHnt );
}
return pPage;
}
@@ -1384,7 +1385,7 @@ void SwRootFrm::RemoveSuperfluous()
(!pSh || !pSh->Imp()->IsUpdateExpFlds()) )
{
SwDocPosUpdate aMsgHnt( nDocPos );
- GetFmt()->GetDoc()->UpdatePageFlds( &aMsgHnt );
+ GetFmt()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFlds( &aMsgHnt );
}
}
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index b6104eed510a..52370a428fac 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -22,6 +22,7 @@
#include "cntfrm.hxx"
#include "viewsh.hxx"
#include "doc.hxx"
+#include <IDocumentFieldsAccess.hxx>
#include "docsh.hxx"
#include "viewimp.hxx"
#include "swtable.hxx"
@@ -3092,7 +3093,7 @@ void SwTabFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
if (GetFmt()->GetPageDesc().GetNumOffset())
((SwRootFrm*)pPage->GetUpper())->SetVirtPageNum( true );
SwDocPosUpdate aMsgHnt( pPage->Frm().Top() );
- GetFmt()->GetDoc()->UpdatePageFlds( &aMsgHnt );
+ GetFmt()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFlds( &aMsgHnt );
}
}
break;
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index f30fa20d023e..8b2a905650d5 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -37,6 +37,7 @@
#include "viewopt.hxx"
#include <doc.hxx>
#include <IDocumentSettingAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <fesh.hxx>
#include <docsh.hxx>
#include <flyfrm.hxx>
@@ -2027,7 +2028,7 @@ void SwCntntFrm::_UpdateAttr( const SfxPoolItem* pOld, const SfxPoolItem* pNew,
if ( GetAttrSet()->GetPageDesc().GetNumOffset() )
((SwRootFrm*)pPage->GetUpper())->SetVirtPageNum( true );
SwDocPosUpdate aMsgHnt( pPage->Frm().Top() );
- pPage->GetFmt()->GetDoc()->UpdatePageFlds( &aMsgHnt );
+ pPage->GetFmt()->GetDoc()->getIDocumentFieldsAccess().UpdatePageFlds( &aMsgHnt );
}
break;
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 0604a623665f..2237de6e5fd0 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -36,6 +36,7 @@
#include <doc.hxx>
#include <IDocumentLinksAdministration.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <frame.hxx>
#include <swtable.hxx>
@@ -2200,7 +2201,7 @@ void SwTableBoxFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
// something changed and some BoxAttribut remained in the set!
if( pNewFmt || pNewFml || pNewVal )
{
- GetDoc()->SetFieldsDirty(true, NULL, 0);
+ GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty(true, NULL, 0);
if( SFX_ITEM_SET == GetItemState( RES_BOXATR_FORMAT, false ) ||
SFX_ITEM_SET == GetItemState( RES_BOXATR_VALUE, false ) ||
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 9da12567a6a6..9c72fc8df542 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -33,6 +33,7 @@
#include <doc.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDeviceAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include "rootfrm.hxx"
#include <pagefrm.hxx>
#include <viewsh.hxx>
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 7329b879dcb8..3e06ec99fe8b 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -550,7 +550,7 @@ void SwTxtInputFld::UpdateFieldContent()
{
const_cast<SwInputField*>(pInputFld)->applyFieldContent( aNewFieldContent );
// trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
- GetTxtNode().GetDoc()->GetUpdtFlds().SetFieldsDirty(true);
+ GetTxtNode().GetDoc()->getIDocumentFieldsAccess().GetUpdtFlds().SetFieldsDirty(true);
}
}
}
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 49a260f332af..23b661ea7676 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -53,6 +53,7 @@
#include <breakit.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <fldbas.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -1159,8 +1160,8 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr )
case RES_HIDDENTXTFLD:
case RES_DBNUMSETFLD:
case RES_DBNEXTSETFLD:
- if( !pDoc->IsNewFldLst() && GetNodes().IsDocNodes() )
- pDoc->InsDelFldInFldLst( false, *(SwTxtFld*)pAttr );
+ if( !pDoc->getIDocumentFieldsAccess().IsNewFldLst() && GetNodes().IsDocNodes() )
+ pDoc->getIDocumentFieldsAccess().InsDelFldInFldLst( false, *(SwTxtFld*)pAttr );
break;
case RES_DDEFLD:
if( GetNodes().IsDocNodes() &&
@@ -3020,7 +3021,7 @@ bool SwpHints::TryInsertHint(
SwDoc* pDoc = rNode.GetDoc();
const SwField* pFld = ((SwTxtFld*)pHint)->GetFmtFld().GetField();
- if( !pDoc->IsNewFldLst() )
+ if( !pDoc->getIDocumentFieldsAccess().IsNewFldLst() )
{
// was fuer ein Feld ist es denn ??
// bestimmte Felder mussen am Doc das Calculations-Flag updaten
@@ -3034,9 +3035,9 @@ bool SwpHints::TryInsertHint(
case RES_DBNEXTSETFLD:
{
if( bDelFirst )
- pDoc->InsDelFldInFldLst( false, *(SwTxtFld*)pHint );
+ pDoc->getIDocumentFieldsAccess().InsDelFldInFldLst( false, *(SwTxtFld*)pHint );
if( rNode.GetNodes().IsDocNodes() )
- pDoc->InsDelFldInFldLst( true, *(SwTxtFld*)pHint );
+ pDoc->getIDocumentFieldsAccess().InsDelFldInFldLst( true, *(SwTxtFld*)pHint );
}
break;
case RES_DDEFLD:
@@ -3059,7 +3060,7 @@ bool SwpHints::TryInsertHint(
// bevor die ReferenzNummer gesetzt wird, sollte
// das Feld am richtigen FeldTypen haengen!
SwSetExpFieldType* pFldType = (SwSetExpFieldType*)
- pDoc->InsertFldType( *pFld->GetTyp() );
+ pDoc->getIDocumentFieldsAccess().InsertFldType( *pFld->GetTyp() );
if( pFldType != pFld->GetTyp() )
{
SwFmtFld* pFmtFld = (SwFmtFld*)&((SwTxtFld*)pHint)->GetFmtFld();
@@ -3074,7 +3075,7 @@ bool SwpHints::TryInsertHint(
break;
case RES_DDEFLD:
- if( pDoc->IsNewFldLst() )
+ if( pDoc->getIDocumentFieldsAccess().IsNewFldLst() )
((SwDDEFieldType*)pFld->GetTyp())->IncRefCnt();
bInsFldType = ((SwDDEFieldType*)pFld->GetTyp())->IsDeleted();
break;
@@ -3085,7 +3086,7 @@ bool SwpHints::TryInsertHint(
break;
}
if( bInsFldType )
- pDoc->InsDeletedFldType( *pFld->GetTyp() );
+ pDoc->getIDocumentFieldsAccess().InsDeletedFldType( *pFld->GetTyp() );
}
}
break;
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 3a02a7ad709f..57706917bfc8 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -106,7 +106,7 @@ lcl_MaskRedlines( const SwTxtNode& rNode, OUStringBuffer& rText,
const SwDoc& rDoc = *rNode.GetDoc();
- for ( size_t nAct = rDoc.GetRedlinePos( rNode, USHRT_MAX ); nAct < rDoc.getIDocumentRedlineAccess().GetRedlineTbl().size(); ++nAct )
+ for ( size_t nAct = rDoc.getIDocumentRedlineAccess().GetRedlinePos( rNode, USHRT_MAX ); nAct < rDoc.getIDocumentRedlineAccess().GetRedlineTbl().size(); ++nAct )
{
const SwRangeRedline* pRed = rDoc.getIDocumentRedlineAccess().GetRedlineTbl()[ nAct ];
diff --git a/sw/source/core/undo/SwUndoField.cxx b/sw/source/core/undo/SwUndoField.cxx
index 738df46bb7d8..7c11c9bef538 100644
--- a/sw/source/core/undo/SwUndoField.cxx
+++ b/sw/source/core/undo/SwUndoField.cxx
@@ -23,6 +23,7 @@
#include <swundo.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <DocumentFieldsManager.hxx>
#include <txtfld.hxx>
#include <fldbas.hxx>
#include <ndtxt.hxx>
@@ -77,26 +78,26 @@ SwUndoFieldFromDoc::~SwUndoFieldFromDoc()
void SwUndoFieldFromDoc::UndoImpl(::sw::UndoRedoContext &)
{
- SwTxtFld * pTxtFld = SwDoc::GetTxtFldAtPos(GetPosition());
+ SwTxtFld * pTxtFld = sw::DocumentFieldsManager::GetTxtFldAtPos(GetPosition());
const SwField * pField = pTxtFld ? pTxtFld->GetFmtFld().GetField() : NULL;
if (pField)
{
- pDoc->UpdateFld(pTxtFld, *pOldField, pHnt, bUpdate);
+ pDoc->getIDocumentFieldsAccess().UpdateFld(pTxtFld, *pOldField, pHnt, bUpdate);
}
}
void SwUndoFieldFromDoc::DoImpl()
{
- SwTxtFld * pTxtFld = SwDoc::GetTxtFldAtPos(GetPosition());
+ SwTxtFld * pTxtFld = sw::DocumentFieldsManager::GetTxtFldAtPos(GetPosition());
const SwField * pField = pTxtFld ? pTxtFld->GetFmtFld().GetField() : NULL;
if (pField)
{
- pDoc->UpdateFld(pTxtFld, *pNewField, pHnt, bUpdate);
+ pDoc->getIDocumentFieldsAccess().UpdateFld(pTxtFld, *pNewField, pHnt, bUpdate);
SwFmtFld* pDstFmtFld = (SwFmtFld*)&pTxtFld->GetFmtFld();
- if ( pDoc->GetFldType(RES_POSTITFLD, aEmptyOUStr, false) == pDstFmtFld->GetField()->GetTyp() )
+ if ( pDoc->getIDocumentFieldsAccess().GetFldType(RES_POSTITFLD, aEmptyOUStr, false) == pDstFmtFld->GetField()->GetTyp() )
pDoc->GetDocShell()->Broadcast( SwFmtFldHint( pDstFmtFld, SWFMTFLD_INSERTED ) );
}
}
@@ -125,7 +126,7 @@ SwUndoFieldFromAPI::~SwUndoFieldFromAPI()
void SwUndoFieldFromAPI::UndoImpl(::sw::UndoRedoContext &)
{
- SwField * pField = SwDoc::GetFieldAtPos(GetPosition());
+ SwField * pField = sw::DocumentFieldsManager::GetFieldAtPos(GetPosition());
if (pField)
pField->PutValue(aOldVal, nWhich);
@@ -133,7 +134,7 @@ void SwUndoFieldFromAPI::UndoImpl(::sw::UndoRedoContext &)
void SwUndoFieldFromAPI::DoImpl()
{
- SwField * pField = SwDoc::GetFieldAtPos(GetPosition());
+ SwField * pField = sw::DocumentFieldsManager::GetFieldAtPos(GetPosition());
if (pField)
pField->PutValue(aNewVal, nWhich);
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 96a229ff231e..41675082886e 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -40,6 +40,7 @@
#include <ftnidx.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <ndtxt.hxx>
#include <paratr.hxx>
@@ -266,7 +267,7 @@ SwHistorySetTxtFld::SwHistorySetTxtFld( SwTxtFld* pTxtFld, sal_uLong nNodePos )
m_nFldWhich == RES_USERFLD ||
m_nFldWhich == RES_SETEXPFLD ||
m_nFldWhich == RES_DDEFLD ||
- !pDoc->GetSysFldType( m_nFldWhich ))
+ !pDoc->getIDocumentFieldsAccess().GetSysFldType( m_nFldWhich ))
{
m_pFldType.reset( m_pFld->GetField()->GetTyp()->Copy() );
m_pFld->GetField()->ChgTyp( m_pFldType.get() ); // change field type
@@ -292,12 +293,12 @@ void SwHistorySetTxtFld::SetInDoc( SwDoc* pDoc, bool )
SwFieldType* pNewFldType = m_pFldType.get();
if ( !pNewFldType )
{
- pNewFldType = pDoc->GetSysFldType( m_nFldWhich );
+ pNewFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType( m_nFldWhich );
}
else
{
// register type with the document
- pNewFldType = pDoc->InsertFldType( *m_pFldType );
+ pNewFldType = pDoc->getIDocumentFieldsAccess().InsertFldType( *m_pFldType );
}
m_pFld->GetField()->ChgTyp( pNewFldType ); // change field type
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index cd69474fa6d8..402094a318d8 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -24,6 +24,7 @@
#include <doc.hxx>
#include <IDocumentLinksAdministration.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <swundo.hxx>
#include <pam.hxx>
@@ -363,7 +364,7 @@ void SwUndoDelSection::UndoImpl(::sw::UndoRedoContext & rContext)
!aInsertedSect.GetCondition().isEmpty() )
{
SwCalc aCalc( rDoc );
- rDoc.FldsToCalc(aCalc, pInsertedSectNd->GetIndex(), USHRT_MAX);
+ rDoc.getIDocumentFieldsAccess().FldsToCalc(aCalc, pInsertedSectNd->GetIndex(), USHRT_MAX);
bool bRecalcCondHidden =
aCalc.Calculate( aInsertedSect.GetCondition() ).GetBool();
aInsertedSect.SetCondHidden( bRecalcCondHidden );
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 9f3d31a0a24b..2be19a0f1998 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -37,6 +37,7 @@
#include <IDocumentUndoRedo.hxx>
#include <IDocumentChartDataProviderAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <editsh.hxx>
#include <docary.hxx>
#include <ndtxt.hxx>
@@ -310,7 +311,7 @@ void SwUndoInsTbl::RedoImpl(::sw::UndoRedoContext & rContext)
if( pDDEFldType )
{
- SwDDEFieldType* pNewType = (SwDDEFieldType*)rDoc.InsertFldType(
+ SwDDEFieldType* pNewType = (SwDDEFieldType*)rDoc.getIDocumentFieldsAccess().InsertFldType(
*pDDEFldType);
SwDDETable* pDDETbl = new SwDDETable( pTblNode->GetTable(), pNewType );
pTblNode->SetNewTable( pDDETbl );
@@ -472,7 +473,7 @@ void SwUndoTblToTxt::UndoImpl(::sw::UndoRedoContext & rContext)
if( pDDEFldType )
{
- SwDDEFieldType* pNewType = (SwDDEFieldType*)rDoc.InsertFldType(
+ SwDDEFieldType* pNewType = (SwDDEFieldType*)rDoc.getIDocumentFieldsAccess().InsertFldType(
*pDDEFldType);
SwDDETable* pDDETbl = new SwDDETable( pTblNd->GetTable(), pNewType );
pTblNd->SetNewTable( pDDETbl, false );
@@ -1686,7 +1687,7 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
aMsgHnt.eFlags = TBL_BOXPTR;
- rDoc.UpdateTblFlds( &aMsgHnt );
+ rDoc.getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
CHECK_TABLE( pTblNd->GetTable() )
@@ -1870,7 +1871,7 @@ void SwUndoTblNdsChg::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
aMsgHnt.eFlags = TBL_BOXPTR;
- rDoc.UpdateTblFlds( &aMsgHnt );
+ rDoc.getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
SwTable &rTable = pTblNd->GetTable();
if( nMax > nMin && rTable.IsNewModel() )
rTable.PrepareDeleteCol( nMin, nMax );
@@ -1882,7 +1883,7 @@ void SwUndoTblNdsChg::RedoImpl(::sw::UndoRedoContext & rContext)
SwTableFmlUpdate aMsgHnt( &rTbl );
aMsgHnt.eFlags = TBL_BOXPTR;
- rDoc.UpdateTblFlds( &aMsgHnt );
+ rDoc.getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
SwTableBox* pBox = rTbl.GetTblBox( nCurrBox );
TblChgMode eOldMode = rTbl.GetTblChgMode();
@@ -1955,7 +1956,7 @@ void SwUndoTblMerge::UndoImpl(::sw::UndoRedoContext & rContext)
SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
aMsgHnt.eFlags = TBL_BOXPTR;
- rDoc.UpdateTblFlds( &aMsgHnt );
+ rDoc.getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
_FndBox aTmpBox( 0, 0 );
// ? TL_CHART2: notification or locking of controller required ?
@@ -2392,7 +2393,7 @@ void SwUndoTblNumFmt::RedoImpl(::sw::UndoRedoContext & rContext)
{
// No matter what was set, an update of the table is always a good idea
SwTableFmlUpdate aTblUpdate( &pSttNd->FindTableNode()->GetTable() );
- rDoc.UpdateTblFlds( &aTblUpdate );
+ rDoc.getIDocumentFieldsAccess().UpdateTblFlds( &aTblUpdate );
}
if( !pNd->IsCntntNode() )
@@ -2909,7 +2910,7 @@ void SwUndoSplitTbl::UndoImpl(::sw::UndoRedoContext & rContext)
SwTableFmlUpdate aMsgHnt( &rTbl );
aMsgHnt.eFlags = TBL_BOXPTR;
- pDoc->UpdateTblFlds( &aMsgHnt );
+ pDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
switch( nMode )
{
@@ -3024,7 +3025,7 @@ void SwUndoMergeTbl::UndoImpl(::sw::UndoRedoContext & rContext)
SwTableFmlUpdate aMsgHnt( pTbl );
aMsgHnt.eFlags = TBL_BOXPTR;
- pDoc->UpdateTblFlds( &aMsgHnt );
+ pDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aMsgHnt );
// get lines for layout update
_FndBox aFndBox( 0, 0 );
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 4c2e4af66231..d42cab250f9f 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -23,6 +23,7 @@
#include <svx/svxids.hrc>
#include <doc.hxx>
#include <IDocumentChartDataProviderAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docary.hxx>
#include <fmtcol.hxx>
#include <poolfmt.hxx>
@@ -784,11 +785,11 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16
break;
case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY:
{
- SwFieldType* pType = pDoc->GetFldType(RES_AUTHORITY, aEmptyOUStr, true);
+ SwFieldType* pType = pDoc->getIDocumentFieldsAccess().GetFldType(RES_AUTHORITY, aEmptyOUStr, true);
if(!pType)
{
SwAuthorityFieldType aType(pDoc);
- pType = pDoc->InsertFldType(aType);
+ pType = pDoc->getIDocumentFieldsAccess().InsertFldType(aType);
}
xRet = SwXFieldMaster::CreateXFieldMaster(*pDoc, *pType);
}
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 4396c2677548..51c367f7aec7 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -28,6 +28,7 @@
#include <swtypes.hxx>
#include <cmdid.h>
#include <doc.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <hints.hxx>
#include <fmtfld.hxx>
#include <txtfld.hxx>
@@ -622,7 +623,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
{
OUString sTypeName;
rValue >>= sTypeName;
- SwFieldType * pType2 = m_pImpl->m_pDoc->GetFldType(
+ SwFieldType * pType2 = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFldType(
m_pImpl->m_nResTypeId, sTypeName, false);
if(pType2 ||
@@ -640,7 +641,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
case RES_USERFLD :
{
SwUserFieldType aType(m_pImpl->m_pDoc, sTypeName);
- pType2 = m_pImpl->m_pDoc->InsertFldType(aType);
+ pType2 = m_pImpl->m_pDoc->getIDocumentFieldsAccess().InsertFldType(aType);
static_cast<SwUserFieldType*>(pType2)->SetContent(m_pImpl->m_sParam1);
static_cast<SwUserFieldType*>(pType2)->SetValue(m_pImpl->m_fParam1);
static_cast<SwUserFieldType*>(pType2)->SetType(m_pImpl->m_bParam1
@@ -652,7 +653,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
SwDDEFieldType aType(sTypeName, m_pImpl->m_sParam1,
sal::static_int_cast<sal_uInt16>((m_pImpl->m_bParam1)
? sfx2::LINKUPDATE_ALWAYS : sfx2::LINKUPDATE_ONCALL));
- pType2 = m_pImpl->m_pDoc->InsertFldType(aType);
+ pType2 = m_pImpl->m_pDoc->getIDocumentFieldsAccess().InsertFldType(aType);
}
break;
case RES_SETEXPFLD :
@@ -662,7 +663,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
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);
+ pType2 = m_pImpl->m_pDoc->getIDocumentFieldsAccess().InsertFldType(aType);
}
break;
case RES_DBFLD :
@@ -788,7 +789,7 @@ SwFieldType* SwXFieldMaster::GetFldType(bool const bDontCreate) const
aData.sCommand = m_pImpl->m_sParam2;
aData.nCommandType = m_pImpl->m_nParam2;
SwDBFieldType aType(m_pImpl->m_pDoc, m_pImpl->m_sParam3, aData);
- SwFieldType *const pType = m_pImpl->m_pDoc->InsertFldType(aType);
+ SwFieldType *const pType = m_pImpl->m_pDoc->getIDocumentFieldsAccess().InsertFldType(aType);
pType->Add(m_pImpl.get());
const_cast<SwXFieldMaster*>(this)->m_pImpl->m_bIsDescriptor = false;
}
@@ -972,7 +973,7 @@ throw (uno::RuntimeException, std::exception)
if (!pFldType)
throw uno::RuntimeException();
sal_uInt16 nTypeIdx = USHRT_MAX;
- const SwFldTypes* pTypes = m_pImpl->m_pDoc->GetFldTypes();
+ const SwFldTypes* pTypes = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFldTypes();
for( size_t i = 0; i < pTypes->size(); i++ )
{
if((*pTypes)[i] == pFldType)
@@ -992,7 +993,7 @@ throw (uno::RuntimeException, std::exception)
pFld = aIter.Next();
}
// then delete FieldType
- m_pImpl->m_pDoc->RemoveFldType(nTypeIdx);
+ m_pImpl->m_pDoc->getIDocumentFieldsAccess().RemoveFldType(nTypeIdx);
}
void SAL_CALL SwXFieldMaster::addEventListener(
@@ -1028,7 +1029,7 @@ OUString SwXFieldMaster::GetProgrammaticName(const SwFieldType& rType, SwDoc& rD
const OUString sName(rType.GetName());
if(RES_SETEXPFLD == rType.Which())
{
- const SwFldTypes* pTypes = rDoc.GetFldTypes();
+ const SwFldTypes* pTypes = rDoc.getIDocumentFieldsAccess().GetFldTypes();
for( size_t i = 0; i <= size_t(INIT_FLDTYPES); i++ )
{
if((*pTypes)[i] == &rType)
@@ -1323,7 +1324,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
{
case SW_SERVICE_FIELDTYPE_ANNOTATION:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_POSTITFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_POSTITFLD);
DateTime aDateTime( DateTime::EMPTY );
if (m_pImpl->m_pProps->pDateTime)
@@ -1352,7 +1353,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_SCRIPT:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_SCRIPTFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_SCRIPTFLD);
pFld = new SwScriptField((SwScriptFieldType*)pFldType,
m_pImpl->m_pProps->sPar1, m_pImpl->m_pProps->sPar2,
m_pImpl->m_pProps->bBool1);
@@ -1367,7 +1368,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
nSub |= DATEFLD;
else
nSub |= TIMEFLD;
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_DATETIMEFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_DATETIMEFLD);
SwDateTimeField *const pDTField = new SwDateTimeField(
static_cast<SwDateTimeFieldType*>(pFldType),
nSub, m_pImpl->m_pProps->nFormat);
@@ -1386,7 +1387,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_FILE_NAME:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_FILENAMEFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_FILENAMEFLD);
sal_Int32 nFormat = m_pImpl->m_pProps->nFormat;
if (m_pImpl->m_pProps->bBool2)
nFormat |= FF_FIXED;
@@ -1402,7 +1403,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_TEMPLATE_NAME:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_TEMPLNAMEFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_TEMPLNAMEFLD);
pFld = new SwTemplNameField((SwTemplNameFieldType*)pFldType,
m_pImpl->m_pProps->nFormat);
uno::Any aFormat;
@@ -1412,7 +1413,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_CHAPTER:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_CHAPTERFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_CHAPTERFLD);
SwChapterField *const pChapterField = new SwChapterField(
static_cast<SwChapterFieldType*>(pFldType),
m_pImpl->m_pProps->nUSHORT1);
@@ -1429,7 +1430,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
if (m_pImpl->m_pProps->bBool2)
nFormat |= AF_FIXED;
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_AUTHORFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_AUTHORFLD);
SwAuthorField *const pAuthorField = new SwAuthorField(
static_cast<SwAuthorFieldType*>(pFldType), nFormat);
pFld = pAuthorField;
@@ -1439,7 +1440,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case SW_SERVICE_FIELDTYPE_CONDITIONED_TEXT:
case SW_SERVICE_FIELDTYPE_HIDDEN_TEXT:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_HIDDENTXTFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_HIDDENTXTFLD);
SwHiddenTxtField *const pHTField = new SwHiddenTxtField(
static_cast<SwHiddenTxtFieldType*>(pFldType),
m_pImpl->m_pProps->sPar1,
@@ -1455,7 +1456,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_HIDDEN_PARA:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_HIDDENPARAFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_HIDDENPARAFLD);
SwHiddenParaField *const pHPField = new SwHiddenParaField(
static_cast<SwHiddenParaFieldType*>(pFldType),
m_pImpl->m_pProps->sPar1);
@@ -1465,7 +1466,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_GET_REFERENCE:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_GETREFFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_GETREFFLD);
pFld = new SwGetRefField((SwGetRefFieldType*)pFldType,
m_pImpl->m_pProps->sPar1,
0,
@@ -1484,7 +1485,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_JUMP_EDIT:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_JUMPEDITFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_JUMPEDITFLD);
pFld = new SwJumpEditField((SwJumpEditFieldType*)pFldType,
m_pImpl->m_pProps->nUSHORT1, m_pImpl->m_pProps->sPar2,
m_pImpl->m_pProps->sPar1);
@@ -1505,7 +1506,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case SW_SERVICE_FIELDTYPE_DOCINFO_REVISION :
case SW_SERVICE_FIELDTYPE_DOC_INFO:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_DOCINFOFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().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 ||
@@ -1539,7 +1540,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
if (m_pImpl->m_pProps->bBool1)
nFormat = AF_FIXED;
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_EXTUSERFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_EXTUSERFLD);
SwExtUserField *const pEUField = new SwExtUserField(
static_cast<SwExtUserFieldType*>(pFldType),
m_pImpl->m_pProps->nUSHORT1, nFormat);
@@ -1550,7 +1551,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case SW_SERVICE_FIELDTYPE_USER:
{
SwFieldType* pFldType =
- pDoc->GetFldType(RES_USERFLD, m_pImpl->m_sTypeName, true);
+ pDoc->getIDocumentFieldsAccess().GetFldType(RES_USERFLD, m_pImpl->m_sTypeName, true);
if (!pFldType)
throw uno::RuntimeException();
sal_uInt16 nUserSubType = (m_pImpl->m_pProps->bBool1)
@@ -1569,7 +1570,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_REF_PAGE_SET:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_REFPAGESETFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_REFPAGESETFLD);
pFld = new SwRefPageSetField( (SwRefPageSetFieldType*)pFldType,
m_pImpl->m_pProps->nUSHORT1,
m_pImpl->m_pProps->bBool1 );
@@ -1577,7 +1578,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_REF_PAGE_GET:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_REFPAGEGETFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_REFPAGEGETFLD);
SwRefPageGetField *const pRGField = new SwRefPageGetField(
static_cast<SwRefPageGetFieldType*>(pFldType),
m_pImpl->m_pProps->nUSHORT1 );
@@ -1587,7 +1588,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_PAGE_NUM:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_PAGENUMBERFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_PAGENUMBERFLD);
SwPageNumberField *const pPNField = new SwPageNumberField(
static_cast<SwPageNumberFieldType*>(pFldType), PG_RANDOM,
m_pImpl->m_pProps->nFormat,
@@ -1602,7 +1603,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case SW_SERVICE_FIELDTYPE_DDE:
{
SwFieldType* pFldType =
- pDoc->GetFldType(RES_DDEFLD, m_pImpl->m_sTypeName, true);
+ pDoc->getIDocumentFieldsAccess().GetFldType(RES_DDEFLD, m_pImpl->m_sTypeName, true);
if (!pFldType)
throw uno::RuntimeException();
pFld = new SwDDEField( (SwDDEFieldType*)pFldType );
@@ -1611,7 +1612,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case SW_SERVICE_FIELDTYPE_DATABASE_NAME:
#if HAVE_FEATURE_DBCONNECTIVITY
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_DBNAMEFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_DBNAMEFLD);
SwDBData aData;
aData.sDataSource = m_pImpl->m_pProps->sPar1;
aData.sCommand = m_pImpl->m_pProps->sPar2;
@@ -1633,7 +1634,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
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);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_DBNEXTSETFLD);
pFld = new SwDBNextSetField((SwDBNextSetFieldType*)pFldType,
m_pImpl->m_pProps->sPar3, OUString(), aData);
}
@@ -1647,7 +1648,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
aData.sCommand = m_pImpl->m_pProps->sPar2;
aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
pFld = new SwDBNumSetField( (SwDBNumSetFieldType*)
- pDoc->GetSysFldType(RES_DBNUMSETFLD),
+ pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_DBNUMSETFLD),
m_pImpl->m_pProps->sPar3,
OUString::number(m_pImpl->m_pProps->nFormat),
aData );
@@ -1663,7 +1664,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
aData.nCommandType = m_pImpl->m_pProps->nSHORT1;
SwDBSetNumberField *const pDBSNField =
new SwDBSetNumberField(static_cast<SwDBSetNumberFieldType*>(
- pDoc->GetSysFldType(RES_DBSETNUMBERFLD)), aData,
+ pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_DBSETNUMBERFLD)), aData,
m_pImpl->m_pProps->nUSHORT1);
pFld = pDBSNField;
pDBSNField->SetSetNumber(m_pImpl->m_pProps->nFormat);
@@ -1680,7 +1681,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
#if HAVE_FEATURE_DBCONNECTIVITY
{
SwFieldType* pFldType =
- pDoc->GetFldType(RES_DBFLD, m_pImpl->m_sTypeName, false);
+ pDoc->getIDocumentFieldsAccess().GetFldType(RES_DBFLD, m_pImpl->m_sTypeName, false);
if (!pFldType)
throw uno::RuntimeException();
pFld = new SwDBField(static_cast<SwDBFieldType*>(pFldType),
@@ -1698,7 +1699,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case SW_SERVICE_FIELDTYPE_SET_EXP:
{
SwFieldType* pFldType =
- pDoc->GetFldType(RES_SETEXPFLD, m_pImpl->m_sTypeName, true);
+ pDoc->getIDocumentFieldsAccess().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
@@ -1746,7 +1747,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
nSubType = nsSwGetSetExpType::GSE_EXPR;
}
//make sure the SubType matches the field type
- SwFieldType* pSetExpFld = pDoc->GetFldType(
+ SwFieldType* pSetExpFld = pDoc->getIDocumentFieldsAccess().GetFldType(
RES_SETEXPFLD, m_pImpl->m_pProps->sPar1, false);
bool bSetGetExpFieldUninitialized = false;
if (pSetExpFld)
@@ -1764,7 +1765,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
nSubType &= ~nsSwExtendedSubType::SUB_CMD;
SwGetExpField *const pGEField = new SwGetExpField(
static_cast<SwGetExpFieldType*>(
- pDoc->GetSysFldType(RES_GETEXPFLD)),
+ pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_GETEXPFLD)),
m_pImpl->m_pProps->sPar1, nSubType,
m_pImpl->m_pProps->nFormat);
pFld = pGEField;
@@ -1780,7 +1781,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case SW_SERVICE_FIELDTYPE_INPUT:
{
SwFieldType* pFldType =
- pDoc->GetFldType(RES_INPUTFLD, m_pImpl->m_sTypeName, true);
+ pDoc->getIDocumentFieldsAccess().GetFldType(RES_INPUTFLD, m_pImpl->m_sTypeName, true);
if (!pFldType)
throw uno::RuntimeException();
sal_uInt16 nInpSubType =
@@ -1800,7 +1801,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
break;
case SW_SERVICE_FIELDTYPE_MACRO:
{
- SwFieldType* pFldType = pDoc->GetSysFldType(RES_MACROFLD);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_MACROFLD);
OUString aName;
// support for Scripting Framework macros
@@ -1835,7 +1836,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
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);
+ SwFieldType* pFldType = pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_DOCSTATFLD);
pFld = new SwDocStatField(
static_cast<SwDocStatFieldType*>(pFldType),
nSubType, m_pImpl->m_pProps->nUSHORT2);
@@ -1845,7 +1846,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
{
SwAuthorityFieldType const type(pDoc);
pFld = new SwAuthorityField(static_cast<SwAuthorityFieldType*>(
- pDoc->InsertFldType(type)),
+ pDoc->getIDocumentFieldsAccess().InsertFldType(type)),
OUString());
if (m_pImpl->m_pProps->aPropSeq.getLength())
{
@@ -1858,14 +1859,14 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS:
// create field
pFld = new SwCombinedCharField( (SwCombinedCharFieldType*)
- pDoc->GetSysFldType(RES_COMBINED_CHARS),
+ pDoc->getIDocumentFieldsAccess().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)));
+ pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_DROPDOWN)));
pFld = pDDField;
pDDField->SetItems(m_pImpl->m_pProps->aStrings);
@@ -1887,7 +1888,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
m_pImpl->m_pProps->nFormat = -1;
}
pFld = new SwTblField( (SwTblFieldType*)
- pDoc->GetSysFldType(RES_TABLEFLD),
+ pDoc->getIDocumentFieldsAccess().GetSysFldType(RES_TABLEFLD),
m_pImpl->m_pProps->sPar2,
nType,
m_pImpl->m_pProps->nFormat);
@@ -2142,7 +2143,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
throw uno::RuntimeException();
SwPosition aPosition( pTxtFld->GetTxtNode() );
aPosition.nContent = pTxtFld->GetStart();
- pDoc->PutValueToField( aPosition, rValue, pEntry->nWID);
+ pDoc->getIDocumentFieldsAccess().PutValueToField( aPosition, rValue, pEntry->nWID);
}
//#i100374# notify SwPostIt about new field content
@@ -2704,7 +2705,7 @@ uno::Any SwXTextFieldMasters::getByName(const OUString& rName)
css::uno::Reference<css::uno::XInterface>());
sName = sName.copy(std::min(sTypeName.getLength()+1, sName.getLength()));
- SwFieldType* pType = GetDoc()->GetFldType(nResId, sName, true);
+ SwFieldType* pType = GetDoc()->getIDocumentFieldsAccess().GetFldType(nResId, sName, true);
if(!pType)
throw container::NoSuchElementException(
"SwXTextFieldMasters::getByName(" + rName + ")",
@@ -2756,7 +2757,7 @@ uno::Sequence< OUString > SwXTextFieldMasters::getElementNames(void)
if(!GetDoc())
throw uno::RuntimeException();
- const SwFldTypes* pFldTypes = GetDoc()->GetFldTypes();
+ const SwFldTypes* pFldTypes = GetDoc()->getIDocumentFieldsAccess().GetFldTypes();
const size_t nCount = pFldTypes->size();
std::vector<OUString> aFldNames;
@@ -2793,7 +2794,7 @@ sal_Bool SwXTextFieldMasters::hasByName(const OUString& rName) throw( uno::Runti
if( USHRT_MAX != nResId )
{
sName = sName.copy(std::min(sTypeName.getLength()+1, sName.getLength()));
- bRet = USHRT_MAX != nResId && 0 != GetDoc()->GetFldType(nResId, sName, true);
+ bRet = USHRT_MAX != nResId && 0 != GetDoc()->getIDocumentFieldsAccess().GetFldType(nResId, sName, true);
}
return bRet;
}
@@ -2888,7 +2889,7 @@ void SAL_CALL SwXTextFieldTypes::refresh() throw (uno::RuntimeException, std::ex
throw uno::RuntimeException();
UnoActionContext aContext(GetDoc());
GetDoc()->UpdateDocStat();
- GetDoc()->UpdateFlds(0, false);
+ GetDoc()->getIDocumentFieldsAccess().UpdateFlds(0, false);
}
// call refresh listeners (without SolarMutex locked)
lang::EventObject const event(static_cast< ::cppu::OWeakObject*>(this));
@@ -2963,7 +2964,7 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc & rDoc)
uno::Reference< text::XTextField > *pItems = m_pImpl->m_Items.getArray();
sal_Int32 nFillPos = 0;
- const SwFldTypes* pFldTypes = m_pImpl->m_pDoc->GetFldTypes();
+ const SwFldTypes* pFldTypes = m_pImpl->m_pDoc->getIDocumentFieldsAccess().GetFldTypes();
const size_t nCount = pFldTypes->size();
for(size_t nType = 0; nType < nCount; ++nType)
{
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 61d770e51ec7..af288e5c0234 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -35,6 +35,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentContentOperations.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <shellres.hxx>
#include <docary.hxx>
#include <ndole.hxx>
@@ -766,7 +767,7 @@ void sw_setValue( SwXCell &rCell, double nVal )
pDoc->SetTblBoxFormulaAttrs( *rCell.pBox, aSet );
// update table
SwTableFmlUpdate aTblUpdate( SwTable::FindTable( rCell.GetFrmFmt() ));
- pDoc->UpdateTblFlds( &aTblUpdate );
+ pDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aTblUpdate );
}
}
@@ -945,7 +946,7 @@ void SwXCell::setFormula(const OUString& rFormula) throw( uno::RuntimeException,
GetDoc()->SetTblBoxFormulaAttrs( *pBox, aSet );
// update table
SwTableFmlUpdate aTblUpdate( SwTable::FindTable( GetFrmFmt() ));
- pMyDoc->UpdateTblFlds( &aTblUpdate );
+ pMyDoc->getIDocumentFieldsAccess().UpdateTblFlds( &aTblUpdate );
}
}
diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx
index 164d760a1405..ae395f77f756 100644
--- a/sw/source/core/view/printdata.cxx
+++ b/sw/source/core/view/printdata.cxx
@@ -49,7 +49,7 @@ void SwRenderData::CreatePostItData( SwDoc *pDoc, const SwViewOption *pViewOpt,
{
DeletePostItData();
m_pPostItFields.reset(new _SetGetExpFlds);
- sw_GetPostIts( pDoc, m_pPostItFields.get() );
+ sw_GetPostIts( &pDoc->getIDocumentFieldsAccess(), m_pPostItFields.get() );
//!! Disable spell and grammar checking in the temporary document.
//!! Otherwise the grammar checker might process it and crash if we later on
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 540224af8696..dbc7d88ad86c 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -35,6 +35,7 @@
#include <IDocumentDeviceAccess.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentOutlineNodes.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <rootfrm.hxx>
#include <pagefrm.hxx>
#include <cntfrm.hxx>
@@ -606,7 +607,7 @@ void SwViewShell::UpdateFlds(bool bCloseDB)
else
StartAction();
- GetDoc()->UpdateFlds(0, bCloseDB);
+ GetDoc()->getIDocumentFieldsAccess().UpdateFlds(0, bCloseDB);
if ( bCrsr )
((SwCrsrShell*)this)->EndAction();
@@ -917,9 +918,9 @@ void SwViewShell::CalcLayout()
aAction.SetStatBar( true );
aAction.SetCalcLayout( true );
aAction.SetReschedule( true );
- GetDoc()->LockExpFlds();
+ GetDoc()->getIDocumentFieldsAccess().LockExpFlds();
aAction.Action();
- GetDoc()->UnlockExpFlds();
+ GetDoc()->getIDocumentFieldsAccess().UnlockExpFlds();
//the SetNewFldLst() on the Doc was cut off and must be fetched again
//(see flowfrm.cxx, txtfld.cxx)
@@ -931,8 +932,8 @@ void SwViewShell::CalcLayout()
aAction.SetReschedule( true );
SwDocPosUpdate aMsgHnt( 0 );
- GetDoc()->UpdatePageFlds( &aMsgHnt );
- GetDoc()->UpdateExpFlds(NULL, true);
+ GetDoc()->getIDocumentFieldsAccess().UpdatePageFlds( &aMsgHnt );
+ GetDoc()->getIDocumentFieldsAccess().UpdateExpFlds(NULL, true);
aAction.Action();
}
@@ -2099,14 +2100,14 @@ void SwViewShell::ImplApplyViewOptions( const SwViewOption &rOpt )
if( mpOpt->IsShowHiddenField() != rOpt.IsShowHiddenField() )
{
- ((SwHiddenTxtFieldType*)mpDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
+ ((SwHiddenTxtFieldType*)mpDoc->getIDocumentFieldsAccess().GetSysFldType( RES_HIDDENTXTFLD ))->
SetHiddenFlag( !rOpt.IsShowHiddenField() );
bReformat = true;
}
if ( mpOpt->IsShowHiddenPara() != rOpt.IsShowHiddenPara() )
{
SwHiddenParaFieldType* pFldType = (SwHiddenParaFieldType*)GetDoc()->
- GetSysFldType(RES_HIDDENPARAFLD);
+ getIDocumentFieldsAccess().GetSysFldType(RES_HIDDENPARAFLD);
if( pFldType && pFldType->GetDepends() )
{
SwMsgPoolItem aHnt( RES_HIDDENPARA_PRINT );
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index af0a0f6ce2af..e4e3d7e3179f 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -22,6 +22,7 @@
#include <IDocumentUndoRedo.hxx>
#include <DocumentSettingManager.hxx>
#include <IDocumentDeviceAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <docsh.hxx>
#include <viewsh.hxx>
#include <rootfrm.hxx>
@@ -196,7 +197,7 @@ SwViewShell::SwViewShell( SwDoc& rDocument, Window *pWindow,
SET_CURR_SHELL( this );
- ((SwHiddenTxtFieldType*)mpDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
+ ((SwHiddenTxtFieldType*)mpDoc->getIDocumentFieldsAccess().GetSysFldType( RES_HIDDENTXTFLD ))->
SetHiddenFlag( !mpOpt->IsShowHiddenField() );
// In Init a standard FrmFmt is created.
@@ -270,7 +271,7 @@ SwViewShell::SwViewShell( SwViewShell& rShell, Window *pWindow,
if ( mbPreview )
mpImp->InitPagePreviewLayout();
- ((SwHiddenTxtFieldType*)mpDoc->GetSysFldType( RES_HIDDENTXTFLD ))->
+ ((SwHiddenTxtFieldType*)mpDoc->getIDocumentFieldsAccess().GetSysFldType( RES_HIDDENTXTFLD ))->
SetHiddenFlag( !mpOpt->IsShowHiddenField() );
// In Init a standard FrmFmt is created.
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index 78c4ee1ce868..381707eef279 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -47,6 +47,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentDeviceAccess.hxx>
+#include <IDocumentFieldsAccess.hxx>
#include <wdocsh.hxx>
#include <fesh.hxx>
#include <pam.hxx>
@@ -323,7 +324,7 @@ SwDoc * SwViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt)
{
OSL_ENSURE( this->IsA( TYPE(SwFEShell) ),"SwViewShell::Prt for FEShell only");
SwFEShell* pFESh = (SwFEShell*)this;
- pPrtDoc->LockExpFlds();
+ pPrtDoc->getIDocumentFieldsAccess().LockExpFlds();
// use given printer
//! Make a copy of it since it gets destroyed with the temporary document