Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / DocumentContentOperationsManager.hxx
blob6d2d9a5fa6ea36ef46e501534216643cb790d175
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <IDocumentContentOperations.hxx>
23 #include <ndarr.hxx> //Only for lcl_RstTxtAttr
25 class SwDoc;
26 class SwNoTextNode;
27 class SwFormatColl;
28 class SwHistory;
30 namespace sw
33 class DocumentContentOperationsManager final : public IDocumentContentOperations
35 public:
36 DocumentContentOperationsManager( SwDoc& i_rSwdoc );
38 //Interface methods:
39 bool CopyRange(SwPaM&, SwPosition&, SwCopyFlags) const override;
41 void DeleteSection(SwNode* pNode) override;
43 void DeleteRange(SwPaM&) override;
45 bool DelFullPara(SwPaM&) override;
47 bool DeleteAndJoin(SwPaM&, SwDeleteFlags flags = SwDeleteFlags::Default) override;
49 bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) override;
51 bool MoveNodeRange(SwNodeRange&, SwNode&, SwMoveFlags) override;
53 void MoveAndJoin(SwPaM&, SwPosition&) override;
55 bool Overwrite(const SwPaM &rRg, const OUString& rStr) override;
57 bool InsertString(const SwPaM &rRg, const OUString&,
58 const SwInsertFlags nInsertMode = SwInsertFlags::EMPTYEXPAND ) override;
60 void SetIME(bool bIME) override;
62 bool GetIME() const override;
64 void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) override;
66 SwFlyFrameFormat* InsertGraphic(const SwPaM &rRg, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic,
67 const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrameFormat*) override;
69 void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic) override;
71 SwDrawFrameFormat* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) override;
73 SwFlyFrameFormat* InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, SfxItemSet* pFlyAttrSet) override;
75 SwFlyFrameFormat* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
76 const SfxItemSet* pGrfAttrSet) override;
78 bool SplitNode(const SwPosition &rPos, bool bChkTableStart) override;
80 bool AppendTextNode(SwPosition& rPos) override;
82 bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
83 const bool bRegExReplace) override;
85 // Add a para for the char attribute exp...
86 bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
87 const SetAttrMode nFlags = SetAttrMode::DEFAULT,
88 SwRootFrame const* pLayout = nullptr,
89 SwTextAttr **ppNewTextAttr = nullptr) override;
91 void InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
92 const SetAttrMode nFlags = SetAttrMode::DEFAULT,
93 SwRootFrame const* pLayout = nullptr) override;
95 void RemoveLeadingWhiteSpace(const SwPosition & rPos ) override;
96 void RemoveLeadingWhiteSpace(SwPaM& rPaM) override;
99 //Non-Interface methods
101 void DeleteDummyChar(SwPosition const& rPos, sal_Unicode cDummy);
103 void CopyWithFlyInFly( const SwNodeRange& rRg,
104 SwNode& rInsPos,
105 const std::pair<const SwPaM&, const SwPosition&> * pCopiedPaM = nullptr,
106 bool bMakeNewFrames = true,
107 bool bDelRedlines = true,
108 bool bCopyFlyAtFly = false,
109 SwCopyFlags flags = SwCopyFlags::Default) const;
110 void CopyFlyInFlyImpl( const SwNodeRange& rRg,
111 SwPaM const*const pCopiedPaM,
112 SwNode& rStartIdx,
113 const bool bCopyFlyAtFly = false,
114 SwCopyFlags flags = SwCopyFlags::Default) const;
116 /// Parameters for _Rst and lcl_SetTextFormatColl
117 //originallyfrom docfmt.cxx
118 struct ParaRstFormat
120 SwFormatColl* pFormatColl;
121 SwHistory* pHistory;
122 const SwPosition *pSttNd, *pEndNd;
123 const SfxItemSet* pDelSet;
124 SwRootFrame const*const pLayout;
125 sal_uInt16 nWhich;
126 bool bReset;
127 bool bResetListAttrs; // #i62575#
128 bool bResetAll;
129 bool bInclRefToxMark;
130 /// From the attributes included in the range, delete only the ones which have exactly same range. Don't delete the ones which are simply included in the range.
131 bool bExactRange;
133 ParaRstFormat(const SwPosition* pStt, const SwPosition* pEnd,
134 SwHistory* pHst, const SfxItemSet* pSet = nullptr,
135 SwRootFrame const*const pLay = nullptr)
136 : pFormatColl(nullptr)
137 , pHistory(pHst)
138 , pSttNd(pStt)
139 , pEndNd(pEnd)
140 , pDelSet(pSet)
141 , pLayout(pLay)
142 , nWhich(0)
143 , bReset(false) // #i62675#
144 , bResetListAttrs(false)
145 , bResetAll(true)
146 , bInclRefToxMark(false)
147 , bExactRange(false)
151 static bool lcl_RstTextAttr( SwNode* pNd, void* pArgs ); //originally from docfmt.cxx
154 virtual ~DocumentContentOperationsManager() override;
156 private:
157 SwDoc& m_rDoc;
159 bool m_bIME = false;
161 bool DeleteAndJoinImpl(SwPaM &, SwDeleteFlags);
162 bool DeleteAndJoinWithRedlineImpl(SwPaM &, SwDeleteFlags);
163 bool DeleteRangeImpl(SwPaM &, SwDeleteFlags);
164 bool DeleteRangeImplImpl(SwPaM &, SwDeleteFlags);
165 bool ReplaceRangeImpl(SwPaM&, OUString const&, const bool);
166 SwFlyFrameFormat* InsNoTextNode( const SwPosition&rPos, SwNoTextNode*,
167 const SfxItemSet* pFlyAttrSet,
168 const SfxItemSet* pGrfAttrSet,
169 SwFrameFormat* );
170 /* Copy a range within the same or to another document.
171 Position may not lie within range! */
172 bool CopyImpl( SwPaM&, SwPosition&,
173 SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const;
174 bool CopyImplImpl(SwPaM&, SwPosition&,
175 SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const;
177 DocumentContentOperationsManager(DocumentContentOperationsManager const&) = delete;
178 DocumentContentOperationsManager& operator=(DocumentContentOperationsManager const&) = delete;
182 void CopyBookmarks(const SwPaM& rPam, const SwPosition& rTarget,
183 SwCopyFlags flags = SwCopyFlags::Default);
185 void CalcBreaks(std::vector<std::pair<SwNodeOffset, sal_Int32>> & rBreaks,
186 SwPaM const & rPam, bool const isOnlyFieldmarks = false);
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */