xref: /trunk/main/sw/source/ui/shells/grfsh.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <cmdid.h>
26cdf0e10cSrcweir #include <hintids.hxx>
27cdf0e10cSrcweir #include <tools/urlobj.hxx>
28cdf0e10cSrcweir #include <vcl/msgbox.hxx>
29cdf0e10cSrcweir #include <svl/stritem.hxx>
30cdf0e10cSrcweir #include <svl/whiter.hxx>
31cdf0e10cSrcweir #include <svl/urihelper.hxx>
32cdf0e10cSrcweir #include <sfx2/docfile.hxx>
33cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
34cdf0e10cSrcweir #include <sfx2/objface.hxx>
35cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
36cdf0e10cSrcweir #include <editeng/protitem.hxx>
37cdf0e10cSrcweir #include <sfx2/request.hxx>
38f120fe41SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx>
39cdf0e10cSrcweir #include <svl/srchitem.hxx>
40cdf0e10cSrcweir #include <svx/htmlmode.hxx>
41cdf0e10cSrcweir #include <svx/sdgluitm.hxx>
42cdf0e10cSrcweir #include <svx/sdgcoitm.hxx>
43cdf0e10cSrcweir #include <svx/sdggaitm.hxx>
44cdf0e10cSrcweir #include <svx/sdgtritm.hxx>
45cdf0e10cSrcweir #include <svx/sdginitm.hxx>
46cdf0e10cSrcweir #include <svx/sdgmoitm.hxx>
47cdf0e10cSrcweir #include <editeng/brshitem.hxx>
48cdf0e10cSrcweir #include <svx/grfflt.hxx>
49cdf0e10cSrcweir #include <svx/tbxcolor.hxx>
50cdf0e10cSrcweir #include <fmturl.hxx>
51cdf0e10cSrcweir #include <view.hxx>
52cdf0e10cSrcweir #include <wrtsh.hxx>
53cdf0e10cSrcweir #include <viewopt.hxx>
54cdf0e10cSrcweir #include <swmodule.hxx>
55cdf0e10cSrcweir #include <frmatr.hxx>
56cdf0e10cSrcweir #include <swundo.hxx>
57cdf0e10cSrcweir #include <uitool.hxx>
58cdf0e10cSrcweir #include <docsh.hxx>
59cdf0e10cSrcweir #include <grfsh.hxx>
60cdf0e10cSrcweir #include <frmmgr.hxx>
61cdf0e10cSrcweir #include <frmdlg.hxx>
62cdf0e10cSrcweir #include <frmfmt.hxx>
63cdf0e10cSrcweir #include <grfatr.hxx>
64cdf0e10cSrcweir #include <usrpref.hxx>
65cdf0e10cSrcweir #include <edtwin.hxx>
66cdf0e10cSrcweir #include <swwait.hxx>
67cdf0e10cSrcweir #include <shells.hrc>
68cdf0e10cSrcweir #include <popup.hrc>
69b740b198SArmin Le Grand #include <doc.hxx>
70b740b198SArmin Le Grand #include <docsh.hxx>
71b740b198SArmin Le Grand #include <svx/drawitem.hxx>
72cdf0e10cSrcweir #define SwGrfShell
73cdf0e10cSrcweir #include <sfx2/msg.hxx>
74cdf0e10cSrcweir #include "swslots.hxx"
75cdf0e10cSrcweir #include "swabstdlg.hxx"
7626ea3662SArmin Le Grand #include <drawdoc.hxx>
77cdf0e10cSrcweir 
78cdf0e10cSrcweir #define TOOLBOX_NAME    ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) )
79cdf0e10cSrcweir 
SFX_IMPL_INTERFACE(SwGrfShell,SwBaseShell,SW_RES (STR_SHELLNAME_GRAPHIC))80cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwGrfShell, SwBaseShell, SW_RES(STR_SHELLNAME_GRAPHIC))
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_GRF_POPUPMENU));
83cdf0e10cSrcweir     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_GRAFIK_TOOLBOX));
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
Execute(SfxRequest & rReq)86cdf0e10cSrcweir void SwGrfShell::Execute(SfxRequest &rReq)
87cdf0e10cSrcweir {
88cdf0e10cSrcweir     SwWrtShell &rSh = GetShell();
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     sal_uInt16 nSlot = rReq.GetSlot();
91cdf0e10cSrcweir     switch(nSlot)
92cdf0e10cSrcweir     {
93cdf0e10cSrcweir         case SID_TWAIN_TRANSFER:
94cdf0e10cSrcweir         {
95cdf0e10cSrcweir             GetView().ExecuteScan( rReq );
96cdf0e10cSrcweir             break;
97cdf0e10cSrcweir         }
98cdf0e10cSrcweir         case FN_SAVE_GRAPHIC:
99cdf0e10cSrcweir         {
100cdf0e10cSrcweir             const Graphic *pGraphic;
101cdf0e10cSrcweir             if(0 != (pGraphic = rSh.GetGraphic()))
102cdf0e10cSrcweir             {
103cdf0e10cSrcweir                 String sGrfNm, sFilterNm;
104cdf0e10cSrcweir                 rSh.GetGrfNms( &sGrfNm, &sFilterNm );
105cdf0e10cSrcweir                 ExportGraphic( *pGraphic, sGrfNm );
106cdf0e10cSrcweir             }
107cdf0e10cSrcweir         }
108cdf0e10cSrcweir         break;
109cdf0e10cSrcweir         case SID_INSERT_GRAPHIC:
11052f1c2eeSArmin Le Grand         {
11152f1c2eeSArmin Le Grand             // #123922# implement slot independent from the two below to
11252f1c2eeSArmin Le Grand             // bring up the insert graphic dialog and associated actions
11352f1c2eeSArmin Le Grand             SwView& rView = GetView();
11452f1c2eeSArmin Le Grand             rReq.SetReturnValue(SfxBoolItem(nSlot, rView.InsertGraphicDlg( rReq )));
11552f1c2eeSArmin Le Grand             break;
11652f1c2eeSArmin Le Grand         }
117cdf0e10cSrcweir         case FN_FORMAT_GRAFIC_DLG:
118395b75f9SOliver-Rainer Wittmann         case FN_DRAW_WRAP_DLG:
119cdf0e10cSrcweir         {
120cdf0e10cSrcweir             SwFlyFrmAttrMgr aMgr( sal_False, &rSh, rSh.IsFrmSelected() ?
121cdf0e10cSrcweir                                                FRMMGR_TYPE_NONE : FRMMGR_TYPE_GRF);
122cdf0e10cSrcweir             const SwViewOption* pVOpt = rSh.GetViewOptions();
123cdf0e10cSrcweir             SwViewOption aUsrPref( *pVOpt );
124cdf0e10cSrcweir 
125b740b198SArmin Le Grand             SfxItemSet aSet(GetPool(), //UUUU sorted by indices
126b740b198SArmin Le Grand 
127b740b198SArmin Le Grand                 RES_FRMATR_BEGIN,RES_FRMATR_END - 1,                            // [   82
128b740b198SArmin Le Grand                 RES_GRFATR_MIRRORGRF,RES_GRFATR_CROPGRF,                        // [  123
129b740b198SArmin Le Grand 
130b740b198SArmin Le Grand                 //UUUU FillAttribute support
131b740b198SArmin Le Grand                 XATTR_FILL_FIRST,       XATTR_FILL_LAST,                        // [ 1014
132b740b198SArmin Le Grand 
133b740b198SArmin Le Grand                 SID_DOCFRAME,SID_DOCFRAME,                                      // [ 5598
134b740b198SArmin Le Grand                 SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER,                    // [10023
135b740b198SArmin Le Grand                 SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE,                          // [10051
136b740b198SArmin Le Grand                 SID_ATTR_GRAF_KEEP_ZOOM,SID_ATTR_GRAF_KEEP_ZOOM,                // [10882
137b740b198SArmin Le Grand                 SID_ATTR_GRAF_FRMSIZE,SID_ATTR_GRAF_GRAPHIC,                    // [10884, contains SID_ATTR_GRAF_FRMSIZE_PERCENT
138b740b198SArmin Le Grand 
139b740b198SArmin Le Grand                 //UUUU items to hand over XPropertyList things like
140b740b198SArmin Le Grand                 // XColorList, XHatchList, XGradientList and XBitmapList
141b740b198SArmin Le Grand                 // to the Area TabPage
142b740b198SArmin Le Grand                 SID_COLOR_TABLE,        SID_BITMAP_LIST,                        // [10179
143b740b198SArmin Le Grand 
144b740b198SArmin Le Grand                 SID_HTML_MODE,SID_HTML_MODE,                                    // [10414
145b740b198SArmin Le Grand                 FN_GET_PRINT_AREA,FN_GET_PRINT_AREA,                            // [21032
146b740b198SArmin Le Grand                 FN_PARAM_GRF_CONNECT,FN_PARAM_GRF_CONNECT,                      // [21153
147b740b198SArmin Le Grand                 FN_PARAM_GRF_DIALOG,FN_PARAM_GRF_DIALOG,                        // [21171
148b740b198SArmin Le Grand                 FN_SET_FRM_NAME,FN_KEEP_ASPECT_RATIO,                           // [21306
149b740b198SArmin Le Grand                 FN_SET_FRM_ALT_NAME,FN_SET_FRM_ALT_NAME,                        // [21318
150cdf0e10cSrcweir                 0);
151cdf0e10cSrcweir 
152b740b198SArmin Le Grand             //UUUU create needed items for XPropertyList entries from the DrawModel so that
153b740b198SArmin Le Grand             // the Area TabPage can access them
15426ea3662SArmin Le Grand             const SwDrawModel* pDrawModel = rSh.GetView().GetDocShell()->GetDoc()->GetDrawModel();
155b740b198SArmin Le Grand 
156b740b198SArmin Le Grand             aSet.Put(SvxColorTableItem(pDrawModel->GetColorTableFromSdrModel(), SID_COLOR_TABLE));
157b740b198SArmin Le Grand             aSet.Put(SvxGradientListItem(pDrawModel->GetGradientListFromSdrModel(), SID_GRADIENT_LIST));
158b740b198SArmin Le Grand             aSet.Put(SvxHatchListItem(pDrawModel->GetHatchListFromSdrModel(), SID_HATCH_LIST));
159b740b198SArmin Le Grand             aSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapListFromSdrModel(), SID_BITMAP_LIST));
160b740b198SArmin Le Grand 
161cdf0e10cSrcweir             sal_uInt16 nHtmlMode = ::GetHtmlMode(GetView().GetDocShell());
162cdf0e10cSrcweir             aSet.Put(SfxUInt16Item(SID_HTML_MODE, nHtmlMode));
163cdf0e10cSrcweir             FieldUnit eMetric = ::GetDfltMetric((0 != (nHtmlMode&HTMLMODE_ON)));
164cdf0e10cSrcweir             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir             const SwRect* pRect = &rSh.GetAnyCurRect(RECT_PAGE);
167cdf0e10cSrcweir             SwFmtFrmSize aFrmSize( ATT_VAR_SIZE, pRect->Width(), pRect->Height());
168cdf0e10cSrcweir             aFrmSize.SetWhich( GetPool().GetWhich( SID_ATTR_PAGE_SIZE ) );
169cdf0e10cSrcweir             aSet.Put( aFrmSize );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir             aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName()));
172cdf0e10cSrcweir             if ( nSlot == FN_FORMAT_GRAFIC_DLG )
173cdf0e10cSrcweir             {
174cdf0e10cSrcweir                 aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) );
175cdf0e10cSrcweir             }
176cdf0e10cSrcweir 
177cdf0e10cSrcweir             pRect = &rSh.GetAnyCurRect(RECT_PAGE_PRT);
178cdf0e10cSrcweir             aFrmSize.SetWidth( pRect->Width() );
179cdf0e10cSrcweir             aFrmSize.SetHeight( pRect->Height() );
180cdf0e10cSrcweir             aFrmSize.SetWhich( GetPool().GetWhich(FN_GET_PRINT_AREA) );
181cdf0e10cSrcweir             aSet.Put( aFrmSize );
182cdf0e10cSrcweir 
183cdf0e10cSrcweir             aSet.Put( aMgr.GetAttrSet() );
184cdf0e10cSrcweir             aSet.SetParent( aMgr.GetAttrSet().GetParent() );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir             // Bei %-Werten Groesse initialisieren
187cdf0e10cSrcweir             SwFmtFrmSize aSizeCopy = (const SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE);
188cdf0e10cSrcweir             if (aSizeCopy.GetWidthPercent() && aSizeCopy.GetWidthPercent() != 0xff)
189cdf0e10cSrcweir                 aSizeCopy.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width());
190cdf0e10cSrcweir             if (aSizeCopy.GetHeightPercent() && aSizeCopy.GetHeightPercent() != 0xff)
191cdf0e10cSrcweir                 aSizeCopy.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height());
192cdf0e10cSrcweir 
193cdf0e10cSrcweir             // and now set the size for "external" tabpages
194cdf0e10cSrcweir             {
195cdf0e10cSrcweir                 SvxSizeItem aSzItm( SID_ATTR_GRAF_FRMSIZE, aSizeCopy.GetSize() );
196cdf0e10cSrcweir                 aSet.Put( aSzItm );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir                 Size aSz( aSizeCopy.GetWidthPercent(), aSizeCopy.GetHeightPercent() );
199cdf0e10cSrcweir                 if( 0xff == aSz.Width() )   aSz.Width() = 0;
200cdf0e10cSrcweir                 if( 0xff == aSz.Height() )  aSz.Height() = 0;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir                 aSzItm.SetSize( aSz );
203cdf0e10cSrcweir                 aSzItm.SetWhich( SID_ATTR_GRAF_FRMSIZE_PERCENT );
204cdf0e10cSrcweir                 aSet.Put( aSzItm );
205cdf0e10cSrcweir             }
206cdf0e10cSrcweir 
207cdf0e10cSrcweir             String sGrfNm, sFilterNm;
208cdf0e10cSrcweir             rSh.GetGrfNms( &sGrfNm, &sFilterNm );
209cdf0e10cSrcweir             if( sGrfNm.Len() )
210cdf0e10cSrcweir             {
211cdf0e10cSrcweir                 aSet.Put( SvxBrushItem( INetURLObject::decode( sGrfNm,
212cdf0e10cSrcweir                                         INET_HEX_ESCAPE,
213cdf0e10cSrcweir                                         INetURLObject::DECODE_UNAMBIGUOUS,
214cdf0e10cSrcweir                                         RTL_TEXTENCODING_UTF8 ),
215cdf0e10cSrcweir                                         sFilterNm, GPOS_LT,
216cdf0e10cSrcweir                                         SID_ATTR_GRAF_GRAPHIC ));
217cdf0e10cSrcweir             }
218cdf0e10cSrcweir             else
219cdf0e10cSrcweir             {
220cdf0e10cSrcweir                 // --> OD 2005-02-09 #119353# - robust
221cdf0e10cSrcweir                 const GraphicObject* pGrfObj = rSh.GetGraphicObj();
222cdf0e10cSrcweir                 if ( pGrfObj )
223cdf0e10cSrcweir                 {
224cdf0e10cSrcweir                     aSet.Put( SvxBrushItem( *pGrfObj, GPOS_LT,
225cdf0e10cSrcweir                                             SID_ATTR_GRAF_GRAPHIC ) );
226cdf0e10cSrcweir                 }
227cdf0e10cSrcweir                 // <--
228cdf0e10cSrcweir             }
229cdf0e10cSrcweir             aSet.Put( SfxBoolItem( FN_PARAM_GRF_CONNECT, sGrfNm.Len() > 0 ) );
230cdf0e10cSrcweir 
231cdf0e10cSrcweir             // get Mirror and Crop
232cdf0e10cSrcweir             {
233cdf0e10cSrcweir                 SfxItemSet aTmpSet( rSh.GetAttrPool(),
234cdf0e10cSrcweir                                 RES_GRFATR_MIRRORGRF, RES_GRFATR_CROPGRF );
235cdf0e10cSrcweir 
236cdf0e10cSrcweir                 rSh.GetCurAttr( aTmpSet );
237cdf0e10cSrcweir                 aSet.Put( aTmpSet );
238cdf0e10cSrcweir             }
239cdf0e10cSrcweir 
240cdf0e10cSrcweir             aSet.Put(SfxBoolItem(FN_KEEP_ASPECT_RATIO, aUsrPref.IsKeepRatio()));
241cdf0e10cSrcweir             aSet.Put(SfxBoolItem( SID_ATTR_GRAF_KEEP_ZOOM, aUsrPref.IsGrfKeepZoom()));
242cdf0e10cSrcweir 
243cdf0e10cSrcweir             aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame()));
244cdf0e10cSrcweir 
245cdf0e10cSrcweir             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
246cdf0e10cSrcweir             DBG_ASSERT(pFact, "Dialogdiet fail!");
247cdf0e10cSrcweir             SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_GRF,
248cdf0e10cSrcweir                                                     GetView().GetViewFrame(),
249cdf0e10cSrcweir                                                     GetView().GetWindow(),
250cdf0e10cSrcweir                                                     aSet, sal_False, DLG_FRM_GRF);
251cdf0e10cSrcweir             DBG_ASSERT(pDlg, "Dialogdiet fail!");
252f120fe41SAndre Fischer 
253395b75f9SOliver-Rainer Wittmann             if (nSlot == FN_DRAW_WRAP_DLG)
254f120fe41SAndre Fischer                 pDlg->SetCurPageId(TP_FRM_WRAP);
255f120fe41SAndre Fischer 
256cdf0e10cSrcweir             if( pDlg->Execute() )
257cdf0e10cSrcweir             {
258cdf0e10cSrcweir                 rSh.StartAllAction();
259cdf0e10cSrcweir                 rSh.StartUndo(UNDO_START);
260cdf0e10cSrcweir                 const SfxPoolItem* pItem;
261cdf0e10cSrcweir                 SfxItemSet* pSet = (SfxItemSet*)pDlg->GetOutputItemSet();
262cdf0e10cSrcweir                 rReq.Done(*pSet);
263cdf0e10cSrcweir                 // change the 2 frmsize SizeItems to the correct SwFrmSizeItem
264cdf0e10cSrcweir                 if( SFX_ITEM_SET == pSet->GetItemState(
265cdf0e10cSrcweir                                 SID_ATTR_GRAF_FRMSIZE, sal_False, &pItem ))
266cdf0e10cSrcweir                 {
267cdf0e10cSrcweir                     SwFmtFrmSize aSize;
268cdf0e10cSrcweir                     const Size& rSz = ((SvxSizeItem*)pItem)->GetSize();
269cdf0e10cSrcweir                     aSize.SetWidth( rSz.Width() );
270cdf0e10cSrcweir                     aSize.SetHeight( rSz.Height() );
271cdf0e10cSrcweir 
272cdf0e10cSrcweir                     if( SFX_ITEM_SET == pSet->GetItemState(
273cdf0e10cSrcweir                             SID_ATTR_GRAF_FRMSIZE_PERCENT, sal_False, &pItem ))
274cdf0e10cSrcweir                     {
275cdf0e10cSrcweir                         const Size& rRelativeSize = ((SvxSizeItem*)pItem)->GetSize();
276cdf0e10cSrcweir                         aSize.SetWidthPercent( static_cast< sal_uInt8 >( rRelativeSize.Width() ) );
277cdf0e10cSrcweir                         aSize.SetHeightPercent( static_cast< sal_uInt8 >( rRelativeSize.Height() ) );
278cdf0e10cSrcweir                     }
279cdf0e10cSrcweir                     pSet->Put( aSize );
280cdf0e10cSrcweir                 }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir                 // Vorlagen-AutoUpdate
283cdf0e10cSrcweir                 SwFrmFmt* pFmt = rSh.GetCurFrmFmt();
284cdf0e10cSrcweir                 if(pFmt && pFmt->IsAutoUpdateFmt())
285cdf0e10cSrcweir                 {
286cdf0e10cSrcweir                     pFmt->SetFmtAttr(*pSet);
287cdf0e10cSrcweir                     SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE,   RES_FRM_SIZE,
288cdf0e10cSrcweir                                                     RES_SURROUND,   RES_SURROUND,
289cdf0e10cSrcweir                                                     RES_ANCHOR,     RES_ANCHOR,
290cdf0e10cSrcweir                                                     RES_VERT_ORIENT,RES_HORI_ORIENT,
291cdf0e10cSrcweir                                                     0);
292cdf0e10cSrcweir                     aShellSet.Put(*pSet);
293cdf0e10cSrcweir                     aMgr.SetAttrSet(aShellSet);
294cdf0e10cSrcweir                 }
295cdf0e10cSrcweir                 else
296cdf0e10cSrcweir                 {
297cdf0e10cSrcweir                     aMgr.SetAttrSet(*pSet);
298cdf0e10cSrcweir                 }
299cdf0e10cSrcweir                 aMgr.UpdateFlyFrm();
300cdf0e10cSrcweir 
301cdf0e10cSrcweir                 sal_Bool bApplyUsrPref = sal_False;
302cdf0e10cSrcweir                 if (SFX_ITEM_SET == pSet->GetItemState(
303cdf0e10cSrcweir                     FN_KEEP_ASPECT_RATIO, sal_True, &pItem ))
304cdf0e10cSrcweir                 {
305cdf0e10cSrcweir                     aUsrPref.SetKeepRatio(
306cdf0e10cSrcweir                                     ((const SfxBoolItem*)pItem)->GetValue() );
307cdf0e10cSrcweir                     bApplyUsrPref = sal_True;
308cdf0e10cSrcweir                 }
309cdf0e10cSrcweir                 if( SFX_ITEM_SET == pSet->GetItemState(
310cdf0e10cSrcweir                     SID_ATTR_GRAF_KEEP_ZOOM, sal_True, &pItem ))
311cdf0e10cSrcweir                 {
312cdf0e10cSrcweir                     aUsrPref.SetGrfKeepZoom(
313cdf0e10cSrcweir                                     ((const SfxBoolItem*)pItem)->GetValue() );
314cdf0e10cSrcweir                     bApplyUsrPref = sal_True;
315cdf0e10cSrcweir                 }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir                 if( bApplyUsrPref )
318cdf0e10cSrcweir                     SW_MOD()->ApplyUsrPref(aUsrPref, &GetView());
319cdf0e10cSrcweir 
320cdf0e10cSrcweir                 // and now set all the graphic attributes and other stuff
321cdf0e10cSrcweir                 if( SFX_ITEM_SET == pSet->GetItemState(
322cdf0e10cSrcweir                                         SID_ATTR_GRAF_GRAPHIC, sal_True, &pItem ))
323cdf0e10cSrcweir                 {
324cdf0e10cSrcweir                     if( ((SvxBrushItem*)pItem)->GetGraphicLink() )
325cdf0e10cSrcweir                         sGrfNm = *((SvxBrushItem*)pItem)->GetGraphicLink();
326cdf0e10cSrcweir                     else
327cdf0e10cSrcweir                         sGrfNm.Erase();
328cdf0e10cSrcweir 
329cdf0e10cSrcweir                     if( ((SvxBrushItem*)pItem)->GetGraphicFilter() )
330cdf0e10cSrcweir                         sFilterNm = *((SvxBrushItem*)pItem)->GetGraphicFilter();
331cdf0e10cSrcweir                     else
332cdf0e10cSrcweir                         sFilterNm.Erase();
333cdf0e10cSrcweir 
334cdf0e10cSrcweir                     if( sGrfNm.Len() )
335cdf0e10cSrcweir                     {
336cdf0e10cSrcweir                         SwDocShell* pDocSh = GetView().GetDocShell();
3378ef2f12bSOliver-Rainer Wittmann                         SwWait aWait( *pDocSh, true );
338cdf0e10cSrcweir                         SfxMedium* pMedium = pDocSh->GetMedium();
339cdf0e10cSrcweir                         INetURLObject aAbs;
340cdf0e10cSrcweir                         if( pMedium )
341cdf0e10cSrcweir                             aAbs = pMedium->GetURLObject();
342cdf0e10cSrcweir                         rSh.ReRead( URIHelper::SmartRel2Abs(
343cdf0e10cSrcweir                                         aAbs, sGrfNm,
344cdf0e10cSrcweir                                         URIHelper::GetMaybeFileHdl() ),
345cdf0e10cSrcweir                                     sFilterNm, 0 );
346cdf0e10cSrcweir                     }
347cdf0e10cSrcweir                 }
348cdf0e10cSrcweir                 if ( SFX_ITEM_SET == pSet->GetItemState(
349cdf0e10cSrcweir                                         FN_SET_FRM_ALT_NAME, sal_True, &pItem ))
350cdf0e10cSrcweir                 {
351cdf0e10cSrcweir                     // --> OD 2009-07-13 #i73249#
352cdf0e10cSrcweir //                    rSh.SetAlternateText(
353cdf0e10cSrcweir //                                ((const SfxStringItem*)pItem)->GetValue() );
354cdf0e10cSrcweir                     rSh.SetObjTitle( ((const SfxStringItem*)pItem)->GetValue() );
355cdf0e10cSrcweir                     // <--
356cdf0e10cSrcweir                 }
357cdf0e10cSrcweir 
358cdf0e10cSrcweir                 SfxItemSet aGrfSet( rSh.GetAttrPool(), RES_GRFATR_BEGIN,
359cdf0e10cSrcweir                                                        RES_GRFATR_END-1 );
360cdf0e10cSrcweir                 aGrfSet.Put( *pSet );
361cdf0e10cSrcweir                 if( aGrfSet.Count() )
36269a74367SOliver-Rainer Wittmann                     rSh.SetAttrSet( aGrfSet );
363cdf0e10cSrcweir 
364cdf0e10cSrcweir                 rSh.EndUndo(UNDO_END);
365cdf0e10cSrcweir                 rSh.EndAllAction();
366cdf0e10cSrcweir             }
367cdf0e10cSrcweir             delete pDlg;
368cdf0e10cSrcweir         }
369cdf0e10cSrcweir         break;
370cdf0e10cSrcweir 
371cdf0e10cSrcweir         case FN_GRAPHIC_MIRROR_ON_EVEN_PAGES:
372cdf0e10cSrcweir         {
373cdf0e10cSrcweir             SfxItemSet aSet(rSh.GetAttrPool(), RES_GRFATR_MIRRORGRF, RES_GRFATR_MIRRORGRF);
374cdf0e10cSrcweir             rSh.GetCurAttr( aSet );
375cdf0e10cSrcweir             SwMirrorGrf aGrf((const SwMirrorGrf &)aSet.Get(RES_GRFATR_MIRRORGRF));
376cdf0e10cSrcweir             aGrf.SetGrfToggle(!aGrf.IsGrfToggle());
37769a74367SOliver-Rainer Wittmann             rSh.SetAttrItem(aGrf);
378cdf0e10cSrcweir         }
379cdf0e10cSrcweir         break;
380cdf0e10cSrcweir 
381cdf0e10cSrcweir         default:
382*870262e3SDon Lewis             ASSERT(sal_False, "wrong dispatcher");
383cdf0e10cSrcweir             return;
384cdf0e10cSrcweir     }
385cdf0e10cSrcweir }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 
ExecAttr(SfxRequest & rReq)388cdf0e10cSrcweir void SwGrfShell::ExecAttr( SfxRequest &rReq )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir     sal_uInt16 nGrfType;
391cdf0e10cSrcweir     if( CNT_GRF == GetShell().GetCntType() &&
392cdf0e10cSrcweir         ( GRAPHIC_BITMAP == ( nGrfType = GetShell().GetGraphicType()) ||
393cdf0e10cSrcweir           GRAPHIC_GDIMETAFILE == nGrfType ))
394cdf0e10cSrcweir     {
395cdf0e10cSrcweir         SfxItemSet aGrfSet( GetShell().GetAttrPool(), RES_GRFATR_BEGIN,
396cdf0e10cSrcweir                                                       RES_GRFATR_END -1 );
397cdf0e10cSrcweir         const SfxItemSet *pArgs = rReq.GetArgs();
398cdf0e10cSrcweir         const SfxPoolItem* pItem;
399cdf0e10cSrcweir         sal_uInt16 nSlot = rReq.GetSlot();
400cdf0e10cSrcweir         if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, sal_False, &pItem ))
401cdf0e10cSrcweir             pItem = 0;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir         switch( nSlot )
404cdf0e10cSrcweir         {
405ee093554SAndre Fischer             case SID_FLIP_VERTICAL:
406ee093554SAndre Fischer             case SID_FLIP_HORIZONTAL:
407cdf0e10cSrcweir             {
408cdf0e10cSrcweir                 GetShell().GetCurAttr( aGrfSet );
409261e9a4bSOliver-Rainer Wittmann                 SwMirrorGrf aMirror( (SwMirrorGrf&)aGrfSet.Get( RES_GRFATR_MIRRORGRF ) );
410cdf0e10cSrcweir                 sal_uInt16 nMirror = aMirror.GetValue();
411261e9a4bSOliver-Rainer Wittmann                 if ( nSlot==SID_FLIP_HORIZONTAL )
412cdf0e10cSrcweir                     switch( nMirror )
413cdf0e10cSrcweir                     {
414cdf0e10cSrcweir                     case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_VERT;
415cdf0e10cSrcweir                                                 break;
416cdf0e10cSrcweir                     case RES_MIRROR_GRAPH_HOR:  nMirror = RES_MIRROR_GRAPH_BOTH;
417cdf0e10cSrcweir                                                 break;
418cdf0e10cSrcweir                     case RES_MIRROR_GRAPH_VERT:   nMirror = RES_MIRROR_GRAPH_DONT;
419cdf0e10cSrcweir                                                 break;
420cdf0e10cSrcweir                     case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_HOR;
421cdf0e10cSrcweir                                                 break;
422cdf0e10cSrcweir                     }
423cdf0e10cSrcweir                 else
424cdf0e10cSrcweir                     switch( nMirror )
425cdf0e10cSrcweir                     {
426cdf0e10cSrcweir                     case RES_MIRROR_GRAPH_DONT: nMirror = RES_MIRROR_GRAPH_HOR;
427cdf0e10cSrcweir                                                 break;
428cdf0e10cSrcweir                     case RES_MIRROR_GRAPH_VERT: nMirror = RES_MIRROR_GRAPH_BOTH;
429cdf0e10cSrcweir                                                 break;
430cdf0e10cSrcweir                     case RES_MIRROR_GRAPH_HOR:    nMirror = RES_MIRROR_GRAPH_DONT;
431cdf0e10cSrcweir                                                 break;
432cdf0e10cSrcweir                     case RES_MIRROR_GRAPH_BOTH: nMirror = RES_MIRROR_GRAPH_VERT;
433cdf0e10cSrcweir                                                 break;
434cdf0e10cSrcweir                     }
435cdf0e10cSrcweir                 aMirror.SetValue( nMirror );
436cdf0e10cSrcweir                 aGrfSet.ClearItem();
437cdf0e10cSrcweir                 aGrfSet.Put( aMirror );
438cdf0e10cSrcweir             }
439cdf0e10cSrcweir             break;
440cdf0e10cSrcweir 
441cdf0e10cSrcweir         case SID_ATTR_GRAF_LUMINANCE:
442cdf0e10cSrcweir             if( pItem )
443cdf0e10cSrcweir                 aGrfSet.Put( SwLuminanceGrf(
444cdf0e10cSrcweir                             ((SfxInt16Item*)pItem)->GetValue() ));
445cdf0e10cSrcweir             break;
446cdf0e10cSrcweir         case SID_ATTR_GRAF_CONTRAST:
447cdf0e10cSrcweir             if( pItem )
448cdf0e10cSrcweir                 aGrfSet.Put( SwContrastGrf(
449cdf0e10cSrcweir                             ((SfxInt16Item*)pItem)->GetValue() ));
450cdf0e10cSrcweir             break;
451cdf0e10cSrcweir         case SID_ATTR_GRAF_RED:
452cdf0e10cSrcweir             if( pItem )
453cdf0e10cSrcweir                 aGrfSet.Put( SwChannelRGrf(
454cdf0e10cSrcweir                             ((SfxInt16Item*)pItem)->GetValue() ));
455cdf0e10cSrcweir             break;
456cdf0e10cSrcweir         case SID_ATTR_GRAF_GREEN:
457cdf0e10cSrcweir             if( pItem )
458cdf0e10cSrcweir                 aGrfSet.Put( SwChannelGGrf(
459cdf0e10cSrcweir                             ((SfxInt16Item*)pItem)->GetValue() ));
460cdf0e10cSrcweir             break;
461cdf0e10cSrcweir         case SID_ATTR_GRAF_BLUE:
462cdf0e10cSrcweir             if( pItem )
463cdf0e10cSrcweir                 aGrfSet.Put( SwChannelBGrf(
464cdf0e10cSrcweir                             ((SfxInt16Item*)pItem)->GetValue() ));
465cdf0e10cSrcweir             break;
466cdf0e10cSrcweir         case SID_ATTR_GRAF_GAMMA:
467cdf0e10cSrcweir             if( pItem )
468cdf0e10cSrcweir             {
469cdf0e10cSrcweir                 double fVal = ((SfxUInt32Item*)pItem)->GetValue();
470cdf0e10cSrcweir                 aGrfSet.Put( SwGammaGrf(fVal/100. ));
471cdf0e10cSrcweir             }
472cdf0e10cSrcweir             break;
473cdf0e10cSrcweir         case SID_ATTR_GRAF_TRANSPARENCE:
474cdf0e10cSrcweir             if( pItem )
475cdf0e10cSrcweir                 aGrfSet.Put( SwTransparencyGrf(
476cdf0e10cSrcweir                     static_cast< sal_Int8 >( ( (SfxUInt16Item*)pItem )->GetValue() ) ) );
477cdf0e10cSrcweir             break;
478cdf0e10cSrcweir         case SID_ATTR_GRAF_INVERT:
479cdf0e10cSrcweir             if( pItem )
480cdf0e10cSrcweir                 aGrfSet.Put( SwInvertGrf(
481cdf0e10cSrcweir                             ((SfxBoolItem*)pItem)->GetValue() ));
482cdf0e10cSrcweir             break;
483cdf0e10cSrcweir 
484cdf0e10cSrcweir         case SID_ATTR_GRAF_MODE:
485cdf0e10cSrcweir             if( pItem )
486cdf0e10cSrcweir                 aGrfSet.Put( SwDrawModeGrf(
487cdf0e10cSrcweir                             ((SfxUInt16Item*)pItem)->GetValue() ));
488cdf0e10cSrcweir             break;
489cdf0e10cSrcweir 
490cdf0e10cSrcweir         case SID_COLOR_SETTINGS:
491cdf0e10cSrcweir         {
492cdf0e10cSrcweir             svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
493cdf0e10cSrcweir             aToolboxAccess.toggleToolbox();
494cdf0e10cSrcweir             break;
495cdf0e10cSrcweir         }
496cdf0e10cSrcweir         case SID_GRFFILTER:
497cdf0e10cSrcweir         case SID_GRFFILTER_INVERT:
498cdf0e10cSrcweir         case SID_GRFFILTER_SMOOTH:
499cdf0e10cSrcweir         case SID_GRFFILTER_SHARPEN:
500cdf0e10cSrcweir         case SID_GRFFILTER_REMOVENOISE:
501cdf0e10cSrcweir         case SID_GRFFILTER_SOBEL:
502cdf0e10cSrcweir         case SID_GRFFILTER_MOSAIC:
503cdf0e10cSrcweir         case SID_GRFFILTER_EMBOSS:
504cdf0e10cSrcweir         case SID_GRFFILTER_POSTER:
505cdf0e10cSrcweir         case SID_GRFFILTER_POPART:
506cdf0e10cSrcweir         case SID_GRFFILTER_SEPIA:
507cdf0e10cSrcweir         case SID_GRFFILTER_SOLARIZE:
508cdf0e10cSrcweir             if( GRAPHIC_BITMAP == nGrfType )
509cdf0e10cSrcweir             {
510cdf0e10cSrcweir                 // --> OD 2005-02-09 #119353# - robust
511cdf0e10cSrcweir                 const GraphicObject* pFilterObj( GetShell().GetGraphicObj() );
512cdf0e10cSrcweir                 if ( pFilterObj )
513cdf0e10cSrcweir                 {
514cdf0e10cSrcweir                     GraphicObject aFilterObj( *pFilterObj );
515cdf0e10cSrcweir                     if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
516cdf0e10cSrcweir                         SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ))
517cdf0e10cSrcweir                         GetShell().ReRead( aEmptyStr, aEmptyStr,
518cdf0e10cSrcweir                                            &aFilterObj.GetGraphic() );
519cdf0e10cSrcweir                 }
520cdf0e10cSrcweir                 // <--
521cdf0e10cSrcweir             }
522cdf0e10cSrcweir             break;
523cdf0e10cSrcweir 
524cdf0e10cSrcweir         default:
525*870262e3SDon Lewis             ASSERT(sal_False, "wrong dispatcher");
526cdf0e10cSrcweir         }
527cdf0e10cSrcweir         if( aGrfSet.Count() )
52869a74367SOliver-Rainer Wittmann             GetShell().SetAttrSet( aGrfSet );
529cdf0e10cSrcweir     }
530cdf0e10cSrcweir     GetView().GetViewFrame()->GetBindings().Invalidate(rReq.GetSlot());
531cdf0e10cSrcweir }
532cdf0e10cSrcweir 
GetAttrState(SfxItemSet & rSet)533cdf0e10cSrcweir void SwGrfShell::GetAttrState(SfxItemSet &rSet)
534cdf0e10cSrcweir {
535cdf0e10cSrcweir     SwWrtShell &rSh = GetShell();
536cdf0e10cSrcweir     SfxItemSet aCoreSet( GetPool(), aNoTxtNodeSetRange );
537cdf0e10cSrcweir     rSh.GetCurAttr( aCoreSet );
538cdf0e10cSrcweir     sal_Bool bParentCntProt = 0 != rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT );
539cdf0e10cSrcweir     sal_Bool bIsGrfCntnt = CNT_GRF == GetShell().GetCntType();
540cdf0e10cSrcweir 
541cdf0e10cSrcweir     SetGetStateSet( &rSet );
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     SfxWhichIter aIter( rSet );
544cdf0e10cSrcweir     sal_uInt16 nWhich = aIter.FirstWhich();
545cdf0e10cSrcweir     while( nWhich )
546cdf0e10cSrcweir     {
547cdf0e10cSrcweir         sal_Bool bDisable = bParentCntProt;
548cdf0e10cSrcweir         switch( nWhich )
549cdf0e10cSrcweir         {
550cdf0e10cSrcweir         case SID_INSERT_GRAPHIC:
551cdf0e10cSrcweir         case FN_FORMAT_GRAFIC_DLG:
552cdf0e10cSrcweir         case SID_TWAIN_TRANSFER:
553cdf0e10cSrcweir             if( bParentCntProt || !bIsGrfCntnt )
554cdf0e10cSrcweir                 bDisable = sal_True;
55569a74367SOliver-Rainer Wittmann             else if ( nWhich == SID_INSERT_GRAPHIC
55669a74367SOliver-Rainer Wittmann                       && rSh.CrsrInsideInputFld() )
55769a74367SOliver-Rainer Wittmann             {
55869a74367SOliver-Rainer Wittmann                 bDisable = sal_True;
55969a74367SOliver-Rainer Wittmann             }
560cdf0e10cSrcweir             break;
56169a74367SOliver-Rainer Wittmann 
562cdf0e10cSrcweir         case FN_SAVE_GRAPHIC:
563cdf0e10cSrcweir             if( rSh.GetGraphicType() == GRAPHIC_NONE )
564cdf0e10cSrcweir                 bDisable = sal_True;
565cdf0e10cSrcweir             break;
56669a74367SOliver-Rainer Wittmann 
567cdf0e10cSrcweir         case SID_COLOR_SETTINGS:
568cdf0e10cSrcweir         {
569cdf0e10cSrcweir             if ( bParentCntProt || !bIsGrfCntnt )
570cdf0e10cSrcweir                 bDisable = sal_True;
571cdf0e10cSrcweir             else
572cdf0e10cSrcweir             {
573cdf0e10cSrcweir                 svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
574cdf0e10cSrcweir                 rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) );
575cdf0e10cSrcweir             }
576cdf0e10cSrcweir             break;
577cdf0e10cSrcweir         }
578cdf0e10cSrcweir 
579261e9a4bSOliver-Rainer Wittmann         case SID_FLIP_HORIZONTAL:
580cdf0e10cSrcweir             if( !bParentCntProt )
581cdf0e10cSrcweir             {
582cdf0e10cSrcweir                 MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get(
583cdf0e10cSrcweir                                         RES_GRFATR_MIRRORGRF )).GetValue());
584cdf0e10cSrcweir 
585cdf0e10cSrcweir                 rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_VERT ||
586cdf0e10cSrcweir                                               nState == RES_MIRROR_GRAPH_BOTH));
587cdf0e10cSrcweir             }
588cdf0e10cSrcweir             break;
589cdf0e10cSrcweir 
590261e9a4bSOliver-Rainer Wittmann         case SID_FLIP_VERTICAL:
591cdf0e10cSrcweir             if( !bParentCntProt )
592cdf0e10cSrcweir             {
593cdf0e10cSrcweir                 MirrorGraph nState = static_cast< MirrorGraph >(((const SwMirrorGrf &) aCoreSet.Get(
594cdf0e10cSrcweir                                         RES_GRFATR_MIRRORGRF )).GetValue());
595cdf0e10cSrcweir 
596cdf0e10cSrcweir                 rSet.Put(SfxBoolItem( nWhich, nState == RES_MIRROR_GRAPH_HOR ||
597cdf0e10cSrcweir                                               nState == RES_MIRROR_GRAPH_BOTH));
598cdf0e10cSrcweir             }
599cdf0e10cSrcweir             break;
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 
602cdf0e10cSrcweir         case SID_ATTR_GRAF_LUMINANCE:
603cdf0e10cSrcweir             if( !bParentCntProt )
604cdf0e10cSrcweir                 rSet.Put( SfxInt16Item( nWhich, ((SwLuminanceGrf&)
605cdf0e10cSrcweir                         aCoreSet.Get(RES_GRFATR_LUMINANCE)).GetValue() ));
606cdf0e10cSrcweir             break;
607cdf0e10cSrcweir         case SID_ATTR_GRAF_CONTRAST:
608cdf0e10cSrcweir             if( !bParentCntProt )
609cdf0e10cSrcweir                 rSet.Put( SfxInt16Item( nWhich, ((SwContrastGrf&)
610cdf0e10cSrcweir                         aCoreSet.Get(RES_GRFATR_CONTRAST)).GetValue() ));
611cdf0e10cSrcweir             break;
612cdf0e10cSrcweir         case SID_ATTR_GRAF_RED:
613cdf0e10cSrcweir             if( !bParentCntProt )
614cdf0e10cSrcweir                 rSet.Put( SfxInt16Item( nWhich, ((SwChannelRGrf&)
615cdf0e10cSrcweir                         aCoreSet.Get(RES_GRFATR_CHANNELR)).GetValue() ));
616cdf0e10cSrcweir             break;
617cdf0e10cSrcweir         case SID_ATTR_GRAF_GREEN:
618cdf0e10cSrcweir             if( !bParentCntProt )
619cdf0e10cSrcweir                 rSet.Put( SfxInt16Item( nWhich, ((SwChannelGGrf&)
620cdf0e10cSrcweir                         aCoreSet.Get(RES_GRFATR_CHANNELG)).GetValue() ));
621cdf0e10cSrcweir             break;
622cdf0e10cSrcweir         case SID_ATTR_GRAF_BLUE:
623cdf0e10cSrcweir             if( !bParentCntProt )
624cdf0e10cSrcweir                 rSet.Put( SfxInt16Item( nWhich, ((SwChannelBGrf&)
625cdf0e10cSrcweir                         aCoreSet.Get(RES_GRFATR_CHANNELB)).GetValue() ));
626cdf0e10cSrcweir             break;
627cdf0e10cSrcweir 
628cdf0e10cSrcweir         case SID_ATTR_GRAF_GAMMA:
629cdf0e10cSrcweir             if( !bParentCntProt )
630cdf0e10cSrcweir                 rSet.Put( SfxUInt32Item( nWhich, static_cast< sal_uInt32 >(
631cdf0e10cSrcweir                     ( (SwGammaGrf&)aCoreSet.Get( RES_GRFATR_GAMMA ) ).GetValue() * 100 ) ) );
632cdf0e10cSrcweir             break;
633cdf0e10cSrcweir         case SID_ATTR_GRAF_TRANSPARENCE:
634cdf0e10cSrcweir             if( !bParentCntProt )
635cdf0e10cSrcweir             {
636cdf0e10cSrcweir                 // --> OD 2005-02-09 #119353# - robust
637cdf0e10cSrcweir                 const GraphicObject* pGrafObj = rSh.GetGraphicObj();
638cdf0e10cSrcweir                 if ( pGrafObj )
639cdf0e10cSrcweir                 {
640cdf0e10cSrcweir                     if( pGrafObj->IsAnimated() ||
641cdf0e10cSrcweir                         GRAPHIC_GDIMETAFILE == pGrafObj->GetType() )
642cdf0e10cSrcweir                         bDisable = sal_True;
643cdf0e10cSrcweir                     else
644cdf0e10cSrcweir                         rSet.Put( SfxUInt16Item( nWhich, ((SwTransparencyGrf&)
645cdf0e10cSrcweir                             aCoreSet.Get(RES_GRFATR_TRANSPARENCY)).GetValue() ));
646cdf0e10cSrcweir                 }
647cdf0e10cSrcweir             }
648cdf0e10cSrcweir             break;
649cdf0e10cSrcweir         case SID_ATTR_GRAF_INVERT:
650cdf0e10cSrcweir             if( !bParentCntProt )
651cdf0e10cSrcweir                 rSet.Put( SfxBoolItem( nWhich, ((SwInvertGrf&)
652cdf0e10cSrcweir                         aCoreSet.Get(RES_GRFATR_INVERT)).GetValue() ));
653cdf0e10cSrcweir             break;
654cdf0e10cSrcweir 
655cdf0e10cSrcweir         case SID_ATTR_GRAF_MODE:
656cdf0e10cSrcweir             if( !bParentCntProt )
657cdf0e10cSrcweir                 rSet.Put( SfxUInt16Item( nWhich, ((SwDrawModeGrf&)
658cdf0e10cSrcweir                         aCoreSet.Get(RES_GRFATR_DRAWMODE)).GetValue() ));
659cdf0e10cSrcweir             break;
660cdf0e10cSrcweir 
661cdf0e10cSrcweir         case SID_GRFFILTER:
662cdf0e10cSrcweir         case SID_GRFFILTER_INVERT:
663cdf0e10cSrcweir         case SID_GRFFILTER_SMOOTH:
664cdf0e10cSrcweir         case SID_GRFFILTER_SHARPEN:
665cdf0e10cSrcweir         case SID_GRFFILTER_REMOVENOISE:
666cdf0e10cSrcweir         case SID_GRFFILTER_SOBEL:
667cdf0e10cSrcweir         case SID_GRFFILTER_MOSAIC:
668cdf0e10cSrcweir         case SID_GRFFILTER_EMBOSS:
669cdf0e10cSrcweir         case SID_GRFFILTER_POSTER:
670cdf0e10cSrcweir         case SID_GRFFILTER_POPART:
671cdf0e10cSrcweir         case SID_GRFFILTER_SEPIA:
672cdf0e10cSrcweir         case SID_GRFFILTER_SOLARIZE:
673cdf0e10cSrcweir             {
674cdf0e10cSrcweir                 if( bParentCntProt || !bIsGrfCntnt )
675cdf0e10cSrcweir                     bDisable = sal_True;
676cdf0e10cSrcweir                 else
677cdf0e10cSrcweir                 {
678cdf0e10cSrcweir                     const sal_uInt16 eGraphicType( rSh.GetGraphicType() );
679cdf0e10cSrcweir                     if ( ( eGraphicType == GRAPHIC_NONE ||
680cdf0e10cSrcweir                            eGraphicType == GRAPHIC_DEFAULT ) &&
681cdf0e10cSrcweir                          rSh.IsGrfSwapOut( sal_True ) )
682cdf0e10cSrcweir                     {
683cdf0e10cSrcweir                         rSet.DisableItem( nWhich );
684cdf0e10cSrcweir                         if( AddGrfUpdateSlot( nWhich ))
685cdf0e10cSrcweir                             rSh.GetGraphic(sal_False);  // start the loading
686cdf0e10cSrcweir                     }
687cdf0e10cSrcweir                     else
688cdf0e10cSrcweir                     {
689cdf0e10cSrcweir                         bDisable = eGraphicType != GRAPHIC_BITMAP;
690cdf0e10cSrcweir                     }
691cdf0e10cSrcweir                 }
692cdf0e10cSrcweir                 // <--
693cdf0e10cSrcweir             }
694cdf0e10cSrcweir             break;
695cdf0e10cSrcweir 
696cdf0e10cSrcweir         default:
697cdf0e10cSrcweir             bDisable = sal_False;
698cdf0e10cSrcweir         }
699cdf0e10cSrcweir 
700cdf0e10cSrcweir         if( bDisable )
701cdf0e10cSrcweir             rSet.DisableItem( nWhich );
702cdf0e10cSrcweir         nWhich = aIter.NextWhich();
703cdf0e10cSrcweir     }
704cdf0e10cSrcweir     SetGetStateSet( 0 );
705cdf0e10cSrcweir }
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 
SwGrfShell(SwView & _rView)708cdf0e10cSrcweir SwGrfShell::SwGrfShell(SwView &_rView) :
709cdf0e10cSrcweir     SwBaseShell(_rView)
710cdf0e10cSrcweir 
711cdf0e10cSrcweir {
712cdf0e10cSrcweir     SetName(String::CreateFromAscii("Graphic"));
713cdf0e10cSrcweir     SetHelpId(SW_GRFSHELL);
714f120fe41SAndre Fischer     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Graphic));
715cdf0e10cSrcweir }
716