[Libreoffice-commits] core.git: 3 commits - sw/inc sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Aug 15 07:49:47 PDT 2014
sw/inc/textboxhelper.hxx | 8 ++++----
sw/qa/extras/uiwriter/data/fdo82191.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 24 ++++++++++++++++++++++++
sw/source/core/doc/DocumentLayoutManager.cxx | 11 +++++++++++
sw/source/core/doc/docfly.cxx | 4 ++--
sw/source/core/doc/textboxhelper.cxx | 16 ++++++++--------
sw/source/core/frmedt/fecopy.cxx | 6 ++++++
sw/source/core/unocore/unocoll.cxx | 2 +-
sw/source/core/unocore/unodraw.cxx | 4 ++--
sw/source/core/unocore/unoframe.cxx | 2 +-
sw/source/core/unocore/unoobj2.cxx | 2 +-
sw/source/core/unocore/unoportenum.cxx | 4 ++--
sw/source/filter/ww8/docxsdrexport.cxx | 2 +-
13 files changed, 63 insertions(+), 22 deletions(-)
New commits:
commit c7307c77254557646f33017af915f6808a861e29
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Aug 15 15:59:56 2014 +0200
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
diff --git a/sw/qa/extras/uiwriter/data/fdo82191.odt b/sw/qa/extras/uiwriter/data/fdo82191.odt
new file mode 100644
index 0000000..d0759c0
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo82191.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 10cb454..e12af85 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 1772723..19b07cb 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 261f492..6bdf41f 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() )
commit 0606ab6a73d5d9e3fd9f7b20f77a2532f2478194
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Aug 15 15:52:55 2014 +0200
SwTextBoxHelper::findTextBoxes: return a set of const pointers
Change-Id: I8e3ea996959bad72e6d15dc9c980ea9d18d31fb3
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index d27fa66..1a59df5 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -67,13 +67,13 @@ public:
static Rectangle getTextRectangle(SwFrmFmt* pShape, bool bAbsolute = true);
/// Look up TextFrames in a document, which are in fact TextBoxes.
- static std::set<SwFrmFmt*> findTextBoxes(const SwDoc* pDoc);
+ static std::set<const SwFrmFmt*> findTextBoxes(const SwDoc* pDoc);
/// Build a textbox -> shape format map.
static std::map<SwFrmFmt*, SwFrmFmt*> findShapes(const SwDoc* pDoc);
/// Count number of shapes in the document, excluding TextBoxes.
- static sal_Int32 getCount(SdrPage* pPage, std::set<SwFrmFmt*>& rTextBoxes);
+ static sal_Int32 getCount(SdrPage* pPage, std::set<const SwFrmFmt*>& rTextBoxes);
/// Get a shape by index, excluding TextBoxes.
- static css::uno::Any getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set<SwFrmFmt*>& rTextBoxes) throw(css::lang::IndexOutOfBoundsException);
+ static css::uno::Any getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set<const SwFrmFmt*>& rTextBoxes) throw(css::lang::IndexOutOfBoundsException);
/// Saves the current shape -> textbox links in a map, so they can be restored later.
static void saveLinks(const SwFrmFmts& rFormats, std::map<const SwFrmFmt*, const SwFrmFmt*>& rLinks);
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index 6b96e96..ff8e0ff 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -79,7 +79,7 @@ sal_uInt16 SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const
sal_uInt16 nCount = 0;
const SwNodeIndex* pIdx;
- std::set<SwFrmFmt*> aTextBoxes;
+ std::set<const SwFrmFmt*> aTextBoxes;
if (bIgnoreTextBoxes)
aTextBoxes = SwTextBoxHelper::findTextBoxes(this);
@@ -131,7 +131,7 @@ SwFrmFmt* SwDoc::GetFlyNum( sal_uInt16 nIdx, FlyCntType eType, bool bIgnoreTextB
const SwNodeIndex* pIdx;
sal_uInt16 nCount = 0;
- std::set<SwFrmFmt*> aTextBoxes;
+ std::set<const SwFrmFmt*> aTextBoxes;
if (bIgnoreTextBoxes)
aTextBoxes = SwTextBoxHelper::findTextBoxes(this);
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 3c54f53..1e06d49 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -116,9 +116,9 @@ void SwTextBoxHelper::destroy(SwFrmFmt* pShape)
}
}
-std::set<SwFrmFmt*> SwTextBoxHelper::findTextBoxes(const SwDoc* pDoc)
+std::set<const SwFrmFmt*> SwTextBoxHelper::findTextBoxes(const SwDoc* pDoc)
{
- std::set<SwFrmFmt*> aRet;
+ std::set<const SwFrmFmt*> aRet;
const SwFrmFmts& rSpzFrmFmts = *pDoc->GetSpzFrmFmts();
for (SwFrmFmts::const_iterator it = rSpzFrmFmts.begin(); it != rSpzFrmFmts.end(); ++it)
@@ -147,13 +147,13 @@ std::map<SwFrmFmt*, SwFrmFmt*> SwTextBoxHelper::findShapes(const SwDoc* pDoc)
}
/// If the passed SdrObject is in fact a TextFrame, that is used as a TextBox.
-bool lcl_isTextBox(SdrObject* pSdrObject, std::set<SwFrmFmt*>& rTextBoxes)
+bool lcl_isTextBox(SdrObject* pSdrObject, std::set<const SwFrmFmt*>& rTextBoxes)
{
SwVirtFlyDrawObj* pObject = PTR_CAST(SwVirtFlyDrawObj, pSdrObject);
return pObject && std::find(rTextBoxes.begin(), rTextBoxes.end(), pObject->GetFmt()) != rTextBoxes.end();
}
-sal_Int32 SwTextBoxHelper::getCount(SdrPage* pPage, std::set<SwFrmFmt*>& rTextBoxes)
+sal_Int32 SwTextBoxHelper::getCount(SdrPage* pPage, std::set<const SwFrmFmt*>& rTextBoxes)
{
sal_Int32 nRet = 0;
for (size_t i = 0; i < pPage->GetObjCount(); ++i)
@@ -165,7 +165,7 @@ sal_Int32 SwTextBoxHelper::getCount(SdrPage* pPage, std::set<SwFrmFmt*>& rTextBo
return nRet;
}
-uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set<SwFrmFmt*>& rTextBoxes) throw(lang::IndexOutOfBoundsException)
+uno::Any SwTextBoxHelper::getByIndex(SdrPage* pPage, sal_Int32 nIndex, std::set<const SwFrmFmt*>& rTextBoxes) throw(lang::IndexOutOfBoundsException)
{
if (nIndex < 0 || nIndex >= getCount(pPage, rTextBoxes))
throw lang::IndexOutOfBoundsException();
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index d42cab2..e42f7c1 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -1085,7 +1085,7 @@ SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc)
// #i104937#
SwFrmFmt* pFmt( 0 );
- std::set<SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+ std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
for( size_t i = 0; i < nSize; ++i )
{
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 9640704..df20923 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -524,7 +524,7 @@ sal_Int32 SwXDrawPage::getCount(void) throw( uno::RuntimeException, std::excepti
{
((SwXDrawPage*)this)->GetSvxPage();
- std::set<SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+ std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
if (aTextBoxes.empty())
return pDrawPage->getCount();
@@ -544,7 +544,7 @@ uno::Any SwXDrawPage::getByIndex(sal_Int32 nIndex)
throw lang::IndexOutOfBoundsException();
((SwXDrawPage*)this)->GetSvxPage();
- std::set<SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+ std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
if (aTextBoxes.empty())
return pDrawPage->getByIndex( nIndex );
else
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 50534a3..b7eba37 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1685,7 +1685,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::
aValue >>= nZOrder;
// Don't set an explicit ZOrder on TextBoxes.
- std::set<SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+ std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
if( nZOrder >= 0 && std::find(aTextBoxes.begin(), aTextBoxes.end(), pFmt) == aTextBoxes.end())
{
SdrObject* pObject =
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 548d7f6..0e4442f 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -184,7 +184,7 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx,
const SwSortedObjs *pObjs = pCFrm->GetDrawObjs();
if( pObjs )
{
- std::set<SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+ std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
for( sal_uInt32 i = 0; i < pObjs->Count(); ++i )
{
SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 971e181..40b0ec5 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -691,7 +691,7 @@ lcl_ExportHints(
const bool bRightMoveForbidden,
bool & o_rbCursorMoved,
sal_Int32 & o_rNextAttrPosition,
- std::set<SwFrmFmt*>& rTextBoxes)
+ std::set<const SwFrmFmt*>& rTextBoxes)
{
// if the attribute has a dummy character, then xRef is set (except META)
// otherwise, the portion for the attribute is inserted into rPortions!
@@ -1243,7 +1243,7 @@ static void lcl_CreatePortions(
PortionStack_t PortionStack;
PortionStack.push( PortionList_t(&i_rPortions, (const SwTxtAttr *)0) );
- std::set<SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
+ std::set<const SwFrmFmt*> aTextBoxes = SwTextBoxHelper::findTextBoxes(pDoc);
bool bAtEnd( false );
while (!bAtEnd) // every iteration consumes at least current character!
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 2c1f7bc..0a88a41 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -168,7 +168,7 @@ struct DocxSdrExport::Impl
sal_Int32 m_nSeq ;
bool m_bDMLAndVMLDrawingOpen;
/// List of TextBoxes in this document: they are exported as part of their shape, never alone.
- std::set<SwFrmFmt*> m_aTextBoxes;
+ std::set<const SwFrmFmt*> m_aTextBoxes;
/// Preserved rotation for TextFrames.
sal_Int32 m_nDMLandVMLTextFrameRotation;
commit 615d3e319c027b6ef656ff2358c5d2c3519d5440
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Aug 15 15:33:11 2014 +0200
SwTextBoxHelper::findTextBox: take a const SwFrmFmt
Change-Id: I531a5864f61ab6c9bfcfc44f7fcacef58ad78489
diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx
index f2aab3b..d27fa66 100644
--- a/sw/inc/textboxhelper.hxx
+++ b/sw/inc/textboxhelper.hxx
@@ -61,7 +61,7 @@ public:
static void syncFlyFrmAttr(SwFrmFmt& rShape, SfxItemSet& rSet);
/// If we have an associated TextFrame, then return that.
- static SwFrmFmt* findTextBox(SwFrmFmt* pShape);
+ static SwFrmFmt* findTextBox(const SwFrmFmt* pShape);
static SwFrmFmt* findTextBox(css::uno::Reference<css::drawing::XShape> xShape);
/// Return the textbox rectangle of a draw shape (in twips).
static Rectangle getTextRectangle(SwFrmFmt* pShape, bool bAbsolute = true);
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 43774cb..3c54f53 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -196,7 +196,7 @@ SwFrmFmt* SwTextBoxHelper::findTextBox(uno::Reference<drawing::XShape> xShape)
return findTextBox(pShape->GetFrmFmt());
}
-SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape)
+SwFrmFmt* SwTextBoxHelper::findTextBox(const SwFrmFmt* pShape)
{
SwFrmFmt* pRet = 0;
@@ -204,8 +204,8 @@ SwFrmFmt* SwTextBoxHelper::findTextBox(SwFrmFmt* pShape)
if (pShape->Which() == RES_DRAWFRMFMT && pShape->GetAttrSet().HasItem(RES_CNTNT))
{
const SwFmtCntnt& rCntnt = pShape->GetCntnt();
- SwFrmFmts& rSpzFrmFmts = *pShape->GetDoc()->GetSpzFrmFmts();
- for (SwFrmFmts::iterator it = rSpzFrmFmts.begin(); it != rSpzFrmFmts.end(); ++it)
+ const SwFrmFmts& rSpzFrmFmts = *pShape->GetDoc()->GetSpzFrmFmts();
+ for (SwFrmFmts::const_iterator it = rSpzFrmFmts.begin(); it != rSpzFrmFmts.end(); ++it)
{
SwFrmFmt* pFmt = *it;
// Only a fly frame can be a TextBox.
More information about the Libreoffice-commits
mailing list