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 TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) override;
64 
65  SwFlyFrameFormat* InsertGraphic(const SwPaM &rRg, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic,
66  const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrameFormat*) override;
67 
68  SwFlyFrameFormat* InsertGraphicObject(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet,
69  const SfxItemSet* pGrfAttrSet) override;
70 
71  void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic) override;
72 
73  SwDrawFrameFormat* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) override;
74 
75  SwFlyFrameFormat* InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, SfxItemSet* pFlyAttrSet) override;
76 
77  SwFlyFrameFormat* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
78  const SfxItemSet* pGrfAttrSet) override;
79 
80  bool SplitNode(const SwPosition &rPos, bool bChkTableStart) override;
81 
82  bool AppendTextNode(SwPosition& rPos) override;
83 
84  bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
85  const bool bRegExReplace) override;
86 
87  // Add a para for the char attribute exp...
88  bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
89  const SetAttrMode nFlags = SetAttrMode::DEFAULT,
90  SwRootFrame const* pLayout = nullptr,
91  SwTextAttr **ppNewTextAttr = nullptr) override;
92 
93  void InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
94  const SetAttrMode nFlags = SetAttrMode::DEFAULT,
95  SwRootFrame const* pLayout = nullptr) override;
96 
97  void RemoveLeadingWhiteSpace(const SwPosition & rPos ) override;
98 
99 
100  //Non-Interface methods
101 
102  void DeleteDummyChar(SwPosition const& rPos, sal_Unicode cDummy);
103 
104  void CopyWithFlyInFly( const SwNodeRange& rRg,
105  const SwNodeIndex& rInsPos,
106  const std::pair<const SwPaM&, const SwPosition&> * pCopiedPaM = nullptr,
107  bool bMakeNewFrames = true,
108  bool bDelRedlines = true,
109  bool bCopyFlyAtFly = false,
110  SwCopyFlags flags = SwCopyFlags::Default) const;
111  void CopyFlyInFlyImpl( const SwNodeRange& rRg,
112  SwPaM const*const pCopiedPaM,
113  const SwNodeIndex& rStartIdx,
114  const bool bCopyFlyAtFly = false,
115  SwCopyFlags flags = SwCopyFlags::Default) const;
116 
118  //originallyfrom docfmt.cxx
120  {
125  SwRootFrame const*const pLayout;
126  sal_uInt16 nWhich;
127  bool bReset;
128  bool bResetListAttrs; // #i62575#
129  bool bResetAll;
133 
134  ParaRstFormat(const SwPosition* pStt, const SwPosition* pEnd,
135  SwHistory* pHst, const SfxItemSet* pSet = nullptr,
136  SwRootFrame const*const pLay = nullptr)
137  : pFormatColl(nullptr)
138  , pHistory(pHst)
139  , pSttNd(pStt)
140  , pEndNd(pEnd)
141  , pDelSet(pSet)
142  , pLayout(pLay)
143  , nWhich(0)
144  , bReset(false) // #i62675#
145  , bResetListAttrs(false)
146  , bResetAll(true)
147  , bInclRefToxMark(false)
148  , bExactRange(false)
149  {
150  }
151  };
152  static bool lcl_RstTextAttr( const SwNodePtr& rpNd, void* pArgs ); //originally from docfmt.cxx
153 
154 
155  virtual ~DocumentContentOperationsManager() override;
156 
157 private:
159 
160  bool DeleteAndJoinImpl(SwPaM&, const bool);
161  bool DeleteAndJoinWithRedlineImpl(SwPaM&, const bool unused = false);
162  bool DeleteRangeImpl(SwPaM&, const bool unused = false);
163  bool DeleteRangeImplImpl(SwPaM &);
164  bool ReplaceRangeImpl(SwPaM&, OUString const&, const bool);
166  const SfxItemSet* pFlyAttrSet,
167  const SfxItemSet* pGrfAttrSet,
168  SwFrameFormat* );
169  /* Copy a range within the same or to another document.
170  Position may not lie within range! */
171  bool CopyImpl( SwPaM&, SwPosition&,
172  SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const;
173  bool CopyImplImpl(SwPaM&, SwPosition&,
174  SwCopyFlags flags, SwPaM *const pCpyRng /*= 0*/) const;
175 
178 };
179 
180 
181 void CopyBookmarks(const SwPaM& rPam, SwPosition& rTarget);
182 
183 void CalcBreaks(std::vector<std::pair<sal_uLong, sal_Int32>> & rBreaks,
184  SwPaM const & rPam, bool const isOnlyFieldmarks = false);
185 
186 }
187 
188 /* 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/...
void CalcBreaks(std::vector< std::pair< sal_uLong, sal_Int32 >> &rBreaks, SwPaM const &rPam, bool const isOnlyFieldmarks)
DocumentContentOperationsManager & operator=(DocumentContentOperationsManager const &)=delete
Marks a position in the document model.
Definition: pam.hxx:35
bool MoveRange(SwPaM &, SwPosition &, SwMoveFlags) override
SwFlyFrameFormat * InsertOLE(const SwPaM &rRg, const OUString &rObjName, sal_Int64 nAspect, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet) override
static bool lcl_RstTextAttr(const SwNodePtr &rpNd, void *pArgs)
pArgs contains the document's ChrFormatTable Is need for selections at the beginning/end and with no ...
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.
bool DeleteAndJoinWithRedlineImpl(SwPaM &, const bool unused=false)
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 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.
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:136
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:31
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 CopyBookmarks(const SwPaM &rPam, SwPosition &rCpyPam)
void DeleteRange(SwPaM &) override
Delete a range SwFlyFrameFormat.
Base class of the Writer document model elements.
Definition: node.hxx:80
bool DeleteRangeImpl(SwPaM &, const bool unused=false)