LibreOffice Module sd (master) 1
drviews6.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 <config_features.h>
21
22#include <DrawViewShell.hxx>
23#include <sfx2/request.hxx>
24#include <vcl/svapp.hxx>
25#include <vcl/weld.hxx>
26#include <sfx2/viewfrm.hxx>
27#include <svx/svdograf.hxx>
28#include <svx/svxids.hrc>
29#include <svx/fontwork.hxx>
30#include <svx/bmpmask.hxx>
31#include <svx/imapdlg.hxx>
33#include <svx/f3dchild.hxx>
35#include <svl/intitem.hxx>
36
37#include <app.hrc>
38#include <strings.hrc>
39
40#include <animobjs.hxx>
42#include <sdresid.hxx>
43#include <drawdoc.hxx>
44#include <drawview.hxx>
45#include <svx/svdoashp.hxx>
46
47namespace sd {
48
53{
54 // nothing is executed during a slide show!
55 if(HasCurrentFunction(SID_PRESENTATION))
56 return;
57
58 CheckLineTo (rReq);
59
60 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
61
62 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() &&
63 !mpDrawView->IsPresObjSelected() )
64 {
65 const SfxItemSet& rSet = *rReq.GetArgs();
66
67 if ( mpDrawView->IsTextEdit() )
68 mpDrawView->SdrEndTextEdit();
69
70 mpDrawView->SetAttributes(rSet);
71 }
72}
73
78{
79 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
80 const SdrObject* pObj = nullptr;
81
82 if ( rMarkList.GetMarkCount() == 1 )
83 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
84
85 const SdrTextObj* pTextObj = DynCastSdrTextObj(pObj);
86 const bool bDeactivate(
87 !pObj ||
88 !pTextObj ||
89 !pTextObj->HasText() ||
90 dynamic_cast< const SdrObjCustomShape* >(pObj)); // #121538# no FontWork for CustomShapes
91
92 if(bDeactivate)
93 {
94// automatic open/close the FontWork-Dialog; first deactivate it
95
107 }
108 else
109 {
110 SfxItemSet aSet( GetDoc()->GetPool() );
111 mpDrawView->GetAttributes( aSet );
112 rSet.Set( aSet );
113 }
114}
115
117{
118 // nothing is executed during a slide show!
119 if (HasCurrentFunction(SID_PRESENTATION))
120 return;
121
122 CheckLineTo (rReq);
123
124 sal_uInt16 nSId = rReq.GetSlot();
125
126 switch( nSId )
127 {
128 case SID_ANIMATOR_INIT:
129 case SID_ANIMATOR_ADD:
130 case SID_ANIMATOR_CREATE:
131 {
132 AnimationWindow* pAnimWin;
133 sal_uInt16 nId = AnimationChildWindow::GetChildWindowId();
134
136
137 pAnimWin = pWnd ? static_cast<AnimationWindow*>(pWnd->GetWindow()) : nullptr;
138
139 if ( pAnimWin )
140 {
141 if( nSId == SID_ANIMATOR_ADD )
142 pAnimWin->AddObj( *mpDrawView );
143 else if( nSId == SID_ANIMATOR_CREATE )
144 pAnimWin->CreateAnimObj( *mpDrawView );
145 }
146 }
147 break;
148
149 default:
150 break;
151 }
152}
153
163{
164 // here we could disable buttons etc.
165 sal_uInt16 nValue;
166
167 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
168 const size_t nMarkCount = rMarkList.GetMarkCount();
169
170 if( nMarkCount == 0 )
171 nValue = 0;
172 else if( nMarkCount > 1 )
173 nValue = 3;
174 else // 1 Object
175 {
176 const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
177 SdrInventor nInv = pObj->GetObjInventor();
179 // 1 selected group object
180 if( nInv == SdrInventor::Default && nId == SdrObjKind::Group )
181 nValue = 3;
182 else if( nInv == SdrInventor::Default && nId == SdrObjKind::Graphic ) // Animated GIF ?
183 {
184 sal_uInt16 nCount = 0;
185
186 if( static_cast<const SdrGrafObj*>(pObj)->IsAnimated() )
187 nCount = static_cast<const SdrGrafObj*>(pObj)->GetGraphic().GetAnimation().Count();
188 if( nCount > 0 )
189 nValue = 2;
190 else
191 nValue = 1;
192 }
193 else
194 nValue = 1;
195 }
196 rSet.Put( SfxUInt16Item( SID_ANIMATOR_STATE, nValue ) );
197}
198
200{
201 // State of SfxChild-Windows (Animator, Fontwork etc.)
202 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_FONTWORK ) )
203 {
204 sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
205 rSet.Put(SfxBoolItem(SID_FONTWORK, GetViewFrame()->HasChildWindow(nId)));
206 }
207 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_COLOR_CONTROL ) )
208 {
209 sal_uInt16 nId = SvxColorChildWindow::GetChildWindowId();
210 rSet.Put(SfxBoolItem(SID_COLOR_CONTROL, GetViewFrame()->HasChildWindow(nId)));
211 }
212 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ANIMATION_OBJECTS ) )
213 {
214 sal_uInt16 nId = AnimationChildWindow::GetChildWindowId();
215 rSet.Put( SfxBoolItem( SID_ANIMATION_OBJECTS, GetViewFrame()->HasChildWindow( nId ) ) );
216 }
217 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_NAVIGATOR ) )
218 {
219 rSet.Put( SfxBoolItem( SID_NAVIGATOR, GetViewFrame()->HasChildWindow( SID_NAVIGATOR ) ) );
220 }
221 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_BMPMASK ) )
222 {
223 sal_uInt16 nId = SvxBmpMaskChildWindow::GetChildWindowId();
224 rSet.Put( SfxBoolItem( SID_BMPMASK, GetViewFrame()->HasChildWindow( nId ) ) );
225 }
226 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_IMAP ) )
227 {
228 sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
229 rSet.Put( SfxBoolItem( SID_IMAP, GetViewFrame()->HasChildWindow( nId ) ) );
230 }
231 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_3D_WIN ) )
232 {
233 sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
234 rSet.Put( SfxBoolItem( SID_3D_WIN, GetViewFrame()->HasChildWindow( nId ) ) );
235 }
236#if HAVE_FEATURE_AVMEDIA
237 if( SfxItemState::DEFAULT == rSet.GetItemState( SID_AVMEDIA_PLAYER ) )
238 {
239 sal_uInt16 nId = ::avmedia::MediaPlayer::GetChildWindowId();
240 rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) );
241 }
242#endif
243}
244
249{
250 // nothing is executed during a slide show!
251 if (HasCurrentFunction(SID_PRESENTATION))
252 return;
253
254 switch ( rReq.GetSlot() )
255 {
256 case SID_BMPMASK_PIPETTE :
257 {
258 mbPipette = rReq.GetArgs()->Get( SID_BMPMASK_PIPETTE ).GetValue();
259 }
260 break;
261
262 case SID_BMPMASK_EXEC :
263 {
264 SdrGrafObj* pObj = nullptr;
265 if( mpDrawView && mpDrawView->GetMarkedObjectList().GetMarkCount() )
266 pObj = dynamic_cast< SdrGrafObj* >( mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() );
267
268 if ( pObj && !mpDrawView->IsTextEdit() )
269 {
271 bool bCont = true;
272
273 if (xNewObj->IsLinkedGraphic())
274 {
275 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/sdraw/ui/queryunlinkimagedialog.ui"));
276 std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryUnlinkImageDialog"));
277
278 if (RET_YES == xQueryBox->run())
279 xNewObj->ReleaseGraphicLink();
280 else
281 bCont = false;
282 }
283
285 SvxBmpMaskChildWindow::GetChildWindowId());
286 SvxBmpMask* pBmpMask = pWnd ? static_cast<SvxBmpMask*>(pWnd->GetWindow()) : nullptr;
287 assert(pBmpMask);
288 if (bCont && pBmpMask)
289 {
290 const Graphic& rOldGraphic = xNewObj->GetGraphic();
291 const Graphic aNewGraphic(pBmpMask->Mask(rOldGraphic));
292
293 if( aNewGraphic != rOldGraphic )
294 {
295 SdrPageView* pPV = mpDrawView->GetSdrPageView();
296
297 xNewObj->SetEmptyPresObj(false);
298 xNewObj->SetGraphic(pBmpMask->Mask(xNewObj->GetGraphic()));
299
300 OUString aStr = mpDrawView->GetDescriptionOfMarkedObjects() +
301 " " + SdResId(STR_EYEDROPPER);
302
303 mpDrawView->BegUndo( aStr );
304 mpDrawView->ReplaceObjectAtView(pObj, *pPV, xNewObj.get());
305 mpDrawView->EndUndo();
306 }
307 }
308 }
309 }
310 break;
311
312 default:
313 break;
314 }
315}
316
318{
319 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
320 const SdrObject* pObj = nullptr;
321 bool bEnable = false;
322
323 if ( rMarkList.GetMarkCount() == 1 )
324 pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
325
326 // valid graphic object?
327 if( auto pGrafObj = dynamic_cast< const SdrGrafObj *>( pObj ) )
328 if (!pGrafObj->IsEPS() && !mpDrawView->IsTextEdit() )
329 bEnable = true;
330
331 // put value
332 rSet.Put( SfxBoolItem( SID_BMPMASK_EXEC, bEnable ) );
333}
334
335} // end of namespace sd
336
337/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrObject * GetMarkedSdrObj() const
virtual SdrInventor GetObjInventor() const
static rtl::Reference< T > Clone(T const &rObj, SdrModel &rTargetModel)
SdrModel & getSdrModelFromSdrObject() const
virtual SdrObjKind GetObjIdentifier() const
virtual bool HasText() const override
vcl::Window * GetWindow() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
bool Set(const SfxItemSet &, bool bDeep=true)
void DisableItem(sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
SfxItemPool & GetPool() const
SfxChildWindow * GetChildWindow(sal_uInt16)
Graphic Mask(const Graphic &rGraphic)
void CreateAnimObj(::sd::View &rView)
Definition: animobjs.cxx:865
void AddObj(::sd::View &rView)
Definition: animobjs.cxx:686
static void CheckLineTo(SfxRequest &rReq)
check if we have to draw a polyline
Definition: drviewsa.cxx:404
std::unique_ptr< DrawView > mpDrawView
void GetBmpMaskState(SfxItemSet &rSet)
Definition: drviews6.cxx:317
void ExecBmpMask(SfxRequest const &rReq)
Handle SfxRequests for pipette.
Definition: drviews6.cxx:248
void ExecFormText(SfxRequest &rReq)
handle SfxRequests for FontWork
Definition: drviews6.cxx:52
void SetChildWindowState(SfxItemSet &rSet)
Definition: drviews6.cxx:199
void ExecAnimationWin(SfxRequest &rReq)
Definition: drviews6.cxx:116
void GetFormTextState(SfxItemSet &rSet)
Return state values for FontWork.
Definition: drviews6.cxx:77
void GetAnimationWinState(SfxItemSet &rSet)
Return status values for animator.
Definition: drviews6.cxx:162
static bool mbPipette
SdDrawDocument * GetDoc() const
Definition: viewshel.cxx:1412
SD_DLLPUBLIC weld::Window * GetFrameWeld() const
Definition: viewshel.cxx:1582
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
bool HasCurrentFunction() const
Definition: ViewShell.hxx:252
int nCount
sal_Int16 nValue
aStr
sal_Int16 nId
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
static SfxItemSet & rSet
SdrInventor
SVXCORE_DLLPUBLIC SdrTextObj * DynCastSdrTextObj(SdrObject *)
SdrObjKind
RET_YES
constexpr TypedWhichId< XFormTextMirrorItem > XATTR_FORMTXTMIRROR(XATTR_TEXT_FIRST+4)
constexpr TypedWhichId< XFormTextStyleItem > XATTR_FORMTXTSTYLE(XATTR_TEXT_FIRST)
constexpr TypedWhichId< XFormTextStartItem > XATTR_FORMTXTSTART(XATTR_TEXT_FIRST+3)
constexpr TypedWhichId< XFormTextShadowYValItem > XATTR_FORMTXTSHDWYVAL(XATTR_TEXT_FIRST+9)
constexpr TypedWhichId< XFormTextHideFormItem > XATTR_FORMTXTHIDEFORM(XATTR_TEXT_FIRST+10)
constexpr TypedWhichId< XFormTextDistanceItem > XATTR_FORMTXTDISTANCE(XATTR_TEXT_FIRST+2)
constexpr TypedWhichId< XFormTextShadowItem > XATTR_FORMTXTSHADOW(XATTR_TEXT_FIRST+6)
constexpr TypedWhichId< XFormTextOutlineItem > XATTR_FORMTXTOUTLINE(XATTR_TEXT_FIRST+5)
constexpr TypedWhichId< XFormTextShadowXValItem > XATTR_FORMTXTSHDWXVAL(XATTR_TEXT_FIRST+8)
constexpr TypedWhichId< XFormTextShadowColorItem > XATTR_FORMTXTSHDWCOLOR(XATTR_TEXT_FIRST+7)
constexpr TypedWhichId< XFormTextAdjustItem > XATTR_FORMTXTADJUST(XATTR_TEXT_FIRST+1)