Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
21 : #define INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
22 :
23 : #include <sal/types.h>
24 : #include <rtl/ustring.hxx>
25 : #include "swtypes.hxx"
26 :
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;
41 :
42 : namespace utl { class TransliterationWrapper; }
43 : namespace svt { class EmbeddedObjectRef; }
44 :
45 : enum class SwMoveFlags
46 : {
47 : DEFAULT = 0x00,
48 : ALLFLYS = 0x01,
49 : CREATEUNDOOBJ = 0x02,
50 : REDLINES = 0x04,
51 : NO_DELFRMS = 0x08
52 : };
53 : namespace o3tl
54 : {
55 : template<> struct typed_flags<SwMoveFlags> : is_typed_flags<SwMoveFlags, 0x0f> {};
56 : }
57 :
58 : // constants for inserting text
59 : enum class SwInsertFlags
60 : {
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
65 : };
66 : namespace o3tl
67 : {
68 : template<> struct typed_flags<SwInsertFlags> : is_typed_flags<SwInsertFlags, 0x07> {};
69 : }
70 :
71 : /** Text operation/manipulation interface
72 : */
73 2958 : class IDocumentContentOperations
74 : {
75 : public:
76 : public:
77 : /** Copy a selected content range to a position
78 :
79 : The position can be in the same or in an another document. It can also
80 : be within the range!
81 :
82 : Normally this function should work only with content nodes. But there
83 : is a special case used by SwDoc::Paste, which starts the SwPaM at the
84 : content start node. This position doesn't contain any content:
85 :
86 : @code
87 : SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 1 );
88 : @endcode
89 :
90 : This is important, because it prevents merging of the first node of
91 : the range into the node pointed to by \p rPos.
92 : As a result this keeps all properties of the first real content node,
93 : which is the 2nd, including the Flys and the page description. In this
94 : case the first (fake) node is silently dropped and all other nodes are
95 : just copied.
96 :
97 : @param rPam
98 : The source node range to copy
99 :
100 : @param rPos
101 : The target copy destination
102 :
103 : @param bCheckPos
104 : If this function should check if rPos is in a fly frame anchored in
105 : rPam. If false, then no such check will be performed, and it is assumed
106 : that the caller took care of verifying this constraint already.
107 : */
108 : virtual bool CopyRange(SwPaM& rPam, SwPosition& rPos, const bool bCopyAll, bool bCheckPos ) const = 0;
109 :
110 : /** Delete section containing the node.
111 : */
112 : virtual void DeleteSection(SwNode* pNode) = 0;
113 :
114 : /** Delete a range SwFlyFrameFormat.
115 : */
116 : virtual bool DeleteRange(SwPaM&) = 0;
117 :
118 : /** Delete full paragraphs.
119 : */
120 : virtual bool DelFullPara(SwPaM&) = 0;
121 :
122 : /** complete delete of a given PaM
123 :
124 : #i100466#
125 : Add optional parameter <bForceJoinNext>, default value <false>
126 : Needed for hiding of deletion redlines
127 : */
128 : virtual bool DeleteAndJoin( SwPaM&,
129 : const bool bForceJoinNext = false ) = 0;
130 :
131 : virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) = 0;
132 :
133 : virtual bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags) = 0;
134 :
135 : /** Move a range.
136 : */
137 : virtual bool MoveAndJoin(SwPaM&, SwPosition&, SwMoveFlags) = 0;
138 :
139 : /** Overwrite string in an existing text node.
140 : */
141 : virtual bool Overwrite(const SwPaM &rRg, const OUString& rStr) = 0;
142 :
143 : /** Insert string into existing text node at position rRg.Point().
144 : */
145 : virtual bool InsertString(const SwPaM &rRg, const OUString&,
146 : const SwInsertFlags nInsertMode = SwInsertFlags::EMPTYEXPAND ) = 0;
147 :
148 : /** change text to Upper/Lower/Hiragana/Katagana/...
149 : */
150 : virtual void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) = 0;
151 :
152 : /** Insert graphic or formula. The XXXX are copied.
153 : */
154 : virtual SwFlyFrameFormat* Insert(const SwPaM &rRg, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic,
155 : const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrameFormat*) = 0;
156 :
157 : virtual SwFlyFrameFormat* Insert(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet,
158 : const SfxItemSet* pGrfAttrSet, SwFrameFormat*) = 0;
159 :
160 : /** Transpose graphic (with undo)
161 : */
162 : virtual void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic, const GraphicObject* pGrfObj) = 0;
163 :
164 : /** Insert a DrawObject. The object must be already registered
165 : in DrawModel.
166 : */
167 : virtual SwDrawFrameFormat* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) = 0;
168 :
169 : /** Insert OLE-objects.
170 : */
171 : virtual SwFlyFrameFormat* Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet,
172 : const SfxItemSet* pGrfAttrSet, SwFrameFormat*) = 0;
173 :
174 : virtual SwFlyFrameFormat* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
175 : const SfxItemSet* pGrfAttrSet, SwFrameFormat*) = 0;
176 :
177 : /** Split a node at rPos (implemented only for TextNode).
178 : */
179 : virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart) = 0;
180 :
181 : virtual bool AppendTextNode(SwPosition& rPos) = 0;
182 :
183 : /** Replace selected range in a TextNode with string.
184 : Intended for search & replace.
185 : bRegExpRplc - replace tabs (\\t) and insert the found string
186 : ( not \& ). E.g.: Find: "zzz", Replace: "xx\t\\t..&..\&"
187 : --> "xx\t<Tab>..zzz..&"
188 : */
189 : virtual bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
190 : const bool bRegExReplace) = 0;
191 :
192 : /** Insert an attribute. If rRg spans several nodes the
193 : attribute is split, provided it makes sense.
194 : Nodes, where this attribute does not make sense are ignored.
195 : In nodes completely enclosed in the selection the attribute
196 : becomes hard-formatted, in all other (text-) nodes the attribute
197 : is inserted into the attribute array.
198 : For a character attribute, in cases where no selection exists
199 : an "empty" hint is inserted. If there is a selection the attribute
200 : is hard-formatted and added to the node at rRg.Start().
201 : If the attribute could not be inserted, the method returns
202 : false.
203 : */
204 : virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
205 : const SetAttrMode nFlags = SetAttrMode::DEFAULT, bool bExpandCharToPara=false) = 0;
206 :
207 : virtual bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
208 : const SetAttrMode nFlags = SetAttrMode::DEFAULT) = 0;
209 :
210 : /** Removes any leading white space from the paragraph
211 : */
212 : virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ) = 0;
213 :
214 : protected:
215 2949 : virtual ~IDocumentContentOperations() {};
216 : };
217 :
218 : #endif // INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
219 :
220 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|