1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_COMMENTSBUFFER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_COMMENTSBUFFER_HXX
22 
23 #include "richstring.hxx"
24 #include "worksheethelper.hxx"
25 #include <com/sun/star/awt/Rectangle.hpp>
26 
27 namespace oox {
28 namespace xls {
29 
30 struct CommentModel
31 {
32     ScRange             maRange;            /// Position of the comment in the worksheet.
33     RichStringRef       mxText;             /// Formatted text of the comment (not used in BIFF8).
34     sal_Int32           mnAuthorId;         /// Identifier of the comment's author (OOXML and BIFF12 only).
35     bool                mbAutoFill;         /// Auto Selection of comment object's fill style
36     bool                mbAutoScale;        /// Auto Scale comment text
37     bool                mbColHidden;        /// Comment cell's Column is Hidden
38     bool                mbLocked;           /// Comment changes Locked
39     bool                mbRowHidden;        /// Comment cell's Row is Hidden
40     sal_Int32           mnTHA;              /// Horizontal Alignment
41     sal_Int32           mnTVA;              /// Vertical Alignment
42     css::awt::Rectangle const maAnchor;           /// Anchor parameters
43 
44     explicit            CommentModel();
45 };
46 
47 class Comment : public WorksheetHelper
48 {
49 public:
50     explicit            Comment( const WorksheetHelper& rHelper );
51 
52     /** Imports a cell comment from the passed attributes of the comment element. */
53     void                importComment( const AttributeList& rAttribs );
54     /** Imports a cell comment Properties from the passed attributes of the comment element. */
55     void                importCommentPr( const AttributeList& rAttribs );
56     /** Imports a cell comment from the passed stream of a COMMENT record. */
57     void                importComment( SequenceInputStream& rStrm );
58 
59     /** Creates and returns a new rich-string object for the comment text. */
60     RichStringRef const & createText();
61 
62     /** Finalizes the formatted string of the comment. */
63     void                finalizeImport();
64 
65 private:
66     CommentModel        maModel;
67 };
68 
69 typedef std::shared_ptr< Comment > CommentRef;
70 
71 class CommentsBuffer : public WorksheetHelper
72 {
73 public:
74     explicit            CommentsBuffer( const WorksheetHelper& rHelper );
75 
76     /** Appends a new author to the list of comment authors. */
77     void                appendAuthor( const OUString& rAuthor );
78     /** Creates and returns a new comment. */
79     CommentRef          createComment();
80 
81     /** Finalizes the formatted string of all comments. */
82     void                finalizeImport();
83 
84 private:
85     typedef RefVector< Comment >                CommentVector;
86 
87     std::vector< OUString > maAuthors;
88     CommentVector       maComments;
89 };
90 
91 } // namespace xls
92 } // namespace oox
93 
94 #endif
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
97