LibreOffice Module sw (master) 1
concustomshape.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 <svx/svdobj.hxx>
21#include <svx/sdtagitm.hxx>
22#include <svx/svdview.hxx>
23#include <editeng/eeitem.hxx>
24#include <view.hxx>
25#include <edtwin.hxx>
26#include <wrtsh.hxx>
27#include <drawbase.hxx>
28#include <concustomshape.hxx>
29#include <svx/gallery.hxx>
30#include <sfx2/request.hxx>
31#include <svx/fmmodel.hxx>
32#include <svl/itempool.hxx>
33#include <svl/stritem.hxx>
34#include <svx/svdpage.hxx>
35#include <svx/svdoashp.hxx>
36#include <svx/xfillit0.hxx>
38
39using namespace com::sun::star;
40
41ConstCustomShape::ConstCustomShape( SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView, SfxRequest const & rReq )
42 : SwDrawBase( pWrtShell, pEditWin, pSwView )
43{
45}
46
47const OUString& ConstCustomShape::GetShapeType() const
48{
49 return m_aCustomShape;
50}
51
53{
54 OUString aRet;
55 const SfxItemSet* pArgs = rReq.GetArgs();
56 if ( pArgs )
57 {
58 const SfxStringItem& rItm = static_cast<const SfxStringItem&>(pArgs->Get( rReq.GetSlot() ));
59 aRet = rItm.GetValue();
60 }
61 return aRet;
62}
63
65{
66 bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
67 if ( bReturn )
68 {
69 SdrView *pSdrView = m_pSh->GetDrawView();
70 if ( pSdrView )
71 {
72 SdrObject* pObj = pSdrView->GetCreateObj();
73 if ( pObj )
74 {
75 SetAttributes( pObj );
76 bool bForceNoFillStyle = false;
77 if ( static_cast<SdrObjCustomShape*>(pObj)->UseNoFillStyle() )
78 bForceNoFillStyle = true;
79
80 SfxItemSet aAttr( m_pView->GetPool() );
81 if ( bForceNoFillStyle )
82 aAttr.Put( XFillStyleItem( drawing::FillStyle_NONE ) );
83 pObj->SetMergedItemSet(aAttr);
84 }
85 }
86 }
87 return bReturn;
88}
89
90void ConstCustomShape::Activate(const sal_uInt16 nSlotId)
91{
92 m_pWin->SetSdrDrawMode( SdrObjKind::CustomShape );
93
94 SwDrawBase::Activate(nSlotId);
95}
96
97// applying attributes
98
100{
101 bool bAttributesAppliedFromGallery = false;
102
104 {
105 std::vector< OUString > aObjList;
107 {
108 for ( std::vector<OUString>::size_type i = 0; i < aObjList.size(); i++ )
109 {
111 {
112 FmFormModel aFormModel;
113 SfxItemPool& rPool(aFormModel.GetItemPool());
114 rPool.FreezeIdRanges();
115
117 {
118 const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
119 if( pSourceObj )
120 {
121 const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
123 // Ranges from SdrAttrObj:
128 // Graphic attributes, 3D properties,
129 // CustomShape properties:
132 // Range from SdrTextObj:
134 aDest( pObj->getSdrModelFromSdrObject().GetItemPool() );
135 aDest.Set( rSource );
136 pObj->SetMergedItemSet( aDest );
137 Degree100 nAngle = pSourceObj->GetRotateAngle();
138 if ( nAngle )
139 pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle );
140 bAttributesAppliedFromGallery = true;
141 }
142 }
143 break;
144 }
145 }
146 }
147 }
148 if ( !bAttributesAppliedFromGallery )
149 {
150 pObj->SetMergedItem( SvxAdjustItem( SvxAdjust::Center, RES_PARATR_ADJUST ) );
154 static_cast<SdrObjCustomShape*>(pObj)->MergeDefaultAttributes( &m_aCustomShape );
155 }
156}
157
159{
161 SdrView *pSdrView = m_pSh->GetDrawView();
162 if ( pSdrView )
163 {
164 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
165 if ( rMarkList.GetMarkCount() == 1 )
166 {
167 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
168 if ( dynamic_cast< const SdrObjCustomShape *>( pObj ) )
169 SetAttributes( pObj );
170 }
171 }
172}
173
175{
177 SdrView *pSdrView = m_pSh->GetDrawView();
178 if ( pSdrView )
179 {
180 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
181 if ( rMarkList.GetMarkCount() == 1 )
182 {
183 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
184 if ( dynamic_cast< const SdrObjCustomShape *>( pObj ) )
185 SetAttributes( pObj );
186 }
187 }
188}
189
190// #i33136#
192{
194}
195
196/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetValue() const
virtual bool doConstructOrthogonal() const override
virtual void Activate(const sal_uInt16 nSlotId) override
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
virtual void CreateDefaultObject() override
ConstCustomShape(SwWrtShell *pSh, SwEditWin *pWin, SwView *pView, SfxRequest const &rReq)
void SetAttributes(SdrObject *pObj)
static OUString GetShapeTypeFromRequest(SfxRequest const &rReq)
const OUString & GetShapeType() const
virtual void CreateDefaultObjectAtPosWithSize(Point aPos, Size aSize) override
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)
SdrObject * GetCreateObj() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
const SdrMarkList & GetMarkedObjectList() const
SdrObject * GetMarkedSdrObj() const
const SfxItemPool & GetItemPool() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
static bool doConstructOrthogonal(std::u16string_view rName)
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 * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
SfxItemPool & GetPool() const
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:432
SwWrtShell * m_pSh
Definition: drawbase.hxx:36
SwView * m_pView
Definition: drawbase.hxx:35
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
virtual void CreateDefaultObjectAtPosWithSize(Point aPos, Size aSize)
Definition: drawbase.cxx:531
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: drawbase.cxx:62
virtual void CreateDefaultObject()
Definition: drawbase.cxx:517
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
SdrView * GetDrawView()
Definition: vnew.cxx:386
Definition: view.hxx:146
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
constexpr Point Center() const
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
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
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)