summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-08-15 15:59:56 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-08-15 16:48:58 +0200
commitc7307c77254557646f33017af915f6808a861e29 (patch)
treebd4ca78aa7bd07c7cfaa5072a62d59cf790ff5b9 /sw
parent0606ab6a73d5d9e3fd9f7b20f77a2532f2478194 (diff)
fdo#82191 sw::DocumentLayoutManager: copy textbox content of draw formats
The SwFmtCntnt, i.e. the content of the draw format was already copied, but that's only a pointer to the real content: instead duplicate the real contents on copy&paste, that's how we copy fly frames as well. Change-Id: I42475e356aaa1c54c08fb23a6a395d1726e5f33e
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/data/fdo82191.odtbin0 -> 10913 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx24
-rw-r--r--sw/source/core/doc/DocumentLayoutManager.cxx11
-rw-r--r--sw/source/core/frmedt/fecopy.cxx6
4 files changed, 41 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/fdo82191.odt b/sw/qa/extras/uiwriter/data/fdo82191.odt
new file mode 100644
index 000000000000..d0759c04dd1c
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/fdo82191.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 10cb4545bb84..e12af858a32a 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -18,6 +18,7 @@
#include <section.hxx>
#include <fmtclds.hxx>
#include <dcontact.hxx>
+#include <textboxhelper.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
@@ -46,6 +47,7 @@ public:
void testCp1000071();
void testShapeTextboxVertadjust();
void testShapeTextboxAutosize();
+ void testFdo82191();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -62,6 +64,7 @@ public:
CPPUNIT_TEST(testCp1000071);
CPPUNIT_TEST(testShapeTextboxVertadjust);
CPPUNIT_TEST(testShapeTextboxAutosize);
+ CPPUNIT_TEST(testFdo82191);
CPPUNIT_TEST_SUITE_END();
private:
@@ -390,6 +393,27 @@ void SwUiWriterTest::testShapeTextboxAutosize()
CPPUNIT_ASSERT(pFirst->GetSnapRect().getHeight() < pSecond->GetSnapRect().getHeight());
}
+void SwUiWriterTest::testFdo82191()
+{
+ SwDoc* pDoc = createDoc("fdo82191.odt");
+ SdrPage* pPage = pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+ std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+ // Make sure we have a single draw shape.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), SwTextBoxHelper::getCount(pPage, aTextBoxes));
+
+ SwDoc aClipboard;
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SdrObject* pObject = pPage->GetObj(0);
+ // Select it, then copy and paste.
+ pWrtShell->SelectObj(Point(), 0, pObject);
+ pWrtShell->Copy(&aClipboard);
+ pWrtShell->Paste(&aClipboard);
+
+ aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+ // This was one: the textbox of the shape wasn't copied.
+ CPPUNIT_ASSERT_EQUAL(size_t(2), aTextBoxes.size());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx
index 1772723d72a3..19b07cbecbd6 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -39,6 +39,7 @@
#include <unoframe.hxx>
#include <docary.hxx>
#include <dcontact.hxx>
+#include <textboxhelper.hxx>
using namespace ::com::sun::star;
@@ -493,6 +494,16 @@ SwFrmFmt *DocumentLayoutManager::CopyLayoutFmt(
if( bMakeFrms )
pDest->MakeFrms();
+ // If the draw format has a TextBox, then copy its fly format as well.
+ if (SwFrmFmt* pSourceTextBox = SwTextBoxHelper::findTextBox(&rSource))
+ {
+ SwFrmFmt* pDestTextBox = CopyLayoutFmt(*pSourceTextBox, rNewAnchor, bSetTxtFlyAtt, bMakeFrms);
+ SwAttrSet aSet(pDest->GetAttrSet());
+ SwFmtCntnt aCntnt(pDestTextBox->GetCntnt().GetCntntIdx()->GetNode().GetStartNode());
+ aSet.Put(aCntnt);
+ pDest->SetFmtAttr(aSet);
+ }
+
return pDest;
}
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 261f49236e55..6bdf41fc9f6e 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -75,6 +75,7 @@
#include <docsh.hxx>
#include <pagedesc.hxx>
#include <mvsave.hxx>
+#include <textboxhelper.hxx>
#include <vcl/virdev.hxx>
#include <svx/svdundo.hxx>
@@ -884,6 +885,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
if( !Imp()->GetDrawView() )
MakeDrawView();
+ std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pClpDoc);
for ( sal_uInt16 i = 0; i < pClpDoc->GetSpzFrmFmts()->size(); ++i )
{
bool bInsWithFmt = true;
@@ -953,6 +955,10 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
continue;
}
+ // Ignore TextBoxes, they are already handled in sw::DocumentLayoutManager::CopyLayoutFmt().
+ if (aTextBoxes.find(&rCpyFmt) != aTextBoxes.end())
+ continue;
+
aAnchor.SetAnchor( pPos );
}
else if ( FLY_AT_PAGE == aAnchor.GetAnchorId() )