Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / engine3d / cube3d.cxx
blob94e482659b97b90c0869e8e336af353bd9cfe069
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svx/strings.hrc>
22 #include <svx/deflt3d.hxx>
23 #include <svx/dialmgr.hxx>
24 #include <svx/cube3d.hxx>
25 #include <svx/svdobjkind.hxx>
26 #include <basegfx/point/b3dpoint.hxx>
27 #include <sdr/contact/viewcontactofe3dcube.hxx>
30 // DrawContact section
32 std::unique_ptr<sdr::contact::ViewContact> E3dCubeObj::CreateObjectSpecificViewContact()
34 return std::make_unique<sdr::contact::ViewContactOfE3dCube>(*this);
38 E3dCubeObj::E3dCubeObj(
39 SdrModel& rSdrModel,
40 const E3dDefaultAttributes& rDefault,
41 const basegfx::B3DPoint& aPos,
42 const basegfx::B3DVector& r3DSize)
43 : E3dCompoundObject(rSdrModel)
45 // Set Defaults
46 SetDefaultAttributes(rDefault);
48 // position centre or left, bottom, back (dependent on bPosIsCenter)
49 aCubePos = aPos;
50 aCubeSize = r3DSize;
53 E3dCubeObj::E3dCubeObj(SdrModel& rSdrModel)
54 : E3dCompoundObject(rSdrModel)
56 // Set Defaults
57 const E3dDefaultAttributes aDefault;
59 SetDefaultAttributes(aDefault);
62 E3dCubeObj::E3dCubeObj(SdrModel& rSdrModel, E3dCubeObj const & rSource)
63 : E3dCompoundObject(rSdrModel, rSource)
65 // Set Defaults
66 const E3dDefaultAttributes aDefault;
68 SetDefaultAttributes(aDefault);
70 aCubePos = rSource.aCubePos;
71 aCubeSize = rSource.aCubeSize;
72 bPosIsCenter = rSource.bPosIsCenter;
75 E3dCubeObj::~E3dCubeObj()
79 void E3dCubeObj::SetDefaultAttributes(const E3dDefaultAttributes& rDefault)
81 aCubePos = rDefault.GetDefaultCubePos();
82 aCubeSize = rDefault.GetDefaultCubeSize();
83 bPosIsCenter = rDefault.GetDefaultCubePosIsCenter();
86 SdrObjKind E3dCubeObj::GetObjIdentifier() const
88 return SdrObjKind::E3D_Cube;
91 // Convert the object into a group object consisting of 6 polygons
93 rtl::Reference<SdrObject> E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
95 return nullptr;
98 rtl::Reference<SdrObject> E3dCubeObj::CloneSdrObject(SdrModel& rTargetModel) const
100 return new E3dCubeObj(rTargetModel, *this);
103 // Set local parameters with geometry re-creating
105 void E3dCubeObj::SetCubePos(const basegfx::B3DPoint& rNew)
107 if(aCubePos != rNew)
109 aCubePos = rNew;
110 ActionChanged();
114 void E3dCubeObj::SetCubeSize(const basegfx::B3DVector& rNew)
116 if(aCubeSize != rNew)
118 aCubeSize = rNew;
119 ActionChanged();
123 void E3dCubeObj::SetPosIsCenter(bool bNew)
125 if(bPosIsCenter != bNew)
127 bPosIsCenter = bNew;
128 ActionChanged();
132 // Get the name of the object (singular)
134 OUString E3dCubeObj::TakeObjNameSingul() const
136 OUString sName = SvxResId(STR_ObjNameSingulCube3d);
138 OUString aName(GetName());
139 if (!aName.isEmpty())
141 sName += " \'" + aName + "'";
143 return sName;
146 // Get the name of the object (plural)
148 OUString E3dCubeObj::TakeObjNamePlural() const
150 return SvxResId(STR_ObjNamePluralCube3d);
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */