xref: /AOO41X/main/sd/source/ui/view/sdview.cxx (revision d3e0dd8eb215533c15e891ee35bd141abe9397ee)
15b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35b190011SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45b190011SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55b190011SAndrew Rist  * distributed with this work for additional information
65b190011SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75b190011SAndrew Rist  * to you under the Apache License, Version 2.0 (the
85b190011SAndrew Rist  * "License"); you may not use this file except in compliance
95b190011SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
115b190011SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
135b190011SAndrew Rist  * Unless required by applicable law or agreed to in writing,
145b190011SAndrew Rist  * software distributed under the License is distributed on an
155b190011SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165b190011SAndrew Rist  * KIND, either express or implied.  See the License for the
175b190011SAndrew Rist  * specific language governing permissions and limitations
185b190011SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
205b190011SAndrew Rist  *************************************************************/
215b190011SAndrew Rist 
225b190011SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
27cdf0e10cSrcweir #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "View.hxx"
30cdf0e10cSrcweir #include <editeng/unolingu.hxx>
31cdf0e10cSrcweir #include <sfx2/request.hxx>
32cdf0e10cSrcweir #include <svx/obj3d.hxx>
33cdf0e10cSrcweir #include <svx/fmview.hxx>
34cdf0e10cSrcweir #include <editeng/outliner.hxx>
35cdf0e10cSrcweir #ifndef _SVX_SVXIDS_HRC
36cdf0e10cSrcweir #include <svx/svxids.hrc>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <svx/svdograf.hxx>
39cdf0e10cSrcweir #include <svx/svdoole2.hxx>
40cdf0e10cSrcweir #include <svx/svdundo.hxx>
41cdf0e10cSrcweir #include <vcl/msgbox.hxx>
42cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
43cdf0e10cSrcweir #include <sfx2/app.hxx>
44cdf0e10cSrcweir #include <svx/svdpagv.hxx>
45cdf0e10cSrcweir #include <sfx2/docfile.hxx>
46cdf0e10cSrcweir #include <svx/svdoutl.hxx>
47cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir #include <svx/svdetc.hxx>
50cdf0e10cSrcweir #include <editeng/editstat.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #include <svx/dialogs.hrc>
53cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
54f120fe41SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx>
55cdf0e10cSrcweir #include <svx/svdopage.hxx>
56cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
57cdf0e10cSrcweir #include <svx/xlndsit.hxx>
58cdf0e10cSrcweir #include <svx/xlineit0.hxx>
59cdf0e10cSrcweir #include <svx/xlnclit.hxx>
6095a18594SAndre Fischer #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
61cdf0e10cSrcweir #include <vcl/virdev.hxx>
62cdf0e10cSrcweir 
63cdf0e10cSrcweir #include "app.hrc"
64cdf0e10cSrcweir #include "strings.hrc"
65cdf0e10cSrcweir #include "Window.hxx"
66cdf0e10cSrcweir #include "Client.hxx"
67cdf0e10cSrcweir #include "drawdoc.hxx"
68cdf0e10cSrcweir #include "DrawDocShell.hxx"
69cdf0e10cSrcweir #include "app.hxx"
70cdf0e10cSrcweir #include "sdpage.hxx"
71cdf0e10cSrcweir #include "glob.hrc"
72cdf0e10cSrcweir #include "sdresid.hxx"
73cdf0e10cSrcweir #include "DrawViewShell.hxx"
74cdf0e10cSrcweir #include "futext.hxx"
75cdf0e10cSrcweir #include "fuinsfil.hxx"
76cdf0e10cSrcweir #include "slideshow.hxx"
77cdf0e10cSrcweir #include "stlpool.hxx"
78cdf0e10cSrcweir #include "FrameView.hxx"
79cdf0e10cSrcweir #include "ViewClipboard.hxx"
80cdf0e10cSrcweir #include "undo/undomanager.hxx"
81cdf0e10cSrcweir #include <svx/sdr/contact/viewobjectcontact.hxx>
82cdf0e10cSrcweir #include <svx/sdr/contact/viewcontact.hxx>
83cdf0e10cSrcweir #include <svx/sdr/contact/displayinfo.hxx>
84766ce4d0SZheng Fan #include <svx/svdotable.hxx>
85cdf0e10cSrcweir #include "EventMultiplexer.hxx"
86cdf0e10cSrcweir #include "ViewShellBase.hxx"
87cdf0e10cSrcweir #include "ViewShellManager.hxx"
88cdf0e10cSrcweir 
89cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
90cdf0e10cSrcweir #include <basegfx/color/bcolor.hxx>
91cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
92cdf0e10cSrcweir #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
93cdf0e10cSrcweir #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
94cdf0e10cSrcweir #include <svx/sdr/contact/objectcontact.hxx>
95766ce4d0SZheng Fan #include <svx/sdr/table/tablecontroller.hxx>
96cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
97cdf0e10cSrcweir #include <drawinglayer/primitive2d/textprimitive2d.hxx>
98cdf0e10cSrcweir #include <svx/unoapi.hxx>
99cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
100edf077abSOliver-Rainer Wittmann #include "DrawController.hxx"
101cdf0e10cSrcweir 
102cdf0e10cSrcweir #include <numeric>
103cdf0e10cSrcweir 
104cdf0e10cSrcweir using namespace com::sun::star;
105cdf0e10cSrcweir using namespace com::sun::star::uno;
106766ce4d0SZheng Fan using namespace sdr::table;
107cdf0e10cSrcweir namespace sd {
108cdf0e10cSrcweir 
109cdf0e10cSrcweir #ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
110cdf0e10cSrcweir #define SO2_DECL_SVINPLACEOBJECT_DEFINED
111cdf0e10cSrcweir SO2_DECL_REF(SvInPlaceObject)
112cdf0e10cSrcweir #endif
113cdf0e10cSrcweir 
114cdf0e10cSrcweir TYPEINIT1(View, FmFormView);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir /*************************************************************************
117cdf0e10cSrcweir |*
118cdf0e10cSrcweir |* Ctor
119cdf0e10cSrcweir |*
120cdf0e10cSrcweir \************************************************************************/
121cdf0e10cSrcweir 
View(SdDrawDocument * pDrawDoc,OutputDevice * pOutDev,ViewShell * pViewShell)122cdf0e10cSrcweir View::View(SdDrawDocument* pDrawDoc, OutputDevice* pOutDev,
123cdf0e10cSrcweir                ViewShell* pViewShell)
124cdf0e10cSrcweir   : FmFormView(pDrawDoc, pOutDev),
125cdf0e10cSrcweir     mpDoc(pDrawDoc),
126cdf0e10cSrcweir     mpDocSh( pDrawDoc->GetDocSh() ),
127cdf0e10cSrcweir     mpViewSh(pViewShell),
128cdf0e10cSrcweir     mpDragSrcMarkList(NULL),
129cdf0e10cSrcweir     mpDropMarkerObj(NULL),
130cdf0e10cSrcweir     mpDropMarker(NULL),
131cdf0e10cSrcweir     mnDragSrcPgNum(SDRPAGE_NOTFOUND),
132cdf0e10cSrcweir     mnAction(DND_ACTION_NONE),
133cdf0e10cSrcweir     mnLockRedrawSmph(0),
134cdf0e10cSrcweir     mpLockedRedraws(NULL),
135cdf0e10cSrcweir     mbIsDropAllowed(sal_True),
136cdf0e10cSrcweir     maSmartTags(*this),
137cdf0e10cSrcweir     mpClipboard (new ViewClipboard (*this))
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     // #i73602# Use default from the configuration
140cdf0e10cSrcweir     SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_DrawImpress());
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     // #i74769#, #i75172# Use default from the configuration
143cdf0e10cSrcweir     SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_DrawImpress());
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     EnableExtendedKeyInputDispatcher(sal_False);
146cdf0e10cSrcweir     EnableExtendedMouseEventDispatcher(sal_False);
147cdf0e10cSrcweir     EnableExtendedCommandEventDispatcher(sal_False);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     SetUseIncompatiblePathCreateInterface(sal_False);
150cdf0e10cSrcweir     SetMarkHdlWhenTextEdit(sal_True);
151cdf0e10cSrcweir     EnableTextEditOnObjectsWithoutTextIfTextTool(sal_True);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     SetMinMoveDistancePixel(2);
154cdf0e10cSrcweir     SetHitTolerancePixel(2);
155cdf0e10cSrcweir     SetMeasureLayer(String(SdResId(STR_LAYER_MEASURELINES)));
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     // Timer fuer verzoegertes Drop (muss fuer MAC sein)
158cdf0e10cSrcweir     maDropErrorTimer.SetTimeoutHdl( LINK(this, View, DropErrorHdl) );
159cdf0e10cSrcweir     maDropErrorTimer.SetTimeout(50);
160cdf0e10cSrcweir     maDropInsertFileTimer.SetTimeoutHdl( LINK(this, View, DropInsertFileHdl) );
161cdf0e10cSrcweir     maDropInsertFileTimer.SetTimeout(50);
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
ImplClearDrawDropMarker()164cdf0e10cSrcweir void View::ImplClearDrawDropMarker()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir     if(mpDropMarker)
167cdf0e10cSrcweir     {
168cdf0e10cSrcweir         delete mpDropMarker;
169cdf0e10cSrcweir         mpDropMarker = 0L;
170cdf0e10cSrcweir     }
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir /*************************************************************************
174cdf0e10cSrcweir |*
175cdf0e10cSrcweir |* Dtor
176cdf0e10cSrcweir |*
177cdf0e10cSrcweir \************************************************************************/
178cdf0e10cSrcweir 
~View()179cdf0e10cSrcweir View::~View()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     maSmartTags.Dispose();
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     // release content of selection clipboard, if we own the content
184cdf0e10cSrcweir     UpdateSelectionClipboard( sal_True );
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     maDropErrorTimer.Stop();
187cdf0e10cSrcweir     maDropInsertFileTimer.Stop();
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     ImplClearDrawDropMarker();
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     while(PaintWindowCount())
192cdf0e10cSrcweir     {
193cdf0e10cSrcweir         // Alle angemeldeten OutDevs entfernen
194cdf0e10cSrcweir         DeleteWindowFromPaintView(GetFirstOutputDevice() /*GetWin(0)*/);
195cdf0e10cSrcweir     }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     // gespeicherte Redraws loeschen
198cdf0e10cSrcweir     if (mpLockedRedraws)
199cdf0e10cSrcweir     {
200cdf0e10cSrcweir         SdViewRedrawRec* pRec = (SdViewRedrawRec*)mpLockedRedraws->First();
201cdf0e10cSrcweir         while (pRec)
202cdf0e10cSrcweir         {
203cdf0e10cSrcweir             delete pRec;
204cdf0e10cSrcweir             pRec = (SdViewRedrawRec*)mpLockedRedraws->Next();
205cdf0e10cSrcweir         }
206cdf0e10cSrcweir         delete mpLockedRedraws;
207cdf0e10cSrcweir     }
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 
211cdf0e10cSrcweir class ViewRedirector : public ::sdr::contact::ViewObjectContactRedirector
212cdf0e10cSrcweir {
213cdf0e10cSrcweir public:
214cdf0e10cSrcweir     ViewRedirector();
215cdf0e10cSrcweir     virtual ~ViewRedirector();
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     // all default implementations just call the same methods at the original. To do something
218cdf0e10cSrcweir     // different, overload the method and at least do what the method does.
219cdf0e10cSrcweir     virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
220cdf0e10cSrcweir         const sdr::contact::ViewObjectContact& rOriginal,
221cdf0e10cSrcweir         const sdr::contact::DisplayInfo& rDisplayInfo);
222cdf0e10cSrcweir };
223cdf0e10cSrcweir 
ViewRedirector()224cdf0e10cSrcweir ViewRedirector::ViewRedirector()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
~ViewRedirector()228cdf0e10cSrcweir ViewRedirector::~ViewRedirector()
229cdf0e10cSrcweir {
230cdf0e10cSrcweir }
231cdf0e10cSrcweir 
createRedirectedPrimitive2DSequence(const sdr::contact::ViewObjectContact & rOriginal,const sdr::contact::DisplayInfo & rDisplayInfo)232cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence ViewRedirector::createRedirectedPrimitive2DSequence(
233cdf0e10cSrcweir     const sdr::contact::ViewObjectContact& rOriginal,
234cdf0e10cSrcweir     const sdr::contact::DisplayInfo& rDisplayInfo)
235cdf0e10cSrcweir {
236cdf0e10cSrcweir     SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
237cdf0e10cSrcweir     drawinglayer::primitive2d::Primitive2DSequence xRetval;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     if(pObject && pObject->GetPage())
240cdf0e10cSrcweir     {
241cdf0e10cSrcweir         const bool bDoCreateGeometry(pObject->GetPage()->checkVisibility( rOriginal, rDisplayInfo, true ));
242cdf0e10cSrcweir 
243cdf0e10cSrcweir         if(!bDoCreateGeometry && !(( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE )) )
244cdf0e10cSrcweir             return xRetval;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir         PresObjKind eKind(PRESOBJ_NONE);
247cdf0e10cSrcweir         const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
248cdf0e10cSrcweir         const bool bIsMasterPageObject(pObject->GetPage()->IsMasterPage());
249cdf0e10cSrcweir         const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter());
250cdf0e10cSrcweir         const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
251cdf0e10cSrcweir         const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
252cdf0e10cSrcweir         const SdPage* pObjectsSdPage = dynamic_cast< SdPage* >(pObject->GetPage());
253cdf0e10cSrcweir         const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
254cdf0e10cSrcweir 
255cdf0e10cSrcweir         // check if we need to draw a placeholder border. Never do it for
256cdf0e10cSrcweir         // objects inside a SdrPageObj and never when printing
257cdf0e10cSrcweir         if(!bIsInsidePageObj && !bIsPrinting)
258cdf0e10cSrcweir         {
259cdf0e10cSrcweir             bool bCreateOutline(false);
260cdf0e10cSrcweir 
261cdf0e10cSrcweir             if( pObject->IsEmptyPresObj() && pObject->ISA(SdrTextObj) )
262cdf0e10cSrcweir             {
263cdf0e10cSrcweir                 if( !bSubContentProcessing || !pObject->IsNotVisibleAsMaster() )
264cdf0e10cSrcweir                 {
265cdf0e10cSrcweir                     eKind = pObjectsSdPage ? pObjectsSdPage->GetPresObjKind(pObject) : PRESOBJ_NONE;
266cdf0e10cSrcweir                     bCreateOutline = true;
267cdf0e10cSrcweir                 }
268cdf0e10cSrcweir             }
269cdf0e10cSrcweir             else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_TEXT ) )
270cdf0e10cSrcweir             {
271cdf0e10cSrcweir                 if( pObjectsSdPage )
272cdf0e10cSrcweir                 {
273cdf0e10cSrcweir                     eKind = pObjectsSdPage->GetPresObjKind(pObject);
274cdf0e10cSrcweir 
275cdf0e10cSrcweir                     if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
276cdf0e10cSrcweir                     {
277cdf0e10cSrcweir                         if( !bSubContentProcessing )
278cdf0e10cSrcweir                         {
279cdf0e10cSrcweir                             // only draw a boundary for header&footer objects on the masterpage itself
280cdf0e10cSrcweir                             bCreateOutline = true;
281cdf0e10cSrcweir                         }
282cdf0e10cSrcweir                     }
283cdf0e10cSrcweir                 }
284cdf0e10cSrcweir             }
285cdf0e10cSrcweir             else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE ) )
286cdf0e10cSrcweir             {
287cdf0e10cSrcweir                 // only for handout page, else this frame will be created for each
288cdf0e10cSrcweir                 // page preview object in SlideSorter and PagePane
289cdf0e10cSrcweir                 if(pObjectsSdPage && PK_HANDOUT == pObjectsSdPage->GetPageKind())
290cdf0e10cSrcweir                 {
291cdf0e10cSrcweir                     bCreateOutline = true;
292cdf0e10cSrcweir                 }
293cdf0e10cSrcweir             }
294cdf0e10cSrcweir 
295cdf0e10cSrcweir             if(bCreateOutline)
296cdf0e10cSrcweir             {
297cdf0e10cSrcweir                 // empty presentation objects get a gray frame
298cdf0e10cSrcweir                 const svtools::ColorConfig aColorConfig;
299cdf0e10cSrcweir                 const svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( svtools::OBJECTBOUNDARIES ) );
300cdf0e10cSrcweir 
301cdf0e10cSrcweir                 if( aColor.bIsVisible )
302cdf0e10cSrcweir                 {
303cdf0e10cSrcweir                     // get basic object transformation
304cdf0e10cSrcweir                     const basegfx::BColor aRGBColor(Color(aColor.nColor).getBColor());
305cdf0e10cSrcweir                     basegfx::B2DHomMatrix aObjectMatrix;
306cdf0e10cSrcweir                     basegfx::B2DPolyPolygon aObjectPolyPolygon;
307cdf0e10cSrcweir                     pObject->TRGetBaseGeometry(aObjectMatrix, aObjectPolyPolygon);
308cdf0e10cSrcweir 
309cdf0e10cSrcweir                     // create dashed border
310cdf0e10cSrcweir                     {
311cdf0e10cSrcweir                         // create object polygon
312cdf0e10cSrcweir                         basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
313cdf0e10cSrcweir                         aPolygon.transform(aObjectMatrix);
314cdf0e10cSrcweir 
315cdf0e10cSrcweir                         // create line and stroke attribute
316cdf0e10cSrcweir                         ::std::vector< double > aDotDashArray;
317cdf0e10cSrcweir 
318cdf0e10cSrcweir                         aDotDashArray.push_back(160.0);
319cdf0e10cSrcweir                         aDotDashArray.push_back(80.0);
320cdf0e10cSrcweir 
321cdf0e10cSrcweir                         const double fFullDotDashLen(::std::accumulate(aDotDashArray.begin(), aDotDashArray.end(), 0.0));
322cdf0e10cSrcweir                         const drawinglayer::attribute::LineAttribute aLine(aRGBColor);
323cdf0e10cSrcweir                         const drawinglayer::attribute::StrokeAttribute aStroke(aDotDashArray, fFullDotDashLen);
324cdf0e10cSrcweir 
325cdf0e10cSrcweir                         // create primitive and add
326cdf0e10cSrcweir                         const drawinglayer::primitive2d::Primitive2DReference xRef(new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
327cdf0e10cSrcweir                             aPolygon,
328cdf0e10cSrcweir                             aLine,
329cdf0e10cSrcweir                             aStroke));
330cdf0e10cSrcweir                         drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
331cdf0e10cSrcweir                     }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir                     // now paint the placeholder description, but only when masterpage
334cdf0e10cSrcweir                     // is displayed as page directly (MasterPage view)
335cdf0e10cSrcweir                     if(!bSubContentProcessing && bIsMasterPageObject)
336cdf0e10cSrcweir                     {
337cdf0e10cSrcweir                         String aObjectString;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir                         switch( eKind )
340cdf0e10cSrcweir                         {
341cdf0e10cSrcweir                             case PRESOBJ_TITLE:
342cdf0e10cSrcweir                             {
343cdf0e10cSrcweir                                 if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
344cdf0e10cSrcweir                                 {
345cdf0e10cSrcweir                                     static String aTitleAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_TITLE ) );
346cdf0e10cSrcweir                                     aObjectString = aTitleAreaStr;
347cdf0e10cSrcweir                                 }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir                                 break;
350cdf0e10cSrcweir                             }
351cdf0e10cSrcweir                             case PRESOBJ_OUTLINE:
352cdf0e10cSrcweir                             {
353cdf0e10cSrcweir                                 static String aOutlineAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_OUTLINE ) );
354cdf0e10cSrcweir                                 aObjectString = aOutlineAreaStr;
355cdf0e10cSrcweir                                 break;
356cdf0e10cSrcweir                             }
357cdf0e10cSrcweir                             case PRESOBJ_FOOTER:
358cdf0e10cSrcweir                             {
359cdf0e10cSrcweir                                 static String aFooterAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_FOOTER ) );
360cdf0e10cSrcweir                                 aObjectString = aFooterAreaStr;
361cdf0e10cSrcweir                                 break;
362cdf0e10cSrcweir                             }
363cdf0e10cSrcweir                             case PRESOBJ_HEADER:
364cdf0e10cSrcweir                             {
365cdf0e10cSrcweir                                 static String aHeaderAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_HEADER ) );
366cdf0e10cSrcweir                                 aObjectString = aHeaderAreaStr;
367cdf0e10cSrcweir                                 break;
368cdf0e10cSrcweir                             }
369cdf0e10cSrcweir                             case PRESOBJ_DATETIME:
370cdf0e10cSrcweir                             {
371cdf0e10cSrcweir                                 static String aDateTimeStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_DATETIME ) );
372cdf0e10cSrcweir                                 aObjectString = aDateTimeStr;
373cdf0e10cSrcweir                                 break;
374cdf0e10cSrcweir                             }
375cdf0e10cSrcweir                             case PRESOBJ_NOTES:
376cdf0e10cSrcweir                             {
377cdf0e10cSrcweir                                 static String aDateTimeStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_NOTES ) );
378cdf0e10cSrcweir                                 aObjectString = aDateTimeStr;
379cdf0e10cSrcweir                                 break;
380cdf0e10cSrcweir                             }
381cdf0e10cSrcweir                             case PRESOBJ_SLIDENUMBER:
382cdf0e10cSrcweir                             {
383cdf0e10cSrcweir                                 if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
384cdf0e10cSrcweir                                 {
385cdf0e10cSrcweir                                     static String aSlideAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_SLIDE ) );
386cdf0e10cSrcweir                                     aObjectString = aSlideAreaStr;
387cdf0e10cSrcweir                                 }
388cdf0e10cSrcweir                                 else
389cdf0e10cSrcweir                                 {
390cdf0e10cSrcweir                                     static String aNumberAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_NUMBER ) );
391cdf0e10cSrcweir                                     aObjectString = aNumberAreaStr;
392cdf0e10cSrcweir                                 }
393cdf0e10cSrcweir                                 break;
394cdf0e10cSrcweir                             }
395cdf0e10cSrcweir                             default:
396cdf0e10cSrcweir                             {
397cdf0e10cSrcweir                                 break;
398cdf0e10cSrcweir                             }
399cdf0e10cSrcweir                         }
400cdf0e10cSrcweir 
401cdf0e10cSrcweir                         if( aObjectString.Len() )
402cdf0e10cSrcweir                         {
403cdf0e10cSrcweir                             // decompose object matrix to be able to place text correctly
404cdf0e10cSrcweir                             basegfx::B2DTuple aScale;
405cdf0e10cSrcweir                             basegfx::B2DTuple aTranslate;
406cdf0e10cSrcweir                             double fRotate, fShearX;
407cdf0e10cSrcweir                             aObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
408cdf0e10cSrcweir 
409cdf0e10cSrcweir                             // create font
410cdf0e10cSrcweir                             SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObject );
411cdf0e10cSrcweir                             const SdrTextVertAdjust eTVA(pTextObj ? pTextObj->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_CENTER);
412cdf0e10cSrcweir                             Font aScaledVclFont;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir                             // use a text size factor to get more reliable text sizes from the text layouter
415cdf0e10cSrcweir                             // (and from vcl), tipp from HDU
416cdf0e10cSrcweir                             static sal_uInt32 nTextSizeFactor(100);
417cdf0e10cSrcweir 
418cdf0e10cSrcweir                             // use a factor to get more linear text size calculations
419cdf0e10cSrcweir                             aScaledVclFont.SetHeight( 500 * nTextSizeFactor );
420cdf0e10cSrcweir 
421cdf0e10cSrcweir                             // get basic geometry and get text size
422cdf0e10cSrcweir                             drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
423cdf0e10cSrcweir                             aTextLayouter.setFont(aScaledVclFont);
424cdf0e10cSrcweir                             const xub_StrLen nTextLength(aObjectString.Len());
425cdf0e10cSrcweir 
426cdf0e10cSrcweir                             // do not forget to use the factor again to get the width for the 500
427cdf0e10cSrcweir                             const double fTextWidth(aTextLayouter.getTextWidth(aObjectString, 0, nTextLength) * (1.0 / nTextSizeFactor));
428cdf0e10cSrcweir                             const double fTextHeight(aTextLayouter.getTextHeight() * (1.0 / nTextSizeFactor));
429cdf0e10cSrcweir 
430cdf0e10cSrcweir                             // calculate text primitive position. If text is at bottom, use top for
431cdf0e10cSrcweir                             // the extra text and vice versa
432cdf0e10cSrcweir                             const double fHorDist(125);
433cdf0e10cSrcweir                             const double fVerDist(125);
434cdf0e10cSrcweir                             const double fPosX((aTranslate.getX() + aScale.getX()) - fTextWidth - fHorDist);
435cdf0e10cSrcweir                             const double fPosY((SDRTEXTVERTADJUST_BOTTOM == eTVA)
436cdf0e10cSrcweir                                 ? aTranslate.getY() - fVerDist + fTextHeight
437cdf0e10cSrcweir                                 : (aTranslate.getY() + aScale.getY()) - fVerDist);
438cdf0e10cSrcweir 
439cdf0e10cSrcweir                             // get font attributes; use normally scaled font
440cdf0e10cSrcweir                             const basegfx::BColor aFontColor(aRGBColor);
441cdf0e10cSrcweir                             Font aVclFont;
442cdf0e10cSrcweir                             basegfx::B2DVector aTextSizeAttribute;
443cdf0e10cSrcweir 
444cdf0e10cSrcweir                             aVclFont.SetHeight( 500 );
445cdf0e10cSrcweir 
446cdf0e10cSrcweir                             const drawinglayer::attribute::FontAttribute aFontAttribute(
447cdf0e10cSrcweir                                 drawinglayer::primitive2d::getFontAttributeFromVclFont(
448cdf0e10cSrcweir                                     aTextSizeAttribute,
449cdf0e10cSrcweir                                     aVclFont,
450cdf0e10cSrcweir                                     false,
451cdf0e10cSrcweir                                     false));
452cdf0e10cSrcweir 
453cdf0e10cSrcweir                             // fill text matrix
454cdf0e10cSrcweir                             const basegfx::B2DHomMatrix aTextMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
455cdf0e10cSrcweir                                 aTextSizeAttribute.getX(), aTextSizeAttribute.getY(),
456cdf0e10cSrcweir                                 fShearX,
457cdf0e10cSrcweir                                 fRotate,
458cdf0e10cSrcweir                                 fPosX, fPosY));
459cdf0e10cSrcweir 
460cdf0e10cSrcweir                             // create DXTextArray (can be empty one)
461cdf0e10cSrcweir                             const ::std::vector< double > aDXArray;
462cdf0e10cSrcweir 
463cdf0e10cSrcweir                             // create locale; this may need some more information in the future
464cdf0e10cSrcweir                             const ::com::sun::star::lang::Locale aLocale;
465cdf0e10cSrcweir 
466cdf0e10cSrcweir                             // create primitive and add
467cdf0e10cSrcweir                             const drawinglayer::primitive2d::Primitive2DReference xRef(
468cdf0e10cSrcweir                                 new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
469cdf0e10cSrcweir                                     aTextMatrix,
470cdf0e10cSrcweir                                     aObjectString,
471cdf0e10cSrcweir                                     0,
472cdf0e10cSrcweir                                     nTextLength,
473cdf0e10cSrcweir                                     aDXArray,
474cdf0e10cSrcweir                                     aFontAttribute,
475cdf0e10cSrcweir                                     aLocale,
476cdf0e10cSrcweir                                     aFontColor));
477cdf0e10cSrcweir                             drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
478cdf0e10cSrcweir                         }
479cdf0e10cSrcweir                     }
480cdf0e10cSrcweir                 }
481cdf0e10cSrcweir             }
482cdf0e10cSrcweir         }
483cdf0e10cSrcweir 
484cdf0e10cSrcweir         if(bDoCreateGeometry)
485cdf0e10cSrcweir         {
486cdf0e10cSrcweir             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
487cdf0e10cSrcweir                 xRetval,
488cdf0e10cSrcweir                 sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
489cdf0e10cSrcweir                     rOriginal,
490cdf0e10cSrcweir                     rDisplayInfo));
491cdf0e10cSrcweir         }
492cdf0e10cSrcweir     }
493cdf0e10cSrcweir     else
494cdf0e10cSrcweir     {
495cdf0e10cSrcweir         // not a SdrObject visualisation (maybe e.g. page) or no page
496cdf0e10cSrcweir         xRetval = sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
497cdf0e10cSrcweir     }
498cdf0e10cSrcweir 
499cdf0e10cSrcweir     return xRetval;
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir /*************************************************************************
503cdf0e10cSrcweir |*
504cdf0e10cSrcweir |* Paint-Methode: das Ereignis wird an die View weitergeleitet
505cdf0e10cSrcweir |*
506cdf0e10cSrcweir \************************************************************************/
507cdf0e10cSrcweir 
CompleteRedraw(OutputDevice * pOutDev,const Region & rReg,sdr::contact::ViewObjectContactRedirector * pRedirector)508cdf0e10cSrcweir void View::CompleteRedraw(OutputDevice* pOutDev, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector /*=0L*/)
509cdf0e10cSrcweir {
510cdf0e10cSrcweir     // ausfuehren ??
511cdf0e10cSrcweir     if (mnLockRedrawSmph == 0)
512cdf0e10cSrcweir     {
513cdf0e10cSrcweir         SdrPageView* pPgView = GetSdrPageView();
514cdf0e10cSrcweir 
515cdf0e10cSrcweir         if (pPgView)
516cdf0e10cSrcweir         {
517cdf0e10cSrcweir             SdPage* pPage = (SdPage*) pPgView->GetPage();
518cdf0e10cSrcweir             if( pPage )
519cdf0e10cSrcweir             {
520cdf0e10cSrcweir                 SdrOutliner& rOutl=mpDoc->GetDrawOutliner(NULL);
521cdf0e10cSrcweir                 bool bScreenDisplay(true);
522cdf0e10cSrcweir 
523cdf0e10cSrcweir                 if(bScreenDisplay && pOutDev && OUTDEV_PRINTER == pOutDev->GetOutDevType())
524cdf0e10cSrcweir                 {
525cdf0e10cSrcweir                     // #i75566# printing; suppress AutoColor BackgroundColor generation
526cdf0e10cSrcweir                     // for visibility reasons by giving GetPageBackgroundColor()
527cdf0e10cSrcweir                     // the needed hint
528cdf0e10cSrcweir                     bScreenDisplay = false;
529cdf0e10cSrcweir                 }
530cdf0e10cSrcweir 
531cdf0e10cSrcweir                 if(bScreenDisplay && pOutDev && pOutDev->GetPDFWriter())
532cdf0e10cSrcweir                 {
533cdf0e10cSrcweir                     // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
534cdf0e10cSrcweir                     bScreenDisplay = false;
535cdf0e10cSrcweir                 }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir                 // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
538cdf0e10cSrcweir                 // hint value if screen display. Only then the AutoColor mechanisms shall be applied
539cdf0e10cSrcweir                 rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor(pPgView, bScreenDisplay) );
540cdf0e10cSrcweir             }
541cdf0e10cSrcweir         }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir         ViewRedirector aViewRedirector;
544cdf0e10cSrcweir         FmFormView::CompleteRedraw(pOutDev, rReg, pRedirector ? pRedirector : &aViewRedirector);
545cdf0e10cSrcweir     }
546cdf0e10cSrcweir     // oder speichern?
547cdf0e10cSrcweir     else
548cdf0e10cSrcweir     {
549cdf0e10cSrcweir         if (!mpLockedRedraws)
550cdf0e10cSrcweir             mpLockedRedraws = new List;
551cdf0e10cSrcweir 
552cdf0e10cSrcweir         SdViewRedrawRec* pRec = new SdViewRedrawRec;
553cdf0e10cSrcweir         pRec->mpOut = pOutDev;
554cdf0e10cSrcweir         pRec->aRect = rReg.GetBoundRect();
555cdf0e10cSrcweir         mpLockedRedraws->Insert(pRec, LIST_APPEND);
556cdf0e10cSrcweir     }
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
559cdf0e10cSrcweir 
560cdf0e10cSrcweir /*************************************************************************
561cdf0e10cSrcweir |*
562cdf0e10cSrcweir |* Selektion hat sich geaendert
563cdf0e10cSrcweir |*
564cdf0e10cSrcweir \************************************************************************/
565cdf0e10cSrcweir 
MarkListHasChanged()566cdf0e10cSrcweir void View::MarkListHasChanged()
567cdf0e10cSrcweir {
568cdf0e10cSrcweir     FmFormView::MarkListHasChanged();
569cdf0e10cSrcweir 
570cdf0e10cSrcweir     if( GetMarkedObjectCount() > 0 )
571cdf0e10cSrcweir         maSmartTags.deselect();
572cdf0e10cSrcweir }
573cdf0e10cSrcweir 
574cdf0e10cSrcweir 
575cdf0e10cSrcweir /*************************************************************************
576cdf0e10cSrcweir |*
577cdf0e10cSrcweir |* Attribute setzen
578cdf0e10cSrcweir |*
579cdf0e10cSrcweir \************************************************************************/
580cdf0e10cSrcweir 
SetAttributes(const SfxItemSet & rSet,sal_Bool bReplaceAll)581cdf0e10cSrcweir sal_Bool View::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
582cdf0e10cSrcweir {
583cdf0e10cSrcweir     sal_Bool bOk = FmFormView::SetAttributes(rSet, bReplaceAll);
584cdf0e10cSrcweir     return (bOk);
585cdf0e10cSrcweir }
586cdf0e10cSrcweir 
587cdf0e10cSrcweir 
588cdf0e10cSrcweir /*************************************************************************
589cdf0e10cSrcweir |*
590cdf0e10cSrcweir |* Attribute holen
591cdf0e10cSrcweir |*
592cdf0e10cSrcweir \************************************************************************/
593cdf0e10cSrcweir 
GetAttributes(SfxItemSet & rTargetSet,sal_Bool bOnlyHardAttr) const594cdf0e10cSrcweir sal_Bool View::GetAttributes( SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr ) const
595cdf0e10cSrcweir {
596cdf0e10cSrcweir     return( FmFormView::GetAttributes( rTargetSet, bOnlyHardAttr ) );
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 
600cdf0e10cSrcweir /*************************************************************************
601cdf0e10cSrcweir |*
602cdf0e10cSrcweir |* Ist ein Praesentationsobjekt selektiert?
603cdf0e10cSrcweir |*
604cdf0e10cSrcweir \************************************************************************/
605cdf0e10cSrcweir 
IsPresObjSelected(sal_Bool bOnPage,sal_Bool bOnMasterPage,sal_Bool bCheckPresObjListOnly,sal_Bool bCheckLayoutOnly) const606cdf0e10cSrcweir sal_Bool View::IsPresObjSelected(sal_Bool bOnPage, sal_Bool bOnMasterPage, sal_Bool bCheckPresObjListOnly, sal_Bool bCheckLayoutOnly) const
607cdf0e10cSrcweir {
608cdf0e10cSrcweir     /**************************************************************************
609cdf0e10cSrcweir     * Ist ein Presentationsobjekt selektiert?
610cdf0e10cSrcweir     **************************************************************************/
611cdf0e10cSrcweir     SdrMarkList* pMarkList;
612cdf0e10cSrcweir 
613cdf0e10cSrcweir     if (mnDragSrcPgNum != SDRPAGE_NOTFOUND &&
614cdf0e10cSrcweir         mnDragSrcPgNum != GetSdrPageView()->GetPage()->GetPageNum())
615cdf0e10cSrcweir     {
616cdf0e10cSrcweir         // Es laeuft gerade Drag&Drop
617cdf0e10cSrcweir         // Source- und Destination-Page unterschiedlich:
618cdf0e10cSrcweir         // es wird die gemerkte MarkList verwendet
619cdf0e10cSrcweir         pMarkList = mpDragSrcMarkList;
620cdf0e10cSrcweir     }
621cdf0e10cSrcweir     else
622cdf0e10cSrcweir     {
623cdf0e10cSrcweir         // Es wird die aktuelle MarkList verwendet
624cdf0e10cSrcweir         pMarkList = new SdrMarkList(GetMarkedObjectList());
625cdf0e10cSrcweir     }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir     SdrMark* pMark;
628cdf0e10cSrcweir     SdPage* pPage;
629cdf0e10cSrcweir     SdrObject* pObj;
630cdf0e10cSrcweir 
631cdf0e10cSrcweir     sal_Bool bSelected = sal_False;
632cdf0e10cSrcweir     sal_Bool bMasterPage = sal_False;
633cdf0e10cSrcweir     long nMark;
634cdf0e10cSrcweir     long nMarkMax = long(pMarkList->GetMarkCount()) - 1;
635cdf0e10cSrcweir 
636cdf0e10cSrcweir     for (nMark = nMarkMax; (nMark >= 0) && !bSelected; nMark--)
637cdf0e10cSrcweir     {
638cdf0e10cSrcweir         // Rueckwaerts durch die Marklist
639cdf0e10cSrcweir         pMark = pMarkList->GetMark(nMark);
640cdf0e10cSrcweir         pObj = pMark->GetMarkedSdrObj();
641cdf0e10cSrcweir 
642cdf0e10cSrcweir         if ( pObj && ( bCheckPresObjListOnly || pObj->IsEmptyPresObj() || pObj->GetUserCall() ) )
643cdf0e10cSrcweir         {
644cdf0e10cSrcweir             pPage = (SdPage*) pObj->GetPage();
645cdf0e10cSrcweir             bMasterPage = pPage->IsMasterPage();
646cdf0e10cSrcweir 
647cdf0e10cSrcweir             if ( (bMasterPage && bOnMasterPage) || (!bMasterPage && bOnPage) )
648cdf0e10cSrcweir             {
649cdf0e10cSrcweir                 if ( pPage && pPage->IsPresObj(pObj) )
650cdf0e10cSrcweir                 {
651cdf0e10cSrcweir                     if( bCheckLayoutOnly )
652cdf0e10cSrcweir                     {
653cdf0e10cSrcweir                         PresObjKind eKind = pPage->GetPresObjKind(pObj);
654cdf0e10cSrcweir 
655cdf0e10cSrcweir                         if((eKind != PRESOBJ_FOOTER) && (eKind != PRESOBJ_HEADER) && (eKind != PRESOBJ_DATETIME) && (eKind != PRESOBJ_SLIDENUMBER) )
656cdf0e10cSrcweir                             bSelected = sal_True;
657cdf0e10cSrcweir                     }
658cdf0e10cSrcweir                     else
659cdf0e10cSrcweir                     {
660cdf0e10cSrcweir                         bSelected = sal_True;
661cdf0e10cSrcweir                     }
662cdf0e10cSrcweir                 }
663cdf0e10cSrcweir             }
664cdf0e10cSrcweir         }
665cdf0e10cSrcweir     }
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     if (pMarkList != mpDragSrcMarkList)
668cdf0e10cSrcweir     {
669cdf0e10cSrcweir        delete pMarkList;
670cdf0e10cSrcweir     }
671cdf0e10cSrcweir 
672cdf0e10cSrcweir     return (bSelected);
673cdf0e10cSrcweir }
674cdf0e10cSrcweir 
675cdf0e10cSrcweir /*************************************************************************
676cdf0e10cSrcweir |*
677cdf0e10cSrcweir |* Alles selektieren
678cdf0e10cSrcweir |*
679cdf0e10cSrcweir \************************************************************************/
680cdf0e10cSrcweir 
SelectAll()681cdf0e10cSrcweir void View::SelectAll()
682cdf0e10cSrcweir {
683cdf0e10cSrcweir     if ( IsTextEdit() )
684cdf0e10cSrcweir     {
685cdf0e10cSrcweir         OutlinerView* pOLV = GetTextEditOutlinerView();
686cdf0e10cSrcweir         const ::Outliner* pOutliner = GetTextEditOutliner();
687cdf0e10cSrcweir         pOLV->SelectRange( 0, (sal_uInt16) pOutliner->GetParagraphCount() );
688cdf0e10cSrcweir     }
689cdf0e10cSrcweir     else
690cdf0e10cSrcweir     {
691cdf0e10cSrcweir         MarkAll();
692cdf0e10cSrcweir     }
693cdf0e10cSrcweir }
694cdf0e10cSrcweir 
695cdf0e10cSrcweir 
696cdf0e10cSrcweir /*************************************************************************
697cdf0e10cSrcweir |*
698cdf0e10cSrcweir |* Dokument hat sich geaendert
699cdf0e10cSrcweir |*
700cdf0e10cSrcweir \************************************************************************/
701cdf0e10cSrcweir 
ModelHasChanged()702cdf0e10cSrcweir void View::ModelHasChanged()
703cdf0e10cSrcweir {
704cdf0e10cSrcweir     // Erst SdrView benachrichtigen
705cdf0e10cSrcweir     FmFormView::ModelHasChanged();
706cdf0e10cSrcweir }
707cdf0e10cSrcweir 
708cdf0e10cSrcweir /*************************************************************************
709cdf0e10cSrcweir |*
710cdf0e10cSrcweir |* StyleSheet setzen
711cdf0e10cSrcweir |*
712cdf0e10cSrcweir \************************************************************************/
713cdf0e10cSrcweir 
SetStyleSheet(SfxStyleSheet * pStyleSheet,sal_Bool bDontRemoveHardAttr)714cdf0e10cSrcweir sal_Bool View::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
715cdf0e10cSrcweir {
716cdf0e10cSrcweir     // weiter an SdrView
717cdf0e10cSrcweir     return FmFormView::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
718cdf0e10cSrcweir }
719cdf0e10cSrcweir 
720cdf0e10cSrcweir 
721cdf0e10cSrcweir /*************************************************************************
722cdf0e10cSrcweir |*
723cdf0e10cSrcweir |* Texteingabe beginnen
724cdf0e10cSrcweir |*
725cdf0e10cSrcweir \************************************************************************/
726cdf0e10cSrcweir 
SetSpellOptions(SdDrawDocument * pDoc,sal_uLong & rCntrl)727cdf0e10cSrcweir static void SetSpellOptions( SdDrawDocument* pDoc, sal_uLong& rCntrl )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir     sal_Bool bOnlineSpell = pDoc->GetOnlineSpell();
730cdf0e10cSrcweir 
731cdf0e10cSrcweir     if( bOnlineSpell )
732cdf0e10cSrcweir         rCntrl |= EE_CNTRL_ONLINESPELLING;
733cdf0e10cSrcweir     else
734cdf0e10cSrcweir         rCntrl &= ~EE_CNTRL_ONLINESPELLING;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir 
SdrBeginTextEdit(SdrObject * pObj,SdrPageView * pPV,::Window * pWin,sal_Bool bIsNewObj,SdrOutliner * pOutl,OutlinerView * pGivenOutlinerView,sal_Bool bDontDeleteOutliner,sal_Bool bOnlyOneView,sal_Bool bGrabFocus)737cdf0e10cSrcweir sal_Bool View::SdrBeginTextEdit(
738cdf0e10cSrcweir     SdrObject* pObj, SdrPageView* pPV, ::Window* pWin,
739cdf0e10cSrcweir     sal_Bool bIsNewObj,
740cdf0e10cSrcweir     SdrOutliner* pOutl, OutlinerView* pGivenOutlinerView,
741cdf0e10cSrcweir     sal_Bool bDontDeleteOutliner, sal_Bool bOnlyOneView, sal_Bool bGrabFocus )
742cdf0e10cSrcweir {
743cdf0e10cSrcweir     GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
744cdf0e10cSrcweir         sd::tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT, (void*)pObj );
745cdf0e10cSrcweir 
746cdf0e10cSrcweir     if( pOutl==NULL && pObj )
747cdf0e10cSrcweir         pOutl = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, pObj->GetModel() );
748cdf0e10cSrcweir 
749cdf0e10cSrcweir     // make draw&impress specific initialisations
750cdf0e10cSrcweir     if( pOutl )
751cdf0e10cSrcweir     {
752cdf0e10cSrcweir         pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
753cdf0e10cSrcweir         pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
754cdf0e10cSrcweir         sal_uLong nCntrl = pOutl->GetControlWord();
755cdf0e10cSrcweir         nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
756cdf0e10cSrcweir         nCntrl |= EE_CNTRL_URLSFXEXECUTE;
757cdf0e10cSrcweir         nCntrl |= EE_CNTRL_MARKFIELDS;
758cdf0e10cSrcweir         nCntrl |= EE_CNTRL_AUTOCORRECT;
759cdf0e10cSrcweir 
760cdf0e10cSrcweir         nCntrl &= ~EE_CNTRL_ULSPACESUMMATION;
761cdf0e10cSrcweir         if ( mpDoc->IsSummationOfParagraphs() )
762cdf0e10cSrcweir             nCntrl |= EE_CNTRL_ULSPACESUMMATION;
763cdf0e10cSrcweir 
764cdf0e10cSrcweir         SetSpellOptions( mpDoc, nCntrl );
765cdf0e10cSrcweir 
766cdf0e10cSrcweir         pOutl->SetControlWord(nCntrl);
767cdf0e10cSrcweir 
768cdf0e10cSrcweir         Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
769cdf0e10cSrcweir         if ( xSpellChecker.is() )
770cdf0e10cSrcweir             pOutl->SetSpeller( xSpellChecker );
771cdf0e10cSrcweir 
772cdf0e10cSrcweir         Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
773cdf0e10cSrcweir         if( xHyphenator.is() )
774cdf0e10cSrcweir             pOutl->SetHyphenator( xHyphenator );
775cdf0e10cSrcweir 
776cdf0e10cSrcweir         pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
777cdf0e10cSrcweir     }
778cdf0e10cSrcweir 
779cdf0e10cSrcweir     sal_Bool bReturn = FmFormView::SdrBeginTextEdit(
780cdf0e10cSrcweir         pObj, pPV, pWin, bIsNewObj, pOutl,
781cdf0e10cSrcweir         pGivenOutlinerView, bDontDeleteOutliner,
782cdf0e10cSrcweir         bOnlyOneView, bGrabFocus);
783cdf0e10cSrcweir 
784edf077abSOliver-Rainer Wittmann     if ( mpViewSh )
785edf077abSOliver-Rainer Wittmann     {
786edf077abSOliver-Rainer Wittmann         mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener();
787edf077abSOliver-Rainer Wittmann     }
788edf077abSOliver-Rainer Wittmann 
789cdf0e10cSrcweir     if (bReturn)
790cdf0e10cSrcweir     {
791cdf0e10cSrcweir         ::Outliner* pOL = GetTextEditOutliner();
792cdf0e10cSrcweir 
793cdf0e10cSrcweir         if( pObj && pObj->GetPage() )
794cdf0e10cSrcweir         {
795cdf0e10cSrcweir             Color aBackground;
796cdf0e10cSrcweir             if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_TABLE )
797cdf0e10cSrcweir             {
798cdf0e10cSrcweir                 aBackground = GetTextEditBackgroundColor(*this);
799cdf0e10cSrcweir             }
800cdf0e10cSrcweir             else
801cdf0e10cSrcweir             {
802cdf0e10cSrcweir                 aBackground = pObj->GetPage()->GetPageBackgroundColor(pPV);
803cdf0e10cSrcweir             }
80402c50d82SAndre Fischer             if (pOL != NULL)
805cdf0e10cSrcweir                 pOL->SetBackgroundColor( aBackground  );
806cdf0e10cSrcweir         }
807cdf0e10cSrcweir 
80802c50d82SAndre Fischer         if (pOL != NULL)
80902c50d82SAndre Fischer         {
810cdf0e10cSrcweir             pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl));
811cdf0e10cSrcweir             pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl));
812cdf0e10cSrcweir         }
81302c50d82SAndre Fischer     }
814cdf0e10cSrcweir 
815cdf0e10cSrcweir     return(bReturn);
816cdf0e10cSrcweir }
817cdf0e10cSrcweir 
818cdf0e10cSrcweir /** ends current text editing */
SdrEndTextEdit(sal_Bool bDontDeleteReally)819cdf0e10cSrcweir SdrEndTextEditKind View::SdrEndTextEdit(sal_Bool bDontDeleteReally )
820cdf0e10cSrcweir {
821cdf0e10cSrcweir     SdrObjectWeakRef xObj( GetTextEditObject() );
822cdf0e10cSrcweir 
823cdf0e10cSrcweir     sal_Bool bDefaultTextRestored = RestoreDefaultText( dynamic_cast< SdrTextObj* >( GetTextEditObject() ) );
824cdf0e10cSrcweir 
825cdf0e10cSrcweir     SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
826cdf0e10cSrcweir 
827cdf0e10cSrcweir     if( bDefaultTextRestored )
828cdf0e10cSrcweir     {
829cdf0e10cSrcweir         if( xObj.is() && !xObj->IsEmptyPresObj() )
830cdf0e10cSrcweir         {
831cdf0e10cSrcweir             xObj->SetEmptyPresObj( sal_True );
832cdf0e10cSrcweir         }
833cdf0e10cSrcweir         else
834cdf0e10cSrcweir         {
835cdf0e10cSrcweir             eKind = SDRENDTEXTEDIT_UNCHANGED;
836cdf0e10cSrcweir         }
837cdf0e10cSrcweir     }
838cdf0e10cSrcweir     else if( xObj.is() && xObj->IsEmptyPresObj() )
839cdf0e10cSrcweir     {
840cdf0e10cSrcweir         SdrTextObj* pObj = dynamic_cast< SdrTextObj* >( xObj.get() );
841cdf0e10cSrcweir         if( pObj && pObj->HasText() )
842cdf0e10cSrcweir         {
843cdf0e10cSrcweir             SdrPage* pPage = pObj->GetPage();
844cdf0e10cSrcweir             if( !pPage || !pPage->IsMasterPage() )
845cdf0e10cSrcweir                 pObj->SetEmptyPresObj( sal_False );
846cdf0e10cSrcweir         }
847cdf0e10cSrcweir     }
848cdf0e10cSrcweir 
84995a18594SAndre Fischer     GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
85095a18594SAndre Fischer         sd::tools::EventMultiplexerEvent::EID_END_TEXT_EDIT,
85195a18594SAndre Fischer         (void*)xObj.get() );
852cdf0e10cSrcweir 
853cdf0e10cSrcweir     if( xObj.is() )
854cdf0e10cSrcweir     {
855edf077abSOliver-Rainer Wittmann         if ( mpViewSh )
856edf077abSOliver-Rainer Wittmann         {
857edf077abSOliver-Rainer Wittmann             mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener();
858edf077abSOliver-Rainer Wittmann         }
859edf077abSOliver-Rainer Wittmann 
860cdf0e10cSrcweir         SdPage* pPage = dynamic_cast< SdPage* >( xObj->GetPage() );
861cdf0e10cSrcweir         if( pPage )
862cdf0e10cSrcweir             pPage->onEndTextEdit( xObj.get() );
863cdf0e10cSrcweir     }
864cdf0e10cSrcweir 
865cdf0e10cSrcweir     return(eKind);
866cdf0e10cSrcweir }
867cdf0e10cSrcweir 
868cdf0e10cSrcweir // --------------------------------------------------------------------
869cdf0e10cSrcweir 
870cdf0e10cSrcweir /** restores the default text if the given text object is currently in edit mode and
871cdf0e10cSrcweir     no text has been entered already. Is only usefull just before text edit ends. */
RestoreDefaultText(SdrTextObj * pTextObj)872cdf0e10cSrcweir bool View::RestoreDefaultText( SdrTextObj* pTextObj )
873cdf0e10cSrcweir {
874cdf0e10cSrcweir     bool bRestored = false;
875cdf0e10cSrcweir 
876cdf0e10cSrcweir     if( pTextObj && (pTextObj == GetTextEditObject()) )
877cdf0e10cSrcweir     {
878cdf0e10cSrcweir         if( !pTextObj->HasText() )
879cdf0e10cSrcweir         {
880cdf0e10cSrcweir             SdPage* pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
881cdf0e10cSrcweir 
882cdf0e10cSrcweir             if(pPage)
883cdf0e10cSrcweir             {
884cdf0e10cSrcweir                 bRestored = pPage->RestoreDefaultText( pTextObj );
885cdf0e10cSrcweir                 if( bRestored )
886cdf0e10cSrcweir                 {
887cdf0e10cSrcweir                     SdrOutliner* pOutliner = GetTextEditOutliner();
888cdf0e10cSrcweir                     pTextObj->SetTextEditOutliner( pOutliner );
889cdf0e10cSrcweir                     OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
890cdf0e10cSrcweir                     if (pOutliner)
891cdf0e10cSrcweir                         pOutliner->SetText(*pParaObj);
892cdf0e10cSrcweir                 }
893cdf0e10cSrcweir             }
894cdf0e10cSrcweir         }
895cdf0e10cSrcweir     }
896cdf0e10cSrcweir 
897cdf0e10cSrcweir     return bRestored;
898cdf0e10cSrcweir }
899cdf0e10cSrcweir 
900cdf0e10cSrcweir /*************************************************************************
901cdf0e10cSrcweir |*
902cdf0e10cSrcweir |* Originalgroesse der markierten Objekte setzen
903cdf0e10cSrcweir |*
904cdf0e10cSrcweir \************************************************************************/
905cdf0e10cSrcweir 
SetMarkedOriginalSize()906cdf0e10cSrcweir void View::SetMarkedOriginalSize()
907cdf0e10cSrcweir {
908cdf0e10cSrcweir     SdrUndoGroup*   pUndoGroup = new SdrUndoGroup(*mpDoc);
909cdf0e10cSrcweir     sal_uLong           nCount = GetMarkedObjectCount();
910cdf0e10cSrcweir     sal_Bool            bOK = sal_False;
911cdf0e10cSrcweir 
912cdf0e10cSrcweir     for( sal_uInt32 i = 0; i < nCount; i++ )
913cdf0e10cSrcweir     {
914cdf0e10cSrcweir         SdrObject* pObj = GetMarkedObjectByIndex(i);
915cdf0e10cSrcweir 
916cdf0e10cSrcweir         if( pObj->GetObjInventor() == SdrInventor )
917cdf0e10cSrcweir         {
918cdf0e10cSrcweir             if( pObj->GetObjIdentifier() == OBJ_OLE2 )
919cdf0e10cSrcweir             {
920cdf0e10cSrcweir                 uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObj)->GetObjRef();
921cdf0e10cSrcweir                 if( xObj.is() )
922cdf0e10cSrcweir                 {
923cdf0e10cSrcweir                     // TODO/LEAN: working with VisualArea can switch object to running state
924cdf0e10cSrcweir 
925cdf0e10cSrcweir                     sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
926cdf0e10cSrcweir                     Size aOleSize;
927cdf0e10cSrcweir 
928cdf0e10cSrcweir                     if ( nAspect == embed::Aspects::MSOLE_ICON )
929cdf0e10cSrcweir                     {
930cdf0e10cSrcweir                         MapMode aMap100( MAP_100TH_MM );
931cdf0e10cSrcweir                         aOleSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMap100 );
932cdf0e10cSrcweir                         bOK = sal_True;
933cdf0e10cSrcweir                     }
934cdf0e10cSrcweir                     else
935cdf0e10cSrcweir                     {
936cdf0e10cSrcweir                         MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
937cdf0e10cSrcweir                         try
938cdf0e10cSrcweir                         {
939cdf0e10cSrcweir                             awt::Size aSz = xObj->getVisualAreaSize( nAspect );
940cdf0e10cSrcweir                             aOleSize = OutputDevice::LogicToLogic( Size( aSz.Width, aSz.Height ), aUnit, MAP_100TH_MM );
941cdf0e10cSrcweir                             bOK = sal_True;
942cdf0e10cSrcweir                         }
943cdf0e10cSrcweir                         catch( embed::NoVisualAreaSizeException& )
944cdf0e10cSrcweir                         {}
945cdf0e10cSrcweir                     }
946cdf0e10cSrcweir 
947cdf0e10cSrcweir                     if ( bOK )
948cdf0e10cSrcweir                     {
949cdf0e10cSrcweir                         Rectangle   aDrawRect( pObj->GetLogicRect() );
950cdf0e10cSrcweir 
951cdf0e10cSrcweir                         pUndoGroup->AddAction( mpDoc->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
952cdf0e10cSrcweir                         pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ),
953cdf0e10cSrcweir                                                         Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) );
954cdf0e10cSrcweir                     }
955cdf0e10cSrcweir                 }
956cdf0e10cSrcweir             }
957cdf0e10cSrcweir             else if( pObj->GetObjIdentifier() == OBJ_GRAF )
958cdf0e10cSrcweir             {
959cdf0e10cSrcweir                 const MapMode   aMap100( MAP_100TH_MM );
960cdf0e10cSrcweir                 Size            aSize;
961cdf0e10cSrcweir 
962cdf0e10cSrcweir                 if ( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
963cdf0e10cSrcweir                     aSize = Application::GetDefaultDevice()->PixelToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(), aMap100 );
964cdf0e10cSrcweir                 else
965cdf0e10cSrcweir                 {
966cdf0e10cSrcweir                     aSize = OutputDevice::LogicToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(),
967cdf0e10cSrcweir                                                         static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode(),
968cdf0e10cSrcweir                                                         aMap100 );
969cdf0e10cSrcweir                 }
970cdf0e10cSrcweir 
971cdf0e10cSrcweir                 pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) );
972cdf0e10cSrcweir                 Rectangle aRect( pObj->GetLogicRect() );
973cdf0e10cSrcweir                 aRect.SetSize( aSize );
974cdf0e10cSrcweir                 pObj->SetLogicRect( aRect );
975cdf0e10cSrcweir 
976cdf0e10cSrcweir                 bOK = sal_True;
977cdf0e10cSrcweir             }
978cdf0e10cSrcweir         }
979cdf0e10cSrcweir     }
980cdf0e10cSrcweir 
981cdf0e10cSrcweir     if( bOK )
982cdf0e10cSrcweir     {
983cdf0e10cSrcweir         pUndoGroup->SetComment( String(SdResId(STR_UNDO_ORIGINALSIZE)) );
984cdf0e10cSrcweir         mpDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
985cdf0e10cSrcweir     }
986cdf0e10cSrcweir     else
987cdf0e10cSrcweir         delete pUndoGroup;
988cdf0e10cSrcweir }
989cdf0e10cSrcweir 
990cdf0e10cSrcweir /*************************************************************************
991cdf0e10cSrcweir |*
992cdf0e10cSrcweir |* OLE-Obj am Client connecten
993cdf0e10cSrcweir |*
994cdf0e10cSrcweir \************************************************************************/
995cdf0e10cSrcweir 
DoConnect(SdrOle2Obj * pObj)996cdf0e10cSrcweir void View::DoConnect(SdrOle2Obj* pObj)
997cdf0e10cSrcweir {
998cdf0e10cSrcweir     if (mpViewSh)
999cdf0e10cSrcweir     {
1000cdf0e10cSrcweir         uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
1001cdf0e10cSrcweir         if( xObj.is() )
1002cdf0e10cSrcweir         {
1003cdf0e10cSrcweir             ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
1004cdf0e10cSrcweir             SfxInPlaceClient* pSdClient = mpViewSh-> GetViewShellBase().FindIPClient( xObj, pWindow );
1005cdf0e10cSrcweir             if ( !pSdClient )
1006cdf0e10cSrcweir             {
1007cdf0e10cSrcweir                 pSdClient = new Client(pObj, mpViewSh, pWindow);
1008cdf0e10cSrcweir                 Rectangle aRect = pObj->GetLogicRect();
1009cdf0e10cSrcweir                 {
1010cdf0e10cSrcweir                     // TODO/LEAN: working with visual area can switch object to running state
1011cdf0e10cSrcweir                     Size aDrawSize = aRect.GetSize();
1012cdf0e10cSrcweir                     awt::Size aSz;
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir                     MapMode aMapMode( mpDoc->GetScaleUnit() );
1015cdf0e10cSrcweir                     Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir                     Fraction aScaleWidth (aDrawSize.Width(),  aObjAreaSize.Width() );
1018cdf0e10cSrcweir                     Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
1019cdf0e10cSrcweir                     aScaleWidth.ReduceInaccurate(10);       // kompatibel zum SdrOle2Obj
1020cdf0e10cSrcweir                     aScaleHeight.ReduceInaccurate(10);
1021cdf0e10cSrcweir                     pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir                     // sichtbarer Ausschnitt wird nur inplace veraendert!
1024cdf0e10cSrcweir                     // the object area must be set after the scaling, since it triggers resize
1025cdf0e10cSrcweir                     aRect.SetSize(aObjAreaSize);
1026cdf0e10cSrcweir                     pSdClient->SetObjArea(aRect);
1027cdf0e10cSrcweir                 }
1028cdf0e10cSrcweir             }
1029cdf0e10cSrcweir         }
1030cdf0e10cSrcweir     }
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir /*************************************************************************
1034cdf0e10cSrcweir |*
1035cdf0e10cSrcweir |*
1036cdf0e10cSrcweir |*
1037cdf0e10cSrcweir \************************************************************************/
1038cdf0e10cSrcweir 
IsMorphingAllowed() const1039cdf0e10cSrcweir sal_Bool View::IsMorphingAllowed() const
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir     const SdrMarkList&  rMarkList = GetMarkedObjectList();
1042cdf0e10cSrcweir     sal_Bool                bRet = sal_False;
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir     if ( rMarkList.GetMarkCount() == 2 )
1045cdf0e10cSrcweir     {
1046cdf0e10cSrcweir         const SdrObject*    pObj1 = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1047cdf0e10cSrcweir         const SdrObject*    pObj2 = rMarkList.GetMark( 1 )->GetMarkedSdrObj();
1048cdf0e10cSrcweir         const sal_uInt16        nKind1 = pObj1->GetObjIdentifier();
1049cdf0e10cSrcweir         const sal_uInt16        nKind2 = pObj2->GetObjIdentifier();
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir         if ( ( nKind1 != OBJ_TEXT && nKind2 != OBJ_TEXT ) &&
1052cdf0e10cSrcweir              ( nKind1 != OBJ_TITLETEXT && nKind2 != OBJ_TITLETEXT ) &&
1053cdf0e10cSrcweir              ( nKind1 != OBJ_OUTLINETEXT && nKind2 != OBJ_OUTLINETEXT ) &&
1054cdf0e10cSrcweir              ( nKind1 != OBJ_GRUP && nKind2 != OBJ_GRUP ) &&
1055cdf0e10cSrcweir              ( nKind1 != OBJ_LINE && nKind2 != OBJ_LINE ) &&
1056cdf0e10cSrcweir              ( nKind1 != OBJ_PLIN && nKind2 != OBJ_PLIN ) &&
1057cdf0e10cSrcweir              ( nKind1 != OBJ_PATHLINE && nKind2 != OBJ_PATHLINE ) &&
1058cdf0e10cSrcweir              ( nKind1 != OBJ_FREELINE && nKind2 != OBJ_FREELINE ) &&
1059cdf0e10cSrcweir              ( nKind1 != OBJ_PATHPLIN && nKind2 != OBJ_PATHPLIN ) &&
1060cdf0e10cSrcweir              ( nKind1 != OBJ_MEASURE && nKind2 != OBJ_MEASURE ) &&
1061cdf0e10cSrcweir              ( nKind1 != OBJ_EDGE && nKind2 != OBJ_EDGE ) &&
1062cdf0e10cSrcweir              ( nKind1 != OBJ_GRAF && nKind2 != OBJ_GRAF ) &&
1063cdf0e10cSrcweir              ( nKind1 != OBJ_OLE2 && nKind2 != OBJ_OLE2 ) &&
1064cdf0e10cSrcweir              ( nKind1 != OBJ_CAPTION && nKind2 !=  OBJ_CAPTION ) &&
1065cdf0e10cSrcweir              !pObj1->ISA( E3dObject) && !pObj2->ISA( E3dObject) )
1066cdf0e10cSrcweir         {
1067cdf0e10cSrcweir             SfxItemSet      aSet1( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
1068cdf0e10cSrcweir             SfxItemSet      aSet2( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir             aSet1.Put(pObj1->GetMergedItemSet());
1071cdf0e10cSrcweir             aSet2.Put(pObj2->GetMergedItemSet());
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir             const XFillStyle    eFillStyle1 = ( (const XFillStyleItem&) aSet1.Get( XATTR_FILLSTYLE ) ).GetValue();
1074cdf0e10cSrcweir             const XFillStyle    eFillStyle2 = ( (const XFillStyleItem&) aSet2.Get( XATTR_FILLSTYLE ) ).GetValue();
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir             if( ( eFillStyle1 == XFILL_NONE || eFillStyle1 == XFILL_SOLID ) &&
1077cdf0e10cSrcweir                 ( eFillStyle2 == XFILL_NONE || eFillStyle2 == XFILL_SOLID ) )
1078cdf0e10cSrcweir                 bRet = sal_True;
1079cdf0e10cSrcweir         }
1080cdf0e10cSrcweir     }
1081cdf0e10cSrcweir 
1082cdf0e10cSrcweir     return bRet;
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir 
1085cdf0e10cSrcweir /*************************************************************************
1086cdf0e10cSrcweir |*
1087cdf0e10cSrcweir |*
1088cdf0e10cSrcweir |*
1089cdf0e10cSrcweir \************************************************************************/
1090cdf0e10cSrcweir 
IsVectorizeAllowed() const1091cdf0e10cSrcweir sal_Bool View::IsVectorizeAllowed() const
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir     const SdrMarkList&  rMarkList = GetMarkedObjectList();
1094cdf0e10cSrcweir     sal_Bool                bRet = sal_False;
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir     if( rMarkList.GetMarkCount() == 1 )
1097cdf0e10cSrcweir     {
1098ddde725dSArmin Le Grand         const SdrGrafObj* pObj = dynamic_cast< const SdrGrafObj* >(rMarkList.GetMark( 0 )->GetMarkedSdrObj());
1099cdf0e10cSrcweir 
1100ddde725dSArmin Le Grand         if(pObj)
1101ddde725dSArmin Le Grand         {
1102ddde725dSArmin Le Grand             if(GRAPHIC_BITMAP == pObj->GetGraphicType() && !pObj->isEmbeddedSvg())
1103ddde725dSArmin Le Grand             {
1104cdf0e10cSrcweir                 bRet = sal_True;
1105cdf0e10cSrcweir             }
1106ddde725dSArmin Le Grand         }
1107ddde725dSArmin Le Grand     }
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir     return bRet;
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir 
onAccessibilityOptionsChanged()1112cdf0e10cSrcweir void View::onAccessibilityOptionsChanged()
1113cdf0e10cSrcweir {
1114cdf0e10cSrcweir     if( mpViewSh )
1115cdf0e10cSrcweir     {
1116cdf0e10cSrcweir         ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
1117cdf0e10cSrcweir         if( pWindow )
1118cdf0e10cSrcweir         {
1119cdf0e10cSrcweir             const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir             sal_uInt16 nOutputSlot, nPreviewSlot;
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir             SvtAccessibilityOptions& aAccOptions = getAccessibilityOptions();
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir             if( mpViewSh->GetViewFrame() && mpViewSh->GetViewFrame()->GetDispatcher() )
1126cdf0e10cSrcweir             {
1127cdf0e10cSrcweir                 if( rStyleSettings.GetHighContrastMode() )
1128cdf0e10cSrcweir                 {
1129cdf0e10cSrcweir                     nOutputSlot = SID_OUTPUT_QUALITY_CONTRAST;
1130cdf0e10cSrcweir                 }
1131cdf0e10cSrcweir                 else
1132cdf0e10cSrcweir                 {
1133cdf0e10cSrcweir                     nOutputSlot = SID_OUTPUT_QUALITY_COLOR;
1134cdf0e10cSrcweir                 }
1135cdf0e10cSrcweir 
1136cdf0e10cSrcweir                 if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
1137cdf0e10cSrcweir                 {
1138cdf0e10cSrcweir                     nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
1139cdf0e10cSrcweir                 }
1140cdf0e10cSrcweir                 else
1141cdf0e10cSrcweir                 {
1142cdf0e10cSrcweir                     nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
1143cdf0e10cSrcweir                 }
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir                 mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nOutputSlot, SFX_CALLMODE_ASYNCHRON );
1146cdf0e10cSrcweir                 mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nPreviewSlot, SFX_CALLMODE_ASYNCHRON );
1147cdf0e10cSrcweir             }
1148cdf0e10cSrcweir 
1149cdf0e10cSrcweir             mpViewSh->Invalidate();
1150cdf0e10cSrcweir         }
1151cdf0e10cSrcweir     }
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir 
IMPL_LINK(View,OnParagraphInsertedHdl,::Outliner *,pOutliner)1154cdf0e10cSrcweir IMPL_LINK( View, OnParagraphInsertedHdl, ::Outliner *, pOutliner )
1155cdf0e10cSrcweir {
1156cdf0e10cSrcweir     Paragraph* pPara = pOutliner->GetHdlParagraph();
1157cdf0e10cSrcweir     SdrObject* pObj = GetTextEditObject();
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir     if( pPara && pObj )
1160cdf0e10cSrcweir     {
1161cdf0e10cSrcweir         SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
1162cdf0e10cSrcweir         if( pPage )
1163cdf0e10cSrcweir             pPage->onParagraphInserted( pOutliner, pPara, pObj );
1164cdf0e10cSrcweir     }
1165cdf0e10cSrcweir     return 0;
1166cdf0e10cSrcweir }
1167cdf0e10cSrcweir 
1168cdf0e10cSrcweir /*************************************************************************
1169cdf0e10cSrcweir |*
1170cdf0e10cSrcweir |* Handler fuer das Loeschen von Seiten (Absaetzen)
1171cdf0e10cSrcweir |*
1172cdf0e10cSrcweir \************************************************************************/
1173cdf0e10cSrcweir 
IMPL_LINK(View,OnParagraphRemovingHdl,::Outliner *,pOutliner)1174cdf0e10cSrcweir IMPL_LINK( View, OnParagraphRemovingHdl, ::Outliner *, pOutliner )
1175cdf0e10cSrcweir {
1176cdf0e10cSrcweir     Paragraph* pPara = pOutliner->GetHdlParagraph();
1177cdf0e10cSrcweir     SdrObject* pObj = GetTextEditObject();
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir     if( pPara && pObj )
1180cdf0e10cSrcweir     {
1181cdf0e10cSrcweir         SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
1182cdf0e10cSrcweir         if( pPage )
1183cdf0e10cSrcweir             pPage->onParagraphRemoving( pOutliner, pPara, pObj );
1184cdf0e10cSrcweir     }
1185cdf0e10cSrcweir     return 0;
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir 
isRecordingUndo() const1188cdf0e10cSrcweir bool View::isRecordingUndo() const
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir     if( mpDoc && mpDoc->IsUndoEnabled() )
1191cdf0e10cSrcweir     {
1192cdf0e10cSrcweir         sd::UndoManager* pUndoManager = mpDoc ? mpDoc->GetUndoManager() : 0;
1193cdf0e10cSrcweir         return pUndoManager && pUndoManager->IsInListAction();
1194cdf0e10cSrcweir     }
1195cdf0e10cSrcweir     else
1196cdf0e10cSrcweir     {
1197cdf0e10cSrcweir         return false;
1198cdf0e10cSrcweir     }
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir 
AddCustomHdl()1201cdf0e10cSrcweir void View::AddCustomHdl()
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir     maSmartTags.addCustomHandles( aHdl );
1204cdf0e10cSrcweir }
1205cdf0e10cSrcweir 
updateHandles()1206cdf0e10cSrcweir void View::updateHandles()
1207cdf0e10cSrcweir {
1208cdf0e10cSrcweir     AdjustMarkHdl();
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir 
GetContext() const1211cdf0e10cSrcweir SdrViewContext View::GetContext() const
1212cdf0e10cSrcweir {
1213cdf0e10cSrcweir     SdrViewContext eContext = SDRCONTEXT_STANDARD;
1214cdf0e10cSrcweir     if( maSmartTags.getContext( eContext ) )
1215cdf0e10cSrcweir         return eContext;
1216cdf0e10cSrcweir     else
1217cdf0e10cSrcweir         return FmFormView::GetContext();
1218cdf0e10cSrcweir }
1219cdf0e10cSrcweir 
HasMarkablePoints() const1220cdf0e10cSrcweir sal_Bool View::HasMarkablePoints() const
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir     if( maSmartTags.HasMarkablePoints() )
1223cdf0e10cSrcweir         return true;
1224cdf0e10cSrcweir     else
1225cdf0e10cSrcweir         return FmFormView::HasMarkablePoints();
1226cdf0e10cSrcweir }
1227cdf0e10cSrcweir 
GetMarkablePointCount() const1228cdf0e10cSrcweir sal_uLong View::GetMarkablePointCount() const
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir     sal_uLong nCount = FmFormView::GetMarkablePointCount();
1231cdf0e10cSrcweir     nCount += maSmartTags.GetMarkablePointCount();
1232cdf0e10cSrcweir     return nCount;
1233cdf0e10cSrcweir }
1234cdf0e10cSrcweir 
HasMarkedPoints() const1235cdf0e10cSrcweir sal_Bool View::HasMarkedPoints() const
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir     if( maSmartTags.HasMarkedPoints() )
1238cdf0e10cSrcweir         return true;
1239cdf0e10cSrcweir     else
1240cdf0e10cSrcweir         return FmFormView::HasMarkedPoints();
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir 
GetMarkedPointCount() const1243cdf0e10cSrcweir sal_uLong View::GetMarkedPointCount() const
1244cdf0e10cSrcweir {
1245cdf0e10cSrcweir     sal_uLong nCount = FmFormView::GetMarkedPointCount();
1246cdf0e10cSrcweir     nCount += maSmartTags.GetMarkedPointCount();
1247cdf0e10cSrcweir     return nCount;
1248cdf0e10cSrcweir }
1249cdf0e10cSrcweir 
IsPointMarkable(const SdrHdl & rHdl) const1250cdf0e10cSrcweir sal_Bool View::IsPointMarkable(const SdrHdl& rHdl) const
1251cdf0e10cSrcweir {
1252cdf0e10cSrcweir     if( maSmartTags.IsPointMarkable( rHdl ) )
1253cdf0e10cSrcweir         return true;
1254cdf0e10cSrcweir     else
1255cdf0e10cSrcweir         return FmFormView::IsPointMarkable( rHdl );
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir 
MarkPoint(SdrHdl & rHdl,sal_Bool bUnmark)1258cdf0e10cSrcweir sal_Bool View::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark )
1259cdf0e10cSrcweir {
1260cdf0e10cSrcweir     if( maSmartTags.MarkPoint( rHdl, bUnmark ) )
1261cdf0e10cSrcweir         return true;
1262cdf0e10cSrcweir     else
1263cdf0e10cSrcweir         return FmFormView::MarkPoint( rHdl, bUnmark );
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir 
MarkPoints(const Rectangle * pRect,sal_Bool bUnmark)1266cdf0e10cSrcweir sal_Bool View::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark)
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir     if( maSmartTags.MarkPoints( pRect, bUnmark ) )
1269cdf0e10cSrcweir         return true;
1270cdf0e10cSrcweir     else
1271cdf0e10cSrcweir         return FmFormView::MarkPoints( pRect, bUnmark );
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir 
CheckPossibilities()1274cdf0e10cSrcweir void View::CheckPossibilities()
1275cdf0e10cSrcweir {
1276cdf0e10cSrcweir     FmFormView::CheckPossibilities();
1277cdf0e10cSrcweir     maSmartTags.CheckPossibilities();
1278cdf0e10cSrcweir }
1279cdf0e10cSrcweir 
OnBeginPasteOrDrop(PasteOrDropInfos *)1280cdf0e10cSrcweir void View::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
1281cdf0e10cSrcweir {
1282cdf0e10cSrcweir }
1283cdf0e10cSrcweir 
1284cdf0e10cSrcweir /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
1285cdf0e10cSrcweir     get the correct style sheet. */
OnEndPasteOrDrop(PasteOrDropInfos * pInfos)1286cdf0e10cSrcweir void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir     SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetTextEditObject() );
1289cdf0e10cSrcweir     SdrOutliner* pOutliner = GetTextEditOutliner();
1290cdf0e10cSrcweir     if( pOutliner && pTextObj && pTextObj->GetPage() )
1291cdf0e10cSrcweir     {
1292cdf0e10cSrcweir         SdPage* pPage = static_cast< SdPage* >( pTextObj->GetPage() );
1293cdf0e10cSrcweir 
1294cdf0e10cSrcweir         SfxStyleSheet* pStyleSheet = 0;
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir         const PresObjKind eKind = pPage->GetPresObjKind(pTextObj);
1297cdf0e10cSrcweir         if( eKind != PRESOBJ_NONE )
1298cdf0e10cSrcweir             pStyleSheet = pPage->GetStyleSheetForPresObj(eKind);
1299cdf0e10cSrcweir         else
1300cdf0e10cSrcweir             pStyleSheet = pTextObj->GetStyleSheet();
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir         if( eKind == PRESOBJ_OUTLINE )
1303cdf0e10cSrcweir         {
1304cdf0e10cSrcweir             // for outline shapes, set the correct outline style sheet for each
1305cdf0e10cSrcweir             // new paragraph, depending on the paragraph depth
1306cdf0e10cSrcweir             SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
1307cdf0e10cSrcweir 
1308cdf0e10cSrcweir             for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1309cdf0e10cSrcweir             {
1310cdf0e10cSrcweir                 sal_Int16 nDepth = pOutliner->GetDepth( nPara );
1311cdf0e10cSrcweir 
1312cdf0e10cSrcweir                 SfxStyleSheet* pStyle = 0;
1313cdf0e10cSrcweir                 if( nDepth > 0 )
1314cdf0e10cSrcweir                 {
1315cdf0e10cSrcweir                     String aStyleSheetName( pStyleSheet->GetName() );
1316cdf0e10cSrcweir                     aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
1317cdf0e10cSrcweir                     aStyleSheetName += String::CreateFromInt32( nDepth );
1318cdf0e10cSrcweir                     pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
1319cdf0e10cSrcweir                     DBG_ASSERT( pStyle, "sd::View::OnEndPasteOrDrop(), Style not found!" );
1320cdf0e10cSrcweir                 }
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir                 if( !pStyle )
1323cdf0e10cSrcweir                     pStyle = pStyleSheet;
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir                 pOutliner->SetStyleSheet( nPara, pStyle );
1326cdf0e10cSrcweir             }
1327cdf0e10cSrcweir         }
1328cdf0e10cSrcweir         else
1329cdf0e10cSrcweir         {
1330cdf0e10cSrcweir             // just put the object style on each new paragraph
1331cdf0e10cSrcweir             for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
1332cdf0e10cSrcweir             {
1333cdf0e10cSrcweir                 pOutliner->SetStyleSheet( nPara, pStyleSheet );
1334cdf0e10cSrcweir             }
1335cdf0e10cSrcweir         }
1336cdf0e10cSrcweir     }
1337cdf0e10cSrcweir }
1338cdf0e10cSrcweir 
ShouldToggleOn(const bool bBulletOnOffMode,const bool bNormalBullet)1339*af89ca6eSOliver-Rainer Wittmann bool View::ShouldToggleOn(
1340*af89ca6eSOliver-Rainer Wittmann     const bool bBulletOnOffMode,
1341*af89ca6eSOliver-Rainer Wittmann     const bool bNormalBullet)
1342766ce4d0SZheng Fan {
1343766ce4d0SZheng Fan     // If setting bullets/numbering by the dialog, always should toggle on.
1344766ce4d0SZheng Fan     if (!bBulletOnOffMode)
1345766ce4d0SZheng Fan         return sal_True;
1346766ce4d0SZheng Fan     SdrModel* pSdrModel = GetModel();
1347766ce4d0SZheng Fan     if (!pSdrModel)
1348766ce4d0SZheng Fan         return sal_False;
1349766ce4d0SZheng Fan 
1350766ce4d0SZheng Fan     sal_Bool bToggleOn = sal_False;
1351766ce4d0SZheng Fan     SdrOutliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrModel);
1352766ce4d0SZheng Fan     sal_uInt32 nMarkCount = GetMarkedObjectCount();
1353766ce4d0SZheng Fan     for (sal_uInt32 nIndex = 0; nIndex < nMarkCount && !bToggleOn; nIndex++)
1354766ce4d0SZheng Fan     {
1355766ce4d0SZheng Fan         SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex));
1356766ce4d0SZheng Fan         if (!pTextObj || pTextObj->IsTextEditActive())
1357766ce4d0SZheng Fan             continue;
1358766ce4d0SZheng Fan         if (pTextObj->ISA(SdrTableObj))
1359766ce4d0SZheng Fan         {
1360766ce4d0SZheng Fan             SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >(pTextObj);
1361766ce4d0SZheng Fan             if (!pTableObj)
1362766ce4d0SZheng Fan                 continue;
1363766ce4d0SZheng Fan             CellPos aStart, aEnd;
1364766ce4d0SZheng Fan             SvxTableController* pTableController = dynamic_cast< SvxTableController* >(getSelectionController().get());
1365766ce4d0SZheng Fan             if (pTableController)
1366766ce4d0SZheng Fan             {
1367766ce4d0SZheng Fan                 pTableController->getSelectedCells(aStart, aEnd);
1368766ce4d0SZheng Fan             }
1369766ce4d0SZheng Fan             else
1370766ce4d0SZheng Fan             {
1371766ce4d0SZheng Fan                 aStart = pTableObj->getFirstCell();
1372766ce4d0SZheng Fan                 aEnd = pTableObj->getLastCell();
1373766ce4d0SZheng Fan             }
1374766ce4d0SZheng Fan             sal_Int32 nColCount = pTableObj->getColumnCount();
1375766ce4d0SZheng Fan             for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow && !bToggleOn; nRow++)
1376766ce4d0SZheng Fan             {
1377766ce4d0SZheng Fan                 for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol && !bToggleOn; nCol++)
1378766ce4d0SZheng Fan                 {
1379766ce4d0SZheng Fan                     sal_Int32 nIndex = nRow * nColCount + nCol;
1380766ce4d0SZheng Fan                     SdrText* pText = pTableObj->getText(nIndex);
1381766ce4d0SZheng Fan                     if (!pText || !pText->GetOutlinerParaObject())
1382766ce4d0SZheng Fan                         continue;
1383766ce4d0SZheng Fan                     pOutliner->SetText(*(pText->GetOutlinerParaObject()));
1384766ce4d0SZheng Fan                     sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus();
1385766ce4d0SZheng Fan                     bToggleOn = ((bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1)) ? sal_True : bToggleOn;
1386766ce4d0SZheng Fan                     pOutliner->Clear();
1387766ce4d0SZheng Fan                 }
1388766ce4d0SZheng Fan             }
1389766ce4d0SZheng Fan         }
1390766ce4d0SZheng Fan         else
1391766ce4d0SZheng Fan         {
1392766ce4d0SZheng Fan             OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
1393766ce4d0SZheng Fan             if (!pParaObj)
1394766ce4d0SZheng Fan                 continue;
1395766ce4d0SZheng Fan             pOutliner->SetText(*pParaObj);
1396766ce4d0SZheng Fan             sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus();
1397766ce4d0SZheng Fan             bToggleOn = ((bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1)) ? sal_True : bToggleOn;
1398766ce4d0SZheng Fan             pOutliner->Clear();
1399766ce4d0SZheng Fan         }
1400766ce4d0SZheng Fan     }
1401766ce4d0SZheng Fan     delete pOutliner;
1402766ce4d0SZheng Fan     return bToggleOn;
1403766ce4d0SZheng Fan }
1404766ce4d0SZheng Fan 
ChangeMarkedObjectsBulletsNumbering(const bool bToggle,const bool bHandleBullets,const SvxNumRule * pNumRule,const bool bSwitchOff)1405*af89ca6eSOliver-Rainer Wittmann void View::ChangeMarkedObjectsBulletsNumbering(
1406*af89ca6eSOliver-Rainer Wittmann     const bool bToggle,
1407*af89ca6eSOliver-Rainer Wittmann     const bool bHandleBullets,
1408*af89ca6eSOliver-Rainer Wittmann     const SvxNumRule* pNumRule,
1409*af89ca6eSOliver-Rainer Wittmann     const bool bSwitchOff )
1410766ce4d0SZheng Fan {
1411766ce4d0SZheng Fan     SdrModel* pSdrModel = GetModel();
1412766ce4d0SZheng Fan     Window* pWindow = dynamic_cast< Window* >(GetFirstOutputDevice());
1413766ce4d0SZheng Fan     if (!pSdrModel || !pWindow)
1414766ce4d0SZheng Fan         return;
1415766ce4d0SZheng Fan 
1416*af89ca6eSOliver-Rainer Wittmann     const bool bUndoEnabled = pSdrModel->IsUndoEnabled();
1417*af89ca6eSOliver-Rainer Wittmann     SdrUndoGroup* pUndoGroup = bUndoEnabled ? new SdrUndoGroup(*pSdrModel) : 0;
1418*af89ca6eSOliver-Rainer Wittmann 
1419*af89ca6eSOliver-Rainer Wittmann     const bool bToggleOn =
1420*af89ca6eSOliver-Rainer Wittmann         bSwitchOff
1421*af89ca6eSOliver-Rainer Wittmann         ? false
1422*af89ca6eSOliver-Rainer Wittmann         : ShouldToggleOn( bToggle, bHandleBullets );
1423*af89ca6eSOliver-Rainer Wittmann 
1424766ce4d0SZheng Fan     SdrOutliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrModel);
1425766ce4d0SZheng Fan     OutlinerView* pOutlinerView = new OutlinerView(pOutliner, pWindow);
1426766ce4d0SZheng Fan 
1427*af89ca6eSOliver-Rainer Wittmann     const sal_uInt32 nMarkCount = GetMarkedObjectCount();
1428766ce4d0SZheng Fan     for (sal_uInt32 nIndex = 0; nIndex < nMarkCount; nIndex++)
1429766ce4d0SZheng Fan     {
1430766ce4d0SZheng Fan         SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex));
1431766ce4d0SZheng Fan         if (!pTextObj || pTextObj->IsTextEditActive())
1432766ce4d0SZheng Fan             continue;
1433766ce4d0SZheng Fan         if (pTextObj->ISA(SdrTableObj))
1434766ce4d0SZheng Fan         {
1435766ce4d0SZheng Fan             SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >(pTextObj);
1436766ce4d0SZheng Fan             if (!pTableObj)
1437766ce4d0SZheng Fan                 continue;
1438766ce4d0SZheng Fan             CellPos aStart, aEnd;
1439766ce4d0SZheng Fan             SvxTableController* pTableController = dynamic_cast< SvxTableController* >(getSelectionController().get());
1440766ce4d0SZheng Fan             if (pTableController)
1441766ce4d0SZheng Fan             {
1442766ce4d0SZheng Fan                 pTableController->getSelectedCells(aStart, aEnd);
1443766ce4d0SZheng Fan             }
1444766ce4d0SZheng Fan             else
1445766ce4d0SZheng Fan             {
1446766ce4d0SZheng Fan                 aStart = pTableObj->getFirstCell();
1447766ce4d0SZheng Fan                 aEnd = pTableObj->getLastCell();
1448766ce4d0SZheng Fan             }
1449766ce4d0SZheng Fan             sal_Int32 nColCount = pTableObj->getColumnCount();
1450766ce4d0SZheng Fan             for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
1451766ce4d0SZheng Fan             {
1452766ce4d0SZheng Fan                 for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
1453766ce4d0SZheng Fan                 {
1454766ce4d0SZheng Fan                     sal_Int32 nIndex = nRow * nColCount + nCol;
1455766ce4d0SZheng Fan                     SdrText* pText = pTableObj->getText(nIndex);
1456766ce4d0SZheng Fan                     if (!pText || !pText->GetOutlinerParaObject())
1457766ce4d0SZheng Fan                         continue;
1458766ce4d0SZheng Fan 
1459766ce4d0SZheng Fan                     pOutliner->SetText(*(pText->GetOutlinerParaObject()));
1460766ce4d0SZheng Fan                     if (bUndoEnabled)
1461766ce4d0SZheng Fan                     {
1462766ce4d0SZheng Fan                         SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nIndex));
1463766ce4d0SZheng Fan                         pUndoGroup->AddAction(pTxtUndo);
1464766ce4d0SZheng Fan                     }
1465*af89ca6eSOliver-Rainer Wittmann                     if ( !bToggleOn )
1466*af89ca6eSOliver-Rainer Wittmann                     {
1467*af89ca6eSOliver-Rainer Wittmann                         pOutlinerView->SwitchOffBulletsNumbering();
1468*af89ca6eSOliver-Rainer Wittmann                     }
1469*af89ca6eSOliver-Rainer Wittmann                     else
1470*af89ca6eSOliver-Rainer Wittmann                     {
1471*af89ca6eSOliver-Rainer Wittmann                         pOutlinerView->ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle );
1472*af89ca6eSOliver-Rainer Wittmann                     }
1473766ce4d0SZheng Fan                     sal_uInt32 nParaCount = pOutliner->GetParagraphCount();
1474766ce4d0SZheng Fan                     pText->SetOutlinerParaObject(pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount));
1475766ce4d0SZheng Fan                     pOutliner->Clear();
1476766ce4d0SZheng Fan                 }
1477766ce4d0SZheng Fan             }
1478766ce4d0SZheng Fan             // Broadcast the object change event.
1479766ce4d0SZheng Fan             if (!pTextObj->AdjustTextFrameWidthAndHeight())
1480766ce4d0SZheng Fan             {
1481766ce4d0SZheng Fan                 pTextObj->SetChanged();
1482766ce4d0SZheng Fan                 pTextObj->BroadcastObjectChange();
1483766ce4d0SZheng Fan             }
1484766ce4d0SZheng Fan         }
1485766ce4d0SZheng Fan         else
1486766ce4d0SZheng Fan         {
1487766ce4d0SZheng Fan             OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
1488766ce4d0SZheng Fan             if (!pParaObj)
1489766ce4d0SZheng Fan                 continue;
1490766ce4d0SZheng Fan             pOutliner->SetText(*pParaObj);
1491766ce4d0SZheng Fan             if (bUndoEnabled)
1492766ce4d0SZheng Fan             {
1493766ce4d0SZheng Fan                 SdrUndoObjSetText* pTxtUndo = dynamic_cast< SdrUndoObjSetText* >(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, 0));
1494766ce4d0SZheng Fan                 pUndoGroup->AddAction(pTxtUndo);
1495766ce4d0SZheng Fan             }
1496*af89ca6eSOliver-Rainer Wittmann             if ( !bToggleOn )
1497*af89ca6eSOliver-Rainer Wittmann             {
1498*af89ca6eSOliver-Rainer Wittmann                 pOutlinerView->SwitchOffBulletsNumbering();
1499*af89ca6eSOliver-Rainer Wittmann             }
1500*af89ca6eSOliver-Rainer Wittmann             else
1501*af89ca6eSOliver-Rainer Wittmann             {
1502*af89ca6eSOliver-Rainer Wittmann                 pOutlinerView->ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle );
1503*af89ca6eSOliver-Rainer Wittmann             }
1504766ce4d0SZheng Fan             sal_uInt32 nParaCount = pOutliner->GetParagraphCount();
1505766ce4d0SZheng Fan             pTextObj->SetOutlinerParaObject(pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount));
1506766ce4d0SZheng Fan             pOutliner->Clear();
1507766ce4d0SZheng Fan         }
1508766ce4d0SZheng Fan     }
1509766ce4d0SZheng Fan 
1510*af89ca6eSOliver-Rainer Wittmann     if ( bUndoEnabled && pUndoGroup->GetActionCount() > 0 )
1511766ce4d0SZheng Fan     {
1512766ce4d0SZheng Fan         pSdrModel->BegUndo();
1513766ce4d0SZheng Fan         pSdrModel->AddUndo(pUndoGroup);
1514766ce4d0SZheng Fan         pSdrModel->EndUndo();
1515766ce4d0SZheng Fan     }
1516*af89ca6eSOliver-Rainer Wittmann 
1517766ce4d0SZheng Fan     delete pOutliner;
1518766ce4d0SZheng Fan     delete pOutlinerView;
1519766ce4d0SZheng Fan }
1520766ce4d0SZheng Fan 
1521cdf0e10cSrcweir } // end of namespace sd
1522