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 .
20 #include <svx/svdograf.hxx>
21 #include <svx/svdoole2.hxx>
22 #include <sfx2/app.hxx>
23 #include <sfx2/viewfrm.hxx>
25 #include "drawview.hxx"
26 #include "drwlayer.hxx"
27 #include "viewdata.hxx"
29 #include "document.hxx"
30 #include "userdat.hxx"
31 #include "tabvwsh.hxx"
34 void ScIMapDlgSet( const Graphic
& rGraphic
, const ImageMap
* pImageMap
,
35 const TargetList
* pTargetList
, void* pEditingObj
); // imapwrap
36 sal_uInt16
ScIMapChildWindowId();
38 // STATIC DATA -----------------------------------------------------------
40 ScDrawView::ScDrawView( OutputDevice
* pOut
, ScViewData
* pData
) :
41 FmFormView( pData
->GetDocument()->GetDrawLayer(), pOut
),
44 pDoc( pData
->GetDocument() ),
45 nTab( pData
->GetTabNo() ),
50 // #i73602# Use default from the configuration
51 SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Calc());
53 // #i74769#, #i75172# Use default from the configuration
54 SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Calc());
61 void ScDrawView::SetPageAnchored()
63 SdrObject
* pObj
= NULL
;
64 if( AreObjectsMarked() )
66 const SdrMarkList
* pMark
= &GetMarkedObjectList();
67 sal_uLong nCount
= pMark
->GetMarkCount();
68 for( sal_uLong i
=0; i
<nCount
; i
++ )
70 pObj
= pMark
->GetMark(i
)->GetMarkedSdrObj();
71 ScDrawLayer::SetPageAnchored( *pObj
);
75 pViewData
->GetDocShell()->SetDrawModified();
77 // Remove the anchor object.
78 aHdl
.RemoveAllByKind(HDL_ANCHOR
);
79 aHdl
.RemoveAllByKind(HDL_ANCHOR_TR
);
83 void ScDrawView::SetCellAnchored()
88 SdrObject
* pObj
= NULL
;
89 if( AreObjectsMarked() )
91 const SdrMarkList
* pMark
= &GetMarkedObjectList();
92 sal_uLong nCount
= pMark
->GetMarkCount();
93 for( sal_uLong i
=0; i
<nCount
; i
++ )
95 pObj
= pMark
->GetMark(i
)->GetMarkedSdrObj();
96 ScDrawLayer::SetCellAnchoredFromPosition(*pObj
, *pDoc
, nTab
);
100 pViewData
->GetDocShell()->SetDrawModified();
102 // Set the anchor object.
107 ScAnchorType
ScDrawView::GetAnchorType() const
109 sal_Bool bPage
= false;
110 sal_Bool bCell
= false;
111 const SdrObject
* pObj
= NULL
;
112 if( AreObjectsMarked() )
114 const SdrMarkList
* pMark
= &GetMarkedObjectList();
115 sal_uLong nCount
= pMark
->GetMarkCount();
117 for( sal_uLong i
=0; i
<nCount
; i
++ )
119 pObj
= pMark
->GetMark(i
)->GetMarkedSdrObj();
120 if( ScDrawLayer::GetAnchorType( *pObj
) == SCA_CELL
)
126 if( bPage
&& !bCell
)
128 if( !bPage
&& bCell
)
136 * Updated the anchors of any non-note object that is cell anchored which
137 * has been moved since the last anchors for its position was calculated.
139 void adjustAnchoredPosition(const SdrHint
& rHint
, const ScDocument
& rDoc
, SCTAB nTab
)
141 if (rHint
.GetKind() != HINT_OBJCHG
&& rHint
.GetKind() != HINT_OBJINSERTED
)
144 SdrObject
* pObj
= const_cast<SdrObject
*>(rHint
.GetObject());
148 ScDrawObjData
*pAnchor
= ScDrawLayer::GetObjData(pObj
);
152 if (pAnchor
->meType
== ScDrawObjData::CellNote
)
155 if (pAnchor
->maLastRect
== pObj
->GetLogicRect())
158 if (pAnchor
->maStart
.Tab() != nTab
)
159 // The object is not anchored on the current sheet. Skip it.
160 // TODO: In the future, we may want to adjust objects that are
161 // anchored on all selected sheets.
164 ScDrawLayer::SetCellAnchoredFromPosition(*pObj
, rDoc
, pAnchor
->maStart
.Tab());
169 void ScDrawView::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
171 if (rHint
.ISA(ScTabDeletedHint
)) // Tabelle geloescht
173 SCTAB nDelTab
= ((ScTabDeletedHint
&)rHint
).GetTab();
174 if (ValidTab(nDelTab
))
176 // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here
177 if ( nDelTab
== nTab
)
181 else if (rHint
.ISA(ScTabSizeChangedHint
)) // Groesse geaendert
183 if ( nTab
== ((ScTabSizeChangedHint
&)rHint
).GetTab() )
186 else if ( rHint
.ISA( SdrHint
) )
188 if (const SdrHint
* pSdrHint
= PTR_CAST( SdrHint
, &rHint
))
189 adjustAnchoredPosition(*pSdrHint
, *pDoc
, nTab
);
190 FmFormView::Notify( rBC
,rHint
);
193 FmFormView::Notify( rBC
,rHint
);
196 void ScDrawView::UpdateIMap( SdrObject
* pObj
)
199 pViewData
->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) &&
200 pObj
&& ( pObj
->ISA(SdrGrafObj
) || pObj
->ISA(SdrOle2Obj
) ) )
203 TargetList aTargetList
;
204 ScIMapInfo
* pIMapInfo
= ScDrawLayer::GetIMapInfo( pObj
);
205 const ImageMap
* pImageMap
= NULL
;
207 pImageMap
= &pIMapInfo
->GetImageMap();
209 // Target-Liste besorgen
210 pViewData
->GetViewShell()->GetViewFrame()->GetTargetList( aTargetList
);
212 // Grafik vom Objekt besorgen
213 if ( pObj
->ISA( SdrGrafObj
) )
214 aGraphic
= ( (SdrGrafObj
*) pObj
)->GetGraphic();
217 Graphic
* pGraphic
= ((const SdrOle2Obj
*) pObj
)->GetGraphic();
219 aGraphic
= *pGraphic
;
222 ScIMapDlgSet( aGraphic
, pImageMap
, &aTargetList
, pObj
); // aus imapwrap
224 // TargetListe kann von uns wieder geloescht werden
225 for ( size_t i
= 0, n
= aTargetList
.size(); i
< n
; ++i
)
226 delete aTargetList
[ i
];
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */