LibreOffice Module sc (master) 1
fuconcustomshape.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <fuconcustomshape.hxx>
21#include <editeng/svxenum.hxx>
22#include <svx/gallery.hxx>
23#include <sfx2/request.hxx>
24#include <svx/fmmodel.hxx>
25#include <svl/itempool.hxx>
26#include <svl/stritem.hxx>
27#include <svx/svdpage.hxx>
28#include <svx/svdoashp.hxx>
29#include <svx/xfillit0.hxx>
30#include <editeng/eeitem.hxx>
31#include <svx/sdtagitm.hxx>
32#include <tabvwsh.hxx>
33#include <drawview.hxx>
35
36using namespace com::sun::star;
37
39 : FuConstruct(rViewSh, pWin, pViewP, pDoc, rReq)
40{
41 const SfxItemSet* pArgs = rReq.GetArgs();
42 if ( pArgs )
43 {
44 const SfxStringItem& rItm = static_cast<const SfxStringItem&>(pArgs->Get( rReq.GetSlot() ));
45 aCustomShape = rItm.GetValue();
46 }
47}
48
50{
51}
52
54{
55 // remember button state for creation of own MouseEvents
57
58 bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
59 if ( rMEvt.IsLeft() && !pView->IsAction() )
60 {
61 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
62 pWindow->CaptureMouse();
63 pView->BegCreateObj(aPnt);
64
65 SdrObject* pObj = pView->GetCreateObj();
66 if ( pObj )
67 {
68 SetAttributes( pObj );
69 bool bForceNoFillStyle = false;
70 if ( static_cast<SdrObjCustomShape*>(pObj)->UseNoFillStyle() )
71 bForceNoFillStyle = true;
72 if ( bForceNoFillStyle )
73 pObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) );
74 }
75
76 bReturn = true;
77 }
78 return bReturn;
79}
80
82{
83 // remember button state for creation of own MouseEvents
85
86 bool bReturn = false;
87
88 if ( pView->IsCreateObj() && rMEvt.IsLeft() )
89 {
90 pView->EndCreateObj(SdrCreateCmd::ForceEnd);
91 bReturn = true;
92 }
93 return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
94}
95
97{
98 pView->SetCurrentObj( SdrObjKind::CustomShape );
99
100 aNewPointer = PointerStyle::DrawRect;
101 aOldPointer = pWindow->GetPointer();
103
105}
106
108{
110
112}
113
114// Create default drawing objects via keyboard
116{
118 *pDrDoc,
121
122 if( pObj )
123 {
124 tools::Rectangle aRectangle( rRectangle );
125 SetAttributes( pObj.get() );
127 ImpForceQuadratic( aRectangle );
128 pObj->SetLogicRect( aRectangle );
129 }
130
131 return pObj;
132}
133
135{
136 bool bAttributesAppliedFromGallery = false;
137
139 {
140 std::vector< OUString > aObjList;
142 {
143 for ( std::vector<OUString>::size_type i = 0; i < aObjList.size(); i++ )
144 {
146 {
147 FmFormModel aFormModel;
148 SfxItemPool& rPool(aFormModel.GetItemPool());
149 rPool.FreezeIdRanges();
150
152 {
153 const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
154 if( pSourceObj )
155 {
156 const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
158 // Ranges from SdrAttrObj:
163 // Graphic attributes, 3D properties,
164 // CustomShape properties:
167 // Range from SdrTextObj:
170 aDest.Set( rSource );
171 pObj->SetMergedItemSet( aDest );
172 Degree100 nAngle = pSourceObj->GetRotateAngle();
173 if ( nAngle )
174 pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle );
175 bAttributesAppliedFromGallery = true;
176 }
177 }
178 break;
179 }
180 }
181 }
182 }
183 if ( !bAttributesAppliedFromGallery )
184 {
185 pObj->SetMergedItem( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
189 static_cast<SdrObjCustomShape*>(pObj)->MergeDefaultAttributes( &aCustomShape );
190 }
191}
192
193// #i33136#
195{
197}
198
199/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetValue() const
void SetAttributes(SdrObject *pObj)
virtual void Deactivate() override
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
virtual void Activate() override
virtual ~FuConstCustomShape() override
virtual rtl::Reference< SdrObject > CreateDefaultObject(const sal_uInt16 nID, const tools::Rectangle &rRectangle) override
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
FuConstCustomShape(ScTabViewShell &rViewSh, vcl::Window *pWin, ScDrawView *pView, SdrModel *pDoc, const SfxRequest &rReq)
virtual bool doConstructOrthogonal() const override
Draw rectangle.
Definition: fuconstr.hxx:28
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:128
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:46
PointerStyle aNewPointer
Definition: fudraw.hxx:30
PointerStyle aOldPointer
Definition: fudraw.hxx:31
ScDrawView * pView
Definition: fupoor.hxx:42
virtual void Activate()
Definition: fupoor.cxx:61
void SetMouseButtonCode(sal_uInt16 nNew)
Definition: fupoor.hxx:70
static void ImpForceQuadratic(tools::Rectangle &rRect)
Definition: fupoor.cxx:224
SdrModel * pDrDoc
Definition: fupoor.hxx:45
virtual void Deactivate()
Definition: fupoor.cxx:65
ScTabViewShell & rViewShell
Definition: fupoor.hxx:43
VclPtr< vcl::Window > pWindow
Definition: fupoor.hxx:44
static sal_uInt32 GetSdrObjCount(std::u16string_view rThemeName)
static bool FillObjListTitle(const sal_uInt32 nThemeId, std::vector< OUString > &rList)
static bool GetSdrObj(std::u16string_view rThemeName, sal_uInt32 nSdrModelPos, SdrModel *pModel, BitmapEx *pThumb=nullptr)
sal_uInt16 GetButtons() const
const Point & GetPosPixel() const
bool IsLeft() const
void SetActivePointer(PointerStyle nPointer)
Definition: tabview.cxx:885
bool BegCreateObj(const Point &rPnt, OutputDevice *pOut=nullptr, short nMinMov=-3)
bool IsCreateObj() const
bool EndCreateObj(SdrCreateCmd eCmd)
SdrInventor GetCurrentObjInventor() const
SdrObjKind GetCurrentObjIdentifier() const
virtual bool IsAction() const override
void SetCurrentObj(SdrObjKind nIdent, SdrInventor nInvent=SdrInventor::Default)
SdrObject * GetCreateObj() const
const SfxItemPool & GetItemPool() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
static bool doConstructOrthogonal(std::u16string_view rName)
static rtl::Reference< SdrObject > MakeNewObject(SdrModel &rSdrModel, SdrInventor nInventor, SdrObjKind nObjIdentifier, const tools::Rectangle *pSnapRect=nullptr)
SdrObject * GetObj(size_t nNum) const
virtual Degree100 GetRotateAngle() const
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
SdrModel & getSdrModelFromSdrObject() const
virtual const tools::Rectangle & GetSnapRect() const
const SfxItemSet & GetMergedItemSet() const
void SetMergedItem(const SfxPoolItem &rItem)
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs)=0
void FreezeIdRanges()
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
constexpr Point Center() const
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr sal_uInt16 EE_ITEMS_END(EE_FEATURE_END)
constexpr sal_uInt16 EE_ITEMS_START(OWN_ATTR_VALUE_END+1)
std::deque< AttachedObject_Impl > aObjList
#define GALLERY_THEME_POWERPOINT
int i
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
SDRTEXTVERTADJUST_CENTER
SDRTEXTHORZADJUST_BLOCK
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
constexpr sal_uInt16 SDRATTR_CUSTOMSHAPE_LAST(SDRATTR_CUSTOMSHAPE_GEOMETRY)
constexpr sal_uInt16 SDRATTR_MISC_LAST(SDRATTR_TEXT_CLIPVERTOVERFLOW)
constexpr sal_uInt16 SDRATTR_MISC_FIRST(SDRATTR_CAPTION_LAST+1)
constexpr sal_uInt16 SDRATTR_GRAF_FIRST(SDRATTR_NOTPERSIST_LAST+1)
constexpr sal_uInt16 SDRATTR_SHADOW_LAST(SDRATTR_SHADOWALIGNMENT)
constexpr TypedWhichId< SvxWritingModeItem > SDRATTR_TEXTDIRECTION(SDRATTR_NOTPERSIST_FIRST+34)