xref: /AOO41X/main/svx/source/sdr/contact/viewcontactofsdrpage.cxx (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
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     {
ViewContactOfPageSubObject(ViewContactOfSdrPage & rParentViewContactOfSdrPage)59         ViewContactOfPageSubObject::ViewContactOfPageSubObject(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
60         :   mrParentViewContactOfSdrPage(rParentViewContactOfSdrPage)
61         {
62         }
63 
~ViewContactOfPageSubObject()64         ViewContactOfPageSubObject::~ViewContactOfPageSubObject()
65         {
66         }
67 
GetParentContact() const68         ViewContact* ViewContactOfPageSubObject::GetParentContact() const
69         {
70             return &mrParentViewContactOfSdrPage;
71         }
72 
getPage() const73         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     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)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 
createViewIndependentPrimitive2DSequence() const94         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 
ViewContactOfPageBackground(ViewContactOfSdrPage & rParentViewContactOfSdrPage)107         ViewContactOfPageBackground::ViewContactOfPageBackground(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
108         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
109         {
110         }
111 
~ViewContactOfPageBackground()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     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)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 
createViewIndependentPrimitive2DSequence() const132         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 > aDiscreteShadow(
169                     new drawinglayer::primitive2d::DiscreteShadow(
170                         BitmapEx(
171                             ResId(
172                                 SIP_SA_PAGESHADOW35X35,
173                                 *ImpGetResMgr()))));
174 
175                 if(aDiscreteShadow.get())
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 
185                 return drawinglayer::primitive2d::Primitive2DSequence();
186             }
187         }
188 
ViewContactOfPageShadow(ViewContactOfSdrPage & rParentViewContactOfSdrPage)189         ViewContactOfPageShadow::ViewContactOfPageShadow(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
190         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
191         {
192         }
193 
~ViewContactOfPageShadow()194         ViewContactOfPageShadow::~ViewContactOfPageShadow()
195         {
196         }
197     } // end of namespace contact
198 } // end of namespace sdr
199 
200 //////////////////////////////////////////////////////////////////////////////
201 
202 namespace sdr
203 {
204     namespace contact
205     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)206         ViewObjectContact& ViewContactOfMasterPage::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
207         {
208             ViewObjectContact* pRetval = new ViewObjectContactOfMasterPage(rObjectContact, *this);
209             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
210 
211             return *pRetval;
212         }
213 
createViewIndependentPrimitive2DSequence() const214         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfMasterPage::createViewIndependentPrimitive2DSequence() const
215         {
216             drawinglayer::primitive2d::Primitive2DSequence xRetval;
217 
218             // this class is used when the page is a MasterPage and is responsible to
219             // create a visualisation for the MPBGO, if exists. This needs to be suppressed
220             // when a SdrPage which uses a MasterPage creates it's output. Suppression
221             // is done in the corresponding VOC since DisplayInfo data is needed
222             const SdrPage& rPage = getPage();
223 
224             if(rPage.IsMasterPage())
225             {
226                 if(0 == rPage.GetPageNum())
227                 {
228                     // #i98063#
229                     // filter MasterPage 0 since it's the HandoutPage. Thus, it's a
230                     // MasterPage, but has no MPBGO, so there is nothing to do here.
231                 }
232                 else
233                 {
234                     drawinglayer::attribute::SdrFillAttribute aFill;
235 
236                     // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets,
237                     // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all
238                     // MasterPages should have a StyleSheet excactly for this reason, but historically
239                     // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others).
240                     if(rPage.getSdrPageProperties().GetStyleSheet())
241                     {
242                         // create page fill attributes with correct properties
243                         aFill = drawinglayer::primitive2d::createNewSdrFillAttribute(
244                             rPage.getSdrPageProperties().GetItemSet());
245                     }
246 
247                     if(!aFill.isDefault())
248                     {
249                         // direct model data is the page size, get and use it
250                         const basegfx::B2DRange aInnerRange(
251                             rPage.GetLftBorder(), rPage.GetUppBorder(),
252                             rPage.GetWdt() - rPage.GetRgtBorder(), rPage.GetHgt() - rPage.GetLwrBorder());
253                         const basegfx::B2DPolygon aInnerPolgon(basegfx::tools::createPolygonFromRect(aInnerRange));
254                         const basegfx::B2DHomMatrix aEmptyTransform;
255                         const drawinglayer::primitive2d::Primitive2DReference xReference(
256                             drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
257                                 basegfx::B2DPolyPolygon(aInnerPolgon),
258                                 aEmptyTransform,
259                                 aFill,
260                                 drawinglayer::attribute::FillGradientAttribute()));
261 
262                         xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
263                     }
264                 }
265             }
266 
267             return xRetval;
268         }
269 
ViewContactOfMasterPage(ViewContactOfSdrPage & rParentViewContactOfSdrPage)270         ViewContactOfMasterPage::ViewContactOfMasterPage(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
271         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
272         {
273         }
274 
~ViewContactOfMasterPage()275         ViewContactOfMasterPage::~ViewContactOfMasterPage()
276         {
277         }
278     } // end of namespace contact
279 } // end of namespace sdr
280 
281 //////////////////////////////////////////////////////////////////////////////
282 
283 namespace sdr
284 {
285     namespace contact
286     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)287         ViewObjectContact& ViewContactOfPageFill::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
288         {
289             ViewObjectContact* pRetval = new ViewObjectContactOfPageFill(rObjectContact, *this);
290             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
291 
292             return *pRetval;
293         }
294 
createViewIndependentPrimitive2DSequence() const295         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageFill::createViewIndependentPrimitive2DSequence() const
296         {
297             const SdrPage& rPage = getPage();
298             const basegfx::B2DRange aPageFillRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt());
299             const basegfx::B2DPolygon aPageFillPolygon(basegfx::tools::createPolygonFromRect(aPageFillRange));
300 
301             // We have only the page information, not the view information. Use the
302             // svtools::DOCCOLOR color for initialisation
303             const svtools::ColorConfig aColorConfig;
304             const Color aPageFillColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
305 
306             // create and add primitive
307             const basegfx::BColor aRGBColor(aPageFillColor.getBColor());
308             const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon), aRGBColor));
309 
310             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
311         }
312 
ViewContactOfPageFill(ViewContactOfSdrPage & rParentViewContactOfSdrPage)313         ViewContactOfPageFill::ViewContactOfPageFill(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
314         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
315         {
316         }
317 
~ViewContactOfPageFill()318         ViewContactOfPageFill::~ViewContactOfPageFill()
319         {
320         }
321     } // end of namespace contact
322 } // end of namespace sdr
323 
324 //////////////////////////////////////////////////////////////////////////////
325 
326 namespace sdr
327 {
328     namespace contact
329     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)330         ViewObjectContact& ViewContactOfOuterPageBorder::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
331         {
332             ViewObjectContact* pRetval = new ViewObjectContactOfOuterPageBorder(rObjectContact, *this);
333             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
334 
335             return *pRetval;
336         }
337 
createViewIndependentPrimitive2DSequence() const338         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfOuterPageBorder::createViewIndependentPrimitive2DSequence() const
339         {
340             drawinglayer::primitive2d::Primitive2DSequence xRetval;
341             const SdrPage& rPage = getPage();
342             const basegfx::B2DRange aPageBorderRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt());
343 
344             // Changed to 0x949599 for renaissance, before svtools::FONTCOLOR was used.
345             // Added old case as fallback for HighContrast.
346             basegfx::BColor aRGBBorderColor(0x94 / (double)0xff, 0x95 / (double)0xff, 0x99 / (double)0xff);
347 
348             if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
349             {
350                 const svtools::ColorConfig aColorConfig;
351                 const Color aBorderColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
352 
353                 aRGBBorderColor = aBorderColor.getBColor();
354             }
355 
356             if(rPage.getPageBorderOnlyLeftRight())
357             {
358                 // #i93597# for Report Designer, the page border shall be only displayed right and left,
359                 // but not top and bottom. Create simplified geometry.
360                 basegfx::B2DPolygon aLeft, aRight;
361 
362                 aLeft.append(basegfx::B2DPoint(aPageBorderRange.getMinX(), aPageBorderRange.getMinY()));
363                 aLeft.append(basegfx::B2DPoint(aPageBorderRange.getMinX(), aPageBorderRange.getMaxY()));
364 
365                 aRight.append(basegfx::B2DPoint(aPageBorderRange.getMaxX(), aPageBorderRange.getMinY()));
366                 aRight.append(basegfx::B2DPoint(aPageBorderRange.getMaxX(), aPageBorderRange.getMaxY()));
367 
368                 xRetval.realloc(2);
369                 xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aLeft, aRGBBorderColor));
370                 xRetval[1] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aRight, aRGBBorderColor));
371             }
372             else
373             {
374                 xRetval.realloc(1);
375                 const basegfx::B2DPolygon aPageBorderPolygon(basegfx::tools::createPolygonFromRect(aPageBorderRange));
376                 xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPageBorderPolygon, aRGBBorderColor));
377             }
378 
379             return xRetval;
380         }
381 
ViewContactOfOuterPageBorder(ViewContactOfSdrPage & rParentViewContactOfSdrPage)382         ViewContactOfOuterPageBorder::ViewContactOfOuterPageBorder(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
383         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
384         {
385         }
386 
~ViewContactOfOuterPageBorder()387         ViewContactOfOuterPageBorder::~ViewContactOfOuterPageBorder()
388         {
389         }
390     } // end of namespace contact
391 } // end of namespace sdr
392 
393 //////////////////////////////////////////////////////////////////////////////
394 
395 namespace sdr
396 {
397     namespace contact
398     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)399         ViewObjectContact& ViewContactOfInnerPageBorder::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
400         {
401             ViewObjectContact* pRetval = new ViewObjectContactOfInnerPageBorder(rObjectContact, *this);
402             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
403 
404             return *pRetval;
405         }
406 
createViewIndependentPrimitive2DSequence() const407         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfInnerPageBorder::createViewIndependentPrimitive2DSequence() const
408         {
409             const SdrPage& rPage = getPage();
410             const basegfx::B2DRange aPageBorderRange(
411                 (double)rPage.GetLftBorder(), (double)rPage.GetUppBorder(),
412                 (double)(rPage.GetWdt() - rPage.GetRgtBorder()), (double)(rPage.GetHgt() - rPage.GetLwrBorder()));
413             const basegfx::B2DPolygon aPageBorderPolygon(basegfx::tools::createPolygonFromRect(aPageBorderRange));
414 
415             // We have only the page information, not the view information. Use the
416             // svtools::FONTCOLOR or svtools::DOCBOUNDARIES color for initialisation
417             const svtools::ColorConfig aColorConfig;
418             Color aBorderColor;
419 
420             if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
421             {
422                 aBorderColor = aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor;
423             }
424             else
425             {
426                 aBorderColor = aColorConfig.GetColorValue(svtools::DOCBOUNDARIES).nColor;
427             }
428 
429             // create page outer border primitive
430             const basegfx::BColor aRGBBorderColor(aBorderColor.getBColor());
431             const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPageBorderPolygon, aRGBBorderColor));
432 
433             return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
434         }
435 
ViewContactOfInnerPageBorder(ViewContactOfSdrPage & rParentViewContactOfSdrPage)436         ViewContactOfInnerPageBorder::ViewContactOfInnerPageBorder(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
437         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
438         {
439         }
440 
~ViewContactOfInnerPageBorder()441         ViewContactOfInnerPageBorder::~ViewContactOfInnerPageBorder()
442         {
443         }
444     } // end of namespace contact
445 } // end of namespace sdr
446 
447 //////////////////////////////////////////////////////////////////////////////
448 
449 namespace sdr
450 {
451     namespace contact
452     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)453         ViewObjectContact& ViewContactOfPageHierarchy::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
454         {
455             ViewObjectContact* pRetval = new ViewObjectContactOfPageHierarchy(rObjectContact, *this);
456             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
457 
458             return *pRetval;
459         }
460 
createViewIndependentPrimitive2DSequence() const461         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageHierarchy::createViewIndependentPrimitive2DSequence() const
462         {
463             // collect sub-hierarchy
464             drawinglayer::primitive2d::Primitive2DSequence xRetval;
465             const sal_uInt32 nObjectCount(GetObjectCount());
466 
467             // collect all sub-primitives
468             for(sal_uInt32 a(0); a < nObjectCount; a++)
469             {
470                 const ViewContact& rCandidate(GetViewContact(a));
471                 const drawinglayer::primitive2d::Primitive2DSequence aCandSeq(rCandidate.getViewIndependentPrimitive2DSequence());
472 
473                 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aCandSeq);
474             }
475 
476             return xRetval;
477         }
478 
ViewContactOfPageHierarchy(ViewContactOfSdrPage & rParentViewContactOfSdrPage)479         ViewContactOfPageHierarchy::ViewContactOfPageHierarchy(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
480         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
481         {
482         }
483 
~ViewContactOfPageHierarchy()484         ViewContactOfPageHierarchy::~ViewContactOfPageHierarchy()
485         {
486         }
487 
GetObjectCount() const488         sal_uInt32 ViewContactOfPageHierarchy::GetObjectCount() const
489         {
490             return getPage().GetObjCount();
491         }
492 
GetViewContact(sal_uInt32 nIndex) const493         ViewContact& ViewContactOfPageHierarchy::GetViewContact(sal_uInt32 nIndex) const
494         {
495             SdrObject* pObj = getPage().GetObj(nIndex);
496             DBG_ASSERT(pObj, "ViewContactOfPageHierarchy::GetViewContact: Corrupt SdrObjList (!)");
497             return pObj->GetViewContact();
498         }
499     } // end of namespace contact
500 } // end of namespace sdr
501 
502 //////////////////////////////////////////////////////////////////////////////
503 
504 namespace sdr
505 {
506     namespace contact
507     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)508         ViewObjectContact& ViewContactOfGrid::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
509         {
510             ViewObjectContact* pRetval = new ViewObjectContactOfPageGrid(rObjectContact, *this);
511             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
512 
513             return *pRetval;
514         }
515 
createViewIndependentPrimitive2DSequence() const516         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGrid::createViewIndependentPrimitive2DSequence() const
517         {
518             // We have only the page information, not the view information and thus no grid settings. Create empty
519             // default. For the view-dependent implementation, see ViewObjectContactOfPageGrid::createPrimitive2DSequence
520             return drawinglayer::primitive2d::Primitive2DSequence();
521         }
522 
ViewContactOfGrid(ViewContactOfSdrPage & rParentViewContactOfSdrPage,bool bFront)523         ViewContactOfGrid::ViewContactOfGrid(ViewContactOfSdrPage& rParentViewContactOfSdrPage, bool bFront)
524         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage),
525             mbFront(bFront)
526         {
527         }
528 
~ViewContactOfGrid()529         ViewContactOfGrid::~ViewContactOfGrid()
530         {
531         }
532     } // end of namespace contact
533 } // end of namespace sdr
534 
535 //////////////////////////////////////////////////////////////////////////////
536 
537 namespace sdr
538 {
539     namespace contact
540     {
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)541         ViewObjectContact& ViewContactOfHelplines::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
542         {
543             ViewObjectContact* pRetval = new ViewObjectContactOfPageHelplines(rObjectContact, *this);
544             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
545 
546             return *pRetval;
547         }
548 
createViewIndependentPrimitive2DSequence() const549         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfHelplines::createViewIndependentPrimitive2DSequence() const
550         {
551             // We have only the page information, not the view information and thus no helplines. Create empty
552             // default. For the view-dependent implementation, see ViewObjectContactOfPageHelplines::createPrimitive2DSequence
553             return drawinglayer::primitive2d::Primitive2DSequence();
554         }
555 
ViewContactOfHelplines(ViewContactOfSdrPage & rParentViewContactOfSdrPage,bool bFront)556         ViewContactOfHelplines::ViewContactOfHelplines(ViewContactOfSdrPage& rParentViewContactOfSdrPage, bool bFront)
557         :   ViewContactOfPageSubObject(rParentViewContactOfSdrPage),
558             mbFront(bFront)
559         {
560         }
561 
~ViewContactOfHelplines()562         ViewContactOfHelplines::~ViewContactOfHelplines()
563         {
564         }
565     } // end of namespace contact
566 } // end of namespace sdr
567 
568 //////////////////////////////////////////////////////////////////////////////
569 
570 namespace sdr
571 {
572     namespace contact
573     {
574         // Create a Object-Specific ViewObjectContact, set ViewContact and
575         // ObjectContact. Always needs to return something.
CreateObjectSpecificViewObjectContact(ObjectContact & rObjectContact)576         ViewObjectContact& ViewContactOfSdrPage::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
577         {
578             ViewObjectContact* pRetval = new ViewObjectContactOfSdrPage(rObjectContact, *this);
579             DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
580 
581             return *pRetval;
582         }
583 
ViewContactOfSdrPage(SdrPage & rPage)584         ViewContactOfSdrPage::ViewContactOfSdrPage(SdrPage& rPage)
585         :   ViewContact(),
586             mrPage(rPage),
587             maViewContactOfPageBackground(*this),
588             maViewContactOfPageShadow(*this),
589             maViewContactOfPageFill(*this),
590             maViewContactOfMasterPage(*this),
591             maViewContactOfOuterPageBorder(*this),
592             maViewContactOfInnerPageBorder(*this),
593             maViewContactOfGridBack(*this, false),
594             maViewContactOfHelplinesBack(*this, false),
595             maViewContactOfPageHierarchy(*this),
596             maViewContactOfGridFront(*this, true),
597             maViewContactOfHelplinesFront(*this, true)
598         {
599         }
600 
~ViewContactOfSdrPage()601         ViewContactOfSdrPage::~ViewContactOfSdrPage()
602         {
603         }
604 
605         // Access to possible sub-hierarchy
GetObjectCount() const606         sal_uInt32 ViewContactOfSdrPage::GetObjectCount() const
607         {
608             // Fixed count of content. It contains PageBackground (Wiese), PageShadow, PageFill,
609             // then - depending on if the page has a MasterPage - either MasterPage Hierarchy
610             // or MPBGO. Also OuterPageBorder, InnerPageBorder and two pairs of Grid and Helplines
611             // (for front and back) which internally are visible or not depending on the current
612             // front/back setting for those.
613             return 11;
614         }
615 
GetViewContact(sal_uInt32 nIndex) const616         ViewContact& ViewContactOfSdrPage::GetViewContact(sal_uInt32 nIndex) const
617         {
618             switch(nIndex)
619             {
620                 case 0: return (ViewContact&)maViewContactOfPageBackground;
621                 case 1: return (ViewContact&)maViewContactOfPageShadow;
622                 case 2: return (ViewContact&)maViewContactOfPageFill;
623                 case 3:
624                 {
625                     const SdrPage& rPage = GetSdrPage();
626 
627                     if(rPage.TRG_HasMasterPage())
628                     {
629                         return rPage.TRG_GetMasterPageDescriptorViewContact();
630                     }
631                     else
632                     {
633                         return (ViewContact&)maViewContactOfMasterPage;
634                     }
635                 }
636                 case 4: return (ViewContact&)maViewContactOfOuterPageBorder;
637                 case 5: return (ViewContact&)maViewContactOfInnerPageBorder;
638                 case 6: return (ViewContact&)maViewContactOfGridBack;
639                 case 7: return (ViewContact&)maViewContactOfHelplinesBack;
640                 case 8: return (ViewContact&)maViewContactOfPageHierarchy;
641                 case 9: return (ViewContact&)maViewContactOfGridFront;
642                 default: return (ViewContact&)maViewContactOfHelplinesFront;
643             }
644         }
645 
646         // React on changes of the object of this ViewContact
ActionChanged()647         void ViewContactOfSdrPage::ActionChanged()
648         {
649             // call parent
650             ViewContact::ActionChanged();
651 
652             // apply to local viewContacts, they all rely on page information. Exception
653             // is the sub hierarchy; this will not be influenced by the change
654             maViewContactOfPageBackground.ActionChanged();
655             maViewContactOfPageShadow.ActionChanged();
656             maViewContactOfPageFill.ActionChanged();
657 
658             const SdrPage& rPage = GetSdrPage();
659 
660             if(rPage.TRG_HasMasterPage())
661             {
662                 rPage.TRG_GetMasterPageDescriptorViewContact().ActionChanged();
663             }
664             else if(rPage.IsMasterPage())
665             {
666                 maViewContactOfMasterPage.ActionChanged();
667             }
668 
669             maViewContactOfOuterPageBorder.ActionChanged();
670             maViewContactOfInnerPageBorder.ActionChanged();
671             maViewContactOfGridBack.ActionChanged();
672             maViewContactOfHelplinesBack.ActionChanged();
673             maViewContactOfGridFront.ActionChanged();
674             maViewContactOfHelplinesFront.ActionChanged();
675         }
676 
677         // overload for acessing the SdrPage
TryToGetSdrPage() const678         SdrPage* ViewContactOfSdrPage::TryToGetSdrPage() const
679         {
680             return &GetSdrPage();
681         }
682 
createViewIndependentPrimitive2DSequence() const683         drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrPage::createViewIndependentPrimitive2DSequence() const
684         {
685             drawinglayer::primitive2d::Primitive2DSequence xRetval;
686 
687             // collect all sub-sequences including sub hierarchy.
688             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageBackground.getViewIndependentPrimitive2DSequence());
689             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageShadow.getViewIndependentPrimitive2DSequence());
690             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageFill.getViewIndependentPrimitive2DSequence());
691 
692             const SdrPage& rPage = GetSdrPage();
693 
694             if(rPage.TRG_HasMasterPage())
695             {
696                 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval,
697                     rPage.TRG_GetMasterPageDescriptorViewContact().getViewIndependentPrimitive2DSequence());
698             }
699             else if(rPage.IsMasterPage())
700             {
701                 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval,
702                     maViewContactOfMasterPage.getViewIndependentPrimitive2DSequence());
703             }
704 
705             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfOuterPageBorder.getViewIndependentPrimitive2DSequence());
706             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfInnerPageBorder.getViewIndependentPrimitive2DSequence());
707             drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageHierarchy.getViewIndependentPrimitive2DSequence());
708 
709             // Only add front versions of grid and helplines since no visibility test is done,
710             // so adding the back incarnations is not necessary. This makes the Front
711             // visualisation the default when no visibility tests are done.
712             //
713             // Since we have no view here, no grid and helpline definitions are available currently. The used
714             // methods at ViewContactOfHelplines and ViewContactOfGrid return only empty sequences and
715             // do not need to be called ATM. This may change later if grid or helpline info gets
716             // model data (it should not). Keeping the lines commented to hold this hint.
717             //
718             // drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfGridFront.getViewIndependentPrimitive2DSequence());
719             // drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfHelplinesFront.getViewIndependentPrimitive2DSequence());
720 
721             return xRetval;
722         }
723     } // end of namespace contact
724 } // end of namespace sdr
725 
726 //////////////////////////////////////////////////////////////////////////////
727 // eof
728