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