public function testRecognizesModule() { $file = new TableOfContents\File(); $file->setFilename('test'); $file2 = new TableOfContents\File(); $file2->setFilename('test2'); $file3 = new TableOfContents\File(); $file3->setFilename('index'); $file4 = new TableOfContents\File(); $file4->setFilename('INDEX'); $file5 = new TableOfContents\File(); $file5->setFilename('test3'); $this->object[] = $file; $this->object[] = $file2; $this->object[] = $file3; $this->object[] = $file4; $this->assertCount(2, $this->object->getModules()); $this->assertSame(array($file3, $file4), $this->object->getModules()); }
/** * Parses a section element of HWPF document * @return HTMLElement */ private function parseSection() { // Create new style for HTML element $container = new HTMLElement(HTMLElement::DIV); $this->mainStyleSheet = new StyleSheet(); // Set class name $styleClass = new StyleClass(); $className = $this->mainStyleSheet->getClassName($styleClass); $container->setClass($className); //Initialize headers and footers $this->collectHeaderFooterInformation(); // Get document body elements $elements = java_values($this->document->getBodyElements()); //Set current processed part $this->currentProcessedPart = "BODY"; $tocNumber = 0; // Every Word document section consists of paragraphs, so we iterate through them, and parse them one by one foreach ($elements as $key => $element) { // Check if element is a table if (java_instanceof($element, java('org.apache.poi.xwpf.usermodel.XWPFTable'))) { $table = new XWPFTable($element, $key, $this->mainStyleSheet); $tableElement = $table->parseTable(); $container->addInnerElement($tableElement); } // Check if element is a paragraph if (java_instanceof($element, java('org.apache.poi.xwpf.usermodel.XWPFParagraph'))) { // Get paragraph out of element $paragraph = java_cast($element, 'org.apache.poi.xwpf.usermodel.XWPFParagraph'); //$beforeProcess = $this->inspectParagraph($paragraph, $container ,$key); if ($this->checkLastRenderedPage($paragraph)) { //echo "page:".$this->pageCounter."<br/>"; // $container->addInnerElement($this->auxContainer[0]); // $container->addInnerElement($this->auxContainer[1]); } //Check if the element is a list $numberingInfo = $this->paragraphExtractNumbering($paragraph); if ($numberingInfo) { $this->processList($numberingInfo, $container, $paragraph, $key); } else { // Parse paragraph $paragraphHTMLElement = $this->parseParagraph($paragraph, $key); $container = $this->processContainer($paragraphHTMLElement, $container, $key); } } // Adjust progress step //$this->_progress->incrementStep(); $elementType = java_values($element->getElementType()->toString()); if ($elementType == "CONTENTCONTROL") { $tableOfContents = new TableOfContents($element); $tocContainer = $tableOfContents->processToc($tocNumber); $container->addInnerElement($tocContainer); $tocNumber++; } } // Add container to inner body $this->htmlDocument->setBody($container); }