xref: /AOO42X/main/sc/source/ui/view/drawvie4.cxx (revision b1c5455db1639c48e26c568e4fa7ee78ca5d60ee)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
31cdf0e10cSrcweir #include <svx/svditer.hxx>
32cdf0e10cSrcweir #include <svx/svdograf.hxx>
33cdf0e10cSrcweir #include <svx/svdogrp.hxx>
34cdf0e10cSrcweir #include <svx/svdoole2.hxx>
35cdf0e10cSrcweir #include <svx/svdpage.hxx>
36cdf0e10cSrcweir #include <svx/svdundo.hxx>
37cdf0e10cSrcweir #include <sfx2/docfile.hxx>
38cdf0e10cSrcweir #include <tools/urlobj.hxx>
39cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "drawview.hxx"
42cdf0e10cSrcweir #include "global.hxx"
43cdf0e10cSrcweir #include "drwlayer.hxx"
44cdf0e10cSrcweir #include "viewdata.hxx"
45cdf0e10cSrcweir #include "document.hxx"
46cdf0e10cSrcweir #include "docsh.hxx"
47cdf0e10cSrcweir #include "drwtrans.hxx"
48cdf0e10cSrcweir #include "transobj.hxx"     // SetDrawClipDoc
49cdf0e10cSrcweir #include "drawutil.hxx"
50cdf0e10cSrcweir #include "scmod.hxx"
51cdf0e10cSrcweir #include "globstr.hrc"
52cdf0e10cSrcweir #include "chartarr.hxx"
53cdf0e10cSrcweir 
54cdf0e10cSrcweir using namespace com::sun::star;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
57cdf0e10cSrcweir 
58cdf0e10cSrcweir Point aDragStartDiff;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // -----------------------------------------------------------------------
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //! welche Funktionen aus drawview/drawvie4 muessen wirklich ohne Optimierung sein?
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #ifdef _MSC_VER
65cdf0e10cSrcweir #pragma optimize ( "", off )
66cdf0e10cSrcweir #endif
67cdf0e10cSrcweir 
68cdf0e10cSrcweir // -----------------------------------------------------------------------
69cdf0e10cSrcweir 
lcl_CheckOle(const SdrMarkList & rMarkList,sal_Bool & rAnyOle,sal_Bool & rOneOle)70cdf0e10cSrcweir void lcl_CheckOle( const SdrMarkList& rMarkList, sal_Bool& rAnyOle, sal_Bool& rOneOle )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     rAnyOle = rOneOle = sal_False;
73cdf0e10cSrcweir     sal_uLong nCount = rMarkList.GetMarkCount();
74cdf0e10cSrcweir     for (sal_uLong i=0; i<nCount; i++)
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir         SdrMark* pMark = rMarkList.GetMark(i);
77cdf0e10cSrcweir         SdrObject* pObj = pMark->GetMarkedSdrObj();
78cdf0e10cSrcweir         sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
79cdf0e10cSrcweir         if (nSdrObjKind == OBJ_OLE2)
80cdf0e10cSrcweir         {
81cdf0e10cSrcweir             rAnyOle = sal_True;
82cdf0e10cSrcweir             rOneOle = (nCount == 1);
83cdf0e10cSrcweir             break;
84cdf0e10cSrcweir         }
85cdf0e10cSrcweir         else if ( pObj->ISA(SdrObjGroup) )
86cdf0e10cSrcweir         {
87cdf0e10cSrcweir             SdrObjListIter aIter( *pObj, IM_DEEPNOGROUPS );
88cdf0e10cSrcweir             SdrObject* pSubObj = aIter.Next();
89cdf0e10cSrcweir             while (pSubObj)
90cdf0e10cSrcweir             {
91cdf0e10cSrcweir                 if ( pSubObj->GetObjIdentifier() == OBJ_OLE2 )
92cdf0e10cSrcweir                 {
93cdf0e10cSrcweir                     rAnyOle = sal_True;
94cdf0e10cSrcweir                     // rOneOle remains sal_False - a group isn't treated like a single OLE object
95cdf0e10cSrcweir                     return;
96cdf0e10cSrcweir                 }
97cdf0e10cSrcweir                 pSubObj = aIter.Next();
98cdf0e10cSrcweir             }
99cdf0e10cSrcweir         }
100cdf0e10cSrcweir     }
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir #if 0
104cdf0e10cSrcweir void lcl_RefreshChartData( SdrModel* pModel, ScDocument* pSourceDoc )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     sal_uInt16 nPages = pModel->GetPageCount();
107cdf0e10cSrcweir     for (SCTAB nTab=0; nTab<nPages; nTab++)
108cdf0e10cSrcweir     {
109cdf0e10cSrcweir         SdrPage* pPage = pModel->GetPage(nTab);
110cdf0e10cSrcweir         SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
111cdf0e10cSrcweir         SdrObject* pObject = aIter.Next();
112cdf0e10cSrcweir         while (pObject)
113cdf0e10cSrcweir         {
114cdf0e10cSrcweir             if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
115cdf0e10cSrcweir             {
116cdf0e10cSrcweir                 SvInPlaceObjectRef aIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
117cdf0e10cSrcweir                 if ( aIPObj.Is() && SotExchange::IsChart( aIPObj->GetStorage()->GetClassName() ) )
118cdf0e10cSrcweir                 {
119cdf0e10cSrcweir                     SchMemChart* pOldData = SchDLL::GetChartData(aIPObj);
120cdf0e10cSrcweir                     if ( pOldData )
121cdf0e10cSrcweir                     {
122cdf0e10cSrcweir                         //  create data from source document
123cdf0e10cSrcweir                         ScChartArray aArray( pSourceDoc, *pOldData );
124cdf0e10cSrcweir                         if ( aArray.IsValid() )
125cdf0e10cSrcweir                         {
126cdf0e10cSrcweir                             SchMemChart* pNewData = aArray.CreateMemChart();
127cdf0e10cSrcweir                             SchDLL::Update( aIPObj, pNewData );
128cdf0e10cSrcweir                             delete pNewData;
129cdf0e10cSrcweir                             ((SdrOle2Obj*)pObject)->GetNewReplacement();
130cdf0e10cSrcweir                         }
131cdf0e10cSrcweir                     }
132cdf0e10cSrcweir                 }
133cdf0e10cSrcweir             }
134cdf0e10cSrcweir             pObject = aIter.Next();
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir }
138cdf0e10cSrcweir #endif
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
BeginDrag(Window * pWindow,const Point & rStartPos)141cdf0e10cSrcweir sal_Bool ScDrawView::BeginDrag( Window* pWindow, const Point& rStartPos )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     if ( AreObjectsMarked() )
146cdf0e10cSrcweir     {
147cdf0e10cSrcweir         BrkAction();
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         Rectangle aMarkedRect = GetAllMarkedRect();
150cdf0e10cSrcweir         Region aRegion( aMarkedRect );
151cdf0e10cSrcweir 
152cdf0e10cSrcweir         aDragStartDiff = rStartPos - aMarkedRect.TopLeft();
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         sal_Bool bAnyOle, bOneOle;
155cdf0e10cSrcweir         const SdrMarkList& rMarkList = GetMarkedObjectList();
156cdf0e10cSrcweir         lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir         ScDocShellRef aDragShellRef;
159cdf0e10cSrcweir         if (bAnyOle)
160cdf0e10cSrcweir         {
161cdf0e10cSrcweir             aDragShellRef = new ScDocShell;     // DocShell needs a Ref immediately
162cdf0e10cSrcweir             aDragShellRef->DoInitNew(NULL);
163cdf0e10cSrcweir         }
164cdf0e10cSrcweir         ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
165cdf0e10cSrcweir         SdrModel* pModel = GetAllMarkedModel();
166cdf0e10cSrcweir         ScDrawLayer::SetGlobalDrawPersist(NULL);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         //  Charts now always copy their data in addition to the source reference, so
169cdf0e10cSrcweir         //  there's no need to call SchDLL::Update for the charts in the clipboard doc.
170cdf0e10cSrcweir         //  Update with the data (including NumberFormatter) from the live document would
171cdf0e10cSrcweir         //  also store the NumberFormatter in the clipboard chart (#88749#)
172cdf0e10cSrcweir         // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         ScDocShell* pDocSh = pViewData->GetDocShell();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir         TransferableObjectDescriptor aObjDesc;
177cdf0e10cSrcweir         pDocSh->FillTransferableObjectDescriptor( aObjDesc );
178cdf0e10cSrcweir         aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
179cdf0e10cSrcweir         // maSize is set in ScDrawTransferObj ctor
180cdf0e10cSrcweir 
181cdf0e10cSrcweir         ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
182cdf0e10cSrcweir         uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
183cdf0e10cSrcweir 
184cdf0e10cSrcweir         pTransferObj->SetDrawPersist( &aDragShellRef );    // keep persist for ole objects alive
185cdf0e10cSrcweir         pTransferObj->SetDragSource( this );            // copies selection
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         SC_MOD()->SetDragObject( NULL, pTransferObj );      // for internal D&D
188cdf0e10cSrcweir         pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
189cdf0e10cSrcweir     }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     return bReturn;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
DoCopy()194cdf0e10cSrcweir void ScDrawView::DoCopy()
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     sal_Bool bAnyOle, bOneOle;
197cdf0e10cSrcweir     const SdrMarkList& rMarkList = GetMarkedObjectList();
198cdf0e10cSrcweir     lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     // update ScGlobal::pDrawClipDocShellRef
201cdf0e10cSrcweir     ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
202cdf0e10cSrcweir     SdrModel* pModel = GetAllMarkedModel();
203cdf0e10cSrcweir     ScDrawLayer::SetGlobalDrawPersist(NULL);
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     //  Charts now always copy their data in addition to the source reference, so
206cdf0e10cSrcweir     //  there's no need to call SchDLL::Update for the charts in the clipboard doc.
207cdf0e10cSrcweir     //  Update with the data (including NumberFormatter) from the live document would
208cdf0e10cSrcweir     //  also store the NumberFormatter in the clipboard chart (#88749#)
209cdf0e10cSrcweir     // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     ScDocShell* pDocSh = pViewData->GetDocShell();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     TransferableObjectDescriptor aObjDesc;
214cdf0e10cSrcweir     pDocSh->FillTransferableObjectDescriptor( aObjDesc );
215cdf0e10cSrcweir     aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
216cdf0e10cSrcweir     // maSize is set in ScDrawTransferObj ctor
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
219cdf0e10cSrcweir     uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
220cdf0e10cSrcweir 
221cdf0e10cSrcweir     if ( ScGlobal::pDrawClipDocShellRef )
222cdf0e10cSrcweir     {
223cdf0e10cSrcweir         pTransferObj->SetDrawPersist( &(*ScGlobal::pDrawClipDocShellRef) );    // keep persist for ole objects alive
224cdf0e10cSrcweir     }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     pTransferObj->CopyToClipboard( pViewData->GetActiveWin() );     // system clipboard
227cdf0e10cSrcweir     SC_MOD()->SetClipObject( NULL, pTransferObj );                  // internal clipboard
228cdf0e10cSrcweir }
229cdf0e10cSrcweir 
CopyToTransferable()230cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable()
231cdf0e10cSrcweir {
232cdf0e10cSrcweir     sal_Bool bAnyOle, bOneOle;
233cdf0e10cSrcweir     const SdrMarkList& rMarkList = GetMarkedObjectList();
234cdf0e10cSrcweir     lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     // update ScGlobal::pDrawClipDocShellRef
237cdf0e10cSrcweir     ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
238cdf0e10cSrcweir     SdrModel* pModel = GetAllMarkedModel();
239cdf0e10cSrcweir     ScDrawLayer::SetGlobalDrawPersist(NULL);
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     //  Charts now always copy their data in addition to the source reference, so
242cdf0e10cSrcweir     //  there's no need to call SchDLL::Update for the charts in the clipboard doc.
243cdf0e10cSrcweir     //  Update with the data (including NumberFormatter) from the live document would
244cdf0e10cSrcweir     //  also store the NumberFormatter in the clipboard chart (#88749#)
245cdf0e10cSrcweir     // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
246cdf0e10cSrcweir 
247cdf0e10cSrcweir     ScDocShell* pDocSh = pViewData->GetDocShell();
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     TransferableObjectDescriptor aObjDesc;
250cdf0e10cSrcweir     pDocSh->FillTransferableObjectDescriptor( aObjDesc );
251cdf0e10cSrcweir     aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
252cdf0e10cSrcweir     // maSize is set in ScDrawTransferObj ctor
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
255cdf0e10cSrcweir     uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     if ( ScGlobal::pDrawClipDocShellRef )
258cdf0e10cSrcweir     {
259cdf0e10cSrcweir         pTransferObj->SetDrawPersist( &(*ScGlobal::pDrawClipDocShellRef) );    // keep persist for ole objects alive
260cdf0e10cSrcweir     }
261cdf0e10cSrcweir 
262cdf0e10cSrcweir     return xTransferable;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir //  Korrektur fuer 100% berechnen, unabhaengig von momentanen Einstellungen
266cdf0e10cSrcweir 
CalcNormScale(Fraction & rFractX,Fraction & rFractY) const267cdf0e10cSrcweir void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
270cdf0e10cSrcweir     double nPPTX = ScGlobal::nScreenPPTX;
271cdf0e10cSrcweir     double nPPTY = ScGlobal::nScreenPPTY;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     if (pViewData)
274cdf0e10cSrcweir         nPPTX /= pViewData->GetDocShell()->GetOutputFactor();
275cdf0e10cSrcweir 
276cdf0e10cSrcweir     SCCOL nEndCol = 0;
277cdf0e10cSrcweir     SCROW nEndRow = 0;
278cdf0e10cSrcweir     pDoc->GetTableArea( nTab, nEndCol, nEndRow );
279cdf0e10cSrcweir     if (nEndCol<20)
280cdf0e10cSrcweir         nEndCol = 20;
281cdf0e10cSrcweir     if (nEndRow<20)
282cdf0e10cSrcweir         nEndRow = 20;
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     Fraction aZoom(1,1);
285cdf0e10cSrcweir     ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev, aZoom,aZoom,
286cdf0e10cSrcweir                             nPPTX, nPPTY, rFractX,rFractY );
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
SetMarkedOriginalSize()289cdf0e10cSrcweir void ScDrawView::SetMarkedOriginalSize()
290cdf0e10cSrcweir {
291cdf0e10cSrcweir     SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*GetModel());
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     const SdrMarkList& rMarkList = GetMarkedObjectList();
294cdf0e10cSrcweir     long nDone = 0;
295cdf0e10cSrcweir     sal_uLong nCount = rMarkList.GetMarkCount();
296cdf0e10cSrcweir     for (sal_uLong i=0; i<nCount; i++)
297cdf0e10cSrcweir     {
298cdf0e10cSrcweir         SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
299cdf0e10cSrcweir         sal_uInt16 nIdent = pObj->GetObjIdentifier();
300cdf0e10cSrcweir         sal_Bool bDo = sal_False;
301cdf0e10cSrcweir         Size aOriginalSize;
302cdf0e10cSrcweir         if (nIdent == OBJ_OLE2)
303cdf0e10cSrcweir         {
304cdf0e10cSrcweir             // TODO/LEAN: working with visual area can switch object to running state
305cdf0e10cSrcweir             uno::Reference < embed::XEmbeddedObject > xObj( ((SdrOle2Obj*)pObj)->GetObjRef(), uno::UNO_QUERY );
306cdf0e10cSrcweir             if ( xObj.is() )    // #121612# NULL for an invalid object that couldn't be loaded
307cdf0e10cSrcweir             {
308cdf0e10cSrcweir                 sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
309cdf0e10cSrcweir 
310cdf0e10cSrcweir                 if ( nAspect == embed::Aspects::MSOLE_ICON )
311cdf0e10cSrcweir                 {
312cdf0e10cSrcweir                     MapMode aMapMode( MAP_100TH_MM );
313cdf0e10cSrcweir                     aOriginalSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMapMode );
314cdf0e10cSrcweir                     bDo = sal_True;
315cdf0e10cSrcweir                 }
316cdf0e10cSrcweir                 else
317cdf0e10cSrcweir                 {
318cdf0e10cSrcweir                     MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( ((SdrOle2Obj*)pObj)->GetAspect() ) );
319cdf0e10cSrcweir                     awt::Size aSz;
320cdf0e10cSrcweir                     try
321cdf0e10cSrcweir                     {
322cdf0e10cSrcweir                         aSz = xObj->getVisualAreaSize( ((SdrOle2Obj*)pObj)->GetAspect() );
323cdf0e10cSrcweir                         aOriginalSize = OutputDevice::LogicToLogic(
324cdf0e10cSrcweir                                             Size( aSz.Width, aSz.Height ),
325cdf0e10cSrcweir                                             aUnit, MAP_100TH_MM );
326cdf0e10cSrcweir                         bDo = sal_True;
327cdf0e10cSrcweir                     } catch( embed::NoVisualAreaSizeException& )
328cdf0e10cSrcweir                     {
329cdf0e10cSrcweir                         OSL_ENSURE( sal_False, "Can't get the original size of the object!" );
330cdf0e10cSrcweir                     }
331cdf0e10cSrcweir                 }
332cdf0e10cSrcweir             }
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir         else if (nIdent == OBJ_GRAF)
335cdf0e10cSrcweir         {
336cdf0e10cSrcweir             const Graphic& rGraphic = ((SdrGrafObj*)pObj)->GetGraphic();
337cdf0e10cSrcweir 
338cdf0e10cSrcweir             MapMode aSourceMap = rGraphic.GetPrefMapMode();
339cdf0e10cSrcweir             MapMode aDestMap( MAP_100TH_MM );
340cdf0e10cSrcweir             if (aSourceMap.GetMapUnit() == MAP_PIXEL)
341cdf0e10cSrcweir             {
342cdf0e10cSrcweir                 //  Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt
343cdf0e10cSrcweir 
344cdf0e10cSrcweir                 Fraction aNormScaleX, aNormScaleY;
345cdf0e10cSrcweir                 CalcNormScale( aNormScaleX, aNormScaleY );
346cdf0e10cSrcweir                 aDestMap.SetScaleX(aNormScaleX);
347cdf0e10cSrcweir                 aDestMap.SetScaleY(aNormScaleY);
348cdf0e10cSrcweir             }
349cdf0e10cSrcweir             if (pViewData)
350cdf0e10cSrcweir             {
351cdf0e10cSrcweir                 Window* pActWin = pViewData->GetActiveWin();
352cdf0e10cSrcweir                 if (pActWin)
353cdf0e10cSrcweir                 {
354cdf0e10cSrcweir                     aOriginalSize = pActWin->LogicToLogic(
355cdf0e10cSrcweir                                     rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
356cdf0e10cSrcweir                     bDo = sal_True;
357cdf0e10cSrcweir                 }
358cdf0e10cSrcweir             }
359cdf0e10cSrcweir         }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir         if ( bDo )
362cdf0e10cSrcweir         {
363cdf0e10cSrcweir             Rectangle aDrawRect = pObj->GetLogicRect();
364cdf0e10cSrcweir 
365cdf0e10cSrcweir             pUndoGroup->AddAction( new SdrUndoGeoObj( *pObj ) );
366cdf0e10cSrcweir             pObj->Resize( aDrawRect.TopLeft(), Fraction( aOriginalSize.Width(), aDrawRect.GetWidth() ),
367cdf0e10cSrcweir                                                  Fraction( aOriginalSize.Height(), aDrawRect.GetHeight() ) );
368cdf0e10cSrcweir             ++nDone;
369cdf0e10cSrcweir         }
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir 
372cdf0e10cSrcweir     if (nDone)
373cdf0e10cSrcweir     {
374cdf0e10cSrcweir         pUndoGroup->SetComment(ScGlobal::GetRscString( STR_UNDO_ORIGINALSIZE ));
375cdf0e10cSrcweir         ScDocShell* pDocSh = pViewData->GetDocShell();
376cdf0e10cSrcweir         pDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
377cdf0e10cSrcweir         pDocSh->SetDrawModified();
378cdf0e10cSrcweir     }
379cdf0e10cSrcweir     else
380cdf0e10cSrcweir         delete pUndoGroup;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 
384cdf0e10cSrcweir #ifdef _MSC_VER
385cdf0e10cSrcweir #pragma optimize ( "", on )
386cdf0e10cSrcweir #endif
387