1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <IDocumentContentOperations.hxx>
23 #include <ndarr.hxx> //Only for lcl_RstTxtAttr
33 class DocumentContentOperationsManager final
: public IDocumentContentOperations
36 DocumentContentOperationsManager( SwDoc
& i_rSwdoc
);
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
,
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
,
113 const bool bCopyFlyAtFly
= false,
114 SwCopyFlags flags
= SwCopyFlags::Default
) const;
116 /// Parameters for _Rst and lcl_SetTextFormatColl
117 //originallyfrom docfmt.cxx
120 SwFormatColl
* pFormatColl
;
122 const SwPosition
*pSttNd
, *pEndNd
;
123 const SfxItemSet
* pDelSet
;
124 SwRootFrame
const*const pLayout
;
127 bool bResetListAttrs
; // #i62575#
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.
133 ParaRstFormat(const SwPosition
* pStt
, const SwPosition
* pEnd
,
134 SwHistory
* pHst
, const SfxItemSet
* pSet
= nullptr,
135 SwRootFrame
const*const pLay
= nullptr)
136 : pFormatColl(nullptr)
143 , bReset(false) // #i62675#
144 , bResetListAttrs(false)
146 , bInclRefToxMark(false)
151 static bool lcl_RstTextAttr( SwNode
* pNd
, void* pArgs
); //originally from docfmt.cxx
154 virtual ~DocumentContentOperationsManager() override
;
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
,
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: */