Use COMReference to handle COM pointers in CreateShortcut
[LibreOffice.git] / sw / qa / core / view / view.cxx
blobc7eb80762a8fcf74a73a25b560d1e768e39c898f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <swmodeltestbase.hxx>
12 #include <svtools/embedhlp.hxx>
13 #include <vcl/graph.hxx>
15 #include <doc.hxx>
16 #include <docsh.hxx>
17 #include <fmtcntnt.hxx>
18 #include <frameformats.hxx>
19 #include <frmfmt.hxx>
20 #include <ndarr.hxx>
21 #include <ndindex.hxx>
22 #include <ndole.hxx>
23 #include <node.hxx>
24 #include <nodeoffset.hxx>
25 #include <wrtsh.hxx>
27 namespace
29 /// Covers sw/source/core/view/ fixes.
30 class Test : public SwModelTestBase
32 public:
33 Test()
34 : SwModelTestBase(u"/sw/qa/core/view/data/"_ustr)
40 CPPUNIT_TEST_FIXTURE(Test, testUpdateOleObjectPreviews)
42 // Given a document with two embedded objects, both with broken native data:
43 createSwDoc("update-ole-object-previews.odt");
44 SwDoc* pDoc = getSwDoc();
45 SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
47 // When updating the previews of those embedded objects (right after document load, before
48 // painting the OLE objects):
49 pWrtShell->UpdateOleObjectPreviews();
51 // Then make sure that the working preview of those objects are not lost:
52 const auto pFormats = pDoc->GetSpzFrameFormats();
53 CPPUNIT_ASSERT(pFormats);
54 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pFormats->size());
55 for (auto pFormat : *pFormats)
57 const SwNodeIndex* pNodeIndex = pFormat->GetContent().GetContentIdx();
58 CPPUNIT_ASSERT(pNodeIndex);
59 SwNode* pNode = pDoc->GetNodes()[pNodeIndex->GetIndex() + 1];
60 SwOLENode* pOleNode = pNode->GetOLENode();
61 CPPUNIT_ASSERT(pOleNode);
62 SwOLEObj& rOleObj = pOleNode->GetOLEObj();
63 const Graphic* pGraphic = rOleObj.GetObject().GetGraphic();
64 // Without the accompanying fix in place, this test would have failed, the update broke the
65 // preview of the second embedded object.
66 CPPUNIT_ASSERT(pGraphic);
67 CPPUNIT_ASSERT(!pGraphic->IsNone());
71 CPPUNIT_PLUGIN_IMPLEMENT();
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */