LibreOffice Module sw (master)  1
DocumentContentOperationsManager.hxx
Go to the documentation of this file.
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 #pragma once
21 
23 #include <ndarr.hxx> //Only for lcl_RstTxtAttr
24 
25 class SwDoc;
26 class SwNoTextNode;
27 class SwFormatColl;
28 class SwHistory;
29 
30 namespace sw
31 {
32 
34 {
35 public:
37 
38  //Interface methods:
39  bool CopyRange(SwPaM&, SwPosition&, SwCopyFlags) const override;
40 
41  void DeleteSection(SwNode* pNode) override;
42 
43  void DeleteRange(SwPaM&) override;
44 
45  bool DelFullPara(SwPaM&) override;
46 
47  // Add optional parameter <bForceJoinNext>, default value <false>
48  // Needed for hiding of deletion redlines
49  bool DeleteAndJoin( SwPaM&,
50  const bool bForceJoinNext = false ) override;
51 
52  bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) override;
53 
55 
56  void MoveAndJoin(SwPaM&, SwPosition&) override;
57 
58  bool Overwrite(const SwPaM &rRg, const OUString& rStr) override;
59 
60  bool InsertString(const SwPaM &rRg, const OUString&,
61  const SwInsertFlags nInsertMode = SwInsertFlags::EMPTYEXPAND ) override;
62 
63  void SetIME(bool bIME) override;
64 
65  bool GetIME() const override;
66 
67  void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) override;
68 
69  SwFlyFrameFormat* InsertGraphic(const SwPaM &rRg, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic,
70  const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrameFormat*) override;
71 
72  SwFlyFrameFormat* InsertGraphicObject(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet,
73  const SfxItemSet* pGrfAttrSet) override;
74 
75  void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic) override;
76 
77  SwDrawFrameFormat* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) override;
78 
79  SwFlyFrameFormat* InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, SfxItemSet* pFlyAttrSet) override;
80 
81  SwFlyFrameFormat* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
82  const SfxItemSet* pGrfAttrSet) override;
83 
84  bool SplitNode(const SwPosition &rPos, bool bChkTableStart) override;
85 
86  bool AppendTextNode(SwPosition& rPos) override;
87 
88  bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
89  const bool bRegExReplace) override;
90 
91  // Add a para for the char attribute exp...
92  bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
93  const SetAttrMode nFlags = SetAttrMode::DEFAULT,
94  SwRootFrame const* pLayout = nullptr,
95  SwTextAttr **ppNewTextAttr = nullptr) override;
96 
97  void InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
98  const SetAttrMode nFlags = SetAttrMode::DEFAULT,
99  SwRootFrame const* pLayout = nullptr) override;
100 
101  void RemoveLeadingWhiteSpace(const SwPosition & rPos ) override;
102 
103 
104  //Non-Interface methods
105 
106  void DeleteDummyChar(SwPosition const& rPos, sal_Unicode cDummy);
107 
108  void CopyWithFlyInFly( const SwNodeRange& rRg,
109  const SwNodeIndex& rInsPos,
110  const std::pair<const SwPaM&, const SwPosition&> * pCopiedPaM = nullptr,
111  bool bMakeNewFrames = true,
112  bool bDelRedlines = true,
113  bool bCopyFlyAtFly = false,
114  SwCopyFlags flags = SwCopyFlags::Default) const;
115  void CopyFlyInFlyImpl( const SwNodeRange& rRg,
116  SwPaM const*const pCopiedPaM,
117  const SwNodeIndex& rStartIdx,
118  const bool bCopyFlyAtFly = false,
119  SwCopyFlags flags = SwCopyFlags::Default) const;
120 
122  //originallyfrom docfmt.cxx
124  {
129  SwRootFrame const*const pLayout;
130  sal_uInt16 nWhich;
131  bool bReset;
132  bool bResetListAttrs; // #i62575#
133  bool bResetAll;
137 
138  ParaRstFormat(const SwPosition* pStt, const SwPosition* pEnd,
139  SwHistory* pHst, const SfxItemSet* pSet = nullptr,
140  SwRootFrame const*const pLay = nullptr)
141  : pFormatColl(nullptr)
142  , pHistory(pHst)
143  , pSttNd(pStt)
144  , pEndNd(pEnd)
145  , pDelSet(pSet)
146  , pLayout(pLay)
147  , nWhich(0)
148  , bReset(false) // #i62675#
149  , bResetListAttrs(false)
150  , bResetAll(true)
151  , bInclRefToxMark(false)
152  , bExactRange(false)
153  {
154  }
155  };
156  static bool lcl_RstTextAttr( SwNode* pNd, void* pArgs ); //originally from docfmt.cxx
157 
158 
159  virtual ~DocumentContentOperationsManager() override;
160 
161 private:
163 
164  bool m_bIME = false;
165 
166  bool DeleteAndJoinImpl(SwPaM&, const bool);
167  bool DeleteAndJoinWithRedlineImpl(SwPaM&, const bool unused = false);
168  bool DeleteRangeImpl(SwPaM&, const bool unused = false);
169  bool DeleteRangeImplImpl(SwPaM &);
170  bool ReplaceRangeImpl(SwPaM&, OUString const&, const bool);
172  const SfxItemSet* pFlyAttrSet,
173  const SfxItemSet* pGrfAttrSet,
174  SwFrameFormat* );
175  /* Copy a range within the same or to another document.
176  Position may not lie within range! */
177  bool CopyImpl( SwPaM&, SwPosition&,
178  SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const;
179  bool CopyImplImpl(SwPaM&, SwPosition&,
180  SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const;
181 
184 };
185 
186 
187 void CopyBookmarks(const SwPaM& rPam, const SwPosition& rTarget);
188 
189 void CalcBreaks(std::vector<std::pair<SwNodeOffset, sal_Int32>> & rBreaks,
190  SwPaM const & rPam, bool const isOnlyFieldmarks = false);
191 
192 }
193 
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwDrawFrameFormat * InsertDrawObj(const SwPaM &rRg, SdrObject &rDrawObj, const SfxItemSet &rFlyAttrSet) override
Insert a DrawObject.
void TransliterateText(const SwPaM &rPaM, utl::TransliterationWrapper &) override
change text to Upper/Lower/Hiragana/Katakana/...
DocumentContentOperationsManager & operator=(DocumentContentOperationsManager const &)=delete
Marks a position in the document model.
Definition: pam.hxx:36
bool MoveRange(SwPaM &, SwPosition &, SwMoveFlags) override
SwFlyFrameFormat * InsertOLE(const SwPaM &rRg, const OUString &rObjName, sal_Int64 nAspect, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet) override
bool GetIME() const override
Did the last inserted string come from IME?
bool CopyImpl(SwPaM &, SwPosition &, SwCopyFlags flags, SwPaM *const pCpyRng) const
Definition: doc.hxx:188
SwFlyFrameFormat * InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef &xObj, SfxItemSet *pFlyAttrSet) override
Insert OLE-objects.
static bool lcl_RstTextAttr(SwNode *pNd, void *pArgs)
pArgs contains the document's ChrFormatTable Is need for selections at the beginning/end and with no ...
bool DeleteAndJoinWithRedlineImpl(SwPaM &, const bool unused=false)
void CopyBookmarks(const SwPaM &rPam, const SwPosition &rCpyPam)
Dialog to specify the properties of date form field.
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
bool DelFullPara(SwPaM &) override
Delete full paragraphs.
bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND) override
Insert string into existing text node at position rRg.Point().
sal_uInt16 sal_Unicode
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
bool SplitNode(const SwPosition &rPos, bool bChkTableStart) override
Split a node at rPos (implemented only for TextNode).
bool DeleteAndJoin(SwPaM &, const bool bForceJoinNext=false) override
complete delete of a given PaM
void SetIME(bool bIME) override
States that the last inserted string came from IME.
void DeleteDummyChar(SwPosition const &rPos, sal_Unicode cDummy)
void CopyFlyInFlyImpl(const SwNodeRange &rRg, SwPaM const *const pCopiedPaM, const SwNodeIndex &rStartIdx, const bool bCopyFlyAtFly=false, SwCopyFlags flags=SwCopyFlags::Default) const
void ReRead(SwPaM &, const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic) override
Transpose graphic (with undo)
void RemoveLeadingWhiteSpace(const SwPosition &rPos) override
Removes any leading white space from the paragraph.
void CalcBreaks(std::vector< std::pair< SwNodeOffset, sal_Int32 >> &rBreaks, SwPaM const &rPam, bool const isOnlyFieldmarks)
bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr, SwTextAttr **ppNewTextAttr=nullptr) override
Insert an attribute.
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
SwFlyFrameFormat * InsNoTextNode(const SwPosition &rPos, SwNoTextNode *, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet, SwFrameFormat *)
Style of a layout element.
Definition: frmfmt.hxx:59
bool bExactRange
From the attributes included in the range, delete only the ones which have exactly same range...
SetAttrMode
Definition: swtypes.hxx:133
SwFlyFrameFormat * InsertGraphicObject(const SwPaM &rRg, const GraphicObject &rGrfObj, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet) override
bool MoveNodeRange(SwNodeRange &, SwNodeIndex &, SwMoveFlags) override
Marks a node in the document model.
Definition: ndindex.hxx:32
Text operation/manipulation interface.
SwFlyFrameFormat * InsertGraphic(const SwPaM &rRg, const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet, SwFrameFormat *) override
Insert graphic or formula.
bool ReplaceRangeImpl(SwPaM &, OUString const &, const bool)
void DeleteSection(SwNode *pNode) override
Delete a full Section of the NodeArray.
bool Overwrite(const SwPaM &rRg, const OUString &rStr) override
Overwrite string in an existing text node.
void InsertItemSet(const SwPaM &rRg, const SfxItemSet &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr) override
bool CopyRange(SwPaM &, SwPosition &, SwCopyFlags) const override
Copy a selected content range to a position.
void CopyWithFlyInFly(const SwNodeRange &rRg, const SwNodeIndex &rInsPos, const std::pair< const SwPaM &, const SwPosition & > *pCopiedPaM=nullptr, bool bMakeNewFrames=true, bool bDelRedlines=true, bool bCopyFlyAtFly=false, SwCopyFlags flags=SwCopyFlags::Default) const
note: rRg/rInsPos exclude a partially selected start text node; pCopiedPaM includes a partially selec...
bool CopyImplImpl(SwPaM &, SwPosition &, SwCopyFlags flags, SwPaM *const pCpyRng) const
void MoveAndJoin(SwPaM &, SwPosition &) override
Move a range.
bool ReplaceRange(SwPaM &rPam, const OUString &rNewStr, const bool bRegExReplace) override
Replace selected range in a TextNode with string.
ParaRstFormat(const SwPosition *pStt, const SwPosition *pEnd, SwHistory *pHst, const SfxItemSet *pSet=nullptr, SwRootFrame const *const pLay=nullptr)
void DeleteRange(SwPaM &) override
Delete a range SwFlyFrameFormat.
Base class of the Writer document model elements.
Definition: node.hxx:81
bool DeleteRangeImpl(SwPaM &, const bool unused=false)