drawsh.cxx (261e9a4b) drawsh.cxx (52f1c2ee)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 37 unchanged lines hidden (view full) ---

46#include <IDocumentStatistics.hxx>
47
48#include <comphelper/processfactory.hxx>
49#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
50
51#include <svx/xtable.hxx>
52#include <sfx2/sidebar/EnumContext.hxx>
53#include <svx/svdoashp.hxx>
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 37 unchanged lines hidden (view full) ---

46#include <IDocumentStatistics.hxx>
47
48#include <comphelper/processfactory.hxx>
49#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
50
51#include <svx/xtable.hxx>
52#include <sfx2/sidebar/EnumContext.hxx>
53#include <svx/svdoashp.hxx>
54#include <svx/svdoole2.hxx>
55#include <sfx2/opengrf.hxx>
56#include <svx/svdograf.hxx>
57#include <svx/svdundo.hxx>
58#include <svx/xbtmpit.hxx>
54
55#include "swundo.hxx"
56#include "wrtsh.hxx"
57#include "cmdid.h"
58#include "globals.hrc"
59#include "helpid.h"
60#include "popup.hrc"
61#include "shells.hrc"

--- 18 unchanged lines hidden (view full) ---

80
81TYPEINIT1(SwDrawShell,SwDrawBaseShell)
82
83/*--------------------------------------------------------------------
84 Beschreibung:
85 --------------------------------------------------------------------*/
86
87
59
60#include "swundo.hxx"
61#include "wrtsh.hxx"
62#include "cmdid.h"
63#include "globals.hrc"
64#include "helpid.h"
65#include "popup.hrc"
66#include "shells.hrc"

--- 18 unchanged lines hidden (view full) ---

