fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / oox / commentsfragment.cxx
blob17ce2df5c13ddc93e83d7744774553bb721f6000
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "commentsfragment.hxx"
22 #include "richstringcontext.hxx"
24 namespace oox {
25 namespace xls {
27 using namespace ::oox::core;
29 CommentsFragment::CommentsFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
30 WorksheetFragmentBase( rHelper, rFragmentPath )
34 ContextHandlerRef CommentsFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
36 switch( getCurrentElement() )
38 case XML_ROOT_CONTEXT:
39 if( nElement == XLS_TOKEN( comments ) ) return this;
40 break;
41 case XLS_TOKEN( comments ):
42 if( nElement == XLS_TOKEN( authors ) ) return this;
43 if( nElement == XLS_TOKEN( commentList ) ) return this;
44 break;
45 case XLS_TOKEN( authors ):
46 if( nElement == XLS_TOKEN( author ) ) return this; // collect author in onCharacters()
47 break;
48 case XLS_TOKEN( commentList ):
49 if( nElement == XLS_TOKEN( comment ) ) { importComment( rAttribs ); return this; }
50 break;
51 case XLS_TOKEN( commentPr ):
52 if( nElement == XLS_TOKEN( anchor ) )
53 return this;
54 break;
55 case XLS_TOKEN( anchor ):
56 if( nElement == XDR_TOKEN( from ) || nElement == XDR_TOKEN( to ) )
57 return this;
58 break;
59 case XDR_TOKEN( from ):
60 case XDR_TOKEN( to ):
61 return this;
62 case XLS_TOKEN( comment ):
63 if( (nElement == XLS_TOKEN( text )) && mxComment.get() )
64 return new RichStringContext( *this, mxComment->createText() );
65 if( nElement == XLS_TOKEN( commentPr ) ) { mxComment->importCommentPr( rAttribs ); return this; }
66 break;
68 return 0;
71 void CommentsFragment::onCharacters( const OUString& rChars )
73 if( isCurrentElement( XLS_TOKEN( author ) ) )
74 getComments().appendAuthor( rChars );
77 void CommentsFragment::onEndElement()
79 if( isCurrentElement( XLS_TOKEN( comment ) ) )
80 mxComment.reset();
83 ContextHandlerRef CommentsFragment::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
85 switch( getCurrentElement() )
87 case XML_ROOT_CONTEXT:
88 if( nRecId == BIFF12_ID_COMMENTS ) return this;
89 break;
90 case BIFF12_ID_COMMENTS:
91 if( nRecId == BIFF12_ID_COMMENTAUTHORS ) return this;
92 if( nRecId == BIFF12_ID_COMMENTLIST ) return this;
93 break;
94 case BIFF12_ID_COMMENTAUTHORS:
95 if( nRecId == BIFF12_ID_COMMENTAUTHOR ) getComments().appendAuthor( BiffHelper::readString( rStrm ) );
96 break;
97 case BIFF12_ID_COMMENTLIST:
98 if( nRecId == BIFF12_ID_COMMENT ) { importComment( rStrm ); return this; }
99 break;
100 case BIFF12_ID_COMMENT:
101 if( (nRecId == BIFF12_ID_COMMENTTEXT) && mxComment.get() )
102 mxComment->createText()->importString( rStrm, true );
103 break;
105 return 0;
108 void CommentsFragment::onEndRecord()
110 if( isCurrentElement( BIFF12_ID_COMMENT ) )
111 mxComment.reset();
114 const RecordInfo* CommentsFragment::getRecordInfos() const
116 static const RecordInfo spRecInfos[] =
118 { BIFF12_ID_COMMENT, BIFF12_ID_COMMENT + 1 },
119 { BIFF12_ID_COMMENTAUTHORS, BIFF12_ID_COMMENTAUTHORS + 1 },
120 { BIFF12_ID_COMMENTLIST, BIFF12_ID_COMMENTLIST + 1 },
121 { BIFF12_ID_COMMENTS, BIFF12_ID_COMMENTS + 1 },
122 { -1, -1 }
124 return spRecInfos;
127 // private --------------------------------------------------------------------
129 void CommentsFragment::importComment( const AttributeList& rAttribs )
131 mxComment = getComments().createComment();
132 mxComment->importComment( rAttribs );
135 void CommentsFragment::importComment( SequenceInputStream& rStrm )
137 mxComment = getComments().createComment();
138 mxComment->importComment( rStrm );
141 } // namespace xls
142 } // namespace oox
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */