1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
#define INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include "swtypes.hxx"
class SwPaM;
struct SwPosition;
class SwNode;
class SwNodeRange;
class Graphic;
class SfxItemSet;
class SfxPoolItem;
class GraphicObject;
class SdrObject;
class SwFrameFormat;
class SwDrawFrameFormat;
class SwFlyFrameFormat;
class SwNodeIndex;
class SwRootFrame;
class SwTextAttr;
namespace utl { class TransliterationWrapper; }
namespace svt { class EmbeddedObjectRef; }
enum class SwMoveFlags
{
DEFAULT = 0x00,
ALLFLYS = 0x01,
CREATEUNDOOBJ = 0x02,
REDLINES = 0x04,
NO_DELFRMS = 0x08
};
namespace o3tl
{
template<> struct typed_flags<SwMoveFlags> : is_typed_flags<SwMoveFlags, 0x0f> {};
}
// constants for inserting text
enum class SwInsertFlags
{
DEFAULT = 0x00, // no extras
EMPTYEXPAND = 0x01, // expand empty hints at insert position
NOHINTEXPAND = 0x02, // do not expand any hints at insert pos
FORCEHINTEXPAND = 0x04 // expand all hints at insert position
};
namespace o3tl
{
template<> struct typed_flags<SwInsertFlags> : is_typed_flags<SwInsertFlags, 0x07> {};
}
enum class SwCopyFlags
{
Default = 0,
CopyAll = (1<<0), ///< copy break attributes even when source is single node
CheckPosInFly = (1<<1), ///< check if target position is in fly anchored at source range
IsMoveToFly = (1<<2), ///< MakeFlyAndMove
// TODO: mbCopyIsMove? mbIsRedlineMove?
};
namespace o3tl
{
template<> struct typed_flags<SwCopyFlags> : is_typed_flags<SwCopyFlags, 0x07> {};
}
enum class SwDeleteFlags
{
Default = 0,
ArtificialSelection = (1<<0), ///< keyboard delete, artificial selection, avoid deleting flys
};
namespace o3tl
{
template<> struct typed_flags<SwDeleteFlags> : is_typed_flags<SwDeleteFlags, 0x01> {};
}
/** Text operation/manipulation interface
*/
class IDocumentContentOperations
{
public:
public:
/** Copy a selected content range to a position
The position can be in the same or in an another document. It can also
be within the range!
\warning The range has to include at least two nodes or has to be a
SwDoc::IsColumnSelection, because the rPam is treated [mark, point[.
Normally this function should work only with content nodes. But there
is a special case used by SwDoc::Paste, which starts the SwPaM at the
content start node. This position doesn't contain any content:
@code
SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 );
@endcode
This is important, because it prevents merging of the first node of
the range into the node pointed to by \p rPos.
As a result this keeps all properties of the first real content node,
which is the 2nd, including the Flys and the page description. In this
case the first (fake) node is silently dropped and all other nodes are
just copied.
@param rPam
The source node range to copy
@param rPos
The target copy destination
@param flags
SwCopyFlags::CheckPos:
If this function should check if rPos is in a fly frame anchored in
rPam. If false, then no such check will be performed, and it is assumed
that the caller took care of verifying this constraint already.
*/
virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, SwCopyFlags flags) const = 0;
/** Delete section containing the node.
*/
virtual void DeleteSection(SwNode* pNode) = 0;
/** Delete a range SwFlyFrameFormat.
*/
virtual void DeleteRange(SwPaM&) = 0;
/** Delete full paragraphs.
*/
virtual bool DelFullPara(SwPaM&) = 0;
/** complete delete of a given PaM
*/
virtual bool DeleteAndJoin(SwPaM&, SwDeleteFlags flags = SwDeleteFlags::Default) = 0;
virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) = 0;
virtual bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags) = 0;
/** Move a range.
*/
virtual void MoveAndJoin(SwPaM&, SwPosition&) = 0;
/** Overwrite string in an existing text node.
*/
virtual bool Overwrite(const SwPaM &rRg, const OUString& rStr) = 0;
/** Insert string into existing text node at position rRg.Point().
*/
virtual bool InsertString(const SwPaM &rRg, const OUString&,
const SwInsertFlags nInsertMode = SwInsertFlags::EMPTYEXPAND ) = 0;
/// States that the last inserted string came from IME.
virtual void SetIME(bool bIME) = 0;
/// Did the last inserted string come from IME?
virtual bool GetIME() const = 0;
/** change text to Upper/Lower/Hiragana/Katakana/...
*/
virtual void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) = 0;
/** Insert graphic or formula. The XXXX are copied.
*/
virtual SwFlyFrameFormat* InsertGraphic(
const SwPaM &rRg, const OUString& rGrfName,
const OUString& rFltName, const Graphic* pGraphic,
const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet,
SwFrameFormat*) = 0;
virtual SwFlyFrameFormat* InsertGraphicObject(
const SwPaM& rRg, const GraphicObject& rGrfObj,
const SfxItemSet* pFlyAttrSet,
const SfxItemSet* pGrfAttrSet) = 0;
/** Transpose graphic (with undo)
*/
virtual void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic) = 0;
/** Insert a DrawObject. The object must be already registered
in DrawModel.
*/
virtual SwDrawFrameFormat* InsertDrawObj(
const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet) = 0;
/** Insert OLE-objects.
*/
virtual SwFlyFrameFormat* InsertEmbObject(
const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
SfxItemSet* pFlyAttrSet) = 0;
virtual SwFlyFrameFormat* InsertOLE(
const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect,
const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet) = 0;
/** Split a node at rPos (implemented only for TextNode).
*/
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart) = 0;
virtual bool AppendTextNode(SwPosition& rPos) = 0;
/** Replace selected range in a TextNode with string.
Intended for search & replace.
bRegExpRplc - replace tabs (\\t) and insert the found string
( not \& ). E.g.: Find: "zzz", Replace: "xx\t\\t..&..\&"
--> "xx\t<Tab>..zzz..&"
*/
virtual bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
const bool bRegExReplace) = 0;
/** Insert an attribute. If rRg spans several nodes the
attribute is split, provided it makes sense.
Nodes, where this attribute does not make sense are ignored.
In nodes completely enclosed in the selection the attribute
becomes hard-formatted, in all other (text-) nodes the attribute
is inserted into the attribute array.
For a character attribute, in cases where no selection exists
an "empty" hint is inserted. If there is a selection the attribute
is hard-formatted and added to the node at rRg.Start().
If the attribute could not be inserted, the method returns
false.
*/
virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
const SetAttrMode nFlags = SetAttrMode::DEFAULT,
SwRootFrame const* pLayout = nullptr,
SwTextAttr **ppNewTextAttr = nullptr) = 0;
virtual void InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
const SetAttrMode nFlags = SetAttrMode::DEFAULT,
SwRootFrame const* pLayout = nullptr) = 0;
/** Removes any leading white space from the paragraph
*/
virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ) = 0;
protected:
virtual ~IDocumentContentOperations() {};
};
#endif // INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|