Skip to content

Commit

Permalink
+ added Words/Document->acceptAllTrackChanges feature
Browse files Browse the repository at this point in the history
+ added Words/Document->rejectAllTrackChanges feature
+ added Words/Document->statistics feature
  • Loading branch information
rvanlaak committed Jan 29, 2014
1 parent d270517 commit 85efd9f
Showing 1 changed file with 145 additions and 5 deletions.
150 changes: 145 additions & 5 deletions src/Saaspose/Words/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getDocumentInfo()
//sign URI
$signedURI = Utils::sign($strURI);

$responseStream = Utils::processCommand($signedURI, "GET", "", "");
$responseStream = Utils::processCommand($signedURI, "GET", "json");

$json = json_decode($responseStream);

Expand Down Expand Up @@ -117,11 +117,10 @@ public function getProperty($propertyName)
//sign URI
$signedURI = Utils::sign($strURI);

$responseStream = Utils::processCommand($signedURI, "GET", "", "");
$responseStream = Utils::processCommand($signedURI, "GET", "json");

$json = json_decode($responseStream);


if($json->Code == 200)
return $json->DocumentProperty;
else
Expand Down Expand Up @@ -190,7 +189,7 @@ public function deleteProperty($propertyName)
//sign URI
$signedURI = Utils::sign($strURI);

$responseStream = Utils::processCommand($signedURI, "DELETE", "", "");
$responseStream = Utils::processCommand($signedURI, "DELETE", "json");

$json = json_decode($responseStream);

Expand All @@ -217,7 +216,7 @@ public function getProperties()
//sign URI
$signedURI = Utils::sign($strURI);

$responseStream = Utils::processCommand($signedURI, "GET", "", "");
$responseStream = Utils::processCommand($signedURI, "GET", "json");

$json = json_decode($responseStream);

Expand Down Expand Up @@ -285,5 +284,146 @@ public function convertLocalFile($inputPath="", $outputPath="", $outputFormat=""
}
}

/**
* Accept all trackChanges of the document, optionally save it as another fileName
*
* Example response:
* POST http://api.aspose.com/v1.1/words/TestRevisions.doc/revisions/acceptAll?filename=TestAcceptAll.doc
*
* <?xml version="1.0" encoding="utf-8"?>
* <WordsResponse xmlns:atom="http://www.w3.org/2005/Atom" >
* <Status>OK</Status>
* <Document>
* <Source rel="self" href="http://api.aspose.com/v1.1/words/TestRevisions.doc"/>
* <Dest rel="result" href="http://api.aspose.com/v1.1/words/TestRejectAll.doc"/>
* </Document>
* </WordsResponse>
*
* @param string $destinationDocumentName
* @throws Exception
* @return array $json
*/
public function acceptAllTrackChanges($destinationDocumentName=null)
{
//build URI to accept all tracking changes in the document
$strUri = Product::$baseProductUri . "/words/" . $this->fileName . "/revisions/acceptAll";

// Put the destination filename in the request
if ($destinationDocumentName) {
$strUri .= '?filename='.$destinationDocumentName;
}

//sign URI
$signedUri = Utils::sign($strUri);

$responseStream = Utils::processCommand($signedUri, "POST", "json");

$json = json_decode($responseStream);

if ($json->Code == 200) {
return $json;
} else {
throw new Exception("Error while accepting all document trackChanges");
}
}

/**
* Reject all trackChanges of the document, optionally save it as another fileName
*
* Example response:
* POST http://api.aspose.com/v1.1/words/TestRevisions.doc/revisions/rejectAll?filename=TestRejectAll.doc
*
* <?xml version="1.0" encoding="utf-8"?>
* <WordsResponse xmlns:atom="http://www.w3.org/2005/Atom" >
* <Status>OK</Status>
* <Document>
* <Source rel="self" href="http://api.aspose.com/v1.1/words/TestRevisions.doc"/>
* <Dest rel="result" href="http://api.aspose.com/v1.1/words/TestRejectAll.doc"/>
* </Document>
* </WordsResponse>
*
* @param string $destinationDocumentName
* @throws Exception
* @return array $json
*/
public function rejectAllTrackChanges($destinationDocumentName=null)
{
//build URI to accept all tracking changes in the document
$strUri = Product::$baseProductUri . "/words/" . $this->fileName . "/revisions/rejectAll";

// Put the destination filename in the request
if ($destinationDocumentName) {
$strUri .= '?filename='.$destinationDocumentName;
}

//sign URI
$signedUri = Utils::sign($strUri);

$responseStream = Utils::processCommand($signedUri, "POST", "json");

$json = json_decode($responseStream);

if ($json->Code == 200) {
return $json;
} else {
throw new Exception("Error while rejecting all document trackChanges");
}
}

/**
* Get pagecount, wordcount, paragraphcount statistics from the Word document
*
* Example response:
* GET http://api.aspose.com/v1.1/words/TestStatDataDocument.doc/statistics
*
* <?xml version="1.0" encoding="utf-8"?>
* <SaaSposeResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
* <Status>OK</Status>
* <StatData>
* <WordCount>100</WordCount>
* <ParagraphCount>40</ParagraphCount>
* <PageCount>3</PageCount>
* <PageStatData>
* <Page number="1">
* <WordCount>25</WordCount>
* <ParagraphCount>10</ParagraphCount>
* </Page>
* <Page number="2">
* <WordCount>45</WordCount>
* <ParagraphCount>15</ParagraphCount>
* </Page>
* <Page number="3">
* <WordCount>30</WordCount>
* <ParagraphCount>15</ParagraphCount>
* </Page>
* </PageStatData>
* </StatData>
* <DocumentLink href="http://api.aspose.com/v1.1/words/TestStatDataDocument.doc" rel="self" />
* </SaaSposeResponse>
*
*
* @param string $destinationDocumentName
* @throws Exception
* @return array $json
*/
public function getStatistics()
{
//build URI to accept all tracking changes in the document
$strUri = Product::$baseProductUri . "/words/" . $this->fileName . "/statistics";

//sign URI
$signedUri = Utils::sign($strUri);

$responseStream = Utils::processCommand($signedUri, "GET", "json");

$json = json_decode($responseStream);

if ($json->Code == 200) {
return $json;
} else {
throw new Exception("Error while retreiving document statistics");
}
}

}

0 comments on commit 85efd9f

Please sign in to comment.