xref: /aoo4110/main/oox/inc/oox/xls/commentsbuffer.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef OOX_XLS_COMMENTSBUFFER_HXX
25 #define OOX_XLS_COMMENTSBUFFER_HXX
26 
27 #include "oox/xls/richstring.hxx"
28 #include "oox/xls/worksheethelper.hxx"
29 
30 namespace oox {
31 namespace xls {
32 
33 // ============================================================================
34 
35 struct CommentModel
36 {
37     ::com::sun::star::table::CellRangeAddress
38                         maRange;            /// Position of the comment in the worksheet.
39     RichStringRef       mxText;             /// Formatted text of the comment (not used in BIFF8).
40     ::rtl::OUString     maAuthor;           /// Comment author (BIFF8 only).
41     sal_Int32           mnAuthorId;         /// Identifier of the comment's author (OOXML and BIFF12 only).
42     sal_uInt16          mnObjId;            /// Drawing object identifier (BIFF8 only).
43     bool                mbVisible;          /// True = comment is always shown (BIFF2-BIFF8 only).
44 
45     explicit            CommentModel();
46 };
47 
48 // ----------------------------------------------------------------------------
49 
50 class Comment : public WorksheetHelper
51 {
52 public:
53     explicit            Comment( const WorksheetHelper& rHelper );
54 
55     /** Imports a cell comment from the passed attributes of the comment element. */
56     void                importComment( const AttributeList& rAttribs );
57     /** Imports a cell comment from the passed stream of a COMMENT record. */
58     void                importComment( SequenceInputStream& rStrm );
59     /** Imports a cell comment from the passed stream of a NOTE record. */
60     void                importNote( BiffInputStream& rStrm );
61 
62     /** Creates and returns a new rich-string object for the comment text. */
63     RichStringRef       createText();
64 
65     /** Finalizes the formatted string of the comment. */
66     void                finalizeImport();
67 
68 private:
69     /** Reads a BIFF2-BIFF5 NOTE record. */
70     void                importNoteBiff2( BiffInputStream& rStrm );
71     /** Reads a BIFF8 NOTE record. */
72     void                importNoteBiff8( BiffInputStream& rStrm );
73     /** Reads a NOTESOUND record. */
74     void                importNoteSound( BiffInputStream& rStrm );
75 
76 private:
77     CommentModel        maModel;
78 };
79 
80 typedef ::boost::shared_ptr< Comment > CommentRef;
81 
82 // ============================================================================
83 
84 class CommentsBuffer : public WorksheetHelper
85 {
86 public:
87     explicit            CommentsBuffer( const WorksheetHelper& rHelper );
88 
89     /** Appends a new author to the list of comment authors. */
90     void                appendAuthor( const ::rtl::OUString& rAuthor );
91     /** Creates and returns a new comment. */
92     CommentRef          createComment();
93 
94     /** Finalizes the formatted string of all comments. */
95     void                finalizeImport();
96 
97 private:
98     typedef ::std::vector< ::rtl::OUString >    OUStringVector;
99     typedef RefVector< Comment >                CommentVector;
100 
101     OUStringVector      maAuthors;
102     CommentVector       maComments;
103 };
104 
105 // ============================================================================
106 
107 } // namespace xls
108 } // namespace oox
109 
110 #endif
111