1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include "hintids.hxx"
27cdf0e10cSrcweir #include <svx/svdtrans.hxx>
28cdf0e10cSrcweir #include <editeng/protitem.hxx>
29cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
30cdf0e10cSrcweir #include <svx/svdpage.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir
33cdf0e10cSrcweir #include <fmtclds.hxx>
34cdf0e10cSrcweir #include <fmtornt.hxx>
35cdf0e10cSrcweir #include <fmtfsize.hxx>
36cdf0e10cSrcweir #include <fmturl.hxx>
37cdf0e10cSrcweir #include "viewsh.hxx"
38cdf0e10cSrcweir #include "viewimp.hxx"
39cdf0e10cSrcweir #include "cntfrm.hxx"
40cdf0e10cSrcweir #include "frmatr.hxx"
41cdf0e10cSrcweir #include "doc.hxx"
42cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
43cdf0e10cSrcweir #include "dview.hxx"
44cdf0e10cSrcweir #include "dflyobj.hxx"
45cdf0e10cSrcweir #include "flyfrm.hxx"
46cdf0e10cSrcweir #include "frmfmt.hxx"
47cdf0e10cSrcweir #include "viewopt.hxx"
48cdf0e10cSrcweir #include "frmtool.hxx"
49cdf0e10cSrcweir #include "flyfrms.hxx"
50cdf0e10cSrcweir #include "ndnotxt.hxx"
51cdf0e10cSrcweir #include "grfatr.hxx"
52cdf0e10cSrcweir #include "pagefrm.hxx"
53cdf0e10cSrcweir #include "rootfrm.hxx"
54cdf0e10cSrcweir
55cdf0e10cSrcweir
56cdf0e10cSrcweir using namespace ::com::sun::star;
57cdf0e10cSrcweir
58cdf0e10cSrcweir
59cdf0e10cSrcweir // --> OD 2004-11-22 #117958#
60cdf0e10cSrcweir #include <svx/sdr/properties/defaultproperties.hxx>
61cdf0e10cSrcweir // <--
62cdf0e10cSrcweir #include <basegfx/range/b2drange.hxx>
63cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
64cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
65cdf0e10cSrcweir
66cdf0e10cSrcweir // AW: For VCOfDrawVirtObj and stuff
67cdf0e10cSrcweir #include <svx/sdr/contact/viewcontactofvirtobj.hxx>
68cdf0e10cSrcweir #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
69cdf0e10cSrcweir #include <sw_primitivetypes2d.hxx>
70cdf0e10cSrcweir #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
71cdf0e10cSrcweir
72cdf0e10cSrcweir using namespace ::com::sun::star;
73cdf0e10cSrcweir
74cdf0e10cSrcweir static sal_Bool bInResize = sal_False;
75cdf0e10cSrcweir
76cdf0e10cSrcweir TYPEINIT1( SwFlyDrawObj, SdrObject )
77cdf0e10cSrcweir TYPEINIT1( SwVirtFlyDrawObj, SdrVirtObj )
78cdf0e10cSrcweir
79cdf0e10cSrcweir /*************************************************************************
80cdf0e10cSrcweir |*
81cdf0e10cSrcweir |* SwFlyDrawObj::Ctor
82cdf0e10cSrcweir |*
83cdf0e10cSrcweir |* Ersterstellung MA 18. Apr. 95
84cdf0e10cSrcweir |* Letzte Aenderung MA 28. May. 96
85cdf0e10cSrcweir |*
86cdf0e10cSrcweir *************************************************************************/
87cdf0e10cSrcweir
88cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
89cdf0e10cSrcweir
90cdf0e10cSrcweir namespace sdr
91cdf0e10cSrcweir {
92cdf0e10cSrcweir namespace contact
93cdf0e10cSrcweir {
94cdf0e10cSrcweir // #i95264# currently needed since createViewIndependentPrimitive2DSequence()
95cdf0e10cSrcweir // is called when RecalcBoundRect() is used. There should currently no VOCs being
96cdf0e10cSrcweir // constructed since it gets not visualized (instead the corresponding SwVirtFlyDrawObj's
97cdf0e10cSrcweir // referencing this one are visualized).
98cdf0e10cSrcweir class VCOfSwFlyDrawObj : public ViewContactOfSdrObj
99cdf0e10cSrcweir {
100cdf0e10cSrcweir protected:
101cdf0e10cSrcweir // This method is responsible for creating the graphical visualisation data
102cdf0e10cSrcweir // ONLY based on model data
103cdf0e10cSrcweir virtual drawinglayer::primitive2d::Primitive2DSequence createViewIndependentPrimitive2DSequence() const;
104cdf0e10cSrcweir
105cdf0e10cSrcweir public:
106cdf0e10cSrcweir // basic constructor, used from SdrObject.
VCOfSwFlyDrawObj(SwFlyDrawObj & rObj)107cdf0e10cSrcweir VCOfSwFlyDrawObj(SwFlyDrawObj& rObj)
108cdf0e10cSrcweir : ViewContactOfSdrObj(rObj)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir }
111cdf0e10cSrcweir virtual ~VCOfSwFlyDrawObj();
112cdf0e10cSrcweir };
113cdf0e10cSrcweir
createViewIndependentPrimitive2DSequence() const114cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence VCOfSwFlyDrawObj::createViewIndependentPrimitive2DSequence() const
115cdf0e10cSrcweir {
116cdf0e10cSrcweir // currently gets not visualized, return empty sequence
117cdf0e10cSrcweir return drawinglayer::primitive2d::Primitive2DSequence();
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
~VCOfSwFlyDrawObj()120cdf0e10cSrcweir VCOfSwFlyDrawObj::~VCOfSwFlyDrawObj()
121cdf0e10cSrcweir {
122cdf0e10cSrcweir }
123cdf0e10cSrcweir } // end of namespace contact
124cdf0e10cSrcweir } // end of namespace sdr
125cdf0e10cSrcweir
126cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////
127cdf0e10cSrcweir
CreateObjectSpecificProperties()128cdf0e10cSrcweir sdr::properties::BaseProperties* SwFlyDrawObj::CreateObjectSpecificProperties()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir // --> OD 2004-11-22 #117958# - create default properties
131cdf0e10cSrcweir return new sdr::properties::DefaultProperties(*this);
132cdf0e10cSrcweir // <--
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
CreateObjectSpecificViewContact()135cdf0e10cSrcweir sdr::contact::ViewContact* SwFlyDrawObj::CreateObjectSpecificViewContact()
136cdf0e10cSrcweir {
137cdf0e10cSrcweir // #i95264# needs an own VC since createViewIndependentPrimitive2DSequence()
138cdf0e10cSrcweir // is called when RecalcBoundRect() is used
139cdf0e10cSrcweir return new sdr::contact::VCOfSwFlyDrawObj(*this);
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
SwFlyDrawObj()142cdf0e10cSrcweir SwFlyDrawObj::SwFlyDrawObj()
143cdf0e10cSrcweir {
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
~SwFlyDrawObj()146cdf0e10cSrcweir SwFlyDrawObj::~SwFlyDrawObj()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir }
149cdf0e10cSrcweir
150cdf0e10cSrcweir /*************************************************************************
151cdf0e10cSrcweir |*
152cdf0e10cSrcweir |* SwFlyDrawObj::Factory-Methoden
153cdf0e10cSrcweir |*
154cdf0e10cSrcweir |* Ersterstellung MA 23. Feb. 95
155cdf0e10cSrcweir |* Letzte Aenderung MA 23. Feb. 95
156cdf0e10cSrcweir |*
157cdf0e10cSrcweir *************************************************************************/
158cdf0e10cSrcweir
GetObjInventor() const159cdf0e10cSrcweir sal_uInt32 __EXPORT SwFlyDrawObj::GetObjInventor() const
160cdf0e10cSrcweir {
161cdf0e10cSrcweir return SWGInventor;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir
GetObjIdentifier() const165cdf0e10cSrcweir sal_uInt16 __EXPORT SwFlyDrawObj::GetObjIdentifier() const
166cdf0e10cSrcweir {
167cdf0e10cSrcweir return SwFlyDrawObjIdentifier;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir
GetObjVersion() const171cdf0e10cSrcweir sal_uInt16 __EXPORT SwFlyDrawObj::GetObjVersion() const
172cdf0e10cSrcweir {
173cdf0e10cSrcweir return SwDrawFirst;
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir /*************************************************************************
177cdf0e10cSrcweir |*
178cdf0e10cSrcweir |* SwVirtFlyDrawObj::CToren, Dtor
179cdf0e10cSrcweir |*
180cdf0e10cSrcweir |* Ersterstellung MA 08. Dec. 94
181cdf0e10cSrcweir |* Letzte Aenderung MA 28. May. 96
182cdf0e10cSrcweir |*
183cdf0e10cSrcweir *************************************************************************/
184cdf0e10cSrcweir
185cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////
186cdf0e10cSrcweir // AW: Need own primitive to get the FlyFrame paint working
187cdf0e10cSrcweir
188cdf0e10cSrcweir namespace drawinglayer
189cdf0e10cSrcweir {
190cdf0e10cSrcweir namespace primitive2d
191cdf0e10cSrcweir {
192cdf0e10cSrcweir class SwVirtFlyDrawObjPrimitive : public BufferedDecompositionPrimitive2D
193cdf0e10cSrcweir {
194cdf0e10cSrcweir private:
195cdf0e10cSrcweir const SwVirtFlyDrawObj& mrSwVirtFlyDrawObj;
196cdf0e10cSrcweir const basegfx::B2DRange maOuterRange;
197cdf0e10cSrcweir
198cdf0e10cSrcweir protected:
199cdf0e10cSrcweir // method which is to be used to implement the local decomposition of a 2D primitive
200cdf0e10cSrcweir virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
201cdf0e10cSrcweir
202cdf0e10cSrcweir public:
SwVirtFlyDrawObjPrimitive(const SwVirtFlyDrawObj & rSwVirtFlyDrawObj,const basegfx::B2DRange & rOuterRange)203cdf0e10cSrcweir SwVirtFlyDrawObjPrimitive(
204cdf0e10cSrcweir const SwVirtFlyDrawObj& rSwVirtFlyDrawObj,
205cdf0e10cSrcweir const basegfx::B2DRange &rOuterRange)
206cdf0e10cSrcweir : BufferedDecompositionPrimitive2D(),
207cdf0e10cSrcweir mrSwVirtFlyDrawObj(rSwVirtFlyDrawObj),
208cdf0e10cSrcweir maOuterRange(rOuterRange)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
212cdf0e10cSrcweir // compare operator
213cdf0e10cSrcweir virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
214cdf0e10cSrcweir
215cdf0e10cSrcweir // get range
216cdf0e10cSrcweir virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
217cdf0e10cSrcweir
218cdf0e10cSrcweir // overloaded to allow callbacks to wrap_DoPaintObject
219cdf0e10cSrcweir virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
220cdf0e10cSrcweir
221cdf0e10cSrcweir // data read access
getSwVirtFlyDrawObj() const222cdf0e10cSrcweir const SwVirtFlyDrawObj& getSwVirtFlyDrawObj() const { return mrSwVirtFlyDrawObj; }
getOuterRange() const223cdf0e10cSrcweir const basegfx::B2DRange& getOuterRange() const { return maOuterRange; }
224cdf0e10cSrcweir
225cdf0e10cSrcweir // provide unique ID
226cdf0e10cSrcweir DeclPrimitrive2DIDBlock()
227cdf0e10cSrcweir };
228cdf0e10cSrcweir } // end of namespace primitive2d
229cdf0e10cSrcweir } // end of namespace drawinglayer
230cdf0e10cSrcweir
231cdf0e10cSrcweir namespace drawinglayer
232cdf0e10cSrcweir {
233cdf0e10cSrcweir namespace primitive2d
234cdf0e10cSrcweir {
create2DDecomposition(const geometry::ViewInformation2D &) const235cdf0e10cSrcweir Primitive2DSequence SwVirtFlyDrawObjPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
236cdf0e10cSrcweir {
237cdf0e10cSrcweir Primitive2DSequence aRetval;
238cdf0e10cSrcweir
239cdf0e10cSrcweir if(!getOuterRange().isEmpty())
240cdf0e10cSrcweir {
241cdf0e10cSrcweir // currently this SW object has no primitive representation. As long as this is the case,
242cdf0e10cSrcweir // create invisible geometry to allow corfect HitTest and BoundRect calculations for the
243cdf0e10cSrcweir // object. Use a filled primitive to get 'inside' as default object hit. The special cases from
244cdf0e10cSrcweir // the old SwVirtFlyDrawObj::CheckHit implementation are handled now in SwDrawView::PickObj;
245cdf0e10cSrcweir // this removed the 'hack' to get a view from inside model data or to react on null-tolerance
246cdf0e10cSrcweir // as it was done in the old implementation
247cdf0e10cSrcweir const Primitive2DReference aHitTestReference(
248cdf0e10cSrcweir createHiddenGeometryPrimitives2D(
249cdf0e10cSrcweir true,
250cdf0e10cSrcweir getOuterRange()));
251cdf0e10cSrcweir
252cdf0e10cSrcweir aRetval = Primitive2DSequence(&aHitTestReference, 1);
253cdf0e10cSrcweir }
254cdf0e10cSrcweir
255cdf0e10cSrcweir return aRetval;
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
operator ==(const BasePrimitive2D & rPrimitive) const258cdf0e10cSrcweir bool SwVirtFlyDrawObjPrimitive::operator==(const BasePrimitive2D& rPrimitive) const
259cdf0e10cSrcweir {
260cdf0e10cSrcweir if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
261cdf0e10cSrcweir {
262cdf0e10cSrcweir const SwVirtFlyDrawObjPrimitive& rCompare = (SwVirtFlyDrawObjPrimitive&)rPrimitive;
263cdf0e10cSrcweir
264cdf0e10cSrcweir return (&getSwVirtFlyDrawObj() == &rCompare.getSwVirtFlyDrawObj()
265cdf0e10cSrcweir && getOuterRange() == rCompare.getOuterRange());
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268cdf0e10cSrcweir return false;
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
getB2DRange(const geometry::ViewInformation2D &) const271cdf0e10cSrcweir basegfx::B2DRange SwVirtFlyDrawObjPrimitive::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
272cdf0e10cSrcweir {
273cdf0e10cSrcweir return getOuterRange();
274cdf0e10cSrcweir }
275cdf0e10cSrcweir
get2DDecomposition(const geometry::ViewInformation2D & rViewInformation) const276cdf0e10cSrcweir Primitive2DSequence SwVirtFlyDrawObjPrimitive::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
277cdf0e10cSrcweir {
278cdf0e10cSrcweir // This is the callback to keep the FlyFrame painting in SW alive as long as it
279cdf0e10cSrcweir // is not changed to primitives. This is the method which will be called by the processors
280cdf0e10cSrcweir // when they do not know this primitive (and they do not). Inside wrap_DoPaintObject
281cdf0e10cSrcweir // there needs to be a test that paint is only done during SW repaints (see there).
282cdf0e10cSrcweir // Using this mechanism guarantees the correct Z-Order of the VirtualObject-based FlyFrames.
283cdf0e10cSrcweir getSwVirtFlyDrawObj().wrap_DoPaintObject();
284cdf0e10cSrcweir
285cdf0e10cSrcweir // call parent
286cdf0e10cSrcweir return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
287cdf0e10cSrcweir }
288cdf0e10cSrcweir
289cdf0e10cSrcweir // provide unique ID
290cdf0e10cSrcweir ImplPrimitrive2DIDBlock(SwVirtFlyDrawObjPrimitive, PRIMITIVE2D_ID_SWVIRTFLYDRAWOBJPRIMITIVE2D)
291cdf0e10cSrcweir
292cdf0e10cSrcweir } // end of namespace primitive2d
293cdf0e10cSrcweir } // end of namespace drawinglayer
294cdf0e10cSrcweir
295cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////
296cdf0e10cSrcweir // AW: own sdr::contact::ViewContact (VC) sdr::contact::ViewObjectContact (VOC) needed
297cdf0e10cSrcweir // since offset is defined different from SdrVirtObj's sdr::contact::ViewContactOfVirtObj.
298cdf0e10cSrcweir // For paint, that offset is used by setting at the OutputDevice; for primitives this is
299cdf0e10cSrcweir // not possible since we have no OutputDevice, but define the geometry itself.
300cdf0e10cSrcweir
301cdf0e10cSrcweir namespace sdr
302cdf0e10cSrcweir {
303cdf0e10cSrcweir namespace contact
304cdf0e10cSrcweir {
305cdf0e10cSrcweir class VCOfSwVirtFlyDrawObj : public ViewContactOfVirtObj
306cdf0e10cSrcweir {
307cdf0e10cSrcweir protected:
308cdf0e10cSrcweir // This method is responsible for creating the graphical visualisation data
309cdf0e10cSrcweir // ONLY based on model data
310cdf0e10cSrcweir virtual drawinglayer::primitive2d::Primitive2DSequence createViewIndependentPrimitive2DSequence() const;
311cdf0e10cSrcweir
312cdf0e10cSrcweir public:
313cdf0e10cSrcweir // basic constructor, used from SdrObject.
VCOfSwVirtFlyDrawObj(SwVirtFlyDrawObj & rObj)314cdf0e10cSrcweir VCOfSwVirtFlyDrawObj(SwVirtFlyDrawObj& rObj)
315cdf0e10cSrcweir : ViewContactOfVirtObj(rObj)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir }
318cdf0e10cSrcweir virtual ~VCOfSwVirtFlyDrawObj();
319cdf0e10cSrcweir
320cdf0e10cSrcweir // access to SwVirtFlyDrawObj
GetSwVirtFlyDrawObj() const321cdf0e10cSrcweir SwVirtFlyDrawObj& GetSwVirtFlyDrawObj() const
322cdf0e10cSrcweir {
323cdf0e10cSrcweir return (SwVirtFlyDrawObj&)mrObject;
324cdf0e10cSrcweir }
325cdf0e10cSrcweir };
326cdf0e10cSrcweir } // end of namespace contact
327cdf0e10cSrcweir } // end of namespace sdr
328cdf0e10cSrcweir
329cdf0e10cSrcweir namespace sdr
330cdf0e10cSrcweir {
331cdf0e10cSrcweir namespace contact
332cdf0e10cSrcweir {
createViewIndependentPrimitive2DSequence() const333cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence VCOfSwVirtFlyDrawObj::createViewIndependentPrimitive2DSequence() const
334cdf0e10cSrcweir {
335cdf0e10cSrcweir drawinglayer::primitive2d::Primitive2DSequence xRetval;
336cdf0e10cSrcweir const SdrObject& rReferencedObject = GetSwVirtFlyDrawObj().GetReferencedObj();
337cdf0e10cSrcweir
338cdf0e10cSrcweir if(rReferencedObject.ISA(SwFlyDrawObj))
339cdf0e10cSrcweir {
340cdf0e10cSrcweir // create an own specialized primitive which is used as repaint callpoint and HitTest
341cdf0e10cSrcweir // for HitTest processor (see primitive implementation above)
342cdf0e10cSrcweir const basegfx::B2DRange aOuterRange(GetSwVirtFlyDrawObj().getOuterBound());
343cdf0e10cSrcweir
344cdf0e10cSrcweir if(!aOuterRange.isEmpty())
345cdf0e10cSrcweir {
346cdf0e10cSrcweir const drawinglayer::primitive2d::Primitive2DReference xPrimitive(
347cdf0e10cSrcweir new drawinglayer::primitive2d::SwVirtFlyDrawObjPrimitive(
348cdf0e10cSrcweir GetSwVirtFlyDrawObj(),
349cdf0e10cSrcweir aOuterRange));
350cdf0e10cSrcweir
351cdf0e10cSrcweir xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xPrimitive, 1);
352cdf0e10cSrcweir }
353cdf0e10cSrcweir }
354cdf0e10cSrcweir
355cdf0e10cSrcweir return xRetval;
356cdf0e10cSrcweir }
357cdf0e10cSrcweir
~VCOfSwVirtFlyDrawObj()358cdf0e10cSrcweir VCOfSwVirtFlyDrawObj::~VCOfSwVirtFlyDrawObj()
359cdf0e10cSrcweir {
360cdf0e10cSrcweir }
361cdf0e10cSrcweir } // end of namespace contact
362cdf0e10cSrcweir } // end of namespace sdr
363cdf0e10cSrcweir
364cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////////////
365cdf0e10cSrcweir
getOuterBound() const366cdf0e10cSrcweir basegfx::B2DRange SwVirtFlyDrawObj::getOuterBound() const
367cdf0e10cSrcweir {
368cdf0e10cSrcweir basegfx::B2DRange aOuterRange;
369cdf0e10cSrcweir const SdrObject& rReferencedObject = GetReferencedObj();
370cdf0e10cSrcweir
371cdf0e10cSrcweir if(rReferencedObject.ISA(SwFlyDrawObj))
372cdf0e10cSrcweir {
373cdf0e10cSrcweir const SwFlyFrm* pFlyFrame = GetFlyFrm();
374cdf0e10cSrcweir
375cdf0e10cSrcweir if(pFlyFrame)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir const Rectangle aOuterRectangle(pFlyFrame->Frm().Pos(), pFlyFrame->Frm().SSize());
378cdf0e10cSrcweir
379cdf0e10cSrcweir if(!aOuterRectangle.IsEmpty()
380cdf0e10cSrcweir && RECT_EMPTY != aOuterRectangle.Right()
381cdf0e10cSrcweir && RECT_EMPTY != aOuterRectangle.Bottom())
382cdf0e10cSrcweir {
383cdf0e10cSrcweir aOuterRange.expand(basegfx::B2DTuple(aOuterRectangle.Left(), aOuterRectangle.Top()));
384cdf0e10cSrcweir aOuterRange.expand(basegfx::B2DTuple(aOuterRectangle.Right(), aOuterRectangle.Bottom()));
385cdf0e10cSrcweir }
386cdf0e10cSrcweir }
387cdf0e10cSrcweir }
388cdf0e10cSrcweir
389cdf0e10cSrcweir return aOuterRange;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir
getInnerBound() const392cdf0e10cSrcweir basegfx::B2DRange SwVirtFlyDrawObj::getInnerBound() const
393cdf0e10cSrcweir {
394cdf0e10cSrcweir basegfx::B2DRange aInnerRange;
395cdf0e10cSrcweir const SdrObject& rReferencedObject = GetReferencedObj();
396cdf0e10cSrcweir
397cdf0e10cSrcweir if(rReferencedObject.ISA(SwFlyDrawObj))
398cdf0e10cSrcweir {
399cdf0e10cSrcweir const SwFlyFrm* pFlyFrame = GetFlyFrm();
400cdf0e10cSrcweir
401cdf0e10cSrcweir if(pFlyFrame)
402cdf0e10cSrcweir {
403cdf0e10cSrcweir const Rectangle aInnerRectangle(pFlyFrame->Frm().Pos() + pFlyFrame->Prt().Pos(), pFlyFrame->Prt().SSize());
404cdf0e10cSrcweir
405cdf0e10cSrcweir if(!aInnerRectangle.IsEmpty()
406cdf0e10cSrcweir && RECT_EMPTY != aInnerRectangle.Right()
407cdf0e10cSrcweir && RECT_EMPTY != aInnerRectangle.Bottom())
408cdf0e10cSrcweir {
409cdf0e10cSrcweir aInnerRange.expand(basegfx::B2DTuple(aInnerRectangle.Left(), aInnerRectangle.Top()));
410cdf0e10cSrcweir aInnerRange.expand(basegfx::B2DTuple(aInnerRectangle.Right(), aInnerRectangle.Bottom()));
411cdf0e10cSrcweir }
412cdf0e10cSrcweir }
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir return aInnerRange;
416cdf0e10cSrcweir }
417cdf0e10cSrcweir
CreateObjectSpecificViewContact()418cdf0e10cSrcweir sdr::contact::ViewContact* SwVirtFlyDrawObj::CreateObjectSpecificViewContact()
419cdf0e10cSrcweir {
420cdf0e10cSrcweir // need an own ViewContact (VC) to allow creation of a specialized primitive
421cdf0e10cSrcweir // for being able to visualize the FlyFrames in primitive renderers
422cdf0e10cSrcweir return new sdr::contact::VCOfSwVirtFlyDrawObj(*this);
423cdf0e10cSrcweir }
424cdf0e10cSrcweir
SwVirtFlyDrawObj(SdrObject & rNew,SwFlyFrm * pFly)425cdf0e10cSrcweir SwVirtFlyDrawObj::SwVirtFlyDrawObj(SdrObject& rNew, SwFlyFrm* pFly) :
426cdf0e10cSrcweir SdrVirtObj( rNew ),
427cdf0e10cSrcweir pFlyFrm( pFly )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir //#110094#-1
430cdf0e10cSrcweir // bNotPersistent = bNeedColorRestore = bWriterFlyFrame = sal_True;
431cdf0e10cSrcweir const SvxProtectItem &rP = pFlyFrm->GetFmt()->GetProtect();
432cdf0e10cSrcweir bMovProt = rP.IsPosProtected();
433cdf0e10cSrcweir bSizProt = rP.IsSizeProtected();
434cdf0e10cSrcweir }
435cdf0e10cSrcweir
436cdf0e10cSrcweir
~SwVirtFlyDrawObj()437cdf0e10cSrcweir __EXPORT SwVirtFlyDrawObj::~SwVirtFlyDrawObj()
438cdf0e10cSrcweir {
439cdf0e10cSrcweir if ( GetPage() ) //Der SdrPage die Verantwortung entziehen.
440cdf0e10cSrcweir GetPage()->RemoveObject( GetOrdNum() );
441cdf0e10cSrcweir }
442cdf0e10cSrcweir
443cdf0e10cSrcweir /*************************************************************************
444cdf0e10cSrcweir |*
445cdf0e10cSrcweir |* SwVirtFlyDrawObj::GetFmt()
446cdf0e10cSrcweir |*
447cdf0e10cSrcweir |* Ersterstellung MA 08. Dec. 94
448cdf0e10cSrcweir |* Letzte Aenderung MA 08. Dec. 94
449cdf0e10cSrcweir |*
450cdf0e10cSrcweir *************************************************************************/
451cdf0e10cSrcweir
GetFmt() const452cdf0e10cSrcweir const SwFrmFmt *SwVirtFlyDrawObj::GetFmt() const
453cdf0e10cSrcweir {
454cdf0e10cSrcweir return GetFlyFrm()->GetFmt();
455cdf0e10cSrcweir }
456cdf0e10cSrcweir
457cdf0e10cSrcweir
GetFmt()458cdf0e10cSrcweir SwFrmFmt *SwVirtFlyDrawObj::GetFmt()
459cdf0e10cSrcweir {
460cdf0e10cSrcweir return GetFlyFrm()->GetFmt();
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
463cdf0e10cSrcweir /*************************************************************************
464cdf0e10cSrcweir |*
465cdf0e10cSrcweir |* SwVirtFlyDrawObj::Paint()
466cdf0e10cSrcweir |*
467cdf0e10cSrcweir |* Ersterstellung MA 20. Dec. 94
468cdf0e10cSrcweir |* Letzte Aenderung MA 18. Dec. 95
469cdf0e10cSrcweir |*
470cdf0e10cSrcweir *************************************************************************/
471cdf0e10cSrcweir
472cdf0e10cSrcweir // --> OD #i102707#
473cdf0e10cSrcweir namespace
474cdf0e10cSrcweir {
475cdf0e10cSrcweir class RestoreMapMode
476cdf0e10cSrcweir {
477cdf0e10cSrcweir public:
RestoreMapMode(ViewShell * pViewShell)478cdf0e10cSrcweir explicit RestoreMapMode( ViewShell* pViewShell )
479cdf0e10cSrcweir : mbMapModeRestored( false )
480cdf0e10cSrcweir , mpOutDev( pViewShell->GetOut() )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir if ( pViewShell->getPrePostMapMode() != mpOutDev->GetMapMode() )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir mpOutDev->Push(PUSH_MAPMODE);
485cdf0e10cSrcweir
486cdf0e10cSrcweir GDIMetaFile* pMetaFile = mpOutDev->GetConnectMetaFile();
487cdf0e10cSrcweir if ( pMetaFile &&
488cdf0e10cSrcweir pMetaFile->IsRecord() && !pMetaFile->IsPause() )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir ASSERT( false,
491cdf0e10cSrcweir "MapMode restoration during meta file creation is somehow suspect - using <SetRelativeMapMode(..)>, but not sure, if correct." )
492cdf0e10cSrcweir mpOutDev->SetRelativeMapMode( pViewShell->getPrePostMapMode() );
493cdf0e10cSrcweir }
494cdf0e10cSrcweir else
495cdf0e10cSrcweir {
496cdf0e10cSrcweir mpOutDev->SetMapMode( pViewShell->getPrePostMapMode() );
497cdf0e10cSrcweir }
498cdf0e10cSrcweir
499cdf0e10cSrcweir mbMapModeRestored = true;
500cdf0e10cSrcweir }
501cdf0e10cSrcweir };
502cdf0e10cSrcweir
~RestoreMapMode()503cdf0e10cSrcweir ~RestoreMapMode()
504cdf0e10cSrcweir {
505cdf0e10cSrcweir if ( mbMapModeRestored )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir mpOutDev->Pop();
508cdf0e10cSrcweir }
509cdf0e10cSrcweir };
510cdf0e10cSrcweir
511cdf0e10cSrcweir private:
512cdf0e10cSrcweir bool mbMapModeRestored;
513cdf0e10cSrcweir OutputDevice* mpOutDev;
514cdf0e10cSrcweir };
515cdf0e10cSrcweir }
516cdf0e10cSrcweir // <--
517cdf0e10cSrcweir
wrap_DoPaintObject() const518cdf0e10cSrcweir void SwVirtFlyDrawObj::wrap_DoPaintObject() const
519cdf0e10cSrcweir {
520cdf0e10cSrcweir ViewShell* pShell = pFlyFrm->getRootFrm()->GetCurrShell();
521cdf0e10cSrcweir
522cdf0e10cSrcweir // Only paint when we have a current shell and a DrawingLayer paint is in progress.
523cdf0e10cSrcweir // This avcoids evtl. problems with renderers which do processing stuff,
524cdf0e10cSrcweir // but no paints. IsPaintInProgress() depends on SW repaint, so, as long
525cdf0e10cSrcweir // as SW paints self and calls DrawLayer() for Heaven and Hell, this will
526cdf0e10cSrcweir // be correct
527cdf0e10cSrcweir if ( pShell && pShell->IsDrawingLayerPaintInProgress() )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir sal_Bool bDrawObject(sal_True);
530cdf0e10cSrcweir
531cdf0e10cSrcweir if ( !SwFlyFrm::IsPaint( (SdrObject*)this, pShell ) )
532cdf0e10cSrcweir {
533cdf0e10cSrcweir bDrawObject = sal_False;
534cdf0e10cSrcweir }
535cdf0e10cSrcweir
536cdf0e10cSrcweir if ( bDrawObject )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir if ( !pFlyFrm->IsFlyInCntFrm() )
539cdf0e10cSrcweir {
540cdf0e10cSrcweir // it is also necessary to restore the VCL MapMode from ViewInformation since e.g.
541cdf0e10cSrcweir // the VCL PixelRenderer resets it at the used OutputDevice. Unfortunately, this
542cdf0e10cSrcweir // excludes shears and rotates which are not expressable in MapMode.
543cdf0e10cSrcweir // OD #i102707#
544cdf0e10cSrcweir // new helper class to restore MapMode - restoration, only if
545cdf0e10cSrcweir // needed and consideration of paint for meta file creation .
546cdf0e10cSrcweir RestoreMapMode aRestoreMapModeIfNeeded( pShell );
547cdf0e10cSrcweir
548cdf0e10cSrcweir // paint the FlyFrame (use standard VCL-Paint)
549cdf0e10cSrcweir pFlyFrm->Paint( GetFlyFrm()->Frm() );
550cdf0e10cSrcweir }
551cdf0e10cSrcweir }
552cdf0e10cSrcweir }
553cdf0e10cSrcweir }
554cdf0e10cSrcweir
555cdf0e10cSrcweir /*************************************************************************
556cdf0e10cSrcweir |*
557cdf0e10cSrcweir |* SwVirtFlyDrawObj::TakeObjInfo()
558cdf0e10cSrcweir |*
559cdf0e10cSrcweir |* Ersterstellung MA 03. May. 95
560cdf0e10cSrcweir |* Letzte Aenderung MA 03. May. 95
561cdf0e10cSrcweir |*
562cdf0e10cSrcweir *************************************************************************/
563cdf0e10cSrcweir
TakeObjInfo(SdrObjTransformInfoRec & rInfo) const564cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::TakeObjInfo( SdrObjTransformInfoRec& rInfo ) const
565cdf0e10cSrcweir {
566cdf0e10cSrcweir rInfo.bSelectAllowed = rInfo.bMoveAllowed =
567cdf0e10cSrcweir rInfo.bResizeFreeAllowed = rInfo.bResizePropAllowed = sal_True;
568cdf0e10cSrcweir
569cdf0e10cSrcweir rInfo.bRotateFreeAllowed = rInfo.bRotate90Allowed =
570cdf0e10cSrcweir rInfo.bMirrorFreeAllowed = rInfo.bMirror45Allowed =
571cdf0e10cSrcweir rInfo.bMirror90Allowed = rInfo.bShearAllowed =
572cdf0e10cSrcweir rInfo.bCanConvToPath = rInfo.bCanConvToPoly =
573cdf0e10cSrcweir rInfo.bCanConvToPathLineToArea = rInfo.bCanConvToPolyLineToArea = sal_False;
574cdf0e10cSrcweir }
575cdf0e10cSrcweir
576cdf0e10cSrcweir
577cdf0e10cSrcweir /*************************************************************************
578cdf0e10cSrcweir |*
579cdf0e10cSrcweir |* SwVirtFlyDrawObj::Groessenermittlung
580cdf0e10cSrcweir |*
581cdf0e10cSrcweir |* Ersterstellung MA 12. Jan. 95
582cdf0e10cSrcweir |* Letzte Aenderung MA 10. Nov. 95
583cdf0e10cSrcweir |*
584cdf0e10cSrcweir *************************************************************************/
585cdf0e10cSrcweir
SetRect() const586cdf0e10cSrcweir void SwVirtFlyDrawObj::SetRect() const
587cdf0e10cSrcweir {
588cdf0e10cSrcweir if ( GetFlyFrm()->Frm().HasArea() )
589cdf0e10cSrcweir ((SwVirtFlyDrawObj*)this)->aOutRect = GetFlyFrm()->Frm().SVRect();
590cdf0e10cSrcweir else
591cdf0e10cSrcweir ((SwVirtFlyDrawObj*)this)->aOutRect = Rectangle();
592cdf0e10cSrcweir }
593cdf0e10cSrcweir
594cdf0e10cSrcweir
GetCurrentBoundRect() const595cdf0e10cSrcweir const Rectangle& __EXPORT SwVirtFlyDrawObj::GetCurrentBoundRect() const
596cdf0e10cSrcweir {
597cdf0e10cSrcweir SetRect();
598cdf0e10cSrcweir return aOutRect;
599cdf0e10cSrcweir }
600cdf0e10cSrcweir
GetLastBoundRect() const601cdf0e10cSrcweir const Rectangle& __EXPORT SwVirtFlyDrawObj::GetLastBoundRect() const
602cdf0e10cSrcweir {
603cdf0e10cSrcweir return GetCurrentBoundRect();
604cdf0e10cSrcweir }
605cdf0e10cSrcweir
606cdf0e10cSrcweir
RecalcBoundRect()607cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::RecalcBoundRect()
608cdf0e10cSrcweir {
609cdf0e10cSrcweir SetRect();
610cdf0e10cSrcweir }
611cdf0e10cSrcweir
612cdf0e10cSrcweir
RecalcSnapRect()613cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::RecalcSnapRect()
614cdf0e10cSrcweir {
615cdf0e10cSrcweir SetRect();
616cdf0e10cSrcweir }
617cdf0e10cSrcweir
618cdf0e10cSrcweir
GetSnapRect() const619cdf0e10cSrcweir const Rectangle& __EXPORT SwVirtFlyDrawObj::GetSnapRect() const
620cdf0e10cSrcweir {
621cdf0e10cSrcweir SetRect();
622cdf0e10cSrcweir return aOutRect;
623cdf0e10cSrcweir }
624cdf0e10cSrcweir
625cdf0e10cSrcweir
SetSnapRect(const Rectangle &)626cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::SetSnapRect(const Rectangle& )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir Rectangle aTmp( GetLastBoundRect() );
629cdf0e10cSrcweir SetRect();
630cdf0e10cSrcweir SetChanged();
631cdf0e10cSrcweir BroadcastObjectChange();
632cdf0e10cSrcweir if (pUserCall!=NULL)
633cdf0e10cSrcweir pUserCall->Changed(*this, SDRUSERCALL_RESIZE, aTmp);
634cdf0e10cSrcweir }
635cdf0e10cSrcweir
636cdf0e10cSrcweir
NbcSetSnapRect(const Rectangle &)637cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::NbcSetSnapRect(const Rectangle& )
638cdf0e10cSrcweir {
639cdf0e10cSrcweir SetRect();
640cdf0e10cSrcweir }
641cdf0e10cSrcweir
642cdf0e10cSrcweir
GetLogicRect() const643cdf0e10cSrcweir const Rectangle& __EXPORT SwVirtFlyDrawObj::GetLogicRect() const
644cdf0e10cSrcweir {
645cdf0e10cSrcweir SetRect();
646cdf0e10cSrcweir return aOutRect;
647cdf0e10cSrcweir }
648cdf0e10cSrcweir
649cdf0e10cSrcweir
SetLogicRect(const Rectangle &)650cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::SetLogicRect(const Rectangle& )
651cdf0e10cSrcweir {
652cdf0e10cSrcweir Rectangle aTmp( GetLastBoundRect() );
653cdf0e10cSrcweir SetRect();
654cdf0e10cSrcweir SetChanged();
655cdf0e10cSrcweir BroadcastObjectChange();
656cdf0e10cSrcweir if (pUserCall!=NULL)
657cdf0e10cSrcweir pUserCall->Changed(*this, SDRUSERCALL_RESIZE, aTmp);
658cdf0e10cSrcweir }
659cdf0e10cSrcweir
660cdf0e10cSrcweir
NbcSetLogicRect(const Rectangle &)661cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::NbcSetLogicRect(const Rectangle& )
662cdf0e10cSrcweir {
663cdf0e10cSrcweir SetRect();
664cdf0e10cSrcweir }
665cdf0e10cSrcweir
666cdf0e10cSrcweir
TakeXorPoly() const667cdf0e10cSrcweir ::basegfx::B2DPolyPolygon SwVirtFlyDrawObj::TakeXorPoly() const
668cdf0e10cSrcweir {
669cdf0e10cSrcweir const Rectangle aSourceRectangle(GetFlyFrm()->Frm().SVRect());
670cdf0e10cSrcweir const ::basegfx::B2DRange aSourceRange(aSourceRectangle.Left(), aSourceRectangle.Top(), aSourceRectangle.Right(), aSourceRectangle.Bottom());
671cdf0e10cSrcweir ::basegfx::B2DPolyPolygon aRetval;
672cdf0e10cSrcweir
673cdf0e10cSrcweir aRetval.append(::basegfx::tools::createPolygonFromRect(aSourceRange));
674cdf0e10cSrcweir
675cdf0e10cSrcweir return aRetval;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir
678cdf0e10cSrcweir /*************************************************************************
679cdf0e10cSrcweir |*
680cdf0e10cSrcweir |* SwVirtFlyDrawObj::Move() und Resize()
681cdf0e10cSrcweir |*
682cdf0e10cSrcweir |* Ersterstellung MA 12. Jan. 95
683cdf0e10cSrcweir |* Letzte Aenderung MA 26. Jul. 96
684cdf0e10cSrcweir |*
685cdf0e10cSrcweir *************************************************************************/
686cdf0e10cSrcweir
NbcMove(const Size & rSiz)687cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::NbcMove(const Size& rSiz)
688cdf0e10cSrcweir {
689cdf0e10cSrcweir MoveRect( aOutRect, rSiz );
690cdf0e10cSrcweir const Point aOldPos( GetFlyFrm()->Frm().Pos() );
691cdf0e10cSrcweir const Point aNewPos( aOutRect.TopLeft() );
692cdf0e10cSrcweir const SwRect aFlyRect( aOutRect );
693cdf0e10cSrcweir
694cdf0e10cSrcweir //Wenn der Fly eine automatische Ausrichtung hat (rechts oder oben),
695cdf0e10cSrcweir //so soll die Automatik erhalten bleiben
696cdf0e10cSrcweir SwFrmFmt *pFmt = GetFlyFrm()->GetFmt();
697cdf0e10cSrcweir const sal_Int16 eHori = pFmt->GetHoriOrient().GetHoriOrient();
698cdf0e10cSrcweir const sal_Int16 eVert = pFmt->GetVertOrient().GetVertOrient();
699cdf0e10cSrcweir const sal_Int16 eRelHori = pFmt->GetHoriOrient().GetRelationOrient();
700cdf0e10cSrcweir const sal_Int16 eRelVert = pFmt->GetVertOrient().GetRelationOrient();
701cdf0e10cSrcweir //Bei Absatzgebundenen Flys muss ausgehend von der neuen Position ein
702cdf0e10cSrcweir //neuer Anker gesetzt werden. Anker und neue RelPos werden vom Fly selbst
703cdf0e10cSrcweir //berechnet und gesetzt.
704cdf0e10cSrcweir if( GetFlyFrm()->IsFlyAtCntFrm() )
705cdf0e10cSrcweir ((SwFlyAtCntFrm*)GetFlyFrm())->SetAbsPos( aNewPos );
706cdf0e10cSrcweir else
707cdf0e10cSrcweir {
708cdf0e10cSrcweir const SwFrmFmt *pTmpFmt = GetFmt();
709cdf0e10cSrcweir const SwFmtVertOrient &rVert = pTmpFmt->GetVertOrient();
710cdf0e10cSrcweir const SwFmtHoriOrient &rHori = pTmpFmt->GetHoriOrient();
711cdf0e10cSrcweir long lXDiff = aNewPos.X() - aOldPos.X();
712cdf0e10cSrcweir if( rHori.IsPosToggle() && text::HoriOrientation::NONE == eHori &&
713cdf0e10cSrcweir !GetFlyFrm()->FindPageFrm()->OnRightPage() )
714cdf0e10cSrcweir lXDiff = -lXDiff;
715cdf0e10cSrcweir
716cdf0e10cSrcweir if( GetFlyFrm()->GetAnchorFrm()->IsRightToLeft() &&
717cdf0e10cSrcweir text::HoriOrientation::NONE == eHori )
718cdf0e10cSrcweir lXDiff = -lXDiff;
719cdf0e10cSrcweir
720cdf0e10cSrcweir long lYDiff = aNewPos.Y() - aOldPos.Y();
721cdf0e10cSrcweir if( GetFlyFrm()->GetAnchorFrm()->IsVertical() )
722cdf0e10cSrcweir {
723cdf0e10cSrcweir //lXDiff -= rVert.GetPos();
724cdf0e10cSrcweir //lYDiff += rHori.GetPos();
725cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
726cdf0e10cSrcweir if ( GetFlyFrm()->GetAnchorFrm()->IsVertLR() )
727cdf0e10cSrcweir {
728cdf0e10cSrcweir lXDiff += rVert.GetPos();
729cdf0e10cSrcweir lXDiff = -lXDiff;
730cdf0e10cSrcweir }
731cdf0e10cSrcweir else
732cdf0e10cSrcweir {
733cdf0e10cSrcweir lXDiff -= rVert.GetPos();
734cdf0e10cSrcweir lYDiff += rHori.GetPos();
735cdf0e10cSrcweir }
736cdf0e10cSrcweir }
737cdf0e10cSrcweir else
738cdf0e10cSrcweir {
739cdf0e10cSrcweir lXDiff += rHori.GetPos();
740cdf0e10cSrcweir lYDiff += rVert.GetPos();
741cdf0e10cSrcweir }
742cdf0e10cSrcweir
743cdf0e10cSrcweir if( GetFlyFrm()->GetAnchorFrm()->IsRightToLeft() &&
744cdf0e10cSrcweir text::HoriOrientation::NONE != eHori )
745cdf0e10cSrcweir lXDiff = GetFlyFrm()->GetAnchorFrm()->Frm().Width() -
746cdf0e10cSrcweir aFlyRect.Width() - lXDiff;
747cdf0e10cSrcweir
748cdf0e10cSrcweir const Point aTmp( lXDiff, lYDiff );
749cdf0e10cSrcweir GetFlyFrm()->ChgRelPos( aTmp );
750cdf0e10cSrcweir }
751cdf0e10cSrcweir
752cdf0e10cSrcweir SwAttrSet aSet( pFmt->GetDoc()->GetAttrPool(),
753cdf0e10cSrcweir RES_VERT_ORIENT, RES_HORI_ORIENT );
754cdf0e10cSrcweir SwFmtHoriOrient aHori( pFmt->GetHoriOrient() );
755cdf0e10cSrcweir SwFmtVertOrient aVert( pFmt->GetVertOrient() );
756cdf0e10cSrcweir sal_Bool bPut = sal_False;
757cdf0e10cSrcweir
758cdf0e10cSrcweir if( !GetFlyFrm()->IsFlyLayFrm() &&
759cdf0e10cSrcweir ::GetHtmlMode(pFmt->GetDoc()->GetDocShell()) )
760cdf0e10cSrcweir {
761cdf0e10cSrcweir //Im HTML-Modus sind nur automatische Ausrichtungen erlaubt.
762cdf0e10cSrcweir //Einzig einen Snap auf Links/Rechts bzw. Linker-/Rechter-Rand koennen
763cdf0e10cSrcweir //wir versuchen.
764cdf0e10cSrcweir const SwFrm* pAnch = GetFlyFrm()->GetAnchorFrm();
765cdf0e10cSrcweir sal_Bool bNextLine = sal_False;
766cdf0e10cSrcweir
767cdf0e10cSrcweir if( !GetFlyFrm()->IsAutoPos() || text::RelOrientation::PAGE_FRAME != aHori.GetRelationOrient() )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir if( text::RelOrientation::CHAR == eRelHori )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir aHori.SetHoriOrient( text::HoriOrientation::LEFT );
772cdf0e10cSrcweir aHori.SetRelationOrient( text::RelOrientation::CHAR );
773cdf0e10cSrcweir }
774cdf0e10cSrcweir else
775cdf0e10cSrcweir {
776cdf0e10cSrcweir bNextLine = sal_True;
777cdf0e10cSrcweir //Horizontale Ausrichtung:
778cdf0e10cSrcweir const sal_Bool bLeftFrm =
779cdf0e10cSrcweir aFlyRect.Left() < pAnch->Frm().Left() + pAnch->Prt().Left(),
780cdf0e10cSrcweir bLeftPrt = aFlyRect.Left() + aFlyRect.Width() <
781cdf0e10cSrcweir pAnch->Frm().Left() + pAnch->Prt().Width()/2;
782cdf0e10cSrcweir if ( bLeftFrm || bLeftPrt )
783cdf0e10cSrcweir {
784cdf0e10cSrcweir aHori.SetHoriOrient( text::HoriOrientation::LEFT );
785cdf0e10cSrcweir aHori.SetRelationOrient( bLeftFrm ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
786cdf0e10cSrcweir }
787cdf0e10cSrcweir else
788cdf0e10cSrcweir {
789cdf0e10cSrcweir const sal_Bool bRightFrm = aFlyRect.Left() >
790cdf0e10cSrcweir pAnch->Frm().Left() + pAnch->Prt().Width();
791cdf0e10cSrcweir aHori.SetHoriOrient( text::HoriOrientation::RIGHT );
792cdf0e10cSrcweir aHori.SetRelationOrient( bRightFrm ? text::RelOrientation::FRAME : text::RelOrientation::PRINT_AREA );
793cdf0e10cSrcweir }
794cdf0e10cSrcweir }
795cdf0e10cSrcweir aSet.Put( aHori );
796cdf0e10cSrcweir }
797cdf0e10cSrcweir //Vertikale Ausrichtung bleibt grundsaetzlich schlicht erhalten,
798cdf0e10cSrcweir //nur bei nicht automatischer Ausrichtung wird umgeschaltet.
799cdf0e10cSrcweir sal_Bool bRelChar = text::RelOrientation::CHAR == eRelVert;
800cdf0e10cSrcweir aVert.SetVertOrient( eVert != text::VertOrientation::NONE ? eVert :
801cdf0e10cSrcweir GetFlyFrm()->IsFlyInCntFrm() ? text::VertOrientation::CHAR_CENTER :
802cdf0e10cSrcweir bRelChar && bNextLine ? text::VertOrientation::CHAR_TOP : text::VertOrientation::TOP );
803cdf0e10cSrcweir if( bRelChar )
804cdf0e10cSrcweir aVert.SetRelationOrient( text::RelOrientation::CHAR );
805cdf0e10cSrcweir else
806cdf0e10cSrcweir aVert.SetRelationOrient( text::RelOrientation::PRINT_AREA );
807cdf0e10cSrcweir aSet.Put( aVert );
808cdf0e10cSrcweir bPut = sal_True;
809cdf0e10cSrcweir }
810cdf0e10cSrcweir
811cdf0e10cSrcweir //Automatische Ausrichtungen wollen wir moeglichst nicht verlieren.
812cdf0e10cSrcweir if ( !bPut && bInResize )
813cdf0e10cSrcweir {
814cdf0e10cSrcweir if ( text::HoriOrientation::NONE != eHori )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir aHori.SetHoriOrient( eHori );
817cdf0e10cSrcweir aHori.SetRelationOrient( eRelHori );
818cdf0e10cSrcweir aSet.Put( aHori );
819cdf0e10cSrcweir bPut = sal_True;
820cdf0e10cSrcweir }
821cdf0e10cSrcweir if ( text::VertOrientation::NONE != eVert )
822cdf0e10cSrcweir {
823cdf0e10cSrcweir aVert.SetVertOrient( eVert );
824cdf0e10cSrcweir aVert.SetRelationOrient( eRelVert );
825cdf0e10cSrcweir aSet.Put( aVert );
826cdf0e10cSrcweir bPut = sal_True;
827cdf0e10cSrcweir }
828cdf0e10cSrcweir }
829cdf0e10cSrcweir if ( bPut )
830cdf0e10cSrcweir pFmt->SetFmtAttr( aSet );
831cdf0e10cSrcweir }
832cdf0e10cSrcweir
833cdf0e10cSrcweir
NbcResize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)834cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::NbcResize(const Point& rRef,
835cdf0e10cSrcweir const Fraction& xFact, const Fraction& yFact)
836cdf0e10cSrcweir {
837cdf0e10cSrcweir ResizeRect( aOutRect, rRef, xFact, yFact );
838cdf0e10cSrcweir
839cdf0e10cSrcweir const SwFrm* pTmpFrm = GetFlyFrm()->GetAnchorFrm();
840cdf0e10cSrcweir if( !pTmpFrm )
841cdf0e10cSrcweir pTmpFrm = GetFlyFrm();
842cdf0e10cSrcweir const bool bVertX = pTmpFrm->IsVertical();
843cdf0e10cSrcweir
844cdf0e10cSrcweir const sal_Bool bRTL = pTmpFrm->IsRightToLeft();
845cdf0e10cSrcweir
846cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
847cdf0e10cSrcweir const bool bVertL2RX = pTmpFrm->IsVertLR();
848cdf0e10cSrcweir const Point aNewPos( ( bVertX && !bVertL2RX ) || bRTL ?
849cdf0e10cSrcweir aOutRect.Right() + 1 :
850cdf0e10cSrcweir aOutRect.Left(),
851cdf0e10cSrcweir aOutRect.Top() );
852cdf0e10cSrcweir
853cdf0e10cSrcweir Size aSz( aOutRect.Right() - aOutRect.Left() + 1,
854cdf0e10cSrcweir aOutRect.Bottom()- aOutRect.Top() + 1 );
855cdf0e10cSrcweir if( aSz != GetFlyFrm()->Frm().SSize() )
856cdf0e10cSrcweir {
857cdf0e10cSrcweir //Die Breite darf bei Spalten nicht zu schmal werden
858cdf0e10cSrcweir if ( GetFlyFrm()->Lower() && GetFlyFrm()->Lower()->IsColumnFrm() )
859cdf0e10cSrcweir {
860cdf0e10cSrcweir SwBorderAttrAccess aAccess( SwFrm::GetCache(), GetFlyFrm() );
861cdf0e10cSrcweir const SwBorderAttrs &rAttrs = *aAccess.Get();
862cdf0e10cSrcweir long nMin = rAttrs.CalcLeftLine()+rAttrs.CalcRightLine();
863cdf0e10cSrcweir const SwFmtCol& rCol = rAttrs.GetAttrSet().GetCol();
864cdf0e10cSrcweir if ( rCol.GetColumns().Count() > 1 )
865cdf0e10cSrcweir {
866cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < rCol.GetColumns().Count(); ++i )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir nMin += rCol.GetColumns()[i]->GetLeft() +
869cdf0e10cSrcweir rCol.GetColumns()[i]->GetRight() +
870cdf0e10cSrcweir MINFLY;
871cdf0e10cSrcweir }
872cdf0e10cSrcweir nMin -= MINFLY;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir aSz.Width() = Max( aSz.Width(), nMin );
875cdf0e10cSrcweir }
876cdf0e10cSrcweir
877cdf0e10cSrcweir SwFrmFmt *pFmt = GetFmt();
878cdf0e10cSrcweir const SwFmtFrmSize aOldFrmSz( pFmt->GetFrmSize() );
879cdf0e10cSrcweir GetFlyFrm()->ChgSize( aSz );
880cdf0e10cSrcweir SwFmtFrmSize aFrmSz( pFmt->GetFrmSize() );
881cdf0e10cSrcweir if ( aFrmSz.GetWidthPercent() || aFrmSz.GetHeightPercent() )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir long nRelWidth, nRelHeight;
884cdf0e10cSrcweir const SwFrm *pRel = GetFlyFrm()->IsFlyLayFrm() ?
885cdf0e10cSrcweir GetFlyFrm()->GetAnchorFrm() :
886cdf0e10cSrcweir GetFlyFrm()->GetAnchorFrm()->GetUpper();
887cdf0e10cSrcweir const ViewShell *pSh = GetFlyFrm()->getRootFrm()->GetCurrShell();
888cdf0e10cSrcweir if ( pSh && pRel->IsBodyFrm() &&
889cdf0e10cSrcweir pSh->GetViewOptions()->getBrowseMode() &&
890cdf0e10cSrcweir pSh->VisArea().HasArea() )
891cdf0e10cSrcweir {
892cdf0e10cSrcweir nRelWidth = pSh->GetBrowseWidth();
893cdf0e10cSrcweir nRelHeight = pSh->VisArea().Height();
894cdf0e10cSrcweir const Size aBorder = pSh->GetOut()->PixelToLogic( pSh->GetBrowseBorder() );
895cdf0e10cSrcweir nRelHeight -= 2*aBorder.Height();
896cdf0e10cSrcweir }
897cdf0e10cSrcweir else
898cdf0e10cSrcweir {
899cdf0e10cSrcweir nRelWidth = pRel->Prt().Width();
900cdf0e10cSrcweir nRelHeight = pRel->Prt().Height();
901cdf0e10cSrcweir }
902cdf0e10cSrcweir if ( aFrmSz.GetWidthPercent() && aFrmSz.GetWidthPercent() != 0xFF &&
903cdf0e10cSrcweir aOldFrmSz.GetWidth() != aFrmSz.GetWidth() )
904cdf0e10cSrcweir aFrmSz.SetWidthPercent( sal_uInt8(aSz.Width() * 100L / nRelWidth + 0.5) );
905cdf0e10cSrcweir if ( aFrmSz.GetHeightPercent() && aFrmSz.GetHeightPercent() != 0xFF &&
906cdf0e10cSrcweir aOldFrmSz.GetHeight() != aFrmSz.GetHeight() )
907cdf0e10cSrcweir aFrmSz.SetHeightPercent( sal_uInt8(aSz.Height() * 100L / nRelHeight + 0.5) );
908cdf0e10cSrcweir pFmt->GetDoc()->SetAttr( aFrmSz, *pFmt );
909cdf0e10cSrcweir }
910cdf0e10cSrcweir }
911cdf0e10cSrcweir
912cdf0e10cSrcweir //Position kann auch veraendert sein!
913cdf0e10cSrcweir const Point aOldPos( ( bVertX && !bVertL2RX ) || bRTL ?
914cdf0e10cSrcweir GetFlyFrm()->Frm().TopRight() :
915cdf0e10cSrcweir GetFlyFrm()->Frm().Pos() );
916cdf0e10cSrcweir if ( aNewPos != aOldPos )
917cdf0e10cSrcweir {
918cdf0e10cSrcweir //Kann sich durch das ChgSize veraendert haben!
919cdf0e10cSrcweir if( bVertX || bRTL )
920cdf0e10cSrcweir {
921cdf0e10cSrcweir if( aOutRect.TopRight() != aNewPos )
922cdf0e10cSrcweir {
923cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
924cdf0e10cSrcweir SwTwips nDeltaX;
925cdf0e10cSrcweir if ( bVertL2RX )
926cdf0e10cSrcweir nDeltaX = aNewPos.X() - aOutRect.Left();
927cdf0e10cSrcweir else
928cdf0e10cSrcweir nDeltaX = aNewPos.X() - aOutRect.Right();
929cdf0e10cSrcweir SwTwips nDeltaY = aNewPos.Y() - aOutRect.Top();
930cdf0e10cSrcweir MoveRect( aOutRect, Size( nDeltaX, nDeltaY ) );
931cdf0e10cSrcweir }
932cdf0e10cSrcweir }
933cdf0e10cSrcweir else if ( aOutRect.TopLeft() != aNewPos )
934cdf0e10cSrcweir aOutRect.SetPos( aNewPos );
935cdf0e10cSrcweir bInResize = sal_True;
936cdf0e10cSrcweir NbcMove( Size( 0, 0 ) );
937cdf0e10cSrcweir bInResize = sal_False;
938cdf0e10cSrcweir }
939cdf0e10cSrcweir }
940cdf0e10cSrcweir
941cdf0e10cSrcweir
Move(const Size & rSiz)942cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::Move(const Size& rSiz)
943cdf0e10cSrcweir {
944cdf0e10cSrcweir NbcMove( rSiz );
945cdf0e10cSrcweir SetChanged();
946cdf0e10cSrcweir GetFmt()->GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
947cdf0e10cSrcweir }
948cdf0e10cSrcweir
949cdf0e10cSrcweir
Resize(const Point & rRef,const Fraction & xFact,const Fraction & yFact)950cdf0e10cSrcweir void __EXPORT SwVirtFlyDrawObj::Resize(const Point& rRef,
951cdf0e10cSrcweir const Fraction& xFact, const Fraction& yFact)
952cdf0e10cSrcweir {
953cdf0e10cSrcweir NbcResize( rRef, xFact, yFact );
954cdf0e10cSrcweir SetChanged();
955cdf0e10cSrcweir GetFmt()->GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false);
956cdf0e10cSrcweir }
957cdf0e10cSrcweir
958cdf0e10cSrcweir
GetMacroPointer(const SdrObjMacroHitRec &) const959cdf0e10cSrcweir Pointer __EXPORT SwVirtFlyDrawObj::GetMacroPointer(
960cdf0e10cSrcweir const SdrObjMacroHitRec& ) const
961cdf0e10cSrcweir {
962cdf0e10cSrcweir return Pointer( POINTER_REFHAND );
963cdf0e10cSrcweir }
964cdf0e10cSrcweir
965cdf0e10cSrcweir
HasMacro() const966cdf0e10cSrcweir FASTBOOL __EXPORT SwVirtFlyDrawObj::HasMacro() const
967cdf0e10cSrcweir {
968cdf0e10cSrcweir const SwFmtURL &rURL = pFlyFrm->GetFmt()->GetURL();
969cdf0e10cSrcweir return rURL.GetMap() || rURL.GetURL().Len();
970cdf0e10cSrcweir }
971cdf0e10cSrcweir
972cdf0e10cSrcweir
CheckMacroHit(const SdrObjMacroHitRec & rRec) const973cdf0e10cSrcweir SdrObject* SwVirtFlyDrawObj::CheckMacroHit( const SdrObjMacroHitRec& rRec ) const
974cdf0e10cSrcweir {
975cdf0e10cSrcweir const SwFmtURL &rURL = pFlyFrm->GetFmt()->GetURL();
976cdf0e10cSrcweir if( rURL.GetMap() || rURL.GetURL().Len() )
977cdf0e10cSrcweir {
978cdf0e10cSrcweir SwRect aRect;
979cdf0e10cSrcweir if ( pFlyFrm->Lower() && pFlyFrm->Lower()->IsNoTxtFrm() )
980cdf0e10cSrcweir {
981cdf0e10cSrcweir aRect = pFlyFrm->Prt();
982cdf0e10cSrcweir aRect += pFlyFrm->Frm().Pos();
983cdf0e10cSrcweir }
984cdf0e10cSrcweir else
985cdf0e10cSrcweir aRect = pFlyFrm->Frm();
986cdf0e10cSrcweir
987cdf0e10cSrcweir if( aRect.IsInside( rRec.aPos ) )
988cdf0e10cSrcweir {
989cdf0e10cSrcweir SwRect aActRect( aRect );
990cdf0e10cSrcweir Size aActSz( aRect.SSize() );
991cdf0e10cSrcweir aRect.Pos().X() += rRec.nTol;
992cdf0e10cSrcweir aRect.Pos().Y() += rRec.nTol;
993cdf0e10cSrcweir aRect.SSize().Height()-= 2 * rRec.nTol;
994cdf0e10cSrcweir aRect.SSize().Width() -= 2 * rRec.nTol;
995cdf0e10cSrcweir
996cdf0e10cSrcweir if( aRect.IsInside( rRec.aPos ) )
997cdf0e10cSrcweir {
998cdf0e10cSrcweir if( !rURL.GetMap() ||
999cdf0e10cSrcweir pFlyFrm->GetFmt()->GetIMapObject( rRec.aPos, pFlyFrm ))
1000cdf0e10cSrcweir return (SdrObject*)this;
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir return 0;
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir return SdrObject::CheckMacroHit( rRec );
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir
supportsFullDrag() const1009cdf0e10cSrcweir bool SwVirtFlyDrawObj::supportsFullDrag() const
1010cdf0e10cSrcweir {
1011cdf0e10cSrcweir // call parent
1012cdf0e10cSrcweir return SdrVirtObj::supportsFullDrag();
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir
getFullDragClone() const1015cdf0e10cSrcweir SdrObject* SwVirtFlyDrawObj::getFullDragClone() const
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir // call parent
1018cdf0e10cSrcweir return SdrVirtObj::getFullDragClone();
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir
1021cdf0e10cSrcweir // eof
1022