merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / view / drawvie3.cxx
blob6c4ee1e68bd04d65e73c468c7120a0434dfd04ad
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: drawvie3.cxx,v $
10 * $Revision: 1.16.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <svx/svdograf.hxx>
39 #include <svx/svdoole2.hxx>
40 #include <sfx2/app.hxx>
41 #include <sfx2/viewfrm.hxx>
43 #include "drawview.hxx"
44 #include "drwlayer.hxx"
45 #include "viewdata.hxx"
46 #include "dbfunc.hxx"
47 #include "document.hxx"
48 #include "userdat.hxx"
49 #include "tabvwsh.hxx"
50 #include "docsh.hxx"
52 void ScIMapDlgSet( const Graphic& rGraphic, const ImageMap* pImageMap,
53 const TargetList* pTargetList, void* pEditingObj ); // imapwrap
54 USHORT ScIMapChildWindowId();
56 // STATIC DATA -----------------------------------------------------------
58 ScDrawView::ScDrawView( OutputDevice* pOut, ScViewData* pData ) :
59 FmFormView( pData->GetDocument()->GetDrawLayer(), pOut ),
60 pViewData( pData ),
61 pDev( pOut ),
62 pDoc( pData->GetDocument() ),
63 nTab( pData->GetTabNo() ),
64 pDropMarker( NULL ),
65 pDropMarkObj( NULL ),
66 bInConstruct( TRUE )
67 //HMHbDisableHdl( FALSE )
69 // #i73602# Use default from the configuration
70 SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Calc());
72 // #i74769#, #i75172# Use default from the configuration
73 SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Calc());
75 Construct();
78 // Verankerung setzen
80 void ScDrawView::SetAnchor( ScAnchorType eType )
82 SdrObject* pObj = NULL;
83 if( AreObjectsMarked() )
85 const SdrMarkList* pMark = &GetMarkedObjectList();
86 ULONG nCount = pMark->GetMarkCount();
87 for( ULONG i=0; i<nCount; i++ )
89 pObj = pMark->GetMark(i)->GetMarkedSdrObj();
90 ScDrawLayer::SetAnchor( pObj, eType );
93 if ( pViewData )
94 pViewData->GetDocShell()->SetDrawModified();
98 ScAnchorType ScDrawView::GetAnchor() const
100 BOOL bPage = FALSE;
101 BOOL bCell = FALSE;
102 const SdrObject* pObj = NULL;
103 if( AreObjectsMarked() )
105 const SdrMarkList* pMark = &GetMarkedObjectList();
106 ULONG nCount = pMark->GetMarkCount();
107 Point p0;
108 for( ULONG i=0; i<nCount; i++ )
110 pObj = pMark->GetMark(i)->GetMarkedSdrObj();
111 if( ScDrawLayer::GetAnchor( pObj ) == SCA_CELL )
112 bCell =TRUE;
113 else
114 bPage = TRUE;
117 if( bPage && !bCell )
118 return SCA_PAGE;
119 if( !bPage && bCell )
120 return SCA_CELL;
121 return SCA_DONTKNOW;
124 void __EXPORT ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
126 if (rHint.ISA(ScTabDeletedHint)) // Tabelle geloescht
128 SCTAB nDelTab = ((ScTabDeletedHint&)rHint).GetTab();
129 if (ValidTab(nDelTab))
131 // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here
132 if ( nDelTab == nTab )
133 HideSdrPage();
136 else if (rHint.ISA(ScTabSizeChangedHint)) // Groesse geaendert
138 if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
139 UpdateWorkArea();
141 else
142 FmFormView::Notify( rBC,rHint );
145 void ScDrawView::UpdateIMap( SdrObject* pObj )
147 if ( pViewData &&
148 pViewData->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) &&
149 pObj && ( pObj->ISA(SdrGrafObj) || pObj->ISA(SdrOle2Obj) ) )
151 Graphic aGraphic;
152 TargetList aTargetList;
153 ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pObj );
154 const ImageMap* pImageMap = NULL;
155 if ( pIMapInfo )
156 pImageMap = &pIMapInfo->GetImageMap();
158 // Target-Liste besorgen
159 pViewData->GetViewShell()->GetViewFrame()->GetTargetList( aTargetList );
161 // Grafik vom Objekt besorgen
162 if ( pObj->ISA( SdrGrafObj ) )
163 aGraphic = ( (SdrGrafObj*) pObj )->GetGraphic();
164 else
166 Graphic* pGraphic = ((const SdrOle2Obj*) pObj )->GetGraphic();
167 if ( pGraphic )
168 aGraphic = *pGraphic;
171 ScIMapDlgSet( aGraphic, pImageMap, &aTargetList, pObj ); // aus imapwrap
173 // TargetListe kann von uns wieder geloescht werden
174 String* pEntry = aTargetList.First();
175 while( pEntry )
177 delete pEntry;
178 pEntry = aTargetList.Next();