1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef OOX_XLS_COMMENTSBUFFER_HXX 29 #define OOX_XLS_COMMENTSBUFFER_HXX 30 31 #include "oox/xls/richstring.hxx" 32 #include "oox/xls/worksheethelper.hxx" 33 34 namespace oox { 35 namespace xls { 36 37 // ============================================================================ 38 39 struct CommentModel 40 { 41 ::com::sun::star::table::CellRangeAddress 42 maRange; /// Position of the comment in the worksheet. 43 RichStringRef mxText; /// Formatted text of the comment (not used in BIFF8). 44 ::rtl::OUString maAuthor; /// Comment author (BIFF8 only). 45 sal_Int32 mnAuthorId; /// Identifier of the comment's author (OOXML and BIFF12 only). 46 sal_uInt16 mnObjId; /// Drawing object identifier (BIFF8 only). 47 bool mbVisible; /// True = comment is always shown (BIFF2-BIFF8 only). 48 49 explicit CommentModel(); 50 }; 51 52 // ---------------------------------------------------------------------------- 53 54 class Comment : public WorksheetHelper 55 { 56 public: 57 explicit Comment( const WorksheetHelper& rHelper ); 58 59 /** Imports a cell comment from the passed attributes of the comment element. */ 60 void importComment( const AttributeList& rAttribs ); 61 /** Imports a cell comment from the passed stream of a COMMENT record. */ 62 void importComment( SequenceInputStream& rStrm ); 63 /** Imports a cell comment from the passed stream of a NOTE record. */ 64 void importNote( BiffInputStream& rStrm ); 65 66 /** Creates and returns a new rich-string object for the comment text. */ 67 RichStringRef createText(); 68 69 /** Finalizes the formatted string of the comment. */ 70 void finalizeImport(); 71 72 private: 73 /** Reads a BIFF2-BIFF5 NOTE record. */ 74 void importNoteBiff2( BiffInputStream& rStrm ); 75 /** Reads a BIFF8 NOTE record. */ 76 void importNoteBiff8( BiffInputStream& rStrm ); 77 /** Reads a NOTESOUND record. */ 78 void importNoteSound( BiffInputStream& rStrm ); 79 80 private: 81 CommentModel maModel; 82 }; 83 84 typedef ::boost::shared_ptr< Comment > CommentRef; 85 86 // ============================================================================ 87 88 class CommentsBuffer : public WorksheetHelper 89 { 90 public: 91 explicit CommentsBuffer( const WorksheetHelper& rHelper ); 92 93 /** Appends a new author to the list of comment authors. */ 94 void appendAuthor( const ::rtl::OUString& rAuthor ); 95 /** Creates and returns a new comment. */ 96 CommentRef createComment(); 97 98 /** Finalizes the formatted string of all comments. */ 99 void finalizeImport(); 100 101 private: 102 typedef ::std::vector< ::rtl::OUString > OUStringVector; 103 typedef RefVector< Comment > CommentVector; 104 105 OUStringVector maAuthors; 106 CommentVector maComments; 107 }; 108 109 // ============================================================================ 110 111 } // namespace xls 112 } // namespace oox 113 114 #endif 115