85
86TYPEINIT1(SwDrawShell,SwDrawBaseShell)
87
88/*--------------------------------------------------------------------
89 Beschreibung:
90 --------------------------------------------------------------------*/
91
92
93// #123922# check as the name implies
94SdrObject* SwDrawShell::IsSingleFillableNonOLESelected()
95{
96 SwWrtShell &rSh = GetShell();
97 SdrView* pSdrView = rSh.GetDrawView();
98
99 if(!pSdrView)
100 {
101 return 0;
102 }
103
104 if(1 != pSdrView->GetMarkedObjectCount())
105 {
106 return 0;
107 }
108
109 SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
110
111 if(!pPickObj)
112 {
113 return 0;
114 }
115
116 if(!pPickObj->IsClosedObj())
117 {
118 return 0;
119 }
120
121 if(dynamic_cast< SdrOle2Obj* >(pPickObj))
122 {
123 return 0;
124 }
125
126 return pPickObj;
127}
128
129// #123922# insert given graphic data dependent of the object type in focus
130void SwDrawShell::InsertPictureFromFile(SdrObject& rObject)
131{
132 SwWrtShell &rSh = GetShell();
133 SdrView* pSdrView = rSh.GetDrawView();
134
135 if(pSdrView)
136 {
137 SvxOpenGraphicDialog aDlg(SW_RESSTR(STR_INSERT_GRAPHIC));
138
139 if(GRFILTER_OK == aDlg.Execute())
140 {
141 Graphic aGraphic;
142 int nError(aDlg.GetGraphic(aGraphic));
143
144 if(GRFILTER_OK == nError)
145 {
146 const bool bAsLink(aDlg.IsAsLink());
147 SdrObject* pResult = &rObject;
148
149 rSh.StartUndo(UNDO_PASTE_CLIPBOARD);
150
151 if(dynamic_cast< SdrGrafObj* >(&rObject))
152 {
153 SdrGrafObj* pNewGrafObj = (SdrGrafObj*)rObject.Clone();
154
155 pNewGrafObj->SetGraphic(aGraphic);
156
157 // #123922# for handling MasterObject and virtual ones correctly, SW
158 // wants us to call ReplaceObject at the page, but that also
159 // triggers the same assertion (I tried it), so stay at the view method
160 pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj);
161
162 // set in all cases - the Clone() will have copied an existing link (!)
163 pNewGrafObj->SetGraphicLink(
164 bAsLink ? aDlg.GetPath() : String(),
165 bAsLink ? aDlg.GetCurrentFilter() : String());
166
167 pResult = pNewGrafObj;
168 }
169 else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject))
170 {
171 pSdrView->AddUndo(new SdrUndoAttrObj(rObject));
172
173 SfxItemSet aSet(pSdrView->GetModel()->GetItemPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
174
175 aSet.Put(XFillStyleItem(XFILL_BITMAP));
176 aSet.Put(XFillBitmapItem(String(), aGraphic));
177 rObject.SetMergedItemSetAndBroadcast(aSet);
178 }
179
180 rSh.EndUndo( UNDO_END );
181
182 if(pResult)
183 {
184 // we are done; mark the modified/new object
185 pSdrView->MarkObj(pResult, pSdrView->GetSdrPageView());
186 }
187 }
188 }
189 }
190}
191
88void SwDrawShell::Execute(SfxRequest &rReq)
89{
90 SwWrtShell &rSh = GetShell();
91 SdrView *pSdrView = rSh.GetDrawView();
92 const SfxItemSet *pArgs = rReq.GetArgs();
93 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
94 sal_uInt16 nSlotId = rReq.GetSlot();
95 sal_Bool bChanged = pSdrView->GetModel()->IsChanged();

--- 184 unchanged lines hidden (view full) ---

280 case SID_FONTWORK_KERN_CHARACTER_PAIRS:
281 case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
282 case SID_FONTWORK_ALIGNMENT_FLOATER:
283 case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
284 svx::FontworkBar::execute( pSdrView, rReq, rBnd );
285 rReq.Ignore ();
286 break;
287
192void SwDrawShell::Execute(SfxRequest &rReq)
193{
194 SwWrtShell &rSh = GetShell();
195 SdrView *pSdrView = rSh.GetDrawView();
196 const SfxItemSet *pArgs = rReq.GetArgs();
197 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings();
198 sal_uInt16 nSlotId = rReq.GetSlot();
199 sal_Bool bChanged = pSdrView->GetModel()->IsChanged();

--- 184 unchanged lines hidden (view full) ---

384 case SID_FONTWORK_KERN_CHARACTER_PAIRS:
385 case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
386 case SID_FONTWORK_ALIGNMENT_FLOATER:
387 case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
388 svx::FontworkBar::execute( pSdrView, rReq, rBnd );
389 rReq.Ignore ();
390 break;
391
392 case SID_INSERT_GRAPHIC:
393 {
394 // #123922# check if we can do something
395 SdrObject* pObj = IsSingleFillableNonOLESelected();
396
397 if(pObj)
398 {
399 // ...and if yes, do something
400 InsertPictureFromFile(*pObj);
401 bool bBla = true;
402 }
403
404 break;
405 }
406
288 default:
289 DBG_ASSERT(!this, "falscher Dispatcher");
290 return;
291 }
292 if (pSdrView->GetModel()->IsChanged())
293 rSh.SetModified();
294 else if (bChanged)
295 pSdrView->GetModel()->SetChanged(sal_True);
296}
297
298/*--------------------------------------------------------------------
299 Beschreibung:
300 --------------------------------------------------------------------*/
301
407 default:
408 DBG_ASSERT(!this, "falscher Dispatcher");
409 return;
410 }
411 if (pSdrView->GetModel()->IsChanged())
412 rSh.SetModified();
413 else if (bChanged)
414 pSdrView->GetModel()->SetChanged(sal_True);
415}
416
417/*--------------------------------------------------------------------
418 Beschreibung:
419 --------------------------------------------------------------------*/
420
302
303
304void SwDrawShell::GetState(SfxItemSet& rSet)
305{
306 SwWrtShell &rSh = GetShell();
307 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
308 SfxWhichIter aIter( rSet );
309 sal_uInt16 nWhich = aIter.FirstWhich();
310 sal_Bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
311

--- 66 unchanged lines hidden (view full) ---

378 rSet.DisableItem( nWhich );
379 else
380 {
381 const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
382 rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId)));
383 }
384 }
385 break;
421void SwDrawShell::GetState(SfxItemSet& rSet)
422{
423 SwWrtShell &rSh = GetShell();
424 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList();
425 SfxWhichIter aIter( rSet );
426 sal_uInt16 nWhich = aIter.FirstWhich();
427 sal_Bool bProtected = rSh.IsSelObjProtected(FLYPROTECT_CONTENT);
428

--- 66 unchanged lines hidden (view full) ---

495 rSet.DisableItem( nWhich );
496 else
497 {
498 const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
499 rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId)));
500 }
501 }
502 break;
503
504 case SID_INSERT_GRAPHIC:
505 {
506 // #123922# check if we can do something
507 SdrObject* pObj = IsSingleFillableNonOLESelected();
508
509 if(!pObj)
510 {
511 rSet.DisableItem(nWhich);
512 }
513
514 break;
515 }
386 }
387 nWhich = aIter.NextWhich();
388 }
389 svx::ExtrusionBar::getState( pSdrView, rSet );
390 svx::FontworkBar::getState( pSdrView, rSet );
391}
392
393/*--------------------------------------------------------------------

--- 104 unchanged lines hidden ---
516 }
517 nWhich = aIter.NextWhich();
518 }
519 svx::ExtrusionBar::getState( pSdrView, rSet );
520 svx::FontworkBar::getState( pSdrView, rSet );
521}
522
523/*--------------------------------------------------------------------

--- 104 unchanged lines hidden ---