1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTFIELDSMANAGER_HXX 20 #define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTFIELDSMANAGER_HXX 21 22 #include <IDocumentFieldsAccess.hxx> 23 #include <sal/types.h> 24 #include <memory> 25 26 class SwDoc; 27 class SwDBNameInfField; 28 29 namespace sw { 30 31 class DocumentFieldsManager final : public IDocumentFieldsAccess 32 { 33 34 public: 35 36 DocumentFieldsManager( SwDoc& i_rSwdoc ); 37 38 virtual const SwFieldTypes *GetFieldTypes() const override; 39 virtual SwFieldType *InsertFieldType(const SwFieldType &) override; 40 virtual SwFieldType *GetSysFieldType( const SwFieldIds eWhich ) const override; 41 virtual SwFieldType* GetFieldType(SwFieldIds nResId, const OUString& rName, bool bDbFieldMatching) const override; 42 virtual void RemoveFieldType(size_t nField) override; 43 virtual void UpdateFields(bool bCloseDB) override; 44 virtual void InsDeletedFieldType(SwFieldType &) override; 45 virtual void PutValueToField(const SwPosition & rPos, const css::uno::Any& rVal, sal_uInt16 nWhich) override; 46 virtual bool UpdateField(SwTextField * rDstFormatField, SwField & rSrcField, SwMsgPoolItem * pMsgHint, bool bUpdateTableFields) override; 47 virtual void UpdateRefFields() override; 48 virtual void UpdateTableFields(SfxPoolItem* pHt) override; 49 virtual void UpdateExpFields(SwTextField* pField, bool bUpdateRefFields) override; 50 virtual void UpdateUsrFields() override; 51 virtual void UpdatePageFields(SfxPoolItem*) override; 52 virtual void LockExpFields() override; 53 virtual void UnlockExpFields() override; 54 virtual bool IsExpFieldsLocked() const override; 55 virtual SwDocUpdateField& GetUpdateFields() const override; 56 virtual bool SetFieldsDirty(bool b, const SwNode* pChk, sal_uLong nLen) override; 57 virtual void SetFixFields(const DateTime* pNewDateTime) override; 58 virtual void FieldsToCalc(SwCalc& rCalc, sal_uLong nLastNd, sal_Int32 nLastCnt) override; 59 virtual void FieldsToCalc(SwCalc& rCalc, const SetGetExpField& rToThisField, SwRootFrame const* pLayout) override; 60 virtual void FieldsToExpand(SwHashTable<HashStr>& rTable, const SetGetExpField& rToThisField, SwRootFrame const& rLayout) override; 61 virtual bool IsNewFieldLst() const override; 62 virtual void SetNewFieldLst( bool bFlag) override; 63 virtual void InsDelFieldInFieldLst(bool bIns, const SwTextField& rField) override; 64 virtual sal_Int32 GetRecordsPerDocument() const override; 65 66 //Non Interface methods 67 68 /** Returns the field at a certain position. 69 @param rPos position to search at 70 @return pointer to field at the given position or NULL in case no field is found 71 */ 72 static SwField* GetFieldAtPos(const SwPosition& rPos); 73 74 /** Returns the field at a certain position. 75 @param rPos position to search at 76 @return pointer to field at the given position or NULL in case no field is found 77 */ 78 static SwTextField* GetTextFieldAtPos(const SwPosition& rPos); 79 80 bool containsUpdatableFields(); 81 82 // Delete all unreferenced field types. 83 void GCFieldTypes(); 84 85 void InitFieldTypes(); 86 87 void ClearFieldTypes(); 88 89 void UpdateDBNumFields( SwDBNameInfField& rDBField, SwCalc& rCalc ); 90 91 virtual ~DocumentFieldsManager() override; 92 93 private: 94 95 DocumentFieldsManager(DocumentFieldsManager const&) = delete; 96 DocumentFieldsManager& operator=(DocumentFieldsManager const&) = delete; 97 98 void UpdateExpFieldsImpl(SwTextField* pField, SwRootFrame const* pLayout); 99 100 SwDoc& m_rDoc; 101 102 bool mbNewFieldLst; //< TRUE: Rebuild field-list. 103 std::unique_ptr<SwDocUpdateField> mpUpdateFields; //< Struct for updating fields 104 std::unique_ptr<SwFieldTypes> mpFieldTypes; 105 sal_Int8 mnLockExpField; //< If != 0 UpdateExpFields() has no effect! 106 }; 107 108 } 109 #endif 110 111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 112