Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
12 : * GNU Lesser General Public License Version 2.1
13 : * =============================================
14 : * Copyright 2000 by Sun Microsystems, Inc.
15 : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : *
17 : * This library is free software; you can redistribute it and/or
18 : * modify it under the terms of the GNU Lesser General Public
19 : * License version 2.1, as published by the Free Software Foundation.
20 : *
21 : * This library is distributed in the hope that it will be useful,
22 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : * Lesser General Public License for more details.
25 : *
26 : * You should have received a copy of the GNU Lesser General Public
27 : * License along with this library; if not, write to the Free Software
28 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : * MA 02111-1307 USA
30 : *
31 : *
32 : * Sun Industry Standards Source License Version 1.1
33 : * =================================================
34 : * The contents of this file are subject to the Sun Industry Standards
35 : * Source License Version 1.1 (the "License"); You may not use this file
36 : * except in compliance with the License. You may obtain a copy of the
37 : * License at http://www.openoffice.org/license.html.
38 : *
39 : * Software provided under this License is provided on an "AS IS" basis,
40 : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : * See the License for the specific provisions governing your rights and
44 : * obligations concerning the Software.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /*************************************************************************
57 : * @file
58 : * For LWP filter architecture prototype
59 : ************************************************************************/
60 : /*************************************************************************
61 : * Change History
62 : Jan 2005 Created
63 : Feb 2005 Process gemotry, margins
64 : ************************************************************************/
65 :
66 : #include "lwplayout.hxx"
67 : #include "lwpusewhen.hxx"
68 : #include "lwptools.hxx"
69 : #include "xfilter/xfcolumns.hxx"
70 : #include "lwpstory.hxx"
71 : #include "lwpparastyle.hxx"
72 : #include "lwpholder.hxx"
73 : #include "lwpdoc.hxx"
74 : #include "lwppagehint.hxx"
75 : #include "lwpdivinfo.hxx"
76 : #include "lwpgrfobj.hxx"
77 : #include <osl/thread.h>
78 :
79 0 : LwpVirtualLayout::LwpVirtualLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
80 : : LwpDLNFPVList(objHdr, pStrm)
81 : , m_nAttributes(0)
82 : , m_nAttributes2(0)
83 : , m_nAttributes3(0)
84 : , m_nOverrideFlag(0)
85 : , m_nDirection(0)
86 0 : , m_nEditorID(0)
87 : {
88 0 : }
89 :
90 0 : void LwpVirtualLayout::Read()
91 : {
92 0 : LwpDLNFPVList::Read();
93 :
94 0 : LwpObjectStream* pStrm = m_pObjStrm;
95 0 : m_nAttributes = pStrm->QuickReaduInt32();
96 0 : m_nAttributes2 = pStrm->QuickReaduInt32();
97 0 : m_nAttributes3 = pStrm->QuickReaduInt32();
98 0 : m_nOverrideFlag = pStrm->QuickReaduInt32();
99 0 : m_nDirection = pStrm->QuickReaduInt16();
100 :
101 : //Note that two bytes is read into m_nEditorID instead of one byte.
102 0 : m_nEditorID = pStrm->QuickReaduInt16();
103 :
104 0 : m_NextEnumerated.ReadIndexed(pStrm);
105 0 : m_PreviousEnumerated.ReadIndexed(pStrm);
106 :
107 0 : pStrm->SkipExtra();
108 0 : }
109 :
110 0 : sal_Bool LwpVirtualLayout::MarginsSameAsParent()
111 : {
112 0 : return m_nAttributes2 & STYLE2_MARGINSSAMEASPARENT ? sal_True : sal_False;
113 : }
114 :
115 : /**
116 : * @descr: Get column width
117 : *
118 : */
119 0 : double LwpVirtualLayout::GetColWidth(sal_uInt16 /*nIndex*/)
120 : {
121 : //return GetContentWidth(); //not support now
122 : //return LwpTools::ConvertToMetric(5); //test
123 0 : return 0; //test
124 : }
125 :
126 : /**
127 : * @descr: Get the gap between columns
128 : *
129 : */
130 0 : double LwpVirtualLayout::GetColGap(sal_uInt16 /*nIndex*/)
131 : {
132 : //return DEFAULTGAPSIZE;
133 : //return LwpTools::ConvertToMetric(0.17);//DEFAULTGAPSIZE=0.17
134 0 : return LwpTools::ConvertToMetric(0.17);
135 : }
136 :
137 : /**
138 : * @descr: Whether it is honoring protection
139 : *
140 : */
141 0 : sal_Bool LwpVirtualLayout::HonorProtection()
142 : {
143 0 : if(!(m_nAttributes2 & STYLE2_HONORPROTECTION))
144 0 : return sal_False;
145 :
146 0 : LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
147 0 : if(pParent && !pParent->IsHeader())
148 : {
149 0 : return pParent->HonorProtection();
150 : }
151 :
152 0 : if(m_pFoundry)//is null now
153 : {
154 0 : LwpDocument* pDoc = m_pFoundry->GetDocument();
155 : /*if(pDoc)
156 : {
157 : return pDoc->HonorProtection();
158 : }*/
159 0 : if(pDoc && pDoc->GetRootDocument())
160 0 : return pDoc->GetRootDocument()->HonorProtection();
161 : }
162 :
163 0 : return sal_True;
164 : }
165 :
166 : /**
167 : * @descr: Whether it is protected
168 : *
169 : */
170 0 : sal_Bool LwpVirtualLayout::IsProtected()
171 : {
172 0 : sal_Bool bProtected = (m_nAttributes & STYLE_PROTECTED)!=0;
173 :
174 0 : LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
175 0 : if(pParent && !pParent->IsHeader())
176 : {
177 0 : if(pParent->HonorProtection()&&(pParent->HasProtection()||bProtected))
178 : {
179 0 : return sal_True;
180 : }
181 : }
182 0 : else if(m_pFoundry)//is null now
183 : {
184 0 : LwpDocument* pDoc = m_pFoundry->GetDocument();
185 0 : if(pDoc)
186 : {
187 0 : if (pDoc->HonorProtection() && bProtected)
188 : {
189 0 : return sal_True;
190 : }
191 : }
192 : }
193 :
194 0 : return sal_False;
195 : }
196 :
197 : /**
198 : * @descr: Whether it has protection
199 : *
200 : */
201 0 : sal_Bool LwpVirtualLayout::HasProtection()
202 : {
203 0 : if(m_nAttributes & STYLE_PROTECTED)
204 0 : return sal_True;
205 :
206 0 : LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
207 0 : if(pParent && !pParent->IsHeader())
208 : {
209 0 : return pParent->HasProtection();
210 : }
211 :
212 0 : return sal_False;
213 : }
214 :
215 : /**
216 : * @descr: Whether it is a mirror layout
217 : *
218 : */
219 0 : sal_Bool LwpVirtualLayout::IsComplex()
220 : {
221 0 : return m_nAttributes & STYLE_COMPLEX ? sal_True : sal_False;
222 : }
223 :
224 : /**
225 : * @descr: Get usewhen pointer
226 : *
227 : */
228 0 : LwpUseWhen* LwpVirtualLayout::GetUseWhen()
229 : {
230 : /*
231 : If we have a parent, and I'm not a page layout,
232 : use my parents information.
233 : */
234 0 : if(GetLayoutType()!=LWP_PAGE_LAYOUT)
235 : {
236 : //get parent
237 0 : LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
238 0 : if(pParent && !pParent->IsHeader()&& (pParent->GetLayoutType()!=LWP_PAGE_LAYOUT))
239 0 : return pParent->GetUseWhen();
240 :
241 : }
242 :
243 0 : return VirtualGetUseWhen();
244 : }
245 : /**
246 : * @descr: Whether this layout is page layout or not
247 : * @param:
248 : * @return:
249 : */
250 0 : sal_Bool LwpVirtualLayout::IsPage()
251 : {
252 0 : return (GetLayoutType() == LWP_PAGE_LAYOUT);
253 : }
254 : /**
255 : * @descr: Whether this layout is heaer layout or not
256 : * @param:
257 : * @return:
258 : */
259 0 : sal_Bool LwpVirtualLayout::IsHeader()
260 : {
261 0 : return (GetLayoutType() == LWP_HEADER_LAYOUT);
262 : }
263 : /**
264 : * @descr: Whether this layout is footer layout or not
265 : * @param:
266 : * @return:
267 : */
268 0 : sal_Bool LwpVirtualLayout::IsFooter()
269 : {
270 0 : return (GetLayoutType() == LWP_FOOTER_LAYOUT);
271 : }
272 : /**
273 : * @descr: Whether this layout is frame layout or not
274 : * @param:
275 : * @return:
276 : */
277 0 : sal_Bool LwpVirtualLayout::IsFrame()
278 : {
279 0 : return (GetLayoutType() == LWP_FRAME_LAYOUT);
280 : }
281 :
282 : /**
283 : * @descr: Whether this layout is cell layout or not
284 : * @param:
285 : * @return:
286 : */
287 0 : sal_Bool LwpVirtualLayout::IsCell()
288 : {
289 0 : return (GetLayoutType() == LWP_CELL_LAYOUT
290 0 : || GetLayoutType() == LWP_CONNECTED_CELL_LAYOUT
291 0 : || GetLayoutType() == LWP_HIDDEN_CELL_LAYOUT);
292 : }
293 : /**
294 : * @descr: Whether this layout is supertable layout or not
295 : * @param:
296 : * @return:
297 : */
298 0 : sal_Bool LwpVirtualLayout::IsSuperTable()
299 : {
300 0 : return (GetLayoutType() == LWP_SUPERTABLE_LAYOUT);
301 : }
302 : /**
303 : * @descr: Whether this layout is group layout or not
304 : * @param:
305 : * @return:
306 : */
307 0 : sal_Bool LwpVirtualLayout::IsGroupHead()
308 : {
309 0 : return (GetLayoutType() == LWP_GROUP_LAYOUT);
310 : }
311 : /**
312 : * @descr: get the relative type
313 : * @param:
314 : * @return:
315 : */
316 0 : sal_uInt8 LwpVirtualLayout::GetRelativeType()
317 : {
318 0 : return LwpLayoutRelativityGuts::LAY_PARENT_RELATIVE;
319 : }
320 : /**
321 : * @descr: whether it is relative anchored layout
322 : * @param:
323 : * @return:
324 : */
325 0 : sal_Bool LwpVirtualLayout::IsRelativeAnchored()
326 : {
327 : sal_uInt8 nType;
328 :
329 0 : nType = GetRelativeType();
330 0 : return (nType == LwpLayoutRelativityGuts::LAY_PARA_RELATIVE) || (nType == LwpLayoutRelativityGuts::LAY_INLINE)
331 0 : || (nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE) || (nType == LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL);
332 : }
333 : /**
334 : * @descr: whether it is MinimumHeight layout
335 : * @param:
336 : * @return:
337 : */
338 0 : sal_Bool LwpVirtualLayout::IsMinimumHeight()
339 : {
340 0 : return ((m_nAttributes3& STYLE3_MINHEIGHTVALID) != 0);
341 : }
342 :
343 : /**
344 : * @descr: Get parent layout
345 : *
346 : */
347 0 : LwpVirtualLayout* LwpVirtualLayout::GetParentLayout()
348 : {
349 0 : return dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
350 : }
351 :
352 : /**
353 : * @descr: Register child layout style
354 : *
355 : */
356 0 : void LwpVirtualLayout::RegisterChildStyle()
357 : {
358 : //Register all children styles
359 0 : LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
360 0 : while(pLayout)
361 : {
362 0 : pLayout->SetFoundry(m_pFoundry);
363 0 : pLayout->RegisterStyle();
364 0 : pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
365 : }
366 0 : }
367 :
368 0 : sal_Bool LwpVirtualLayout::NoContentReference()
369 : {
370 0 : return (m_nAttributes2 & STYLE2_NOCONTENTREFERENCE) != 0;
371 : }
372 :
373 0 : sal_Bool LwpVirtualLayout::IsStyleLayout()
374 : {
375 0 : if (m_nAttributes3 & STYLE3_STYLELAYOUT)
376 0 : return sal_True;
377 :
378 0 : LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*>(GetParent()->obj());
379 0 : if (pParent)
380 0 : return pParent->IsStyleLayout();
381 0 : return sal_False;
382 : }
383 :
384 : /**
385 : * @descr: Find child layout by layout type
386 : *
387 : */
388 0 : LwpVirtualLayout* LwpVirtualLayout::FindChildByType(LWP_LAYOUT_TYPE eType)
389 : {
390 0 : LwpObjectID *pID = GetChildHead();
391 :
392 0 : while(pID && !pID->IsNull())
393 : {
394 0 : LwpVirtualLayout * pLayout = dynamic_cast<LwpVirtualLayout *>(pID->obj());
395 0 : if(!pLayout)
396 : {
397 0 : break;
398 : }
399 :
400 0 : if (pLayout && pLayout->GetLayoutType() == eType)
401 : {
402 0 : return pLayout;
403 : }
404 0 : pID = pLayout->GetNext();
405 : }
406 :
407 0 : return NULL;
408 : }
409 :
410 : /**
411 : * @descr: Whether the size of layout is fit the graphic
412 : *
413 : */
414 0 : sal_Bool LwpVirtualLayout::IsFitGraphic()
415 : {
416 0 : return IsAutoGrowRight() && !IsAutoGrowLeft() && IsAutoGrowDown();
417 : }
418 :
419 : /**
420 : * @descr: Whether the width of layout is auto grow
421 : *
422 : */
423 0 : sal_Bool LwpVirtualLayout::IsAutoGrowWidth()
424 : {
425 0 : return IsAutoGrowLeft() || IsAutoGrowRight();
426 : }
427 :
428 : /**
429 : * @descr: Determine whether the layout width is to margin
430 : *
431 : */
432 0 : sal_Bool LwpVirtualLayout::IsInlineToMargin()
433 : {
434 0 : return (m_nAttributes3 & STYLE3_INLINETOMARGIN) != 0;
435 : }
436 :
437 0 : void LwpAssociatedLayouts::Read(LwpObjectStream* pStrm)
438 : {
439 0 : m_OnlyLayout.ReadIndexed(pStrm);
440 0 : m_Layouts.Read(pStrm);
441 0 : pStrm->SkipExtra();
442 0 : }
443 :
444 : /**
445 : * @descr: Looking for the layout which follows the pStartLayout
446 : * @param: pStartLayout - the layout which is used for looking for its following layout
447 : */
448 0 : LwpVirtualLayout* LwpAssociatedLayouts::GetLayout(LwpVirtualLayout *pStartLayout)
449 : {
450 0 : LwpVirtualLayout* pLayout = NULL;
451 :
452 0 : if (!pStartLayout && !m_OnlyLayout.IsNull())
453 : /* Looking for the first layout and there's only one layout in the list.*/
454 0 : return dynamic_cast<LwpVirtualLayout*>(m_OnlyLayout.obj());
455 :
456 0 : LwpObjectHolder* pObjHolder = dynamic_cast<LwpObjectHolder*>(m_Layouts.GetHead()->obj());
457 0 : if(pObjHolder)
458 : {
459 0 : pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
460 0 : if(!pStartLayout )
461 0 : return pLayout;
462 :
463 0 : while(pObjHolder && pStartLayout != pLayout)
464 : {
465 0 : pObjHolder = dynamic_cast<LwpObjectHolder*>(pObjHolder->GetNext()->obj());
466 0 : if(pObjHolder)
467 : {
468 0 : pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
469 : }
470 : }
471 :
472 0 : if(pObjHolder)
473 : {
474 0 : pObjHolder = dynamic_cast<LwpObjectHolder*>(pObjHolder->GetNext()->obj());
475 0 : if(pObjHolder)
476 : {
477 0 : pLayout = dynamic_cast<LwpVirtualLayout*>(pObjHolder->GetObject()->obj());
478 0 : return pLayout;
479 : }
480 : }
481 :
482 : //return pLayout;
483 : }
484 :
485 0 : return NULL;
486 : }
487 :
488 0 : LwpHeadLayout::LwpHeadLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
489 0 : : LwpVirtualLayout(objHdr, pStrm)
490 0 : {}
491 :
492 0 : void LwpHeadLayout::Read()
493 : {
494 0 : LwpVirtualLayout::Read();
495 : //For PermissiveLayout
496 0 : m_pObjStrm->SkipExtra();
497 : //For me
498 0 : m_pObjStrm->SkipExtra();
499 0 : }
500 :
501 0 : void LwpHeadLayout::RegisterStyle()
502 : {
503 : //Register all children styles
504 0 : LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
505 0 : while(pLayout)
506 : {
507 0 : pLayout->SetFoundry(m_pFoundry);
508 : //if the layout is relative to para, the layout will be registered in para
509 0 : if(!pLayout->IsRelativeAnchored())
510 : {
511 0 : if (pLayout == this)
512 : {
513 : OSL_FAIL("Layout points to itself");
514 0 : break;
515 : }
516 0 : pLayout->RegisterStyle();
517 : }
518 0 : LwpVirtualLayout *pNext = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
519 0 : if (pNext == pLayout)
520 : {
521 : OSL_FAIL("Layout points to itself");
522 0 : break;
523 : }
524 0 : pLayout = pNext;
525 : }
526 0 : }
527 :
528 : /**
529 : * @descr find endnote supertable layout from the child layout list. Suppose that there is only one endnote supertablelayout in one division
530 : * @return pointer to endnote supertable layout
531 : */
532 0 : LwpVirtualLayout* LwpHeadLayout::FindEnSuperTableLayout()
533 : {
534 0 : LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
535 0 : while(pLayout)
536 : {
537 0 : if(pLayout->GetLayoutType() == LWP_ENDNOTE_SUPERTABLE_LAYOUT)
538 : {
539 0 : return pLayout;
540 : }
541 0 : pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext()->obj());
542 : }
543 0 : return NULL;
544 : }
545 :
546 0 : LwpLayoutStyle::LwpLayoutStyle()
547 : : m_nStyleDefinition(0)
548 0 : , m_pDescription(new LwpAtomHolder)
549 0 : , m_nKey(0)
550 : {
551 0 : }
552 :
553 0 : LwpLayoutStyle::~LwpLayoutStyle()
554 : {
555 0 : delete m_pDescription;
556 0 : }
557 :
558 0 : void LwpLayoutStyle::Read(LwpObjectStream* pStrm)
559 : {
560 0 : m_nStyleDefinition = pStrm->QuickReaduInt32();
561 0 : m_pDescription->Read(pStrm);
562 0 : if (pStrm->CheckExtra())
563 : {
564 0 : m_nKey = pStrm->QuickReaduInt16();
565 0 : pStrm->SkipExtra();
566 : }
567 0 : }
568 :
569 0 : LwpLayoutMisc::LwpLayoutMisc() :
570 : m_nGridDistance(0), m_nGridType(0),
571 0 : m_pContentStyle(new LwpAtomHolder)
572 : {
573 0 : }
574 :
575 0 : LwpLayoutMisc::~LwpLayoutMisc()
576 : {
577 0 : if (m_pContentStyle)
578 : {
579 0 : delete m_pContentStyle;
580 : }
581 0 : }
582 :
583 0 : void LwpLayoutMisc::Read(LwpObjectStream* pStrm)
584 : {
585 0 : m_nGridType = pStrm->QuickReaduInt16();
586 0 : m_nGridDistance = pStrm->QuickReadInt32();
587 0 : m_pContentStyle->Read(pStrm);
588 0 : pStrm->SkipExtra();
589 0 : }
590 :
591 0 : LwpMiddleLayout::LwpMiddleLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm )
592 : : LwpVirtualLayout(objHdr, pStrm),
593 0 : m_pStyleStuff(new LwpLayoutStyle), m_pMiscStuff(new LwpLayoutMisc)
594 0 : {}
595 :
596 0 : LwpMiddleLayout::~LwpMiddleLayout()
597 : {
598 0 : if (m_pStyleStuff)
599 : {
600 0 : delete m_pStyleStuff;
601 : }
602 0 : if (m_pMiscStuff)
603 : {
604 0 : delete m_pMiscStuff;
605 : }
606 0 : }
607 0 : void LwpMiddleLayout::Read()
608 : {
609 0 : LwpObjectStream* pStrm = m_pObjStrm;
610 :
611 0 : LwpVirtualLayout::Read();
612 :
613 : //skip CLiteLayout data;
614 0 : LwpAtomHolder ContentClass;
615 0 : ContentClass.Read(pStrm);
616 0 : pStrm->SkipExtra();
617 :
618 : // before layout hierarchy rework
619 0 : if(LwpFileHeader::m_nFileRevision < 0x000B)
620 0 : return;
621 :
622 0 : m_Content.ReadIndexed(pStrm);
623 :
624 : // 01/20/2005
625 0 : m_BasedOnStyle.ReadIndexed(pStrm);
626 0 : m_TabPiece.ReadIndexed(pStrm);
627 :
628 0 : sal_uInt8 nWhatsItGot = pStrm->QuickReaduInt8();
629 :
630 0 : if (nWhatsItGot & DISK_GOT_STYLE_STUFF)
631 : {
632 0 : m_pStyleStuff->Read(pStrm);
633 : }
634 0 : if (nWhatsItGot & DISK_GOT_MISC_STUFF)
635 : {
636 0 : m_pMiscStuff->Read(pStrm);
637 : }
638 :
639 0 : m_LayGeometry.ReadIndexed(pStrm);
640 0 : m_LayScale.ReadIndexed(pStrm);
641 0 : m_LayMargins.ReadIndexed(pStrm);
642 0 : m_LayBorderStuff.ReadIndexed(pStrm);
643 0 : m_LayBackgroundStuff.ReadIndexed(pStrm);
644 :
645 0 : if (pStrm->CheckExtra())
646 : {
647 0 : m_LayExtBorderStuff.ReadIndexed(pStrm);
648 0 : pStrm->SkipExtra();
649 0 : }
650 : //end
651 : }
652 :
653 : #include "lwplaypiece.hxx"
654 :
655 : /**
656 : * @descr: Get the geometry of current layout
657 : *
658 : */
659 0 : LwpLayoutGeometry* LwpMiddleLayout::GetGeometry()
660 : {
661 0 : if( !m_LayGeometry.IsNull() )
662 : {
663 0 : return ( dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj()) );
664 : }
665 0 : else if( !m_BasedOnStyle.IsNull() )
666 : {
667 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
668 0 : return pLay ? pLay->GetGeometry() : NULL;
669 : }
670 0 : return NULL;
671 : }
672 :
673 : /**
674 : * @descr: Get layout height, measured by "cm"
675 : *
676 : */
677 0 : double LwpMiddleLayout::GetGeometryHeight()
678 : {
679 0 : LwpLayoutGeometry* pGeo = GetGeometry();
680 0 : if(pGeo)
681 : {
682 0 : return ( LwpTools::ConvertFromUnitsToMetric( pGeo->GetHeight() ) );
683 : }
684 : else
685 0 : return -1;
686 : }
687 :
688 : /**
689 : * @descr: Get layout width, measured by "cm"
690 : *
691 : */
692 0 : double LwpMiddleLayout::GetGeometryWidth()
693 : {
694 0 : LwpLayoutGeometry* pGeo = GetGeometry();
695 0 : if(pGeo)
696 : {
697 0 : return ( LwpTools::ConvertFromUnitsToMetric( pGeo->GetWidth() ) );
698 : }
699 : else
700 0 : return -1;
701 : }
702 :
703 : /**
704 : * @descr: Whether the margins is same as parent layout
705 : *
706 : */
707 0 : sal_Bool LwpMiddleLayout::MarginsSameAsParent()
708 : {
709 0 : if(m_nOverrideFlag & OVER_MARGINS)
710 : {
711 0 : return LwpVirtualLayout::MarginsSameAsParent();
712 : }
713 0 : if(!m_BasedOnStyle.IsNull())
714 : {
715 0 : LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
716 0 : if (pLay)
717 0 : pLay->MarginsSameAsParent();
718 : }
719 0 : return LwpVirtualLayout::MarginsSameAsParent();
720 :
721 : }
722 :
723 : /**
724 : * @descr: Get margin
725 : * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
726 : */
727 0 : double LwpMiddleLayout::GetMarginsValue(const sal_uInt8 &nWhichSide)
728 : {
729 0 : double fValue = 0;
730 0 : if((nWhichSide==MARGIN_LEFT)||(nWhichSide==MARGIN_RIGHT))
731 : {
732 0 : if ( MarginsSameAsParent() )
733 : {
734 0 : LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
735 0 : if(pParent && !pParent->IsHeader())
736 : {
737 0 : fValue = pParent->GetMarginsValue(nWhichSide);
738 0 : return fValue;
739 : }
740 : }
741 : }
742 :
743 0 : if(m_nOverrideFlag & OVER_MARGINS)
744 : {
745 0 : LwpLayoutMargins* pMar1 = dynamic_cast<LwpLayoutMargins*> (m_LayMargins.obj());
746 0 : if(pMar1)
747 : {
748 0 : fValue = pMar1->GetMargins()->GetMarginsValue(nWhichSide);
749 0 : return fValue;
750 : }
751 : }
752 0 : LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
753 0 : if(pStyle)
754 : {
755 0 : fValue = pStyle->GetMarginsValue(nWhichSide);
756 0 : return fValue;
757 : }
758 0 : return LwpVirtualLayout::GetMarginsValue(nWhichSide);
759 : }
760 : /**
761 : * @descr: Get extmargin value
762 : * @param: nWhichSide - 0: left, 1: right, 2:top, 3: bottom
763 : * @param:
764 : * @return:
765 : */
766 0 : double LwpMiddleLayout::GetExtMarginsValue(const sal_uInt8 &nWhichSide)
767 : {
768 0 : double fValue = 0;
769 0 : if(m_nOverrideFlag & OVER_MARGINS)
770 : {
771 0 : LwpLayoutMargins* pMar1 = dynamic_cast<LwpLayoutMargins*> (m_LayMargins.obj());
772 0 : if(pMar1)
773 : {
774 0 : fValue = pMar1->GetExtMargins()->GetMarginsValue(nWhichSide);
775 0 : return fValue;
776 : }
777 : }
778 0 : LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
779 0 : if(pStyle)
780 : {
781 0 : fValue = pStyle->GetExtMarginsValue(nWhichSide);
782 0 : return fValue;
783 : }
784 0 : return LwpVirtualLayout::GetExtMarginsValue(nWhichSide);
785 : }
786 : /**
787 : * @descr: Get the LwpBorderStuff object according to m_LayBorderStuff id.
788 : * @param:
789 : * @param:
790 : * @return:
791 : */
792 0 : LwpBorderStuff* LwpMiddleLayout::GetBorderStuff()
793 : {
794 0 : if(m_nOverrideFlag & OVER_BORDERS)
795 : {
796 0 : LwpLayoutBorder* pLayoutBorder = dynamic_cast<LwpLayoutBorder*>(m_LayBorderStuff.obj());
797 0 : return pLayoutBorder ? pLayoutBorder->GetBorderStuff() : NULL;
798 : }
799 0 : else if( !m_BasedOnStyle.IsNull() )
800 : {
801 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
802 0 : return pLay ? pLay->GetBorderStuff() : NULL;
803 : }
804 0 : return NULL;
805 : }
806 :
807 : /**
808 : * @descr: Get LwpBackgroundStuff object according to m_LayBackgroundStuff id;
809 : * @param:
810 : * @param:
811 : * @return:
812 : */
813 0 : LwpBackgroundStuff* LwpMiddleLayout::GetBackgroundStuff()
814 : {
815 0 : if(m_nOverrideFlag & OVER_BACKGROUND)
816 : {
817 0 : LwpLayoutBackground* pLayoutBackground = dynamic_cast<LwpLayoutBackground*>(m_LayBackgroundStuff.obj());
818 0 : return pLayoutBackground ? pLayoutBackground->GetBackgoudStuff() : NULL;
819 : }
820 0 : else if( !m_BasedOnStyle.IsNull() )
821 : {
822 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
823 0 : return pLay ? pLay->GetBackgroundStuff() : NULL;
824 : }
825 0 : return NULL;
826 : }
827 : /**
828 : * @descr: create xfborder.
829 : * @param:
830 : * @param:
831 : * @return:
832 : */
833 0 : XFBorders* LwpMiddleLayout::GetXFBorders()
834 : {
835 0 : LwpBorderStuff* pBorderStuff = GetBorderStuff();
836 0 : if(pBorderStuff&&pBorderStuff->GetSide() != 0)
837 : {
838 : //copy from lwpparastyle.
839 0 : XFBorders *pXFBorders = new XFBorders();
840 : // apply 4 borders respectively
841 : LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
842 0 : LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
843 :
844 0 : for (sal_uInt8 nC = 0; nC < 4; nC++)
845 : {
846 0 : if (pBorderStuff->HasSide(pType[nC]))
847 : {
848 0 : LwpParaStyle::ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
849 : }
850 : }
851 0 : return pXFBorders;
852 : }
853 0 : return NULL;
854 : }
855 :
856 : /**
857 : * @descr: Get text direction settings.
858 : * @param:
859 : * @param:
860 : * @return:
861 : */
862 0 : enumXFTextDir LwpMiddleLayout::GetTextDirection()
863 : {
864 0 : enumXFTextDir eTextDir = enumXFTextDirNone;
865 0 : sal_uInt8 nDirection = GetContentOrientation();
866 0 : switch(nDirection)
867 : {
868 : case TEXT_ORIENT_LRTB:
869 : {
870 0 : eTextDir = enumXFTextDirLR_TB;
871 0 : break;
872 : }
873 : case TEXT_ORIENT_TBRL:
874 : {
875 0 : eTextDir = enumXFTextDirTB_RL;
876 0 : break;
877 : }
878 : case TEXT_ORIENT_RLBT: // not supported now
879 : {
880 0 : eTextDir = enumXFTextDirNone;
881 0 : break;
882 : }
883 : case TEXT_ORIENT_BTLR: // not supported now
884 : {
885 0 : eTextDir = enumXFTextDirNone;
886 0 : break;
887 : }
888 : default:
889 0 : break;
890 : }
891 0 : return eTextDir;
892 : }
893 : /**
894 : * @descr: Get back ground color.
895 : * @param:
896 : * @param:
897 : * @return:
898 : */
899 0 : LwpColor* LwpMiddleLayout::GetBackColor()
900 : {
901 0 : LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
902 0 : if(pBackgroundStuff && !pBackgroundStuff->IsTransparent())
903 : {
904 0 : LwpColor* pColor = pBackgroundStuff->GetFillColor();
905 0 : if(pColor->IsValidColor())
906 : {
907 0 : return pColor;
908 : }
909 : }
910 0 : return NULL;
911 : }
912 :
913 : /**
914 : * @descr: Add back color settings into xfpagemaster.
915 : * @param:
916 : * @param:
917 : * @return:
918 : */
919 0 : LwpTabOverride* LwpMiddleLayout::GetTabOverride()
920 : {
921 0 : if(m_nAttributes & OVER_TABS)
922 : {
923 0 : if(!m_TabPiece.IsNull())
924 : {
925 0 : LwpTabPiece *pPiece = dynamic_cast<LwpTabPiece*>(m_TabPiece.obj());
926 0 : return (LwpTabOverride*)(pPiece ? pPiece->GetOverride() : NULL);
927 : }
928 0 : return NULL;
929 : }
930 0 : else if( !m_BasedOnStyle.IsNull() )
931 : {
932 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
933 0 : return pLay ? pLay->GetTabOverride() : NULL;
934 : }
935 0 : return NULL;
936 : }
937 :
938 : /**
939 : * @descr: Layscale for graphic & watermark
940 : * @param:
941 : * @param:
942 : * @return:
943 : */
944 0 : sal_uInt16 LwpMiddleLayout::GetScaleMode(void)
945 : {
946 0 : if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
947 0 : return GetLayoutScale()->GetScaleMode();
948 0 : else if (m_BasedOnStyle.obj())
949 0 : return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleMode();
950 : else
951 0 : return (LwpLayoutScale::FIT_IN_FRAME | LwpLayoutScale::MAINTAIN_ASPECT_RATIO);
952 : }
953 :
954 0 : sal_uInt16 LwpMiddleLayout::GetScaleTile(void)
955 : {
956 0 : if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
957 0 : return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::TILED)
958 0 : ? 1 : 0;
959 0 : else if (m_BasedOnStyle.obj())
960 0 : return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleTile();
961 : else
962 0 : return 0;
963 : }
964 :
965 0 : sal_uInt16 LwpMiddleLayout::GetScaleCenter(void)
966 : {
967 0 : if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
968 0 : return (GetLayoutScale()->GetPlacement() & LwpLayoutScale::CENTERED)
969 0 : ? 1 : 0;
970 0 : else if (m_BasedOnStyle.obj())
971 0 : return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleCenter();
972 : else
973 0 : return 0;
974 : }
975 :
976 0 : sal_uInt32 LwpMiddleLayout::GetScalePercentage(void)
977 : {
978 0 : if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
979 0 : return GetLayoutScale()->GetScalePercentage()/10;//m_nScalePercentage 1000 = 100%
980 0 : else if (m_BasedOnStyle.obj())
981 0 : return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScalePercentage();
982 : else
983 0 : return 100;
984 : }
985 :
986 0 : double LwpMiddleLayout::GetScaleWidth(void)
987 : {
988 0 : if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
989 0 : return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleWidth());
990 0 : else if (m_BasedOnStyle.obj())
991 0 : return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleWidth();
992 : else
993 0 : return 0;
994 : }
995 :
996 0 : double LwpMiddleLayout::GetScaleHeight(void)
997 : {
998 0 : if ((m_nOverrideFlag & OVER_SCALING) && m_LayScale.obj())
999 0 : return LwpTools::ConvertFromUnits(GetLayoutScale()->GetScaleHeight());
1000 0 : else if (m_BasedOnStyle.obj())
1001 0 : return dynamic_cast<LwpMiddleLayout*>(m_BasedOnStyle.obj())->GetScaleHeight();
1002 : else
1003 0 : return 0;
1004 : }
1005 0 : sal_Bool LwpMiddleLayout::CanSizeRight(void)
1006 : {
1007 0 : sal_uInt8 RelType = GetRelativeType();
1008 :
1009 0 : if (RelType == LwpLayoutRelativityGuts::LAY_INLINE || RelType == LwpLayoutRelativityGuts::LAY_PARA_RELATIVE
1010 0 : || RelType == LwpLayoutRelativityGuts::LAY_INLINE_VERTICAL)
1011 : {
1012 0 : return sal_False;
1013 : }
1014 0 : return sal_True;
1015 : }
1016 0 : sal_Int32 LwpMiddleLayout::GetMinimumWidth()
1017 : {
1018 0 : if (((m_nAttributes3 & STYLE3_WIDTHVALID) != 0) && GetGeometry())
1019 : {
1020 0 : return GetGeometry()->GetWidth();
1021 : }
1022 0 : else if (m_nOverrideFlag & OVER_SIZE)
1023 : {
1024 0 : return DetermineWidth();
1025 : }
1026 0 : return 0;
1027 : }
1028 0 : sal_Int32 LwpMiddleLayout::DetermineWidth()
1029 : {
1030 0 : if (IsSizeRightToContent())
1031 : {
1032 : assert(false);
1033 : }
1034 0 : else if (IsSizeRightToContainer())
1035 : {
1036 : assert(false);
1037 : }
1038 : else
1039 : {
1040 0 : m_nAttributes3 |= STYLE3_WIDTHVALID;
1041 0 : return GetGeometry()->GetWidth();
1042 : }
1043 0 : return 0;
1044 : }
1045 0 : sal_Bool LwpMiddleLayout::IsSizeRightToContainer(void)
1046 : {
1047 0 : if (!CanSizeRight())
1048 0 : return sal_False;
1049 :
1050 0 : if (m_nOverrideFlag & OVER_SIZE)
1051 : {
1052 0 : return (m_nDirection & ((LAY_USEDIRECTION|LAY_AUTOSIZE|LAY_TOCONTAINER)
1053 : << SHIFT_RIGHT))
1054 0 : == ((LAY_USEDIRECTION | LAY_TOCONTAINER | LAY_AUTOSIZE) << SHIFT_RIGHT);
1055 : }
1056 0 : else if (m_BasedOnStyle.obj())
1057 : {
1058 0 : LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj());
1059 0 : return pLayout ? pLayout->IsSizeRightToContainer() : sal_False;
1060 : }
1061 : else
1062 0 : return sal_False;
1063 : }
1064 0 : sal_Bool LwpMiddleLayout::IsSizeRightToContent(void)
1065 : {
1066 0 : if (!CanSizeRight())
1067 0 : return sal_False;
1068 :
1069 0 : if (m_nOverrideFlag & OVER_SIZE)
1070 : {
1071 0 : return (m_nDirection & ((LAY_USEDIRECTION|LAY_AUTOSIZE|LAY_TOCONTAINER)
1072 : << SHIFT_RIGHT))
1073 0 : == ((LAY_USEDIRECTION | LAY_AUTOSIZE) << SHIFT_RIGHT);
1074 : }
1075 0 : else if (m_BasedOnStyle.obj())
1076 : {
1077 0 : LwpMiddleLayout * pLayout = dynamic_cast<LwpMiddleLayout *>(m_BasedOnStyle.obj());
1078 0 : return pLayout ? pLayout->IsSizeRightToContent() : sal_False;
1079 : }
1080 : else
1081 0 : return sal_False;
1082 : }
1083 :
1084 : /**
1085 : * @descr: Get layout height
1086 : *
1087 : */
1088 0 : double LwpMiddleLayout::GetHeight()
1089 : {
1090 0 : return GetGeometryHeight();
1091 : }
1092 :
1093 : /**
1094 : * @descr: Get layout height
1095 : *
1096 : */
1097 0 : double LwpMiddleLayout::GetWidth()
1098 : {
1099 0 : return GetGeometryWidth();
1100 : }
1101 : /**
1102 : * @descr: Get layout orgin point
1103 : *
1104 : */
1105 0 : LwpPoint LwpMiddleLayout::GetOrigin()
1106 : {
1107 0 : LwpLayoutGeometry* pGeo = GetGeometry();
1108 0 : if(pGeo)
1109 : {
1110 0 : sal_uInt8 nType = GetRelativeType();
1111 0 : if(nType == LwpLayoutRelativityGuts::LAY_INLINE
1112 0 : || nType == LwpLayoutRelativityGuts::LAY_INLINE_NEWLINE )
1113 : {
1114 0 : return pGeo->GetAbsoluteOrigin();
1115 : }
1116 : else
1117 0 : return pGeo->GetOrigin();
1118 :
1119 : }
1120 :
1121 0 : return LwpPoint();
1122 : }
1123 :
1124 : /**
1125 : * @descr: Whether the fill is pattern fill or not
1126 : * @return: True if yes, false if not.
1127 : */
1128 0 : sal_Bool LwpMiddleLayout::IsPatternFill()
1129 : {
1130 0 : LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
1131 0 : if (pBackgroundStuff)
1132 : {
1133 0 : return pBackgroundStuff->IsPatternFill();
1134 : }
1135 :
1136 0 : return sal_False;
1137 : }
1138 :
1139 : /**
1140 : * @descr: Get the fill pattern style. Data are saved in a XFBGImage object
1141 : * @return: the fill pattern style.
1142 : */
1143 0 : XFBGImage* LwpMiddleLayout::GetFillPattern()
1144 : {
1145 0 : LwpBackgroundStuff* pBackgroundStuff = GetBackgroundStuff();
1146 0 : if (pBackgroundStuff)
1147 : {
1148 0 : return pBackgroundStuff->GetFillPattern();
1149 : }
1150 :
1151 0 : return NULL;
1152 :
1153 : }
1154 :
1155 : /**
1156 : * @descr: Whether the height and width of layout is auto grow
1157 : *
1158 : */
1159 0 : sal_Bool LwpMiddleLayout::IsAutoGrow()
1160 : {
1161 0 : if(m_nOverrideFlag & OVER_SIZE)
1162 : {
1163 0 : return m_nDirection &
1164 : ((LAY_AUTOGROW << SHIFT_UP) | (LAY_AUTOGROW << SHIFT_DOWN) |
1165 : (LAY_AUTOGROW << SHIFT_RIGHT) | (LAY_AUTOGROW << SHIFT_LEFT))
1166 0 : ? sal_True : sal_False;
1167 : }
1168 0 : else if( !m_BasedOnStyle.IsNull() )
1169 : {
1170 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1171 0 : return pLay ? pLay->IsAutoGrow() : sal_False;
1172 : }
1173 0 : return LwpVirtualLayout::IsAutoGrow();
1174 : }
1175 :
1176 : /**
1177 : * @descr: Whether the height of layout is auto grow down
1178 : *
1179 : */
1180 0 : sal_Bool LwpMiddleLayout::IsAutoGrowDown()
1181 : {
1182 0 : if(m_nOverrideFlag & OVER_SIZE)
1183 : {
1184 0 : return m_nDirection & (LAY_AUTOGROW << SHIFT_DOWN) ? sal_True : sal_False;
1185 : }
1186 0 : else if( !m_BasedOnStyle.IsNull() )
1187 : {
1188 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1189 0 : return pLay ? pLay->IsAutoGrowDown() : sal_False;
1190 : }
1191 0 : return LwpVirtualLayout::IsAutoGrowDown();
1192 : }
1193 :
1194 : /**
1195 : * @descr: Whether the height of layout is auto grow up
1196 : *
1197 : */
1198 0 : sal_Bool LwpMiddleLayout::IsAutoGrowUp()
1199 : {
1200 0 : if(m_nOverrideFlag & OVER_SIZE)
1201 : {
1202 0 : return m_nDirection & (LAY_AUTOGROW << SHIFT_UP) ? sal_True : sal_False;
1203 : }
1204 0 : else if( !m_BasedOnStyle.IsNull() )
1205 : {
1206 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1207 0 : return pLay ? pLay->IsAutoGrowUp() : sal_False;
1208 : }
1209 0 : return LwpVirtualLayout::IsAutoGrowUp();
1210 : }
1211 :
1212 : /**
1213 : * @descr: Whether the height of layout is auto grow down
1214 : *
1215 : */
1216 0 : sal_Bool LwpMiddleLayout::IsAutoGrowLeft()
1217 : {
1218 0 : if(m_nOverrideFlag & OVER_SIZE)
1219 : {
1220 0 : return m_nDirection & (LAY_AUTOGROW << SHIFT_LEFT) ? sal_True : sal_False;
1221 : }
1222 0 : else if( !m_BasedOnStyle.IsNull() )
1223 : {
1224 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1225 0 : if (pLay)
1226 0 : return pLay->IsAutoGrowLeft();
1227 : }
1228 0 : return LwpVirtualLayout::IsAutoGrowLeft();
1229 : }
1230 :
1231 : /**
1232 : * @descr: Whether the height of layout is auto grow down
1233 : *
1234 : */
1235 0 : sal_Bool LwpMiddleLayout::IsAutoGrowRight()
1236 : {
1237 0 : if(m_nOverrideFlag & OVER_SIZE)
1238 : {
1239 0 : return m_nDirection & (LAY_AUTOGROW << SHIFT_RIGHT) ? sal_True : sal_False;
1240 : }
1241 0 : else if( !m_BasedOnStyle.IsNull() )
1242 : {
1243 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1244 0 : return pLay ? pLay->IsAutoGrowRight() : sal_False;
1245 : }
1246 0 : return LwpVirtualLayout::IsAutoGrowRight();
1247 : }
1248 :
1249 : /**
1250 : * @descr: Get contents orientation
1251 : *
1252 : */
1253 0 : sal_uInt8 LwpMiddleLayout::GetContentOrientation()
1254 : {
1255 : //content orientation in Graphic objects and OLE objects not supported now
1256 0 : if((m_nOverrideFlag & OVER_ROTATION)&& !m_LayGeometry.IsNull())
1257 : {
1258 0 : LwpLayoutGeometry* pLayGeometry = dynamic_cast<LwpLayoutGeometry*> (m_LayGeometry.obj());
1259 0 : if (pLayGeometry)
1260 0 : return pLayGeometry->GetContentOrientation();
1261 : }
1262 0 : else if( !m_BasedOnStyle.IsNull() )
1263 : {
1264 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1265 0 : if (pLay)
1266 0 : return pLay->GetContentOrientation();
1267 : }
1268 0 : return LwpVirtualLayout::GetContentOrientation();
1269 : }
1270 :
1271 : /**
1272 : * @descr: Whether it is honoring protection
1273 : *
1274 : */
1275 0 : sal_Bool LwpMiddleLayout::HonorProtection()
1276 : {
1277 0 : if(m_nOverrideFlag & OVER_MISC)
1278 : {
1279 0 : if(!(m_nAttributes2 & STYLE2_HONORPROTECTION))
1280 0 : return sal_False;
1281 :
1282 0 : LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
1283 0 : if(pParent && !pParent->IsHeader())
1284 : {
1285 0 : return pParent->HonorProtection();
1286 : }
1287 :
1288 0 : if(m_pFoundry)//is null now
1289 : {
1290 0 : LwpDocument* pDoc = m_pFoundry->GetDocument();
1291 0 : if(pDoc)
1292 : {
1293 0 : return pDoc->HonorProtection();
1294 : }
1295 : }
1296 : }
1297 0 : else if( !m_BasedOnStyle.IsNull() )
1298 : {
1299 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1300 0 : if (pLay)
1301 0 : return pLay->HonorProtection();
1302 : }
1303 :
1304 0 : return LwpVirtualLayout::HonorProtection();
1305 : }
1306 :
1307 : /**
1308 : * @descr: Whether it is pretected
1309 : *
1310 : */
1311 0 : sal_Bool LwpMiddleLayout::IsProtected()
1312 : {
1313 0 : sal_Bool bProtected = sal_False;
1314 0 : if(m_nOverrideFlag & OVER_MISC)
1315 : {
1316 0 : bProtected = (m_nAttributes & STYLE_PROTECTED)!=0;
1317 : }
1318 0 : else if( !m_BasedOnStyle.IsNull() )
1319 : {
1320 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1321 0 : bProtected = pLay ? pLay->IsProtected() : sal_False;
1322 : }
1323 : else
1324 0 : bProtected = LwpVirtualLayout::IsProtected();
1325 :
1326 0 : LwpVirtualLayout* pParent = dynamic_cast<LwpVirtualLayout*> (GetParent()->obj());
1327 0 : if(pParent && !pParent->IsHeader())
1328 : {
1329 : /* If a parent's protected then none of its children can be accessed. */
1330 0 : if(pParent->IsProtected())
1331 0 : return sal_True;
1332 :
1333 0 : if(pParent->HonorProtection())
1334 0 : return bProtected;
1335 :
1336 : /* If our parent isn't honoring protection then we aren't protected. */
1337 0 : return sal_False;
1338 :
1339 : }
1340 0 : if(m_pFoundry)//is null now
1341 : {
1342 0 : LwpDocument* pDoc = m_pFoundry->GetDocument();
1343 0 : if(pDoc)
1344 : {
1345 0 : if (pDoc->HonorProtection())
1346 0 : return bProtected;
1347 :
1348 : /* If the document isn't honoring protection then we aren't protected.*/
1349 0 : return sal_False;
1350 : }
1351 : }
1352 :
1353 0 : return bProtected;
1354 : }
1355 :
1356 : /**
1357 : * @descr: Get watermark layout
1358 : *
1359 : */
1360 0 : LwpVirtualLayout* LwpMiddleLayout::GetWaterMarkLayout()
1361 : {
1362 0 : LwpVirtualLayout* pLay = dynamic_cast<LwpVirtualLayout*>(GetChildHead()->obj());
1363 0 : while(pLay)
1364 : {
1365 0 : if( pLay->IsForWaterMark())
1366 : {
1367 0 : return pLay;
1368 : }
1369 0 : pLay = dynamic_cast<LwpVirtualLayout*> (pLay->GetNext()->obj());
1370 : }
1371 0 : return NULL;
1372 : }
1373 :
1374 : /**
1375 : * @descr: Create and reture xfbgimage object for watermark
1376 : *
1377 : */
1378 0 : XFBGImage* LwpMiddleLayout::GetXFBGImage()
1379 : {
1380 0 : LwpMiddleLayout* pLay = static_cast<LwpMiddleLayout*>(GetWaterMarkLayout());
1381 0 : if(pLay)
1382 : {
1383 : //test BGImage
1384 0 : LwpGraphicObject* pGrfObj = dynamic_cast<LwpGraphicObject*>(pLay->GetContent()->obj());
1385 0 : if(pGrfObj)
1386 : {
1387 0 : XFBGImage* pXFBGImage = new XFBGImage();
1388 :
1389 0 : if(pGrfObj->IsLinked())
1390 : {
1391 : //set file link
1392 0 : OUString linkedfilepath = pGrfObj->GetLinkedFilePath();
1393 0 : OUString fileURL = LwpTools::convertToFileUrl(OUStringToOString(linkedfilepath, osl_getThreadTextEncoding()));
1394 0 : pXFBGImage->SetFileLink(fileURL);
1395 : }
1396 : else
1397 : {
1398 0 : sal_uInt8* pGrafData = NULL;
1399 0 : sal_uInt32 nDataLen = pGrfObj->GetRawGrafData(pGrafData);
1400 0 : pXFBGImage->SetImageData(pGrafData, nDataLen);
1401 0 : if(pGrafData)
1402 : {
1403 0 : delete[] pGrafData;
1404 0 : pGrafData = NULL;
1405 : }
1406 : }
1407 :
1408 : //automatic, top left
1409 0 : pXFBGImage->SetPosition(enumXFAlignStart,enumXFAlignTop);
1410 0 : if(pLay->GetScaleCenter())
1411 : {
1412 : //center
1413 0 : pXFBGImage->SetPosition(enumXFAlignCenter,enumXFAlignCenter);
1414 : }
1415 0 : else if(pLay->GetScaleTile())
1416 : {
1417 : //tile
1418 0 : pXFBGImage->SetRepeate();
1419 : }
1420 : //fit type, area type
1421 0 : if((pLay->GetScaleMode()& LwpLayoutScale::FIT_IN_FRAME)!=0)
1422 : {
1423 0 : if((pLay->GetScaleMode()& LwpLayoutScale::MAINTAIN_ASPECT_RATIO)==0)
1424 : {
1425 0 : pXFBGImage->SetStretch();
1426 : }
1427 : }
1428 0 : return pXFBGImage;
1429 : }
1430 : }
1431 0 : return NULL;
1432 : }
1433 :
1434 : /**
1435 : * @descr: Whether the page uses the printer setting
1436 : *
1437 : */
1438 0 : sal_Bool LwpMiddleLayout::GetUsePrinterSettings()
1439 : {
1440 0 : if(m_nOverrideFlag & OVER_SIZE)
1441 : {
1442 0 : return (m_nAttributes3 & STYLE3_USEPRINTERSETTINGS) != 0;
1443 : }
1444 0 : else if( !m_BasedOnStyle.IsNull() )
1445 : {
1446 0 : LwpMiddleLayout* pLay = dynamic_cast<LwpMiddleLayout*> ( m_BasedOnStyle.obj() );
1447 0 : return pLay ? pLay->GetUsePrinterSettings() : sal_False;
1448 : }
1449 0 : return sal_False;
1450 : }
1451 :
1452 : //Check whether there are contents in the layout
1453 0 : sal_Bool LwpMiddleLayout::HasContent()
1454 : {
1455 0 : LwpObject* content = m_Content.obj();
1456 0 : if(content)
1457 0 : return sal_True;
1458 0 : return sal_False;
1459 : }
1460 : //End by
1461 :
1462 0 : LwpLayout::LwpLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm ) :
1463 0 : LwpMiddleLayout(objHdr, pStrm), m_pUseWhen(new LwpUseWhen)
1464 0 : {}
1465 :
1466 0 : LwpLayout::~LwpLayout()
1467 : {
1468 0 : if (m_pUseWhen)
1469 : {
1470 0 : delete m_pUseWhen;
1471 : }
1472 0 : }
1473 :
1474 0 : void LwpLayout::Read()
1475 : {
1476 0 : LwpObjectStream* pStrm = m_pObjStrm;
1477 :
1478 0 : LwpMiddleLayout::Read();
1479 0 : if (LwpFileHeader::m_nFileRevision < 0x000B)
1480 : {
1481 : // read PreRevBLayout...
1482 : }
1483 : else
1484 : {
1485 0 : sal_uInt16 nSimple = pStrm->QuickReaduInt16();
1486 :
1487 0 : if (!nSimple)
1488 : {
1489 0 : m_pUseWhen->Read(pStrm);
1490 :
1491 0 : sal_uInt8 nFlag = pStrm->QuickReaduInt8();
1492 0 : if (nFlag)
1493 0 : m_Positon.ReadIndexed(pStrm);
1494 : }
1495 :
1496 0 : m_LayColumns.ReadIndexed(pStrm);
1497 0 : m_LayGutterStuff.ReadIndexed(pStrm);
1498 0 : m_LayJoinStuff.ReadIndexed(pStrm);
1499 0 : m_LayShadow.ReadIndexed(pStrm);
1500 :
1501 0 : if (pStrm->CheckExtra())
1502 : {
1503 0 : m_LayExtJoinStuff.ReadIndexed(pStrm);
1504 0 : pStrm->SkipExtra();
1505 : }
1506 : }
1507 0 : }
1508 :
1509 : /**
1510 : * @descr: Get columns number
1511 : *
1512 : */
1513 0 : sal_uInt16 LwpLayout::GetNumCols()
1514 : {
1515 0 : if(m_nOverrideFlag & OVER_COLUMNS)
1516 : {
1517 0 : LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
1518 0 : if(pLayColumns)
1519 : {
1520 0 : return pLayColumns->GetNumCols();
1521 : }
1522 : }
1523 :
1524 0 : LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
1525 0 : if(pStyle)
1526 : {
1527 0 : return pStyle->GetNumCols();
1528 : }
1529 :
1530 0 : return LwpVirtualLayout::GetNumCols();
1531 :
1532 : }
1533 :
1534 : /**
1535 : * @descr: Get column width
1536 : * @param: the order of column
1537 : */
1538 0 : double LwpLayout::GetColWidth(sal_uInt16 nIndex)
1539 : {
1540 0 : if((m_nOverrideFlag & OVER_COLUMNS)||(m_nAttributes2 & STYLE2_LOCALCOLUMNINFO))
1541 : {
1542 0 : LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
1543 0 : if(pLayColumns)
1544 : {
1545 0 : return pLayColumns->GetColWidth(nIndex);
1546 : }
1547 : }
1548 :
1549 0 : LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
1550 0 : if(pStyle)
1551 : {
1552 0 : return pStyle->GetColWidth(nIndex);
1553 : }
1554 :
1555 0 : return LwpVirtualLayout::GetColWidth(nIndex);
1556 :
1557 : }
1558 :
1559 : /**
1560 : * @descr: Get gap between columns
1561 : * @param: the order of column
1562 : */
1563 0 : double LwpLayout::GetColGap(sal_uInt16 nIndex)
1564 : {
1565 0 : if((m_nOverrideFlag & OVER_COLUMNS)||(m_nAttributes2 & STYLE2_LOCALCOLUMNINFO))
1566 : {
1567 0 : LwpLayoutColumns* pLayColumns = dynamic_cast<LwpLayoutColumns*>(m_LayColumns.obj());
1568 0 : if(pLayColumns)
1569 : {
1570 0 : return pLayColumns->GetColGap(nIndex);
1571 : }
1572 : }
1573 :
1574 0 : LwpVirtualLayout* pStyle = dynamic_cast<LwpVirtualLayout*> (m_BasedOnStyle.obj());
1575 0 : if(pStyle)
1576 : {
1577 0 : return pStyle->GetColGap(nIndex);
1578 : }
1579 :
1580 0 : return LwpVirtualLayout::GetColGap(nIndex);
1581 : }
1582 :
1583 : /**
1584 : * @descr: Create and return XFColumns object
1585 : *
1586 : */
1587 0 : XFColumns* LwpLayout::GetXFColumns()
1588 : {
1589 : //if there is only one column, do not need insert columns
1590 0 : sal_uInt16 nCols = GetNumCols();
1591 0 : if(nCols==1)
1592 : {
1593 0 : return NULL;
1594 : }
1595 :
1596 0 : XFColumns* pColumns = new XFColumns();
1597 : //set XFColumnSep
1598 0 : boost::scoped_ptr<XFColumnSep> pColumnSep(GetColumnSep());
1599 0 : if(pColumnSep)
1600 : {
1601 0 : pColumns->SetSeparator(*pColumnSep);
1602 : }
1603 :
1604 : //set column count and column gap
1605 0 : pColumns->SetCount(nCols);
1606 0 : double fGap = GetColGap(0);
1607 0 : pColumns->SetGap(fGap);
1608 :
1609 : //set xfcolumn
1610 0 : for(sal_uInt16 nIndex = 0; nIndex<nCols; nIndex++)
1611 : {
1612 0 : XFColumn aColumn;
1613 0 : sal_Int32 nWidth = static_cast<sal_Int32>(GetColWidth(nIndex));
1614 0 : nWidth=8305/nCols; //relative width
1615 0 : aColumn.SetRelWidth(nWidth);
1616 :
1617 : //the left and right margins is 0;
1618 0 : double nGap = GetColGap(nIndex)/2;
1619 : //nGap=0;
1620 0 : aColumn.SetMargins(nGap,nGap);
1621 0 : if(nIndex==0)
1622 : {
1623 0 : aColumn.SetMargins(0,nGap);
1624 : }
1625 0 : if(nIndex==(nCols-1))
1626 : {
1627 0 : aColumn.SetMargins(nGap,0);
1628 : }
1629 0 : pColumns->AddColumn(aColumn);
1630 0 : }
1631 :
1632 0 : return pColumns;
1633 : }
1634 :
1635 : /**
1636 : * @descr: Create and return XFColumnSep object
1637 : *
1638 : */
1639 0 : XFColumnSep* LwpLayout::GetColumnSep()
1640 : {
1641 :
1642 : //Get LwpLayoutGutters
1643 0 : LwpLayoutGutters* pLayoutGutters = dynamic_cast<LwpLayoutGutters*>(m_LayGutterStuff.obj());
1644 0 : if(!pLayoutGutters)
1645 : {
1646 0 : return NULL;
1647 : }
1648 :
1649 0 : LwpBorderStuff* pBorderStuff = pLayoutGutters->GetBorderStuff();
1650 :
1651 0 : if(pBorderStuff)
1652 : {
1653 0 : LwpBorderStuff::BorderType eType = LwpBorderStuff::LEFT;
1654 0 : LwpColor aColor = pBorderStuff->GetSideColor(eType);
1655 0 : double fWidth = pBorderStuff->GetSideWidth(eType);
1656 : //sal_uInt16 nType = pBorderStuff->GetSideType(eType);
1657 :
1658 0 : XFColumnSep* pColumnSep = new XFColumnSep();
1659 0 : XFColor aXFColor(aColor.To24Color());
1660 0 : pColumnSep->SetColor(aXFColor);
1661 0 : pColumnSep->SetWidth(fWidth);
1662 0 : pColumnSep->SetRelHeight(100);
1663 0 : pColumnSep->SetVerticalAlign(enumXFAlignTop);
1664 :
1665 0 : return pColumnSep;
1666 : }
1667 0 : return NULL;
1668 :
1669 : }
1670 :
1671 : /**
1672 : * @descr: Get use when type
1673 : *
1674 : */
1675 0 : LwpLayout::UseWhenType LwpLayout::GetUseWhenType()
1676 : {
1677 0 : UseWhenType eType = StartWithinPage;
1678 0 : LwpUseWhen* pUseWhen = GetUseWhen();
1679 0 : if(pUseWhen)
1680 : {
1681 0 : if(pUseWhen->IsStartOnThisHF())
1682 : {
1683 0 : eType = StartWithinColume;
1684 : }
1685 0 : else if(pUseWhen->IsStartOnThisPage())
1686 : {
1687 0 : eType = StartWithinPage;
1688 : }
1689 0 : else if(pUseWhen->IsStartOnNextPage())
1690 : {
1691 0 : eType = StartOnNextPage;
1692 : }
1693 0 : else if(pUseWhen->IsStartOnNextOddPage())
1694 : {
1695 0 : eType = StartOnOddPage;
1696 : }
1697 0 : else if(pUseWhen->IsStartOnNextEvenPage())
1698 : {
1699 0 : eType = StartOnEvenPage;
1700 : }
1701 :
1702 : }
1703 : else
1704 : {
1705 0 : eType = StartOnNextPage;
1706 : }
1707 0 : return eType;
1708 : }
1709 :
1710 : /**
1711 : * @descr: Get use page
1712 : *
1713 : */
1714 0 : sal_uInt16 LwpLayout::GetUsePage()
1715 : {
1716 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
1717 : {
1718 0 : LwpUseWhen* pUseWhen = GetUseWhen();
1719 0 : if(pUseWhen)
1720 0 : return pUseWhen->GetUsePage();
1721 : else
1722 0 : return 0;
1723 : }
1724 0 : else if( !m_BasedOnStyle.IsNull() )
1725 : {
1726 0 : LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
1727 0 : return pLay ? pLay->GetUsePage() : 0;
1728 : }
1729 0 : return 0;
1730 : }
1731 :
1732 : /**
1733 : * @descr: Get usewhen pointer
1734 : *
1735 : */
1736 0 : LwpUseWhen* LwpLayout::VirtualGetUseWhen()
1737 : {
1738 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
1739 : {
1740 0 : return m_pUseWhen;
1741 : }
1742 0 : else if( !m_BasedOnStyle.IsNull() )
1743 : {
1744 0 : LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
1745 0 : return pLay ? pLay->VirtualGetUseWhen() : NULL;
1746 : }
1747 0 : return LwpVirtualLayout::VirtualGetUseWhen();
1748 : }
1749 :
1750 : /**
1751 : * @descr: Whether it is use on all pages
1752 : *
1753 : */
1754 0 : sal_Bool LwpLayout::IsUseOnAllPages()
1755 : {
1756 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
1757 : {
1758 0 : LwpUseWhen* pUseWhen = GetUseWhen();
1759 0 : if(pUseWhen)
1760 0 : return pUseWhen->IsUseOnAllPages();
1761 : else
1762 0 : return sal_False;
1763 : }
1764 0 : else if( !m_BasedOnStyle.IsNull() )
1765 : {
1766 0 : LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
1767 0 : if (pLay)
1768 0 : return pLay->IsUseOnAllPages();
1769 : }
1770 0 : return LwpVirtualLayout::IsUseOnAllPages();
1771 : }
1772 :
1773 : /**
1774 : * @descr: Whether it is use on all even pages
1775 : *
1776 : */
1777 0 : sal_Bool LwpLayout::IsUseOnAllEvenPages()
1778 : {
1779 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
1780 : {
1781 0 : LwpUseWhen* pUseWhen = GetUseWhen();
1782 0 : if(pUseWhen)
1783 0 : return pUseWhen->IsUseOnAllEvenPages();
1784 : else
1785 0 : return sal_False;
1786 : }
1787 0 : else if( !m_BasedOnStyle.IsNull() )
1788 : {
1789 0 : LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
1790 0 : if (pLay)
1791 0 : return pLay->IsUseOnAllEvenPages();
1792 : }
1793 0 : return LwpVirtualLayout::IsUseOnAllEvenPages();
1794 : }
1795 :
1796 : /**
1797 : * @descr: Whether it is use on all odd pages
1798 : *
1799 : */
1800 0 : sal_Bool LwpLayout::IsUseOnAllOddPages()
1801 : {
1802 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
1803 : {
1804 0 : LwpUseWhen* pUseWhen = GetUseWhen();
1805 0 : if(pUseWhen)
1806 0 : return pUseWhen->IsUseOnAllOddPages();
1807 : else
1808 0 : return sal_False;
1809 : }
1810 0 : else if( !m_BasedOnStyle.IsNull() )
1811 : {
1812 0 : LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
1813 0 : if (pLay)
1814 0 : return pLay->IsUseOnAllOddPages();
1815 : }
1816 0 : return LwpVirtualLayout::IsUseOnAllOddPages();
1817 : }
1818 :
1819 : /**
1820 : * @descr: Whether it is use on current page
1821 : *
1822 : */
1823 0 : sal_Bool LwpLayout::IsUseOnPage()
1824 : {
1825 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
1826 : {
1827 0 : LwpUseWhen* pUseWhen = GetUseWhen();
1828 0 : if(pUseWhen)
1829 0 : return pUseWhen->IsUseOnPage();
1830 : else
1831 0 : return sal_False;
1832 : }
1833 0 : else if( !m_BasedOnStyle.IsNull() )
1834 : {
1835 0 : LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
1836 0 : if (pLay)
1837 0 : return pLay->IsUseOnPage();
1838 : }
1839 0 : return LwpVirtualLayout::IsUseOnPage();
1840 : }
1841 :
1842 : /**
1843 : * @descr: Get the LwpShadow object according to m_LayShadow id.
1844 : * @param:
1845 : * @param:
1846 : * @return:
1847 : */
1848 0 : LwpShadow* LwpLayout::GetShadow()
1849 : {
1850 0 : if(m_nOverrideFlag & OVER_SHADOW)
1851 : {
1852 0 : LwpLayoutShadow* pLayoutShadow = dynamic_cast<LwpLayoutShadow*>(m_LayShadow.obj());
1853 0 : return pLayoutShadow ? pLayoutShadow->GetShadow() : NULL;
1854 : }
1855 0 : else if( !m_BasedOnStyle.IsNull() )
1856 : {
1857 0 : LwpLayout* pLay = dynamic_cast<LwpLayout*> ( m_BasedOnStyle.obj() );
1858 0 : return pLay ? pLay->GetShadow() : NULL;
1859 : }
1860 0 : return NULL;
1861 : }
1862 :
1863 : /**
1864 : * @descr: create xfshadow
1865 : * @param:
1866 : * @param:
1867 : * @return:
1868 : */
1869 0 : XFShadow* LwpLayout::GetXFShadow()
1870 : {
1871 0 : LwpShadow* pShadow = GetShadow();
1872 0 : if( pShadow )
1873 : {
1874 0 : LwpColor color = pShadow->GetColor();
1875 0 : double offsetX = pShadow->GetOffsetX();
1876 0 : double offsetY = pShadow->GetOffsetY();
1877 :
1878 0 : if( offsetX && offsetY && color.IsValidColor() )
1879 : {
1880 0 : XFShadow* pXFShadow = new XFShadow();
1881 0 : enumXFShadowPos eXFShadowPos = enumXFShadowLeftTop;
1882 0 : double fOffset = 0;
1883 :
1884 0 : sal_Bool left = sal_False;
1885 0 : sal_Bool top = sal_False;
1886 0 : if( offsetX < 0 )
1887 0 : left = sal_True;
1888 0 : if( offsetY < 0 )
1889 0 : top = sal_True;
1890 0 : if( left )
1891 : {
1892 0 : fOffset = -offsetX;
1893 0 : if( top )
1894 0 : eXFShadowPos = enumXFShadowLeftTop;
1895 : else
1896 0 : eXFShadowPos = enumXFShadowLeftBottom;
1897 : }
1898 : else
1899 : {
1900 0 : fOffset = offsetX;
1901 0 : if( top )
1902 0 : eXFShadowPos = enumXFShadowRightTop;
1903 : else
1904 0 : eXFShadowPos = enumXFShadowRightBottom;
1905 : }
1906 :
1907 0 : pXFShadow->SetPosition(eXFShadowPos);
1908 0 : pXFShadow->SetOffset(fOffset);
1909 0 : pXFShadow->SetColor(XFColor(color.To24Color()));
1910 :
1911 0 : return pXFShadow;
1912 0 : }
1913 : }
1914 0 : return NULL;
1915 : }
1916 :
1917 : /**
1918 : * @descr get the layout that containers the current frame layout
1919 : *
1920 : */
1921 0 : LwpVirtualLayout* LwpLayout::GetContainerLayout()
1922 : {
1923 0 : if(IsRelativeAnchored())
1924 : {
1925 : //get position
1926 0 : LwpPara* pPara = dynamic_cast<LwpPara*>(GetPosition()->obj());
1927 0 : if(pPara)
1928 : {
1929 0 : LwpStory* pStory = pPara->GetStory();
1930 0 : return pStory ? pStory->GetTabLayout() : NULL;
1931 : }
1932 : }
1933 0 : return GetParentLayout();
1934 : }
1935 :
1936 0 : LwpPlacableLayout::LwpPlacableLayout( LwpObjectHeader &objHdr, LwpSvStream* pStrm )
1937 : : LwpLayout(objHdr, pStrm)
1938 : , m_nWrapType(0)
1939 : , m_nBuoyancy(0)
1940 : , m_nBaseLineOffset(0)
1941 : , m_nPageNumber(0)
1942 0 : , m_pFont(NULL)
1943 0 : {}
1944 :
1945 0 : LwpPlacableLayout::~LwpPlacableLayout()
1946 0 : {}
1947 :
1948 0 : void LwpPlacableLayout::Read()
1949 : {
1950 0 : LwpObjectStream* pStrm = m_pObjStrm;
1951 0 : LwpLayout::Read();
1952 0 : if(LwpFileHeader::m_nFileRevision < 0x000B)
1953 : {
1954 : assert(false);
1955 : }
1956 : else
1957 : {
1958 0 : sal_uInt16 simple = pStrm->QuickReaduInt16();
1959 0 : if(!simple)
1960 : {
1961 0 : m_nWrapType = pStrm->QuickReaduInt8();
1962 0 : m_nBuoyancy = pStrm->QuickReaduInt8();
1963 0 : m_nBaseLineOffset = pStrm->QuickReadInt32();
1964 0 : m_Script.Read( pStrm);
1965 : }
1966 : else
1967 : {
1968 0 : m_nWrapType = LAY_WRAP_AROUND;
1969 0 : m_nBuoyancy = LAY_BUOYNEUTRAL;
1970 0 : m_nBaseLineOffset = 0;
1971 : }
1972 0 : m_LayRelativity.ReadIndexed( pStrm);
1973 0 : if(pStrm->CheckExtra())
1974 : {
1975 0 : sal_uInt16 count = pStrm->QuickReaduInt16();
1976 0 : if(count)
1977 : {
1978 : // temporily added by to avoid assertion
1979 0 : while (count)
1980 : {
1981 0 : LwpPoint aPoint;
1982 0 : aPoint.Read(pStrm);
1983 0 : count--;
1984 : }
1985 : // end added by
1986 : }
1987 0 : pStrm->SkipExtra();
1988 : }
1989 : }
1990 0 : }
1991 : /**
1992 : * @descr: get wrap type
1993 : * @param:
1994 : * @param:
1995 : * @return:
1996 : */
1997 0 : sal_uInt8 LwpPlacableLayout::GetWrapType()
1998 : {
1999 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
2000 : {
2001 0 : return m_nWrapType;
2002 : }
2003 0 : else if( !m_BasedOnStyle.IsNull() )
2004 : {
2005 0 : LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
2006 0 : if (pLay)
2007 0 : return pLay->GetWrapType();
2008 : }
2009 0 : return LAY_WRAP_AROUND;
2010 : }
2011 : /**
2012 : * @descr: get LayoutRelativity
2013 : * @param:
2014 : * @param:
2015 : * @return:
2016 : */
2017 0 : LwpLayoutRelativity* LwpPlacableLayout::GetRelativityPiece()
2018 : {
2019 0 : if(!m_LayRelativity.IsNull())
2020 : {
2021 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
2022 : {
2023 0 : return dynamic_cast<LwpLayoutRelativity*>(m_LayRelativity.obj());
2024 : }
2025 : }
2026 0 : else if( !m_BasedOnStyle.IsNull() )
2027 : {
2028 0 : LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
2029 0 : return pLay ? pLay->GetRelativityPiece() : NULL;
2030 : }
2031 0 : return NULL;
2032 : }
2033 : /**
2034 : * @descr: Get relative type
2035 : *
2036 : */
2037 0 : sal_uInt8 LwpPlacableLayout::GetRelativeType()
2038 : {
2039 0 : LwpLayoutRelativity* pLayRel = GetRelativityPiece();
2040 0 : if(pLayRel)
2041 : {
2042 0 : return pLayRel->GetRelGuts()->GetRelativeType();
2043 : }
2044 0 : return LwpVirtualLayout::GetRelativeType();
2045 : }
2046 : /**
2047 : * @descr: Get offset from the baseline
2048 : *
2049 : */
2050 0 : sal_Int32 LwpPlacableLayout::GetBaseLineOffset()
2051 : {
2052 : /* The baseline is only valid if this is flow-with-text */
2053 0 : if(GetRelativeType()!=LwpLayoutRelativityGuts::LAY_INLINE)
2054 : {
2055 0 : return 0;
2056 : }
2057 :
2058 : // First, ask our content if it has a baseline, ignore now
2059 : /*
2060 : if (Content && Content->GetBaseLineOffset(&Baseline))
2061 : return Baseline;
2062 : */
2063 :
2064 0 : if(m_nOverrideFlag & OVER_PLACEMENT)
2065 : {
2066 0 : return m_nBaseLineOffset;
2067 : }
2068 0 : else if( !m_BasedOnStyle.IsNull() )
2069 : {
2070 0 : LwpPlacableLayout* pLay = dynamic_cast<LwpPlacableLayout*> ( m_BasedOnStyle.obj() );
2071 0 : return pLay ? pLay->GetBaseLineOffset() : 0;
2072 : }
2073 0 : return 0;
2074 :
2075 : }
2076 : /**
2077 : * @descr: whether the parent layout is page layout
2078 : *
2079 : */
2080 0 : sal_Bool LwpPlacableLayout::IsAnchorPage()
2081 : {
2082 0 : if(IsRelativeAnchored())
2083 0 : return sal_False;
2084 :
2085 0 : LwpVirtualLayout* pLayout = GetParentLayout();
2086 0 : if(pLayout && (pLayout->IsPage() || pLayout->IsHeader() || pLayout->IsFooter()))
2087 : //if(pLayout && pLayout->IsPage())
2088 : {
2089 0 : return sal_True;
2090 : }
2091 0 : return sal_False;
2092 : }
2093 : /**
2094 : * @descr: whether the parent layout is frame layout
2095 : *
2096 : */
2097 0 : sal_Bool LwpPlacableLayout::IsAnchorFrame()
2098 : {
2099 0 : if(IsRelativeAnchored())
2100 0 : return sal_False;
2101 :
2102 0 : LwpVirtualLayout* pLayout = GetParentLayout();
2103 0 : if(pLayout && (pLayout->IsFrame()||pLayout->IsGroupHead()))
2104 : {
2105 0 : return sal_True;
2106 : }
2107 0 : return sal_False;
2108 : }
2109 : /**
2110 : * @descr: whether the parent layout is cell layout
2111 : *
2112 : */
2113 0 : sal_Bool LwpPlacableLayout::IsAnchorCell()
2114 : {
2115 0 : if(IsRelativeAnchored())
2116 0 : return sal_False;
2117 :
2118 0 : LwpVirtualLayout* pLayout = GetParentLayout();
2119 0 : if(pLayout && pLayout->IsCell())
2120 : {
2121 0 : return sal_True;
2122 : }
2123 0 : return sal_False;
2124 : }
2125 :
2126 : /**
2127 : * @descr: Get font style for setting position of frame
2128 : *
2129 : */
2130 0 : XFFont* LwpPlacableLayout::GetFont()
2131 : {
2132 0 : return m_pFont;
2133 : }
2134 : /**
2135 : * @descr: Set font style for setting position of frame
2136 : *
2137 : */
2138 0 : void LwpPlacableLayout::SetFont(XFFont * pFont)
2139 : {
2140 0 : m_pFont = pFont;
2141 0 : }
2142 :
2143 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|