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>
26 #include "scresid.hxx"
27 #include "drawview.hxx"
28 #include "drwlayer.hxx"
29 #include "imapwrap.hxx"
30 #include "viewdata.hxx"
32 #include "document.hxx"
33 #include "userdat.hxx"
34 #include "tabvwsh.hxx"
37 ScDrawView::ScDrawView( OutputDevice
* pOut
, ScViewData
* pData
) :
38 FmFormView( pData
->GetDocument()->GetDrawLayer(), pOut
),
41 pDoc( pData
->GetDocument() ),
42 nTab( pData
->GetTabNo() ),
47 // #i73602# Use default from the configuration
48 SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Calc());
50 // #i74769#, #i75172# Use default from the configuration
51 SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Calc());
58 void ScDrawView::SetPageAnchored()
60 if( AreObjectsMarked() )
62 const SdrMarkList
* pMark
= &GetMarkedObjectList();
63 const size_t nCount
= pMark
->GetMarkCount();
65 BegUndo( OUString(ScResId( SCSTR_UNDO_PAGE_ANCHOR
)) );
66 for( size_t i
=0; i
<nCount
; ++i
)
68 SdrObject
* pObj
= pMark
->GetMark(i
)->GetMarkedSdrObj();
69 AddUndo (new ScUndoAnchorData( pObj
, pDoc
, nTab
));
70 ScDrawLayer::SetPageAnchored( *pObj
);
75 pViewData
->GetDocShell()->SetDrawModified();
77 // Remove the anchor object.
78 maHdlList
.RemoveAllByKind(HDL_ANCHOR
);
79 maHdlList
.RemoveAllByKind(HDL_ANCHOR_TR
);
83 void ScDrawView::SetCellAnchored()
88 if( AreObjectsMarked() )
90 const SdrMarkList
* pMark
= &GetMarkedObjectList();
91 const size_t nCount
= pMark
->GetMarkCount();
93 BegUndo( OUString(ScResId( SCSTR_UNDO_CELL_ANCHOR
)) );
94 for( size_t i
=0; i
<nCount
; ++i
)
96 SdrObject
* pObj
= pMark
->GetMark(i
)->GetMarkedSdrObj();
97 AddUndo (new ScUndoAnchorData( pObj
, pDoc
, nTab
));
98 ScDrawLayer::SetCellAnchoredFromPosition(*pObj
, *pDoc
, nTab
);
103 pViewData
->GetDocShell()->SetDrawModified();
105 // Set the anchor object.
110 ScAnchorType
ScDrawView::GetAnchorType() const
114 if( AreObjectsMarked() )
116 const SdrMarkList
* pMark
= &GetMarkedObjectList();
117 const size_t nCount
= pMark
->GetMarkCount();
118 for( size_t i
=0; i
<nCount
; ++i
)
120 const SdrObject
* pObj
= pMark
->GetMark(i
)->GetMarkedSdrObj();
121 if( ScDrawLayer::GetAnchorType( *pObj
) == SCA_CELL
)
127 if( bPage
&& !bCell
)
129 if( !bPage
&& bCell
)
137 * Updated the anchors of any non-note object that is cell anchored which
138 * has been moved since the last anchors for its position was calculated.
140 void adjustAnchoredPosition(const SdrHint
& rHint
, const ScDocument
& rDoc
, SCTAB nTab
)
142 if (rHint
.GetKind() != HINT_OBJCHG
&& rHint
.GetKind() != HINT_OBJINSERTED
)
145 SdrObject
* pObj
= const_cast<SdrObject
*>(rHint
.GetObject());
149 ScDrawObjData
*pAnchor
= ScDrawLayer::GetObjData(pObj
);
153 if (pAnchor
->meType
== ScDrawObjData::CellNote
)
156 if (pAnchor
->maLastRect
== pObj
->GetSnapRect())
159 if (pAnchor
->maStart
.Tab() != nTab
)
160 // The object is not anchored on the current sheet. Skip it.
161 // TODO: In the future, we may want to adjust objects that are
162 // anchored on all selected sheets.
165 ScDrawLayer::SetCellAnchoredFromPosition(*pObj
, rDoc
, pAnchor
->maStart
.Tab());
170 void ScDrawView::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
172 if (dynamic_cast<const ScTabDeletedHint
*>(&rHint
)) // Tabelle geloescht
174 SCTAB nDelTab
= static_cast<const ScTabDeletedHint
&>(rHint
).GetTab();
175 if (ValidTab(nDelTab
))
177 // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here
178 if ( nDelTab
== nTab
)
182 else if (dynamic_cast<const ScTabSizeChangedHint
*>(&rHint
)) // Groesse geaendert
184 if ( nTab
== static_cast<const ScTabSizeChangedHint
&>(rHint
).GetTab() )
187 else if ( const SdrHint
* pSdrHint
= dynamic_cast<const 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
= static_cast<SdrGrafObj
*>(pObj
)->GetGraphic();
217 const Graphic
* pGraphic
= static_cast<const SdrOle2Obj
*>(pObj
)->GetGraphic();
219 aGraphic
= *pGraphic
;
222 ScIMapDlgSet( aGraphic
, pImageMap
, &aTargetList
, pObj
); // aus imapwrap
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */