xref: /trunk/main/sc/source/ui/view/drawview.cxx (revision 512ec1615a3a70b8fc9ba54f26a5921e3624428f)
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>
4514af77b6SArmin 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"
6314af77b6SArmin 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 );
228766ce4d0SZheng Fan     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
229766ce4d0SZheng Fan     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
230766ce4d0SZheng Fan     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
231766ce4d0SZheng Fan     rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
232cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGNLEFT );
233cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGNCENTERHOR );
234cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGNRIGHT );
235cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGNBLOCK );
236cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
237cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
238cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
239cdf0e10cSrcweir     rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
240cdf0e10cSrcweir     rBindings.Invalidate( SID_SET_SUB_SCRIPT );
241*512ec161SZheng Fan     rBindings.Invalidate( SID_ATTR_CHAR_KERNING );
242*512ec161SZheng Fan     rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT );
243*512ec161SZheng Fan     rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED );
244cdf0e10cSrcweir     rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
245cdf0e10cSrcweir     rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
246cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
247cdf0e10cSrcweir     rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
248cdf0e10cSrcweir     // pseudo slots for Format menu
249cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
250cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
251cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
252cdf0e10cSrcweir     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir //void ScDrawView::DrawMarks( OutputDevice* pOut ) const
256cdf0e10cSrcweir //{
257cdf0e10cSrcweir //  DBG_ASSERT(pOut, "ScDrawView::DrawMarks: No OutputDevice (!)");
258cdf0e10cSrcweir //  SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
259cdf0e10cSrcweir //
260cdf0e10cSrcweir //  if(pPaintWindow)
261cdf0e10cSrcweir //  {
262cdf0e10cSrcweir //      if(pPaintWindow->isXorVisible())
263cdf0e10cSrcweir //      {
264cdf0e10cSrcweir //          ToggleShownXor(pOut, 0L);
265cdf0e10cSrcweir //      }
266cdf0e10cSrcweir //  }
267cdf0e10cSrcweir //}
268cdf0e10cSrcweir 
269cdf0e10cSrcweir void ScDrawView::SetMarkedToLayer( sal_uInt8 nLayerNo )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir     if (AreObjectsMarked())
272cdf0e10cSrcweir     {
273cdf0e10cSrcweir         //  #i11702# use SdrUndoObjectLayerChange for undo
274cdf0e10cSrcweir         //  STR_UNDO_SELATTR is "Attributes" - should use a different text later
275cdf0e10cSrcweir         BegUndo( ScGlobal::GetRscString( STR_UNDO_SELATTR ) );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir         const SdrMarkList& rMark = GetMarkedObjectList();
278cdf0e10cSrcweir         sal_uLong nCount = rMark.GetMarkCount();
279cdf0e10cSrcweir         for (sal_uLong i=0; i<nCount; i++)
280cdf0e10cSrcweir         {
281cdf0e10cSrcweir             SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
282cdf0e10cSrcweir             if ( !pObj->ISA(SdrUnoObj) && (pObj->GetLayer() != SC_LAYER_INTERN) )
283cdf0e10cSrcweir             {
284cdf0e10cSrcweir                 AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), (SdrLayerID)nLayerNo) );
285cdf0e10cSrcweir                 pObj->SetLayer( nLayerNo );
286cdf0e10cSrcweir             }
287cdf0e10cSrcweir         }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir         EndUndo();
290cdf0e10cSrcweir 
291cdf0e10cSrcweir         //  repaint is done in SetLayer
292cdf0e10cSrcweir 
293cdf0e10cSrcweir         pViewData->GetDocShell()->SetDrawModified();
294cdf0e10cSrcweir 
295cdf0e10cSrcweir         //  #84073# check mark list now instead of later in a timer
296cdf0e10cSrcweir         CheckMarked();
297cdf0e10cSrcweir         MarkListHasChanged();
298cdf0e10cSrcweir     }
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir bool ScDrawView::HasMarkedControl() const
302cdf0e10cSrcweir {
303cdf0e10cSrcweir     SdrObjListIter aIter( GetMarkedObjectList() );
304cdf0e10cSrcweir     for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
305cdf0e10cSrcweir         if( pObj->ISA( SdrUnoObj ) )
306cdf0e10cSrcweir             return true;
307cdf0e10cSrcweir     return false;
308cdf0e10cSrcweir }
309cdf0e10cSrcweir 
310cdf0e10cSrcweir bool ScDrawView::HasMarkedInternal() const
311cdf0e10cSrcweir {
312cdf0e10cSrcweir     // internal objects should not be inside a group, but who knows...
313cdf0e10cSrcweir     SdrObjListIter aIter( GetMarkedObjectList() );
314cdf0e10cSrcweir     for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
315cdf0e10cSrcweir         if( pObj->GetLayer() == SC_LAYER_INTERN )
316cdf0e10cSrcweir             return true;
317cdf0e10cSrcweir     return false;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir void ScDrawView::UpdateWorkArea()
321cdf0e10cSrcweir {
322cdf0e10cSrcweir     SdrPage* pPage = GetModel()->GetPage(static_cast<sal_uInt16>(nTab));
323cdf0e10cSrcweir     if (pPage)
324cdf0e10cSrcweir     {
325cdf0e10cSrcweir         Point aPos;
326cdf0e10cSrcweir         Size aPageSize( pPage->GetSize() );
327cdf0e10cSrcweir         Rectangle aNewArea( aPos, aPageSize );
328cdf0e10cSrcweir         if ( aPageSize.Width() < 0 )
329cdf0e10cSrcweir         {
330cdf0e10cSrcweir             //  RTL: from max.negative (left) to zero (right)
331cdf0e10cSrcweir             aNewArea.Right() = 0;
332cdf0e10cSrcweir             aNewArea.Left() = aPageSize.Width() + 1;
333cdf0e10cSrcweir         }
334cdf0e10cSrcweir         SetWorkArea( aNewArea );
335cdf0e10cSrcweir     }
336cdf0e10cSrcweir     else
337cdf0e10cSrcweir     {
338cdf0e10cSrcweir         DBG_ERROR("Page nicht gefunden");
339cdf0e10cSrcweir     }
340cdf0e10cSrcweir }
341cdf0e10cSrcweir 
342cdf0e10cSrcweir void ScDrawView::DoCut()
343cdf0e10cSrcweir {
344cdf0e10cSrcweir     DoCopy();
345cdf0e10cSrcweir     BegUndo( ScGlobal::GetRscString( STR_UNDO_CUT ) );
346cdf0e10cSrcweir     DeleteMarked();     // auf dieser View - von der 505f Umstellung nicht betroffen
347cdf0e10cSrcweir     EndUndo();
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const
351cdf0e10cSrcweir {
352cdf0e10cSrcweir     rFractX = aScaleX;
353cdf0e10cSrcweir     rFractY = aScaleY;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir void ScDrawView::RecalcScale()
357cdf0e10cSrcweir {
358cdf0e10cSrcweir     double nPPTX;
359cdf0e10cSrcweir     double nPPTY;
360cdf0e10cSrcweir     Fraction aZoomX(1,1);
361cdf0e10cSrcweir     Fraction aZoomY(1,1);
362cdf0e10cSrcweir 
363cdf0e10cSrcweir     if (pViewData)
364cdf0e10cSrcweir     {
365cdf0e10cSrcweir         nTab = pViewData->GetTabNo();
366cdf0e10cSrcweir         nPPTX = pViewData->GetPPTX();
367cdf0e10cSrcweir         nPPTY = pViewData->GetPPTY();
368cdf0e10cSrcweir         aZoomX = pViewData->GetZoomX();
369cdf0e10cSrcweir         aZoomY = pViewData->GetZoomY();
370cdf0e10cSrcweir     }
371cdf0e10cSrcweir     else
372cdf0e10cSrcweir     {
373cdf0e10cSrcweir         Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
374cdf0e10cSrcweir         nPPTX = aLogic.X() / 1000.0;
375cdf0e10cSrcweir         nPPTY = aLogic.Y() / 1000.0;
376cdf0e10cSrcweir                                             //! Zoom uebergeben ???
377cdf0e10cSrcweir     }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir     SCCOL nEndCol = 0;
380cdf0e10cSrcweir     SCROW nEndRow = 0;
381cdf0e10cSrcweir     pDoc->GetTableArea( nTab, nEndCol, nEndRow );
382cdf0e10cSrcweir     if (nEndCol<20)
383cdf0e10cSrcweir         nEndCol = 20;
384cdf0e10cSrcweir     if (nEndRow<20)
385cdf0e10cSrcweir         nEndRow = 20;   // #i116848# instead of a large row number for an empty sheet, heights are multiplied in CalcScale
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY,
388cdf0e10cSrcweir                             aScaleX,aScaleY );
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir void ScDrawView::DoConnect(SdrOle2Obj* pOleObj)
392cdf0e10cSrcweir {
393cdf0e10cSrcweir     if ( pViewData )
394cdf0e10cSrcweir         pViewData->GetViewShell()->ConnectObject( pOleObj );
395cdf0e10cSrcweir }
396cdf0e10cSrcweir 
397cdf0e10cSrcweir void ScDrawView::MarkListHasChanged()
398cdf0e10cSrcweir {
399cdf0e10cSrcweir     FmFormView::MarkListHasChanged();
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     UpdateBrowser();
402cdf0e10cSrcweir 
403cdf0e10cSrcweir     ScTabViewShell* pViewSh = pViewData->GetViewShell();
404cdf0e10cSrcweir 
405cdf0e10cSrcweir     // #i110829# remove the cell selection only if drawing objects are selected
406cdf0e10cSrcweir     if ( !bInConstruct && GetMarkedObjectList().GetMarkCount() )
407cdf0e10cSrcweir     {
408cdf0e10cSrcweir         pViewSh->Unmark();      // remove cell selection
409cdf0e10cSrcweir 
410cdf0e10cSrcweir         //  #65379# end cell edit mode if drawing objects are selected
411cdf0e10cSrcweir         SC_MOD()->InputEnterHandler();
412cdf0e10cSrcweir     }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir     //  IP deaktivieren
415cdf0e10cSrcweir 
416cdf0e10cSrcweir     ScModule* pScMod = SC_MOD();
417cdf0e10cSrcweir     bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
418cdf0e10cSrcweir 
419cdf0e10cSrcweir     ScClient* pClient = (ScClient*) pViewSh->GetIPClient();
420cdf0e10cSrcweir     if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
421cdf0e10cSrcweir     {
422cdf0e10cSrcweir         //  #41730# beim ViewShell::Activate aus dem Reset2Open nicht die Handles anzeigen
423cdf0e10cSrcweir         //HMHbDisableHdl = sal_True;
424cdf0e10cSrcweir         pClient->DeactivateObject();
425cdf0e10cSrcweir         //HMHbDisableHdl = sal_False;
426cdf0e10cSrcweir         //  Image-Ole wieder durch Grafik ersetzen passiert jetzt in ScClient::UIActivate
427cdf0e10cSrcweir     }
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     //  Ole-Objekt selektiert?
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     SdrOle2Obj* pOle2Obj = NULL;
432cdf0e10cSrcweir     SdrGrafObj* pGrafObj = NULL;
433cdf0e10cSrcweir     SdrMediaObj* pMediaObj = NULL;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir     const SdrMarkList& rMarkList = GetMarkedObjectList();
436cdf0e10cSrcweir     sal_uLong nMarkCount = rMarkList.GetMarkCount();
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     if ( nMarkCount == 0 && !pViewData->GetViewShell()->IsDrawSelMode() && !bInConstruct )
439cdf0e10cSrcweir     {
440cdf0e10cSrcweir         //  relock layers that may have been unlocked before
441cdf0e10cSrcweir         LockBackgroundLayer();
442cdf0e10cSrcweir         LockInternalLayer();
443cdf0e10cSrcweir     }
444cdf0e10cSrcweir 
445cdf0e10cSrcweir     sal_Bool bSubShellSet = sal_False;
446cdf0e10cSrcweir     if (nMarkCount == 1)
447cdf0e10cSrcweir     {
448cdf0e10cSrcweir         SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
449cdf0e10cSrcweir         if (pObj->GetObjIdentifier() == OBJ_OLE2)
450cdf0e10cSrcweir         {
451cdf0e10cSrcweir             pOle2Obj = (SdrOle2Obj*) pObj;
452cdf0e10cSrcweir             if (!pDoc->IsChart(pObj) )
453cdf0e10cSrcweir                 pViewSh->SetOleObjectShell(sal_True);
454cdf0e10cSrcweir             else
455cdf0e10cSrcweir                 pViewSh->SetChartShell(sal_True);
456cdf0e10cSrcweir             bSubShellSet = sal_True;
457cdf0e10cSrcweir         }
458cdf0e10cSrcweir         else if (pObj->GetObjIdentifier() == OBJ_GRAF)
459cdf0e10cSrcweir         {
460cdf0e10cSrcweir             pGrafObj = (SdrGrafObj*) pObj;
461cdf0e10cSrcweir             pViewSh->SetGraphicShell(sal_True);
462cdf0e10cSrcweir             bSubShellSet = sal_True;
463cdf0e10cSrcweir         }
464cdf0e10cSrcweir         else if (pObj->GetObjIdentifier() == OBJ_MEDIA)
465cdf0e10cSrcweir         {
466cdf0e10cSrcweir             pMediaObj = (SdrMediaObj*) pObj;
467cdf0e10cSrcweir             pViewSh->SetMediaShell(sal_True);
468cdf0e10cSrcweir             bSubShellSet = sal_True;
469cdf0e10cSrcweir         }
470cdf0e10cSrcweir         else if (pObj->GetObjIdentifier() != OBJ_TEXT   // Verhindern, das beim Anlegen
471cdf0e10cSrcweir                     || !pViewSh->IsDrawTextShell())     // eines TextObjekts auf die
472cdf0e10cSrcweir         {                                               // DrawShell umgeschaltet wird.
473cdf0e10cSrcweir             pViewSh->SetDrawShell(sal_True);                //@#70206#
474cdf0e10cSrcweir         }
475cdf0e10cSrcweir     }
476cdf0e10cSrcweir 
477cdf0e10cSrcweir     if ( nMarkCount && !bSubShellSet )
478cdf0e10cSrcweir     {
479cdf0e10cSrcweir         sal_Bool bOnlyControls = sal_True;
480cdf0e10cSrcweir         sal_Bool bOnlyGraf     = sal_True;
481cdf0e10cSrcweir         for (sal_uLong i=0; i<nMarkCount; i++)
482cdf0e10cSrcweir         {
483cdf0e10cSrcweir             SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
484cdf0e10cSrcweir             if ( pObj->ISA( SdrObjGroup ) )
485cdf0e10cSrcweir             {
486cdf0e10cSrcweir                 const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
487cdf0e10cSrcweir                 sal_uLong nListCount = pLst->GetObjCount();
488cdf0e10cSrcweir                 if ( nListCount == 0 )
489cdf0e10cSrcweir                 {
490cdf0e10cSrcweir                     //  #104156# An empty group (may occur during Undo) is no control or graphics object.
491cdf0e10cSrcweir                     //  Creating the form shell during undo would lead to problems with the undo manager.
492cdf0e10cSrcweir                     bOnlyControls = sal_False;
493cdf0e10cSrcweir                     bOnlyGraf = sal_False;
494cdf0e10cSrcweir                 }
495cdf0e10cSrcweir                 for ( sal_uInt16 j = 0; j < nListCount; ++j )
496cdf0e10cSrcweir                 {
497cdf0e10cSrcweir                     SdrObject *pSubObj = pLst->GetObj( j );
498cdf0e10cSrcweir 
499cdf0e10cSrcweir                     if (!pSubObj->ISA(SdrUnoObj))
500cdf0e10cSrcweir                         bOnlyControls = sal_False;
501cdf0e10cSrcweir                     if (pSubObj->GetObjIdentifier() != OBJ_GRAF)
502cdf0e10cSrcweir                         bOnlyGraf = sal_False;
503cdf0e10cSrcweir 
504cdf0e10cSrcweir                     if ( !bOnlyControls && !bOnlyGraf ) break;
505cdf0e10cSrcweir                 }
506cdf0e10cSrcweir             }
507cdf0e10cSrcweir             else
508cdf0e10cSrcweir             {
509cdf0e10cSrcweir                 if (!pObj->ISA(SdrUnoObj))
510cdf0e10cSrcweir                     bOnlyControls = sal_False;
511cdf0e10cSrcweir                 if (pObj->GetObjIdentifier() != OBJ_GRAF)
512cdf0e10cSrcweir                     bOnlyGraf = sal_False;
513cdf0e10cSrcweir             }
514cdf0e10cSrcweir 
515cdf0e10cSrcweir             if ( !bOnlyControls && !bOnlyGraf ) break;
516cdf0e10cSrcweir         }
517cdf0e10cSrcweir 
518cdf0e10cSrcweir         if(bOnlyControls)
519cdf0e10cSrcweir         {
520cdf0e10cSrcweir             pViewSh->SetDrawFormShell(sal_True);            // jetzt UNO-Controls
521cdf0e10cSrcweir         }
522cdf0e10cSrcweir         else if(bOnlyGraf)
523cdf0e10cSrcweir         {
524cdf0e10cSrcweir             pViewSh->SetGraphicShell(sal_True);
525cdf0e10cSrcweir         }
526cdf0e10cSrcweir         else if(nMarkCount>1)
527cdf0e10cSrcweir         {
528cdf0e10cSrcweir             pViewSh->SetDrawShell(sal_True);
529cdf0e10cSrcweir         }
530cdf0e10cSrcweir     }
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 
534cdf0e10cSrcweir     //  Verben anpassen
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     SfxViewFrame* pViewFrame = pViewSh->GetViewFrame();
537cdf0e10cSrcweir     sal_Bool bOle = pViewSh->GetViewFrame()->GetFrame().IsInPlace();
538cdf0e10cSrcweir     uno::Sequence< embed::VerbDescriptor > aVerbs;
539cdf0e10cSrcweir     if ( pOle2Obj && !bOle )
540cdf0e10cSrcweir     {
541cdf0e10cSrcweir         uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef();
542cdf0e10cSrcweir         DBG_ASSERT( xObj.is(), "SdrOle2Obj ohne ObjRef" );
543cdf0e10cSrcweir         if (xObj.is())
544cdf0e10cSrcweir             aVerbs = xObj->getSupportedVerbs();
545cdf0e10cSrcweir     }
546cdf0e10cSrcweir     pViewSh->SetVerbs( aVerbs );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir     //  Image-Map Editor
549cdf0e10cSrcweir 
550cdf0e10cSrcweir     if ( pOle2Obj )
551cdf0e10cSrcweir         UpdateIMap( pOle2Obj );
552cdf0e10cSrcweir     else if ( pGrafObj )
553cdf0e10cSrcweir         UpdateIMap( pGrafObj );
554cdf0e10cSrcweir 
555cdf0e10cSrcweir     InvalidateAttribs();                // nach dem IMap-Editor Update
556cdf0e10cSrcweir     InvalidateDrawTextAttrs();
557cdf0e10cSrcweir 
558cdf0e10cSrcweir     for(sal_uInt32 a(0L); a < PaintWindowCount(); a++)
559cdf0e10cSrcweir     {
560cdf0e10cSrcweir         SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
561cdf0e10cSrcweir         OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
562cdf0e10cSrcweir 
563cdf0e10cSrcweir         if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
564cdf0e10cSrcweir         {
565cdf0e10cSrcweir             ((Window&)rOutDev).Update();
566cdf0e10cSrcweir         }
567cdf0e10cSrcweir     }
568cdf0e10cSrcweir 
569cdf0e10cSrcweir     //  uno object for view returns drawing objects as selection,
570cdf0e10cSrcweir     //  so it must notify its SelectionChangeListeners
571cdf0e10cSrcweir 
572cdf0e10cSrcweir     if (pViewFrame)
573cdf0e10cSrcweir     {
574cdf0e10cSrcweir         SfxFrame& rFrame = pViewFrame->GetFrame();
575cdf0e10cSrcweir         uno::Reference<frame::XController> xController = rFrame.GetController();
576cdf0e10cSrcweir         if (xController.is())
577cdf0e10cSrcweir         {
578cdf0e10cSrcweir             ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
579cdf0e10cSrcweir             if (pImp)
580cdf0e10cSrcweir                 pImp->SelectionChanged();
581cdf0e10cSrcweir         }
582cdf0e10cSrcweir     }
583cdf0e10cSrcweir 
584cdf0e10cSrcweir     //  update selection transfer object
585cdf0e10cSrcweir 
586cdf0e10cSrcweir     pViewSh->CheckSelectionTransfer();
587cdf0e10cSrcweir 
588cdf0e10cSrcweir }
589cdf0e10cSrcweir 
590cdf0e10cSrcweir void __EXPORT ScDrawView::ModelHasChanged()
591cdf0e10cSrcweir {
592cdf0e10cSrcweir     SdrObject* pEditObj = GetTextEditObject();
593cdf0e10cSrcweir     if ( pEditObj && !pEditObj->IsInserted() && pViewData )
594cdf0e10cSrcweir     {
595cdf0e10cSrcweir         //  #111700# SdrObjEditView::ModelHasChanged will end text edit in this case,
596cdf0e10cSrcweir         //  so make sure the EditEngine's undo manager is no longer used.
597cdf0e10cSrcweir         pViewData->GetViewShell()->SetDrawTextUndo(NULL);
598cdf0e10cSrcweir         SetCreateMode();    // don't leave FuText in a funny state
599cdf0e10cSrcweir     }
600cdf0e10cSrcweir 
601cdf0e10cSrcweir     FmFormView::ModelHasChanged();
602cdf0e10cSrcweir }
603cdf0e10cSrcweir 
604cdf0e10cSrcweir void __EXPORT ScDrawView::UpdateUserViewOptions()
605cdf0e10cSrcweir {
606cdf0e10cSrcweir     if (pViewData)
607cdf0e10cSrcweir     {
608cdf0e10cSrcweir         const ScViewOptions&    rOpt = pViewData->GetOptions();
609cdf0e10cSrcweir         const ScGridOptions&    rGrid = rOpt.GetGridOptions();
610cdf0e10cSrcweir 
611cdf0e10cSrcweir         sal_Bool bBigHdl = rOpt.GetOption( VOPT_BIGHANDLES );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir         SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) );
614cdf0e10cSrcweir         SetSolidMarkHdl( rOpt.GetOption( VOPT_SOLIDHANDLES ) );
615cdf0e10cSrcweir         SetMarkHdlSizePixel( bBigHdl ? SC_HANDLESIZE_BIG : SC_HANDLESIZE_SMALL );
616cdf0e10cSrcweir 
617cdf0e10cSrcweir         SetGridVisible( rGrid.GetGridVisible() );
618cdf0e10cSrcweir         SetSnapEnabled( rGrid.GetUseGridSnap() );
619cdf0e10cSrcweir         SetGridSnap( rGrid.GetUseGridSnap() );
620cdf0e10cSrcweir 
621cdf0e10cSrcweir         //  Snap from grid options is no longer used
622cdf0e10cSrcweir //      SetSnapGrid( Size( rGrid.GetFldSnapX(), rGrid.GetFldSnapY() ) );
623cdf0e10cSrcweir 
624cdf0e10cSrcweir         Fraction aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 );
625cdf0e10cSrcweir         Fraction aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 );
626cdf0e10cSrcweir         SetSnapGridWidth( aFractX, aFractY );
627cdf0e10cSrcweir 
628cdf0e10cSrcweir         SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) );
629cdf0e10cSrcweir         SetGridFine( Size( rGrid.GetFldDrawX() / (rGrid.GetFldDivisionX() + 1),
630cdf0e10cSrcweir                            rGrid.GetFldDrawY() / (rGrid.GetFldDivisionY() + 1) ) );
631cdf0e10cSrcweir     }
632cdf0e10cSrcweir }
633cdf0e10cSrcweir 
634cdf0e10cSrcweir #ifdef _MSC_VER
635cdf0e10cSrcweir #pragma optimize ( "", on )
636cdf0e10cSrcweir #endif
637cdf0e10cSrcweir 
638cdf0e10cSrcweir sal_Bool ScDrawView::SelectObject( const String& rName )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir     UnmarkAll();
641cdf0e10cSrcweir 
642cdf0e10cSrcweir     SCTAB nObjectTab = 0;
643cdf0e10cSrcweir     SdrObject* pFound = NULL;
644cdf0e10cSrcweir 
645cdf0e10cSrcweir     SfxObjectShell* pShell = pDoc->GetDocumentShell();
646cdf0e10cSrcweir     if (pShell)
647cdf0e10cSrcweir     {
648cdf0e10cSrcweir         SdrModel* pDrawLayer = GetModel();
649cdf0e10cSrcweir         SCTAB nTabCount = pDoc->GetTableCount();
650cdf0e10cSrcweir         for (SCTAB i=0; i<nTabCount && !pFound; i++)
651cdf0e10cSrcweir         {
652cdf0e10cSrcweir             SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i));
653cdf0e10cSrcweir             DBG_ASSERT(pPage,"Page ?");
654cdf0e10cSrcweir             if (pPage)
655cdf0e10cSrcweir             {
656cdf0e10cSrcweir                 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
657cdf0e10cSrcweir                 SdrObject* pObject = aIter.Next();
658cdf0e10cSrcweir                 while (pObject && !pFound)
659cdf0e10cSrcweir                 {
660cdf0e10cSrcweir                     if ( ScDrawLayer::GetVisibleName( pObject ) == rName )
661cdf0e10cSrcweir                     {
662cdf0e10cSrcweir                         pFound = pObject;
663cdf0e10cSrcweir                         nObjectTab = i;
664cdf0e10cSrcweir                     }
665cdf0e10cSrcweir                     pObject = aIter.Next();
666cdf0e10cSrcweir                 }
667cdf0e10cSrcweir             }
668cdf0e10cSrcweir         }
669cdf0e10cSrcweir     }
670cdf0e10cSrcweir 
671cdf0e10cSrcweir     if ( pFound )
672cdf0e10cSrcweir     {
673cdf0e10cSrcweir         ScTabView* pView = pViewData->GetView();
674cdf0e10cSrcweir         if ( nObjectTab != nTab )                               // Tabelle umschalten
675cdf0e10cSrcweir             pView->SetTabNo( nObjectTab );
676cdf0e10cSrcweir 
677cdf0e10cSrcweir         DBG_ASSERT( nTab == nObjectTab, "Tabellen umschalten hat nicht geklappt" );
678cdf0e10cSrcweir 
679cdf0e10cSrcweir         pView->ScrollToObject( pFound );
680cdf0e10cSrcweir 
681cdf0e10cSrcweir         /*  #61585# To select an object on the background layer, the layer has to
682cdf0e10cSrcweir             be unlocked even if exclusive drawing selection mode is not active
683cdf0e10cSrcweir             (this is reversed in MarkListHasChanged when nothing is selected) */
684cdf0e10cSrcweir         if ( pFound->GetLayer() == SC_LAYER_BACK &&
685cdf0e10cSrcweir                 !pViewData->GetViewShell()->IsDrawSelMode() &&
686cdf0e10cSrcweir                 !pDoc->IsTabProtected( nTab ) &&
687cdf0e10cSrcweir                 !pViewData->GetSfxDocShell()->IsReadOnly() )
688cdf0e10cSrcweir         {
689cdf0e10cSrcweir             UnlockBackgroundLayer();
690cdf0e10cSrcweir         }
691cdf0e10cSrcweir 
692cdf0e10cSrcweir         SdrPageView* pPV = GetSdrPageView();
693cdf0e10cSrcweir         MarkObj( pFound, pPV );
694cdf0e10cSrcweir     }
695cdf0e10cSrcweir 
696cdf0e10cSrcweir     return ( pFound != NULL );
697cdf0e10cSrcweir }
698cdf0e10cSrcweir 
699cdf0e10cSrcweir //UNUSED2008-05  String ScDrawView::GetSelectedChartName() const
700cdf0e10cSrcweir //UNUSED2008-05  {
701cdf0e10cSrcweir //UNUSED2008-05      //  used for modifying a chart's data area - PersistName must always be used
702cdf0e10cSrcweir //UNUSED2008-05      //  (as in ScDocument::FindChartData and UpdateChartArea)
703cdf0e10cSrcweir //UNUSED2008-05
704cdf0e10cSrcweir //UNUSED2008-05      const SdrMarkList& rMarkList = GetMarkedObjectList();
705cdf0e10cSrcweir //UNUSED2008-05      if (rMarkList.GetMarkCount() == 1)
706cdf0e10cSrcweir //UNUSED2008-05      {
707cdf0e10cSrcweir //UNUSED2008-05          SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
708cdf0e10cSrcweir //UNUSED2008-05          if (pObj->GetObjIdentifier() == OBJ_OLE2)
709cdf0e10cSrcweir //UNUSED2008-05              if ( pDoc->IsChart(pObj) )
710cdf0e10cSrcweir //UNUSED2008-05                  return static_cast<SdrOle2Obj*>(pObj)->GetPersistName();
711cdf0e10cSrcweir //UNUSED2008-05      }
712cdf0e10cSrcweir //UNUSED2008-05
713cdf0e10cSrcweir //UNUSED2008-05      return EMPTY_STRING;        // nichts gefunden
714cdf0e10cSrcweir //UNUSED2008-05  }
715cdf0e10cSrcweir 
716cdf0e10cSrcweir FASTBOOL ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, sal_uLong nOptions)
717cdf0e10cSrcweir {
718cdf0e10cSrcweir     //  Markierung nicht aendern, wenn Ole-Objekt aktiv
719cdf0e10cSrcweir     //  (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!)
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     if (pViewData)
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir         SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient();
724cdf0e10cSrcweir         if ( pClient && pClient->IsObjectInPlaceActive() )
725cdf0e10cSrcweir             nOptions |= SDRINSERT_DONTMARK;
726cdf0e10cSrcweir     }
727cdf0e10cSrcweir 
728cdf0e10cSrcweir     return InsertObjectAtView( pObj, rPV, nOptions );
729cdf0e10cSrcweir }
730cdf0e10cSrcweir 
731cdf0e10cSrcweir SdrObject* ScDrawView::GetMarkedNoteCaption( ScDrawObjData** ppCaptData )
732cdf0e10cSrcweir {
733cdf0e10cSrcweir     const SdrMarkList& rMarkList = GetMarkedObjectList();
734cdf0e10cSrcweir     if( pViewData && (rMarkList.GetMarkCount() == 1) )
735cdf0e10cSrcweir     {
736cdf0e10cSrcweir         SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
737cdf0e10cSrcweir         if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, pViewData->GetTabNo() ) )
738cdf0e10cSrcweir         {
739cdf0e10cSrcweir             if( ppCaptData ) *ppCaptData = pCaptData;
740cdf0e10cSrcweir             return pObj;
741cdf0e10cSrcweir         }
742cdf0e10cSrcweir     }
743cdf0e10cSrcweir     return 0;
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir void ScDrawView::LockCalcLayer( SdrLayerID nLayer, bool bLock )
747cdf0e10cSrcweir {
748cdf0e10cSrcweir     SdrLayer* pLockLayer = GetModel()->GetLayerAdmin().GetLayerPerID( nLayer );
749cdf0e10cSrcweir     if( pLockLayer && (IsLayerLocked( pLockLayer->GetName() ) != bLock) )
750cdf0e10cSrcweir         SetLayerLocked( pLockLayer->GetName(), bLock );
751cdf0e10cSrcweir }
752cdf0e10cSrcweir 
753cdf0e10cSrcweir void __EXPORT ScDrawView::MakeVisible( const Rectangle& rRect, Window& rWin )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir     //! rWin richtig auswerten
756cdf0e10cSrcweir     //! ggf Zoom aendern
757cdf0e10cSrcweir 
758cdf0e10cSrcweir     if ( pViewData && pViewData->GetActiveWin() == &rWin )
759cdf0e10cSrcweir         pViewData->GetView()->MakeVisible( rRect );
760cdf0e10cSrcweir }
761cdf0e10cSrcweir 
762cdf0e10cSrcweir void ScDrawView::DeleteMarked()
763cdf0e10cSrcweir {
764cdf0e10cSrcweir     // try to delete a note caption object with its cell note in the Calc document
765cdf0e10cSrcweir     ScDrawObjData* pCaptData = 0;
766cdf0e10cSrcweir     if( SdrObject* pCaptObj = GetMarkedNoteCaption( &pCaptData ) )
767cdf0e10cSrcweir     {
768cdf0e10cSrcweir         (void)pCaptObj; // prevent 'unused variable' compiler warning in pro builds
769cdf0e10cSrcweir         ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
770cdf0e10cSrcweir         ScDocShell* pDocShell = pViewData ? pViewData->GetDocShell() : 0;
771cdf0e10cSrcweir         ::svl::IUndoManager* pUndoMgr = pDocShell ? pDocShell->GetUndoManager() : 0;
772cdf0e10cSrcweir         bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled();
773cdf0e10cSrcweir 
774cdf0e10cSrcweir         // remove the cell note from document, we are its owner now
775cdf0e10cSrcweir         ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart );
776cdf0e10cSrcweir         DBG_ASSERT( pNote, "ScDrawView::DeleteMarked - cell note missing in document" );
777cdf0e10cSrcweir         if( pNote )
778cdf0e10cSrcweir         {
779cdf0e10cSrcweir             // rescue note data for undo (with pointer to caption object)
780cdf0e10cSrcweir             ScNoteData aNoteData = pNote->GetNoteData();
781cdf0e10cSrcweir             DBG_ASSERT( aNoteData.mpCaption == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" );
782cdf0e10cSrcweir             // collect the drawing undo action created while deleting the note
783cdf0e10cSrcweir             if( bUndo )
784cdf0e10cSrcweir                 pDrawLayer->BeginCalcUndo();
785cdf0e10cSrcweir             // delete the note (already removed from document above)
786cdf0e10cSrcweir             delete pNote;
787cdf0e10cSrcweir             // add the undo action for the note
788cdf0e10cSrcweir             if( bUndo )
789cdf0e10cSrcweir                 pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
790cdf0e10cSrcweir             // repaint the cell to get rid of the note marker
791cdf0e10cSrcweir             if( pDocShell )
792cdf0e10cSrcweir                 pDocShell->PostPaintCell( pCaptData->maStart );
793cdf0e10cSrcweir             // done, return now to skip call of FmFormView::DeleteMarked()
794cdf0e10cSrcweir             return;
795cdf0e10cSrcweir         }
796cdf0e10cSrcweir     }
797cdf0e10cSrcweir 
798cdf0e10cSrcweir     FmFormView::DeleteMarked();
799cdf0e10cSrcweir }
800cdf0e10cSrcweir 
801cdf0e10cSrcweir SdrEndTextEditKind ScDrawView::ScEndTextEdit()
802cdf0e10cSrcweir {
803cdf0e10cSrcweir     sal_Bool bIsTextEdit = IsTextEdit();
804cdf0e10cSrcweir     SdrEndTextEditKind eKind = SdrEndTextEdit();
805cdf0e10cSrcweir 
806cdf0e10cSrcweir     if ( bIsTextEdit && pViewData )
807cdf0e10cSrcweir         pViewData->GetViewShell()->SetDrawTextUndo(NULL);   // "normaler" Undo-Manager
808cdf0e10cSrcweir 
809cdf0e10cSrcweir     return eKind;
810cdf0e10cSrcweir }
811cdf0e10cSrcweir 
812cdf0e10cSrcweir void ScDrawView::MarkDropObj( SdrObject* pObj )
813cdf0e10cSrcweir {
814cdf0e10cSrcweir     if ( pDropMarkObj != pObj )
815cdf0e10cSrcweir     {
816cdf0e10cSrcweir         pDropMarkObj = pObj;
817cdf0e10cSrcweir         ImplClearCalcDropMarker();
818cdf0e10cSrcweir 
819cdf0e10cSrcweir         if(pDropMarkObj)
820cdf0e10cSrcweir         {
821cdf0e10cSrcweir             pDropMarker = new SdrDropMarkerOverlay(*this, *pDropMarkObj);
822cdf0e10cSrcweir         }
823cdf0e10cSrcweir     }
824cdf0e10cSrcweir }
825cdf0e10cSrcweir 
82614af77b6SArmin Le Grand // support enhanced text edit for draw objects
82714af77b6SArmin Le Grand SdrUndoManager* ScDrawView::getSdrUndoManagerForEnhancedTextEdit() const
82814af77b6SArmin Le Grand {
82914af77b6SArmin Le Grand     return pDoc ? dynamic_cast< SdrUndoManager* >(pDoc->GetUndoManager()) : 0;
83014af77b6SArmin Le Grand }
83114af77b6SArmin Le Grand 
83214af77b6SArmin Le Grand // eof
833