xref: /trunk/main/sc/source/ui/view/drawview.cxx (revision 14af77b6d25ba272273c2e5e4523fbde7e527166)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/embed/EmbedStates.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <svx/svditer.hxx>
32cdf0e10cSrcweir #include <svx/svdograf.hxx>
33cdf0e10cSrcweir #include <svx/svdomedia.hxx>
34cdf0e10cSrcweir #include <svx/svdogrp.hxx>
35cdf0e10cSrcweir #include <svx/svdoole2.hxx>
36cdf0e10cSrcweir #include <svx/svdouno.hxx>
37cdf0e10cSrcweir #include <svx/svdpage.hxx>
38cdf0e10cSrcweir #include <svx/svdundo.hxx>
39cdf0e10cSrcweir #include <svx/svdocapt.hxx>
40cdf0e10cSrcweir #include <editeng/outlobj.hxx>
41cdf0e10cSrcweir #include <editeng/writingmodeitem.hxx>
42cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
43cdf0e10cSrcweir #include <sfx2/bindings.hxx>
44cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
45*14af77b6SArmin Le Grand #include <svx/sdrundomanager.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include "drawview.hxx"
48cdf0e10cSrcweir #include "global.hxx"
49cdf0e10cSrcweir #include "viewdata.hxx"
50cdf0e10cSrcweir #include "document.hxx"
51cdf0e10cSrcweir #include "drawutil.hxx"
52cdf0e10cSrcweir #include "futext.hxx"
53cdf0e10cSrcweir #include "globstr.hrc"
54cdf0e10cSrcweir #include "tabvwsh.hxx"
55cdf0e10cSrcweir #include "client.hxx"
56cdf0e10cSrcweir #include "scmod.hxx"
57cdf0e10cSrcweir #include "drwlayer.hxx"
58cdf0e10cSrcweir #include "docsh.hxx"
59cdf0e10cSrcweir #include "viewuno.hxx"
60cdf0e10cSrcweir #include "userdat.hxx"
61cdf0e10cSrcweir #include "postit.hxx"
62cdf0e10cSrcweir #include "undocell.hxx"
63*14af77b6SArmin Le Grand #include "document.hxx"
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #include "sc.hrc"
66cdf0e10cSrcweir 
67cdf0e10cSrcweir using namespace com::sun::star;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir // -----------------------------------------------------------------------
70cdf0e10cSrcweir 
71cdf0e10cSrcweir #define SC_HANDLESIZE_BIG       9
72cdf0e10cSrcweir #define SC_HANDLESIZE_SMALL     7
73cdf0e10cSrcweir 
74cdf0e10cSrcweir // -----------------------------------------------------------------------
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #ifdef _MSC_VER
77cdf0e10cSrcweir #pragma optimize ( "", off )
78cdf0e10cSrcweir #endif
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
81cdf0e10cSrcweir void ScDrawView::Construct()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     EnableExtendedKeyInputDispatcher(sal_False);
84cdf0e10cSrcweir     EnableExtendedMouseEventDispatcher(sal_False);
85cdf0e10cSrcweir     EnableExtendedCommandEventDispatcher(sal_False);
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     SetFrameDragSingles(sal_True);
88cdf0e10cSrcweir //  SetSolidMarkHdl(sal_True);              // einstellbar -> UpdateUserViewOptions
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     SetMinMoveDistancePixel( 2 );
91cdf0e10cSrcweir     SetHitTolerancePixel( 2 );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     if (pViewData)
94cdf0e10cSrcweir     {
95cdf0e10cSrcweir         SCTAB nViewTab = pViewData->GetTabNo();
96cdf0e10cSrcweir         ShowSdrPage(GetModel()->GetPage(nViewTab));
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         sal_Bool bEx = pViewData->GetViewShell()->IsDrawSelMode();
99cdf0e10cSrcweir         sal_Bool bProt = pDoc->IsTabProtected( nViewTab ) ||
100cdf0e10cSrcweir                      pViewData->GetSfxDocShell()->IsReadOnly();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         SdrLayer* pLayer;
103cdf0e10cSrcweir         SdrLayerAdmin& rAdmin = GetModel()->GetLayerAdmin();
104cdf0e10cSrcweir         pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
105cdf0e10cSrcweir         if (pLayer)
106cdf0e10cSrcweir             SetLayerLocked( pLayer->GetName(), bProt || !bEx );
107cdf0e10cSrcweir         pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
108cdf0e10cSrcweir         if (pLayer)
109cdf0e10cSrcweir             SetLayerLocked( pLayer->GetName(), sal_True );
110cdf0e10cSrcweir         pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
111cdf0e10cSrcweir         if (pLayer)
112cdf0e10cSrcweir         {
113cdf0e10cSrcweir             SetLayerLocked( pLayer->GetName(), bProt );
114cdf0e10cSrcweir             SetActiveLayer( pLayer->GetName() );        // FRONT als aktiven Layer setzen
115cdf0e10cSrcweir         }
116cdf0e10cSrcweir         pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
117cdf0e10cSrcweir         if (pLayer)
118cdf0e10cSrcweir             SetLayerLocked( pLayer->GetName(), bProt );
119cdf0e10cSrcweir         pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
120cdf0e10cSrcweir         if (pLayer)
121cdf0e10cSrcweir         {
122cdf0e10cSrcweir             SetLayerLocked( pLayer->GetName(), bProt );
123cdf0e10cSrcweir             SetLayerVisible( pLayer->GetName(), sal_False);
124cdf0e10cSrcweir         }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir         SetSwapAsynchron(sal_True);
127cdf0e10cSrcweir     }
128cdf0e10cSrcweir     else
129cdf0e10cSrcweir     {
130cdf0e10cSrcweir         ShowSdrPage(GetModel()->GetPage(nTab));
131cdf0e10cSrcweir     }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     UpdateUserViewOptions();
134cdf0e10cSrcweir     RecalcScale();
135cdf0e10cSrcweir     UpdateWorkArea();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     bInConstruct = sal_False;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir void ScDrawView::ImplClearCalcDropMarker()
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     if(pDropMarker)
143cdf0e10cSrcweir     {
144cdf0e10cSrcweir         delete pDropMarker;
145cdf0e10cSrcweir         pDropMarker = 0L;
146cdf0e10cSrcweir     }
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
149cdf0e10cSrcweir __EXPORT ScDrawView::~ScDrawView()
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     ImplClearCalcDropMarker();
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir void ScDrawView::AddCustomHdl()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir     sal_Bool bNegativePage = pDoc->IsNegativePage( nTab );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     const SdrMarkList &rMrkList = GetMarkedObjectList();
159cdf0e10cSrcweir     sal_uInt32 nCount = rMrkList.GetMarkCount();
160cdf0e10cSrcweir     for(sal_uInt32 nPos=0; nPos<nCount; nPos++ )
161cdf0e10cSrcweir     {
162cdf0e10cSrcweir         const SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
163cdf0e10cSrcweir         if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
164cdf0e10cSrcweir         {
165cdf0e10cSrcweir             const sal_Int32 nDelta = 1;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir             Rectangle aBoundRect = pObj->GetCurrentBoundRect();
168cdf0e10cSrcweir             Point aPos;
169cdf0e10cSrcweir             if (bNegativePage)
170cdf0e10cSrcweir             {
171cdf0e10cSrcweir                 aPos = aBoundRect.TopRight();
172cdf0e10cSrcweir                 aPos.X() = -aPos.X();           // so the loop below is the same
173cdf0e10cSrcweir             }
174cdf0e10cSrcweir             else
175cdf0e10cSrcweir                 aPos = aBoundRect.TopLeft();
176cdf0e10cSrcweir             long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta;
177cdf0e10cSrcweir             long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir             SCCOL nCol;
180cdf0e10cSrcweir             sal_Int32 nWidth = 0;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir             for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++)
183cdf0e10cSrcweir                 nWidth += pDoc->GetColWidth(nCol,nTab);
184cdf0e10cSrcweir 
185cdf0e10cSrcweir             if(nCol > 0)
186cdf0e10cSrcweir                 --nCol;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir             SCROW nRow = nPosY <= 0 ? 0 : pDoc->GetRowForHeight( nTab,
189cdf0e10cSrcweir                     (sal_uLong) nPosY);
190cdf0e10cSrcweir             if(nRow > 0)
191cdf0e10cSrcweir                 --nRow;
192cdf0e10cSrcweir 
193cdf0e10cSrcweir             ScTabView* pView = pViewData->GetView();
194cdf0e10cSrcweir             ScAddress aScAddress(nCol, nRow, nTab);
195cdf0e10cSrcweir             pView->CreateAnchorHandles(aHdl, aScAddress);
196cdf0e10cSrcweir         }
197cdf0e10cSrcweir     }
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir void ScDrawView::InvalidateAttribs()
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     if (!pViewData) return;
203cdf0e10cSrcweir     SfxBindings& rBindings = pViewData->GetBindings();
204cdf0e10cSrcweir 
205cdf0e10cSrcweir         // echte Statuswerte:
206cdf0e10cSrcweir     rBindings.InvalidateAll( sal_True );
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir void ScDrawView::InvalidateDrawTextAttrs()
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     if (!pViewData) return;
212cdf0e10cSrcweir     SfxBindings& rBindings = pViewData->GetBindings();
213cdf0e10cSrcweir 
214cdf0e10cSrcweir     //  cjk/ctl font items have no configured slots,
215cdf0e10cSrcweir     //  need no invalidate
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_CHAR_FONT );
218cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
219cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
220cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
221cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
222cdf0e10cSrcweir     rBindings.Invalidate( SID_ULINE_VAL_NONE );
223cdf0e10cSrcweir     rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
224cdf0e10cSrcweir     rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
225cdf0e10cSrcweir     rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
226cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
227cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
228cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGNLEFT );
229cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGNCENTERHOR );
230cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGNRIGHT );
231cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGNBLOCK );
232cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
233cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
234cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
235cdf0e10cSrcweir     rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
236cdf0e10cSrcweir     rBindings.Invalidate( SID_SET_SUB_SCRIPT );
237cdf0e10cSrcweir     rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
238cdf0e10cSrcweir     rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
239cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
240cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
241cdf0e10cSrcweir     // pseudo slots for Format menu
242cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
243cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
244cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
245cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
246cdf0e10cSrcweir }
247cdf0e10cSrcweir 
248cdf0e10cSrcweir //void ScDrawView::DrawMarks( OutputDevice* pOut ) const
249cdf0e10cSrcweir //{
250cdf0e10cSrcweir //  DBG_ASSERT(pOut, "ScDrawView::DrawMarks: No OutputDevice (!)");
251cdf0e10cSrcweir //  SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
252cdf0e10cSrcweir //
253cdf0e10cSrcweir //  if(pPaintWindow)
254cdf0e10cSrcweir //  {
255cdf0e10cSrcweir //      if(pPaintWindow->isXorVisible())
256cdf0e10cSrcweir //      {
257cdf0e10cSrcweir //          ToggleShownXor(pOut, 0L);
258cdf0e10cSrcweir //      }
259cdf0e10cSrcweir //  }
260cdf0e10cSrcweir //}
261cdf0e10cSrcweir 
262cdf0e10cSrcweir void ScDrawView::SetMarkedToLayer( sal_uInt8 nLayerNo )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir     if (AreObjectsMarked())
265cdf0e10cSrcweir     {
266cdf0e10cSrcweir         //  #i11702# use SdrUndoObjectLayerChange for undo
267cdf0e10cSrcweir         //  STR_UNDO_SELATTR is "Attributes" - should use a different text later
268cdf0e10cSrcweir         BegUndo( ScGlobal::GetRscString( STR_UNDO_SELATTR ) );
269cdf0e10cSrcweir 
270cdf0e10cSrcweir         const SdrMarkList& rMark = GetMarkedObjectList();
271cdf0e10cSrcweir         sal_uLong nCount = rMark.GetMarkCount();
272cdf0e10cSrcweir         for (sal_uLong i=0; i<nCount; i++)
273cdf0e10cSrcweir         {
274cdf0e10cSrcweir             SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
275cdf0e10cSrcweir             if ( !pObj->ISA(SdrUnoObj) && (pObj->GetLayer() != SC_LAYER_INTERN) )
276cdf0e10cSrcweir             {
277cdf0e10cSrcweir                 AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), (SdrLayerID)nLayerNo) );
278cdf0e10cSrcweir                 pObj->SetLayer( nLayerNo );
279cdf0e10cSrcweir             }
280cdf0e10cSrcweir         }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir         EndUndo();
283cdf0e10cSrcweir 
284cdf0e10cSrcweir         //  repaint is done in SetLayer
285cdf0e10cSrcweir 
286cdf0e10cSrcweir         pViewData->GetDocShell()->SetDrawModified();
287cdf0e10cSrcweir 
288cdf0e10cSrcweir         //  #84073# check mark list now instead of later in a timer
289cdf0e10cSrcweir         CheckMarked();
290cdf0e10cSrcweir         MarkListHasChanged();
291cdf0e10cSrcweir     }
292cdf0e10cSrcweir }
293cdf0e10cSrcweir 
294cdf0e10cSrcweir bool ScDrawView::HasMarkedControl() const
295cdf0e10cSrcweir {
296cdf0e10cSrcweir     SdrObjListIter aIter( GetMarkedObjectList() );
297cdf0e10cSrcweir     for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
298cdf0e10cSrcweir         if( pObj->ISA( SdrUnoObj ) )
299cdf0e10cSrcweir             return true;
300cdf0e10cSrcweir     return false;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir 
303cdf0e10cSrcweir bool ScDrawView::HasMarkedInternal() const
304cdf0e10cSrcweir {
305cdf0e10cSrcweir     // internal objects should not be inside a group, but who knows...
306cdf0e10cSrcweir     SdrObjListIter aIter( GetMarkedObjectList() );
307cdf0e10cSrcweir     for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
308cdf0e10cSrcweir         if( pObj->GetLayer() == SC_LAYER_INTERN )
309cdf0e10cSrcweir             return true;
310cdf0e10cSrcweir     return false;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir void ScDrawView::UpdateWorkArea()
314cdf0e10cSrcweir {
315cdf0e10cSrcweir     SdrPage* pPage = GetModel()->GetPage(static_cast<sal_uInt16>(nTab));
316cdf0e10cSrcweir     if (pPage)
317cdf0e10cSrcweir     {
318cdf0e10cSrcweir         Point aPos;
319cdf0e10cSrcweir         Size aPageSize( pPage->GetSize() );
320cdf0e10cSrcweir         Rectangle aNewArea( aPos, aPageSize );
321cdf0e10cSrcweir         if ( aPageSize.Width() < 0 )
322cdf0e10cSrcweir         {
323cdf0e10cSrcweir             //  RTL: from max.negative (left) to zero (right)
324cdf0e10cSrcweir             aNewArea.Right() = 0;
325cdf0e10cSrcweir             aNewArea.Left() = aPageSize.Width() + 1;
326cdf0e10cSrcweir         }
327cdf0e10cSrcweir         SetWorkArea( aNewArea );
328cdf0e10cSrcweir     }
329cdf0e10cSrcweir     else
330cdf0e10cSrcweir     {
331cdf0e10cSrcweir         DBG_ERROR("Page nicht gefunden");
332cdf0e10cSrcweir     }
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir void ScDrawView::DoCut()
336cdf0e10cSrcweir {
337cdf0e10cSrcweir     DoCopy();
338cdf0e10cSrcweir     BegUndo( ScGlobal::GetRscString( STR_UNDO_CUT ) );
339cdf0e10cSrcweir     DeleteMarked();     // auf dieser View - von der 505f Umstellung nicht betroffen
340cdf0e10cSrcweir     EndUndo();
341cdf0e10cSrcweir }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const
344cdf0e10cSrcweir {
345cdf0e10cSrcweir     rFractX = aScaleX;
346cdf0e10cSrcweir     rFractY = aScaleY;
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir void ScDrawView::RecalcScale()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir     double nPPTX;
352cdf0e10cSrcweir     double nPPTY;
353cdf0e10cSrcweir     Fraction aZoomX(1,1);
354cdf0e10cSrcweir     Fraction aZoomY(1,1);
355cdf0e10cSrcweir 
356cdf0e10cSrcweir     if (pViewData)
357cdf0e10cSrcweir     {
358cdf0e10cSrcweir         nTab = pViewData->GetTabNo();
359cdf0e10cSrcweir         nPPTX = pViewData->GetPPTX();
360cdf0e10cSrcweir         nPPTY = pViewData->GetPPTY();
361cdf0e10cSrcweir         aZoomX = pViewData->GetZoomX();
362cdf0e10cSrcweir         aZoomY = pViewData->GetZoomY();
363cdf0e10cSrcweir     }
364cdf0e10cSrcweir     else
365cdf0e10cSrcweir     {
366cdf0e10cSrcweir         Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
367cdf0e10cSrcweir         nPPTX = aLogic.X() / 1000.0;
368cdf0e10cSrcweir         nPPTY = aLogic.Y() / 1000.0;
369cdf0e10cSrcweir                                             //! Zoom uebergeben ???
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir 
372cdf0e10cSrcweir     SCCOL nEndCol = 0;
373cdf0e10cSrcweir     SCROW nEndRow = 0;
374cdf0e10cSrcweir     pDoc->GetTableArea( nTab, nEndCol, nEndRow );
375cdf0e10cSrcweir     if (nEndCol<20)
376cdf0e10cSrcweir         nEndCol = 20;
377cdf0e10cSrcweir     if (nEndRow<20)
378cdf0e10cSrcweir         nEndRow = 20;   // #i116848# instead of a large row number for an empty sheet, heights are multiplied in CalcScale
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY,
381cdf0e10cSrcweir                             aScaleX,aScaleY );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir void ScDrawView::DoConnect(SdrOle2Obj* pOleObj)
385cdf0e10cSrcweir {
386cdf0e10cSrcweir     if ( pViewData )
387cdf0e10cSrcweir         pViewData->GetViewShell()->ConnectObject( pOleObj );
388cdf0e10cSrcweir }
389cdf0e10cSrcweir 
390cdf0e10cSrcweir void ScDrawView::MarkListHasChanged()
391cdf0e10cSrcweir {
392cdf0e10cSrcweir     FmFormView::MarkListHasChanged();
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     UpdateBrowser();
395cdf0e10cSrcweir 
396cdf0e10cSrcweir     ScTabViewShell* pViewSh = pViewData->GetViewShell();
397cdf0e10cSrcweir 
398cdf0e10cSrcweir     // #i110829# remove the cell selection only if drawing objects are selected
399cdf0e10cSrcweir     if ( !bInConstruct && GetMarkedObjectList().GetMarkCount() )
400cdf0e10cSrcweir     {
401cdf0e10cSrcweir         pViewSh->Unmark();      // remove cell selection
402cdf0e10cSrcweir 
403cdf0e10cSrcweir         //  #65379# end cell edit mode if drawing objects are selected
404cdf0e10cSrcweir         SC_MOD()->InputEnterHandler();
405cdf0e10cSrcweir     }
406cdf0e10cSrcweir 
407cdf0e10cSrcweir     //  IP deaktivieren
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     ScModule* pScMod = SC_MOD();
410cdf0e10cSrcweir     bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
411cdf0e10cSrcweir 
412cdf0e10cSrcweir     ScClient* pClient = (ScClient*) pViewSh->GetIPClient();
413cdf0e10cSrcweir     if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
414cdf0e10cSrcweir     {
415cdf0e10cSrcweir         //  #41730# beim ViewShell::Activate aus dem Reset2Open nicht die Handles anzeigen
416cdf0e10cSrcweir         //HMHbDisableHdl = sal_True;
417cdf0e10cSrcweir         pClient->DeactivateObject();
418cdf0e10cSrcweir         //HMHbDisableHdl = sal_False;
419cdf0e10cSrcweir         //  Image-Ole wieder durch Grafik ersetzen passiert jetzt in ScClient::UIActivate
420cdf0e10cSrcweir     }
421cdf0e10cSrcweir 
422cdf0e10cSrcweir     //  Ole-Objekt selektiert?
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     SdrOle2Obj* pOle2Obj = NULL;
425cdf0e10cSrcweir     SdrGrafObj* pGrafObj = NULL;
426cdf0e10cSrcweir     SdrMediaObj* pMediaObj = NULL;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir     const SdrMarkList& rMarkList = GetMarkedObjectList();
429cdf0e10cSrcweir     sal_uLong nMarkCount = rMarkList.GetMarkCount();
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     if ( nMarkCount == 0 && !pViewData->GetViewShell()->IsDrawSelMode() && !bInConstruct )
432cdf0e10cSrcweir     {
433cdf0e10cSrcweir         //  relock layers that may have been unlocked before
434cdf0e10cSrcweir         LockBackgroundLayer();
435cdf0e10cSrcweir         LockInternalLayer();
436cdf0e10cSrcweir     }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     sal_Bool bSubShellSet = sal_False;
439cdf0e10cSrcweir     if (nMarkCount == 1)
440cdf0e10cSrcweir     {
441cdf0e10cSrcweir         SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
442cdf0e10cSrcweir         if (pObj->GetObjIdentifier() == OBJ_OLE2)
443cdf0e10cSrcweir         {
444cdf0e10cSrcweir             pOle2Obj = (SdrOle2Obj*) pObj;
445cdf0e10cSrcweir             if (!pDoc->IsChart(pObj) )
446cdf0e10cSrcweir                 pViewSh->SetOleObjectShell(sal_True);
447cdf0e10cSrcweir             else
448cdf0e10cSrcweir                 pViewSh->SetChartShell(sal_True);
449cdf0e10cSrcweir             bSubShellSet = sal_True;
450cdf0e10cSrcweir         }
451cdf0e10cSrcweir         else if (pObj->GetObjIdentifier() == OBJ_GRAF)
452cdf0e10cSrcweir         {
453cdf0e10cSrcweir             pGrafObj = (SdrGrafObj*) pObj;
454cdf0e10cSrcweir             pViewSh->SetGraphicShell(sal_True);
455cdf0e10cSrcweir             bSubShellSet = sal_True;
456cdf0e10cSrcweir         }
457cdf0e10cSrcweir         else if (pObj->GetObjIdentifier() == OBJ_MEDIA)
458cdf0e10cSrcweir         {
459cdf0e10cSrcweir             pMediaObj = (SdrMediaObj*) pObj;
460cdf0e10cSrcweir             pViewSh->SetMediaShell(sal_True);
461cdf0e10cSrcweir             bSubShellSet = sal_True;
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir         else if (pObj->GetObjIdentifier() != OBJ_TEXT   // Verhindern, das beim Anlegen
464cdf0e10cSrcweir                     || !pViewSh->IsDrawTextShell())     // eines TextObjekts auf die
465cdf0e10cSrcweir         {                                               // DrawShell umgeschaltet wird.
466cdf0e10cSrcweir             pViewSh->SetDrawShell(sal_True);                //@#70206#
467cdf0e10cSrcweir         }
468cdf0e10cSrcweir     }
469cdf0e10cSrcweir 
470cdf0e10cSrcweir     if ( nMarkCount && !bSubShellSet )
471cdf0e10cSrcweir     {
472cdf0e10cSrcweir         sal_Bool bOnlyControls = sal_True;
473cdf0e10cSrcweir         sal_Bool bOnlyGraf     = sal_True;
474cdf0e10cSrcweir         for (sal_uLong i=0; i<nMarkCount; i++)
475cdf0e10cSrcweir         {
476cdf0e10cSrcweir             SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
477cdf0e10cSrcweir             if ( pObj->ISA( SdrObjGroup ) )
478cdf0e10cSrcweir             {
479cdf0e10cSrcweir                 const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
480cdf0e10cSrcweir                 sal_uLong nListCount = pLst->GetObjCount();
481cdf0e10cSrcweir                 if ( nListCount == 0 )
482cdf0e10cSrcweir                 {
483cdf0e10cSrcweir                     //  #104156# An empty group (may occur during Undo) is no control or graphics object.
484cdf0e10cSrcweir                     //  Creating the form shell during undo would lead to problems with the undo manager.
485cdf0e10cSrcweir                     bOnlyControls = sal_False;
486cdf0e10cSrcweir                     bOnlyGraf = sal_False;
487cdf0e10cSrcweir                 }
488cdf0e10cSrcweir                 for ( sal_uInt16 j = 0; j < nListCount; ++j )
489cdf0e10cSrcweir                 {
490cdf0e10cSrcweir                     SdrObject *pSubObj = pLst->GetObj( j );
491cdf0e10cSrcweir 
492cdf0e10cSrcweir                     if (!pSubObj->ISA(SdrUnoObj))
493cdf0e10cSrcweir                         bOnlyControls = sal_False;
494cdf0e10cSrcweir                     if (pSubObj->GetObjIdentifier() != OBJ_GRAF)
495cdf0e10cSrcweir                         bOnlyGraf = sal_False;
496cdf0e10cSrcweir 
497cdf0e10cSrcweir                     if ( !bOnlyControls && !bOnlyGraf ) break;
498cdf0e10cSrcweir                 }
499cdf0e10cSrcweir             }
500cdf0e10cSrcweir             else
501cdf0e10cSrcweir             {
502cdf0e10cSrcweir                 if (!pObj->ISA(SdrUnoObj))
503cdf0e10cSrcweir                     bOnlyControls = sal_False;
504cdf0e10cSrcweir                 if (pObj->GetObjIdentifier() != OBJ_GRAF)
505cdf0e10cSrcweir                     bOnlyGraf = sal_False;
506cdf0e10cSrcweir             }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir             if ( !bOnlyControls && !bOnlyGraf ) break;
509cdf0e10cSrcweir         }
510cdf0e10cSrcweir 
511cdf0e10cSrcweir         if(bOnlyControls)
512cdf0e10cSrcweir         {
513cdf0e10cSrcweir             pViewSh->SetDrawFormShell(sal_True);            // jetzt UNO-Controls
514cdf0e10cSrcweir         }
515cdf0e10cSrcweir         else if(bOnlyGraf)
516cdf0e10cSrcweir         {
517cdf0e10cSrcweir             pViewSh->SetGraphicShell(sal_True);
518cdf0e10cSrcweir         }
519cdf0e10cSrcweir         else if(nMarkCount>1)
520cdf0e10cSrcweir         {
521cdf0e10cSrcweir             pViewSh->SetDrawShell(sal_True);
522cdf0e10cSrcweir         }
523cdf0e10cSrcweir     }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 
527cdf0e10cSrcweir     //  Verben anpassen
528cdf0e10cSrcweir 
529cdf0e10cSrcweir     SfxViewFrame* pViewFrame = pViewSh->GetViewFrame();
530cdf0e10cSrcweir     sal_Bool bOle = pViewSh->GetViewFrame()->GetFrame().IsInPlace();
531cdf0e10cSrcweir     uno::Sequence< embed::VerbDescriptor > aVerbs;
532cdf0e10cSrcweir     if ( pOle2Obj && !bOle )
533cdf0e10cSrcweir     {
534cdf0e10cSrcweir         uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef();
535cdf0e10cSrcweir         DBG_ASSERT( xObj.is(), "SdrOle2Obj ohne ObjRef" );
536cdf0e10cSrcweir         if (xObj.is())
537cdf0e10cSrcweir             aVerbs = xObj->getSupportedVerbs();
538cdf0e10cSrcweir     }
539cdf0e10cSrcweir     pViewSh->SetVerbs( aVerbs );
540cdf0e10cSrcweir 
541cdf0e10cSrcweir     //  Image-Map Editor
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     if ( pOle2Obj )
544cdf0e10cSrcweir         UpdateIMap( pOle2Obj );
545cdf0e10cSrcweir     else if ( pGrafObj )
546cdf0e10cSrcweir         UpdateIMap( pGrafObj );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir     InvalidateAttribs();                // nach dem IMap-Editor Update
549cdf0e10cSrcweir     InvalidateDrawTextAttrs();
550cdf0e10cSrcweir 
551cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < PaintWindowCount(); a++)
552cdf0e10cSrcweir     {
553cdf0e10cSrcweir         SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
554cdf0e10cSrcweir         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
555cdf0e10cSrcweir 
556cdf0e10cSrcweir         if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
557cdf0e10cSrcweir         {
558cdf0e10cSrcweir             ((Window&)rOutDev).Update();
559cdf0e10cSrcweir         }
560cdf0e10cSrcweir     }
561cdf0e10cSrcweir 
562cdf0e10cSrcweir     //  uno object for view returns drawing objects as selection,
563cdf0e10cSrcweir     //  so it must notify its SelectionChangeListeners
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     if (pViewFrame)
566cdf0e10cSrcweir     {
567cdf0e10cSrcweir         SfxFrame& rFrame = pViewFrame->GetFrame();
568cdf0e10cSrcweir         uno::Reference<frame::XController> xController = rFrame.GetController();
569cdf0e10cSrcweir         if (xController.is())
570cdf0e10cSrcweir         {
571cdf0e10cSrcweir             ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
572cdf0e10cSrcweir             if (pImp)
573cdf0e10cSrcweir                 pImp->SelectionChanged();
574cdf0e10cSrcweir         }
575cdf0e10cSrcweir     }
576cdf0e10cSrcweir 
577cdf0e10cSrcweir     //  update selection transfer object
578cdf0e10cSrcweir 
579cdf0e10cSrcweir     pViewSh->CheckSelectionTransfer();
580cdf0e10cSrcweir 
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
583cdf0e10cSrcweir void __EXPORT ScDrawView::ModelHasChanged()
584cdf0e10cSrcweir {
585cdf0e10cSrcweir     SdrObject* pEditObj = GetTextEditObject();
586cdf0e10cSrcweir     if ( pEditObj && !pEditObj->IsInserted() && pViewData )
587cdf0e10cSrcweir     {
588cdf0e10cSrcweir         //  #111700# SdrObjEditView::ModelHasChanged will end text edit in this case,
589cdf0e10cSrcweir         //  so make sure the EditEngine's undo manager is no longer used.
590cdf0e10cSrcweir         pViewData->GetViewShell()->SetDrawTextUndo(NULL);
591cdf0e10cSrcweir         SetCreateMode();    // don't leave FuText in a funny state
592cdf0e10cSrcweir     }
593cdf0e10cSrcweir 
594cdf0e10cSrcweir     FmFormView::ModelHasChanged();
595cdf0e10cSrcweir }
596cdf0e10cSrcweir 
597cdf0e10cSrcweir void __EXPORT ScDrawView::UpdateUserViewOptions()
598cdf0e10cSrcweir {
599cdf0e10cSrcweir     if (pViewData)
600cdf0e10cSrcweir     {
601cdf0e10cSrcweir         const ScViewOptions&    rOpt = pViewData->GetOptions();
602cdf0e10cSrcweir         const ScGridOptions&    rGrid = rOpt.GetGridOptions();
603cdf0e10cSrcweir 
604cdf0e10cSrcweir         sal_Bool bBigHdl = rOpt.GetOption( VOPT_BIGHANDLES );
605cdf0e10cSrcweir 
606cdf0e10cSrcweir         SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) );
607cdf0e10cSrcweir         SetSolidMarkHdl( rOpt.GetOption( VOPT_SOLIDHANDLES ) );
608cdf0e10cSrcweir         SetMarkHdlSizePixel( bBigHdl ? SC_HANDLESIZE_BIG : SC_HANDLESIZE_SMALL );
609cdf0e10cSrcweir 
610cdf0e10cSrcweir         SetGridVisible( rGrid.GetGridVisible() );
611cdf0e10cSrcweir         SetSnapEnabled( rGrid.GetUseGridSnap() );
612cdf0e10cSrcweir         SetGridSnap( rGrid.GetUseGridSnap() );
613cdf0e10cSrcweir 
614cdf0e10cSrcweir         //  Snap from grid options is no longer used
615cdf0e10cSrcweir //      SetSnapGrid( Size( rGrid.GetFldSnapX(), rGrid.GetFldSnapY() ) );
616cdf0e10cSrcweir 
617cdf0e10cSrcweir         Fraction aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 );
618cdf0e10cSrcweir         Fraction aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 );
619cdf0e10cSrcweir         SetSnapGridWidth( aFractX, aFractY );
620cdf0e10cSrcweir 
621cdf0e10cSrcweir         SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) );
622cdf0e10cSrcweir         SetGridFine( Size( rGrid.GetFldDrawX() / (rGrid.GetFldDivisionX() + 1),
623cdf0e10cSrcweir                            rGrid.GetFldDrawY() / (rGrid.GetFldDivisionY() + 1) ) );
624cdf0e10cSrcweir     }
625cdf0e10cSrcweir }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir #ifdef _MSC_VER
628cdf0e10cSrcweir #pragma optimize ( "", on )
629cdf0e10cSrcweir #endif
630cdf0e10cSrcweir 
631cdf0e10cSrcweir sal_Bool ScDrawView::SelectObject( const String& rName )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir     UnmarkAll();
634cdf0e10cSrcweir 
635cdf0e10cSrcweir     SCTAB nObjectTab = 0;
636cdf0e10cSrcweir     SdrObject* pFound = NULL;
637cdf0e10cSrcweir 
638cdf0e10cSrcweir     SfxObjectShell* pShell = pDoc->GetDocumentShell();
639cdf0e10cSrcweir     if (pShell)
640cdf0e10cSrcweir     {
641cdf0e10cSrcweir         SdrModel* pDrawLayer = GetModel();
642cdf0e10cSrcweir         SCTAB nTabCount = pDoc->GetTableCount();
643cdf0e10cSrcweir         for (SCTAB i=0; i<nTabCount && !pFound; i++)
644cdf0e10cSrcweir         {
645cdf0e10cSrcweir             SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i));
646cdf0e10cSrcweir             DBG_ASSERT(pPage,"Page ?");
647cdf0e10cSrcweir             if (pPage)
648cdf0e10cSrcweir             {
649cdf0e10cSrcweir                 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
650cdf0e10cSrcweir                 SdrObject* pObject = aIter.Next();
651cdf0e10cSrcweir                 while (pObject && !pFound)
652cdf0e10cSrcweir                 {
653cdf0e10cSrcweir                     if ( ScDrawLayer::GetVisibleName( pObject ) == rName )
654cdf0e10cSrcweir                     {
655cdf0e10cSrcweir                         pFound = pObject;
656cdf0e10cSrcweir                         nObjectTab = i;
657cdf0e10cSrcweir                     }
658cdf0e10cSrcweir                     pObject = aIter.Next();
659cdf0e10cSrcweir                 }
660cdf0e10cSrcweir             }
661cdf0e10cSrcweir         }
662cdf0e10cSrcweir     }
663cdf0e10cSrcweir 
664cdf0e10cSrcweir     if ( pFound )
665cdf0e10cSrcweir     {
666cdf0e10cSrcweir         ScTabView* pView = pViewData->GetView();
667cdf0e10cSrcweir         if ( nObjectTab != nTab )                               // Tabelle umschalten
668cdf0e10cSrcweir             pView->SetTabNo( nObjectTab );
669cdf0e10cSrcweir 
670cdf0e10cSrcweir         DBG_ASSERT( nTab == nObjectTab, "Tabellen umschalten hat nicht geklappt" );
671cdf0e10cSrcweir 
672cdf0e10cSrcweir         pView->ScrollToObject( pFound );
673cdf0e10cSrcweir 
674cdf0e10cSrcweir         /*  #61585# To select an object on the background layer, the layer has to
675cdf0e10cSrcweir             be unlocked even if exclusive drawing selection mode is not active
676cdf0e10cSrcweir             (this is reversed in MarkListHasChanged when nothing is selected) */
677cdf0e10cSrcweir         if ( pFound->GetLayer() == SC_LAYER_BACK &&
678cdf0e10cSrcweir                 !pViewData->GetViewShell()->IsDrawSelMode() &&
679cdf0e10cSrcweir                 !pDoc->IsTabProtected( nTab ) &&
680cdf0e10cSrcweir                 !pViewData->GetSfxDocShell()->IsReadOnly() )
681cdf0e10cSrcweir         {
682cdf0e10cSrcweir             UnlockBackgroundLayer();
683cdf0e10cSrcweir         }
684cdf0e10cSrcweir 
685cdf0e10cSrcweir         SdrPageView* pPV = GetSdrPageView();
686cdf0e10cSrcweir         MarkObj( pFound, pPV );
687cdf0e10cSrcweir     }
688cdf0e10cSrcweir 
689cdf0e10cSrcweir     return ( pFound != NULL );
690cdf0e10cSrcweir }
691cdf0e10cSrcweir 
692cdf0e10cSrcweir //UNUSED2008-05  String ScDrawView::GetSelectedChartName() const
693cdf0e10cSrcweir //UNUSED2008-05  {
694cdf0e10cSrcweir //UNUSED2008-05      //  used for modifying a chart's data area - PersistName must always be used
695cdf0e10cSrcweir //UNUSED2008-05      //  (as in ScDocument::FindChartData and UpdateChartArea)
696cdf0e10cSrcweir //UNUSED2008-05
697cdf0e10cSrcweir //UNUSED2008-05      const SdrMarkList& rMarkList = GetMarkedObjectList();
698cdf0e10cSrcweir //UNUSED2008-05      if (rMarkList.GetMarkCount() == 1)
699cdf0e10cSrcweir //UNUSED2008-05      {
700cdf0e10cSrcweir //UNUSED2008-05          SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
701cdf0e10cSrcweir //UNUSED2008-05          if (pObj->GetObjIdentifier() == OBJ_OLE2)
702cdf0e10cSrcweir //UNUSED2008-05              if ( pDoc->IsChart(pObj) )
703cdf0e10cSrcweir //UNUSED2008-05                  return static_cast<SdrOle2Obj*>(pObj)->GetPersistName();
704cdf0e10cSrcweir //UNUSED2008-05      }
705cdf0e10cSrcweir //UNUSED2008-05
706cdf0e10cSrcweir //UNUSED2008-05      return EMPTY_STRING;        // nichts gefunden
707cdf0e10cSrcweir //UNUSED2008-05  }
708cdf0e10cSrcweir 
709cdf0e10cSrcweir FASTBOOL ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, sal_uLong nOptions)
710cdf0e10cSrcweir {
711cdf0e10cSrcweir     //  Markierung nicht aendern, wenn Ole-Objekt aktiv
712cdf0e10cSrcweir     //  (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!)
713cdf0e10cSrcweir 
714cdf0e10cSrcweir     if (pViewData)
715cdf0e10cSrcweir     {
716cdf0e10cSrcweir         SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient();
717cdf0e10cSrcweir         if ( pClient && pClient->IsObjectInPlaceActive() )
718cdf0e10cSrcweir             nOptions |= SDRINSERT_DONTMARK;
719cdf0e10cSrcweir     }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     return InsertObjectAtView( pObj, rPV, nOptions );
722cdf0e10cSrcweir }
723cdf0e10cSrcweir 
724cdf0e10cSrcweir SdrObject* ScDrawView::GetMarkedNoteCaption( ScDrawObjData** ppCaptData )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir     const SdrMarkList& rMarkList = GetMarkedObjectList();
727cdf0e10cSrcweir     if( pViewData && (rMarkList.GetMarkCount() == 1) )
728cdf0e10cSrcweir     {
729cdf0e10cSrcweir         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
730cdf0e10cSrcweir         if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, pViewData->GetTabNo() ) )
731cdf0e10cSrcweir         {
732cdf0e10cSrcweir             if( ppCaptData ) *ppCaptData = pCaptData;
733cdf0e10cSrcweir             return pObj;
734cdf0e10cSrcweir         }
735cdf0e10cSrcweir     }
736cdf0e10cSrcweir     return 0;
737cdf0e10cSrcweir }
738cdf0e10cSrcweir 
739cdf0e10cSrcweir void ScDrawView::LockCalcLayer( SdrLayerID nLayer, bool bLock )
740cdf0e10cSrcweir {
741cdf0e10cSrcweir     SdrLayer* pLockLayer = GetModel()->GetLayerAdmin().GetLayerPerID( nLayer );
742cdf0e10cSrcweir     if( pLockLayer && (IsLayerLocked( pLockLayer->GetName() ) != bLock) )
743cdf0e10cSrcweir         SetLayerLocked( pLockLayer->GetName(), bLock );
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir void __EXPORT ScDrawView::MakeVisible( const Rectangle& rRect, Window& rWin )
747cdf0e10cSrcweir {
748cdf0e10cSrcweir     //! rWin richtig auswerten
749cdf0e10cSrcweir     //! ggf Zoom aendern
750cdf0e10cSrcweir 
751cdf0e10cSrcweir     if ( pViewData && pViewData->GetActiveWin() == &rWin )
752cdf0e10cSrcweir         pViewData->GetView()->MakeVisible( rRect );
753cdf0e10cSrcweir }
754cdf0e10cSrcweir 
755cdf0e10cSrcweir void ScDrawView::DeleteMarked()
756cdf0e10cSrcweir {
757cdf0e10cSrcweir     // try to delete a note caption object with its cell note in the Calc document
758cdf0e10cSrcweir     ScDrawObjData* pCaptData = 0;
759cdf0e10cSrcweir     if( SdrObject* pCaptObj = GetMarkedNoteCaption( &pCaptData ) )
760cdf0e10cSrcweir     {
761cdf0e10cSrcweir         (void)pCaptObj; // prevent 'unused variable' compiler warning in pro builds
762cdf0e10cSrcweir         ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
763cdf0e10cSrcweir         ScDocShell* pDocShell = pViewData ? pViewData->GetDocShell() : 0;
764cdf0e10cSrcweir         ::svl::IUndoManager* pUndoMgr = pDocShell ? pDocShell->GetUndoManager() : 0;
765cdf0e10cSrcweir         bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled();
766cdf0e10cSrcweir 
767cdf0e10cSrcweir         // remove the cell note from document, we are its owner now
768cdf0e10cSrcweir         ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart );
769cdf0e10cSrcweir         DBG_ASSERT( pNote, "ScDrawView::DeleteMarked - cell note missing in document" );
770cdf0e10cSrcweir         if( pNote )
771cdf0e10cSrcweir         {
772cdf0e10cSrcweir             // rescue note data for undo (with pointer to caption object)
773cdf0e10cSrcweir             ScNoteData aNoteData = pNote->GetNoteData();
774cdf0e10cSrcweir             DBG_ASSERT( aNoteData.mpCaption == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" );
775cdf0e10cSrcweir             // collect the drawing undo action created while deleting the note
776cdf0e10cSrcweir             if( bUndo )
777cdf0e10cSrcweir                 pDrawLayer->BeginCalcUndo();
778cdf0e10cSrcweir             // delete the note (already removed from document above)
779cdf0e10cSrcweir             delete pNote;
780cdf0e10cSrcweir             // add the undo action for the note
781cdf0e10cSrcweir             if( bUndo )
782cdf0e10cSrcweir                 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
783cdf0e10cSrcweir             // repaint the cell to get rid of the note marker
784cdf0e10cSrcweir             if( pDocShell )
785cdf0e10cSrcweir                 pDocShell->PostPaintCell( pCaptData->maStart );
786cdf0e10cSrcweir             // done, return now to skip call of FmFormView::DeleteMarked()
787cdf0e10cSrcweir             return;
788cdf0e10cSrcweir         }
789cdf0e10cSrcweir     }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir     FmFormView::DeleteMarked();
792cdf0e10cSrcweir }
793cdf0e10cSrcweir 
794cdf0e10cSrcweir SdrEndTextEditKind ScDrawView::ScEndTextEdit()
795cdf0e10cSrcweir {
796cdf0e10cSrcweir     sal_Bool bIsTextEdit = IsTextEdit();
797cdf0e10cSrcweir     SdrEndTextEditKind eKind = SdrEndTextEdit();
798cdf0e10cSrcweir 
799cdf0e10cSrcweir     if ( bIsTextEdit && pViewData )
800cdf0e10cSrcweir         pViewData->GetViewShell()->SetDrawTextUndo(NULL);   // "normaler" Undo-Manager
801cdf0e10cSrcweir 
802cdf0e10cSrcweir     return eKind;
803cdf0e10cSrcweir }
804cdf0e10cSrcweir 
805cdf0e10cSrcweir void ScDrawView::MarkDropObj( SdrObject* pObj )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir     if ( pDropMarkObj != pObj )
808cdf0e10cSrcweir     {
809cdf0e10cSrcweir         pDropMarkObj = pObj;
810cdf0e10cSrcweir         ImplClearCalcDropMarker();
811cdf0e10cSrcweir 
812cdf0e10cSrcweir         if(pDropMarkObj)
813cdf0e10cSrcweir         {
814cdf0e10cSrcweir             pDropMarker = new SdrDropMarkerOverlay(*this, *pDropMarkObj);
815cdf0e10cSrcweir         }
816cdf0e10cSrcweir     }
817cdf0e10cSrcweir }
818cdf0e10cSrcweir 
819*14af77b6SArmin Le Grand // support enhanced text edit for draw objects
820*14af77b6SArmin Le Grand SdrUndoManager* ScDrawView::getSdrUndoManagerForEnhancedTextEdit() const
821*14af77b6SArmin Le Grand {
822*14af77b6SArmin Le Grand     return pDoc ? dynamic_cast< SdrUndoManager* >(pDoc->GetUndoManager()) : 0;
823*14af77b6SArmin Le Grand }
824*14af77b6SArmin Le Grand 
825*14af77b6SArmin Le Grand // eof
826