summaryrefslogtreecommitdiff
path: root/sw/source/uibase/dochdl/swdtflvr.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase/dochdl/swdtflvr.cxx')
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx95
1 files changed, 80 insertions, 15 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index da8c13e04caa..9200cd67df9f 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -82,6 +82,7 @@
#include <IDocumentUndoRedo.hxx>
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentFieldsAccess.hxx>
+#include <IDocumentRedlineAccess.hxx>
#include <IDocumentState.hxx>
#include <IMark.hxx>
#include <section.hxx>
@@ -867,6 +868,84 @@ void SwTransferable::DeleteSelection()
m_pWrtShell->EndUndo( SwUndoId::END );
}
+static void DeleteDDEMarks(SwDoc & rDest)
+{
+ IDocumentMarkAccess *const pMarkAccess = rDest.getIDocumentMarkAccess();
+ std::vector< ::sw::mark::IMark* > vDdeMarks;
+ // find all DDE-Bookmarks
+ for (IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
+ ppMark != pMarkAccess->getAllMarksEnd();
+ ++ppMark)
+ {
+ if (IDocumentMarkAccess::MarkType::DDE_BOOKMARK == IDocumentMarkAccess::GetType(**ppMark))
+ {
+ vDdeMarks.push_back(*ppMark);
+ }
+ }
+ // remove all DDE-Bookmarks, they are invalid inside the clipdoc!
+ for (const auto& rpMark : vDdeMarks)
+ {
+ pMarkAccess->deleteMark(rpMark);
+ }
+}
+
+void SwTransferable::PrepareForCopyTextRange(SwPaM & rPaM)
+{
+ std::unique_ptr<SwWait> pWait;
+ if (m_pWrtShell->ShouldWait())
+ {
+ pWait.reset(new SwWait( *m_pWrtShell->GetView().GetDocShell(), true ));
+ }
+
+ m_pClpDocFac.reset(new SwDocFac);
+
+ SwDoc& rDest(lcl_GetDoc(*m_pClpDocFac));
+ rDest.getIDocumentFieldsAccess().LockExpFields(); // Never update fields - leave text as is
+ {
+ SwDoc const& rSrc(*m_pWrtShell->GetDoc());
+ assert(&rSrc == &rPaM.GetDoc());
+
+ rDest.ReplaceCompatibilityOptions(rSrc);
+ rDest.ReplaceDefaults(rSrc);
+
+ //It would probably make most sense here to only insert the styles used
+ //by the selection, e.g. apply SwDoc::IsUsed on styles ?
+ rDest.ReplaceStyles(rSrc, false);
+
+ // relevant bits of rSrcWrtShell.Copy(rDest);
+ rDest.GetIDocumentUndoRedo().DoUndo(false); // always false!
+ rDest.getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::DeleteRedlines );
+
+ SwNodeIndex const aIdx(rDest.GetNodes().GetEndOfContent(), -1);
+ SwContentNode *const pContentNode(aIdx.GetNode().GetContentNode());
+ SwPosition aPos(aIdx,
+ SwIndex(pContentNode, pContentNode ? pContentNode->Len() : 0));
+
+ rSrc.getIDocumentContentOperations().CopyRange(rPaM, aPos, SwCopyFlags::CheckPosInFly);
+
+ rDest.getIDocumentRedlineAccess().SetRedlineFlags_intern( RedlineFlags::NONE );
+
+ rDest.GetMetaFieldManager().copyDocumentProperties(rSrc);
+ }
+
+ DeleteDDEMarks(rDest);
+
+ // a new one was created in core (OLE objects copied!)
+ m_aDocShellRef = rDest.GetTmpDocShell();
+ if (m_aDocShellRef.Is())
+ SwTransferable::InitOle( m_aDocShellRef );
+ rDest.SetTmpDocShell( nullptr );
+
+ // let's add some formats
+ AddFormat( SotClipboardFormatId::EMBED_SOURCE );
+ AddFormat( SotClipboardFormatId::RTF );
+#if HAVE_FEATURE_DESKTOP
+ AddFormat( SotClipboardFormatId::RICHTEXT );
+ AddFormat( SotClipboardFormatId::HTML );
+#endif
+ AddFormat( SotClipboardFormatId::STRING );
+}
+
int SwTransferable::PrepareForCopy( bool bIsCut )
{
int nRet = 1;
@@ -974,21 +1053,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
rTmpDoc.getIDocumentFieldsAccess().LockExpFields(); // Never update fields - leave text as is
lclOverWriteDoc(*m_pWrtShell, rTmpDoc);
- {
- IDocumentMarkAccess* const pMarkAccess = rTmpDoc.getIDocumentMarkAccess();
- std::vector< ::sw::mark::IMark* > vDdeMarks;
- // find all DDE-Bookmarks
- for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getAllMarksBegin();
- ppMark != pMarkAccess->getAllMarksEnd();
- ++ppMark)
- {
- if(IDocumentMarkAccess::MarkType::DDE_BOOKMARK == IDocumentMarkAccess::GetType(**ppMark))
- vDdeMarks.push_back(*ppMark);
- }
- // remove all DDE-Bookmarks, they are invalid inside the clipdoc!
- for(const auto& rpMark : vDdeMarks)
- pMarkAccess->deleteMark(rpMark);
- }
+ DeleteDDEMarks(rTmpDoc);
// a new one was created in CORE (OLE objects copied!)
m_aDocShellRef = rTmpDoc.GetTmpDocShell();