LibreOffice Module sw (master) 1
frmfmt.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#ifndef INCLUDED_SW_INC_FRMFMT_HXX
20#define INCLUDED_SW_INC_FRMFMT_HXX
21
22#include <memory>
23#include <com/sun/star/text/PositionLayoutDir.hpp>
25#include <tools/gen.hxx>
26#include "format.hxx"
27#include "hintids.hxx"
28#include "swdllapi.h"
29#include <list>
30#include "textboxhelper.hxx"
31
32class SwFlyFrame;
35class Graphic;
36class ImageMap;
37class IMapObject;
38class SwRect;
39class SdrObject;
40class SwRootFrame;
41class SwTableBox;
42
43namespace sw
44{
45 class DocumentLayoutManager;
46 // This is cheating: we are not really decoupling much with this hint.
47 // SwDrawFrameFormat should probably bookkeep its SdrObject (and
48 // SwDrawFrameFormat too) as members
50 {
53 : SfxHint(SfxHintId::SwFindSdrObject), m_rpObject(rpObject) {};
54 virtual ~FindSdrObjectHint() override;
55 };
56}
57class SwFrameFormats;
58
61 : public SwFormat
62{
63 friend class SwDoc;
64 friend class SwPageDesc;
65 friend class ::sw::DocumentLayoutManager;
66 friend class SwFrameFormats;
67 friend class SwTextBoxHelper;
68 friend class SwUndoFlyBase;
69
70 css::uno::WeakReference<css::uno::XInterface> m_wXObject;
71
72 // DrawingLayer FillAttributes in a preprocessed form for primitive usage
74
75 // The assigned SwFrmFmt list.
77
78 std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats;
79
81 {
82 change_name(const OUString &rName) : mName(rName) {}
83 void operator()(SwFormat *pFormat) { pFormat->m_aFormatName = mName; }
84 const OUString &mName;
85 };
86
87protected:
89 SwAttrPool& rPool,
90 const char* pFormatNm,
91 SwFrameFormat *pDrvdFrame,
92 sal_uInt16 nFormatWhich = RES_FRMFMT,
93 const WhichRangesContainer& pWhichRange = aFrameFormatSetRange);
94
96 SwAttrPool& rPool,
97 const OUString &rFormatNm,
98 SwFrameFormat *pDrvdFrame,
99 sal_uInt16 nFormatWhich = RES_FRMFMT,
100 const WhichRangesContainer& pWhichRange = aFrameFormatSetRange);
101
102 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
103
104public:
105
106 const std::shared_ptr< SwTextBoxNode >& GetOtherTextBoxFormats() const { return m_pOtherTextBoxFormats; };
107 void SetOtherTextBoxFormats(const std::shared_ptr<SwTextBoxNode>& rNew) { m_pOtherTextBoxFormats = rNew; };
108
109 virtual ~SwFrameFormat() override;
110
111 SwFrameFormat(SwFrameFormat const &) = default;
115
117 virtual void DelFrames();
118
120 virtual void MakeFrames();
121
122 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt );
123
128 IMapObject* GetIMapObject( const Point& rPoint,
129 const SwFlyFrame *pFly = nullptr ) const;
130
134 SwRect FindLayoutRect( const bool bPrtArea = false,
135 const Point* pPoint = nullptr ) const;
136
142 {
143 SdrObject* pObject(nullptr);
144 CallSwClientNotify(sw::FindSdrObjectHint(pObject));
145 return pObject;
146 }
148 { return const_cast<SwFrameFormat*>(this)->FindSdrObject(); }
149
150 SdrObject *FindRealSdrObject();
152 { return const_cast<SwFrameFormat*>(this)->FindRealSdrObject(); }
153
154 bool IsLowerOf( const SwFrameFormat& rFormat ) const;
155
157 {
160 VERT_R2L
161 };
162
163 virtual SwFrameFormat::tLayoutDir GetLayoutDir() const;
164 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir );
165
166 virtual sal_Int16 GetPositionLayoutDir() const;
167 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir );
168
169 virtual OUString GetDescription() const;
170
171 SAL_DLLPRIVATE css::uno::WeakReference<css::uno::XInterface> const& GetXObject() const
172 { return m_wXObject; }
173 SAL_DLLPRIVATE void SetXObject(css::uno::Reference<css::uno::XInterface> const& xObject)
174 { m_wXObject = xObject; }
175
176 void RegisterToFormat( SwFormat& rFormat );
177
178 // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
179 virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const override;
180 virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
181
182 void dumpAsXml(xmlTextWriterPtr pWriter) const;
183
184 virtual void SetFormatName( const OUString& rNewName, bool bBroadcast=false ) override;
185 void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat);
186};
187
188// The FlyFrame-Format
189
191{
192 friend class SwDoc;
193 OUString msTitle;
194 OUString msDesc;
196 OUString msTooltip;
197
203 std::unique_ptr<SwFlyDrawContact> m_pContact;
204
205 SwFlyFrameFormat( const SwFlyFrameFormat &rCpy ) = delete;
207
208 SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame );
209
210public:
211 virtual ~SwFlyFrameFormat() override;
212
214 virtual void MakeFrames() override;
215
216 SwFlyFrame* GetFrame( const Point* pDocPos = nullptr ) const;
217
218 SwAnchoredObject* GetAnchoredObj() const;
219
220 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
221
222 virtual bool GetInfo( SfxPoolItem& rInfo ) const override;
223
224 OUString GetObjTitle() const;
225 void SetObjTitle( const OUString& rTitle, bool bBroadcast = false );
226
227 const OUString & GetObjTooltip() const;
228 void SetObjTooltip(const OUString& rTooltip);
229
230 OUString GetObjDescription() const;
231 void SetObjDescription( const OUString& rDescription, bool bBroadcast = false );
232
242 virtual bool IsBackgroundTransparent() const override;
243
253 bool IsBackgroundBrushInherited() const;
254
255 const Point & GetLastFlyFramePrtRectPos() const { return m_aLastFlyFramePrtRectPos; }
256 void SetLastFlyFramePrtRectPos( const Point &rPoint ) { m_aLastFlyFramePrtRectPos = rPoint; }
257
258 SwFlyDrawContact* GetOrCreateContact();
259};
260
261//The DrawFrame-Format
262
263
265class SwDrawContact;
266class SdrTextObj;
267
268namespace sw
269{
271 DYING,
279 };
281 {
285 virtual ~DrawFrameFormatHint() override;
286 };
288 {
290 CheckDrawFrameFormatLayerHint(bool* bCheckControlLayer)
292 m_bCheckControlLayer(bCheckControlLayer) {};
293 virtual ~CheckDrawFrameFormatLayerHint() override;
294 };
296 {
300 m_ppObject(ppObject) {};
301 virtual ~ContactChangedHint() override;
302 };
304 {
309 m_rDestFormat(rDestFormat), m_rDestDoc(rDestDoc) {};
310 virtual ~DrawFormatLayoutCopyHint() override;
311 };
312 enum class WW8AnchorConv
313 {
314 NO_CONV,
315 CONV2PG,
317 CONV2CHAR,
318 CONV2LINE,
320 };
322 {
327 WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv) : m_eHoriConv(eHoriConv), m_eVertConv(eVertConv), m_bConverted(false) {};
328 };
330 {
334 m_rResult(rResult) {};
335 virtual ~WW8AnchorConvHint() override;
336 };
338 {
342 m_aPos(aPos) {};
343 virtual ~RestoreFlyAnchorHint() override;
344 };
346 {
350 m_ppContact(ppContact) {};
351 virtual ~CreatePortionHint() override;
352 };
354 {
355 std::list<SdrTextObj*>& m_rTextObjects;
356 CollectTextObjectsHint(std::list<SdrTextObj*>& rTextObjects)
358 m_rTextObjects(rTextObjects) {};
359 virtual ~CollectTextObjectsHint() override;
360 };
361 struct GetZOrderHint final : SfxHint
362 {
363 sal_uInt32& m_rnZOrder;
364 GetZOrderHint(sal_uInt32& rnZOrder)
366 m_rnZOrder(rnZOrder) {};
367 virtual ~GetZOrderHint() override;
368 };
370 {
373 GetObjectConnectedHint(bool& risConnected, const SwRootFrame* pRoot)
375 m_risConnected(risConnected), m_pRoot(pRoot) {};
376 virtual ~GetObjectConnectedHint() override;
377 };
378}
379
381{
382 friend class SwDoc;
383
386
387 SwDrawFrameFormat( const SwDrawFrameFormat &rCpy ) = delete;
389
391
393
395
396 SwDrawFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm,
397 SwFrameFormat *pDrvdFrame )
398 : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_DRAWFRMFMT ),
399 m_pSdrObjectCached(nullptr),
400 meLayoutDir( SwFrameFormat::HORI_L2R ),
401
402 mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ),
403
404 mbPosAttrSet( false )
405 {}
406
407public:
408 virtual ~SwDrawFrameFormat() override;
409
412 virtual void DelFrames() override;
413
416 virtual void MakeFrames() override;
417
418 virtual Graphic MakeGraphic( ImageMap* pMap = nullptr, const sal_uInt32 nMaximumQuadraticPixels = 500000, const std::optional<Size>& rTargetDPI = std::nullopt ) override;
419
420 virtual SwFrameFormat::tLayoutDir GetLayoutDir() const override;
421 virtual void SetLayoutDir( const SwFrameFormat::tLayoutDir _eLayoutDir ) override;
422
423 virtual sal_Int16 GetPositionLayoutDir() const override;
424 virtual void SetPositionLayoutDir( const sal_Int16 _nPositionLayoutDir ) override;
425
426 bool IsPosAttrSet() const { return mbPosAttrSet; }
427 void PosAttrSet() { mbPosAttrSet = true; }
428
429 virtual OUString GetDescription() const override;
430};
431
432namespace sw {
433
435
436void CheckAnchoredFlyConsistency(SwDoc const& rDoc);
437
438}
439
440#endif
441
442/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxHint & operator=(SfxHint const &)=default
wrapper class for the positioning of Writer fly frames and drawing objects
Definition: doc.hxx:195
ContactObject for connection of formats as representatives of draw objects in SwClient and the object...
Definition: dcontact.hxx:305
SwDrawFrameFormat & operator=(const SwDrawFrameFormat &rCpy)=delete
SwDrawFrameFormat(SwAttrPool &rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame)
Definition: frmfmt.hxx:396
const SdrObject * m_pSdrObjectCached
Definition: frmfmt.hxx:384
OUString m_sSdrObjectCachedComment
Definition: frmfmt.hxx:385
SwFrameFormat::tLayoutDir meLayoutDir
Definition: frmfmt.hxx:390
bool IsPosAttrSet() const
Definition: frmfmt.hxx:426
sal_Int16 mnPositionLayoutDir
Definition: frmfmt.hxx:392
void PosAttrSet()
Definition: frmfmt.hxx:427
SwDrawFrameFormat(const SwDrawFrameFormat &rCpy)=delete
ContactObject for connection between frames (or their formats respectively) in SwClient and the drawo...
Definition: dcontact.hxx:177
OUString msDesc
Definition: frmfmt.hxx:194
OUString msTitle
Definition: frmfmt.hxx:193
const Point & GetLastFlyFramePrtRectPos() const
Definition: frmfmt.hxx:255
Point m_aLastFlyFramePrtRectPos
Both not existent.
Definition: frmfmt.hxx:202
OUString msTooltip
A tooltip has priority over an SwFormatURL and is not persisted to files.
Definition: frmfmt.hxx:196
std::unique_ptr< SwFlyDrawContact > m_pContact
Definition: frmfmt.hxx:203
SwFlyFrameFormat & operator=(const SwFlyFrameFormat &rCpy)=delete
void SetLastFlyFramePrtRectPos(const Point &rPoint)
Definition: frmfmt.hxx:256
SwFlyFrameFormat(const SwFlyFrameFormat &rCpy)=delete
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
Base class for various Writer styles.
Definition: format.hxx:47
OUString m_aFormatName
Definition: format.hxx:50
Style of a layout element.
Definition: frmfmt.hxx:62
SAL_DLLPRIVATE css::uno::WeakReference< css::uno::XInterface > const & GetXObject() const
Definition: frmfmt.hxx:171
css::uno::WeakReference< css::uno::XInterface > m_wXObject
Definition: frmfmt.hxx:70
const SdrObject * FindRealSdrObject() const
Definition: frmfmt.hxx:151
SwFrameFormat(SwFrameFormat const &)=default
SwFrameFormat(SwFrameFormat &&)=default
void SetOtherTextBoxFormats(const std::shared_ptr< SwTextBoxNode > &rNew)
Definition: frmfmt.hxx:107
SwFrameFormats * m_ffList
Definition: frmfmt.hxx:76
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::uno::XInterface > const &xObject)
Definition: frmfmt.hxx:173
std::shared_ptr< SwTextBoxNode > m_pOtherTextBoxFormats
Definition: frmfmt.hxx:78
const std::shared_ptr< SwTextBoxNode > & GetOtherTextBoxFormats() const
Definition: frmfmt.hxx:106
const SdrObject * FindSdrObject() const
Definition: frmfmt.hxx:147
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:141
drawinglayer::attribute::SdrAllFillAttributesHelperPtr maFillAttributes
Definition: frmfmt.hxx:73
Specific frame formats (frames, DrawObjects).
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
The root element of a Writer document layout.
Definition: rootfrm.hxx:83
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:436
A TextBox is a TextFrame, that is tied to a drawinglayer shape.
struct _xmlTextWriter * xmlTextWriterPtr
virtual void GetDescription(OUString &rName) override
EmbeddedObjectRef * pObject
void MakeFrames(SwDoc *pDoc, SwNode &rSttIdx, SwNode &rEndIdx)
Definition: frmtool.cxx:2017
SfxHintId
@ SwCollectTextObjects
@ SwGetObjectConnected
@ SwRestoreFlyAnchor
@ SwCheckDrawFrameFormatLayer
@ SwDrawFormatLayoutCopy
@ SwContactChanged
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(165)
constexpr TypedWhichId< SwFrameFormat > RES_FRMFMT(161)
WhichRangesContainer const aFrameFormatSetRange(svl::Items< RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
def text(shape, orig_st)
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:41
Dialog to specify the properties of date form field.
DrawFrameFormatHintId
Definition: frmfmt.hxx:270
void CheckAnchoredFlyConsistency(SwDoc const &rDoc)
Definition: atrfrm.cxx:3675
bool IsFlyFrameFormatInHeader(const SwFrameFormat &rFormat)
Definition: atrfrm.cxx:3650
WW8AnchorConv
Definition: frmfmt.hxx:313
void operator()(SwFormat *pFormat)
Definition: frmfmt.hxx:83
const OUString & mName
Definition: frmfmt.hxx:84
change_name(const OUString &rName)
Definition: frmfmt.hxx:82
CheckDrawFrameFormatLayerHint(bool *bCheckControlLayer)
Definition: frmfmt.hxx:290
virtual ~CheckDrawFrameFormatLayerHint() override
Definition: atrfrm.cxx:3474
CollectTextObjectsHint(std::list< SdrTextObj * > &rTextObjects)
Definition: frmfmt.hxx:356
virtual ~CollectTextObjectsHint() override
Definition: atrfrm.cxx:3481
std::list< SdrTextObj * > & m_rTextObjects
Definition: frmfmt.hxx:355
ContactChangedHint(SdrObject **ppObject)
Definition: frmfmt.hxx:298
SdrObject ** m_ppObject
Definition: frmfmt.hxx:297
virtual ~ContactChangedHint() override
Definition: atrfrm.cxx:3475
SwDrawContact ** m_ppContact
Definition: frmfmt.hxx:347
CreatePortionHint(SwDrawContact **ppContact)
Definition: frmfmt.hxx:348
virtual ~CreatePortionHint() override
Definition: atrfrm.cxx:3479
virtual ~DrawFormatLayoutCopyHint() override
Definition: atrfrm.cxx:3476
SwDrawFrameFormat & m_rDestFormat
Definition: frmfmt.hxx:305
DrawFormatLayoutCopyHint(SwDrawFrameFormat &rDestFormat, SwDoc &rDestDoc)
Definition: frmfmt.hxx:307
DrawFrameFormatHintId m_eId
Definition: frmfmt.hxx:282
DrawFrameFormatHint(DrawFrameFormatHintId eId)
Definition: frmfmt.hxx:283
virtual ~DrawFrameFormatHint() override
Definition: atrfrm.cxx:3473
SdrObject *& m_rpObject
Definition: frmfmt.hxx:51
FindSdrObjectHint(SdrObject *&rpObject)
Definition: frmfmt.hxx:52
GetObjectConnectedHint(bool &risConnected, const SwRootFrame *pRoot)
Definition: frmfmt.hxx:373
virtual ~GetObjectConnectedHint() override
Definition: atrfrm.cxx:3483
const SwRootFrame * m_pRoot
Definition: frmfmt.hxx:372
sal_uInt32 & m_rnZOrder
Definition: frmfmt.hxx:363
GetZOrderHint(sal_uInt32 &rnZOrder)
Definition: frmfmt.hxx:364
virtual ~GetZOrderHint() override
Definition: atrfrm.cxx:3482
virtual ~RestoreFlyAnchorHint() override
Definition: atrfrm.cxx:3478
RestoreFlyAnchorHint(Point aPos)
Definition: frmfmt.hxx:340
WW8AnchorConvResult & m_rResult
Definition: frmfmt.hxx:331
WW8AnchorConvHint(WW8AnchorConvResult &rResult)
Definition: frmfmt.hxx:332
WW8AnchorConvResult(WW8AnchorConv eHoriConv, WW8AnchorConv eVertConv)
Definition: frmfmt.hxx:327
WW8AnchorConv m_eHoriConv
Definition: frmfmt.hxx:323
WW8AnchorConv m_eVertConv
Definition: frmfmt.hxx:324
#define SW_DLLPUBLIC
Definition: swdllapi.h:28