LibreOffice Module test (master)  1
xshapegrouper.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  */
9 
11 #include <sal/types.h>
12 
13 #include <com/sun/star/drawing/XShape.hpp>
14 #include <com/sun/star/drawing/XShapeGroup.hpp>
15 #include <com/sun/star/drawing/XShapeGrouper.hpp>
16 #include <com/sun/star/drawing/XShapes.hpp>
17 
18 #include <com/sun/star/uno/Reference.hxx>
19 
20 #include <cppunit/TestAssert.h>
21 
22 using namespace css;
23 
24 namespace apitest
25 {
26 void XShapeGrouper::testGroup()
27 {
28  uno::Reference<drawing::XShapeGrouper> xSG(init(), uno::UNO_QUERY_THROW);
29 
30  uno::Reference<drawing::XShapes> xShapes(m_xDrawPage, uno::UNO_QUERY_THROW);
31  const sal_Int32 nCountBeforeGroup = xShapes->getCount();
32 
33  uno::Reference<drawing::XShape> xShape(xSG->group(xShapes), uno::UNO_QUERY_THROW);
34  const sal_Int32 nCountAfterGroup = xShapes->getCount();
35 
36  CPPUNIT_ASSERT(xShape.is());
37  CPPUNIT_ASSERT(nCountAfterGroup < nCountBeforeGroup);
38 }
39 
40 void XShapeGrouper::testUngroup()
41 {
42  uno::Reference<drawing::XShapeGrouper> xSG(init(), uno::UNO_QUERY_THROW);
43 
44  uno::Reference<drawing::XShapes> xShapes(m_xDrawPage, uno::UNO_QUERY_THROW);
45  uno::Reference<drawing::XShape> xShape(xSG->group(xShapes), uno::UNO_QUERY_THROW);
46  uno::Reference<drawing::XShapeGroup> xShapeGroup(xShape, uno::UNO_QUERY_THROW);
47 
48  const sal_Int32 nCountAfterGroup = xShapes->getCount();
49 
50  xSG->ungroup(xShapeGroup);
51  const sal_Int32 nCountAfterUngroup = xShapes->getCount();
52 
53  CPPUNIT_ASSERT(nCountAfterUngroup != nCountAfterGroup);
54 }
55 } // namespace apitest
56 
57 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
FILE * init(int, char **)