LibreOffice Module sd (master) 1
fuconcs.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 <fuconcs.hxx>
21#include <rtl/ustring.hxx>
22
23#include <svx/svxids.hrc>
24
25#include <sfx2/viewfrm.hxx>
26#include <sfx2/dispatch.hxx>
27#include <sfx2/request.hxx>
29#include <editeng/eeitem.hxx>
30#include <svx/svdoashp.hxx>
31#include <svx/sdtagitm.hxx>
32
33#include <ViewShell.hxx>
34#include <ViewShellBase.hxx>
35#include <ToolBarManager.hxx>
36#include <svx/gallery.hxx>
37#include <svx/sdooitm.hxx>
38#include <svl/itempool.hxx>
39#include <svl/stritem.hxx>
40
41#include <View.hxx>
42#include <Window.hxx>
43#include <drawdoc.hxx>
44
45namespace sd {
46
47
49 ViewShell* pViewSh,
50 ::sd::Window* pWin,
51 ::sd::View* pView,
52 SdDrawDocument* pDoc,
53 SfxRequest& rReq ) :
54 FuConstruct(pViewSh, pWin, pView, pDoc, rReq)
55{
56}
57
59{
61 rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructCustomShape( pViewSh, pWin, pView, pDoc, rReq ) );
62 xFunc->DoExecute(rReq);
63 pFunc->SetPermanent( bPermanent );
64 return xFunc;
65}
66
68{
70
71 const SfxItemSet* pArgs = rReq.GetArgs();
72 if ( pArgs )
73 {
74 const SfxStringItem& rItm = static_cast<const SfxStringItem&>(pArgs->Get( rReq.GetSlot() ));
75 aCustomShape = rItm.GetValue();
76 }
77
81}
82
84{
85 bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
86
87 if ( rMEvt.IsLeft() && !mpView->IsAction() )
88 {
89 Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
90
91 mpWindow->CaptureMouse();
92 sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
93
94 mpView->BegCreateObj(aPnt, nullptr, nDrgLog);
95
96 SdrObject* pObj = mpView->GetCreateObj();
97 if ( pObj )
98 {
99 SetAttributes( pObj );
100 bool bForceFillStyle = true;
101 bool bForceNoFillStyle = false;
102 if ( static_cast<SdrObjCustomShape*>(pObj)->UseNoFillStyle() )
103 {
104 bForceFillStyle = false;
105 bForceNoFillStyle = true;
106 }
107 SfxItemSet aAttr(mpDoc->GetPool());
108 SetStyleSheet( aAttr, pObj, bForceFillStyle, bForceNoFillStyle );
109 pObj->SetMergedItemSet(aAttr);
110 }
111 }
112
113 return bReturn;
114}
115
117{
119 return false;
120
121 bool bReturn(false);
122
123 if(mpView->IsCreateObj() && rMEvt.IsLeft())
124 {
125 SdrObject* pObj = mpView->GetCreateObj();
126 if( pObj && mpView->EndCreateObj( SdrCreateCmd::ForceEnd ) )
127 {
128 bReturn = true;
129 }
130 else
131 {
132 //Drag was too small to create object, so insert default object at click pos
133 Point aClickPos(mpWindow->PixelToLogic(rMEvt.GetPosPixel()));
134 sal_uInt32 nDefaultObjectSize(1000);
135 sal_Int32 nCenterOffset(-sal_Int32(nDefaultObjectSize / 2));
136 aClickPos.AdjustX(nCenterOffset);
137 aClickPos.AdjustY(nCenterOffset);
138
140 if(mpView->IsSnapEnabled())
141 aClickPos = mpView->GetSnapPos(aClickPos, pPV);
142
143 ::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize));
144 rtl::Reference<SdrObject> pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle);
145
146 bReturn = mpView->InsertObjectAtView(pObjDefault.get(), *pPV);
147 }
148 }
149 bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
150
151 if (!bPermanent)
152 mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
153
154 return bReturn;
155}
156
158{
159 mpView->SetCurrentObj( SdrObjKind::CustomShape );
161}
162
167{
168 bool bAttributesAppliedFromGallery = false;
169
171 {
172 std::vector< OUString > aObjList;
174 {
175 for ( std::vector<OUString>::size_type i = 0; i < aObjList.size(); i++ )
176 {
178 {
179 FmFormModel aFormModel;
180 SfxItemPool& rPool(aFormModel.GetItemPool());
181 rPool.FreezeIdRanges();
182
184 {
185 const SdrPage* pPage = aFormModel.GetPage( 0 );
186 if ( pPage )
187 {
188 const SdrObject* pSourceObj = pPage->GetObj( 0 );
189 if( pSourceObj )
190 {
191 const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
193 // Ranges from SdrAttrObj:
198 // Graphic attributes, 3D properties,
199 // CustomShape properties:
202 // Range from SdrTextObj:
204 aDest.Set( rSource );
205 pObj->SetMergedItemSet( aDest );
206 // Enables Word-wrap by default (tdf#134369)
208 Degree100 nAngle = pSourceObj->GetRotateAngle();
209 if ( nAngle )
210 pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle );
211 bAttributesAppliedFromGallery = true;
212 }
213 }
214 }
215 break;
216 }
217 }
218 }
219 }
220 if ( !bAttributesAppliedFromGallery )
221 {
222 pObj->SetMergedItem( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
226 static_cast<SdrObjCustomShape*>(pObj)->MergeDefaultAttributes( &aCustomShape );
227 }
228}
229
231{
232 return aCustomShape;
233}
234
235rtl::Reference<SdrObject> FuConstructCustomShape::CreateDefaultObject(const sal_uInt16, const ::tools::Rectangle& rRectangle)
236{
241
242 if( pObj )
243 {
244 ::tools::Rectangle aRect( rRectangle );
245 if ( doConstructOrthogonal() )
246 ImpForceQuadratic( aRect );
247 pObj->SetLogicRect( aRect );
248 SetAttributes( pObj.get() );
249 SfxItemSet aAttr(mpDoc->GetPool());
250 SetStyleSheet(aAttr, pObj.get());
251 pObj->SetMergedItemSet(aAttr);
252 }
253 return pObj;
254}
255
256// #i33136#
258{
260}
261
262} // end of namespace sd
263
264/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & GetValue() const
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)
const Point & GetPosPixel() const
bool IsLeft() const
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
SAL_DLLPRIVATE SfxItemPool & GetPool()
Definition: drawdoc.hxx:237
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
sal_Int32 GetDragThresholdPixels() const
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
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
SdrModel & getSdrModelFromSdrView() const
SdrPageView * GetSdrPageView() const
bool IsSnapEnabled() const
Point GetSnapPos(const Point &rPnt, const SdrPageView *pPV) const
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
void FreezeIdRanges()
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
SfxDispatcher * GetDispatcher()
static rtl::Reference< FuPoor > Create(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq, bool bPermanent)
Definition: fuconcs.cxx:58
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconcs.cxx:116
virtual void Activate() override
activates the function
Definition: fuconcs.cxx:157
virtual rtl::Reference< SdrObject > CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle &rRectangle) override
Definition: fuconcs.cxx:235
FuConstructCustomShape(ViewShell *pViewSh, ::sd::Window *pWin, ::sd::View *pView, SdDrawDocument *pDoc, SfxRequest &rReq)
Definition: fuconcs.cxx:48
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconcs.cxx:83
const OUString & GetShapeType() const
Definition: fuconcs.cxx:230
virtual void DoExecute(SfxRequest &rReq) override
Definition: fuconcs.cxx:67
virtual bool doConstructOrthogonal() const override
Decide if the object to be created should be created orthogonal.
Definition: fuconcs.cxx:257
void SetAttributes(SdrObject *pObj)
set attribute for the object to be created
Definition: fuconcs.cxx:166
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:128
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: fuconstr.cxx:64
virtual void Activate() override
activates the function
Definition: fuconstr.cxx:221
void SetStyleSheet(SfxItemSet &rAttr, SdrObject *pObj)
set style sheet for the object to be created
Definition: fuconstr.cxx:249
bool IsIgnoreUnexpectedMouseButtonUp()
Definition: fuconstr.cxx:233
bool bPermanent
Definition: fudraw.hxx:76
void SetPermanent(bool bSet)
Definition: fudraw.hxx:52
SdDrawDocument * mpDoc
Definition: fupoor.hxx:148
VclPtr< ::sd::Window > mpWindow
Definition: fupoor.hxx:146
static void ImpForceQuadratic(::tools::Rectangle &rRect)
Definition: fupoor.cxx:1018
ViewShell * mpViewShell
Definition: fupoor.hxx:145
sal_uInt16 nSlotId
Definition: fupoor.hxx:150
::sd::View * mpView
Definition: fupoor.hxx:144
virtual void DoExecute(SfxRequest &rReq)
Definition: fupoor.cxx:1129
static constexpr OUStringLiteral msDrawingObjectToolBar
std::shared_ptr< ToolBarManager > const & GetToolBarManager() const
Base class of the stacked shell hierarchy.
Definition: ViewShell.hxx:92
SD_DLLPUBLIC ViewShellBase & GetViewShellBase() const
Definition: viewshel.cxx:1397
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
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
constexpr int nCenterOffset
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 TypedWhichId< SdrOnOffItem > SDRATTR_TEXT_WORDWRAP(SDRATTR_MISC_FIRST+24)
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)