1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <hintids.hxx>
22 #include <tools/urlobj.hxx>
23 #include <vcl/msgbox.hxx>
24 #include <svl/stritem.hxx>
25 #include <svl/whiter.hxx>
26 #include <svl/urihelper.hxx>
27 #include <sfx2/docfile.hxx>
28 #include <sfx2/dispatch.hxx>
30 #include <sfx2/objface.hxx>
31 #include <editeng/sizeitem.hxx>
32 #include <editeng/protitem.hxx>
33 #include <sfx2/request.hxx>
34 #include <sfx2/sidebar/EnumContext.hxx>
35 #include <svl/srchitem.hxx>
36 #include <sfx2/htmlmode.hxx>
37 #include <svx/sdgluitm.hxx>
38 #include <svx/sdgcoitm.hxx>
39 #include <svx/sdggaitm.hxx>
40 #include <svx/sdgtritm.hxx>
41 #include <svx/sdginitm.hxx>
42 #include <svx/sdgmoitm.hxx>
43 #include <editeng/brushitem.hxx>
44 #include <svx/grfflt.hxx>
45 #include <svx/compressgraphicdialog.hxx>
46 #include <vcl/GraphicNativeTransform.hxx>
47 #include <svx/tbxcolor.hxx>
51 #include <viewopt.hxx>
52 #include <swmodule.hxx>
62 #include <usrpref.hxx>
67 #include <svx/extedit.hxx>
68 #include <svx/graphichelper.hxx>
70 #include <sfx2/msg.hxx>
71 #include "swslots.hxx"
73 #include "swabstdlg.hxx"
75 #define TOOLBOX_NAME "colorbar"
79 class SwExternalToolEdit
: public ExternalToolEdit
84 SwExternalToolEdit ( SwWrtShell
* pShell
) :
88 virtual void Update( Graphic
& aGraphic
)
90 m_pShell
->ReRead(aEmptyStr
, aEmptyStr
, (const Graphic
*) &aGraphic
);
95 SFX_IMPL_INTERFACE(SwGrfShell
, SwBaseShell
, SW_RES(STR_SHELLNAME_GRAPHIC
))
97 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU
));
98 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_GRAFIK_TOOLBOX
));
101 void SwGrfShell::Execute(SfxRequest
&rReq
)
103 SwWrtShell
&rSh
= GetShell();
105 sal_uInt16 nSlot
= rReq
.GetSlot();
108 case SID_TWAIN_TRANSFER
:
110 GetView().ExecuteScan( rReq
);
113 case SID_SAVE_GRAPHIC
:
115 const Graphic
*pGraphic
;
116 if(0 != (pGraphic
= rSh
.GetGraphic()))
118 String sGrfNm
, sFilterNm
;
119 rSh
.GetGrfNms( &sGrfNm
, &sFilterNm
);
120 GraphicHelper::ExportGraphic( *pGraphic
, sGrfNm
);
124 case SID_COMPRESS_GRAPHIC
:
126 const Graphic
* pGraphic
= rSh
.GetGraphic();
130 TWIP_TO_MM100(rSh
.GetAnyCurRect(RECT_FLY_EMBEDDED
).Width()),
131 TWIP_TO_MM100(rSh
.GetAnyCurRect(RECT_FLY_EMBEDDED
).Height()));
133 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_GRFATR_CROPGRF
, RES_GRFATR_CROPGRF
);
134 rSh
.GetCurAttr( aSet
);
135 SwCropGrf
aCrop( (const SwCropGrf
&) aSet
.Get(RES_GRFATR_CROPGRF
) );
137 Rectangle
aCropRectangle(
138 TWIP_TO_MM100(aCrop
.GetLeft()),
139 TWIP_TO_MM100(aCrop
.GetTop()),
140 TWIP_TO_MM100(aCrop
.GetRight()),
141 TWIP_TO_MM100(aCrop
.GetBottom()) );
143 Graphic aGraphic
= Graphic( *pGraphic
);
145 CompressGraphicsDialog
aDialog( GetView().GetWindow(), aGraphic
, aSize
, aCropRectangle
, GetView().GetViewFrame()->GetBindings() );
146 if( aDialog
.Execute() == RET_OK
)
148 rSh
.StartAllAction();
149 rSh
.StartUndo(UNDO_START
);
150 Rectangle aScaledCropedRectangle
= aDialog
.GetScaledCropRectangle();
152 aCrop
.SetLeft( MM100_TO_TWIP( aScaledCropedRectangle
.Left() ));
153 aCrop
.SetTop( MM100_TO_TWIP( aScaledCropedRectangle
.Top() ));
154 aCrop
.SetRight( MM100_TO_TWIP( aScaledCropedRectangle
.Right() ));
155 aCrop
.SetBottom( MM100_TO_TWIP( aScaledCropedRectangle
.Bottom() ));
157 Graphic
aCompressedGraphic( aDialog
.GetCompressedGraphic() );
158 rSh
.ReRead(aEmptyStr
, aEmptyStr
, (const Graphic
*) &aCompressedGraphic
);
162 rSh
.EndUndo(UNDO_END
);
168 case SID_EXTERNAL_EDIT
:
170 // When the graphic is selected to be opened via some external tool
171 // for advanced editing
172 GraphicObject
*pGraphicObject
= (GraphicObject
*) rSh
.GetGraphicObj();
173 if(0 != pGraphicObject
)
175 SwExternalToolEdit
* externalToolEdit
= new SwExternalToolEdit( &rSh
);
176 externalToolEdit
->Edit ( pGraphicObject
);
180 case SID_INSERT_GRAPHIC
:
181 case FN_FORMAT_GRAFIC_DLG
:
182 case FN_DRAW_WRAP_DLG
:
184 SwFlyFrmAttrMgr
aMgr( sal_False
, &rSh
, rSh
.IsFrmSelected() ?
185 FRMMGR_TYPE_NONE
: FRMMGR_TYPE_GRF
);
186 const SwViewOption
* pVOpt
= rSh
.GetViewOptions();
187 SwViewOption
aUsrPref( *pVOpt
);
189 SfxItemSet
aSet(GetPool(), RES_FRMATR_BEGIN
, RES_FRMATR_END
-1,
190 RES_GRFATR_MIRRORGRF
, RES_GRFATR_CROPGRF
,
191 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
,
192 SID_ATTR_GRAF_KEEP_ZOOM
, SID_ATTR_GRAF_KEEP_ZOOM
,
193 SID_ATTR_GRAF_FRMSIZE
, SID_ATTR_GRAF_FRMSIZE
,
194 SID_ATTR_GRAF_FRMSIZE_PERCENT
, SID_ATTR_GRAF_FRMSIZE_PERCENT
,
195 SID_ATTR_GRAF_GRAPHIC
, SID_ATTR_GRAF_GRAPHIC
,
196 FN_PARAM_GRF_CONNECT
, FN_PARAM_GRF_CONNECT
,
197 SID_ATTR_PAGE_SIZE
, SID_ATTR_PAGE_SIZE
,
198 FN_GET_PRINT_AREA
, FN_GET_PRINT_AREA
,
199 FN_SET_FRM_NAME
, FN_KEEP_ASPECT_RATIO
,
200 FN_PARAM_GRF_DIALOG
, FN_PARAM_GRF_DIALOG
,
201 SID_DOCFRAME
, SID_DOCFRAME
,
202 SID_HTML_MODE
, SID_HTML_MODE
,
203 FN_SET_FRM_ALT_NAME
, FN_SET_FRM_ALT_NAME
,
206 sal_uInt16 nHtmlMode
= ::GetHtmlMode(GetView().GetDocShell());
207 aSet
.Put(SfxUInt16Item(SID_HTML_MODE
, nHtmlMode
));
208 FieldUnit eMetric
= ::GetDfltMetric((0 != (nHtmlMode
&HTMLMODE_ON
)));
209 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< sal_uInt16
>(eMetric
)) );
211 const SwRect
* pRect
= &rSh
.GetAnyCurRect(RECT_PAGE
);
212 SwFmtFrmSize
aFrmSize( ATT_VAR_SIZE
, pRect
->Width(), pRect
->Height());
213 aFrmSize
.SetWhich( GetPool().GetWhich( SID_ATTR_PAGE_SIZE
) );
214 aSet
.Put( aFrmSize
);
216 aSet
.Put(SfxStringItem(FN_SET_FRM_NAME
, rSh
.GetFlyName()));
217 if ( nSlot
== FN_FORMAT_GRAFIC_DLG
)
220 aSet
.Put( SfxStringItem( FN_SET_FRM_ALT_NAME
, rSh
.GetObjTitle() ) );
223 pRect
= &rSh
.GetAnyCurRect(RECT_PAGE_PRT
);
224 aFrmSize
.SetWidth( pRect
->Width() );
225 aFrmSize
.SetHeight( pRect
->Height() );
226 aFrmSize
.SetWhich( GetPool().GetWhich(FN_GET_PRINT_AREA
) );
227 aSet
.Put( aFrmSize
);
229 aSet
.Put( aMgr
.GetAttrSet() );
230 aSet
.SetParent( aMgr
.GetAttrSet().GetParent() );
232 // At percentage values ​​initialize size
233 SwFmtFrmSize aSizeCopy
= (const SwFmtFrmSize
&)aSet
.Get(RES_FRM_SIZE
);
234 if (aSizeCopy
.GetWidthPercent() && aSizeCopy
.GetWidthPercent() != 0xff)
235 aSizeCopy
.SetWidth(rSh
.GetAnyCurRect(RECT_FLY_EMBEDDED
).Width());
236 if (aSizeCopy
.GetHeightPercent() && aSizeCopy
.GetHeightPercent() != 0xff)
237 aSizeCopy
.SetHeight(rSh
.GetAnyCurRect(RECT_FLY_EMBEDDED
).Height());
238 // and now set the size for "external" tabpages
240 SvxSizeItem
aSzItm( SID_ATTR_GRAF_FRMSIZE
, aSizeCopy
.GetSize() );
243 Size
aSz( aSizeCopy
.GetWidthPercent(), aSizeCopy
.GetHeightPercent() );
244 if( 0xff == aSz
.Width() ) aSz
.Width() = 0;
245 if( 0xff == aSz
.Height() ) aSz
.Height() = 0;
247 aSzItm
.SetSize( aSz
);
248 aSzItm
.SetWhich( SID_ATTR_GRAF_FRMSIZE_PERCENT
);
252 String sGrfNm
, sFilterNm
;
253 rSh
.GetGrfNms( &sGrfNm
, &sFilterNm
);
256 aSet
.Put( SvxBrushItem( INetURLObject::decode( sGrfNm
,
258 INetURLObject::DECODE_UNAMBIGUOUS
,
259 RTL_TEXTENCODING_UTF8
),
261 SID_ATTR_GRAF_GRAPHIC
));
266 const GraphicObject
* pGrfObj
= rSh
.GetGraphicObj();
269 aSet
.Put( SvxBrushItem( *pGrfObj
, GPOS_LT
,
270 SID_ATTR_GRAF_GRAPHIC
) );
273 aSet
.Put( SfxBoolItem( FN_PARAM_GRF_CONNECT
, sGrfNm
.Len() > 0 ) );
275 // get Mirror and Crop
277 SfxItemSet
aTmpSet( rSh
.GetAttrPool(),
278 RES_GRFATR_MIRRORGRF
, RES_GRFATR_CROPGRF
);
280 rSh
.GetCurAttr( aTmpSet
);
284 aSet
.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO
, aUsrPref
.IsKeepRatio()));
285 aSet
.Put(SfxBoolItem( SID_ATTR_GRAF_KEEP_ZOOM
, aUsrPref
.IsGrfKeepZoom()));
287 aSet
.Put(SfxFrameItem( SID_DOCFRAME
, &GetView().GetViewFrame()->GetTopFrame()));
289 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
290 OSL_ENSURE(pFact
, "Dialogdiet fail!");
291 SfxAbstractTabDialog
* pDlg
= pFact
->CreateFrmTabDialog( DLG_FRM_GRF
,
292 GetView().GetViewFrame(),
293 GetView().GetWindow(),
294 aSet
, sal_False
, DLG_FRM_GRF
);
295 OSL_ENSURE(pDlg
, "Dialogdiet fail!");
297 if (nSlot
== FN_DRAW_WRAP_DLG
)
298 pDlg
->SetCurPageId(TP_FRM_WRAP
);
300 if( pDlg
->Execute() )
302 rSh
.StartAllAction();
303 rSh
.StartUndo(UNDO_START
);
304 const SfxPoolItem
* pItem
;
305 SfxItemSet
* pSet
= (SfxItemSet
*)pDlg
->GetOutputItemSet();
307 // change the 2 frmsize SizeItems to the correct SwFrmSizeItem
308 if( SFX_ITEM_SET
== pSet
->GetItemState(
309 SID_ATTR_GRAF_FRMSIZE
, sal_False
, &pItem
))
312 const Size
& rSz
= ((SvxSizeItem
*)pItem
)->GetSize();
313 aSize
.SetWidth( rSz
.Width() );
314 aSize
.SetHeight( rSz
.Height() );
316 if( SFX_ITEM_SET
== pSet
->GetItemState(
317 SID_ATTR_GRAF_FRMSIZE_PERCENT
, sal_False
, &pItem
))
319 const Size
& rRelativeSize
= ((SvxSizeItem
*)pItem
)->GetSize();
320 aSize
.SetWidthPercent( static_cast< sal_uInt8
>( rRelativeSize
.Width() ) );
321 aSize
.SetHeightPercent( static_cast< sal_uInt8
>( rRelativeSize
.Height() ) );
326 // Templates AutoUpdate
327 SwFrmFmt
* pFmt
= rSh
.GetCurFrmFmt();
328 if(pFmt
&& pFmt
->IsAutoUpdateFmt())
330 pFmt
->SetFmtAttr(*pSet
);
331 SfxItemSet
aShellSet(GetPool(), RES_FRM_SIZE
, RES_FRM_SIZE
,
332 RES_SURROUND
, RES_SURROUND
,
333 RES_ANCHOR
, RES_ANCHOR
,
334 RES_VERT_ORIENT
,RES_HORI_ORIENT
,
336 aShellSet
.Put(*pSet
);
337 aMgr
.SetAttrSet(aShellSet
);
341 aMgr
.SetAttrSet(*pSet
);
345 bool bApplyUsrPref
= false;
346 if (SFX_ITEM_SET
== pSet
->GetItemState(
347 FN_KEEP_ASPECT_RATIO
, sal_True
, &pItem
))
349 aUsrPref
.SetKeepRatio(
350 ((const SfxBoolItem
*)pItem
)->GetValue() );
351 bApplyUsrPref
= true;
353 if( SFX_ITEM_SET
== pSet
->GetItemState(
354 SID_ATTR_GRAF_KEEP_ZOOM
, sal_True
, &pItem
))
356 aUsrPref
.SetGrfKeepZoom(
357 ((const SfxBoolItem
*)pItem
)->GetValue() );
358 bApplyUsrPref
= true;
362 SW_MOD()->ApplyUsrPref(aUsrPref
, &GetView());
364 // and now set all the graphic attributes and other stuff
365 if( SFX_ITEM_SET
== pSet
->GetItemState(
366 SID_ATTR_GRAF_GRAPHIC
, sal_True
, &pItem
))
368 if( ((SvxBrushItem
*)pItem
)->GetGraphicLink() )
369 sGrfNm
= *((SvxBrushItem
*)pItem
)->GetGraphicLink();
373 if( ((SvxBrushItem
*)pItem
)->GetGraphicFilter() )
374 sFilterNm
= *((SvxBrushItem
*)pItem
)->GetGraphicFilter();
380 SwDocShell
* pDocSh
= GetView().GetDocShell();
381 SwWait
aWait( *pDocSh
, sal_True
);
382 SfxMedium
* pMedium
= pDocSh
->GetMedium();
385 aAbs
= pMedium
->GetURLObject();
386 rSh
.ReRead( URIHelper::SmartRel2Abs(
388 URIHelper::GetMaybeFileHdl() ),
392 if ( SFX_ITEM_SET
== pSet
->GetItemState(
393 FN_SET_FRM_ALT_NAME
, sal_True
, &pItem
))
396 rSh
.SetObjTitle( ((const SfxStringItem
*)pItem
)->GetValue() );
399 SfxItemSet
aGrfSet( rSh
.GetAttrPool(), RES_GRFATR_BEGIN
,
401 aGrfSet
.Put( *pSet
);
402 if( aGrfSet
.Count() )
403 rSh
.SetAttr( aGrfSet
);
405 rSh
.EndUndo(UNDO_END
);
412 case FN_GRAPHIC_MIRROR_ON_EVEN_PAGES
:
414 SfxItemSet
aSet(rSh
.GetAttrPool(), RES_GRFATR_MIRRORGRF
, RES_GRFATR_MIRRORGRF
);
415 rSh
.GetCurAttr( aSet
);
416 SwMirrorGrf
aGrf((const SwMirrorGrf
&)aSet
.Get(RES_GRFATR_MIRRORGRF
));
417 aGrf
.SetGrfToggle(!aGrf
.IsGrfToggle());
423 OSL_ENSURE(!this, "wrong dispatcher");
428 void SwGrfShell::ExecAttr( SfxRequest
&rReq
)
431 if( CNT_GRF
== GetShell().GetCntType() &&
432 ( GRAPHIC_BITMAP
== ( nGrfType
= GetShell().GetGraphicType()) ||
433 GRAPHIC_GDIMETAFILE
== nGrfType
))
435 SfxItemSet
aGrfSet( GetShell().GetAttrPool(), RES_GRFATR_BEGIN
,
437 const SfxItemSet
*pArgs
= rReq
.GetArgs();
438 const SfxPoolItem
* pItem
;
439 sal_uInt16 nSlot
= rReq
.GetSlot();
440 if( !pArgs
|| SFX_ITEM_SET
!= pArgs
->GetItemState( nSlot
, sal_False
, &pItem
))
445 case SID_FLIP_VERTICAL
:
446 case SID_FLIP_HORIZONTAL
:
448 GetShell().GetCurAttr( aGrfSet
);
449 SwMirrorGrf
aMirror( (SwMirrorGrf
&)aGrfSet
.Get( RES_GRFATR_MIRRORGRF
) );
450 sal_uInt16 nMirror
= aMirror
.GetValue();
451 if ( nSlot
==SID_FLIP_HORIZONTAL
)
454 case RES_MIRROR_GRAPH_DONT
: nMirror
= RES_MIRROR_GRAPH_VERT
;
456 case RES_MIRROR_GRAPH_HOR
: nMirror
= RES_MIRROR_GRAPH_BOTH
;
458 case RES_MIRROR_GRAPH_VERT
: nMirror
= RES_MIRROR_GRAPH_DONT
;
460 case RES_MIRROR_GRAPH_BOTH
: nMirror
= RES_MIRROR_GRAPH_HOR
;
466 case RES_MIRROR_GRAPH_DONT
: nMirror
= RES_MIRROR_GRAPH_HOR
;
468 case RES_MIRROR_GRAPH_VERT
: nMirror
= RES_MIRROR_GRAPH_BOTH
;
470 case RES_MIRROR_GRAPH_HOR
: nMirror
= RES_MIRROR_GRAPH_DONT
;
472 case RES_MIRROR_GRAPH_BOTH
: nMirror
= RES_MIRROR_GRAPH_VERT
;
475 aMirror
.SetValue( nMirror
);
477 aGrfSet
.Put( aMirror
);
481 case SID_ATTR_GRAF_LUMINANCE
:
483 aGrfSet
.Put( SwLuminanceGrf(
484 ((SfxInt16Item
*)pItem
)->GetValue() ));
486 case SID_ATTR_GRAF_CONTRAST
:
488 aGrfSet
.Put( SwContrastGrf(
489 ((SfxInt16Item
*)pItem
)->GetValue() ));
491 case SID_ATTR_GRAF_RED
:
493 aGrfSet
.Put( SwChannelRGrf(
494 ((SfxInt16Item
*)pItem
)->GetValue() ));
496 case SID_ATTR_GRAF_GREEN
:
498 aGrfSet
.Put( SwChannelGGrf(
499 ((SfxInt16Item
*)pItem
)->GetValue() ));
501 case SID_ATTR_GRAF_BLUE
:
503 aGrfSet
.Put( SwChannelBGrf(
504 ((SfxInt16Item
*)pItem
)->GetValue() ));
506 case SID_ATTR_GRAF_GAMMA
:
509 double fVal
= ((SfxUInt32Item
*)pItem
)->GetValue();
510 aGrfSet
.Put( SwGammaGrf(fVal
/100. ));
513 case SID_ATTR_GRAF_TRANSPARENCE
:
515 aGrfSet
.Put( SwTransparencyGrf(
516 static_cast< sal_Int8
>( ( (SfxUInt16Item
*)pItem
)->GetValue() ) ) );
518 case SID_ATTR_GRAF_INVERT
:
520 aGrfSet
.Put( SwInvertGrf(
521 ((SfxBoolItem
*)pItem
)->GetValue() ));
524 case SID_ATTR_GRAF_MODE
:
526 aGrfSet
.Put( SwDrawModeGrf(
527 ((SfxUInt16Item
*)pItem
)->GetValue() ));
530 case SID_COLOR_SETTINGS
:
532 svx::ToolboxAccess
aToolboxAccess( TOOLBOX_NAME
);
533 aToolboxAccess
.toggleToolbox();
537 case SID_GRFFILTER_INVERT
:
538 case SID_GRFFILTER_SMOOTH
:
539 case SID_GRFFILTER_SHARPEN
:
540 case SID_GRFFILTER_REMOVENOISE
:
541 case SID_GRFFILTER_SOBEL
:
542 case SID_GRFFILTER_MOSAIC
:
543 case SID_GRFFILTER_EMBOSS
:
544 case SID_GRFFILTER_POSTER
:
545 case SID_GRFFILTER_POPART
:
546 case SID_GRFFILTER_SEPIA
:
547 case SID_GRFFILTER_SOLARIZE
:
548 if( GRAPHIC_BITMAP
== nGrfType
)
551 const GraphicObject
* pFilterObj( GetShell().GetGraphicObj() );
554 GraphicObject
aFilterObj( *pFilterObj
);
555 if( SVX_GRAPHICFILTER_ERRCODE_NONE
==
556 SvxGraphicFilter::ExecuteGrfFilterSlot( rReq
, aFilterObj
))
557 GetShell().ReRead( aEmptyStr
, aEmptyStr
,
558 &aFilterObj
.GetGraphic() );
564 OSL_ENSURE(!this, "wrong dispatcher");
566 if( aGrfSet
.Count() )
567 GetShell().SetAttr( aGrfSet
);
569 GetView().GetViewFrame()->GetBindings().Invalidate(rReq
.GetSlot());
572 void SwGrfShell::GetAttrState(SfxItemSet
&rSet
)
574 SwWrtShell
&rSh
= GetShell();
575 SfxItemSet
aCoreSet( GetPool(), aNoTxtNodeSetRange
);
576 rSh
.GetCurAttr( aCoreSet
);
577 bool bParentCntProt
= 0 != rSh
.IsSelObjProtected( FLYPROTECT_CONTENT
|FLYPROTECT_PARENT
);
578 bool bIsGrfCntnt
= CNT_GRF
== GetShell().GetCntType();
580 SetGetStateSet( &rSet
);
582 SfxWhichIter
aIter( rSet
);
583 sal_uInt16 nWhich
= aIter
.FirstWhich();
586 bool bDisable
= bParentCntProt
;
589 case SID_INSERT_GRAPHIC
:
590 case FN_FORMAT_GRAFIC_DLG
:
591 case SID_TWAIN_TRANSFER
:
592 if( bParentCntProt
|| !bIsGrfCntnt
)
595 case SID_SAVE_GRAPHIC
:
596 case SID_EXTERNAL_EDIT
:
597 if( rSh
.GetGraphicType() == GRAPHIC_NONE
)
600 case SID_COLOR_SETTINGS
:
602 if ( bParentCntProt
|| !bIsGrfCntnt
)
606 svx::ToolboxAccess
aToolboxAccess( TOOLBOX_NAME
);
607 rSet
.Put( SfxBoolItem( nWhich
, aToolboxAccess
.isToolboxVisible() ) );
612 case SID_FLIP_HORIZONTAL
:
613 if( !bParentCntProt
)
615 MirrorGraph nState
= static_cast< MirrorGraph
>(((const SwMirrorGrf
&) aCoreSet
.Get(
616 RES_GRFATR_MIRRORGRF
)).GetValue());
618 rSet
.Put(SfxBoolItem( nWhich
, nState
== RES_MIRROR_GRAPH_VERT
||
619 nState
== RES_MIRROR_GRAPH_BOTH
));
623 case SID_FLIP_VERTICAL
:
624 if( !bParentCntProt
)
626 MirrorGraph nState
= static_cast< MirrorGraph
>(((const SwMirrorGrf
&) aCoreSet
.Get(
627 RES_GRFATR_MIRRORGRF
)).GetValue());
629 rSet
.Put(SfxBoolItem( nWhich
, nState
== RES_MIRROR_GRAPH_HOR
||
630 nState
== RES_MIRROR_GRAPH_BOTH
));
635 case SID_ATTR_GRAF_LUMINANCE
:
636 if( !bParentCntProt
)
637 rSet
.Put( SfxInt16Item( nWhich
, ((SwLuminanceGrf
&)
638 aCoreSet
.Get(RES_GRFATR_LUMINANCE
)).GetValue() ));
640 case SID_ATTR_GRAF_CONTRAST
:
641 if( !bParentCntProt
)
642 rSet
.Put( SfxInt16Item( nWhich
, ((SwContrastGrf
&)
643 aCoreSet
.Get(RES_GRFATR_CONTRAST
)).GetValue() ));
645 case SID_ATTR_GRAF_RED
:
646 if( !bParentCntProt
)
647 rSet
.Put( SfxInt16Item( nWhich
, ((SwChannelRGrf
&)
648 aCoreSet
.Get(RES_GRFATR_CHANNELR
)).GetValue() ));
650 case SID_ATTR_GRAF_GREEN
:
651 if( !bParentCntProt
)
652 rSet
.Put( SfxInt16Item( nWhich
, ((SwChannelGGrf
&)
653 aCoreSet
.Get(RES_GRFATR_CHANNELG
)).GetValue() ));
655 case SID_ATTR_GRAF_BLUE
:
656 if( !bParentCntProt
)
657 rSet
.Put( SfxInt16Item( nWhich
, ((SwChannelBGrf
&)
658 aCoreSet
.Get(RES_GRFATR_CHANNELB
)).GetValue() ));
661 case SID_ATTR_GRAF_GAMMA
:
662 if( !bParentCntProt
)
663 rSet
.Put( SfxUInt32Item( nWhich
, static_cast< sal_uInt32
>(
664 ( (SwGammaGrf
&)aCoreSet
.Get( RES_GRFATR_GAMMA
) ).GetValue() * 100 ) ) );
666 case SID_ATTR_GRAF_TRANSPARENCE
:
667 if( !bParentCntProt
)
670 const GraphicObject
* pGrafObj
= rSh
.GetGraphicObj();
673 if( pGrafObj
->IsAnimated() ||
674 GRAPHIC_GDIMETAFILE
== pGrafObj
->GetType() )
677 rSet
.Put( SfxUInt16Item( nWhich
, ((SwTransparencyGrf
&)
678 aCoreSet
.Get(RES_GRFATR_TRANSPARENCY
)).GetValue() ));
682 case SID_ATTR_GRAF_INVERT
:
683 if( !bParentCntProt
)
684 rSet
.Put( SfxBoolItem( nWhich
, ((SwInvertGrf
&)
685 aCoreSet
.Get(RES_GRFATR_INVERT
)).GetValue() ));
688 case SID_ATTR_GRAF_MODE
:
689 if( !bParentCntProt
)
690 rSet
.Put( SfxUInt16Item( nWhich
, ((SwDrawModeGrf
&)
691 aCoreSet
.Get(RES_GRFATR_DRAWMODE
)).GetValue() ));
695 case SID_GRFFILTER_INVERT
:
696 case SID_GRFFILTER_SMOOTH
:
697 case SID_GRFFILTER_SHARPEN
:
698 case SID_GRFFILTER_REMOVENOISE
:
699 case SID_GRFFILTER_SOBEL
:
700 case SID_GRFFILTER_MOSAIC
:
701 case SID_GRFFILTER_EMBOSS
:
702 case SID_GRFFILTER_POSTER
:
703 case SID_GRFFILTER_POPART
:
704 case SID_GRFFILTER_SEPIA
:
705 case SID_GRFFILTER_SOLARIZE
:
707 if( bParentCntProt
|| !bIsGrfCntnt
)
709 // #i59688# load graphic only if type is unknown
712 const sal_uInt16
eGraphicType( rSh
.GetGraphicType() );
713 if ( ( eGraphicType
== GRAPHIC_NONE
||
714 eGraphicType
== GRAPHIC_DEFAULT
) &&
715 rSh
.IsGrfSwapOut( sal_True
) )
717 rSet
.DisableItem( nWhich
);
718 if( AddGrfUpdateSlot( nWhich
))
719 rSh
.GetGraphic(sal_False
); // start the loading
723 bDisable
= eGraphicType
!= GRAPHIC_BITMAP
;
734 rSet
.DisableItem( nWhich
);
735 nWhich
= aIter
.NextWhich();
740 void SwGrfShell::ExecuteRotation(SfxRequest
&rReq
)
742 sal_uInt16 aRotation
;
744 SwWrtShell
& rShell
= GetShell();
746 if (rReq
.GetSlot() == SID_ROTATE_GRAPHIC_LEFT
)
750 else if (rReq
.GetSlot() == SID_ROTATE_GRAPHIC_RIGHT
)
759 rShell
.StartAllAction();
760 rShell
.StartUndo(UNDO_START
);
762 Graphic aGraphic
= *rShell
.GetGraphic();
763 GraphicNativeTransform
aTransform(aGraphic
);
764 aTransform
.rotate(aRotation
);
765 rShell
.ReRead(aEmptyStr
, aEmptyStr
, (const Graphic
*) &aGraphic
);
767 SwFlyFrmAttrMgr
aManager(false, &rShell
, rShell
.IsFrmSelected() ? FRMMGR_TYPE_NONE
: FRMMGR_TYPE_GRF
);
768 Size
aSize(aManager
.GetSize().Height(), aManager
.GetSize().Width());
769 aManager
.SetSize(aSize
);
770 aManager
.UpdateFlyFrm();
772 SfxItemSet
aSet( rShell
.GetAttrPool(), RES_GRFATR_CROPGRF
, RES_GRFATR_CROPGRF
);
773 rShell
.GetCurAttr( aSet
);
774 SwCropGrf
aCrop( (const SwCropGrf
&) aSet
.Get(RES_GRFATR_CROPGRF
) );
775 Rectangle
aCropRectangle(aCrop
.GetLeft(), aCrop
.GetTop(), aCrop
.GetRight(), aCrop
.GetBottom());
777 if (rReq
.GetSlot() == SID_ROTATE_GRAPHIC_LEFT
)
779 aCrop
.SetLeft( aCropRectangle
.Top() );
780 aCrop
.SetTop( aCropRectangle
.Right() );
781 aCrop
.SetRight( aCropRectangle
.Bottom() );
782 aCrop
.SetBottom( aCropRectangle
.Left() );
784 else if (rReq
.GetSlot() == SID_ROTATE_GRAPHIC_RIGHT
)
786 aCrop
.SetLeft( aCropRectangle
.Bottom() );
787 aCrop
.SetTop( aCropRectangle
.Left() );
788 aCrop
.SetRight( aCropRectangle
.Top() );
789 aCrop
.SetBottom( aCropRectangle
.Right() );
792 rShell
.SetAttr(aCrop
);
794 rShell
.EndUndo(UNDO_END
);
795 rShell
.EndAllAction();
798 void SwGrfShell::GetAttrStateForRotation(SfxItemSet
&rSet
)
800 SwWrtShell
& rShell
= GetShell();
801 bool bIsParentContentProtected
= 0 != rShell
.IsSelObjProtected( FLYPROTECT_CONTENT
|FLYPROTECT_PARENT
);
803 SetGetStateSet( &rSet
);
805 SfxWhichIter
aIterator( rSet
);
806 sal_uInt16 nWhich
= aIterator
.FirstWhich();
809 bool bDisable
= bIsParentContentProtected
;
812 case SID_ROTATE_GRAPHIC_LEFT
:
813 case SID_ROTATE_GRAPHIC_RIGHT
:
814 if( rShell
.GetGraphicType() == GRAPHIC_NONE
)
820 Graphic aGraphic
= *rShell
.GetGraphic();
821 GraphicNativeTransform
aTransform(aGraphic
);
822 if (!aTransform
.canBeRotated())
833 rSet
.DisableItem( nWhich
);
834 nWhich
= aIterator
.NextWhich();
840 SwGrfShell::SwGrfShell(SwView
&_rView
) :
844 SetName(OUString("Graphic"));
845 SetHelpId(SW_GRFSHELL
);
846 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Graphic
));
849 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */