xref: /aoo42x/main/sc/source/ui/view/drawvie3.cxx (revision b3f79822)
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
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 // INCLUDE ---------------------------------------------------------------
30 
31 #include <svx/svdograf.hxx>
32 #include <svx/svdoole2.hxx>
33 #include <sfx2/app.hxx>
34 #include <sfx2/viewfrm.hxx>
35 
36 #include "drawview.hxx"
37 #include "drwlayer.hxx"
38 #include "viewdata.hxx"
39 #include "dbfunc.hxx"
40 #include "document.hxx"
41 #include "userdat.hxx"
42 #include "tabvwsh.hxx"
43 #include "docsh.hxx"
44 
45 void ScIMapDlgSet( const Graphic& rGraphic, const ImageMap* pImageMap,
46 					const TargetList* pTargetList, void* pEditingObj );		// imapwrap
47 sal_uInt16 ScIMapChildWindowId();
48 
49 // STATIC DATA -----------------------------------------------------------
50 
ScDrawView(OutputDevice * pOut,ScViewData * pData)51 ScDrawView::ScDrawView( OutputDevice* pOut, ScViewData* pData ) :
52 	FmFormView( pData->GetDocument()->GetDrawLayer(), pOut ),
53 	pViewData( pData ),
54 	pDev( pOut ),
55 	pDoc( pData->GetDocument() ),
56 	nTab( pData->GetTabNo() ),
57 	pDropMarker( NULL ),
58 	pDropMarkObj( NULL ),
59 	bInConstruct( sal_True )
60 	//HMHbDisableHdl( sal_False )
61 {
62 	// #i73602# Use default from the configuration
63 	SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Calc());
64 
65 	// #i74769#, #i75172# Use default from the configuration
66 	SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Calc());
67 
68 	Construct();
69 }
70 
71 // Verankerung setzen
72 
SetAnchor(ScAnchorType eType)73 void ScDrawView::SetAnchor( ScAnchorType eType )
74 {
75 	SdrObject* pObj = NULL;
76 	if( AreObjectsMarked() )
77 	{
78 		const SdrMarkList* pMark = &GetMarkedObjectList();
79 		sal_uLong nCount = pMark->GetMarkCount();
80 		for( sal_uLong i=0; i<nCount; i++ )
81 		{
82 			pObj = pMark->GetMark(i)->GetMarkedSdrObj();
83 			ScDrawLayer::SetAnchor( pObj, eType );
84 		}
85 
86 		if ( pViewData )
87 			pViewData->GetDocShell()->SetDrawModified();
88 	}
89 }
90 
GetAnchor() const91 ScAnchorType ScDrawView::GetAnchor() const
92 {
93 	sal_Bool bPage = sal_False;
94 	sal_Bool bCell = sal_False;
95 	const SdrObject* pObj = NULL;
96 	if( AreObjectsMarked() )
97 	{
98 		const SdrMarkList* pMark = &GetMarkedObjectList();
99 		sal_uLong nCount = pMark->GetMarkCount();
100 		Point p0;
101 		for( sal_uLong i=0; i<nCount; i++ )
102 		{
103 			pObj = pMark->GetMark(i)->GetMarkedSdrObj();
104 			if( ScDrawLayer::GetAnchor( pObj ) == SCA_CELL )
105 				bCell =sal_True;
106 			else
107 				bPage = sal_True;
108 		}
109 	}
110 	if( bPage && !bCell )
111 		return SCA_PAGE;
112 	if( !bPage && bCell )
113 		return SCA_CELL;
114 	return SCA_DONTKNOW;
115 }
116 
Notify(SfxBroadcaster & rBC,const SfxHint & rHint)117 void __EXPORT ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
118 {
119 	if (rHint.ISA(ScTabDeletedHint))						// Tabelle geloescht
120 	{
121 		SCTAB nDelTab = ((ScTabDeletedHint&)rHint).GetTab();
122 		if (ValidTab(nDelTab))
123 		{
124             // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here
125             if ( nDelTab == nTab )
126                 HideSdrPage();
127 		}
128 	}
129 	else if (rHint.ISA(ScTabSizeChangedHint))				// Groesse geaendert
130 	{
131 		if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
132 			UpdateWorkArea();
133 	}
134 	else
135 		FmFormView::Notify( rBC,rHint );
136 }
137 
UpdateIMap(SdrObject * pObj)138 void ScDrawView::UpdateIMap( SdrObject* pObj )
139 {
140 	if ( pViewData &&
141 		 pViewData->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) &&
142 		 pObj && ( pObj->ISA(SdrGrafObj) || pObj->ISA(SdrOle2Obj) ) )
143 	{
144 		Graphic		aGraphic;
145 		TargetList	aTargetList;
146 		ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pObj );
147 		const ImageMap* pImageMap = NULL;
148 		if ( pIMapInfo )
149 			pImageMap = &pIMapInfo->GetImageMap();
150 
151 		// Target-Liste besorgen
152 		pViewData->GetViewShell()->GetViewFrame()->GetTargetList( aTargetList );
153 
154 		// Grafik vom Objekt besorgen
155 		if ( pObj->ISA( SdrGrafObj ) )
156 			aGraphic = ( (SdrGrafObj*) pObj )->GetGraphic();
157 		else
158         {
159             Graphic* pGraphic = ((const SdrOle2Obj*) pObj )->GetGraphic();
160             if ( pGraphic )
161                 aGraphic = *pGraphic;
162         }
163 
164 		ScIMapDlgSet( aGraphic, pImageMap, &aTargetList, pObj );	// aus imapwrap
165 
166 		// TargetListe kann von uns wieder geloescht werden
167 		String* pEntry = aTargetList.First();
168 		while( pEntry )
169 		{
170 			delete pEntry;
171 			pEntry = aTargetList.Next();
172 		}
173 	}
174 }
175 
176 
177 
178 
179