LibreOffice Module sc (master) 1
postit.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <rtl/ustring.hxx>
23#include <svl/itemset.hxx>
24#include <rtl/ref.hxx>
25#include "address.hxx"
26#include "scdllapi.h"
27
28#include <memory>
29#include <string_view>
30
31class EditTextObject;
33class SdrCaptionObj;
34class SdrPage;
35
36class ScDocument;
37namespace tools { class Rectangle; }
39
42{
43 typedef std::shared_ptr< ScCaptionInitData > ScCaptionInitDataRef;
44
45 OUString maDate;
46 OUString maAuthor;
49 bool mbShown;
50
51 explicit ScNoteData( bool bShown = false );
52};
53
58{
59public:
60 static sal_uInt32 mnLastPostItId;
61
64 explicit ScPostIt( ScDocument& rDoc, const ScAddress& rPos, sal_uInt32 nPostItId = 0 );
65
67 explicit ScPostIt( ScDocument& rDoc, const ScAddress& rPos, const ScPostIt& rNote, sal_uInt32 nPostItId = 0 );
68
79 explicit ScPostIt(
80 ScDocument& rDoc, const ScAddress& rPos,
81 ScNoteData aNoteData, bool bAlwaysCreateCaption, sal_uInt32 nPostItId = 0 );
82
84 ~ScPostIt();
85
94 std::unique_ptr<ScPostIt> Clone(
95 const ScAddress& rOwnPos,
96 ScDocument& rDestDoc, const ScAddress& rDestPos,
97 bool bCloneCaption ) const;
98
100 sal_uInt32 GetId() const { return mnPostItId; }
101
103 const ScNoteData& GetNoteData() const { return maNoteData;}
104
106 const OUString& GetDate() const { return maNoteData.maDate;}
108 void SetDate( const OUString& rDate );
109
111 const OUString& GetAuthor() const { return maNoteData.maAuthor;}
113 void SetAuthor( const OUString& rAuthor );
114
116 void AutoStamp();
117
119 const OutlinerParaObject* GetOutlinerObject() const;
121 const EditTextObject* GetEditTextObject() const;
122
124 OUString GetText() const;
126 bool HasMultiLineText() const;
128 void SetText( const ScAddress& rPos, const OUString& rText );
129
134 SdrCaptionObj* GetCaption() const { return maNoteData.mxCaption.get();}
139 SdrCaptionObj* GetOrCreateCaption( const ScAddress& rPos ) const;
140
147 void ForgetCaption( bool bPreserveData = false );
148
150 void ShowCaption( const ScAddress& rPos, bool bShow );
152 bool IsCaptionShown() const { return maNoteData.mbShown;}
153
155 void ShowCaptionTemp( const ScAddress& rPos, bool bShow = true );
156
158 void UpdateCaptionPos( const ScAddress& rPos );
159
160private:
161 ScPostIt( const ScPostIt& ) = delete;
162 ScPostIt& operator=( const ScPostIt& ) = delete;
163
165 void CreateCaptionFromInitData( const ScAddress& rPos ) const;
167 void CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCaption = nullptr );
169 void RemoveCaption();
170
171private:
174 sal_uInt32 mnPostItId;
175};
176
178{
179public:
180
182 static rtl::Reference<SdrCaptionObj> CreateTempCaption( ScDocument& rDoc, const ScAddress& rPos,
183 SdrPage& rDrawPage, std::u16string_view rUserText,
184 const tools::Rectangle& rVisRect, bool bTailFront );
185
202 static ScPostIt* CreateNoteFromCaption(
203 ScDocument& rDoc, const ScAddress& rPos,
204 SdrCaptionObj* pCaption );
205
230 static ScPostIt* CreateNoteFromObjectData(
231 ScDocument& rDoc, const ScAddress& rPos,
232 SfxItemSet&& oItemSet,
233 const OutlinerParaObject& rOutlinerObj,
234 const tools::Rectangle& rCaptionRect, bool bShown );
235
252 static ScPostIt* CreateNoteFromString(
253 ScDocument& rDoc, const ScAddress& rPos,
254 const OUString& rNoteText, bool bShown,
255 bool bAlwaysCreateCaption, sal_uInt32 nPostItId = 0 );
256
257};
258
259namespace sc {
260
262{
265
266 NoteEntry( const ScAddress& rPos, const ScPostIt* pNote );
267};
268
269}
270
271/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Additional class containing cell annotation data.
Definition: postit.hxx:58
const ScNoteData & GetNoteData() const
Returns the data struct containing all note settings.
Definition: postit.hxx:103
sal_uInt32 GetId() const
Returns the note id.
Definition: postit.hxx:100
ScNoteData maNoteData
Parent document containing the note.
Definition: postit.hxx:173
const OUString & GetDate() const
Returns the creation date of this note.
Definition: postit.hxx:106
const OUString & GetAuthor() const
Returns the author date of this note.
Definition: postit.hxx:111
ScPostIt(const ScPostIt &)=delete
static sal_uInt32 mnLastPostItId
Definition: postit.hxx:60
sal_uInt32 mnPostItId
Note data with pointer to caption object.
Definition: postit.hxx:174
ScDocument & mrDoc
Definition: postit.hxx:172
ScPostIt & operator=(const ScPostIt &)=delete
bool IsCaptionShown() const
Returns true, if the caption object is visible.
Definition: postit.hxx:152
SdrCaptionObj * GetCaption() const
Returns an existing note caption object.
Definition: postit.hxx:134
virtual void SetText(const OUString &rStr) override
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
Internal data for a cell annotation.
Definition: postit.hxx:42
rtl::Reference< SdrCaptionObj > mxCaption
Initial data for invisible notes without SdrObject.
Definition: postit.hxx:48
ScCaptionInitDataRef mxInitData
Author of the note.
Definition: postit.hxx:47
OUString maDate
Definition: postit.hxx:45
OUString maAuthor
Creation date of the note.
Definition: postit.hxx:46
bool mbShown
Drawing object representing the cell note.
Definition: postit.hxx:49
ScNoteData(bool bShown=false)
True = note is visible.
Definition: postit.cxx:474
std::shared_ptr< ScCaptionInitData > ScCaptionInitDataRef
Definition: postit.hxx:43
ScAddress maPos
Definition: postit.hxx:263
const ScPostIt * mpNote
Definition: postit.hxx:264
NoteEntry(const ScAddress &rPos, const ScPostIt *pNote)
Definition: postit.cxx:950