1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 #include <svx/sdr/contact/viewcontactofsdrpage.hxx>
31 #include <svx/sdr/contact/viewobjectcontact.hxx>
32 #include <svx/svdpage.hxx>
33 #include <svx/sdr/contact/displayinfo.hxx>
34 #include <svx/sdr/contact/viewobjectcontactofsdrpage.hxx>
35 #include <basegfx/polygon/b2dpolygontools.hxx>
36 #include <basegfx/matrix/b2dhommatrix.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <svx/svdview.hxx>
39 #include <vcl/svapp.hxx>
40 #include <svx/sdr/contact/objectcontact.hxx>
41 #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
43 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
44 #include <basegfx/polygon/b2dpolygon.hxx>
45 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
46 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
47 #include <vcl/lazydelete.hxx>
48 #include <svx/svdstr.hrc>
49 #include <svx/svdglob.hxx>
50 #include <drawinglayer/primitive2d/discreteshadowprimitive2d.hxx>
51 #include <drawinglayer/attribute/sdrfillattribute.hxx>
52 
53 //////////////////////////////////////////////////////////////////////////////
54 
55 #define PAPER_SHADOW(SIZE) (SIZE >> 8)
56 
57 //////////////////////////////////////////////////////////////////////////////
58 
59 namespace sdr
60 {
61 	namespace contact
62 	{
63 		ViewContactOfPageSubObject::ViewContactOfPageSubObject(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
64 		:	mrParentViewContactOfSdrPage(rParentViewContactOfSdrPage)
65 		{
66 		}
67 
68 		ViewContactOfPageSubObject::~ViewContactOfPageSubObject()
69 		{
70 		}
71 
72 		ViewContact* ViewContactOfPageSubObject::GetParentContact() const
73 		{
74 			return &mrParentViewContactOfSdrPage;
75 		}
76 
77 		const SdrPage& ViewContactOfPageSubObject::getPage() const
78 		{
79 			return mrParentViewContactOfSdrPage.GetSdrPage();
80 		}
81 	} // end of namespace contact
82 } // end of namespace sdr
83 
84 //////////////////////////////////////////////////////////////////////////////
85 
86 namespace sdr
87 {
88 	namespace contact
89 	{
90 		ViewObjectContact& ViewContactOfPageBackground::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
91 		{
92 			ViewObjectContact* pRetval = new ViewObjectContactOfPageBackground(rObjectContact, *this);
93 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
94 
95 			return *pRetval;
96 		}
97 
98 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageBackground::createViewIndependentPrimitive2DSequence() const
99 		{
100 			// We have only the page information, not the view information. Use the
101 			// svtools::DOCCOLOR color for initialisation
102 			const svtools::ColorConfig aColorConfig;
103 			const Color aInitColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
104 			const basegfx::BColor aRGBColor(aInitColor.getBColor());
105 			const drawinglayer::primitive2d::Primitive2DReference xReference(
106                 new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor));
107 
108             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
109 		}
110 
111 		ViewContactOfPageBackground::ViewContactOfPageBackground(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
112 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
113 		{
114 		}
115 
116 		ViewContactOfPageBackground::~ViewContactOfPageBackground()
117 		{
118 		}
119 	} // end of namespace contact
120 } // end of namespace sdr
121 
122 //////////////////////////////////////////////////////////////////////////////
123 
124 namespace sdr
125 {
126 	namespace contact
127 	{
128 		ViewObjectContact& ViewContactOfPageShadow::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
129 		{
130 			ViewObjectContact* pRetval = new ViewObjectContactOfPageShadow(rObjectContact, *this);
131 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
132 
133 			return *pRetval;
134 		}
135 
136 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageShadow::createViewIndependentPrimitive2DSequence() const
137 		{
138             static bool bUseOldPageShadow(false);
139 		    const SdrPage& rPage = getPage();
140 		    basegfx::B2DHomMatrix aPageMatrix;
141 		    aPageMatrix.set(0, 0, (double)rPage.GetWdt());
142 		    aPageMatrix.set(1, 1, (double)rPage.GetHgt());
143 
144             if(bUseOldPageShadow)
145             {
146 			    // create page shadow polygon
147 			    const double fPageBorderFactor(1.0 / 256.0);
148 			    basegfx::B2DPolygon aPageShadowPolygon;
149 			    aPageShadowPolygon.append(basegfx::B2DPoint(1.0, fPageBorderFactor));
150 			    aPageShadowPolygon.append(basegfx::B2DPoint(1.0 + fPageBorderFactor, fPageBorderFactor));
151 			    aPageShadowPolygon.append(basegfx::B2DPoint(1.0 + fPageBorderFactor, 1.0 + fPageBorderFactor));
152 			    aPageShadowPolygon.append(basegfx::B2DPoint(fPageBorderFactor, 1.0 + fPageBorderFactor));
153 			    aPageShadowPolygon.append(basegfx::B2DPoint(fPageBorderFactor, 1.0));
154 			    aPageShadowPolygon.append(basegfx::B2DPoint(1.0, 1.0));
155 			    aPageShadowPolygon.setClosed(true);
156 			    aPageShadowPolygon.transform(aPageMatrix);
157 
158 			    // We have only the page information, not the view information. Use the
159 			    // svtools::FONTCOLOR color for initialisation
160 			    const svtools::ColorConfig aColorConfig;
161 			    const Color aShadowColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
162 			    const basegfx::BColor aRGBShadowColor(aShadowColor.getBColor());
163 			    const drawinglayer::primitive2d::Primitive2DReference xReference(
164                     new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
165                         basegfx::B2DPolyPolygon(aPageShadowPolygon),
166                         aRGBShadowColor));
167 
168                 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
169             }
170             else
171             {
172                 static vcl::DeleteOnDeinit<drawinglayer::primitive2d::DiscreteShadow>
173                     aDiscreteShadow(new drawinglayer::primitive2d::DiscreteShadow(
174                         BitmapEx(ResId(SIP_SA_PAGESHADOW35X35, *ImpGetResMgr()))));
175                 if (aDiscreteShadow.get() != NULL)
176                 {
177                     const drawinglayer::primitive2d::Primitive2DReference xReference(
178                         new drawinglayer::primitive2d::DiscreteShadowPrimitive2D(
179                             aPageMatrix,
180                                 *aDiscreteShadow.get()));
181 
182                     return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
183                 }
184                 return drawinglayer::primitive2d::Primitive2DSequence();
185             }
186 		}
187 
188 		ViewContactOfPageShadow::ViewContactOfPageShadow(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
189 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
190 		{
191 		}
192 
193 		ViewContactOfPageShadow::~ViewContactOfPageShadow()
194 		{
195 		}
196 	} // end of namespace contact
197 } // end of namespace sdr
198 
199 //////////////////////////////////////////////////////////////////////////////
200 
201 namespace sdr
202 {
203 	namespace contact
204 	{
205 		ViewObjectContact& ViewContactOfMasterPage::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
206 		{
207 			ViewObjectContact* pRetval = new ViewObjectContactOfMasterPage(rObjectContact, *this);
208 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
209 
210 			return *pRetval;
211 		}
212 
213 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfMasterPage::createViewIndependentPrimitive2DSequence() const
214 		{
215 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
216 
217 			// this class is used when the page is a MasterPage and is responsible to
218 			// create a visualisation for the MPBGO, if exists. This needs to be suppressed
219 			// when a SdrPage which uses a MasterPage creates it's output. Suppression
220 			// is done in the corresponding VOC since DisplayInfo data is needed
221 			const SdrPage& rPage = getPage();
222 
223 			if(rPage.IsMasterPage())
224 			{
225                 if(0 == rPage.GetPageNum())
226                 {
227                     // #i98063#
228                     // filter MasterPage 0 since it's the HandoutPage. Thus, it's a
229                     // MasterPage, but has no MPBGO, so there is nothing to do here.
230                 }
231                 else
232                 {
233                     drawinglayer::attribute::SdrFillAttribute aFill;
234 
235                     // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets,
236                     // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all
237                     // MasterPages should have a StyleSheet excactly for this reason, but historically
238                     // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others).
239                     if(rPage.getSdrPageProperties().GetStyleSheet())
240                     {
241                         // create page fill attributes with correct properties
242 				        aFill = drawinglayer::primitive2d::createNewSdrFillAttribute(
243                             rPage.getSdrPageProperties().GetItemSet());
244                     }
245 
246 				    if(!aFill.isDefault())
247 				    {
248 					    // direct model data is the page size, get and use it
249 					    const basegfx::B2DRange aInnerRange(
250 						    rPage.GetLftBorder(), rPage.GetUppBorder(),
251 						    rPage.GetWdt() - rPage.GetRgtBorder(), rPage.GetHgt() - rPage.GetLwrBorder());
252 					    const basegfx::B2DPolygon aInnerPolgon(basegfx::tools::createPolygonFromRect(aInnerRange));
253 					    const basegfx::B2DHomMatrix aEmptyTransform;
254 					    const drawinglayer::primitive2d::Primitive2DReference xReference(
255 							drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
256 								basegfx::B2DPolyPolygon(aInnerPolgon),
257 								aEmptyTransform,
258 								aFill,
259 								drawinglayer::attribute::FillGradientAttribute()));
260 
261 					    xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
262 				    }
263                 }
264 			}
265 
266 			return xRetval;
267 		}
268 
269 		ViewContactOfMasterPage::ViewContactOfMasterPage(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
270 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
271 		{
272 		}
273 
274 		ViewContactOfMasterPage::~ViewContactOfMasterPage()
275 		{
276 		}
277 	} // end of namespace contact
278 } // end of namespace sdr
279 
280 //////////////////////////////////////////////////////////////////////////////
281 
282 namespace sdr
283 {
284 	namespace contact
285 	{
286 		ViewObjectContact& ViewContactOfPageFill::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
287 		{
288 			ViewObjectContact* pRetval = new ViewObjectContactOfPageFill(rObjectContact, *this);
289 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
290 
291 			return *pRetval;
292 		}
293 
294 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageFill::createViewIndependentPrimitive2DSequence() const
295 		{
296 			const SdrPage& rPage = getPage();
297 			const basegfx::B2DRange aPageFillRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt());
298 			const basegfx::B2DPolygon aPageFillPolygon(basegfx::tools::createPolygonFromRect(aPageFillRange));
299 
300 			// We have only the page information, not the view information. Use the
301 			// svtools::DOCCOLOR color for initialisation
302 			const svtools::ColorConfig aColorConfig;
303 			const Color aPageFillColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
304 
305 			// create and add primitive
306 			const basegfx::BColor aRGBColor(aPageFillColor.getBColor());
307 			const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon), aRGBColor));
308 
309             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
310 		}
311 
312 		ViewContactOfPageFill::ViewContactOfPageFill(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
313 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
314 		{
315 		}
316 
317 		ViewContactOfPageFill::~ViewContactOfPageFill()
318 		{
319 		}
320 	} // end of namespace contact
321 } // end of namespace sdr
322 
323 //////////////////////////////////////////////////////////////////////////////
324 
325 namespace sdr
326 {
327 	namespace contact
328 	{
329 		ViewObjectContact& ViewContactOfOuterPageBorder::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
330 		{
331 			ViewObjectContact* pRetval = new ViewObjectContactOfOuterPageBorder(rObjectContact, *this);
332 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
333 
334 			return *pRetval;
335 		}
336 
337 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfOuterPageBorder::createViewIndependentPrimitive2DSequence() const
338 		{
339             drawinglayer::primitive2d::Primitive2DSequence xRetval;
340 			const SdrPage& rPage = getPage();
341 			const basegfx::B2DRange aPageBorderRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt());
342 
343             // Changed to 0x949599 for renaissance, before svtools::FONTCOLOR was used.
344             // Added old case as fallback for HighContrast.
345 			basegfx::BColor aRGBBorderColor(0x94 / (double)0xff, 0x95 / (double)0xff, 0x99 / (double)0xff);
346 
347 			if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
348 			{
349     			const svtools::ColorConfig aColorConfig;
350 				const Color aBorderColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
351 
352                 aRGBBorderColor = aBorderColor.getBColor();
353 			}
354 
355             if(rPage.getPageBorderOnlyLeftRight())
356             {
357                 // #i93597# for Report Designer, the page border shall be only displayed right and left,
358                 // but not top and bottom. Create simplified geometry.
359                 basegfx::B2DPolygon aLeft, aRight;
360 
361                 aLeft.append(basegfx::B2DPoint(aPageBorderRange.getMinX(), aPageBorderRange.getMinY()));
362                 aLeft.append(basegfx::B2DPoint(aPageBorderRange.getMinX(), aPageBorderRange.getMaxY()));
363 
364                 aRight.append(basegfx::B2DPoint(aPageBorderRange.getMaxX(), aPageBorderRange.getMinY()));
365                 aRight.append(basegfx::B2DPoint(aPageBorderRange.getMaxX(), aPageBorderRange.getMaxY()));
366 
367                 xRetval.realloc(2);
368                 xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aLeft, aRGBBorderColor));
369                 xRetval[1] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aRight, aRGBBorderColor));
370             }
371             else
372             {
373                 xRetval.realloc(1);
374                 const basegfx::B2DPolygon aPageBorderPolygon(basegfx::tools::createPolygonFromRect(aPageBorderRange));
375                 xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPageBorderPolygon, aRGBBorderColor));
376             }
377 
378             return xRetval;
379 		}
380 
381 		ViewContactOfOuterPageBorder::ViewContactOfOuterPageBorder(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
382 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
383 		{
384 		}
385 
386 		ViewContactOfOuterPageBorder::~ViewContactOfOuterPageBorder()
387 		{
388 		}
389 	} // end of namespace contact
390 } // end of namespace sdr
391 
392 //////////////////////////////////////////////////////////////////////////////
393 
394 namespace sdr
395 {
396 	namespace contact
397 	{
398 		ViewObjectContact& ViewContactOfInnerPageBorder::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
399 		{
400 			ViewObjectContact* pRetval = new ViewObjectContactOfInnerPageBorder(rObjectContact, *this);
401 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
402 
403 			return *pRetval;
404 		}
405 
406 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfInnerPageBorder::createViewIndependentPrimitive2DSequence() const
407 		{
408 			const SdrPage& rPage = getPage();
409 			const basegfx::B2DRange aPageBorderRange(
410 				(double)rPage.GetLftBorder(), (double)rPage.GetUppBorder(),
411 				(double)(rPage.GetWdt() - rPage.GetRgtBorder()), (double)(rPage.GetHgt() - rPage.GetLwrBorder()));
412 			const basegfx::B2DPolygon aPageBorderPolygon(basegfx::tools::createPolygonFromRect(aPageBorderRange));
413 
414 			// We have only the page information, not the view information. Use the
415 			// svtools::FONTCOLOR or svtools::DOCBOUNDARIES color for initialisation
416 			const svtools::ColorConfig aColorConfig;
417 			Color aBorderColor;
418 
419 			if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
420 			{
421 				aBorderColor = aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor;
422 			}
423 			else
424 			{
425 				aBorderColor = aColorConfig.GetColorValue(svtools::DOCBOUNDARIES).nColor;
426 			}
427 
428 			// create page outer border primitive
429 			const basegfx::BColor aRGBBorderColor(aBorderColor.getBColor());
430 			const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPageBorderPolygon, aRGBBorderColor));
431 
432             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
433 		}
434 
435 		ViewContactOfInnerPageBorder::ViewContactOfInnerPageBorder(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
436 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
437 		{
438 		}
439 
440 		ViewContactOfInnerPageBorder::~ViewContactOfInnerPageBorder()
441 		{
442 		}
443 	} // end of namespace contact
444 } // end of namespace sdr
445 
446 //////////////////////////////////////////////////////////////////////////////
447 
448 namespace sdr
449 {
450 	namespace contact
451 	{
452 		ViewObjectContact& ViewContactOfPageHierarchy::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
453 		{
454 			ViewObjectContact* pRetval = new ViewObjectContactOfPageHierarchy(rObjectContact, *this);
455 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
456 
457 			return *pRetval;
458 		}
459 
460 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageHierarchy::createViewIndependentPrimitive2DSequence() const
461 		{
462 			// collect sub-hierarchy
463 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
464 			const sal_uInt32 nObjectCount(GetObjectCount());
465 
466 			// collect all sub-primitives
467 			for(sal_uInt32 a(0); a < nObjectCount; a++)
468 			{
469 				const ViewContact& rCandidate(GetViewContact(a));
470 				const drawinglayer::primitive2d::Primitive2DSequence aCandSeq(rCandidate.getViewIndependentPrimitive2DSequence());
471 
472 				drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aCandSeq);
473 			}
474 
475 			return xRetval;
476 		}
477 
478 		ViewContactOfPageHierarchy::ViewContactOfPageHierarchy(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
479 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
480 		{
481 		}
482 
483 		ViewContactOfPageHierarchy::~ViewContactOfPageHierarchy()
484 		{
485 		}
486 
487 		sal_uInt32 ViewContactOfPageHierarchy::GetObjectCount() const
488 		{
489 			return getPage().GetObjCount();
490 		}
491 
492 		ViewContact& ViewContactOfPageHierarchy::GetViewContact(sal_uInt32 nIndex) const
493 		{
494 			SdrObject* pObj = getPage().GetObj(nIndex);
495 			DBG_ASSERT(pObj, "ViewContactOfPageHierarchy::GetViewContact: Corrupt SdrObjList (!)");
496 			return pObj->GetViewContact();
497 		}
498 	} // end of namespace contact
499 } // end of namespace sdr
500 
501 //////////////////////////////////////////////////////////////////////////////
502 
503 namespace sdr
504 {
505 	namespace contact
506 	{
507 		ViewObjectContact& ViewContactOfGrid::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
508 		{
509 			ViewObjectContact* pRetval = new ViewObjectContactOfPageGrid(rObjectContact, *this);
510 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
511 
512 			return *pRetval;
513 		}
514 
515 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGrid::createViewIndependentPrimitive2DSequence() const
516 		{
517 			// We have only the page information, not the view information and thus no grid settings. Create empty
518 			// default. For the view-dependent implementation, see ViewObjectContactOfPageGrid::createPrimitive2DSequence
519             return drawinglayer::primitive2d::Primitive2DSequence();
520 		}
521 
522 		ViewContactOfGrid::ViewContactOfGrid(ViewContactOfSdrPage& rParentViewContactOfSdrPage, bool bFront)
523 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage),
524 			mbFront(bFront)
525 		{
526 		}
527 
528 		ViewContactOfGrid::~ViewContactOfGrid()
529 		{
530 		}
531 	} // end of namespace contact
532 } // end of namespace sdr
533 
534 //////////////////////////////////////////////////////////////////////////////
535 
536 namespace sdr
537 {
538 	namespace contact
539 	{
540 		ViewObjectContact& ViewContactOfHelplines::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
541 		{
542 			ViewObjectContact* pRetval = new ViewObjectContactOfPageHelplines(rObjectContact, *this);
543 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
544 
545 			return *pRetval;
546 		}
547 
548 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfHelplines::createViewIndependentPrimitive2DSequence() const
549 		{
550 			// We have only the page information, not the view information and thus no helplines. Create empty
551 			// default. For the view-dependent implementation, see ViewObjectContactOfPageHelplines::createPrimitive2DSequence
552             return drawinglayer::primitive2d::Primitive2DSequence();
553 		}
554 
555 		ViewContactOfHelplines::ViewContactOfHelplines(ViewContactOfSdrPage& rParentViewContactOfSdrPage, bool bFront)
556 		:	ViewContactOfPageSubObject(rParentViewContactOfSdrPage),
557 			mbFront(bFront)
558 		{
559 		}
560 
561 		ViewContactOfHelplines::~ViewContactOfHelplines()
562 		{
563 		}
564 	} // end of namespace contact
565 } // end of namespace sdr
566 
567 //////////////////////////////////////////////////////////////////////////////
568 
569 namespace sdr
570 {
571 	namespace contact
572 	{
573 		// Create a Object-Specific ViewObjectContact, set ViewContact and
574 		// ObjectContact. Always needs to return something.
575 		ViewObjectContact& ViewContactOfSdrPage::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
576 		{
577 			ViewObjectContact* pRetval = new ViewObjectContactOfSdrPage(rObjectContact, *this);
578 			DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
579 
580 			return *pRetval;
581 		}
582 
583 		ViewContactOfSdrPage::ViewContactOfSdrPage(SdrPage& rPage)
584 		:	ViewContact(),
585 			mrPage(rPage),
586 			maViewContactOfPageBackground(*this),
587 			maViewContactOfPageShadow(*this),
588 			maViewContactOfPageFill(*this),
589 			maViewContactOfMasterPage(*this),
590 			maViewContactOfOuterPageBorder(*this),
591 			maViewContactOfInnerPageBorder(*this),
592 			maViewContactOfGridBack(*this, false),
593 			maViewContactOfHelplinesBack(*this, false),
594 			maViewContactOfPageHierarchy(*this),
595 			maViewContactOfGridFront(*this, true),
596 			maViewContactOfHelplinesFront(*this, true)
597 		{
598 		}
599 
600 		ViewContactOfSdrPage::~ViewContactOfSdrPage()
601 		{
602 		}
603 
604 		// Access to possible sub-hierarchy
605 		sal_uInt32 ViewContactOfSdrPage::GetObjectCount() const
606 		{
607 			// Fixed count of content. It contains PageBackground (Wiese), PageShadow, PageFill,
608 			// then - depending on if the page has a MasterPage - either MasterPage Hierarchy
609 			// or MPBGO. Also OuterPageBorder, InnerPageBorder and two pairs of Grid and Helplines
610 			// (for front and back) which internally are visible or not depending on the current
611 			// front/back setting for those.
612 			return 11;
613 		}
614 
615 		ViewContact& ViewContactOfSdrPage::GetViewContact(sal_uInt32 nIndex) const
616 		{
617 			switch(nIndex)
618 			{
619 				case 0: return (ViewContact&)maViewContactOfPageBackground;
620 				case 1: return (ViewContact&)maViewContactOfPageShadow;
621 				case 2: return (ViewContact&)maViewContactOfPageFill;
622 				case 3:
623 				{
624 					const SdrPage& rPage = GetSdrPage();
625 
626 					if(rPage.TRG_HasMasterPage())
627 					{
628 						return rPage.TRG_GetMasterPageDescriptorViewContact();
629 					}
630 					else
631 					{
632 						return (ViewContact&)maViewContactOfMasterPage;
633 					}
634 				}
635 				case 4: return (ViewContact&)maViewContactOfOuterPageBorder;
636 				case 5: return (ViewContact&)maViewContactOfInnerPageBorder;
637 				case 6: return (ViewContact&)maViewContactOfGridBack;
638 				case 7: return (ViewContact&)maViewContactOfHelplinesBack;
639 				case 8: return (ViewContact&)maViewContactOfPageHierarchy;
640 				case 9: return (ViewContact&)maViewContactOfGridFront;
641 				default: return (ViewContact&)maViewContactOfHelplinesFront;
642 			}
643 		}
644 
645 		// React on changes of the object of this ViewContact
646 		void ViewContactOfSdrPage::ActionChanged()
647 		{
648 			// call parent
649 			ViewContact::ActionChanged();
650 
651 			// apply to local viewContacts, they all rely on page information. Exception
652 			// is the sub hierarchy; this will not be influenced by the change
653 			maViewContactOfPageBackground.ActionChanged();
654 			maViewContactOfPageShadow.ActionChanged();
655 			maViewContactOfPageFill.ActionChanged();
656 
657 			const SdrPage& rPage = GetSdrPage();
658 
659 			if(rPage.TRG_HasMasterPage())
660 			{
661 				rPage.TRG_GetMasterPageDescriptorViewContact().ActionChanged();
662 			}
663 			else if(rPage.IsMasterPage())
664 			{
665 				maViewContactOfMasterPage.ActionChanged();
666 			}
667 
668 			maViewContactOfOuterPageBorder.ActionChanged();
669 			maViewContactOfInnerPageBorder.ActionChanged();
670 			maViewContactOfGridBack.ActionChanged();
671 			maViewContactOfHelplinesBack.ActionChanged();
672 			maViewContactOfGridFront.ActionChanged();
673 			maViewContactOfHelplinesFront.ActionChanged();
674 		}
675 
676 		// overload for acessing the SdrPage
677 		SdrPage* ViewContactOfSdrPage::TryToGetSdrPage() const
678 		{
679 			return &GetSdrPage();
680 		}
681 
682 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrPage::createViewIndependentPrimitive2DSequence() const
683 		{
684 			drawinglayer::primitive2d::Primitive2DSequence xRetval;
685 
686 			// collect all sub-sequences including sub hierarchy.
687 			drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageBackground.getViewIndependentPrimitive2DSequence());
688 			drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageShadow.getViewIndependentPrimitive2DSequence());
689 			drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageFill.getViewIndependentPrimitive2DSequence());
690 
691 			const SdrPage& rPage = GetSdrPage();
692 
693 			if(rPage.TRG_HasMasterPage())
694 			{
695 				drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval,
696 					rPage.TRG_GetMasterPageDescriptorViewContact().getViewIndependentPrimitive2DSequence());
697 			}
698 			else if(rPage.IsMasterPage())
699 			{
700 				drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval,
701 					maViewContactOfMasterPage.getViewIndependentPrimitive2DSequence());
702 			}
703 
704 			drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfOuterPageBorder.getViewIndependentPrimitive2DSequence());
705 			drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfInnerPageBorder.getViewIndependentPrimitive2DSequence());
706 			drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageHierarchy.getViewIndependentPrimitive2DSequence());
707 
708 			// Only add front versions of grid and helplines since no visibility test is done,
709 			// so adding the back incarnations is not necessary. This makes the Front
710 			// visualisation the default when no visibility tests are done.
711 			//
712 			// Since we have no view here, no grid and helpline definitions are available currently. The used
713 			// methods at ViewContactOfHelplines and ViewContactOfGrid return only empty sequences and
714 			// do not need to be called ATM. This may change later if grid or helpline info gets
715 			// model data (it should not). Keeping the lines commented to hold this hint.
716 			//
717 			// drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfGridFront.getViewIndependentPrimitive2DSequence());
718 			// drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfHelplinesFront.getViewIndependentPrimitive2DSequence());
719 
720 			return xRetval;
721 		}
722 	} // end of namespace contact
723 } // end of namespace sdr
724 
725 //////////////////////////////////////////////////////////////////////////////
726 // eof
727