Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
31 : : #include <svx/svdoole2.hxx>
32 : : #include <svx/sdr/contact/viewobjectcontactofsdrole2obj.hxx>
33 : : #include <basegfx/matrix/b2dhommatrix.hxx>
34 : : #include <svx/sdr/primitive2d/sdrole2primitive2d.hxx>
35 : : #include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
36 : : #include <basegfx/polygon/b2dpolygontools.hxx>
37 : : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
38 : : #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
39 : : #include <svtools/colorcfg.hxx>
40 : : #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
41 : : #include <vcl/svapp.hxx>
42 : : #include <svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx>
43 : : #include <basegfx/matrix/b2dhommatrixtools.hxx>
44 : :
45 : : //////////////////////////////////////////////////////////////////////////////
46 : :
47 : : namespace sdr
48 : : {
49 : : namespace contact
50 : : {
51 : : // Create a Object-Specific ViewObjectContact, set ViewContact and
52 : : // ObjectContact. Always needs to return something.
53 : 12 : ViewObjectContact& ViewContactOfSdrOle2Obj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
54 : : {
55 [ + - ]: 12 : ViewObjectContact* pRetval = new ViewObjectContactOfSdrOle2Obj(rObjectContact, *this);
56 : : DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
57 : :
58 : 12 : return *pRetval;
59 : : }
60 : :
61 : 27 : ViewContactOfSdrOle2Obj::ViewContactOfSdrOle2Obj(SdrOle2Obj& rOle2Obj)
62 : 27 : : ViewContactOfSdrRectObj(rOle2Obj)
63 : : {
64 : 27 : }
65 : :
66 : 27 : ViewContactOfSdrOle2Obj::~ViewContactOfSdrOle2Obj()
67 : : {
68 [ - + ]: 54 : }
69 : :
70 : 181 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createPrimitive2DSequenceWithParameters() const
71 : : {
72 : : // take unrotated snap rect (direct model data) for position and size
73 : 181 : const Rectangle& rRectangle = GetOle2Obj().GetGeoRect();
74 [ + - ]: 181 : const basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
75 : :
76 : : // create object matrix
77 : 181 : const GeoStat& rGeoStat(GetOle2Obj().GetGeoStat());
78 [ - + ]: 181 : const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
79 [ - + ]: 181 : const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
80 : : const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
81 : : aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate,
82 [ + - ][ + - ]: 181 : aObjectRange.getMinX(), aObjectRange.getMinY()));
[ + - ][ + - ]
[ + - ]
83 : :
84 : : // Prepare attribute settings, will be used soon anyways
85 [ + - ]: 181 : const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet();
86 : : const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
87 : : drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
88 : : rItemSet,
89 [ + - ][ + - ]: 181 : GetOle2Obj().getText(0)));
90 : :
91 : : // #i102063# embed OLE content in an own primitive; this will be able to decompose accessing
92 : : // the weak SdrOle2 reference and will also implement getB2DRange() for fast BoundRect
93 : : // calculations without OLE Graphic access (which may trigger e.g. chart recalculation).
94 : : // It will also take care of HighContrast and ScaleContent
95 : : const drawinglayer::primitive2d::Primitive2DReference xOleContent(
96 : : new drawinglayer::primitive2d::SdrOleContentPrimitive2D(
97 : : GetOle2Obj(),
98 : : aObjectMatrix,
99 : :
100 : : // #i104867# add GraphicVersion number to be able to check for
101 : : // content change in the primitive later
102 : 181 : GetOle2Obj().getEmbeddedObjectRef().getGraphicVersion()
103 [ + - ][ + - ]: 362 : ));
[ + - ][ + - ]
104 : :
105 : : // create primitive. Use Ole2 primitive here. Prepare attribute settings, will
106 : : // be used soon anyways. Always create primitives to allow the decomposition of
107 : : // SdrOle2Primitive2D to create needed invisible elements for HitTest and/or BoundRect
108 [ + - ]: 181 : const drawinglayer::primitive2d::Primitive2DSequence xOLEContent(&xOleContent, 1);
109 : : const drawinglayer::primitive2d::Primitive2DReference xReference(
110 : : new drawinglayer::primitive2d::SdrOle2Primitive2D(
111 : : xOLEContent,
112 : : aObjectMatrix,
113 [ + - ][ + - ]: 181 : aAttribute));
[ + - ]
114 : :
115 [ + - ][ + - ]: 181 : return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
[ + - ][ + - ]
116 : : }
117 : :
118 : 19 : drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createViewIndependentPrimitive2DSequence() const
119 : : {
120 : 19 : return createPrimitive2DSequenceWithParameters();
121 : : }
122 : : } // end of namespace contact
123 : : } // end of namespace sdr
124 : :
125 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|