summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@suse.com>2013-03-13 20:54:06 +0100
committerThorsten Behrens <tbehrens@suse.com>2013-03-13 20:58:52 +0100
commit83e1044d939285f90a3e1adbc67d1c4d08cb5c58 (patch)
tree900694e46a8c3c84bb94b56d420db237d240df26 /oox/source
parent8131b3892a6d7b287075a3ccb50f947a63e42e33 (diff)
Cleanup pptx comment import patch a bit.
This cleans up 856756ec77ac64d1caee6c1b80c3641d4e487b2d a bit: * add vim footer for new file * use UpperCamelCase for class names * use const references for parameter / bulk object passing * indent properly * don't mix private/public class members randomly * use customary exception object, actually handle the error * stick comment classes into oox namespace * use 'ma' class member prefixes where applicable Change-Id: I98021415331e62a8ee583ecfd27829f7dbfbc498
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/ppt/presentationfragmenthandler.cxx106
-rw-r--r--oox/source/ppt/slidefragmenthandler.cxx41
2 files changed, 90 insertions, 57 deletions
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index bbf826764cec..d38d815a8514 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -43,7 +43,7 @@
#include "oox/ppt/pptimport.hxx"
#include <com/sun/star/office/XAnnotation.hpp>
-#include <com/sun/star/office/XAnnotationAccess.hpp> //for comments
+#include <com/sun/star/office/XAnnotationAccess.hpp>
using namespace ::com::sun::star;
using namespace ::oox::core;
@@ -59,6 +59,7 @@ namespace oox { namespace ppt {
PresentationFragmentHandler::PresentationFragmentHandler( XmlFilterBase& rFilter, const OUString& rFragmentPath ) throw()
: FragmentHandler2( rFilter, rFragmentPath )
, mpTextListStyle( new TextListStyle )
+, mbCommentAuthorsRead(false)
{
TextParagraphPropertiesVector& rParagraphDefaulsVector( mpTextListStyle->getListStyle() );
TextParagraphPropertiesVector::iterator aParagraphDefaultIter( rParagraphDefaulsVector.begin() );
@@ -276,46 +277,76 @@ 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++)
- {
+ if( !mbCommentAuthorsRead && !aCommentFragmentPath.isEmpty() )
+ {
+ // Comments are present and commentAuthors.xml has still not been read
+ mbCommentAuthorsRead = 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 );
+ maAuthorList.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 );
+
+ //set comment chars for last comment on slide
+ SlideFragmentHandler* comment_handler =
+ dynamic_cast<SlideFragmentHandler*>(xCommentsFragmentHandler.get());
+ pCommentsPersistPtr->getCommentsList().cmLst.back().setText(
+ comment_handler->getCharVector().back() );
+ pCommentsPersistPtr->getCommentAuthors().setValues(maAuthorList);
+
+ //insert all comments from commentsList
+ for(int i=0; i<pCommentsPersistPtr->getCommentsList().getSize(); i++)
+ {
+ try {
+ Comment aComment = pCommentsPersistPtr->getCommentsList().getCommentAtIndex(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() );
+ int nPosX = aComment.getIntX();
+ int nPosY = aComment.getIntY();
+ xAnnotation->setPosition(
+ geometry::RealPoint2D(
+ ::oox::drawingml::convertEmuToHmm( nPosX ) * 15.87,
+ ::oox::drawingml::convertEmuToHmm( nPosY ) * 15.87 ) );
+ xAnnotation->setAuthor( aComment.getAuthor(maAuthorList) );
+ xAnnotation->setDateTime( aComment.getDateTime() );
uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
- xText->setString( pCommentsPersistPtr->getCommentsList()->getCommentAtIndex(i).get_text());
- }
-
+ xText->setString( aComment.get_text());
+ } catch( css::lang::IllegalArgumentException& ) {}
}
+ }
}
}
catch( uno::Exception& )
@@ -365,7 +396,6 @@ 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 5d69d3443cdd..6f0cf755bf76 100644
--- a/oox/source/ppt/slidefragmenthandler.cxx
+++ b/oox/source/ppt/slidefragmenthandler.cxx
@@ -39,7 +39,6 @@
#include "oox/ppt/pptimport.hxx"
-using rtl::OUString;
using namespace ::com::sun::star;
using namespace ::oox::core;
using namespace ::oox::drawingml;
@@ -192,38 +191,42 @@ SlideFragmentHandler::~SlideFragmentHandler() throw()
//for Comments
case PPT_TOKEN( cmLst ):
- break;
+ break;
case PPT_TOKEN( cm ):
-
- if(!mpSlidePersistPtr->getCommentsList()->cmLst.empty())
- { mpSlidePersistPtr->getCommentsList()->cmLst.back().setText( getCharVector().back() ); // set comment text for earlier comment
+ if(!mpSlidePersistPtr->getCommentsList().cmLst.empty())
+ {
+ // set comment text for earlier comment
+ mpSlidePersistPtr->getCommentsList().cmLst.back().setText( getCharVector().back() );
}
- 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
+ // insert a new comment in vector commentsList
+ mpSlidePersistPtr->getCommentsList().cmLst.push_back(Comment());
+ mpSlidePersistPtr->getCommentsList().cmLst.back().setAuthorId(rAttribs.getString(XML_authorId, OUString()));
+ mpSlidePersistPtr->getCommentsList().cmLst.back().setdt(rAttribs.getString(XML_dt, OUString()));
+ mpSlidePersistPtr->getCommentsList().cmLst.back().setidx(rAttribs.getString(XML_idx, OUString()));
break;
case PPT_TOKEN( pos ):
- mpSlidePersistPtr->getCommentsList()->cmLst.back().setPoint(rAttribs.getString(XML_x, OUString()),rAttribs.getString(XML_y, OUString())); //set x , set y
+ mpSlidePersistPtr->getCommentsList().cmLst.back().setPoint(
+ rAttribs.getString(XML_x, OUString()),
+ rAttribs.getString(XML_y, OUString()));
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
+ CommentAuthor _author;
+ _author.clrIdx = rAttribs.getString(XML_clrIdx, OUString());
+ _author.id = rAttribs.getString(XML_id, OUString());
+ _author.initials = rAttribs.getString(XML_initials, OUString());
+ _author.lastIdx = rAttribs.getString(XML_lastIdx, OUString());
+ _author.name = rAttribs.getString(XML_name, OUString());
+ mpSlidePersistPtr->getCommentAuthors().addAuthor(_author);
+ break;
}
return this;
}
void SlideFragmentHandler::onCharacters( const OUString& rChars)
{
- charVector.push_back(rChars);
+ maCharVector.push_back(rChars);
}
void SlideFragmentHandler::finalizeImport()
{