Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / core / view / view.cxx
blob576095c7f4cc4aa06b8ef8c9633b16dbfe2912df
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("/sw/qa/core/view/data/")
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 = pDoc->GetDocShell()->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 svt::EmbeddedObjectRef& rObject = rOleObj.GetObject();
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(!rObject.GetGraphic()->IsNone());
70 CPPUNIT_PLUGIN_IMPLEMENT();
72 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */