예제 #1
0
 /**
  * This method is called by the Aspose.Words find and replace engine for each match.
  * This method highlights the match string, even if it spans multiple runs.
  */
 public static function replacing($e)
 {
     // This is a Run node that contains either the beginning or the complete match.
     $currentNode = $e->getMatchNode();
     // The first (and may be the only) run can contain text before the match,
     // in this case it is necessary to split the run.
     if (java_values($e->getMatchOffset()) > 0) {
         $currentNode = ReplaceEvaluatorFindAndHighlight::splitRun($currentNode, $e->getMatchOffset());
     }
     // This array is used to store all nodes of the match for further highlighting.
     $runs = new Java("java.util.ArrayList");
     // Find all runs that contain parts of the match string.
     $remainingLength = $e->getMatch()->group()->length();
     while (java_values($remainingLength) > 0 && java_values($currentNode) != null && java_values($currentNode->getText()->length()) <= java_values($remainingLength)) {
         $runs->add($currentNode);
         $remainingLength = java_values($remainingLength) - java_values($currentNode->getText()->length());
         // Select the next Run node.
         // Have to loop because there could be other nodes such as BookmarkStart etc.
         do {
             $currentNode = $currentNode->getNextSibling();
             $nodeType = Java("com.aspose.words.NodeType");
         } while (java_values($currentNode) != null && java_values($currentNode->getNodeType()) != java_values($nodeType->RUN));
     }
     // Split the last run that contains the match if there is any text left.
     if (java_values($currentNode) != null && java_values($remainingLength) > 0) {
         ReplaceEvaluatorFindAndHighlight::splitRun($currentNode, $remainingLength);
         $runs->add($currentNode);
     }
     // Now highlight all runs in the sequence.
     $runs = $runs->toArray();
     $color = Java("java.awt.Color");
     foreach ($runs as $run) {
         $run->getFont()->setHighlightColor('yellow');
     }
     // Signal to the replace engine to do nothing because we have already done all what we wanted.
     $replaceAction = Java("com.aspose.words.ReplaceAction");
     return $replaceAction->SKIP;
 }
예제 #2
0
 public static function extractComments()
 {
     $args = func_get_args();
     $doc = $args[0];
     $collectedComments = new Java("java.util.ArrayList");
     // Collect all comments in the document
     $nodeType = Java("com.aspose.words.NodeType");
     $comments = $doc->getChildNodes($nodeType->COMMENT, true)->toArray();
     //echo "<PRE>"; echo java_inspect($comments); exit;
     // Look through all comments and gather information about them.
     $saveFormat = Java("com.aspose.words.SaveFormat");
     foreach ($comments as $comment) {
         if (isset($args[1]) && !empty($args[1])) {
             $authorName = $args[1];
             if (java_values($comment->getAuthor()->equals(authorName))) {
                 $collectedComments->add($comment->getAuthor() . " " . $comment->getDateTime() . " " . $comment->toString($saveFormat->TEXT));
             }
         } else {
             $collectedComments->add($comment->getAuthor() . " " . $comment->getDateTime() . " " . $comment->toString($saveFormat->TEXT));
         }
     }
     return $collectedComments;
 }
 public static function runsByStyleName($doc, $styleName)
 {
     // Create an array to collect runs of the specified style.
     $runsWithStyle = new Java("java.util.ArrayList");
     // Get all runs from the document.
     $nodeType = Java("com.aspose.words.NodeType");
     $runs = $doc->getChildNodes($nodeType->RUN, true);
     // Look through all runs to find those with the specified style.
     $runs = $runs->toArray();
     foreach ($runs as $run) {
         if (java_values($run->getFont()->getStyle()->getName()->equals($styleName))) {
             $runsWithStyle->add($run);
         }
     }
     return $runsWithStyle;
 }
예제 #4
0
파일: jawt.php 프로젝트: OTiZ/osx
<?

  // This example is only intented to be run as a CGI.

  $frame = new Java("java.awt.Frame", "Zend");
  $button = new Java("java.awt.Button", "Hello Java world!");
  $frame->add("North", $button);
  $frame->validate();
  $frame->pack();
  $frame->visible = True;

  $thread = new Java("java.lang.Thread");
  $thread->sleep(10000);

  $frame->dispose();

  // Odd behavior noted with Sun JVMs:
  //
  //   1) $thread->destroy() will fail with a NoSuchMethodError exception.
  //   2) The call to (*jvm)->DestroyJVM(jvm) made when PHP terminates
  //      will hang, unless _BOTH_ the calls to pack and setVisible above
  //      are removed.
  //
  //  Even more odd: both effects are seen with a 100% Java implementation
  //  of the above!

?>
예제 #5
0
 /**
  * Update the URI of a given entity
  * 
  * @param mixed $oldUri The current URI of the entity to update
  * @param mixed $newUri The new URI of the entity
  *  
  * @author Frederick Giasson, Structured Dynamics LLC.
  */
 public function updateEntityUri($oldUri, $newUri)
 {
     $ontologiesSet = new Java("java.util.HashSet");
     $ontologiesSet->add($this->ontology);
     $entityRenamer = new Java("org.semanticweb.owlapi.util.OWLEntityRenamer", $this->manager, $ontologiesSet);
     $changes = $entityRenamer->changeIRI(java("org.semanticweb.owlapi.model.IRI")->create($oldUri), java("org.semanticweb.owlapi.model.IRI")->create($newUri));
     $this->manager->applyChanges($changes);
 }
예제 #6
0
        }
        $this->p->cEnd();
        $ar = sscanf($this->p->res(), "%d");
        $this->java = $ar[0];
    }
    function __call($meth, $args)
    {
        $this->p->iBeg($this->java, $meth);
        foreach ($args as $arg) {
            $this->p->val($arg);
        }
        $this->p->iEnd();
        $proxy = new Java();
        $ar = sscanf($this->p->res(), "%d");
        $proxy->java = $ar[0];
        $proxy->p = $this->p;
        return $proxy;
    }
    function toString()
    {
        $this->p->iBeg("", "castToString");
        $this->p->val($this);
        $this->p->iEnd();
        return base64_decode($this->p->res());
    }
}
// Test
$i1 = new Java("java.math.BigInteger", "1");
$i2 = new Java("java.math.BigInteger", "2");
$i3 = $i1->add($i2);
echo $i3->toString() . "\n";
예제 #7
0
 public static function paragraphsByStyleName($doc, $styleName)
 {
     // Create an array to collect paragraphs of the specified style.
     $paragraphsWithStyle = new Java("java.util.ArrayList");
     // Get all paragraphs from the document.
     $nodeType = Java("com.aspose.words.NodeType");
     $paragraphs = $doc->getChildNodes($nodeType->PARAGRAPH, true);
     $paragraphs_count = $paragraphs->getCount();
     $paragraphs_count = java_values($paragraphs_count);
     // Look through all paragraphs to find those with the specified style.
     $i = 0;
     while ($i < $paragraphs_count) {
         $paragraphs = $doc->getChildNodes($nodeType->PARAGRAPH, true);
         $paragraph = $paragraphs->get($i);
         if (java_values($paragraph->getParagraphFormat()->getStyle()->getName()->equals($styleName))) {
             $paragraphsWithStyle->add($paragraph);
         }
         $i++;
     }
     return $paragraphsWithStyle;
 }