summaryrefslogtreecommitdiff
path: root/oox/source/ppt
diff options
context:
space:
mode:
authorVinaya <vinaya.mandke@synerzip.com>2013-02-08 19:19:38 +0530
committerFridrich Strba <fridrich@documentfoundation.org>2013-03-13 09:27:17 +0000
commit856756ec77ac64d1caee6c1b80c3641d4e487b2d (patch)
tree8fb43999174b35c1418869c8a649416f0c86d091 /oox/source/ppt
parent790a36d299f8470e07fc0af59960fccd637b31a6 (diff)
Changes to enable display of comments annotations in pptx files
Change-Id: Ibf7dc0c61dc46d1568abe47285662810f79410e7 Change-Id: I965798cd3a539ab8deffcdf4a8e2c52c9e8e8fc1 Reviewed-on: https://gerrit.libreoffice.org/2048 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
Diffstat (limited to 'oox/source/ppt')
-rw-r--r--oox/source/ppt/presentationfragmenthandler.cxx46
-rw-r--r--oox/source/ppt/slidefragmenthandler.cxx34
2 files changed, 79 insertions, 1 deletions
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index c2fdf536b0e4..bbf826764cec 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -42,6 +42,9 @@
#include "oox/ppt/layoutfragmenthandler.hxx"
#include "oox/ppt/pptimport.hxx"
+#include <com/sun/star/office/XAnnotation.hpp>
+#include <com/sun/star/office/XAnnotationAccess.hpp> //for comments
+
using namespace ::com::sun::star;
using namespace ::oox::core;
using namespace ::oox::drawingml;
@@ -160,6 +163,7 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, sal_Bool bFirst
// importing the corresponding masterpage/layout
OUString aLayoutFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "slideLayout" ) );
+ OUString aCommentFragmentPath = xSlideFragmentHandler->getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATION_TYPE( "comments" ) );
if ( !aLayoutFragmentPath.isEmpty() )
{
// importing layout
@@ -271,6 +275,47 @@ void PresentationFragmentHandler::importSlide(sal_uInt32 nSlide, sal_Bool bFirst
}
}
}
+
+ if( !aCommentFragmentPath.isEmpty() && readCommentAuthors == 0 )
+ {// Comments are present and commentAuthors.xml has still not been read
+ readCommentAuthors = 1; //set to true
+ rtl::OUString aCommentAuthorsFragmentPath = "ppt/commentAuthors.xml";
+ Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
+ Reference< XDrawPage > xCommentAuthorsPage( xPresentationPage->getNotesPage() );
+ SlidePersistPtr pCommentAuthorsPersistPtr( new SlidePersist( rFilter, sal_False, sal_True, xCommentAuthorsPage,
+ ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
+ FragmentHandlerRef xCommentAuthorsFragmentHandler( new SlideFragmentHandler( getFilter(), aCommentAuthorsFragmentPath, pCommentAuthorsPersistPtr, Slide ) );
+
+ importSlide( xCommentAuthorsFragmentHandler, pCommentAuthorsPersistPtr );
+ AuthorList.setValues(*(pCommentAuthorsPersistPtr->getCommentAuthors()));
+ }
+ if( !aCommentFragmentPath.isEmpty() )
+ { Reference< XPresentationPage > xPresentationPage( xSlide, UNO_QUERY );
+ Reference< XDrawPage > xCommentsPage( xPresentationPage->getNotesPage() );
+ SlidePersistPtr pCommentsPersistPtr( new SlidePersist( rFilter, sal_False, sal_True, xCommentsPage,
+ ShapePtr( new PPTShape( Slide, "com.sun.star.drawing.GroupShape" ) ), mpTextListStyle ) );
+ FragmentHandlerRef xCommentsFragmentHandler( new SlideFragmentHandler( getFilter(), aCommentFragmentPath, pCommentsPersistPtr, Slide ) );
+ pCommentsPersistPtr->getCommentsList()->cmLst.clear();
+ importSlide( xCommentsFragmentHandler, pCommentsPersistPtr );
+ SlideFragmentHandler *comment_handler = dynamic_cast<SlideFragmentHandler*>(xCommentsFragmentHandler.get());
+ pCommentsPersistPtr->getCommentsList()->cmLst.back().setText( comment_handler->getCharVector().back() );//set comment chars for last comment on slide
+
+ pCommentsPersistPtr->getCommentAuthors()->setValues(AuthorList);
+ //insert all comments from commentsList
+ for(int i=0; i<pCommentsPersistPtr->getCommentsList()->getSize(); i++)
+ {
+ uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xSlide, UNO_QUERY_THROW );
+ uno::Reference< office::XAnnotation > xAnnotation( xAnnotationAccess->createAndInsertAnnotation() );
+ int nPosX = pCommentsPersistPtr->getCommentsList()->getCommentAtIndex(i).getIntX();
+ int nPosY = pCommentsPersistPtr->getCommentsList()->getCommentAtIndex(i).getIntY();
+ xAnnotation->setPosition( geometry::RealPoint2D( ::oox::drawingml::convertEmuToHmm( nPosX ) * 15.87 , ::oox::drawingml::convertEmuToHmm( nPosY ) * 15.87 ) );
+ xAnnotation->setAuthor( pCommentsPersistPtr->getCommentsList()->getCommentAtIndex(i).getAuthor(AuthorList) );
+ xAnnotation->setDateTime( pCommentsPersistPtr->getCommentsList()->getCommentAtIndex(i).getDateTime() );
+ uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
+ xText->setString( pCommentsPersistPtr->getCommentsList()->getCommentAtIndex(i).get_text());
+ }
+
+ }
}
}
catch( uno::Exception& )
@@ -320,6 +365,7 @@ void PresentationFragmentHandler::finalizeImport()
try
{
int nPagesImported = 0;
+ readCommentAuthors = 0; // as commentAuthors.xml has not been read still
while (aIter!=aEnd)
{
if ( rxStatusIndicator.is() )
diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx
index 12b0ebb40bd1..5d69d3443cdd 100644
--- a/oox/source/ppt/slidefragmenthandler.cxx
+++ b/oox/source/ppt/slidefragmenthandler.cxx
@@ -39,6 +39,7 @@
#include "oox/ppt/pptimport.hxx"
+using rtl::OUString;
using namespace ::com::sun::star;
using namespace ::oox::core;
using namespace ::oox::drawingml;
@@ -188,11 +189,42 @@ SlideFragmentHandler::~SlideFragmentHandler() throw()
case PPT_TOKEN( custDataLst ): // CT_CustomerDataList
case PPT_TOKEN( tagLst ): // CT_TagList
return this;
+
+ //for Comments
+ case PPT_TOKEN( cmLst ):
+ break;
+ case PPT_TOKEN( cm ):
+
+ if(!mpSlidePersistPtr->getCommentsList()->cmLst.empty())
+ { mpSlidePersistPtr->getCommentsList()->cmLst.back().setText( getCharVector().back() ); // set comment text for earlier comment
+ }
+ mpSlidePersistPtr->getCommentsList()->cmLst.push_back(comment()); // insert a new comment in vector commentsList
+ mpSlidePersistPtr->getCommentsList()->cmLst.back().setAuthorId(rAttribs.getString(XML_authorId, OUString())); //set AuthorId
+ mpSlidePersistPtr->getCommentsList()->cmLst.back().setdt(rAttribs.getString(XML_dt, OUString())); //set dt
+ mpSlidePersistPtr->getCommentsList()->cmLst.back().setidx(rAttribs.getString(XML_idx, OUString())); //set idx
+ break;
+
+ case PPT_TOKEN( pos ):
+ mpSlidePersistPtr->getCommentsList()->cmLst.back().setPoint(rAttribs.getString(XML_x, OUString()),rAttribs.getString(XML_y, OUString())); //set x , set y
+ break;
+ //case PPT_TOKEN( text ):
+
+ case PPT_TOKEN( cmAuthor ):
+ commentAuthor _author;
+ _author.clrIdx = rAttribs.getString(XML_clrIdx, OUString()); //set clrIdx
+ _author.id = rAttribs.getString(XML_id, OUString()); // set id
+ _author.initials = rAttribs.getString(XML_initials, OUString()); // set initials
+ _author.lastIdx = rAttribs.getString(XML_lastIdx, OUString()); // set lastIdx
+ _author.name = rAttribs.getString(XML_name, OUString()); //set name
+ mpSlidePersistPtr->getCommentAuthors()->addAuthor(_author); // insert a new comment Author in cmAuthorList
}
return this;
}
-
+void SlideFragmentHandler::onCharacters( const OUString& rChars)
+{
+ charVector.push_back(rChars);
+}
void SlideFragmentHandler::finalizeImport()
{
try