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 .
20 #ifndef INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
21 #define INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
23 #include <sal/types.h>
24 #include <rtl/ustring.hxx>
25 #include "swtypes.hxx"
37 class SwDrawFrameFormat
;
38 class SwFlyFrameFormat
;
43 namespace utl
{ class TransliterationWrapper
; }
44 namespace svt
{ class EmbeddedObjectRef
; }
46 enum class SwMoveFlags
56 template<> struct typed_flags
<SwMoveFlags
> : is_typed_flags
<SwMoveFlags
, 0x0f> {};
59 // constants for inserting text
60 enum class SwInsertFlags
62 DEFAULT
= 0x00, // no extras
63 EMPTYEXPAND
= 0x01, // expand empty hints at insert position
64 NOHINTEXPAND
= 0x02, // do not expand any hints at insert pos
65 FORCEHINTEXPAND
= 0x04 // expand all hints at insert position
69 template<> struct typed_flags
<SwInsertFlags
> : is_typed_flags
<SwInsertFlags
, 0x07> {};
72 enum class SwDeleteFlags
75 ArtificialSelection
= (1<<0), ///< keyboard delete, artificial selection, avoid deleting flys
79 template<> struct typed_flags
<SwDeleteFlags
> : is_typed_flags
<SwDeleteFlags
, 0x01> {};
82 /** Text operation/manipulation interface
84 class IDocumentContentOperations
88 /** Copy a selected content range to a position
90 The position can be in the same or in an another document. It can also
93 \warning The range has to include at least two nodes or has to be a
94 SwDoc::IsColumnSelection, because the rPam is treated [mark, point[.
96 Normally this function should work only with content nodes. But there
97 is a special case used by SwDoc::Paste, which starts the SwPaM at the
98 content start node. This position doesn't contain any content:
101 SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 );
104 This is important, because it prevents merging of the first node of
105 the range into the node pointed to by \p rPos.
106 As a result this keeps all properties of the first real content node,
107 which is the 2nd, including the Flys and the page description. In this
108 case the first (fake) node is silently dropped and all other nodes are
112 The source node range to copy
115 The target copy destination
118 If this function should check if rPos is in a fly frame anchored in
119 rPam. If false, then no such check will be performed, and it is assumed
120 that the caller took care of verifying this constraint already.
122 virtual bool CopyRange(SwPaM
& rPam
, SwPosition
& rPos
, const bool bCopyAll
, bool bCheckPos
, bool bCopyText
) const = 0;
124 /** Delete section containing the node.
126 virtual void DeleteSection(SwNode
* pNode
) = 0;
128 /** Delete a range SwFlyFrameFormat.
130 virtual void DeleteRange(SwPaM
&) = 0;
132 /** Delete full paragraphs.
134 virtual bool DelFullPara(SwPaM
&) = 0;
136 /** complete delete of a given PaM
139 Add optional parameter <bForceJoinNext>, default value <false>
140 Needed for hiding of deletion redlines
142 virtual bool DeleteAndJoin( SwPaM
&,
143 SwDeleteFlags flags
= SwDeleteFlags::Default
,
144 const bool bForceJoinNext
= false ) = 0;
146 virtual bool MoveRange(SwPaM
&, SwPosition
&, SwMoveFlags
) = 0;
148 virtual bool MoveNodeRange(SwNodeRange
&, SwNodeIndex
&, SwMoveFlags
) = 0;
152 virtual bool MoveAndJoin(SwPaM
&, SwPosition
&) = 0;
154 /** Overwrite string in an existing text node.
156 virtual bool Overwrite(const SwPaM
&rRg
, const OUString
& rStr
) = 0;
158 /** Insert string into existing text node at position rRg.Point().
160 virtual bool InsertString(const SwPaM
&rRg
, const OUString
&,
161 const SwInsertFlags nInsertMode
= SwInsertFlags::EMPTYEXPAND
) = 0;
163 /** change text to Upper/Lower/Hiragana/Katakana/...
165 virtual void TransliterateText(const SwPaM
& rPaM
, utl::TransliterationWrapper
&) = 0;
167 /** Insert graphic or formula. The XXXX are copied.
169 virtual SwFlyFrameFormat
* InsertGraphic(
170 const SwPaM
&rRg
, const OUString
& rGrfName
,
171 const OUString
& rFltName
, const Graphic
* pGraphic
,
172 const SfxItemSet
* pFlyAttrSet
, const SfxItemSet
* pGrfAttrSet
,
175 virtual SwFlyFrameFormat
* InsertGraphicObject(
176 const SwPaM
& rRg
, const GraphicObject
& rGrfObj
,
177 const SfxItemSet
* pFlyAttrSet
,
178 const SfxItemSet
* pGrfAttrSet
) = 0;
180 /** Transpose graphic (with undo)
182 virtual void ReRead(SwPaM
&, const OUString
& rGrfName
, const OUString
& rFltName
, const Graphic
* pGraphic
) = 0;
184 /** Insert a DrawObject. The object must be already registered
187 virtual SwDrawFrameFormat
* InsertDrawObj(
188 const SwPaM
&rRg
, SdrObject
& rDrawObj
, const SfxItemSet
& rFlyAttrSet
) = 0;
190 /** Insert OLE-objects.
192 virtual SwFlyFrameFormat
* InsertEmbObject(
193 const SwPaM
&rRg
, const svt::EmbeddedObjectRef
& xObj
,
194 SfxItemSet
* pFlyAttrSet
) = 0;
196 virtual SwFlyFrameFormat
* InsertOLE(
197 const SwPaM
&rRg
, const OUString
& rObjName
, sal_Int64 nAspect
,
198 const SfxItemSet
* pFlyAttrSet
, const SfxItemSet
* pGrfAttrSet
) = 0;
200 /** Split a node at rPos (implemented only for TextNode).
202 virtual bool SplitNode(const SwPosition
&rPos
, bool bChkTableStart
) = 0;
204 virtual bool AppendTextNode(SwPosition
& rPos
) = 0;
206 /** Replace selected range in a TextNode with string.
207 Intended for search & replace.
208 bRegExpRplc - replace tabs (\\t) and insert the found string
209 ( not \& ). E.g.: Find: "zzz", Replace: "xx\t\\t..&..\&"
210 --> "xx\t<Tab>..zzz..&"
212 virtual bool ReplaceRange(SwPaM
& rPam
, const OUString
& rNewStr
,
213 const bool bRegExReplace
) = 0;
215 /** Insert an attribute. If rRg spans several nodes the
216 attribute is split, provided it makes sense.
217 Nodes, where this attribute does not make sense are ignored.
218 In nodes completely enclosed in the selection the attribute
219 becomes hard-formatted, in all other (text-) nodes the attribute
220 is inserted into the attribute array.
221 For a character attribute, in cases where no selection exists
222 an "empty" hint is inserted. If there is a selection the attribute
223 is hard-formatted and added to the node at rRg.Start().
224 If the attribute could not be inserted, the method returns
227 virtual bool InsertPoolItem(const SwPaM
&rRg
, const SfxPoolItem
&,
228 const SetAttrMode nFlags
= SetAttrMode::DEFAULT
,
229 SwRootFrame
const* pLayout
= nullptr,
230 bool bExpandCharToPara
= false,
231 SwTextAttr
**ppNewTextAttr
= nullptr) = 0;
233 virtual void InsertItemSet (const SwPaM
&rRg
, const SfxItemSet
&,
234 const SetAttrMode nFlags
= SetAttrMode::DEFAULT
,
235 SwRootFrame
const* pLayout
= nullptr) = 0;
237 /** Removes any leading white space from the paragraph
239 virtual void RemoveLeadingWhiteSpace(const SwPosition
& rPos
) = 0;
242 virtual ~IDocumentContentOperations() {};
245 #endif // INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */