1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include <swmodeltestbase.hxx>
13 #include <swdtflvr.hxx>
14 #include <swmodule.hxx>
16 #include <frameformats.hxx>
17 #include <formatflysplit.hxx>
21 /// Covers sw/source/core/attr/ fixes.
22 class Test
: public SwModelTestBase
26 : SwModelTestBase("/sw/qa/core/attr/data/")
31 CPPUNIT_TEST_FIXTURE(Test
, testSwAttrSet
)
33 // Given a document with track changes and the whole document is selected:
34 createSwDoc("attr-set.docx");
35 SwDoc
* pDoc
= getSwDoc();
36 SwDocShell
* pDocShell
= pDoc
->GetDocShell();
37 SwWrtShell
* pWrtShell
= pDocShell
->GetWrtShell();
38 dispatchCommand(mxComponent
, ".uno:SelectAll", {});
39 dispatchCommand(mxComponent
, ".uno:Cut", {});
40 dispatchCommand(mxComponent
, ".uno:SelectAll", {});
41 rtl::Reference
<SwTransferable
> xTransferable(new SwTransferable(*pWrtShell
));
42 SwModule
* pMod
= SW_MOD();
43 SwTransferable
* pOldTransferable
= pMod
->m_pXSelection
;
44 pMod
->m_pXSelection
= xTransferable
.get();
46 // When getting the plain text version of the selection:
47 datatransfer::DataFlavor aFlavor
;
48 aFlavor
.MimeType
= "text/plain;charset=utf-16";
49 aFlavor
.DataType
= cppu::UnoType
<OUString
>::get();
50 uno::Any aData
= xTransferable
->getTransferData(aFlavor
);
52 // Then make sure we get data without crashing:
53 CPPUNIT_ASSERT(aData
.hasValue());
54 pMod
->m_pXSelection
= pOldTransferable
;
57 CPPUNIT_TEST_FIXTURE(Test
, testFormatFlySplit
)
60 SwWrtShell
* pWrtShell
= getSwDocShell()->GetWrtShell();
61 SwFlyFrameAttrMgr
aMgr(true, pWrtShell
, Frmmgr_Type::TEXT
, nullptr);
62 RndStdIds eAnchor
= RndStdIds::FLY_AT_PARA
;
63 aMgr
.InsertFlyFrame(eAnchor
, aMgr
.GetPos(), aMgr
.GetSize());
64 SwDoc
* pDoc
= getSwDoc();
65 sw::SpzFrameFormats
& rFlys
= *pDoc
->GetSpzFrameFormats();
66 sw::SpzFrameFormat
* pFly
= rFlys
[0];
67 CPPUNIT_ASSERT(!pFly
->GetAttrSet().GetFlySplit().GetValue());
69 SfxItemSet
aSet(pFly
->GetAttrSet());
70 SwFormatFlySplit
aItem(true);
72 pDoc
->SetFlyFrameAttr(*pFly
, aSet
);
74 CPPUNIT_ASSERT(pFly
->GetAttrSet().GetFlySplit().GetValue());
78 CPPUNIT_PLUGIN_IMPLEMENT();
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */