Add a comment to clarify what kind of inputs the class handles
[LibreOffice.git] / sw / source / core / inc / DocumentContentOperationsManager.hxx
blob2aa4dd299310892ff6b66d2756281aae88709272
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, sal_uInt32 nMovedID = 0) 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,
115 bool bMakeNewFrames = true) const;
117 /// Parameters for _Rst and lcl_SetTextFormatColl
118 //originallyfrom docfmt.cxx
119 struct ParaRstFormat
121 SwTextFormatColl* pFormatColl;
122 SwHistory* pHistory;
123 const SwPosition *pSttNd, *pEndNd;
124 const SfxItemSet* pDelSet;
125 SwRootFrame const*const pLayout;
126 sal_uInt16 nWhich;
127 bool bReset;
128 bool bResetListAttrs; // #i62575#
129 bool bResetAll;
130 bool bResetAllCharAttrs;
131 bool bInclRefToxMark;
132 /// 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.
133 bool bExactRange;
135 ParaRstFormat(const SwPosition* pStart, const SwPosition* pEnd,
136 SwHistory* pHst, const SfxItemSet* pSet = nullptr,
137 SwRootFrame const*const pLay = nullptr)
138 : pFormatColl(nullptr)
139 , pHistory(pHst)
140 , pSttNd(pStart)
141 , pEndNd(pEnd)
142 , pDelSet(pSet)
143 , pLayout(pLay)
144 , nWhich(0)
145 , bReset(false) // #i62675#
146 , bResetListAttrs(false)
147 , bResetAll(true)
148 , bResetAllCharAttrs(false)
149 , bInclRefToxMark(false)
150 , bExactRange(false)
154 static bool lcl_RstTextAttr( SwNode* pNd, void* pArgs ); //originally from docfmt.cxx
155 static std::shared_ptr<SfxItemSet> lcl_createDelSet(SwDoc& rDoc);
157 virtual ~DocumentContentOperationsManager() override;
159 private:
160 SwDoc& m_rDoc;
162 bool m_bIME = false;
164 bool DeleteAndJoinImpl(SwPaM &, SwDeleteFlags);
165 bool DeleteAndJoinWithRedlineImpl(SwPaM &, SwDeleteFlags);
166 bool DeleteRangeImpl(SwPaM &, SwDeleteFlags);
167 bool DeleteRangeImplImpl(SwPaM &, SwDeleteFlags);
168 bool ReplaceRangeImpl(SwPaM&, OUString const&, const bool);
169 SwFlyFrameFormat* InsNoTextNode( const SwPosition&rPos, SwNoTextNode*,
170 const SfxItemSet* pFlyAttrSet,
171 const SfxItemSet* pGrfAttrSet,
172 SwFrameFormat* );
173 /* Copy a range within the same or to another document.
174 Position may not lie within range! */
175 bool CopyImpl( SwPaM&, SwPosition&,
176 SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const;
177 bool CopyImplImpl(SwPaM&, SwPosition&,
178 SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const;
180 DocumentContentOperationsManager(DocumentContentOperationsManager const&) = delete;
181 DocumentContentOperationsManager& operator=(DocumentContentOperationsManager const&) = delete;
185 void CopyBookmarks(const SwPaM& rPam, const SwPosition& rTarget,
186 SwCopyFlags flags = SwCopyFlags::Default);
188 void CalcBreaks(std::vector<std::pair<SwNodeOffset, sal_Int32>> & rBreaks,
189 SwPaM const & rPam, bool const isOnlyFieldmarks = false);
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */