tdf#131098 docx export: write fill property of graphic
[LibreOffice.git] / lotuswordpro / source / filter / lwpcelllayout.cxx
blobd2de666aad2c0794181b992a029051360eb9412f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
5 * either of the following licenses
7 * - GNU Lesser General Public License Version 2.1
8 * - Sun Industry Standards Source License Version 1.1
10 * Sun Microsystems Inc., October, 2000
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
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.
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.
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
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.
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.
46 * The Initial Developer of the Original Code is: IBM Corporation
48 * Copyright: 2008 by IBM Corporation
50 * All Rights Reserved.
52 * Contributor(s): _______________________________________
55 ************************************************************************/
56 /**
57 * @file
58 * For LWP filter architecture prototype - cell layouts
61 #include <memory>
62 #include "lwpcelllayout.hxx"
63 #include "lwpnumericfmt.hxx"
64 #include "lwptable.hxx"
65 #include "lwprowlayout.hxx"
66 #include <lwpfilehdr.hxx>
67 #include <lwpglobalmgr.hxx>
69 #include <sal/log.hxx>
70 #include <comphelper/configuration.hxx>
72 #include <xfilter/xfstylemanager.hxx>
73 #include <xfilter/xfcell.hxx>
74 #include <xfilter/xfcellstyle.hxx>
75 #include <xfilter/xfcolstyle.hxx>
77 LwpCellLayout::LwpCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
78 : LwpMiddleLayout(objHdr, pStrm)
79 , m_bConvertCell(false)
80 , crowid(0)
81 , ccolid(0)
82 , cType(LDT_NONE)
86 LwpCellLayout::~LwpCellLayout()
89 /**
90 * @short Get table layout pointer, if default cell layout, return NULL
91 * @param LwpTableLayout *
92 * @return
94 LwpTableLayout * LwpCellLayout::GetTableLayout()
96 LwpRowLayout * pRow = dynamic_cast<LwpRowLayout *>(GetParent().obj().get());
97 if(!pRow)
99 return nullptr;
101 LwpTableLayout * pTableLayout = pRow->GetParentTableLayout();
102 return pTableLayout;
105 * @short Get table pointer, if default cell layout, return NULL
106 * @param LwpTable *
107 * @return
109 LwpTable * LwpCellLayout::GetTable()
111 LwpTableLayout * pTableLayout = GetTableLayout();
112 if(!pTableLayout)
114 return nullptr;
116 LwpTable *pTable = pTableLayout->GetTable();
117 return pTable;
120 * @short Set current cell layout to cell layout map
121 * @param
122 * @return
124 void LwpCellLayout::SetCellMap()
126 LwpTableLayout * pTableLayout = GetTableLayout();
127 if (pTableLayout)
128 pTableLayout->SetWordProCellMap(crowid, ccolid, this);
131 * @short Get actual width of this cell layout
132 * @param
133 * @return width (cm)
135 double LwpCellLayout::GetActualWidth()
137 //Get table layout
138 LwpTableLayout * pTableLayout = GetTableLayout();
140 if (pTableLayout == nullptr)
142 return GetGeometryWidth();
145 OUString strColStyle = pTableLayout->GetColumnWidth(ccolid);
147 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
148 XFColStyle *pStyle = static_cast<XFColStyle *>(pXFStyleManager->FindStyle(strColStyle));
149 if(pStyle)
151 return pStyle->GetWidth();
154 return GetGeometryWidth();
158 * @short Apply padding to cell style
159 * @param pCellStyle - pointer of XFCellStyle
160 * @return
162 void LwpCellLayout::ApplyPadding(XFCellStyle *pCellStyle)
164 double fLeft = GetMarginsValue(MARGIN_LEFT);
165 double fRight = GetMarginsValue(MARGIN_RIGHT);
166 double fTop = GetMarginsValue(MARGIN_TOP);
167 double fBottom = GetMarginsValue(MARGIN_BOTTOM);
168 pCellStyle->SetPadding(static_cast<float>(fLeft),static_cast<float>(fRight),static_cast<float>(fTop),static_cast<float>(fBottom));
171 * @short Apply border to cell style according to cell position, default cell layout won't use this function
172 * @param
173 * @return pCellStyle - pointer of XFCellStyle
175 void LwpCellLayout::ApplyBorders(XFCellStyle *pCellStyle)
177 // judge cell border type
178 LwpCellBorderType eType = GetCellBorderType(crowid, ccolid, GetTableLayout());
180 // get left cell and judge if neighbour border is different
181 std::unique_ptr<XFBorders> xBorders(GetXFBorders());
182 if (!xBorders)
184 return;
187 switch (eType)
189 case enumNoBottomBorder:
190 xBorders->SetWidth(enumXFBorderBottom, 0);
191 break;
192 case enumNoLeftBorder:
193 xBorders->SetWidth(enumXFBorderLeft, 0);
194 break;
195 case enumNoLeftNoBottomBorder:
196 xBorders->SetWidth(enumXFBorderBottom, 0);
197 xBorders->SetWidth(enumXFBorderLeft, 0);
198 break;
199 case enumWholeBorder:
200 break;
201 default:
202 assert(false);
204 pCellStyle->SetBorders(xBorders.release());
207 * @short Apply watermark to cell style
208 * @param pCellStyle - pointer of XFCellStyle
209 * @return
211 void LwpCellLayout::ApplyWatermark(XFCellStyle *pCellStyle)
213 std::unique_ptr<XFBGImage> xBGImage(GetXFBGImage());
214 if (xBGImage)
216 pCellStyle->SetBackImage(xBGImage);
221 * @short Apply pattern fill to cell style
222 * @param pCellStyle - pointer of XFCellStyle
223 * @return
225 void LwpCellLayout::ApplyPatternFill(XFCellStyle* pCellStyle)
227 std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
228 if (xXFBGImage)
230 pCellStyle->SetBackImage(xXFBGImage);
235 * @short Apply background to cell style
236 * @param pCellStyle - pointer of XFCellStyle
237 * @return
239 void LwpCellLayout::ApplyBackGround(XFCellStyle* pCellStyle)
241 if (IsPatternFill())
243 ApplyPatternFill(pCellStyle);
245 else
247 ApplyBackColor(pCellStyle);
251 * @short Apply back color to cell style
252 * @param pCellStyle - pointer of XFCellStyle
253 * @return
255 void LwpCellLayout::ApplyBackColor(XFCellStyle *pCellStyle)
257 LwpColor* pColor = GetBackColor();
258 if(pColor && pColor->IsValidColor())
260 XFColor aXFColor(pColor->To24Color());
261 pCellStyle->SetBackColor(aXFColor);
265 * @short register style of cell layout
266 * @param pCellStyle The style of the cell, which would be applied to the cell.
267 * @return
269 void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle)
271 LwpLayoutNumerics* pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(cLayNumerics.obj().get());
272 if (!pLayoutNumerics)
274 // if current layout doesn't have format, go to based on layout
275 LwpCellLayout* pCellLayout = dynamic_cast<LwpCellLayout*>(GetBasedOnStyle().get());
276 if (pCellLayout)
278 pLayoutNumerics = dynamic_cast<LwpLayoutNumerics*>(pCellLayout->GetNumericsObject().obj().get());
282 // apply format style
283 if (pLayoutNumerics)
285 XFStyle* pStyle = pLayoutNumerics->Convert();
286 if (pStyle)
288 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
289 m_NumfmtName = pXFStyleManager->AddStyle(std::unique_ptr<XFStyle>(pStyle)).m_pStyle->GetStyleName();
290 pCellStyle->SetDataStyle(m_NumfmtName);
295 * @short get style name according to cell position, only table default cells use this function
296 * @param nRow - default cell position row number
297 * @param nCol - default cell position col number
298 * @return OUString - registered cell style name
300 OUString const & LwpCellLayout::GetCellStyleName(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
302 // judge cell border type
303 LwpCellBorderType eType = GetCellBorderType(nRow, nCol, pTableLayout);
304 return m_CellStyleNames[eType];
307 * Make the XFCell
308 * @param aTableID - ID of the table which this cell belongs to
309 * @param bIsTopRow - whether current cell is top row
310 * @param bIsRightCol - whether current cell is the rightest column
311 * @return XFCell*
313 rtl::Reference<XFCell> LwpCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
315 // if cell layout is aTableID's default cell layout
316 // it can't have any content, bypass these code
317 LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
318 if (!pTable)
320 assert(false);
321 return nullptr;
323 rtl::Reference<XFCell> xXFCell(new XFCell);
324 OUString aStyleName = m_StyleName;
326 // if cell layout is aTableID's default cell layout
327 // we should adjust its style by current position
328 if (pTable->GetDefaultCellStyle() == GetObjectID())
330 aStyleName = GetCellStyleName(nRow, nCol, pTable->GetTableLayout().get());
333 // content of cell
334 LwpStory* pStory = dynamic_cast<LwpStory*>(m_Content.obj().get());
335 if (pStory)
337 pStory->XFConvert(xXFCell.get());
340 ApplyProtect(xXFCell.get(), aTableID);
341 xXFCell->SetStyleName(aStyleName);
342 return xXFCell;
345 LwpPara* LwpCellLayout::GetLastParaOfPreviousStory()
347 LwpObjectID* pPreStoryID = GetPreviousCellStory();
348 if (pPreStoryID && !(pPreStoryID->IsNull()))
350 LwpStory* pPreStory = dynamic_cast<LwpStory*>(pPreStoryID->obj(VO_STORY).get());
351 if (!pPreStory)
353 SAL_WARN("lwp", "unexpected null VO_STORY");
354 return nullptr;
356 return dynamic_cast<LwpPara*>(pPreStory->GetLastPara().obj(VO_PARA).get());
358 else
360 return nullptr;
365 * @short Get previous cell which used for bullet inside cell
366 * @param
367 * @return LwpObjectID * - object ID of cell content story
369 LwpObjectID * LwpCellLayout::GetPreviousCellStory()
371 LwpTable *pTable = GetTable();
372 if (!pTable)
374 assert(false);
375 return nullptr;
377 sal_uInt16 nRow = crowid;
378 sal_uInt16 nCol = ccolid;
380 // if table is reset paragraph in columns, get cell on the top side of current cell
381 if (pTable->IsNumberDown())
383 if (nRow == 0)
385 return nullptr;
387 nRow -=1;
389 else
391 // if not, get cell on the left side of current cell
392 if (nCol == 0)
394 if (nRow == 0)
396 return nullptr;
398 else
400 nRow--;
401 nCol = pTable->GetColumn() - 1;
404 else
406 nCol -=1;
410 // get the object id pointer of previous cell story
411 LwpTableLayout * pTableLayout = GetTableLayout();
412 if (!pTableLayout)
414 assert(false);
415 return nullptr;
417 return pTableLayout->SearchCellStoryMap(nRow, nCol);
421 * @short judge border type by cell neighbour
422 * @param nRow
423 * @param nCol
424 * @param pTableLayout
425 * @return LwpCellBorderType
427 LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
429 if (!pTableLayout)
430 return enumWholeBorder;
432 // get left cell and judge if neighbour border is different
433 std::unique_ptr<XFBorders> xBorders(GetXFBorders());
434 if (!xBorders)
436 return enumWholeBorder;
438 XFBorder& rLeftBorder = xBorders->GetLeft();
439 XFBorder& rBottomBorder = xBorders->GetBottom();
440 bool bNoLeftBorder = false;
441 bool bNoBottomBorder = false;
443 LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow, GetLeftColID(nCol), pTableLayout);
444 if (pLeftNeighbour)
446 std::unique_ptr<XFBorders> pNeighbourBorders = pLeftNeighbour->GetXFBorders();
447 if (pNeighbourBorders)
449 XFBorder& rRightBorder = pNeighbourBorders->GetRight();
450 if (rLeftBorder == rRightBorder)
452 // for these 2 types cell, left border should be ignored for sake of avoiding duplication border
453 // but if left border is different with right border of left cell
454 // we should not ignored it
455 bNoLeftBorder = true;
461 LwpCellLayout * pBelowNeighbour = GetCellByRowCol(GetBelowRowID(nRow), nCol, pTableLayout);
462 if (pBelowNeighbour) //&& (eType == enumRightNotLastCellBorder || eType == enumLeftNotLastCellBorder) )
464 std::unique_ptr<XFBorders> pBelowBorders = pBelowNeighbour->GetXFBorders();
465 if (pBelowBorders)
467 XFBorder& rTopBorder = pBelowBorders->GetTop();
468 if (rTopBorder == rBottomBorder)
470 // for these 2 types cell, bottom border should be ignored for sake of avoiding duplication border
471 // but if bottom border is different with right border of left cell
472 // we should not ignored it
473 bNoBottomBorder = true;
478 xBorders.reset();
480 if (bNoBottomBorder)
482 if (bNoLeftBorder)
484 return enumNoLeftNoBottomBorder;
486 return enumNoBottomBorder;
488 if (bNoLeftBorder)
490 return enumNoLeftBorder;
492 return enumWholeBorder;
496 * @short Get neighbour cell by specifying ROW+COL
497 * @param nRow
498 * @param nCol
499 * @return LwpCellLayout *
501 LwpCellLayout * LwpCellLayout::GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
503 return pTableLayout->GetCellByRowCol(nRow, nCol);
506 * @short Register table's default cell layout
507 * @param
508 * @return
510 void LwpCellLayout::RegisterDefaultCell()
512 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
513 for (sal_uInt16 eLoop = enumWholeBorder; eLoop < enumCellBorderTopLimit; eLoop++)
515 // register cell style
516 std::unique_ptr<XFCellStyle> xCellStyle(new XFCellStyle());
518 ApplyPadding(xCellStyle.get());
519 ApplyBackColor(xCellStyle.get());
520 ApplyWatermark(xCellStyle.get());
521 ApplyFmtStyle(xCellStyle.get());
522 xCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
524 std::unique_ptr<XFBorders> xBorders(GetXFBorders());
525 if (xBorders)
527 switch(eLoop)
529 case enumNoBottomBorder:
531 //| |
533 // remove bottom line
534 xBorders->SetWidth(enumXFBorderBottom, 0);
535 break;
536 case enumNoLeftNoBottomBorder:
538 // |
540 // remove left and bottom
541 xBorders->SetWidth(enumXFBorderLeft, 0);
542 xBorders->SetWidth(enumXFBorderBottom, 0);
543 break;
544 case enumWholeBorder:
546 //||
548 // nothing to remove
549 break;
550 case enumNoLeftBorder:
552 //| |
554 // remove left line
555 xBorders->SetWidth(enumXFBorderLeft, 0);
556 break;
557 default:
558 assert(false);
560 xCellStyle->SetBorders(xBorders.release());
562 m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(std::move(xCellStyle)).m_pStyle->GetStyleName();
566 * @short Register 4 types of cell style and register content styles
567 * @param
568 * @param
569 * @param
570 * @return
572 void LwpCellLayout::RegisterStyle()
574 rtl::Reference<LwpVirtualLayout> xParent(dynamic_cast<LwpVirtualLayout *>(GetParent().obj().get()));
575 if (!xParent.is() || xParent->GetLayoutType() != LWP_ROW_LAYOUT)
577 // default cell layout, we must register 4 styles for it
578 RegisterDefaultCell();
579 return;
582 // register cell style
583 std::unique_ptr<XFCellStyle> xCellStyle(new XFCellStyle);
585 ApplyPadding(xCellStyle.get());
586 ApplyBackGround(xCellStyle.get());
587 ApplyWatermark(xCellStyle.get());
588 ApplyFmtStyle(xCellStyle.get());
589 ApplyBorders(xCellStyle.get());
591 xCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
593 XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
594 m_StyleName = pXFStyleManager->AddStyle(std::move(xCellStyle)).m_pStyle->GetStyleName();
596 // content object register styles
597 rtl::Reference<LwpObject> pObj = m_Content.obj();
598 if (pObj.is())
600 pObj->SetFoundry(m_pFoundry);
601 pObj->DoRegisterStyle();
604 //register child layout style
605 RegisterChildStyle();
608 * @short Read cell layout
609 * @param
610 * @return
612 void LwpCellLayout::Read()
614 LwpObjectStream* pStrm = m_pObjStrm.get();
616 LwpMiddleLayout::Read();
618 // before the layout hierarchy rework
619 if (LwpFileHeader::m_nFileRevision < 0x000b)
621 assert(false);
623 else
625 crowid = pStrm->QuickReaduInt16();
626 ccolid = static_cast<sal_uInt8>(pStrm->QuickReaduInt16()); // written as a lushort
628 sal_uInt16 type;
630 type = pStrm->QuickReaduInt16();
631 pStrm->SkipExtra();
632 cType = static_cast<LeaderDotType>(type);
634 cLayNumerics.ReadIndexed(pStrm);
635 cLayDiagonalLine.ReadIndexed(pStrm);
637 pStrm->SkipExtra();
642 * Apply protect attribute to cell of table
643 * @param aTableID - ID of the table which the cell belongs to
644 * @param
645 * @return XFCell*
647 void LwpCellLayout::ApplyProtect(XFCell * pCell, LwpObjectID aTableID)
649 bool bProtected = false;
650 // judge current cell
651 if (GetIsProtected())
653 bProtected = true;
655 else
657 // judge base on
658 LwpCellLayout * pBase = dynamic_cast<LwpCellLayout *>(GetBasedOnStyle().get());
659 if (pBase && pBase->GetIsProtected())
661 bProtected = true;
663 else
665 // judge whole table
666 LwpTable * pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
667 rtl::Reference<LwpTableLayout> xTableLayout(pTable ? pTable->GetTableLayout() : nullptr);
668 LwpSuperTableLayout * pSuper = xTableLayout.is() ? xTableLayout->GetSuperTableLayout() : nullptr;
669 if (pSuper && pSuper->GetIsProtected())
671 bProtected = true;
676 pCell->SetProtect(bProtected);
679 LwpConnectedCellLayout::LwpConnectedCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
680 : LwpCellLayout(objHdr, pStrm)
681 , cnumrows(0)
682 , cnumcols(0)
683 , m_nRealrowspan(0)
684 , m_nRealcolspan(0)
688 LwpConnectedCellLayout::~LwpConnectedCellLayout()
691 * @short Set current connected cell layout to cell layout map
692 * @param pCellLayoutMap - cell layout map reference
693 * @return
695 void LwpConnectedCellLayout::SetCellMap()
697 LwpTableLayout * pTableLayout = GetTableLayout();
698 if (!pTableLayout)
699 return;
701 sal_uInt16 nRowSpan = m_nRealrowspan;
703 for (sal_uInt16 iLoop = 0; iLoop < nRowSpan; iLoop ++)
705 for (sal_uInt16 jLoop = 0; jLoop < cnumcols; jLoop ++)
706 pTableLayout->SetWordProCellMap(iLoop + crowid, jLoop + ccolid, this);
711 * @short judge border type by cell neighbour
712 * @param nRow
713 * @param nCol
714 * @param pTableLayout
715 * @return LwpCellBorderType
717 LwpCellBorderType LwpConnectedCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 nCol, LwpTableLayout * pTableLayout)
719 if (!pTableLayout)
720 throw std::runtime_error("missing table layout");
722 sal_uInt16 nRowSpan = m_nRealrowspan;
724 // get left cell and judge if neighbour border is different
725 std::unique_ptr<XFBorders> xBorders(GetXFBorders());
726 if( !xBorders)
728 return enumWholeBorder;
730 XFBorder& rLeftBorder = xBorders->GetLeft();
731 XFBorder& rBottomBorder = xBorders->GetBottom();
732 bool bNoLeftBorder = true;
733 bool bNoBottomBorder = true;
735 if (nCol == 0)
737 bNoLeftBorder = false;
739 else
741 for (sal_uInt16 iLoop=0; iLoop < nRowSpan; iLoop++)
743 LwpCellLayout * pLeftNeighbour = GetCellByRowCol(nRow+iLoop, GetLeftColID(nCol), pTableLayout);
744 if (pLeftNeighbour)
746 std::unique_ptr<XFBorders> pNeighbourBorders(pLeftNeighbour->GetXFBorders());
747 if (pNeighbourBorders)
749 XFBorder& rRightBorder = pNeighbourBorders->GetRight();
750 if (rLeftBorder != rRightBorder)
752 // if left border is different with right border of left cell
753 // we should not ignored it
754 bNoLeftBorder = false;
755 break;
762 LwpTable* pTable = pTableLayout->GetTable();
763 if (!pTable)
764 throw std::runtime_error("missing table");
766 if ( (nRow + nRowSpan) == pTable->GetRow())
768 bNoBottomBorder = false;
770 else
772 for (sal_uInt16 iLoop = 0; iLoop < cnumcols; iLoop ++)
774 LwpCellLayout * pBelowNeighbour = GetCellByRowCol(nRow + nRowSpan, nCol+iLoop, pTableLayout);
775 if (pBelowNeighbour)
777 std::unique_ptr<XFBorders> pBelowBorders(pBelowNeighbour->GetXFBorders());
778 if (pBelowBorders)
780 XFBorder& rTopBorder = pBelowBorders->GetTop();
781 if (rTopBorder != rBottomBorder)
783 // if bottom border is different with right border of left cell
784 // we should not ignored it
785 bNoBottomBorder = false;
786 break;
793 xBorders.reset();
795 if (bNoBottomBorder)
797 if (bNoLeftBorder)
799 return enumNoLeftNoBottomBorder;
801 return enumNoBottomBorder;
803 if (bNoLeftBorder)
805 return enumNoLeftBorder;
807 return enumWholeBorder;
810 * @short Read connected cell layout
811 * @param
812 * @return
814 void LwpConnectedCellLayout::Read()
816 LwpCellLayout::Read();
818 cnumrows = m_pObjStrm->QuickReaduInt16();
819 sal_uInt16 numcols = m_pObjStrm->QuickReaduInt16(); // written as a lushort
820 cnumcols = static_cast<sal_uInt8>(numcols);
822 m_nRealrowspan = cnumrows;
823 if (comphelper::IsFuzzing())
824 m_nRealrowspan = std::min<sal_uInt16>(m_nRealrowspan, 128);
825 m_nRealcolspan = cnumcols;
827 m_pObjStrm->SkipExtra();
830 rtl::Reference<XFCell> LwpConnectedCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
832 rtl::Reference<XFCell> xXFCell = LwpCellLayout::ConvertCell(aTableID, nRow, nCol);
833 xXFCell->SetColumnSpaned(cnumcols);
834 return xXFCell;
838 * @short parse connected cell layout
839 * @param pOutputStream - output stream
840 * @return
842 void LwpConnectedCellLayout::Parse(IXFStream* /*pOutputStream*/)
846 LwpHiddenCellLayout::LwpHiddenCellLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
847 : LwpCellLayout(objHdr, pStrm)
850 LwpHiddenCellLayout::~LwpHiddenCellLayout()
853 * @short Set current hidden cell layout to cell layout map
854 * @param
855 * @return
857 void LwpHiddenCellLayout::SetCellMap()
861 * @short Read hidden cell layout
862 * @param
863 * @return
865 void LwpHiddenCellLayout::Read()
867 LwpCellLayout::Read();
869 cconnectedlayout.ReadIndexed(m_pObjStrm.get());
870 m_pObjStrm->SkipExtra();
874 * @short Convert hidden cell layout
875 * @param aTableID - Object ID of table
876 * @return XFCell * - pointer to converted cell
879 rtl::Reference<XFCell> LwpHiddenCellLayout::ConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
881 if (!cconnectedlayout.obj().is())
882 return nullptr;
883 LwpConnectedCellLayout* pConnCell = dynamic_cast<LwpConnectedCellLayout* >(cconnectedlayout.obj().get());
885 if (!pConnCell || nRow < (pConnCell->GetNumrows()+pConnCell->GetRowID()))
886 return nullptr;
887 // if the hidden cell should be displayed for limit of SODC
888 // use the default cell layout
889 rtl::Reference<XFCell> xXFCell;
890 LwpTable *pTable = dynamic_cast<LwpTable *>(aTableID.obj().get());
891 if (pTable)
893 LwpCellLayout *pDefault = dynamic_cast<LwpCellLayout *>(pTable->GetDefaultCellStyle().obj().get());
894 if (pDefault)
896 xXFCell = pDefault->DoConvertCell(aTableID, nRow, nCol);
898 else
900 xXFCell = pConnCell->DoConvertCell(aTableID, nRow, nCol);
902 xXFCell->SetColumnSpaned(pConnCell->GetNumcols());
904 else
906 assert(false);
908 return xXFCell;
911 * @short parse hidden cell layout
912 * @param pOutputStream - output stream
913 * @return
915 void LwpHiddenCellLayout::Parse(IXFStream* /*pOutputStream*/)
919 LwpParallelColumnsBlock::LwpParallelColumnsBlock(LwpObjectHeader const &objHdr, LwpSvStream* pStrm):LwpCellLayout(objHdr, pStrm)
922 LwpParallelColumnsBlock::~LwpParallelColumnsBlock()
925 void LwpParallelColumnsBlock::Read()
927 LwpCellLayout::Read();
928 m_pObjStrm->SkipExtra();
931 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */