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 "tablehandles.hxx"
31 : :
32 : : #include <vcl/svapp.hxx>
33 : : #include <vcl/outdev.hxx>
34 : : #include <vcl/canvastools.hxx>
35 : : #include <vcl/hatch.hxx>
36 : : #include <basegfx/polygon/b2dpolygon.hxx>
37 : : #include <basegfx/polygon/b2dpolypolygontools.hxx>
38 : : #include <basegfx/range/b2drectangle.hxx>
39 : : #include <basegfx/polygon/b2dpolygontools.hxx>
40 : : #include <svx/sdr/overlay/overlayobject.hxx>
41 : : #include <svx/sdr/overlay/overlaymanager.hxx>
42 : : #include <svx/sdrpagewindow.hxx>
43 : : #include <svx/sdrpaintwindow.hxx>
44 : : #include <svx/svdmrkv.hxx>
45 : : #include <svx/svdpagv.hxx>
46 : : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
47 : : #include <svx/sdr/overlay/overlayhatchrect.hxx>
48 : : #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
49 : :
50 : : namespace sdr { namespace table {
51 : :
52 : : // --------------------------------------------------------------------
53 : :
54 : : class OverlayTableEdge : public sdr::overlay::OverlayObject
55 : : {
56 : : protected:
57 : : basegfx::B2DPolyPolygon maPolyPolygon;
58 : : bool mbVisible;
59 : :
60 : : // geometry creation for OverlayObject
61 : : virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
62 : :
63 : : public:
64 : : OverlayTableEdge( const basegfx::B2DPolyPolygon& rPolyPolygon, bool bVisible );
65 : : virtual ~OverlayTableEdge();
66 : : };
67 : :
68 : : // --------------------------------------------------------------------
69 : :
70 : 0 : TableEdgeHdl::TableEdgeHdl( const Point& rPnt, bool bHorizontal, sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nEdges )
71 : : : SdrHdl( rPnt, HDL_USER )
72 : : , mbHorizontal( bHorizontal )
73 : : , mnMin( nMin )
74 : : , mnMax( nMax )
75 [ # # ]: 0 : , maEdges(nEdges)
76 : : {
77 : 0 : }
78 : :
79 : 0 : void TableEdgeHdl::SetEdge( sal_Int32 nEdge, sal_Int32 nStart, sal_Int32 nEnd, TableEdgeState eState )
80 : : {
81 [ # # ][ # # ]: 0 : if( (nEdge >= 0) && (nEdge <= sal::static_int_cast<sal_Int32>(maEdges.size())) )
[ # # ]
82 : : {
83 : 0 : maEdges[nEdge].mnStart = nStart;
84 : 0 : maEdges[nEdge].mnEnd = nEnd;
85 : 0 : maEdges[nEdge].meState = eState;
86 : : }
87 : : else
88 : : {
89 : : OSL_FAIL( "sdr::table::TableEdgeHdl::SetEdge(), invalid edge!" );
90 : : }
91 : 0 : }
92 : :
93 : 0 : Pointer TableEdgeHdl::GetPointer() const
94 : : {
95 [ # # ]: 0 : if( mbHorizontal )
96 : 0 : return POINTER_VSPLIT;
97 : : else
98 : 0 : return POINTER_HSPLIT;
99 : : }
100 : :
101 : 0 : sal_Int32 TableEdgeHdl::GetValidDragOffset( const SdrDragStat& rDrag ) const
102 : : {
103 [ # # ][ # # ]: 0 : return std::min( std::max( static_cast<sal_Int32>(mbHorizontal ? rDrag.GetDY() : rDrag.GetDX()), mnMin ), mnMax );
[ # # ]
104 : : }
105 : :
106 : 0 : basegfx::B2DPolyPolygon TableEdgeHdl::getSpecialDragPoly(const SdrDragStat& rDrag) const
107 : : {
108 [ # # ]: 0 : basegfx::B2DPolyPolygon aVisible;
109 [ # # ]: 0 : basegfx::B2DPolyPolygon aInvisible;
110 : :
111 : : // create and return visible and non-visible parts for drag
112 [ # # ]: 0 : getPolyPolygon(aVisible, aInvisible, &rDrag);
113 [ # # ]: 0 : aVisible.append(aInvisible);
114 : :
115 [ # # ]: 0 : return aVisible;
116 : : }
117 : :
118 : 0 : void TableEdgeHdl::getPolyPolygon(basegfx::B2DPolyPolygon& rVisible, basegfx::B2DPolyPolygon& rInvisible, const SdrDragStat* pDrag) const
119 : : {
120 : : // changed method to create visible and invisible partial polygons in one run in
121 : : // separate PolyPolygons; both kinds are used
122 : 0 : basegfx::B2DPoint aOffset(aPos.X(), aPos.Y());
123 [ # # ]: 0 : rVisible.clear();
124 [ # # ]: 0 : rInvisible.clear();
125 : :
126 [ # # ]: 0 : if( pDrag )
127 : : {
128 [ # # ]: 0 : int n = mbHorizontal ? 1 : 0;
129 [ # # ]: 0 : aOffset[n] = aOffset[n] + GetValidDragOffset( *pDrag );
130 : : }
131 : :
132 : 0 : basegfx::B2DPoint aStart(aOffset), aEnd(aOffset);
133 [ # # ]: 0 : int nPos = mbHorizontal ? 0 : 1;
134 : 0 : TableEdgeVector::const_iterator aIter( maEdges.begin() );
135 : :
136 [ # # ][ # # ]: 0 : while( aIter != maEdges.end() )
137 : : {
138 [ # # ]: 0 : TableEdge aEdge(*aIter++);
139 : :
140 : 0 : aStart[nPos] = aOffset[nPos] + aEdge.mnStart;
141 : 0 : aEnd[nPos] = aOffset[nPos] + aEdge.mnEnd;
142 : :
143 [ # # ]: 0 : basegfx::B2DPolygon aPolygon;
144 [ # # ]: 0 : aPolygon.append( aStart );
145 [ # # ]: 0 : aPolygon.append( aEnd );
146 : :
147 [ # # ]: 0 : if(aEdge.meState == Visible)
148 : : {
149 [ # # ]: 0 : rVisible.append(aPolygon);
150 : : }
151 : : else
152 : : {
153 [ # # ]: 0 : rInvisible.append(aPolygon);
154 : : }
155 [ # # ]: 0 : }
156 : 0 : }
157 : :
158 : 0 : void TableEdgeHdl::CreateB2dIAObject()
159 : : {
160 : 0 : GetRidOfIAObject();
161 : :
162 [ # # ][ # # ]: 0 : if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())
[ # # ][ # # ]
163 : : {
164 : 0 : SdrMarkView* pView = pHdlList->GetView();
165 : 0 : SdrPageView* pPageView = pView->GetSdrPageView();
166 : :
167 [ # # ]: 0 : if(pPageView)
168 : : {
169 [ # # ]: 0 : basegfx::B2DPolyPolygon aVisible;
170 [ # # ]: 0 : basegfx::B2DPolyPolygon aInvisible;
171 : :
172 : : // get visible and invisible parts
173 [ # # ]: 0 : getPolyPolygon(aVisible, aInvisible, 0);
174 : :
175 [ # # ][ # # ]: 0 : if(aVisible.count() || aInvisible.count())
[ # # ][ # # ]
[ # # ]
176 : : {
177 [ # # ]: 0 : for(sal_uInt32 nWindow = 0; nWindow < pPageView->PageWindowCount(); nWindow++)
178 : : {
179 [ # # ]: 0 : const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(nWindow);
180 : :
181 [ # # ]: 0 : if(rPageWindow.GetPaintWindow().OutputToWindow())
182 : : {
183 [ # # ]: 0 : rtl::Reference< ::sdr::overlay::OverlayManager > xManager = rPageWindow.GetOverlayManager();
184 [ # # ]: 0 : if (xManager.is())
185 : : {
186 [ # # ][ # # ]: 0 : if(aVisible.count())
187 : : {
188 : : // create overlay object for visible parts
189 [ # # ][ # # ]: 0 : sdr::overlay::OverlayObject* pOverlayObject = new OverlayTableEdge(aVisible, true);
190 [ # # ]: 0 : xManager->add(*pOverlayObject);
191 [ # # ]: 0 : maOverlayGroup.append(*pOverlayObject);
192 : : }
193 : :
194 [ # # ][ # # ]: 0 : if(aInvisible.count())
195 : : {
196 : : // also create overlay object vor invisible parts to allow
197 : : // a standard HitTest using the primitives from that overlay object
198 : : // (see OverlayTableEdge implementation)
199 [ # # ][ # # ]: 0 : sdr::overlay::OverlayObject* pOverlayObject = new OverlayTableEdge(aInvisible, false);
200 [ # # ]: 0 : xManager->add(*pOverlayObject);
201 [ # # ]: 0 : maOverlayGroup.append(*pOverlayObject);
202 : : }
203 [ # # ]: 0 : }
204 : : }
205 : : }
206 [ # # ][ # # ]: 0 : }
207 : : }
208 : : }
209 : 0 : }
210 : :
211 : : //////////////////////////////////////////////////////////////////////////////
212 : :
213 : 0 : OverlayTableEdge::OverlayTableEdge( const basegfx::B2DPolyPolygon& rPolyPolygon, bool bVisible )
214 : : : OverlayObject(Color(COL_GRAY))
215 : : , maPolyPolygon( rPolyPolygon )
216 [ # # ][ # # ]: 0 : , mbVisible(bVisible)
217 : : {
218 : 0 : }
219 : :
220 [ # # ]: 0 : OverlayTableEdge::~OverlayTableEdge()
221 : : {
222 [ # # ]: 0 : }
223 : :
224 : 0 : drawinglayer::primitive2d::Primitive2DSequence OverlayTableEdge::createOverlayObjectPrimitive2DSequence()
225 : : {
226 : 0 : drawinglayer::primitive2d::Primitive2DSequence aRetval;
227 : :
228 [ # # ][ # # ]: 0 : if(maPolyPolygon.count())
229 : : {
230 : : // Discussed with CL. Currently i will leave the transparence out since this
231 : : // a little bit expensive. We may check the look with drag polygons later
232 : : const drawinglayer::primitive2d::Primitive2DReference aReference(
233 : : new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D(
234 : : maPolyPolygon,
235 [ # # ][ # # ]: 0 : getBaseColor().getBColor()));
[ # # ]
236 : :
237 [ # # ]: 0 : if(mbVisible)
238 : : {
239 : : // visible, just return as sequence
240 [ # # ][ # # ]: 0 : aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
[ # # ]
241 : : }
242 : : else
243 : : {
244 : : // embed in HiddenGeometryPrimitive2D to support HitTest of this invisible
245 : : // overlay object
246 [ # # ]: 0 : const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aReference, 1);
247 : : const drawinglayer::primitive2d::Primitive2DReference aNewReference(
248 [ # # ][ # # ]: 0 : new drawinglayer::primitive2d::HiddenGeometryPrimitive2D(aSequence));
[ # # ]
249 [ # # ][ # # ]: 0 : aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aNewReference, 1);
[ # # ][ # # ]
250 : 0 : }
251 : : }
252 : :
253 : 0 : return aRetval;
254 : : }
255 : :
256 : : // ====================================================================
257 : :
258 : 0 : TableBorderHdl::TableBorderHdl( const Rectangle& rRect )
259 : : : SdrHdl( rRect.TopLeft(), HDL_MOVE )
260 [ # # ]: 0 : , maRectangle( rRect )
261 : : {
262 : :
263 : 0 : }
264 : :
265 : 0 : Pointer TableBorderHdl::GetPointer() const
266 : : {
267 : 0 : return POINTER_MOVE;
268 : : }
269 : :
270 : : // create marker for this kind
271 : 0 : void TableBorderHdl::CreateB2dIAObject()
272 : : {
273 : 0 : GetRidOfIAObject();
274 : :
275 [ # # ][ # # ]: 0 : if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())
[ # # ][ # # ]
276 : : {
277 : 0 : SdrMarkView* pView = pHdlList->GetView();
278 : 0 : SdrPageView* pPageView = pView->GetSdrPageView();
279 : :
280 [ # # ]: 0 : if(pPageView)
281 : : {
282 [ # # ]: 0 : for(sal_uInt32 nWindow = 0; nWindow < pPageView->PageWindowCount(); nWindow++)
283 : : {
284 : : // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
285 : 0 : const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(nWindow);
286 : :
287 [ # # ]: 0 : if(rPageWindow.GetPaintWindow().OutputToWindow())
288 : : {
289 [ # # ]: 0 : rtl::Reference< ::sdr::overlay::OverlayManager > xManager = rPageWindow.GetOverlayManager();
290 [ # # ]: 0 : if (xManager.is())
291 : : {
292 [ # # ]: 0 : const basegfx::B2DRange aRange(vcl::unotools::b2DRectangleFromRectangle(maRectangle));
293 : : sdr::overlay::OverlayObject* pOverlayObject = new sdr::overlay::OverlayHatchRect(
294 : : aRange.getMinimum(),
295 : : aRange.getMaximum(),
296 : : Color(0x80, 0x80, 0x80),
297 : : 6.0,
298 : : 0.0,
299 : : 45 * F_PI180,
300 [ # # ][ # # ]: 0 : 0.0);
[ # # ][ # # ]
301 : :
302 [ # # ]: 0 : xManager->add(*pOverlayObject);
303 [ # # ]: 0 : maOverlayGroup.append(*pOverlayObject);
304 [ # # ]: 0 : }
305 : : }
306 : : }
307 : : }
308 : : }
309 : 0 : }
310 : :
311 : : //////////////////////////////////////////////////////////////////////////////
312 : :
313 : : } // end of namespace table
314 : : } // end of namespace sdr
315 : :
316 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|