LibreOffice Module sc (master) 1
postit.cxx
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#include <memory>
21#include <postit.hxx>
22
23#include <rtl/ustrbuf.hxx>
24#include <sal/log.hxx>
26#include <svx/svdpage.hxx>
27#include <svx/svdocapt.hxx>
28#include <editeng/outlobj.hxx>
29#include <editeng/editobj.hxx>
31#include <osl/diagnose.h>
32#include <comphelper/lok.hxx>
33
34#include <scitems.hxx>
35#include <svx/xfillit0.hxx>
36#include <svx/xlnstit.hxx>
37#include <svx/xlnstwit.hxx>
38#include <svx/xlnstcit.hxx>
39#include <svx/sxcecitm.hxx>
40#include <svx/xflclit.hxx>
41#include <svx/sdshitm.hxx>
42#include <svx/sdsxyitm.hxx>
43#include <svx/sdtditm.hxx>
44#include <svx/sdtagitm.hxx>
45#include <svx/sdtmfitm.hxx>
46#include <tools/gen.hxx>
47
48#include <document.hxx>
49#include <docpool.hxx>
50#include <patattr.hxx>
51#include <drwlayer.hxx>
52#include <userdat.hxx>
53#include <detfunc.hxx>
54#include <editutil.hxx>
55#include <utility>
56
57using namespace com::sun::star;
58
59namespace {
60
61const tools::Long SC_NOTECAPTION_WIDTH = 2900;
62const tools::Long SC_NOTECAPTION_MAXWIDTH_TEMP = 12000;
63const tools::Long SC_NOTECAPTION_HEIGHT = 1800;
64const tools::Long SC_NOTECAPTION_CELLDIST = 600;
65const tools::Long SC_NOTECAPTION_OFFSET_Y = -1500;
66const tools::Long SC_NOTECAPTION_OFFSET_X = 1500;
67const tools::Long SC_NOTECAPTION_BORDERDIST_TEMP = 100;
68
70class ScCaptionUtil
71{
72public:
74 static void SetCaptionLayer( SdrCaptionObj& rCaption, bool bShown );
76 static void SetBasicCaptionSettings( SdrCaptionObj& rCaption, bool bShown );
78 static void SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress& rPos );
80 static void SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc, const SfxItemSet* pExtraItemSet );
81};
82
83void ScCaptionUtil::SetCaptionLayer( SdrCaptionObj& rCaption, bool bShown )
84{
85 SdrLayerID nLayer = bShown ? SC_LAYER_INTERN : SC_LAYER_HIDDEN;
86 if( nLayer != rCaption.GetLayer() )
87 rCaption.SetLayer( nLayer );
88}
89
90void ScCaptionUtil::SetBasicCaptionSettings( SdrCaptionObj& rCaption, bool bShown )
91{
92 SetCaptionLayer( rCaption, bShown );
93 rCaption.SetFixedTail();
94 rCaption.SetSpecialTextBoxShadow();
95}
96
97void ScCaptionUtil::SetCaptionUserData( SdrCaptionObj& rCaption, const ScAddress& rPos )
98{
99 // pass true to ScDrawLayer::GetObjData() to create the object data entry
100 ScDrawObjData* pObjData = ScDrawLayer::GetObjData( &rCaption, true );
101 OSL_ENSURE( pObjData, "ScCaptionUtil::SetCaptionUserData - missing drawing object user data" );
102 pObjData->maStart = rPos;
104}
105
106void ScCaptionUtil::SetDefaultItems( SdrCaptionObj& rCaption, ScDocument& rDoc, const SfxItemSet* pExtraItemSet )
107{
108 SfxItemSet aItemSet = rCaption.GetMergedItemSet();
109
110 // caption tail arrow
111 ::basegfx::B2DPolygon aTriangle;
112 aTriangle.append( ::basegfx::B2DPoint( 10.0, 0.0 ) );
113 aTriangle.append( ::basegfx::B2DPoint( 0.0, 30.0 ) );
114 aTriangle.append( ::basegfx::B2DPoint( 20.0, 30.0 ) );
115 aTriangle.setClosed( true );
116 /* Line ends are now created with an empty name. The
117 checkForUniqueItem() method then finds a unique name for the item's
118 value. */
119 aItemSet.Put( XLineStartItem( OUString(), ::basegfx::B2DPolyPolygon( aTriangle ) ) );
120 aItemSet.Put( XLineStartWidthItem( 200 ) );
121 aItemSet.Put( XLineStartCenterItem( false ) );
122 aItemSet.Put( XFillStyleItem( drawing::FillStyle_SOLID ) );
123 aItemSet.Put( XFillColorItem( OUString(), ScDetectiveFunc::GetCommentColor() ) );
124 aItemSet.Put( SdrCaptionEscDirItem( SdrCaptionEscDir::BestFit ) );
125
126 // shadow
127 /* SdrShadowItem has sal_False, instead the shadow is set for the
128 rectangle only with SetSpecialTextBoxShadow() when the object is
129 created (item must be set to adjust objects from older files). */
130 aItemSet.Put( makeSdrShadowItem( false ) );
131 aItemSet.Put( makeSdrShadowXDistItem( 100 ) );
132 aItemSet.Put( makeSdrShadowYDistItem( 100 ) );
133
134 // text attributes
135 aItemSet.Put( makeSdrTextLeftDistItem( 100 ) );
136 aItemSet.Put( makeSdrTextRightDistItem( 100 ) );
137 aItemSet.Put( makeSdrTextUpperDistItem( 100 ) );
138 aItemSet.Put( makeSdrTextLowerDistItem( 100 ) );
139 aItemSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
140 aItemSet.Put( makeSdrTextAutoGrowHeightItem( true ) );
141 // use the default cell style to be able to modify the caption font
142 const ScPatternAttr& rDefPattern = rDoc.GetPool()->GetDefaultItem( ATTR_PATTERN );
143 rDefPattern.FillEditItemSet( &aItemSet );
144
145 if (pExtraItemSet)
146 {
147 /* Updates caption item set according to the passed item set while removing shadow items. */
148
149 aItemSet.Put(*pExtraItemSet);
150 // reset shadow items
151 aItemSet.Put( makeSdrShadowItem( false ) );
152 aItemSet.Put( makeSdrShadowXDistItem( 100 ) );
153 aItemSet.Put( makeSdrShadowYDistItem( 100 ) );
154 }
155
156 rCaption.SetMergedItemSet( aItemSet );
157
158 if (pExtraItemSet)
159 rCaption.SetSpecialTextBoxShadow();
160}
161
164class ScCaptionCreator
165{
166public:
168 explicit ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, bool bTailFront );
170 explicit ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, const rtl::Reference<SdrCaptionObj>& xCaption );
171
173 SdrPage* GetDrawPage();
175 rtl::Reference<SdrCaptionObj> & GetCaption() { return mxCaption; }
176
178 void FitCaptionToRect( const tools::Rectangle* pVisRect = nullptr );
180 void AutoPlaceCaption( const tools::Rectangle* pVisRect = nullptr );
182 void UpdateCaptionPos();
183
184protected:
186 explicit ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos );
187
189 Point CalcTailPos( bool bTailFront );
191 void CreateCaption( bool bShown, bool bTailFront );
192
193private:
195 void Initialize();
197 const tools::Rectangle& GetVisRect( const tools::Rectangle* pVisRect ) const { return pVisRect ? *pVisRect : maPageRect; }
198
199private:
200 ScDocument& mrDoc;
201 ScAddress maPos;
203 tools::Rectangle maPageRect;
204 tools::Rectangle maCellRect;
205 bool mbNegPage;
206};
207
208ScCaptionCreator::ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, bool bTailFront ) :
209 mrDoc( rDoc ),
210 maPos( rPos )
211{
212 Initialize();
213 CreateCaption( true/*bShown*/, bTailFront );
214}
215
216ScCaptionCreator::ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, const rtl::Reference<SdrCaptionObj>& xCaption ) :
217 mrDoc( rDoc ),
218 maPos( rPos ),
219 mxCaption( xCaption )
220{
221 Initialize();
222}
223
224ScCaptionCreator::ScCaptionCreator( ScDocument& rDoc, const ScAddress& rPos ) :
225 mrDoc( rDoc ),
226 maPos( rPos )
227{
228 Initialize();
229}
230
231SdrPage* ScCaptionCreator::GetDrawPage()
232{
233 ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer();
234 return pDrawLayer ? pDrawLayer->GetPage( static_cast< sal_uInt16 >( maPos.Tab() ) ) : nullptr;
235}
236
237void ScCaptionCreator::FitCaptionToRect( const tools::Rectangle* pVisRect )
238{
239 const tools::Rectangle& rVisRect = GetVisRect( pVisRect );
240
241 // tail position
242 Point aTailPos = mxCaption->GetTailPos();
243 aTailPos.setX( ::std::clamp( aTailPos.X(), rVisRect.Left(), rVisRect.Right() ) );
244 aTailPos.setY( ::std::clamp( aTailPos.Y(), rVisRect.Top(), rVisRect.Bottom() ) );
245 mxCaption->SetTailPos( aTailPos );
246
247 // caption rectangle
248 tools::Rectangle aCaptRect = mxCaption->GetLogicRect();
249 Point aCaptPos = aCaptRect.TopLeft();
250 // move textbox inside right border of visible area
251 aCaptPos.setX( ::std::min< tools::Long >( aCaptPos.X(), rVisRect.Right() - aCaptRect.GetWidth() ) );
252 // move textbox inside left border of visible area (this may move it outside on right side again)
253 aCaptPos.setX( ::std::max< tools::Long >( aCaptPos.X(), rVisRect.Left() ) );
254 // move textbox inside bottom border of visible area
255 aCaptPos.setY( ::std::min< tools::Long >( aCaptPos.Y(), rVisRect.Bottom() - aCaptRect.GetHeight() ) );
256 // move textbox inside top border of visible area (this may move it outside on bottom side again)
257 aCaptPos.setY( ::std::max< tools::Long >( aCaptPos.Y(), rVisRect.Top() ) );
258 // update caption
259 aCaptRect.SetPos( aCaptPos );
260 mxCaption->SetLogicRect( aCaptRect );
261}
262
263void ScCaptionCreator::AutoPlaceCaption( const tools::Rectangle* pVisRect )
264{
265 const tools::Rectangle& rVisRect = GetVisRect( pVisRect );
266
267 // caption rectangle
268 tools::Rectangle aCaptRect = mxCaption->GetLogicRect();
269 tools::Long nWidth = aCaptRect.GetWidth();
270 tools::Long nHeight = aCaptRect.GetHeight();
271
272 // n***Space contains available space between border of visible area and cell
273 tools::Long nLeftSpace = maCellRect.Left() - rVisRect.Left() + 1;
274 tools::Long nRightSpace = rVisRect.Right() - maCellRect.Right() + 1;
275 tools::Long nTopSpace = maCellRect.Top() - rVisRect.Top() + 1;
276 tools::Long nBottomSpace = rVisRect.Bottom() - maCellRect.Bottom() + 1;
277
278 // nNeeded*** contains textbox dimensions plus needed distances to cell or border of visible area
279 tools::Long nNeededSpaceX = nWidth + SC_NOTECAPTION_CELLDIST;
280 tools::Long nNeededSpaceY = nHeight + SC_NOTECAPTION_CELLDIST;
281
282 // bFitsWidth*** == true means width of textbox fits into horizontal free space of visible area
283 bool bFitsWidthLeft = nNeededSpaceX <= nLeftSpace; // text box width fits into the width left of cell
284 bool bFitsWidthRight = nNeededSpaceX <= nRightSpace; // text box width fits into the width right of cell
285 bool bFitsWidth = nWidth <= rVisRect.GetWidth(); // text box width fits into width of visible area
286
287 // bFitsHeight*** == true means height of textbox fits into vertical free space of visible area
288 bool bFitsHeightTop = nNeededSpaceY <= nTopSpace; // text box height fits into the height above cell
289 bool bFitsHeightBottom = nNeededSpaceY <= nBottomSpace; // text box height fits into the height below cell
290 bool bFitsHeight = nHeight <= rVisRect.GetHeight(); // text box height fits into height of visible area
291
292 // bFits*** == true means the textbox fits completely into free space of visible area
293 bool bFitsLeft = bFitsWidthLeft && bFitsHeight;
294 bool bFitsRight = bFitsWidthRight && bFitsHeight;
295 bool bFitsTop = bFitsWidth && bFitsHeightTop;
296 bool bFitsBottom = bFitsWidth && bFitsHeightBottom;
297
298 Point aCaptPos;
299 // use left/right placement if possible, or if top/bottom placement not possible
300 if( bFitsLeft || bFitsRight || (!bFitsTop && !bFitsBottom) )
301 {
302 // prefer left in RTL sheet and right in LTR sheets
303 bool bPreferLeft = bFitsLeft && (mbNegPage || !bFitsRight);
304 bool bPreferRight = bFitsRight && (!mbNegPage || !bFitsLeft);
305 // move to left, if left is preferred, or if neither left nor right fit and there is more space to the left
306 if( bPreferLeft || (!bPreferRight && (nLeftSpace > nRightSpace)) )
307 aCaptPos.setX( maCellRect.Left() - SC_NOTECAPTION_CELLDIST - nWidth );
308 else // to right
309 aCaptPos.setX( maCellRect.Right() + SC_NOTECAPTION_CELLDIST );
310 // Y position according to top cell border
311 aCaptPos.setY( maCellRect.Top() + SC_NOTECAPTION_OFFSET_Y );
312 }
313 else // top or bottom placement
314 {
315 // X position
316 aCaptPos.setX( maCellRect.Left() + SC_NOTECAPTION_OFFSET_X );
317 // top placement, if possible
318 if( bFitsTop )
319 aCaptPos.setY( maCellRect.Top() - SC_NOTECAPTION_CELLDIST - nHeight );
320 else // bottom placement
321 aCaptPos.setY( maCellRect.Bottom() + SC_NOTECAPTION_CELLDIST );
322 }
323
324 // update textbox position in note caption object
325 aCaptRect.SetPos( aCaptPos );
326 mxCaption->SetLogicRect( aCaptRect );
327 FitCaptionToRect( pVisRect );
328}
329
330void ScCaptionCreator::UpdateCaptionPos()
331{
332 ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer();
333
334 // update caption position
335 const Point& rOldTailPos = mxCaption->GetTailPos();
336 Point aTailPos = CalcTailPos( false );
337 if( rOldTailPos != aTailPos )
338 {
339 // create drawing undo action
340 if( pDrawLayer && pDrawLayer->IsRecording() )
341 pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoGeoObj>( *mxCaption ) );
342 // calculate new caption rectangle (#i98141# handle LTR<->RTL switch correctly)
343 tools::Rectangle aCaptRect = mxCaption->GetLogicRect();
344 tools::Long nDiffX = (rOldTailPos.X() >= 0) ? (aCaptRect.Left() - rOldTailPos.X()) : (rOldTailPos.X() - aCaptRect.Right());
345 if( mbNegPage ) nDiffX = -nDiffX - aCaptRect.GetWidth();
346 tools::Long nDiffY = aCaptRect.Top() - rOldTailPos.Y();
347 aCaptRect.SetPos( aTailPos + Point( nDiffX, nDiffY ) );
348 // set new tail position and caption rectangle
349 mxCaption->SetTailPos( aTailPos );
350 mxCaption->SetLogicRect( aCaptRect );
351 // fit caption into draw page
352 FitCaptionToRect();
353 }
354
355 // update cell position in caption user data
356 ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( mxCaption.get(), maPos.Tab() );
357 if( pCaptData && (maPos != pCaptData->maStart) )
358 {
359 // create drawing undo action
360 if( pDrawLayer && pDrawLayer->IsRecording() )
361 pDrawLayer->AddCalcUndo( std::make_unique<ScUndoObjData>( mxCaption.get(), pCaptData->maStart, pCaptData->maEnd, maPos, pCaptData->maEnd ) );
362 // set new position
363 pCaptData->maStart = maPos;
364 }
365}
366
367Point ScCaptionCreator::CalcTailPos( bool bTailFront )
368{
369 // tail position
370 bool bTailLeft = bTailFront != mbNegPage;
371 Point aTailPos = bTailLeft ? maCellRect.TopLeft() : maCellRect.TopRight();
372 // move caption point 1/10 mm inside cell
373 if( bTailLeft ) aTailPos.AdjustX(10 ); else aTailPos.AdjustX( -10 );
374 aTailPos.AdjustY(10);
375 return aTailPos;
376}
377
378void ScCaptionCreator::CreateCaption( bool bShown, bool bTailFront )
379{
380 // create the caption drawing object
381 tools::Rectangle aTextRect( Point( 0 , 0 ), Size( SC_NOTECAPTION_WIDTH, SC_NOTECAPTION_HEIGHT ) );
382 Point aTailPos = CalcTailPos( bTailFront );
383 mxCaption =
384 new SdrCaptionObj(
385 *mrDoc.GetDrawLayer(), // TTTT should ret a ref?
386 aTextRect,
387 aTailPos);
388 // basic caption settings
389 ScCaptionUtil::SetBasicCaptionSettings( *mxCaption, bShown );
390}
391
392void ScCaptionCreator::Initialize()
393{
394 maCellRect = ScDrawLayer::GetCellRect( mrDoc, maPos, true );
395 mbNegPage = mrDoc.IsNegativePage( maPos.Tab() );
396 if( SdrPage* pDrawPage = GetDrawPage() )
397 {
398 maPageRect = tools::Rectangle( Point( 0, 0 ), pDrawPage->GetSize() );
399 /* #i98141# SdrPage::GetSize() returns negative width in RTL mode.
400 The call to Rectangle::Adjust() orders left/right coordinate
401 accordingly. */
402 maPageRect.Normalize();
403 }
404}
405
407class ScNoteCaptionCreator : public ScCaptionCreator
408{
409public:
411 explicit ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, ScNoteData& rNoteData );
413 explicit ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, rtl::Reference<SdrCaptionObj>& xCaption, bool bShown );
414};
415
416ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, ScNoteData& rNoteData ) :
417 ScCaptionCreator( rDoc, rPos ) // use helper c'tor that does not create the caption yet
418{
419 SdrPage* pDrawPage = GetDrawPage();
420 OSL_ENSURE( pDrawPage, "ScNoteCaptionCreator::ScNoteCaptionCreator - no drawing page" );
421 if( !pDrawPage )
422 return;
423
424 // create the caption drawing object
425 CreateCaption( rNoteData.mbShown, false );
426 rNoteData.mxCaption = GetCaption();
427 OSL_ENSURE( rNoteData.mxCaption, "ScNoteCaptionCreator::ScNoteCaptionCreator - missing caption object" );
428 if( rNoteData.mxCaption )
429 {
430 // store note position in user data of caption object
431 ScCaptionUtil::SetCaptionUserData( *rNoteData.mxCaption, rPos );
432 // insert object into draw page
433 pDrawPage->InsertObject( rNoteData.mxCaption.get() );
434 }
435}
436
437ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& rPos, rtl::Reference<SdrCaptionObj>& xCaption, bool bShown ) :
438 ScCaptionCreator( rDoc, rPos, xCaption )
439{
440 SdrPage* pDrawPage = GetDrawPage();
441 OSL_ENSURE( pDrawPage, "ScNoteCaptionCreator::ScNoteCaptionCreator - no drawing page" );
442 OSL_ENSURE( xCaption->getSdrPageFromSdrObject() == pDrawPage, "ScNoteCaptionCreator::ScNoteCaptionCreator - wrong drawing page in caption" );
443 if( pDrawPage && (xCaption->getSdrPageFromSdrObject() == pDrawPage) )
444 {
445 // store note position in user data of caption object
446 ScCaptionUtil::SetCaptionUserData( *xCaption, rPos );
447 // basic caption settings
448 ScCaptionUtil::SetBasicCaptionSettings( *xCaption, bShown );
449 // set correct tail position
450 xCaption->SetTailPos( CalcTailPos( false ) );
451 }
452}
453
454} // namespace
455
456
458{
459 std::optional< SfxItemSet > moItemSet;
461 OUString maSimpleText;
465
466 explicit ScCaptionInitData();
467};
468
470 mbDefaultPosSize( true )
471{
472}
473
475 mbShown( bShown )
476{
477}
478
479sal_uInt32 ScPostIt::mnLastPostItId = 1;
480
481ScPostIt::ScPostIt( ScDocument& rDoc, const ScAddress& rPos, sal_uInt32 nPostItId ) :
482 mrDoc( rDoc ),
483 maNoteData( false )
484{
485 mnPostItId = nPostItId == 0 ? mnLastPostItId++ : nPostItId;
486 AutoStamp();
487 CreateCaption( rPos );
488}
489
490ScPostIt::ScPostIt( ScDocument& rDoc, const ScAddress& rPos, const ScPostIt& rNote, sal_uInt32 nPostItId ) :
491 mrDoc( rDoc ),
492 maNoteData( rNote.maNoteData )
493{
494 mnPostItId = nPostItId == 0 ? mnLastPostItId++ : nPostItId;
495 maNoteData.mxCaption.clear();
496 CreateCaption( rPos, rNote.maNoteData.mxCaption.get() );
497}
498
499ScPostIt::ScPostIt( ScDocument& rDoc, const ScAddress& rPos, ScNoteData aNoteData, bool bAlwaysCreateCaption, sal_uInt32 nPostItId ) :
500 mrDoc( rDoc ),
501 maNoteData(std::move( aNoteData ))
502{
503 mnPostItId = nPostItId == 0 ? mnLastPostItId++ : nPostItId;
504 if( bAlwaysCreateCaption || maNoteData.mbShown )
506}
507
509{
511}
512
513std::unique_ptr<ScPostIt> ScPostIt::Clone( const ScAddress& rOwnPos, ScDocument& rDestDoc, const ScAddress& rDestPos, bool bCloneCaption ) const
514{
515 CreateCaptionFromInitData( rOwnPos );
516 sal_uInt32 nPostItId = comphelper::LibreOfficeKit::isActive() ? 0 : mnPostItId;
517 return bCloneCaption ? std::make_unique<ScPostIt>( rDestDoc, rDestPos, *this, nPostItId ) : std::make_unique<ScPostIt>( rDestDoc, rDestPos, maNoteData, false, mnPostItId );
518}
519
520void ScPostIt::SetDate( const OUString& rDate )
521{
522 maNoteData.maDate = rDate;
523}
524
525void ScPostIt::SetAuthor( const OUString& rAuthor )
526{
527 maNoteData.maAuthor = rAuthor;
528}
529
531{
534}
535
537{
539 return maNoteData.mxCaption->GetOutlinerParaObject();
540 if( maNoteData.mxInitData && maNoteData.mxInitData->mxOutlinerObj )
541 return &*maNoteData.mxInitData->mxOutlinerObj;
542 return nullptr;
543}
544
546{
548 return pOPO ? &pOPO->GetTextObject() : nullptr;
549}
550
551OUString ScPostIt::GetText() const
552{
553 if( const EditTextObject* pEditObj = GetEditTextObject() )
554 {
555 OUStringBuffer aBuffer;
557 rEngine.SetTextCurrentDefaults(*pEditObj);
558 sal_Int32 nParaCount = rEngine.GetParagraphCount();
559 for( sal_Int32 nPara = 0; nPara < nParaCount; ++nPara )
560 {
561 if( nPara > 0 )
562 aBuffer.append( '\n' );
563 aBuffer.append(rEngine.GetText(nPara));
564 }
565 return aBuffer.makeStringAndClear();
566 }
568 return maNoteData.mxInitData->maSimpleText;
569 return OUString();
570}
571
573{
574 if( const EditTextObject* pEditObj = GetEditTextObject() )
575 return pEditObj->GetParagraphCount() > 1;
577 return maNoteData.mxInitData->maSimpleText.indexOf( '\n' ) >= 0;
578 return false;
579}
580
581void ScPostIt::SetText( const ScAddress& rPos, const OUString& rText )
582{
585 maNoteData.mxCaption->SetText( rText );
586}
587
589{
591 return maNoteData.mxCaption.get();
592}
593
594void ScPostIt::ForgetCaption( bool bPreserveData )
595{
596 if (bPreserveData)
597 {
598 // Used in clipboard when the originating document is destructed to be
599 // able to paste into another document. Caption size and relative
600 // position are not preserved but default created when pasted. Also the
601 // MergedItemSet can not be carried over or it had to be adapted to
602 // defaults and pool. At least preserve the text and outline object if
603 // possible.
604 ScCaptionInitData* pInitData = new ScCaptionInitData;
606 if (pOPO)
607 pInitData->mxOutlinerObj = *pOPO;
608 pInitData->maSimpleText = GetText();
609
610 maNoteData.mxInitData.reset(pInitData);
611 maNoteData.mxCaption.clear();
612 }
613 else
614 {
615 /* This function is used in undo actions to give up the responsibility for
616 the caption object which is handled by separate drawing undo actions. */
617 maNoteData.mxCaption.clear();
618 maNoteData.mxInitData.reset();
619 }
620}
621
622void ScPostIt::ShowCaption( const ScAddress& rPos, bool bShow )
623{
625 // no separate drawing undo needed, handled completely inside ScUndoShowHideNote
626 maNoteData.mbShown = bShow;
628 ScCaptionUtil::SetCaptionLayer( *maNoteData.mxCaption, bShow );
629}
630
631void ScPostIt::ShowCaptionTemp( const ScAddress& rPos, bool bShow )
632{
635 ScCaptionUtil::SetCaptionLayer( *maNoteData.mxCaption, maNoteData.mbShown || bShow );
636}
637
639{
642 {
643 ScCaptionCreator aCreator( mrDoc, rPos, maNoteData.mxCaption );
644 aCreator.UpdateCaptionPos();
645 }
646}
647
648// private --------------------------------------------------------------------
649
651{
652 // Captions are not created in Undo documents and only rarely in Clipboard,
653 // but otherwise we need caption or initial data.
656 return;
657
658
659 /* This function is called from ScPostIt::Clone() when copying cells
660 to the clipboard/undo document, and when copying cells from the
661 clipboard/undo document. The former should always be called first,
662 so if called in a clipboard/undo document, the caption should have
663 been created already. However, for clipboard in case the
664 originating document was destructed a new caption has to be
665 created. */
666 OSL_ENSURE( !mrDoc.IsUndo() && (!mrDoc.IsClipboard() || !maNoteData.mxCaption),
667 "ScPostIt::CreateCaptionFromInitData - note caption should not be created in undo/clip documents" );
668
669 // going to forget the initial caption data struct when this method returns
670 auto xInitData = std::move(maNoteData.mxInitData);
671
672 /* #i104915# Never try to create notes in Undo document, leads to
673 crash due to missing document members (e.g. row height array). */
675 return;
676
677 if (mrDoc.IsClipboard())
678 mrDoc.InitDrawLayer(); // ensure there is a drawing layer
679
680 // ScNoteCaptionCreator c'tor creates the caption and inserts it into the document and maNoteData
681 ScNoteCaptionCreator aCreator( mrDoc, rPos, maNoteData );
682 if( !maNoteData.mxCaption )
683 return;
684
685 // Prevent triple change broadcasts of the same object.
686 bool bWasLocked = maNoteData.mxCaption->getSdrModelFromSdrObject().isLocked();
687 maNoteData.mxCaption->getSdrModelFromSdrObject().setLock(true);
688
689 // transfer ownership of outliner object to caption, or set simple text
690 OSL_ENSURE( xInitData->mxOutlinerObj || !xInitData->maSimpleText.isEmpty(),
691 "ScPostIt::CreateCaptionFromInitData - need either outliner para object or simple text" );
692 if (xInitData->mxOutlinerObj)
693 maNoteData.mxCaption->SetOutlinerParaObject( std::move(xInitData->mxOutlinerObj) );
694 else
695 maNoteData.mxCaption->SetText( xInitData->maSimpleText );
696
697 // copy all items or set default items; reset shadow items
698 ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, xInitData->moItemSet ? &*xInitData->moItemSet : nullptr );
699
700 // set position and size of the caption object
701 if( xInitData->mbDefaultPosSize )
702 {
703 // set other items and fit caption size to text
704 maNoteData.mxCaption->SetMergedItem( makeSdrTextMinFrameWidthItem( SC_NOTECAPTION_WIDTH ) );
705 maNoteData.mxCaption->SetMergedItem( makeSdrTextMaxFrameWidthItem( SC_NOTECAPTION_MAXWIDTH_TEMP ) );
706 maNoteData.mxCaption->AdjustTextFrameWidthAndHeight();
707 aCreator.AutoPlaceCaption();
708 }
709 else
710 {
711 tools::Rectangle aCellRect = ScDrawLayer::GetCellRect( mrDoc, rPos, true );
712 bool bNegPage = mrDoc.IsNegativePage( rPos.Tab() );
713 tools::Long nPosX = bNegPage ? (aCellRect.Left() - xInitData->maCaptionOffset.X()) : (aCellRect.Right() + xInitData->maCaptionOffset.X());
714 tools::Long nPosY = aCellRect.Top() + xInitData->maCaptionOffset.Y();
715 tools::Rectangle aCaptRect( Point( nPosX, nPosY ), xInitData->maCaptionSize );
716 maNoteData.mxCaption->SetLogicRect( aCaptRect );
717 aCreator.FitCaptionToRect();
718 }
719
720 // End prevent triple change broadcasts of the same object.
721 maNoteData.mxCaption->getSdrModelFromSdrObject().setLock(bWasLocked);
722 maNoteData.mxCaption->BroadcastObjectChange();
723}
724
725void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCaption )
726{
727 OSL_ENSURE( !maNoteData.mxCaption, "ScPostIt::CreateCaption - unexpected caption object found" );
728 maNoteData.mxCaption.clear();
729
730 /* #i104915# Never try to create notes in Undo document, leads to
731 crash due to missing document members (e.g. row height array). */
732 OSL_ENSURE( !mrDoc.IsUndo(), "ScPostIt::CreateCaption - note caption should not be created in undo documents" );
733 if( mrDoc.IsUndo() )
734 return;
735
736 // drawing layer may be missing, if a note is copied into a clipboard document
737 if( mrDoc.IsClipboard() )
739
740 // ScNoteCaptionCreator c'tor creates the caption and inserts it into the document and maNoteData
741 ScNoteCaptionCreator aCreator( mrDoc, rPos, maNoteData );
742 if( !maNoteData.mxCaption )
743 return;
744
745 // clone settings of passed caption
746 if( pCaption )
747 {
748 // copy edit text object (object must be inserted into page already)
749 if( OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
750 maNoteData.mxCaption->SetOutlinerParaObject( *pOPO );
751 // copy formatting items (after text has been copied to apply font formatting)
752 maNoteData.mxCaption->SetMergedItemSetAndBroadcast( pCaption->GetMergedItemSet() );
753 // move textbox position relative to new cell, copy textbox size
754 tools::Rectangle aCaptRect = pCaption->GetLogicRect();
755 Point aDist = maNoteData.mxCaption->GetTailPos() - pCaption->GetTailPos();
756 aCaptRect.Move( aDist.X(), aDist.Y() );
757 maNoteData.mxCaption->SetLogicRect( aCaptRect );
758 aCreator.FitCaptionToRect();
759 }
760 else
761 {
762 // set default formatting and default position
763 ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, nullptr );
764 aCreator.AutoPlaceCaption();
765 }
766
767 // create undo action
768 if( ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer() )
769 if( pDrawLayer->IsRecording() )
770 pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoNewObj>( *maNoteData.mxCaption ) );
771}
772
774{
776 return;
777
778 /* Remove caption object only, if this note is its owner (e.g. notes in
779 undo documents refer to captions in original document, do not remove
780 them from drawing layer here). */
781 // TTTT maybe no longer needed - can that still happen?
782 ScDrawLayer* pDrawLayer = mrDoc.GetDrawLayer();
783 if (pDrawLayer == &maNoteData.mxCaption->getSdrModelFromSdrObject())
784 {
785 SdrPage* pDrawPage(maNoteData.mxCaption->getSdrPageFromSdrObject());
786 SAL_WARN_IF( !pDrawPage, "sc.core", "ScCaptionPtr::removeFromDrawPageAndFree - object without drawing page");
787 if (pDrawPage)
788 {
789 pDrawPage->RecalcObjOrdNums();
790 // create drawing undo action (before removing the object to have valid draw page in undo action)
791 bool bRecording = (pDrawLayer && pDrawLayer->IsRecording());
792 if (bRecording)
793 pDrawLayer->AddCalcUndo( std::make_unique<SdrUndoDelObj>( *maNoteData.mxCaption ));
794 // remove the object from the drawing page
795 rtl::Reference<SdrObject> pRemovedObj = pDrawPage->RemoveObject( maNoteData.mxCaption->GetOrdNum() );
796 assert(pRemovedObj.get() == maNoteData.mxCaption.get()); (void)pRemovedObj;
797 }
798 }
799
800 SAL_INFO("sc.core","ScPostIt::RemoveCaption -"
801 " IsUndo: " << mrDoc.IsUndo() << " IsClip: " << mrDoc.IsClipboard() <<
802 " Dtor: " << mrDoc.IsInDtorClear());
803
804 // Forget the caption object if removeFromDrawPageAndFree() did not free it.
806 {
807 SAL_INFO("sc.core","ScPostIt::RemoveCaption - forgetting one ref");
808 maNoteData.mxCaption.clear();
809 }
810}
811
813 ScDocument& rDoc, const ScAddress& rPos, SdrPage& rDrawPage,
814 std::u16string_view rUserText, const tools::Rectangle& rVisRect, bool bTailFront )
815{
816 OUStringBuffer aBuffer( rUserText );
817 // add plain text of invisible (!) cell note (no formatting etc.)
818 SdrCaptionObj* pNoteCaption = nullptr;
819 const ScPostIt* pNote = rDoc.GetNote( rPos );
820 if( pNote && !pNote->IsCaptionShown() )
821 {
822 if( !aBuffer.isEmpty() )
823 aBuffer.append( "\n--------\n" + pNote->GetText() );
824 pNoteCaption = pNote->GetOrCreateCaption( rPos );
825 }
826
827 // create a caption if any text exists
828 if( !pNoteCaption && aBuffer.isEmpty() )
830
831 // prepare visible rectangle (add default distance to all borders)
832 tools::Rectangle aVisRect(
833 rVisRect.Left() + SC_NOTECAPTION_BORDERDIST_TEMP,
834 rVisRect.Top() + SC_NOTECAPTION_BORDERDIST_TEMP,
835 rVisRect.Right() - SC_NOTECAPTION_BORDERDIST_TEMP,
836 rVisRect.Bottom() - SC_NOTECAPTION_BORDERDIST_TEMP );
837
838 // create the caption object
839 ScCaptionCreator aCreator( rDoc, rPos, bTailFront );
840
841 // insert caption into page (needed to set caption text)
842 rtl::Reference<SdrCaptionObj> pCaption = aCreator.GetCaption(); // just for ease of use
843 rDrawPage.InsertObject( pCaption.get() );
844
845
846 // clone the edit text object, unless user text is present, then set this text
847 if( pNoteCaption && rUserText.empty() )
848 {
849 if( OutlinerParaObject* pOPO = pNoteCaption->GetOutlinerParaObject() )
850 pCaption->SetOutlinerParaObject( *pOPO );
851 // set formatting (must be done after setting text) and resize the box to fit the text
852 pCaption->SetMergedItemSetAndBroadcast( pNoteCaption->GetMergedItemSet() );
853 tools::Rectangle aCaptRect( pCaption->GetLogicRect().TopLeft(), pNoteCaption->GetLogicRect().GetSize() );
854 pCaption->SetLogicRect( aCaptRect );
855 }
856 else
857 {
858 // if pNoteCaption is null, then aBuffer contains some text
859 pCaption->SetText( aBuffer.makeStringAndClear() );
860 ScCaptionUtil::SetDefaultItems( *pCaption, rDoc, nullptr );
861 // adjust caption size to text size
862 tools::Long nMaxWidth = ::std::min< tools::Long >( aVisRect.GetWidth() * 2 / 3, SC_NOTECAPTION_MAXWIDTH_TEMP );
863 pCaption->SetMergedItem( makeSdrTextAutoGrowWidthItem( true ) );
864 pCaption->SetMergedItem( makeSdrTextMinFrameWidthItem( SC_NOTECAPTION_WIDTH ) );
865 pCaption->SetMergedItem( makeSdrTextMaxFrameWidthItem( nMaxWidth ) );
866 pCaption->SetMergedItem( makeSdrTextAutoGrowHeightItem( true ) );
867 pCaption->AdjustTextFrameWidthAndHeight();
868 }
869
870 // move caption into visible area
871 aCreator.AutoPlaceCaption( &aVisRect );
872
873 // XXX Note it is already inserted to the draw page.
874 return aCreator.GetCaption();
875}
876
878 ScDocument& rDoc, const ScAddress& rPos, SdrCaptionObj* pCaption )
879{
880 ScNoteData aNoteData( true/*bShown*/ );
881 aNoteData.mxCaption = pCaption;
882 ScPostIt* pNote = new ScPostIt( rDoc, rPos, aNoteData, false );
883 pNote->AutoStamp();
884
885 rDoc.SetNote(rPos, std::unique_ptr<ScPostIt>(pNote));
886
887 // ScNoteCaptionCreator c'tor updates the caption object to be part of a note
888 ScNoteCaptionCreator aCreator( rDoc, rPos, aNoteData.mxCaption, true/*bShown*/ );
889
890 return pNote;
891}
892
894 ScDocument& rDoc, const ScAddress& rPos, SfxItemSet&& rItemSet,
895 const OutlinerParaObject& rOutlinerObj, const tools::Rectangle& rCaptionRect,
896 bool bShown )
897{
898 ScNoteData aNoteData( bShown );
899 aNoteData.mxInitData = std::make_shared<ScCaptionInitData>();
900 ScCaptionInitData& rInitData = *aNoteData.mxInitData;
901 rInitData.moItemSet.emplace(std::move(rItemSet));
902 rInitData.mxOutlinerObj = rOutlinerObj;
903
904 // convert absolute caption position to relative position
905 rInitData.mbDefaultPosSize = rCaptionRect.IsEmpty();
906 if( !rInitData.mbDefaultPosSize )
907 {
908 tools::Rectangle aCellRect = ScDrawLayer::GetCellRect( rDoc, rPos, true );
909 bool bNegPage = rDoc.IsNegativePage( rPos.Tab() );
910 rInitData.maCaptionOffset.setX( bNegPage ? (aCellRect.Left() - rCaptionRect.Right()) : (rCaptionRect.Left() - aCellRect.Right()) );
911 rInitData.maCaptionOffset.setY( rCaptionRect.Top() - aCellRect.Top() );
912 rInitData.maCaptionSize = rCaptionRect.GetSize();
913 }
914
915 /* Create the note and insert it into the document. If the note is
916 visible, the caption object will be created automatically. */
917 ScPostIt* pNote = new ScPostIt( rDoc, rPos, std::move(aNoteData), /*bAlwaysCreateCaption*/false, 0/*nPostItId*/ );
918 pNote->AutoStamp();
919
920 rDoc.SetNote(rPos, std::unique_ptr<ScPostIt>(pNote));
921
922 return pNote;
923}
924
926 ScDocument& rDoc, const ScAddress& rPos, const OUString& rNoteText,
927 bool bShown, bool bAlwaysCreateCaption, sal_uInt32 nPostItId )
928{
929 ScPostIt* pNote = nullptr;
930 if( !rNoteText.isEmpty() )
931 {
932 ScNoteData aNoteData( bShown );
933 aNoteData.mxInitData = std::make_shared<ScCaptionInitData>();
934 ScCaptionInitData& rInitData = *aNoteData.mxInitData;
935 rInitData.maSimpleText = rNoteText;
936 rInitData.mbDefaultPosSize = true;
937
938 /* Create the note and insert it into the document. If the note is
939 visible, the caption object will be created automatically. */
940 pNote = new ScPostIt( rDoc, rPos, std::move(aNoteData), bAlwaysCreateCaption, nPostItId );
941 pNote->AutoStamp();
942 //insert takes ownership
943 rDoc.SetNote(rPos, std::unique_ptr<ScPostIt>(pNote));
944 }
945 return pNote;
946}
947
948namespace sc {
949
950NoteEntry::NoteEntry( const ScAddress& rPos, const ScPostIt* pNote ) :
951 maPos(rPos), mpNote(pNote) {}
952
953}
954
955/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetText(LineEnd eEnd=LINEEND_LF) const
sal_Int32 GetParagraphCount() const
OUString getDate(const Date &rDate) const
const EditTextObject & GetTextObject() const
SCTAB Tab() const
Definition: address.hxx:283
static Color GetCommentColor()
Definition: detfunc.cxx:1724
bool IsUndo() const
Definition: document.hxx:1592
void SetNote(const ScAddress &rPos, std::unique_ptr< ScPostIt > pNote)
Definition: document.cxx:6755
SC_DLLPUBLIC void InitDrawLayer(SfxObjectShell *pDocShell=nullptr)
Definition: documen9.cxx:98
bool IsClipboard() const
Definition: document.hxx:1593
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6181
SC_DLLPUBLIC ScPostIt * GetNote(const ScAddress &rPos)
Definition: document.cxx:6741
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:1006
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1083
SC_DLLPUBLIC ScNoteEditEngine & GetNoteEngine()
Definition: documen2.cxx:496
bool IsInDtorClear() const
Definition: document.hxx:2455
static tools::Rectangle GetCellRect(const ScDocument &rDoc, const ScAddress &rPos, bool bMergedCell)
Returns the rectangle for the passed cell address in 1/100 mm.
Definition: drwlayer.cxx:2131
static ScDrawObjData * GetObjData(SdrObject *pObj, bool bCreate=false)
Definition: drwlayer.cxx:2620
bool IsRecording() const
Definition: drwlayer.hxx:142
static ScDrawObjData * GetNoteCaptionData(SdrObject *pObj, SCTAB nTab)
Returns the object data, if the passed object is a cell note caption.
Definition: drwlayer.cxx:2653
void AddCalcUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: drwlayer.cxx:1438
ScAddress maStart
Definition: userdat.hxx:36
ScAddress maEnd
Definition: userdat.hxx:37
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:616
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
Definition: global.cxx:1053
static ScPostIt * CreateNoteFromObjectData(ScDocument &rDoc, const ScAddress &rPos, SfxItemSet &&oItemSet, const OutlinerParaObject &rOutlinerObj, const tools::Rectangle &rCaptionRect, bool bShown)
Creates a cell note based on the passed caption object data.
Definition: postit.cxx:893
static ScPostIt * CreateNoteFromCaption(ScDocument &rDoc, const ScAddress &rPos, SdrCaptionObj *pCaption)
Creates a cell note using the passed caption drawing object.
Definition: postit.cxx:877
static ScPostIt * CreateNoteFromString(ScDocument &rDoc, const ScAddress &rPos, const OUString &rNoteText, bool bShown, bool bAlwaysCreateCaption, sal_uInt32 nPostItId=0)
Creates a cell note based on the passed string and inserts it into the document.
Definition: postit.cxx:925
static rtl::Reference< SdrCaptionObj > CreateTempCaption(ScDocument &rDoc, const ScAddress &rPos, SdrPage &rDrawPage, std::u16string_view rUserText, const tools::Rectangle &rVisRect, bool bTailFront)
Creates and returns a caption object for a temporary caption.
Definition: postit.cxx:812
void FillEditItemSet(SfxItemSet *pEditSet, const SfxItemSet *pCondSet=nullptr) const
Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSe...
Definition: patattr.cxx:827
Additional class containing cell annotation data.
Definition: postit.hxx:58
void SetAuthor(const OUString &rAuthor)
Sets a new author date for this note.
Definition: postit.cxx:525
void ShowCaptionTemp(const ScAddress &rPos, bool bShow=true)
Shows or hides the caption temporarily (does not change internal visibility state).
Definition: postit.cxx:631
~ScPostIt()
Removes the caption object from drawing layer, if this note is its owner.
Definition: postit.cxx:508
ScNoteData maNoteData
Parent document containing the note.
Definition: postit.hxx:173
void AutoStamp()
Sets date and author from system settings.
Definition: postit.cxx:530
void SetText(const ScAddress &rPos, const OUString &rText)
Changes the caption text of this note.
Definition: postit.cxx:581
void UpdateCaptionPos(const ScAddress &rPos)
Updates caption position according to position of the passed cell.
Definition: postit.cxx:638
static sal_uInt32 mnLastPostItId
Definition: postit.hxx:60
std::unique_ptr< ScPostIt > Clone(const ScAddress &rOwnPos, ScDocument &rDestDoc, const ScAddress &rDestPos, bool bCloneCaption) const
Clones this note and its caption object, if specified.
Definition: postit.cxx:513
sal_uInt32 mnPostItId
Note data with pointer to caption object.
Definition: postit.hxx:174
ScDocument & mrDoc
Definition: postit.hxx:172
void ShowCaption(const ScAddress &rPos, bool bShow)
Shows or hides the note caption object.
Definition: postit.cxx:622
const EditTextObject * GetEditTextObject() const
Returns the pointer to the current edit text object, or null.
Definition: postit.cxx:545
SdrCaptionObj * GetOrCreateCaption(const ScAddress &rPos) const
Returns the caption object of this note.
Definition: postit.cxx:588
void CreateCaptionFromInitData(const ScAddress &rPos) const
Creates the caption object from initial caption data if existing.
Definition: postit.cxx:650
void ForgetCaption(bool bPreserveData=false)
Forgets the pointer to the note caption object.
Definition: postit.cxx:594
ScPostIt(ScDocument &rDoc, const ScAddress &rPos, sal_uInt32 nPostItId=0)
Creates an empty note and its caption object and places it according to the passed cell position.
Definition: postit.cxx:481
void SetDate(const OUString &rDate)
Sets a new creation date for this note.
Definition: postit.cxx:520
const OutlinerParaObject * GetOutlinerObject() const
Returns the pointer to the current outliner object, or null.
Definition: postit.cxx:536
bool IsCaptionShown() const
Returns true, if the caption object is visible.
Definition: postit.hxx:152
OUString GetText() const
Returns the caption text of this note.
Definition: postit.cxx:551
void RemoveCaption()
Removes the caption object from the drawing layer, if this note is its owner.
Definition: postit.cxx:773
bool HasMultiLineText() const
Returns true, if the caption text of this note contains line breaks.
Definition: postit.cxx:572
void CreateCaption(const ScAddress &rPos, const SdrCaptionObj *pCaption=nullptr)
Creates a new caption object at the passed cell position, clones passed existing caption.
Definition: postit.cxx:725
void SetSpecialTextBoxShadow()
const Point & GetTailPos() const
virtual const tools::Rectangle & GetLogicRect() const override
void SetFixedTail()
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual void InsertObject(SdrObject *pObj, size_t nPos=SAL_MAX_SIZE)
void RecalcObjOrdNums()
virtual rtl::Reference< SdrObject > RemoveObject(size_t nObjNum)
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
const SfxItemSet & GetMergedItemSet() const
virtual SdrLayerID GetLayer() const
virtual void SetLayer(SdrLayerID nLayer)
virtual OutlinerParaObject * GetOutlinerParaObject() const override
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
void setClosed(bool bNew)
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
constexpr Point TopLeft() const
void SetPos(const Point &rPoint)
constexpr Size GetSize() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Right() const
constexpr tools::Long GetHeight() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
constexpr SdrLayerID SC_LAYER_HIDDEN(4)
constexpr SdrLayerID SC_LAYER_INTERN(2)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
CAUTION! The following defines must be in the same namespace as the respective type.
Definition: broadcast.cxx:15
long Long
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
SdrOnOffItem makeSdrShadowItem(bool bShadow)
SdrMetricItem makeSdrShadowXDistItem(tools::Long nDist)
SdrMetricItem makeSdrShadowYDistItem(tools::Long nDist)
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
SdrOnOffItem makeSdrTextAutoGrowWidthItem(bool bAuto)
SdrMetricItem makeSdrTextUpperDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextRightDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextLowerDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextLeftDistItem(tools::Long mnHeight)
SdrMetricItem makeSdrTextMaxFrameWidthItem(tools::Long mnWidth)
SdrMetricItem makeSdrTextMinFrameWidthItem(tools::Long mnWidth)
Point maCaptionOffset
Simple text without formatting.
Definition: postit.cxx:462
Size maCaptionSize
Caption position relative to cell corner.
Definition: postit.cxx:463
OUString maSimpleText
Text object with all text portion formatting.
Definition: postit.cxx:461
bool mbDefaultPosSize
Size of the caption object.
Definition: postit.cxx:464
std::optional< OutlinerParaObject > mxOutlinerObj
Caption object formatting.
Definition: postit.cxx:460
ScCaptionInitData()
True = use default position and size for caption.
Definition: postit.cxx:469
std::optional< SfxItemSet > moItemSet
Definition: postit.cxx:459
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
NoteEntry(const ScAddress &rPos, const ScPostIt *pNote)
Definition: postit.cxx:950
std::unique_ptr< char[]> aBuffer