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 #include <DocumentStateManager.hxx> 20 #include <doc.hxx> 21 #include <DocumentStatisticsManager.hxx> 22 #include <IDocumentUndoRedo.hxx> 23 #include <DocumentLayoutManager.hxx> 24 #include <acorrect.hxx> 25 26 namespace sw 27 { 28 DocumentStateManager(SwDoc & i_rSwdoc)29DocumentStateManager::DocumentStateManager( SwDoc& i_rSwdoc ) : 30 m_rDoc( i_rSwdoc ), 31 mbEnableSetModified(true), 32 mbModified(false), 33 mbUpdateExpField(false), 34 mbNewDoc(false), 35 mbInCallModified(false) 36 { 37 } 38 SetModified()39void DocumentStateManager::SetModified() 40 { 41 if (!IsEnableSetModified()) 42 return; 43 44 m_rDoc.GetDocumentLayoutManager().ClearSwLayouterEntries(); 45 mbModified = true; 46 m_rDoc.GetDocumentStatisticsManager().SetDocStatModified( true ); 47 if( m_rDoc.GetOle2Link().IsSet() ) 48 { 49 mbInCallModified = true; 50 m_rDoc.GetOle2Link().Call( true ); 51 mbInCallModified = false; 52 } 53 54 if( m_rDoc.GetAutoCorrExceptWord() && !m_rDoc.GetAutoCorrExceptWord()->IsDeleted() ) 55 m_rDoc.DeleteAutoCorrExceptWord(); 56 } 57 ResetModified()58void DocumentStateManager::ResetModified() 59 { 60 // give the old and new modified state to the link 61 // Bit 0: -> old state 62 // Bit 1: -> new state 63 bool bOldModified = mbModified; 64 mbModified = false; 65 m_rDoc.GetDocumentStatisticsManager().SetDocStatModified( false ); 66 m_rDoc.GetIDocumentUndoRedo().SetUndoNoModifiedPosition(); 67 if( bOldModified && m_rDoc.GetOle2Link().IsSet() ) 68 { 69 mbInCallModified = true; 70 m_rDoc.GetOle2Link().Call( false ); 71 mbInCallModified = false; 72 } 73 } 74 IsModified() const75bool DocumentStateManager::IsModified() const 76 { 77 return mbModified; 78 } 79 IsEnableSetModified() const80bool DocumentStateManager::IsEnableSetModified() const 81 { 82 return mbEnableSetModified; 83 } 84 SetEnableSetModified(bool bEnableSetModified)85void DocumentStateManager::SetEnableSetModified(bool bEnableSetModified) 86 { 87 mbEnableSetModified = bEnableSetModified; 88 } 89 IsInCallModified() const90bool DocumentStateManager::IsInCallModified() const 91 { 92 return mbInCallModified; 93 } 94 IsUpdateExpField() const95bool DocumentStateManager::IsUpdateExpField() const 96 { 97 return mbUpdateExpField; 98 } 99 IsNewDoc() const100bool DocumentStateManager::IsNewDoc() const 101 { 102 return mbNewDoc; 103 } 104 SetNewDoc(bool b)105void DocumentStateManager::SetNewDoc(bool b) 106 { 107 mbNewDoc = b; 108 } 109 SetUpdateExpFieldStat(bool b)110void DocumentStateManager::SetUpdateExpFieldStat(bool b) 111 { 112 mbUpdateExpField = b; 113 } 114 115 } 116 117 118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 119
