1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_TABLE_MANAGER_HXX 25 #define INCLUDED_TABLE_MANAGER_HXX 26 27 #include <resourcemodel/TableData.hxx> 28 #include <resourcemodel/WW8ResourceModel.hxx> 29 #include <doctok/sprmids.hxx> 30 31 #include <boost/shared_ptr.hpp> 32 #include <stack> 33 #include "util.hxx" 34 #include "TagLogger.hxx" 35 36 namespace writerfilter 37 { 38 39 using namespace ::std; 40 41 template <typename T, typename PropertiesPointer> 42 /** 43 Class to handle events generated by TableManager::resolveCurrentTable 44 */ 45 class WRITERFILTER_DLLPUBLIC TableDataHandler 46 { 47 public: 48 typedef boost::shared_ptr<TableDataHandler> Pointer_t; 49 50 /** 51 Handle start of table. 52 53 @param nRows number of rows in the table 54 @param nDepth depth of the table in surrounding table hierarchy 55 @param pProps properties of the table 56 */ 57 virtual void startTable( 58 unsigned int nRows, 59 unsigned int nDepth, 60 PropertiesPointer pProps ) = 0; 61 62 /** 63 Handle end of table. 64 */ 65 virtual void endTable( 66 const unsigned int nDepth ) = 0; 67 68 /** 69 Handle start of row. 70 71 @param nCols number of columns in the table 72 @param pProps properties of the row 73 */ 74 virtual void startRow( 75 unsigned int nCols, 76 PropertiesPointer pProps ) = 0; 77 78 /** 79 Handle end of row. 80 */ 81 virtual void endRow() = 0; 82 83 /** 84 Handle start of cell. 85 86 @param rT start handle of the cell 87 @param pProps properties of the cell 88 */ 89 virtual void startCell( 90 const T & rT, 91 PropertiesPointer pProps ) = 0; 92 93 /** 94 Handle end of cell. 95 96 @param rT end handle of cell 97 */ 98 virtual void endCell( 99 const T & rT ) = 0; 100 }; 101 102 template <typename T, typename PropertiesPointer> 103 /** 104 The table manager. 105 106 This class gets forwarded events from the tokenizer. It gathers the 107 table data and after ending the table generates events for the 108 table structure. The events have to be handles by a TableDataHandler. 109 110 */ 111 class TableManager 112 { 113 #ifdef DEBUG_TABLE 114 TagLogger::Pointer_t mpTableLogger; 115 #endif 116 117 class TableManagerState 118 { 119 /** 120 properties at the current point in document 121 */ 122 PropertiesPointer mpProps; 123 124 /** 125 properties of the current cell 126 */ 127 PropertiesPointer mpCellProps; 128 129 /** 130 properties of the current row 131 */ 132 PropertiesPointer mpRowProps; 133 134 /** 135 properties of the current table 136 */ 137 stack<PropertiesPointer> mTableProps; 138 139 /** 140 true if at the end of a row 141 */ 142 bool mbRowEnd; 143 144 /** 145 true when in a cell 146 */ 147 bool mbInCell; 148 149 /** 150 true when at the end of a cell 151 */ 152 bool mbCellEnd; 153 154 public: 155 /** 156 Constructor 157 */ 158 TableManagerState() 159 : mbRowEnd(false), mbInCell(false), mbCellEnd(false) 160 { 161 } 162 163 virtual ~TableManagerState() 164 { 165 } 166 167 void startLevel() 168 { 169 PropertiesPointer pProps; 170 mTableProps.push(pProps); 171 } 172 173 void endLevel() 174 { 175 mTableProps.pop(); 176 } 177 178 /** 179 Reset to initial state at beginning of row. 180 */ 181 void resetCellSpecifics() 182 { 183 mbRowEnd = false; 184 mbInCell = false; 185 mbCellEnd = false; 186 } 187 188 void resetProps() 189 { 190 mpProps.reset(); 191 } 192 193 void setProps(PropertiesPointer pProps) 194 { 195 mpProps = pProps; 196 } 197 198 PropertiesPointer getProps() 199 { 200 return mpProps; 201 } 202 203 void resetCellProps() 204 { 205 mpCellProps.reset(); 206 } 207 208 void setCellProps(PropertiesPointer pProps) 209 { 210 mpCellProps = pProps; 211 } 212 213 PropertiesPointer getCellProps() 214 { 215 return mpCellProps; 216 } 217 218 void resetRowProps() 219 { 220 mpRowProps.reset(); 221 } 222 223 void setRowProps(PropertiesPointer pProps) 224 { 225 mpRowProps = pProps; 226 } 227 228 PropertiesPointer getRowProps() 229 { 230 return mpRowProps; 231 } 232 233 void resetTableProps() 234 { 235 if (mTableProps.size() > 0) 236 mTableProps.top().reset(); 237 } 238 239 void setTableProps(PropertiesPointer pProps) 240 { 241 if (mTableProps.size() > 0) 242 mTableProps.top() = pProps; 243 } 244 245 PropertiesPointer getTableProps() 246 { 247 PropertiesPointer pResult; 248 249 if (mTableProps.size() > 0) 250 pResult = mTableProps.top(); 251 252 return pResult; 253 } 254 255 void setInCell(bool bInCell) 256 { 257 mbInCell = bInCell; 258 } 259 260 bool isInCell() const 261 { 262 return mbInCell; 263 } 264 265 void setCellEnd(bool bCellEnd) 266 { 267 mbCellEnd = bCellEnd; 268 } 269 270 bool isCellEnd() const 271 { 272 return mbCellEnd; 273 } 274 275 void setRowEnd(bool bRowEnd) 276 { 277 mbRowEnd = bRowEnd; 278 } 279 280 bool isRowEnd() const 281 { 282 return mbRowEnd; 283 } 284 }; 285 286 /** 287 handle for the current position in document 288 */ 289 T mCurHandle; 290 291 TableManagerState mState; 292 293 protected: 294 PropertiesPointer getProps() 295 { 296 return mState.getProps(); 297 } 298 299 void setProps( 300 PropertiesPointer pProps ) 301 { 302 mState.setProps( pProps ); 303 } 304 305 void resetProps() 306 { 307 mState.resetProps(); 308 } 309 310 PropertiesPointer getCellProps() 311 { 312 return mState.getCellProps(); 313 } 314 315 void setCellProps( 316 PropertiesPointer pProps ) 317 { 318 mState.setCellProps( pProps ); 319 } 320 321 void resetCellProps() 322 { 323 mState.resetCellProps(); 324 } 325 326 PropertiesPointer getRowProps() 327 { 328 return mState.getRowProps(); 329 } 330 331 void setRowProps( 332 PropertiesPointer pProps ) 333 { 334 mState.setRowProps( pProps ); 335 } 336 337 void resetRowProps() 338 { 339 mState.resetRowProps(); 340 } 341 342 void setInCell( 343 bool bInCell ) 344 { 345 mState.setInCell( bInCell ); 346 } 347 348 bool isInCell() const 349 { 350 return mState.isInCell(); 351 } 352 353 void setCellEnd( 354 bool bCellEnd ) 355 { 356 mState.setCellEnd( bCellEnd ); 357 } 358 359 bool isCellEnd() const 360 { 361 return mState.isCellEnd(); 362 } 363 364 void setRowEnd( 365 bool bRowEnd ) 366 { 367 mState.setRowEnd( bRowEnd ); 368 } 369 370 bool isRowEnd() const 371 { 372 return mState.isRowEnd(); 373 } 374 375 PropertiesPointer getTableProps() 376 { 377 return mState.getTableProps(); 378 } 379 380 void setTableProps( 381 PropertiesPointer pProps ) 382 { 383 mState.setTableProps( pProps ); 384 } 385 386 void resetTableProps() 387 { 388 mState.resetTableProps(); 389 } 390 391 T getHandle() 392 { 393 return mCurHandle; 394 } 395 396 void setHandle( 397 const T & rHandle ) 398 { 399 mCurHandle = rHandle; 400 } 401 402 private: 403 typedef boost::shared_ptr<T> T_p; 404 405 /** 406 depth of the current cell 407 */ 408 sal_uInt32 mnTableDepthNew; 409 410 /** 411 depth of the previous cell 412 */ 413 sal_uInt32 mnTableDepth; 414 415 /** 416 stack of table data 417 418 for each level of nested tables there is one frame in the stack 419 */ 420 stack<typename TableData<T, PropertiesPointer>::Pointer_t > mTableDataStack; 421 422 typedef typename TableDataHandler<T, PropertiesPointer>::Pointer_t TableDataHandlerPointer_t; 423 424 /** 425 handler for resolveCurrentTable 426 */ 427 TableDataHandlerPointer_t mpTableDataHandler; 428 429 /** 430 Set flag which indicates the current handle is in a cell. 431 */ 432 void inCell(); 433 434 /** 435 Set flag which indicate the current handle is at the end of a cell. 436 */ 437 void endCell(); 438 439 /** 440 Set the table depth of the current cell. 441 442 @param nDepth the cell depth 443 */ 444 void cellDepth(sal_uInt32 nDepth); 445 446 /** 447 Set flag indication the current handle is at the end of a row. 448 */ 449 void endRow(); 450 451 /** 452 Resolve the current table to the TableDataHandler. 453 */ 454 void resolveCurrentTable(); 455 456 /** 457 Open a cell at current level. 458 */ 459 460 void openCell(const T & handle, PropertiesPointer pProps); 461 462 /** 463 Close a cell at current level. 464 */ 465 void closeCell(const T & handle); 466 467 /** 468 Ensure a cell is open at the current level. 469 */ 470 void ensureOpenCell(PropertiesPointer pProps); 471 472 protected: 473 474 /** 475 Return current table depth. 476 */ 477 sal_uInt32 getTableDepthNew() { return mnTableDepthNew; } 478 479 /** 480 Action to be carried out at the end of the last paragraph of a 481 cell. 482 */ 483 virtual void endOfCellAction(); 484 485 /** 486 Action to be carried out at the end of the "table row" 487 paragraph. 488 */ 489 virtual void endOfRowAction(); 490 491 492 public: 493 TableManager(); 494 virtual ~TableManager(){} 495 496 /** 497 Set handler for resolveCurrentTable. 498 499 @param pTableDataHandler the handler 500 */ 501 void setHandler(TableDataHandlerPointer_t pTableDataHandler); 502 503 /** 504 Set the current handle. 505 506 @param rHandle the handle 507 */ 508 virtual void handle(const T & rHandle); 509 510 /** 511 Start a new table level. 512 513 A new context is pushed onto the table data stack, 514 */ 515 virtual void startLevel(); 516 517 /** 518 End a table level. 519 520 The current table is resolved and the context is popped from 521 the stack. 522 */ 523 virtual void endLevel(); 524 525 /** 526 Handle the start of a paragraph group. 527 */ 528 virtual void startParagraphGroup(); 529 530 /** 531 Handle the end of a paragraph group. 532 */ 533 virtual void endParagraphGroup(); 534 535 /** 536 Handle an SPRM at current handle. 537 538 @param rSprm the SPRM 539 */ 540 virtual bool sprm(Sprm & rSprm); 541 542 /** 543 Handle properties at current handle. 544 545 @param pProps the properties 546 */ 547 virtual void props(PropertiesPointer pProps); 548 549 /** 550 Handle occurrence of character 0x7. 551 */ 552 virtual void handle0x7(); 553 554 /** 555 Handle 8 bit text at current handle. 556 557 @param data array of characters 558 @param len number of characters to handle 559 */ 560 virtual void text(const sal_uInt8 * data, size_t len); 561 562 /** 563 Handle 16 bit text at current handle. 564 565 @param data array of characters 566 @param len number of characters to handle 567 */ 568 virtual void utext(const sal_uInt8 * data, size_t len); 569 570 /** 571 Handle properties of the current cell. 572 573 @param pProps the properties 574 */ 575 virtual void cellProps(PropertiesPointer pProps); 576 577 /** 578 Handle properties of a certain cell in the current row. 579 580 @paran i index of the cell in the current row 581 @param pProps the properties 582 */ 583 virtual void cellPropsByCell(unsigned int i, PropertiesPointer pProps); 584 585 /** 586 Handle properties of the current row. 587 588 @param pProps the properties 589 */ 590 virtual void insertRowProps(PropertiesPointer pProps); 591 592 /** 593 Handle properties of the current table. 594 595 @param pProps the properties 596 */ 597 virtual void insertTableProps(PropertiesPointer pProps); 598 599 /** 600 Return if table manager has detected paragraph to ignore. 601 602 If this function returns true the current paragraph contains 603 only control information, e.g. end of row. 604 */ 605 virtual bool isIgnore() const; 606 607 608 #ifdef DEBUG_TABLE 609 void setTagLogger(TagLogger::Pointer_t _tagLogger) 610 { 611 mpTableLogger = _tagLogger; 612 } 613 #endif 614 }; 615 616 template <typename T, typename PropertiesPointer> 617 TableManager<T, PropertiesPointer>::TableManager() 618 : mnTableDepthNew(0), mnTableDepth(0) 619 { 620 setRowEnd(false); 621 setInCell(false); 622 setCellEnd(false); 623 } 624 625 template <typename T, typename PropertiesPointer> 626 void TableManager<T, PropertiesPointer>::cellDepth(sal_uInt32 nDepth) 627 { 628 #ifdef DEBUG_TABLE 629 if (mpTableLogger.get() != NULL) 630 { 631 mpTableLogger->startElement("tablemanager.cellDepth"); 632 mpTableLogger->attribute("depth", nDepth); 633 mpTableLogger->endElement("tablemanager.cellDepth"); 634 } 635 #endif 636 637 mnTableDepthNew = nDepth; 638 } 639 640 template <typename T, typename PropertiesPointer> 641 void TableManager<T, PropertiesPointer>::inCell() 642 { 643 #ifdef DEBUG_TABLE 644 if (mpTableLogger.get() != NULL) 645 mpTableLogger->element("tablemanager.inCell"); 646 #endif 647 setInCell(true); 648 649 if (mnTableDepthNew < 1) 650 mnTableDepthNew = 1; 651 } 652 653 template <typename T, typename PropertiesPointer> 654 void TableManager<T, PropertiesPointer>::endCell() 655 { 656 #ifdef DEBUG_TABLE 657 if (mpTableLogger.get() != NULL) 658 mpTableLogger->element("tablemanager.endCell"); 659 #endif 660 661 setCellEnd(true); 662 } 663 664 template <typename T, typename PropertiesPointer> 665 void TableManager<T, PropertiesPointer>::endRow() 666 { 667 #ifdef DEBUG_TABLE 668 if (mpTableLogger.get() != NULL) 669 mpTableLogger->element("tablemanager.endRow"); 670 #endif 671 672 setRowEnd(true); 673 } 674 675 template <typename T, typename PropertiesPointer> 676 void TableManager<T, PropertiesPointer>::setHandler 677 (typename TableDataHandler<T, PropertiesPointer>::Pointer_t pTableDataHandler) 678 { 679 mpTableDataHandler = pTableDataHandler; 680 } 681 682 template <typename T, typename PropertiesPointer> 683 void TableManager<T, PropertiesPointer>::handle(const T & rHandle) 684 { 685 #ifdef DEBUG_TABLE 686 if (mpTableLogger.get()) 687 { 688 mpTableLogger->startElement("tablemanager.handle"); 689 mpTableLogger->chars(toString(rHandle)); 690 mpTableLogger->endElement("tablemanager.handle"); 691 } 692 #endif 693 694 setHandle(rHandle); 695 } 696 697 template <typename T, typename PropertiesPointer> 698 void TableManager<T, PropertiesPointer>::startLevel() 699 { 700 #ifdef DEBUG_TABLE 701 if (mpTableLogger.get() != NULL) 702 { 703 typename TableData<T, PropertiesPointer>::Pointer_t pTableData; 704 705 if (mTableDataStack.size() > 0) 706 pTableData = mTableDataStack.top(); 707 708 mpTableLogger->startElement("tablemanager.startLevel"); 709 mpTableLogger->attribute("level", mTableDataStack.size()); 710 711 if (pTableData.get() != NULL) 712 mpTableLogger->attribute("openCell", 713 pTableData->isCellOpen() ? "yes" : "no"); 714 715 mpTableLogger->endElement("tablemanager.startLevel"); 716 } 717 #endif 718 719 typename TableData<T, PropertiesPointer>::Pointer_t pTableData 720 (new TableData<T, PropertiesPointer>(mTableDataStack.size())); 721 722 mTableDataStack.push(pTableData); 723 mState.startLevel(); 724 } 725 726 template <typename T, typename PropertiesPointer> 727 void TableManager<T, PropertiesPointer>::endLevel() 728 { 729 if (mpTableDataHandler.get() != NULL) 730 resolveCurrentTable(); 731 732 mState.endLevel(); 733 mTableDataStack.pop(); 734 735 #ifdef DEBUG_TABLE 736 if (mpTableLogger.get() != NULL) 737 { 738 typename TableData<T, PropertiesPointer>::Pointer_t pTableData; 739 740 if (mTableDataStack.size() > 0) 741 pTableData = mTableDataStack.top(); 742 743 mpTableLogger->startElement("tablemanager.endLevel"); 744 mpTableLogger->attribute("level", mTableDataStack.size()); 745 746 if (pTableData.get() != NULL) 747 mpTableLogger->attribute("openCell", 748 pTableData->isCellOpen() ? "yes" : "no"); 749 750 mpTableLogger->endElement("tablemanager.endLevel"); 751 } 752 #endif 753 } 754 755 template <typename T, typename PropertiesPointer> 756 void TableManager<T, PropertiesPointer>::startParagraphGroup() 757 { 758 mState.resetCellSpecifics(); 759 mnTableDepthNew = 0; 760 } 761 762 template <typename T, typename PropertiesPointer> 763 void TableManager<T, PropertiesPointer>::endParagraphGroup() 764 { 765 sal_Int32 nTableDepthDifference = mnTableDepthNew - mnTableDepth; 766 767 PropertiesPointer pEmptyProps; 768 769 while (nTableDepthDifference > 0) 770 { 771 ensureOpenCell(pEmptyProps); 772 startLevel(); 773 774 --nTableDepthDifference; 775 } 776 while (nTableDepthDifference < 0) 777 { 778 endLevel(); 779 780 ++nTableDepthDifference; 781 } 782 783 mnTableDepth = mnTableDepthNew; 784 785 if ( mnTableDepth > 0 ) 786 { 787 typename TableData< T, PropertiesPointer >::Pointer_t pTableData = mTableDataStack.top(); 788 789 if ( isRowEnd() ) 790 { 791 endOfRowAction(); 792 pTableData->endRow( getRowProps() ); 793 resetRowProps(); 794 } 795 796 else if ( isInCell() ) 797 { 798 ensureOpenCell( getCellProps() ); 799 800 if ( isCellEnd() ) 801 { 802 endOfCellAction(); 803 closeCell( getHandle() ); 804 } 805 } 806 resetCellProps(); 807 } 808 } 809 810 template <typename T, typename PropertiesPointer> 811 bool TableManager<T, PropertiesPointer>::sprm(Sprm & rSprm) 812 { 813 bool bRet = true; 814 switch (rSprm.getId()) 815 { 816 case NS_sprm::LN_PTableDepth: 817 { 818 Value::Pointer_t pValue = rSprm.getValue(); 819 820 cellDepth(pValue->getInt()); 821 } 822 break; 823 case NS_sprm::LN_PFInTable: 824 inCell(); 825 break; 826 case NS_sprm::LN_PCell: 827 endCell(); 828 break; 829 case NS_sprm::LN_PFTtp: 830 case NS_sprm::LN_PRow: 831 endRow(); 832 break; 833 default: 834 bRet = false; 835 } 836 return bRet; 837 } 838 template <typename T, typename PropertiesPointer> 839 void TableManager<T, PropertiesPointer>::props(PropertiesPointer pProps) 840 { 841 setProps(pProps); 842 } 843 844 template <typename T, typename PropertiesPointer> 845 void TableManager<T, PropertiesPointer>::handle0x7() 846 { 847 #ifdef DEBUG_TABLE 848 if (mpTableLogger.get() != NULL) 849 mpTableLogger->startElement("tablemanager.handle0x7"); 850 #endif 851 852 if (mnTableDepthNew < 1) 853 mnTableDepthNew = 1; 854 855 if (isInCell()) 856 endCell(); 857 else 858 endRow(); 859 860 #ifdef DEBUG_TABLE 861 if (mpTableLogger.get() != NULL) 862 mpTableLogger->endElement("tablemanager.handle0x7"); 863 #endif 864 } 865 866 template <typename T, typename PropertiesPointer> 867 void TableManager<T, PropertiesPointer>::text(const sal_uInt8 * data, size_t len) 868 { 869 // optimization: cell/row end characters are the last characters in a run 870 if (len > 0) 871 { 872 if (data[len - 1] == 0x7) 873 handle0x7(); 874 } 875 } 876 877 template <typename T, typename PropertiesPointer> 878 void TableManager<T, PropertiesPointer>::utext(const sal_uInt8 * data, size_t len) 879 { 880 // optimization: cell/row end characters are the last characters in a run 881 882 if (len > 0) 883 { 884 sal_Unicode nChar = data[(len - 1) * 2] + (data[(len - 1) * 2 + 1] << 8); 885 if (nChar == 0x7) 886 handle0x7(); 887 } 888 } 889 890 template <typename T, typename PropertiesPointer> 891 void TableManager<T, PropertiesPointer>::cellProps(PropertiesPointer pProps) 892 { 893 #ifdef DEBUG_TABLE 894 if (mpTableLogger.get() != NULL) 895 mpTableLogger->startElement("tablemanager.cellProps"); 896 #endif 897 898 if(getCellProps().get()) 899 getCellProps()->insert( pProps ); 900 else 901 setCellProps(pProps); 902 903 #ifdef DEBUG_TABLE 904 if (mpTableLogger.get() != NULL) 905 mpTableLogger->endElement("tablemanager.cellProps"); 906 #endif 907 } 908 909 template <typename T, typename PropertiesPointer> 910 void TableManager<T, PropertiesPointer>::cellPropsByCell 911 (unsigned int i, PropertiesPointer pProps) 912 { 913 #ifdef DEBUG_TABLE 914 if (mpTableLogger.get() != NULL) 915 mpTableLogger->startElement("tablemanager.cellPropsByCell"); 916 #endif 917 918 mTableDataStack.top()->insertCellProperties(i, pProps); 919 920 #ifdef DEBUG_TABLE 921 if (mpTableLogger.get() != NULL) 922 mpTableLogger->endElement("tablemanager.cellPropsByCell"); 923 #endif 924 } 925 926 template <typename T, typename PropertiesPointer> 927 void TableManager<T, PropertiesPointer>::insertRowProps(PropertiesPointer pProps) 928 { 929 #ifdef DEBUG_TABLE 930 if (mpTableLogger.get() != NULL) 931 mpTableLogger->startElement("tablemanager.insertRowProps"); 932 #endif 933 934 if( getRowProps().get() ) 935 getRowProps()->insert( pProps ); 936 else 937 setRowProps(pProps); 938 939 #ifdef DEBUG_TABLE 940 if (mpTableLogger.get() != NULL) 941 mpTableLogger->endElement("tablemanager.insertRowProps"); 942 #endif 943 } 944 945 template <typename T, typename PropertiesPointer> 946 void TableManager<T, PropertiesPointer>::insertTableProps(PropertiesPointer pProps) 947 { 948 #ifdef DEBUG_TABLE 949 if (mpTableLogger.get() != NULL) 950 mpTableLogger->startElement("tablemanager.insertTableProps"); 951 #endif 952 953 if( getTableProps().get() ) 954 getTableProps()->insert( pProps ); 955 else 956 setTableProps(pProps); 957 958 #ifdef DEBUG_TABLE 959 if (mpTableLogger.get() != NULL) 960 mpTableLogger->endElement("tablemanager.insertTableProps"); 961 #endif 962 } 963 964 template <typename T, typename PropertiesPointer> 965 void TableManager<T, PropertiesPointer>::resolveCurrentTable() 966 { 967 #ifdef DEBUG_TABLE 968 if (mpTableLogger.get() != NULL) 969 mpTableLogger->startElement("tablemanager.resolveCurrentTable"); 970 #endif 971 972 if (mpTableDataHandler.get() != NULL) 973 { 974 typename TableData<T, PropertiesPointer>::Pointer_t 975 pTableData = mTableDataStack.top(); 976 977 const unsigned int nRows = pTableData->getRowCount(); 978 979 mpTableDataHandler->startTable(nRows, pTableData->getDepth(), getTableProps()); 980 981 for (unsigned int nRow = 0; nRow < nRows; ++nRow) 982 { 983 typename RowData<T, PropertiesPointer>::Pointer_t pRowData = pTableData->getRow(nRow); 984 985 unsigned int nCells = pRowData->getCellCount(); 986 987 mpTableDataHandler->startRow(nCells, pRowData->getProperties()); 988 989 for (unsigned int nCell = 0; nCell < nCells; ++nCell) 990 { 991 mpTableDataHandler->startCell 992 (pRowData->getCellStart(nCell), 993 pRowData->getCellProperties(nCell)); 994 995 mpTableDataHandler->endCell(pRowData->getCellEnd(nCell)); 996 } 997 998 mpTableDataHandler->endRow(); 999 } 1000 1001 mpTableDataHandler->endTable( pTableData->getDepth() ); 1002 } 1003 resetTableProps(); 1004 1005 #ifdef DEBUG_TABLE 1006 if (mpTableLogger.get() != NULL) 1007 mpTableLogger->endElement("tablemanager.resolveCurrentTable"); 1008 #endif 1009 } 1010 1011 template <typename T, typename PropertiesPointer> 1012 void TableManager<T, PropertiesPointer>::endOfCellAction() 1013 { 1014 } 1015 1016 template <typename T, typename PropertiesPointer> 1017 void TableManager<T, PropertiesPointer>::endOfRowAction() 1018 { 1019 } 1020 1021 template <typename T, typename PropertiesPointer> 1022 bool TableManager<T, PropertiesPointer>::isIgnore() const 1023 { 1024 return isRowEnd(); 1025 } 1026 1027 template <typename T, typename PropertiesPointer> 1028 void TableManager<T, PropertiesPointer>::openCell 1029 (const T & rHandle, PropertiesPointer pProps) 1030 { 1031 #ifdef DEBUG_TABLE 1032 mpTableLogger->startElement("tablemanager.openCell"); 1033 mpTableLogger->chars(toString(rHandle)); 1034 mpTableLogger->endElement("tablemanager.openCell"); 1035 #endif 1036 1037 if (mTableDataStack.size() > 0) 1038 { 1039 typename TableData<T, PropertiesPointer>::Pointer_t 1040 pTableData = mTableDataStack.top(); 1041 1042 pTableData->addCell(rHandle, pProps); 1043 } 1044 } 1045 1046 template <typename T, typename PropertiesPointer> 1047 void TableManager<T, PropertiesPointer>::closeCell 1048 (const T & rHandle) 1049 { 1050 #ifdef DEBUG_TABLE 1051 mpTableLogger->startElement("tablemanager.closeCell"); 1052 mpTableLogger->chars(toString(rHandle)); 1053 mpTableLogger->endElement("tablemanager.closeCell"); 1054 #endif 1055 1056 if (mTableDataStack.size() > 0) 1057 { 1058 typename TableData<T, PropertiesPointer>::Pointer_t 1059 pTableData = mTableDataStack.top(); 1060 1061 pTableData->endCell(rHandle); 1062 } 1063 } 1064 1065 template <typename T, typename PropertiesPointer> 1066 void TableManager<T, PropertiesPointer>::ensureOpenCell(PropertiesPointer pProps) 1067 { 1068 #ifdef DEBUG_TABLE 1069 mpTableLogger->startElement("tablemanager.ensureOpenCell"); 1070 #endif 1071 1072 if (mTableDataStack.size() > 0) 1073 { 1074 typename TableData<T, PropertiesPointer>::Pointer_t 1075 pTableData = mTableDataStack.top(); 1076 1077 if (pTableData.get() != NULL) 1078 { 1079 if (!pTableData->isCellOpen()) 1080 openCell(getHandle(), pProps); 1081 else 1082 pTableData->insertCellProperties(pProps); 1083 } 1084 } 1085 #ifdef DEBUG_TABLE 1086 mpTableLogger->endElement("tablemanager.ensureOpenCell"); 1087 #endif 1088 } 1089 1090 } 1091 1092 #endif // INCLUDED_TABLE_MANAGER_HXX 1093