Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sw / inc / IDocumentContentOperations.hxx
blobc0becb223b1aa520d9d7b1460f23efbc78a113b9
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 #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"
27 class SwPaM;
28 struct SwPosition;
29 class SwNode;
30 class SwNodeRange;
31 class Graphic;
32 class SfxItemSet;
33 class SfxPoolItem;
34 class GraphicObject;
35 class SdrObject;
36 class SwFrameFormat;
37 class SwDrawFrameFormat;
38 class SwFlyFrameFormat;
39 class SwNodeIndex;
40 class SwFormatField;
42 namespace utl { class TransliterationWrapper; }
43 namespace svt { class EmbeddedObjectRef; }
45 enum class SwMoveFlags
47 DEFAULT = 0x00,
48 ALLFLYS = 0x01,
49 CREATEUNDOOBJ = 0x02,
50 REDLINES = 0x04,
51 NO_DELFRMS = 0x08
53 namespace o3tl
55 template<> struct typed_flags<SwMoveFlags> : is_typed_flags<SwMoveFlags, 0x0f> {};
58 // constants for inserting text
59 enum class SwInsertFlags
61 DEFAULT = 0x00, // no extras
62 EMPTYEXPAND = 0x01, // expand empty hints at insert position
63 NOHINTEXPAND = 0x02, // do not expand any hints at insert pos
64 FORCEHINTEXPAND = 0x04 // expand all hints at insert position
66 namespace o3tl
68 template<> struct typed_flags<SwInsertFlags> : is_typed_flags<SwInsertFlags, 0x07> {};
71 /** Text operation/manipulation interface
73 class IDocumentContentOperations
75 public:
76 public:
77 /** Copy a selected content range to a position
79 The position can be in the same or in an another document. It can also
80 be within the range!
82 \warning The range has to include at least two nodes or has to be a
83 SwDoc::IsColumnSelection, because the rPam is treated [mark, point[.
85 Normally this function should work only with content nodes. But there
86 is a special case used by SwDoc::Paste, which starts the SwPaM at the
87 content start node. This position doesn't contain any content:
89 @code
90 SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 );
91 @endcode
93 This is important, because it prevents merging of the first node of
94 the range into the node pointed to by \p rPos.
95 As a result this keeps all properties of the first real content node,
96 which is the 2nd, including the Flys and the page description. In this
97 case the first (fake) node is silently dropped and all other nodes are
98 just copied.
100 @param rPam
101 The source node range to copy
103 @param rPos
104 The target copy destination
106 @param bCheckPos
107 If this function should check if rPos is in a fly frame anchored in
108 rPam. If false, then no such check will be performed, and it is assumed
109 that the caller took care of verifying this constraint already.
111 virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, const bool bCopyAll, bool bCheckPos ) const = 0;
113 /** Delete section containing the node.
115 virtual void DeleteSection(SwNode* pNode) = 0;
117 /** Delete a range SwFlyFrameFormat.
119 virtual bool DeleteRange(SwPaM&) = 0;
121 /** Delete full paragraphs.
123 virtual bool DelFullPara(SwPaM&) = 0;
125 /** complete delete of a given PaM
127 #i100466#
128 Add optional parameter <bForceJoinNext>, default value <false>
129 Needed for hiding of deletion redlines
131 virtual bool DeleteAndJoin( SwPaM&,
132 const bool bForceJoinNext = false ) = 0;
134 virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) = 0;
136 virtual bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags) = 0;
138 /** Move a range.
140 virtual bool MoveAndJoin(SwPaM&, SwPosition&) = 0;
142 /** Overwrite string in an existing text node.
144 virtual bool Overwrite(const SwPaM &rRg, const OUString& rStr) = 0;
146 /** Insert string into existing text node at position rRg.Point().
148 virtual bool InsertString(const SwPaM &rRg, const OUString&,
149 const SwInsertFlags nInsertMode = SwInsertFlags::EMPTYEXPAND ) = 0;
151 /** change text to Upper/Lower/Hiragana/Katagana/...
153 virtual void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) = 0;
155 /** Insert graphic or formula. The XXXX are copied.
157 virtual SwFlyFrameFormat* InsertGraphic(
158 const SwPaM &rRg, const OUString& rGrfName,
159 const OUString& rFltName, const Graphic* pGraphic,
160 const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet,
161 SwFrameFormat*) = 0;
163 virtual SwFlyFrameFormat* InsertGraphicObject(
164 const SwPaM& rRg, const GraphicObject& rGrfObj,
165 const SfxItemSet* pFlyAttrSet,
166 const SfxItemSet* pGrfAttrSet, SwFrameFormat*) = 0;
168 /** Transpose graphic (with undo)
170 virtual void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic, const GraphicObject* pGrfObj) = 0;
172 /** Insert a DrawObject. The object must be already registered
173 in DrawModel.
175 virtual SwDrawFrameFormat* InsertDrawObj(
176 const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet) = 0;
178 /** Insert OLE-objects.
180 virtual SwFlyFrameFormat* InsertEmbObject(
181 const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
182 const SfxItemSet* pFlyAttrSet) = 0;
184 virtual SwFlyFrameFormat* InsertOLE(
185 const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect,
186 const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet) = 0;
188 /** Split a node at rPos (implemented only for TextNode).
190 virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart) = 0;
192 virtual bool AppendTextNode(SwPosition& rPos) = 0;
194 /** Replace selected range in a TextNode with string.
195 Intended for search & replace.
196 bRegExpRplc - replace tabs (\\t) and insert the found string
197 ( not \& ). E.g.: Find: "zzz", Replace: "xx\t\\t..&..\&"
198 --> "xx\t<Tab>..zzz..&"
200 virtual bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
201 const bool bRegExReplace) = 0;
203 /** Insert an attribute. If rRg spans several nodes the
204 attribute is split, provided it makes sense.
205 Nodes, where this attribute does not make sense are ignored.
206 In nodes completely enclosed in the selection the attribute
207 becomes hard-formatted, in all other (text-) nodes the attribute
208 is inserted into the attribute array.
209 For a character attribute, in cases where no selection exists
210 an "empty" hint is inserted. If there is a selection the attribute
211 is hard-formatted and added to the node at rRg.Start().
212 If the attribute could not be inserted, the method returns
213 false.
215 virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
216 const SetAttrMode nFlags = SetAttrMode::DEFAULT, bool bExpandCharToPara=false) = 0;
218 virtual bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
219 const SetAttrMode nFlags = SetAttrMode::DEFAULT) = 0;
221 /** Removes any leading white space from the paragraph
223 virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ) = 0;
225 protected:
226 virtual ~IDocumentContentOperations() {};
229 #endif // INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */