LibreOffice Module lotuswordpro (master) 1
lwptablelayout.cxx
Go to the documentation of this file.
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 ************************************************************************/
61#include <lwpglobalmgr.hxx>
62#include "lwptablelayout.hxx"
63#include <lwpfoundry.hxx>
64#include "lwpholder.hxx"
65#include "lwptable.hxx"
66#include "lwptblcell.hxx"
67#include "lwprowlayout.hxx"
68#include <lwpfilehdr.hxx>
69
72#include <xfilter/xfrow.hxx>
74#include <xfilter/xfcell.hxx>
77#include <xfilter/xfframe.hxx>
79#include "lwpframelayout.hxx"
83#include <sal/log.hxx>
85
86#include <algorithm>
87#include <memory>
88
90 : LwpPlacableLayout(objHdr, pStrm)
91{
92 m_pFrame.reset(new LwpFrame(this) );
93}
94
96{
97}
102{
104 m_pObjStrm->SkipExtra();
105
106}
112{
113 LwpObjectID *pID = &GetChildTail();
114
116 while (pID && !pID->IsNull())
117 {
118 bool bAlreadySeen = !aSeen.insert(pID).second;
119 if (bAlreadySeen)
120 throw std::runtime_error("loop in conversion");
121
122 LwpLayout* pLayout = dynamic_cast<LwpLayout*>(pID->obj().get());
123 if (!pLayout)
124 break;
125 if (pLayout->GetLayoutType() == LWP_TABLE_LAYOUT)
126 return dynamic_cast<LwpTableLayout *>(pLayout);
127 pID = &pLayout->GetPrevious();
128 }
129
130 return nullptr;
131}
132
138{
139 LwpObjectID *pID = &GetChildTail();
140
142 while (pID && !pID->IsNull())
143 {
144 bool bAlreadySeen = !aSeen.insert(pID).second;
145 if (bAlreadySeen)
146 throw std::runtime_error("loop in conversion");
147
148 LwpLayout * pLayout = dynamic_cast<LwpLayout *>(pID->obj().get());
149 if (!pLayout)
150 break;
151 if (pLayout->GetLayoutType() == LWP_TABLE_HEADING_LAYOUT)
152 return dynamic_cast<LwpTableHeadingLayout *>(pLayout);
153 pID = &pLayout->GetPrevious();
154 }
155
156 return nullptr;
157}
158
163{
164 // if this layout is style of real table entry
165 LwpTableLayout* pTableLayout = GetTableLayout();
166 if (pTableLayout != nullptr)
167 {
168 pTableLayout->SetFoundry(m_pFoundry);
169 pTableLayout->RegisterStyle();
170 }
171}
178{
179 /* Only "with paragraph above" tables can size right to content. */
182
183 return false;
184}
191{
193}
200{
201 double dWidth = GetTableWidth();
202 double dLeft = GetMarginsValue(MARGIN_LEFT);
203 double dRight = GetMarginsValue(MARGIN_RIGHT);
204
205 return (dWidth + dLeft + dRight);
206}
213{
214 sal_Int32 nWidth = 0;
215 if(!IsJustifiable() || ((nWidth = LwpMiddleLayout::GetMinimumWidth()) <= 0))
216 {
217 LwpTableLayout* pTableLayout = GetTableLayout();
218 if(!pTableLayout)
219 {
220 SAL_WARN("lwp", "missing table layout, early return");
221 return 0;
222 }
223 LwpTable *pTable = pTableLayout->GetTable();
224 if(!pTable)
225 {
226 SAL_WARN("lwp", "missing table, early return");
227 return 0;
228 }
229 double dDefaultWidth = pTable->GetWidth();
230 sal_uInt16 nCol = pTable->GetColumn();
231
232 double dWidth = 0;
233
234 for(sal_uInt16 i =0; i< nCol; i++)
235 {
236 LwpObjectID *pColumnID = &pTableLayout->GetColumnLayoutHead();
237 LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
238 double dColumnWidth = dDefaultWidth;
240 while (pColumnLayout)
241 {
242 bool bAlreadySeen = !aSeen.insert(pColumnLayout).second;
243 if (bAlreadySeen)
244 throw std::runtime_error("loop in conversion");
245 if(pColumnLayout->GetColumnID() == i)
246 {
247 dColumnWidth = pColumnLayout->GetWidth();
248 break;
249 }
250 pColumnID = &pColumnLayout->GetNext();
251 pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
252 }
253 dWidth += dColumnWidth;
254 }
255
256 return dWidth;
257 }
258
259 double dLeft = GetMarginsValue(MARGIN_LEFT);
260 double dRight = GetMarginsValue(MARGIN_RIGHT);
261 return LwpTools::ConvertFromUnitsToMetric(nWidth)-dLeft-dRight;
262
263}
270{
271 // use shadow property of supertable
272 std::unique_ptr<XFShadow> pXFShadow(GetXFShadow());
273 if(pXFShadow)
274 {
275 pTableStyle->SetShadow(pXFShadow->GetPosition(), pXFShadow->GetOffset(), pXFShadow->GetColor());
276 }
277}
284{
285 std::unique_ptr<XFBGImage> xXFBGImage(GetFillPattern());
286 if (xXFBGImage)
287 {
288 pTableStyle->SetBackImage(xXFBGImage);
289 }
290}
291
298{
299 if (IsPatternFill())
300 {
301 ApplyPatternFill(pTableStyle);
302 }
303 else
304 {
305 ApplyBackColor(pTableStyle);
306 }
307}
314{
315 LwpColor* pColor = GetBackColor();
316 if(pColor && pColor->IsValidColor())
317 {
318 XFColor aColor(pColor->To24Color());
319 pTableStyle->SetBackColor(aColor);
320 }
321}
328{
329 std::unique_ptr<XFBGImage> xBGImage(GetXFBGImage());
330 if (xBGImage)
331 {
332 pTableStyle->SetBackImage(xBGImage);
333 }
334}
341{
342 LwpPoint aPoint;
343 if (LwpLayoutGeometry* pGeometry = GetGeometry())
344 aPoint = pGeometry->GetOrigin();
345 double dXOffset = LwpTools::ConvertFromUnitsToMetric(aPoint.GetX());
346
347 // add left padding to alignment distance
348 double dLeft = GetMarginsValue(MARGIN_LEFT);
349
350 pTableStyle->SetAlign(enumXFAlignStart, dXOffset+ dLeft);
351}
358{
360 && (!GetContainerLayout().is() || !GetContainerLayout()->IsCell()) )
361 {
362 LwpTableLayout * pTableLayout = GetTableLayout();
363 if (pTableLayout)
364 {
365 pTableLayout->XFConvert(pCont);
366 }
367 }
368 else if(IsRelativeAnchored())
369 {
370 //anchor to paragraph except "with paragraph above"
371 XFConvertFrame(pCont);
372 }
373 else if(m_pFrame)
374 {
375 //anchor to page, frame, cell
376 m_pFrame->XFConvert(pCont);
377 }
378}
384void LwpSuperTableLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd, bool bAll)
385{
386 if(!m_pFrame)
387 return;
388
390 if(nEnd < nStart)
391 {
392 xXFFrame.set(new XFFrame);
393 }
394 else
395 {
396 xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
397 }
398
399 m_pFrame->Parse(xXFFrame.get(), static_cast<sal_uInt16>(nStart));
400 //parse table, and add table to frame
401 LwpTableLayout * pTableLayout = GetTableLayout();
402 if (pTableLayout)
403 {
404 pTableLayout->XFConvert(xXFFrame.get());
405 }
406 //add frame to the container
407 pCont->Add(xXFFrame.get());
408
409}
416{
417 std::unique_ptr<XFFrameStyle> xFrameStyle(new XFFrameStyle);
418 m_pFrame->RegisterStyle(xFrameStyle);
419}
420
422 : LwpLayout(objHdr, pStrm)
423 , m_nRows(0)
424 , m_nCols(0)
425 , m_pDefaultCellLayout(nullptr)
426 , m_bConverted(false)
427{
428}
429
436LwpCellLayout * LwpTableLayout::GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol)
437{
438 if (nRow >= m_nRows || nCol >= m_nCols)
439 return nullptr;
440
441 return m_WordProCellsMap[static_cast<size_t>(nRow)*m_nCols + nCol];
442}
443
451{
452 sal_uInt32 nCount = m_nRows*m_nCols;
453
454 // new cell map nRow*nCOl and initialize
456
457 // set value
458 LwpObjectID* pRowID = &GetChildHead();
459 LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
461 while (pRowLayout)
462 {
463 bool bAlreadySeen = !aSeen.insert(pRowLayout).second;
464 if (bAlreadySeen)
465 throw std::runtime_error("loop in conversion");
466
467 pRowLayout->SetRowMap();
468
469 // for 's analysis job
470 m_RowsMap[pRowLayout->GetRowID()] = pRowLayout;
471 pRowLayout->CollectMergeInfo();
472 // end for 's analysis
473
474 pRowID = &pRowLayout->GetNext();
475 pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
476 }
477}
478
485LwpObjectID * LwpTableLayout::SearchCellStoryMap(sal_uInt16 nRow, sal_uInt16 nCol)
486{
487 if (nRow >= m_nRows || nCol >= m_nCols )
488 {
489 return nullptr;
490 }
491
492 LwpCellLayout * pCell = GetCellByRowCol(nRow, nCol);
493 if (pCell)
494 {
495 // maybe connected cell layout
496 // maybe default cell layout
497 if (nRow != pCell->GetRowID() || nCol != pCell->GetColID())
498 {
499 return nullptr;
500 }
501 return &pCell->GetContent();
502 }
503
504 return nullptr;
505}
506
512{
513 return dynamic_cast<LwpSuperTableLayout *>(GetParent().obj().get());
514}
520{
521 return dynamic_cast<LwpTable *>(m_Content.obj().get());
522}
528OUString LwpTableLayout::GetColumnWidth(sal_uInt16 nCol)
529{
530 if (nCol >= m_nCols)
531 {
532 assert(false);
534 }
535
536 LwpColumnLayout * pCol = m_aColumns[nCol];
537 if (pCol)
538 {
539 return pCol->GetStyleName();
540 }
541
543}
550{
551 LwpTable* pTable = GetTable();
552 if (!pTable)
553 throw std::range_error("corrupt LwpTableLayout");
554
556 if (!pSuper)
557 throw std::range_error("corrupt LwpTableLayout");
558
559 sal_uInt16 nCols = m_nCols;
560
561 m_aColumns.resize(nCols);
562 std::unique_ptr<bool[]> pWidthCalculated( new bool[nCols] );
563 for(sal_uInt16 i=0;i<nCols; i++)
564 {
565 pWidthCalculated[i] = false;
566 m_aColumns[i] = nullptr;
567 }
568
569 double dDefaultColumn = pTable->GetWidth();
570 sal_uInt16 nJustifiableColumn = nCols;
571
572 double dTableWidth = pSuper->GetTableWidth();
573
574 // Get total width of justifiable columns
575 // NOTICE: all default columns are regarded as justifiable columns
576 LwpObjectID* pColumnID = &GetColumnLayoutHead();
577 LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
579 while (pColumnLayout)
580 {
581 bool bAlreadySeen = !aSeen.insert(pColumnLayout).second;
582 if (bAlreadySeen)
583 throw std::runtime_error("loop in conversion");
584
585 auto nColId = pColumnLayout->GetColumnID();
586 if (nColId >= nCols)
587 {
588 throw std::range_error("corrupt LwpTableLayout");
589 }
590 m_aColumns[nColId] = pColumnLayout;
591 if (!pColumnLayout->IsJustifiable())
592 {
593 pWidthCalculated[nColId] = true;
594 dTableWidth -= pColumnLayout->GetWidth();
595 nJustifiableColumn --;
596 }
597
598 pColumnID = &pColumnLayout->GetNext();
599 pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColumnID->obj().get());
600 }
601
602 // if all columns are not justifiable, the rightmost column will be changed to justifiable
603 if (nJustifiableColumn == 0 && nCols != 0)
604 {
605 nJustifiableColumn ++;
606 if (m_aColumns[nCols - 1])
607 {
608 pWidthCalculated[nCols-1] = false;
609 dTableWidth += m_aColumns[nCols-1]->GetWidth();
610 }
611 else
612 {
613 // this can't happen
614 dTableWidth = dDefaultColumn;
615 assert(false);
616 }
617 }
618
619 // justifiable columns will share the remain width averagely
620 dDefaultColumn = nJustifiableColumn ? dTableWidth/nJustifiableColumn : 0;
621
622 // register default column style
623 std::unique_ptr<XFColStyle> xColStyle(new XFColStyle);
624 xColStyle->SetWidth(static_cast<float>(dDefaultColumn));
625
627 m_DefaultColumnStyleName = pXFStyleManager->AddStyle(std::move(xColStyle)).m_pStyle->GetStyleName();
628
629 // register existed column style
630 sal_uInt16 i=0;
631 for( i=0;i<nCols; i++)
632 {
633 if (m_aColumns[i])
634 {
635 m_aColumns[i]->SetFoundry(m_pFoundry);
636 if(!pWidthCalculated[i])
637 {
638 // justifiable ----register style with calculated value
639 m_aColumns[i]->SetStyleName(m_DefaultColumnStyleName);
640 }
641 else
642 {
643 // not justifiable ---- register style with original value
644 m_aColumns[i]->RegisterStyle(m_aColumns[i]->GetWidth());
645 }
646 }
647 }
648}
654{
655 LwpTable * pTable = GetTable();
656 if (pTable == nullptr)
657 {
658 assert(false);
659 return;
660 }
661
662 // register default row style
663 std::unique_ptr<XFRowStyle> xRowStyle(new XFRowStyle);
664 if (m_nDirection & 0x0030)
665 {
666 xRowStyle->SetMinRowHeight(static_cast<float>(pTable->GetHeight()));
667 }
668 else
669 {
670 xRowStyle->SetRowHeight(static_cast<float>(pTable->GetHeight()));
671 }
673 m_DefaultRowStyleName = pXFStyleManager->AddStyle(std::move(xRowStyle)).m_pStyle->GetStyleName();
674
675 // register style of rows
676 LwpObjectID * pRowID = &GetChildHead();
677 LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
678 while (pRowLayout)
679 {
680 pRowLayout->SetFoundry(m_pFoundry);
681 pRowLayout->RegisterStyle();
682
683 pRowID = &pRowLayout->GetNext();
684 pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
685 }
686}
692{
693 // get super table layout
695 if (!pSuper)
696 return;
697
698 // get table
699 LwpTable * pTable = GetTable();
700 if (pTable == nullptr)
701 {
702 SAL_WARN("lwp", "missing table, early return");
703 return;
704 }
705
706 // get row/column number of this table
707 m_nRows = pTable->GetRow();
708 m_nCols = pTable->GetColumn();
709 //http://www.danielsays.com/ss-gallery-win1x2x3x-lotus-word-pro-96.html
710 //tables with up to 255 rows and 8192 columns
711 //the row limit tallies with the casting of m_nCols to an unsigned char
712 //elsewhere
713 if (m_nRows > MAX_NUM_ROWS)
714 throw std::runtime_error("max legal row exceeded");
715 if (m_nCols > MAX_NUM_COLS)
716 throw std::runtime_error("max legal column exceeded");
717
718 // get default cell layout of current table
719 LwpObjectID& rID= pTable->GetDefaultCellStyle();
720 m_pDefaultCellLayout = dynamic_cast<LwpCellLayout *>(rID.obj().get());
721
722 // register columns styles
724
725 // register style of whole table
726 std::unique_ptr<XFTableStyle> xTableStyle(new XFTableStyle);
727
728 sal_uInt8 nType = pSuper->GetRelativeType();
729 // If the table is not "with paragraph above" placement, create an frame style
730 // by supertable layout
732 && (!pSuper->GetContainerLayout().is() || !pSuper->GetContainerLayout()->IsCell()) )
733 {
734 //with para above
735 pSuper->ApplyBackGround(xTableStyle.get());
736 pSuper->ApplyWatermark(xTableStyle.get());
737 pSuper->ApplyShadow(xTableStyle.get());
738 pSuper->ApplyAlignment(xTableStyle.get());
739 xTableStyle->SetWidth(pSuper->GetTableWidth());
740 }
741 else
742 {
743 pSuper->RegisterFrameStyle();
744 xTableStyle->SetAlign(enumXFAlignCenter);
745 xTableStyle->SetWidth(pSuper->GetTableWidth());
746 }
748 m_StyleName = pXFStyleManager->AddStyle(std::move(xTableStyle)).m_pStyle->GetStyleName();
749
750 //convert to OO table now and register row style traverse
752
754
755 // Register rows layouts, it must be after SplitConflictCells
756 RegisterRows();
757
758 // Parse table
759 ParseTable();
760
761 // the old code doesn't check if the LwpFoundry pointer is NULL,
762 // so the NULL pointer cause sodc freeze. Add code to check the pointer.
763 if (GetFoundry())
764 PutCellVals(GetFoundry(), pTable->GetObjectID());
765}
771{
772 // get super table layout
774 if (!pSuper)
775 {
776 throw std::runtime_error("missing super table");
777 }
778
779 if (m_pXFTable)
780 {
781 throw std::runtime_error("this table is already parsed");
782 }
783
784 // set name of object
785 m_pXFTable.set(new XFTable);
786
787 m_pXFTable->SetTableName(pSuper->GetName().str());
788 // set table style
789 m_pXFTable->SetStyleName(m_StyleName);
790
791 sal_uInt16 nRow = m_nRows;
792 sal_uInt8 nCol = static_cast<sal_uInt8>(m_nCols);
793
794 sal_uInt16 nContentRow = 0;
795
796 //process header rows
797 LwpTableHeadingLayout* pTableHeading;
798 pTableHeading = pSuper->GetTableHeadingLayout();
799 if (pTableHeading)
800 {
801 sal_uInt16 nStartHeadRow;
802 sal_uInt16 nEndHeadRow;
803 pTableHeading->GetStartEndRow(nStartHeadRow,nEndHeadRow);
804 if (nStartHeadRow == 0)
805 {
806 if (utl::ConfigManager::IsFuzzing() && nEndHeadRow - nStartHeadRow > 128)
807 {
808 SAL_WARN("lwp", "truncating HeadingRow for fuzzing performance");
809 nEndHeadRow = nStartHeadRow + 128;
810 }
811 nContentRow = ConvertHeadingRow(m_pXFTable,nStartHeadRow,nEndHeadRow+1);
812 }
813 }
814
815 ConvertTable(m_pXFTable, nContentRow, nRow, 0, nCol);
816}
817
823{
825
826 // before layout hierarchy rework!
828 {
829 assert(false);
830 }
832
833 m_pObjStrm->SkipExtra();
834}
835
842{
843 if (!m_pXFTable)
844 return;
845 if (m_bConverted)
846 throw std::runtime_error("already added to a container");
847 pCont->Add(m_pXFTable.get());
848 m_bConverted = true;
849}
850
858 rtl::Reference<XFTable> const & pXFTable, sal_uInt16 nStartHeadRow, sal_uInt16 nEndHeadRow)
859{
860 sal_uInt16 nContentRow;
861 LwpTable* pTable = GetTable();
862 assert(pTable);
863 sal_uInt8 nCol = static_cast<sal_uInt8>(pTable->GetColumn());
864 rtl::Reference<XFTable> pTmpTable( new XFTable );
865
866 ConvertTable(pTmpTable,nStartHeadRow,nEndHeadRow,0,nCol);
867
868 sal_uInt16 nRowNum = pTmpTable->GetRowCount();
869 std::vector<sal_uInt8> CellMark(nRowNum);
870
871 if (nRowNum == 1)
872 {
873 XFRow* pXFRow = pTmpTable->GetRow(1);
874 pXFTable->AddHeaderRow(pXFRow);
875 pTmpTable->RemoveRow(1);
876 nContentRow = nEndHeadRow;
877 }
878 else
879 {
880 sal_uInt8 nFirstColSpann = 1;
881 const bool bFindFlag = FindSplitColMark(pTmpTable.get(), CellMark, nFirstColSpann);
882
883 if (bFindFlag)//split to 2 cells
884 {
885 SplitRowToCells(pTmpTable.get(), pXFTable, nFirstColSpann, CellMark.data());
886 nContentRow = nEndHeadRow;
887 }
888 else//can not split,the first row will be the heading row,the rest will be content row
889 {
890 XFRow* pXFRow = pTmpTable->GetRow(1);
891 pXFTable->AddHeaderRow(pXFRow);
892 pTmpTable->RemoveRow(1);
893 auto iter = m_RowsMap.find(0);
894 if (iter == m_RowsMap.end())
895 {
896 SAL_WARN("lwp", "row 0 is unknown");
897 nContentRow = 0;
898 }
899 else
900 nContentRow = iter->second->GetCurMaxSpannedRows(0,nCol);
901 }
902 }
903 return nContentRow;
904}
905
907 sal_uInt8 nFirstColSpann,const sal_uInt8* pCellMark)
908{
909 sal_uInt16 i;
910 sal_uInt16 nRowNum = pTmpTable->GetRowCount();
911 LwpTable* pTable = GetTable();
912 assert(pTable);
913 sal_uInt8 nCol = static_cast<sal_uInt8>(pTable->GetColumn());
914
915 rtl::Reference<XFRow> xXFRow(new XFRow);
916
917 //register style for heading row
918 double fHeight = 0;
919 OUString styleName;
920 std::unique_ptr<XFRowStyle> xRowStyle(new XFRowStyle);
921 XFRow* pRow = pTmpTable->GetRow(1);
922 if (!pRow)
923 throw std::runtime_error("missing row");
924 styleName = pRow->GetStyleName();
925
926 // get settings of the row and assign them to new row style
928 XFRowStyle *pTempRowStyle = static_cast<XFRowStyle*>(pXFStyleManager->FindStyle(styleName));
929 if (pTempRowStyle)
930 *xRowStyle = *pTempRowStyle;
931
932 for (i=1;i<=nRowNum;i++)
933 {
934 styleName = pTmpTable->GetRow(i)->GetStyleName();
935 fHeight+=static_cast<XFRowStyle*>(pXFStyleManager->FindStyle(styleName))->GetRowHeight();
936 }
937 if (m_nDirection & 0x0030)
938 {
939 xRowStyle->SetMinRowHeight(static_cast<float>(fHeight));
940 }
941 else
942 {
943 xRowStyle->SetRowHeight(static_cast<float>(fHeight));
944 }
945 xXFRow->SetStyleName(pXFStyleManager->AddStyle(std::move(xRowStyle)).m_pStyle->GetStyleName());
946
947 //construct heading row
948 rtl::Reference<XFCell> xXFCell1(new XFCell);
949 rtl::Reference<XFCell> xXFCell2(new XFCell);
950 rtl::Reference<XFTable> xSubTable1(new XFTable);
951 rtl::Reference<XFTable> xSubTable2(new XFTable);
952 rtl::Reference<XFCell> xNewCell;
953
954 for (i=1;i<=nRowNum;i++)
955 {
956 XFRow* pOldRow = pTmpTable->GetRow(i);
957 rtl::Reference<XFRow> xNewRow(new XFRow);
958 xNewRow->SetStyleName(pOldRow->GetStyleName());
959 for (sal_uInt8 j=1;j<=pCellMark[i];j++)
960 {
961 xNewCell = pOldRow->GetCell(j);
962 xNewRow->AddCell(xNewCell);
963 }
964 xSubTable1->AddRow(xNewRow);
965 }
966 ConvertColumn(xSubTable1, 0, nFirstColSpann);//add column info
967
968 xXFCell1->Add(xSubTable1.get());
969 xXFCell1->SetColumnSpaned(nFirstColSpann);
970 xXFRow->AddCell(xXFCell1);
971
972 for (i=1;i<=nRowNum;i++)
973 {
974 XFRow* pOldRow = pTmpTable->GetRow(i);
975 rtl::Reference<XFRow> xNewRow(new XFRow);
976 xNewRow->SetStyleName(pOldRow->GetStyleName());
977 for(sal_Int32 j=pCellMark[i]+1;j<=pOldRow->GetCellCount();j++)
978 {
979 xNewCell = pOldRow->GetCell(j);
980 xNewRow->AddCell(xNewCell);
981 }
982 xSubTable2->AddRow(xNewRow);
983
984 }
985 ConvertColumn(xSubTable2, nFirstColSpann, nCol);//add column info
986 xXFCell2->Add(xSubTable2.get());
987 xXFCell2->SetColumnSpaned(nCol-nFirstColSpann);
988 xXFRow->AddCell(xXFCell2);
989
990 pXFTable->AddHeaderRow(xXFRow.get());
991
992 //remove tmp table
993 for (i=1;i<=nRowNum;i++)
994 {
995 pTmpTable->RemoveRow(i);
996 }
997}
998
1004bool LwpTableLayout::FindSplitColMark(XFTable* pXFTable, std::vector<sal_uInt8>& rCellMark,
1005 sal_uInt8& nMaxColSpan)
1006{
1007 sal_uInt16 nRowNum = pXFTable->GetRowCount();
1008 sal_uInt8 nColNum = static_cast<sal_uInt8>(pXFTable->GetColumnCount());
1010 sal_uInt8 nColSpan;
1011 bool bFindFlag = false;
1012 XFRow* pTmpRow;
1013
1014 for(sal_uInt8 i=1;i<=nColNum;i++)
1015 {
1016 sal_uInt16 nRowLoop;
1017
1018 //find current max column span
1019 nMaxColSpan = 1;
1020 for (nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)
1021 {
1022 nColSpan = 0;
1023 for(sal_uInt8 nCellLoop=1; nCellLoop<i+1; nCellLoop++)
1024 {
1025 pTmpRow = pXFTable->GetRow(nRowLoop);
1026 XFCell* pCell = pTmpRow->GetCell(nCellLoop);
1027 if (pCell)
1028 nColSpan += static_cast<sal_uInt8>(pCell->GetColSpaned());
1029 else
1030 return false;
1031 }
1032 if (nColSpan > nMaxColSpan)
1033 nMaxColSpan = nColSpan;
1034 rCellMark.at(nRowLoop) = 0;//reset all cell mark to zero
1035 }
1036
1037 //find if other row has the same column
1038 for (nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)
1039 {
1040 pTmpRow = pXFTable->GetRow(nRowLoop);
1041 nCount = 0;
1042 sal_Int32 nCellMark = 0;
1043 for (sal_Int32 nCellLoop=1; nCellLoop<=pTmpRow->GetCellCount(); nCellLoop++)
1044 {
1045 if (nCount>nMaxColSpan)
1046 break;
1047 nCount+= static_cast<sal_uInt8>(pTmpRow->GetCell(nCellLoop)->GetColSpaned());
1048 if (nCount == nMaxColSpan)
1049 {
1050 nCellMark = nCellLoop;
1051 break;
1052 }
1053 }
1054 if (nCellMark == 0)
1055 break;
1056 else
1057 rCellMark.at(nRowLoop) = nCellMark;
1058 }
1059 for(nRowLoop=1;nRowLoop<=nRowNum;nRowLoop++)//check if all ==0,break
1060 {
1061 if (rCellMark.at(nRowLoop) == 0)
1062 break;
1063 }
1064 if (nRowLoop == nRowNum+1)
1065 {
1066 bFindFlag = true;
1067 return bFindFlag;
1068 }
1069
1070 }
1071 return bFindFlag;
1072}
1073
1075{
1076 return a.mnStartRow == b.mnStartRow &&
1077 a.mnEndRow == b.mnEndRow &&
1078 a.mnStartCol== b.mnStartCol &&
1079 a.mnEndCol == b.mnEndCol;
1080}
1081
1090void LwpTableLayout::ConvertTable(rtl::Reference<XFTable> const & pXFTable, sal_uInt16 nStartRow,
1091 sal_uInt16 nEndRow,sal_uInt8 nStartCol,sal_uInt8 nEndCol)
1092{
1093 TableConvertAttempt aConversionAttempt(nStartRow, nEndRow, nStartCol, nEndCol);
1094 auto itr = std::find(m_aConvertingStack.begin(), m_aConvertingStack.end(), aConversionAttempt);
1095 if (itr != m_aConvertingStack.end())
1096 {
1097 SAL_WARN("lwp", "already trying to convert this range");
1098 return;
1099 }
1100
1101 m_aConvertingStack.push_back(aConversionAttempt);
1102
1103 //out put column info TO BE CHANGED
1104 ConvertColumn(pXFTable,nStartCol,nEndCol);
1105
1106 std::map<sal_uInt16,LwpRowLayout*>::iterator iter;
1107
1108 for (sal_uInt16 i=nStartRow; i<nEndRow;)
1109 {
1110 iter = m_RowsMap.find(i);
1111 if (iter == m_RowsMap.end())
1112 {
1113 ConvertDefaultRow(pXFTable,nStartCol,nEndCol,i);
1114 i++;
1115 }
1116 else
1117 {
1118 LwpRowLayout* pRow = iter->second;
1119 if (pRow->GetCurMaxSpannedRows(nStartCol,nEndCol) == 1)
1120 {
1121 pRow->ConvertCommonRow(pXFTable,nStartCol,nEndCol);
1122 i++;
1123 }
1124 else
1125 {
1126 pRow->ConvertRow(pXFTable,nStartCol,nEndCol);
1127 i += pRow->GetCurMaxSpannedRows(nStartCol,nEndCol);
1128 }
1129 }
1130 }
1131
1132 m_aConvertingStack.pop_back();
1133}
1134
1141{
1142
1143 // The old code doesn't check if the LwpFoundry pointer is NULL, so the NULL
1144 // pointer cause sodc frozen. Add code to check the pointer.
1145 if( !pFoundry ) return;
1146
1147 try{
1148
1149 LwpDLVListHeadHolder* pHolder = dynamic_cast<LwpDLVListHeadHolder*>(pFoundry->GetNumberManager().GetTableRangeID().obj().get());
1150
1151 LwpTableRange* pTableRange = pHolder ? dynamic_cast<LwpTableRange*>(pHolder->GetHeadID().obj().get()) : nullptr;
1152
1153 //Look up the table
1155 while (pTableRange)
1156 {
1157 bool bAlreadySeenTable = !aTableSeen.insert(pTableRange).second;
1158 if (bAlreadySeenTable)
1159 throw std::runtime_error("loop in conversion");
1160 LwpObjectID aID = pTableRange->GetTableID();
1161 if (aID == aTableID)
1162 {
1163 break;
1164 }
1165 pTableRange = pTableRange->GetNext();
1166 }
1167
1168 if (!pTableRange)
1169 return;
1170
1171 LwpCellRange* pRange = dynamic_cast<LwpCellRange*>(pTableRange->GetCellRangeID().obj().get());
1172 if (!pRange)
1173 return;
1174
1175 LwpFolder* pFolder = dynamic_cast<LwpFolder*>(pRange->GetFolderID().obj().get());
1176 if (!pFolder)
1177 return;
1178
1179 LwpObjectID aRowListID = pFolder->GetChildHeadID();
1180 LwpRowList* pRowList = dynamic_cast<LwpRowList*>(aRowListID.obj().get());
1181
1182 //loop the rowlist
1184 while (pRowList)
1185 {
1186 bool bAlreadySeenOuter = !aOuterSeen.insert(pRowList).second;
1187 if (bAlreadySeenOuter)
1188 throw std::runtime_error("loop in conversion");
1189 sal_uInt16 nRowID = pRowList->GetRowID();
1190 {
1191 LwpCellList* pCellList = dynamic_cast<LwpCellList*>(pRowList->GetChildHeadID().obj().get());
1192 //loop the cellList
1194 while (pCellList)
1195 {
1196 bool bAlreadySeen = !aSeen.insert(pCellList).second;
1197 if (bAlreadySeen)
1198 throw std::runtime_error("loop in conversion");
1199
1200 {//put cell
1201 sal_uInt16 nColID = pCellList->GetColumnID();
1202
1203 XFCell* pCell = GetCellsMap(nRowID,static_cast<sal_uInt8>(nColID));
1204 if (!pCell)
1205 {
1206 throw std::runtime_error("Hidden cell would not be in cellsmap");
1207 }
1208
1209 pCellList->Convert(pCell, this);
1210
1211 //process paragraph
1212 PostProcessParagraph(pCell, nRowID, nColID);
1213
1214 }
1215 pCellList = dynamic_cast<LwpCellList*>(pCellList->GetNextID().obj().get());
1216 }
1217 }
1218 pRowList = dynamic_cast<LwpRowList*>(pRowList->GetNextID().obj().get());
1219 }
1220
1221 }catch (...) {
1222 SAL_WARN("lwp", "bad PutCellVals");
1223 }
1224}
1225
1232void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_uInt16 nColID)
1233{
1234 // if number right, set alignment to right
1235 LwpCellLayout * pCellLayout = GetCellByRowCol(nRowID, nColID);
1236 if(!pCellLayout)
1237 return;
1238
1241 XFParagraph * pXFPara = static_cast<XFParagraph*>(first.get());
1242 if (!pXFPara)
1243 return;
1244 XFColor aNullColor;
1245
1246 OUString sNumfmt = pCellLayout->GetNumfmtName();
1247 bool bColorMod = false;
1248 XFNumberStyle* pNumStyle = nullptr;
1250 if (!sNumfmt.isEmpty())
1251 {
1252 pNumStyle = static_cast<XFNumberStyle*>(pXFStyleManager->FindStyle(sNumfmt));
1253 XFColor aColor = pNumStyle->GetColor();
1254 if ( aColor != aNullColor )
1255 bColorMod = true;//end
1256 }
1257
1258 XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
1259 if (!((pStyle && pStyle->GetNumberRight()) || bColorMod))
1260 return;
1261
1262 std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
1263
1264 if (pStyle)
1265 {
1266 *xOverStyle = *pStyle;
1267
1268 if (pStyle->GetNumberRight())
1269 xOverStyle->SetAlignType(enumXFAlignEnd);
1270 }
1271
1272 if (bColorMod)
1273 {
1274 rtl::Reference<XFFont> xFont = xOverStyle->GetFont();
1275 if (xFont.is())
1276 {
1277 XFColor aColor = xFont->GetColor();
1278 if (aColor == aNullColor)
1279 {
1280 rtl::Reference<XFFont> pNewFont(new XFFont);
1281 aColor = pNumStyle->GetColor();
1282 pNewFont->SetColor(aColor);
1283 xOverStyle->SetFont(pNewFont);
1284 }
1285 }
1286 }
1287
1288 xOverStyle->SetStyleName("");
1289 OUString StyleName
1290 = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
1291
1292 pXFPara->SetStyleName(StyleName);
1293}
1294
1300{
1301 LwpTable * pTable = GetTable();
1302 if (!pTable)
1303 {
1304 assert(false);
1305 return;
1306 }
1307
1308 for (sal_uInt32 iLoop = 0; iLoop < static_cast<sal_uInt32>(nEndCol)-nStartCol; ++iLoop)
1309 {
1310 // add row to table
1311 LwpObjectID *pColID = &GetColumnLayoutHead();
1312 LwpColumnLayout * pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj().get());
1313 while (pColumnLayout)
1314 {
1315 if (pColumnLayout->GetColumnID() == (iLoop+nStartCol))
1316 {
1317 pXFTable->SetColumnStyle(iLoop+1, pColumnLayout->GetStyleName());
1318 break;
1319 }
1320 pColID = &pColumnLayout->GetNext();
1321 pColumnLayout = dynamic_cast<LwpColumnLayout *>(pColID->obj().get());
1322 }
1323 if (!pColumnLayout)
1324 {
1325 pXFTable->SetColumnStyle(iLoop+1, m_DefaultColumnStyleName);
1326 }
1327 }
1328}
1333{
1334 LwpTable * pTable = GetTable();
1335 if (!pTable)
1336 return;
1337 sal_uInt16 nCol = pTable->GetColumn();
1338 sal_uInt16 nRow = pTable->GetRow();
1339
1340 sal_uInt16 nEffectRows;
1341 std::map<sal_uInt16,LwpRowLayout*>::iterator iter1;
1342 std::map<sal_uInt16,LwpRowLayout*>::iterator iter2;
1343 LwpRowLayout* pRowLayout;
1344 LwpRowLayout* pEffectRow;
1345
1346 for (sal_uInt16 i=0; i<nRow; )
1347 {
1348 iter1 = m_RowsMap.find(i);
1349 if (iter1 == m_RowsMap.end())//default rows
1350 {
1351 i++;
1352 continue;
1353 }
1354 pRowLayout= iter1->second;
1355 if (!pRowLayout->GetMergeCellFlag())
1356 {
1357 i++;
1358 continue;
1359 }
1360 else
1361 {
1362 nEffectRows = i + pRowLayout->GetCurMaxSpannedRows(0,static_cast<sal_uInt8>(nCol));
1363
1364 for (sal_uInt16 j = i+1; j<nEffectRows; j++)
1365 {
1366 iter2 = m_RowsMap.find(j);
1367 if (iter2 == m_RowsMap.end())
1368 continue;
1369 pEffectRow = iter2->second;
1370 if (!pEffectRow->GetMergeCellFlag())
1371 continue;
1372 else
1373 pEffectRow->SetCellSplit(nEffectRows);
1374 }
1375 i = nEffectRows;
1376 }
1377 }//end for
1378
1379}
1388 sal_uInt8 nEndCol, sal_uInt16 nRowID)
1389{
1390 // current row doesn't exist in the file
1391 rtl::Reference<XFRow> xRow(new XFRow);
1392 xRow->SetStyleName(m_DefaultRowStyleName);
1393
1394 for (sal_uInt16 j =0;j < nEndCol-nStartCol; j++)
1395 {
1396 // if table has default cell layout, use it to ConvertCell
1397 // otherwise use blank cell
1400 {
1401 LwpTable* pTable = GetTable();
1402 assert(pTable);
1404 pTable->GetObjectID(),nRowID,j+nStartCol);
1405 }
1406 else
1407 {
1408 xCell.set(new XFCell);
1409 }
1410 xRow->AddCell(xCell);
1411 }
1412
1413 pXFTable->AddRow(xRow);
1414}
1415
1422void LwpTableLayout::SetCellsMap(sal_uInt16 nRow1, sal_uInt8 nCol1,
1423 sal_uInt16 nRow2, sal_uInt8 nCol2, XFCell* pXFCell)
1424{
1425 m_CellsMap.insert({{nRow1, nCol1}, {nRow2, nCol2}}, pXFCell);
1426}
1427
1435{
1436 auto results = m_CellsMap.search({{nRow, nCol}, {nRow, nCol}}, rt_type::search_type::overlap);
1437 if (results.begin() == results.end())
1438 return nullptr;
1439 // return the last thing inserted for this position
1440 return std::prev(results.end())->GetCell();
1441}
1447{
1448 LwpObjectID *pRowID = &GetChildHead();
1449 LwpRowLayout * pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
1450 while (pRowLayout)
1451 {
1452 if(pRowLayout->GetRowID() == nRow)
1453 return pRowLayout;
1454
1455 pRowID = &pRowLayout->GetNext();
1456 pRowLayout = dynamic_cast<LwpRowLayout *>(pRowID->obj().get());
1457 }
1458 return nullptr;
1459}
1460
1461//add end by
1463 : LwpVirtualLayout(objHdr, pStrm)
1464 , ccolid(0)
1465 , cwidth(0)
1466{}
1467
1469{}
1471{
1472 LwpObjectStream* pStrm = m_pObjStrm.get();
1473
1475
1476 sal_uInt16 colid;
1477
1478 colid = pStrm->QuickReaduInt16(); // forced to lushort
1479 ccolid = static_cast<sal_uInt8>(colid);
1480 cwidth = pStrm->QuickReadInt32();
1481
1482 pStrm->SkipExtra();
1483}
1484
1485void LwpColumnLayout::RegisterStyle(double dCalculatedWidth)
1486{
1487 std::unique_ptr<XFColStyle> xColStyle(new XFColStyle);
1488 xColStyle->SetWidth(static_cast<float>(dCalculatedWidth));
1490 m_StyleName = pXFStyleManager->AddStyle(std::move(xColStyle)).m_pStyle->GetStyleName();
1491}
1492
1494 : LwpTableLayout(objHdr, pStrm)
1495 , cStartRow(0)
1496 , cEndRow(0)
1497{}
1498
1500{}
1507{
1509
1510 cStartRow = m_pObjStrm->QuickReaduInt16();
1511 cEndRow = m_pObjStrm->QuickReaduInt16();
1512
1513 m_pObjStrm->SkipExtra();
1514
1515}
1522void LwpTableHeadingLayout::GetStartEndRow(sal_uInt16& nStartRow, sal_uInt16& nEndRow)
1523{
1524 nStartRow = cStartRow;
1525 nEndRow = cEndRow;
1526}
1527
1529{
1530}
1532{}
1533
1535{
1537 m_pObjStrm->SkipExtra();
1538
1539}
1540
1542{
1543}
1544
1546{
1547}
1548
1550{
1552 m_pObjStrm->SkipExtra();
1553}
1554
1556{
1557}
1558
1560{
1561}
1562
1564{
1566 m_pObjStrm->SkipExtra();
1567}
1568
1569/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString GetStyleName()=0
@descr: return the style name.
const OUString & str() const
VO_CELLLAYOUT object.
const OUString & GetNumfmtName() const
rtl::Reference< XFCell > DoConvertCell(LwpObjectID aTableID, sal_uInt16 nRow, sal_uInt16 nCol)
sal_uInt8 GetColID() const
sal_uInt16 GetRowID() const
VO_CELLLIST object.
Definition: lwptblcell.hxx:79
sal_uInt8 GetColumnID() const
Definition: lwptblcell.hxx:85
LwpObjectID const & GetNextID()
Definition: lwptblcell.hxx:84
virtual void Convert(XFCell *pCell, LwpTableLayout *pCellsMap=nullptr)
Definition: lwptblcell.cxx:99
VO_CELLRANGE object.
Definition: lwptblcell.hxx:161
const LwpObjectID & GetFolderID() const
Definition: lwptblcell.hxx:166
lwpcolor class (red, green, blue, extra)
Definition: lwpcolor.hxx:71
bool IsValidColor() const
Definition: lwpcolor.hxx:114
sal_uInt32 To24Color()
@descr return the BGR format
Definition: lwpcolor.cxx:66
VO_COLUMNLAYOUT object.
bool IsJustifiable() const
LwpColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
double GetWidth() override
sal_uInt32 GetColumnID() const
virtual ~LwpColumnLayout() override
void Read() override
@descr Read name of LwpDLNFVList from object stream
LwpObjectID & GetParent()
Definition: lwpdlvlist.hxx:111
LwpObjectID & GetChildHead()
Definition: lwpdlvlist.hxx:109
LwpAtomHolder & GetName()
Definition: lwpdlvlist.hxx:108
LwpObjectID & GetChildTail()
Definition: lwpdlvlist.hxx:110
VO_HEADHOLDER, LwpDLVListHeadHolder, contains an id to the head of LwpDLVList.
Definition: lwpholder.hxx:71
LwpObjectID & GetHeadID()
Definition: lwpholder.hxx:75
LwpObjectID & GetPrevious()
Definition: lwpdlvlist.hxx:76
LwpObjectID & GetNext()
Definition: lwpdlvlist.hxx:75
static sal_uInt16 m_nFileRevision
Definition: lwpfilehdr.hxx:77
VO_FOLDER object.
Definition: lwptblcell.hxx:178
LwpObjectID const & GetChildHeadID()
Definition: lwptblcell.hxx:183
LwpNumberManager & GetNumberManager()
Definition: lwpfoundry.hxx:255
For register frame style and parse frame.
XFStyleManager * GetXFStyleManager()
static LwpGlobalMgr * GetInstance(LwpSvStream *pSvStream=nullptr)
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwplayout.cxx:1478
XFShadow * GetXFShadow()
@descr: create xfshadow
Definition: lwplayout.cxx:1860
virtual rtl::Reference< LwpVirtualLayout > GetContainerLayout() override
@descr get the layout that containers the current frame layout
Definition: lwplayout.cxx:1909
sal_Int32 GetMinimumWidth()
Definition: lwplayout.cxx:989
LwpObjectID & GetContent()
Definition: lwplayout.hxx:415
std::unique_ptr< XFBGImage > GetXFBGImage()
@descr: Create and return xfbgimage object for watermark
Definition: lwplayout.cxx:1381
virtual double GetWidth() override
@descr: Get layout height
Definition: lwplayout.cxx:1067
LwpObjectID m_Content
Definition: lwplayout.hxx:401
std::unique_ptr< XFBGImage > GetFillPattern()
@descr: Get the fill pattern style.
Definition: lwplayout.cxx:1109
bool IsPatternFill()
@descr: Whether the fill is pattern fill or not
Definition: lwplayout.cxx:1094
LwpColor * GetBackColor()
@descr: Get background color.
Definition: lwplayout.cxx:894
LwpLayoutGeometry * GetGeometry()
@descr: Get the geometry of current layout
Definition: lwplayout.cxx:634
bool IsSizeRightToContent()
Definition: lwplayout.cxx:1037
const LwpObjectID & GetTableRangeID() const
Definition: lwpfoundry.hxx:102
Base class of all Lwp VO objects.
Definition: lwpobjhdr.hxx:71
object id class
Definition: lwpobjid.hxx:79
void ReadIndexed(LwpSvStream *pStrm)
@descr Read object id with indexed format from stream if index>0, lowid is get from time table per th...
Definition: lwpobjid.cxx:96
rtl::Reference< LwpObject > obj(VO_TYPE tag=VO_INVALID) const
@descr get object from object factory per the object id
Definition: lwpobjid.cxx:183
bool IsNull() const
Definition: lwpobjid.hxx:110
stream class for LwpObject body data provide stream like interface to read object data
Definition: lwpobjstrm.hxx:77
sal_uInt16 QuickReaduInt16(bool *pFailure=nullptr)
@descr Quick read sal_uInt32
Definition: lwpobjstrm.cxx:200
void SkipExtra()
@descr skip extra bytes
Definition: lwpobjstrm.cxx:258
sal_Int32 QuickReadInt32()
@descr Quick read sal_Int32
Definition: lwpobjstrm.cxx:211
void SetFoundry(LwpFoundry *pFoundry)
Definition: lwpobj.hxx:137
LwpFoundry * m_pFoundry
Definition: lwpobj.hxx:91
virtual void RegisterStyle()
@descr default register style function
Definition: lwpobj.cxx:100
std::unique_ptr< LwpObjectStream > m_pObjStrm
Definition: lwpobj.hxx:90
LwpFoundry * GetFoundry()
Definition: lwpobj.hxx:136
LwpObjectID & GetObjectID()
Definition: lwpobj.hxx:138
LwpParallelColumnsLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
void Read() override
read table layout
virtual ~LwpParallelColumnsLayout() override
virtual sal_uInt8 GetRelativeType() override
@descr: Get relative type
Definition: lwplayout.cxx:2033
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwplayout.cxx:1936
point class
sal_Int32 GetX() const
VO_ROWLAYOUT obj.
void CollectMergeInfo()
collect merge cell info when register row styles
void SetRowMap()
register row style
void ConvertRow(rtl::Reference< XFTable > const &pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
Parse rows with connect cell.
sal_uInt16 GetRowID() const
void ConvertCommonRow(rtl::Reference< XFTable > const &pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
convert row with rowlayout,but no merge cells
void SetCellSplit(sal_uInt16 nEffectRows)
split merge cells in this row
bool GetMergeCellFlag() const
check if the row has merge cell
virtual void RegisterStyle() override
register row style
sal_uInt16 GetCurMaxSpannedRows(sal_uInt8 nStartCol, sal_uInt8 nEndCol)
get max spanned row numbers in a given column range
VO_ROWLIST object.
Definition: lwptblcell.hxx:102
sal_uInt16 GetRowID() const
Definition: lwptblcell.hxx:109
LwpObjectID const & GetChildHeadID()
Definition: lwptblcell.hxx:107
LwpObjectID const & GetNextID()
Definition: lwptblcell.hxx:108
void Read() override
Read super table layout record.
LwpSuperGlossaryLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
virtual ~LwpSuperGlossaryLayout() override
void Read() override
Read super table layout record.
virtual ~LwpSuperParallelColumnLayout() override
LwpSuperParallelColumnLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
VO_SUPERTABLELAYOUT object.
void ApplyBackColor(XFTableStyle *pTableStyle)
Apply back color to table.
void ApplyBackGround(XFTableStyle *pTableStyle)
Apply background to table style.
void Read() override
Read super table layout record.
double GetWidth() override
Get width of frame outside table.
void RegisterNewStyle()
Register super table layout style.
void RegisterFrameStyle()
register frame style
bool IsSizeRightToContent()
Judge whether table size is according to content, borrowed from Word Pro code.
LwpSuperTableLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
void ApplyPatternFill(XFTableStyle *pTableStyle)
Apply pattern fill to table style.
void ApplyShadow(XFTableStyle *pTableStyle)
Apply shadow to table.
bool IsJustifiable()
Judge whether table is justifiable, borrowed from Word Pro code.
LwpTableHeadingLayout * GetTableHeadingLayout()
Get effective heading table layout, the one just before table layout is the only one which is effecti...
void XFConvert(XFContentContainer *pCont) override
Add table to container.
std::unique_ptr< LwpFrame > m_pFrame
void ApplyWatermark(XFTableStyle *pTableStyle)
Apply watermark to table.
double GetTableWidth()
Get width of table.
LwpTableLayout * GetTableLayout()
Get child table layout.
virtual void XFConvertFrame(XFContentContainer *pCont, sal_Int32 nStart=0, sal_Int32 nEnd=0, bool bAll=false) override
convert frame which anchor to page
virtual ~LwpSuperTableLayout() override
void ApplyAlignment(XFTableStyle *pTableStyle)
Apply alignment to table.
encapsulate XInputStream to provide SvStream like interfaces
Definition: lwpsvstream.hxx:69
VO_TABLEHEADINGLAYOUT object.
void Read() override
read table heading layout
virtual ~LwpTableHeadingLayout() override
void GetStartEndRow(sal_uInt16 &nStartRow, sal_uInt16 &nEndRow)
get start and end row number of table heading
LwpTableHeadingLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
VO_TABLELAYOUT object and functions for registering styles and converting tables.
void PutCellVals(LwpFoundry *pFoundry, LwpObjectID aTableID)
apply numeric value and formula to cell
LwpCellLayout * GetCellByRowCol(sal_uInt16 nRow, sal_uInt16 nCol)
Get neighbour cell by specifying ROW+COL.
std::vector< LwpCellLayout * > m_WordProCellsMap
std::map< sal_uInt16, LwpRowLayout * > m_RowsMap
void SplitConflictCells()
split conflict merged cells
LwpSuperTableLayout * GetSuperTableLayout()
Get parent super table layout of table layout.
sal_uInt16 ConvertHeadingRow(rtl::Reference< XFTable > const &pXFTable, sal_uInt16 nStartHeadRow, sal_uInt16 nEndHeadRow)
convert heading row
std::vector< LwpColumnLayout * > m_aColumns
OUString m_DefaultColumnStyleName
void RegisterRows()
register all row styles
LwpRowLayout * GetRowLayout(sal_uInt16 nRow)
@descr Get row layout by row id
static bool FindSplitColMark(XFTable *pXFTable, std::vector< sal_uInt8 > &rCellMark, sal_uInt8 &nMaxColSpan)
find if the heading rows can be split to 2 cells
void ConvertTable(rtl::Reference< XFTable > const &pXFTable, sal_uInt16 nStartRow, sal_uInt16 nEndRow, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
convert word pro table to SODC table
LwpObjectID & GetColumnLayoutHead()
LwpObjectID m_ColumnLayout
sal_uInt16 m_nCols
void PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_uInt16 nColID)
1.
void SplitRowToCells(XFTable *pTmpTable, rtl::Reference< XFTable > const &pXFTable, sal_uInt8 nFirstColSpann, const sal_uInt8 *pCellMark)
rtl::Reference< XFTable > m_pXFTable
void ConvertDefaultRow(rtl::Reference< XFTable > const &pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol, sal_uInt16 nRowID)
add default row which are missing in the file
void ParseTable()
read table layout
void RegisterColumns()
analyze all columns to get whole table width and width of all columns
void RegisterStyle() override
register table style, if needed, including frame style
LwpCellLayout * m_pDefaultCellLayout
void TraverseTable()
traverse all table cells
LwpObjectID * SearchCellStoryMap(sal_uInt16 nRow, sal_uInt16 nCol)
search the cell map
void SetCellsMap(sal_uInt16 nRow1, sal_uInt8 nCol1, sal_uInt16 nRow2, sal_uInt8 nCol2, XFCell *pXFCell)
set cell map info
OUString m_DefaultRowStyleName
LwpTable * GetTable()
Get table pointer.
LwpTableLayout(LwpObjectHeader const &objHdr, LwpSvStream *pStrm)
OUString GetColumnWidth(sal_uInt16 nCol)
Get column style name by column ID.
void XFConvert(XFContentContainer *pCont) override
Convert table.
std::vector< TableConvertAttempt > m_aConvertingStack
XFCell * GetCellsMap(sal_uInt16 nRow, sal_uInt8 nCol)
get cell map info
void Read() override
read table layout
void ConvertColumn(rtl::Reference< XFTable > const &pXFTable, sal_uInt8 nStartCol, sal_uInt8 nEndCol)
Parse all cols of table.
sal_uInt16 m_nRows
VO_TABLERANGE object.
Definition: lwptblcell.hxx:141
LwpTableRange * GetNext()
Definition: lwptblcell.hxx:148
const LwpObjectID & GetTableID() const
Definition: lwptblcell.hxx:147
const LwpObjectID & GetCellRangeID() const
Definition: lwptblcell.hxx:146
VO_TABLE object.
Definition: lwptable.hxx:107
double GetHeight()
Definition: lwptable.hxx:114
double GetWidth()
Definition: lwptable.hxx:113
sal_uInt16 GetRow() const
Definition: lwptable.hxx:116
sal_uInt16 GetColumn() const
Definition: lwptable.hxx:117
LwpObjectID & GetDefaultCellStyle()
Definition: lwptable.hxx:115
static double ConvertFromUnitsToMetric(sal_Int32 nUnits)
Definition: lwptools.hxx:117
void Read() override
@descr Read name of LwpDLNFVList from object stream
Definition: lwplayout.cxx:101
bool IsRelativeAnchored()
@descr: whether it is relative anchored layout
Definition: lwplayout.cxx:295
OUString m_StyleName
Definition: lwplayout.hxx:249
const OUString & GetStyleName() const
Definition: lwplayout.hxx:171
sal_uInt16 m_nDirection
Definition: lwplayout.hxx:245
double GetMarginsValue(sal_uInt8 nWhichSide)
Definition: lwplayout.hxx:153
bool IsCell()
@descr: Whether this layout is cell layout or not
Definition: lwplayout.cxx:272
virtual LWP_LAYOUT_TYPE GetLayoutType()
Definition: lwplayout.hxx:291
@descr Table cell object.
Definition: xfcell.hxx:76
sal_Int32 GetColSpaned() const
@descr return cell column span property.
Definition: xfcell.hxx:190
Column style, it has only one property-the column width.
Definition: xfcolstyle.hxx:70
Color object.
Definition: xfcolor.hxx:70
A container for content.
virtual void Add(XFContent *pContent)
@descr Add content.
rtl::Reference< XFContent > FindFirstContent(enumXFContent type)
@descr helper function, find first content by type.
const OUString & GetStyleName() const
: return the style name.
Definition: xfcontent.hxx:95
virtual void SetStyleName(const OUString &style)
: All content except XFTextContent can have a style.
Definition: xfcontent.hxx:90
Floating frame on any page.
@descr The font struct of openoffice xml filter.
Definition: xffont.hxx:120
Style for all frame objects.
Base class for all frame object,include drawing,image,text-box.
Definition: xfframe.hxx:79
const XFColor & GetColor() const
Style object for aragraph.
Definition: xfparastyle.hxx:93
bool GetNumberRight() const
void SetAlignType(enumXFAlignType eAlign)
@descr Set alignment property of the paragraph.
Paragraph object for SODC.
Definition: xfparagraph.hxx:73
void SetMinRowHeight(double height)
Definition: xfrowstyle.hxx:92
Definition: xfrow.hxx:69
XFCell * GetCell(sal_Int32 col) const
Definition: xfrow.cxx:95
sal_Int32 GetCellCount() const
Definition: xfrow.cxx:89
Style manager for the filter.
IXFStyle * FindStyle(std::u16string_view name)
IXFStyleRet AddStyle(std::unique_ptr< IXFStyle > pStyle)
XFParaStyle * FindParaStyle(std::u16string_view name)
void SetBackColor(XFColor const &color)
void SetAlign(enumXFAlignType eAlign, double offset=0)
void SetShadow(enumXFShadowPos pos, double offset, XFColor color)
void SetBackImage(std::unique_ptr< XFBGImage > &rImage)
sal_uInt16 GetRowCount()
Definition: xftable.cxx:155
XFRow * GetRow(sal_Int32 row)
Definition: xftable.cxx:167
void RemoveRow(sal_uInt16 row)
Definition: xftable.hxx:103
sal_Int32 GetColumnCount()
Definition: xftable.cxx:172
std::pair< const_iterator, bool > insert(Value &&x)
static bool IsFuzzing()
int nCount
uno_Any a
#define SAL_WARN(area, stream)
const sal_uInt8 MARGIN_RIGHT
Definition: lwpmargins.hxx:64
const sal_uInt8 MARGIN_LEFT
Definition: lwpmargins.hxx:63
For LWP filter architecture prototype - row layouts.
For LWP filter architecture prototype - table object.
#define MAX_NUM_COLS
Definition: lwptable.hxx:176
#define MAX_NUM_ROWS
Definition: lwptable.hxx:175
static bool operator==(const TableConvertAttempt &a, const TableConvertAttempt &b)
For LWP filter architecture prototype - table layouts.
For LWP filter architecture prototype - table object.
int i
constexpr OUStringLiteral first
QPRO_FUNC_TYPE nType
IXFStyle * m_pStyle
Definition: xfstylecont.hxx:71
unsigned char sal_uInt8
@ enumXFContentPara
Definition: xfdefs.hxx:68
@ enumXFAlignStart
Definition: xfdefs.hxx:174
@ enumXFAlignEnd
Definition: xfdefs.hxx:176
@ enumXFAlignCenter
Definition: xfdefs.hxx:175