tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sw / inc / IDocumentContentOperations.hxx
blobec63dca0bc2b585a93a041bea21443a7e4ac042e
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 <sal/types.h>
23 #include <rtl/ustring.hxx>
24 #include "swtypes.hxx"
26 class SwPaM;
27 struct SwPosition;
28 class SwNode;
29 class SwNodeRange;
30 class Graphic;
31 class SfxItemSet;
32 class SfxPoolItem;
33 class GraphicObject;
34 class SdrObject;
35 class SwFrameFormat;
36 class SwDrawFrameFormat;
37 class SwFlyFrameFormat;
38 class SwNodeIndex;
39 class SwRootFrame;
40 class SwTextAttr;
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 enum class SwCopyFlags
73 Default = 0,
74 CopyAll = (1<<0), ///< copy break attributes even when source is single node
75 CheckPosInFly = (1<<1), ///< check if target position is in fly anchored at source range
76 IsMoveToFly = (1<<2), ///< MakeFlyAndMove
77 // TODO: mbCopyIsMove? mbIsRedlineMove?
79 namespace o3tl
81 template<> struct typed_flags<SwCopyFlags> : is_typed_flags<SwCopyFlags, 0x07> {};
84 enum class SwDeleteFlags
86 Default = 0,
87 ArtificialSelection = (1<<0), ///< keyboard delete, artificial selection, avoid deleting flys
88 DontCompressRedlines = (1<<1) ///< don't call compress redlines while we are loading document
90 namespace o3tl
92 template<> struct typed_flags<SwDeleteFlags> : is_typed_flags<SwDeleteFlags, 0x03> {};
95 /** Text operation/manipulation interface
97 class IDocumentContentOperations
99 public:
100 public:
101 /** Copy a selected content range to a position
103 The position can be in the same or in an another document. It can also
104 be within the range!
106 \warning The range has to include at least two nodes or has to be a
107 SwDoc::IsColumnSelection, because the rPam is treated [mark, point[.
109 Normally this function should work only with content nodes. But there
110 is a special case used by SwDoc::Paste, which starts the SwPaM at the
111 content start node. This position doesn't contain any content:
113 @code
114 SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 );
115 @endcode
117 This is important, because it prevents merging of the first node of
118 the range into the node pointed to by \p rPos.
119 As a result this keeps all properties of the first real content node,
120 which is the 2nd, including the Flys and the page description. In this
121 case the first (fake) node is silently dropped and all other nodes are
122 just copied.
124 @param rPam
125 The source node range to copy
127 @param rPos
128 The target copy destination
130 @param flags
131 SwCopyFlags::CheckPos:
132 If this function should check if rPos is in a fly frame anchored in
133 rPam. If false, then no such check will be performed, and it is assumed
134 that the caller took care of verifying this constraint already.
136 virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, SwCopyFlags flags, sal_uInt32 nMovedID = 0) const = 0;
138 /** Delete section containing the node.
140 virtual void DeleteSection(SwNode* pNode) = 0;
142 /** Delete a range SwFlyFrameFormat.
144 virtual void DeleteRange(SwPaM&) = 0;
146 /** Delete full paragraphs.
148 virtual bool DelFullPara(SwPaM&) = 0;
150 /** complete delete of a given PaM
152 virtual bool DeleteAndJoin(SwPaM&, SwDeleteFlags flags = SwDeleteFlags::Default) = 0;
154 virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) = 0;
156 virtual bool MoveNodeRange(SwNodeRange&, SwNode&, SwMoveFlags) = 0;
158 /** Move a range.
160 virtual void MoveAndJoin(SwPaM&, SwPosition&) = 0;
162 /** Overwrite string in an existing text node.
164 virtual bool Overwrite(const SwPaM &rRg, const OUString& rStr) = 0;
166 /** Insert string into existing text node at position rRg.Point().
168 virtual bool InsertString(const SwPaM &rRg, const OUString&,
169 const SwInsertFlags nInsertMode = SwInsertFlags::EMPTYEXPAND ) = 0;
171 /// States that the last inserted string came from IME.
172 virtual void SetIME(bool bIME) = 0;
174 /// Did the last inserted string come from IME?
175 virtual bool GetIME() const = 0;
177 /** change text to Upper/Lower/Hiragana/Katakana/...
179 virtual void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) = 0;
181 /** Insert graphic or formula. The XXXX are copied.
183 virtual SwFlyFrameFormat* InsertGraphic(
184 const SwPaM &rRg, const OUString& rGrfName,
185 const OUString& rFltName, const Graphic* pGraphic,
186 const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet,
187 SwFrameFormat*) = 0;
189 /** Transpose graphic (with undo)
191 virtual void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic) = 0;
193 /** Insert a DrawObject. The object must be already registered
194 in DrawModel.
196 virtual SwDrawFrameFormat* InsertDrawObj(
197 const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet) = 0;
199 /** Insert OLE-objects.
201 virtual SwFlyFrameFormat* InsertEmbObject(
202 const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
203 SfxItemSet* pFlyAttrSet) = 0;
205 virtual SwFlyFrameFormat* InsertOLE(
206 const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect,
207 const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet) = 0;
209 /** Split a node at rPos (implemented only for TextNode).
211 virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart) = 0;
213 virtual bool AppendTextNode(SwPosition& rPos) = 0;
215 /** Replace selected range in a TextNode with string.
216 Intended for search & replace.
217 bRegExpRplc - replace tabs (\\t) and insert the found string
218 ( not \& ). E.g.: Find: "zzz", Replace: "xx\t\\t..&..\&"
219 --> "xx\t<Tab>..zzz..&"
221 virtual bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
222 const bool bRegExReplace) = 0;
224 /** Insert an attribute. If rRg spans several nodes the
225 attribute is split, provided it makes sense.
226 Nodes, where this attribute does not make sense are ignored.
227 In nodes completely enclosed in the selection the attribute
228 becomes hard-formatted, in all other (text-) nodes the attribute
229 is inserted into the attribute array.
230 For a character attribute, in cases where no selection exists
231 an "empty" hint is inserted. If there is a selection the attribute
232 is hard-formatted and added to the node at rRg.Start().
233 If the attribute could not be inserted, the method returns
234 false.
236 virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
237 const SetAttrMode nFlags = SetAttrMode::DEFAULT,
238 SwRootFrame const* pLayout = nullptr,
239 SwTextAttr **ppNewTextAttr = nullptr) = 0;
241 virtual void InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
242 const SetAttrMode nFlags = SetAttrMode::DEFAULT,
243 SwRootFrame const* pLayout = nullptr) = 0;
245 /** Removes any leading white space from the paragraph
247 virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ) = 0;
248 virtual void RemoveLeadingWhiteSpace(SwPaM& rPaM) = 0;
250 protected:
251 virtual ~IDocumentContentOperations() {};
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */