diff options
Diffstat (limited to 'sw/source/core/inc/frame.hxx')
-rw-r--r-- | sw/source/core/inc/frame.hxx | 71 |
1 files changed, 54 insertions, 17 deletions
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx index bf3ea789dd4d..a46a50bf8326 100644 --- a/sw/source/core/inc/frame.hxx +++ b/sw/source/core/inc/frame.hxx @@ -116,6 +116,58 @@ namespace drawinglayer { namespace attribute { typedef std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr; }} +/// Helper class to isolate gerometry-defining members of SwFrame +/// and to control their accesses. Moved to own class to have no +/// hidden accesses to 'private' members anymore +class SW_DLLPUBLIC SwFrameRect +{ +private: + SwRect maFrameRect; // absolute position in document and size of the Frame + SwRect maPrintRect; // position relatively to Frame and size of PrtArea + +public: + SwFrameRect(); + + // read accesses - only const access allowed. Do *not* const_cast results, + // it is necessary to track changes. use The 'set' methods instead + const SwRect& getSwFrame() const { return maFrameRect; } + const SwRect& getSwPrint() const { return maPrintRect; } + + // helper class(es) for FrameRect/PrintRect manipulation. These + // have to be used to apply changes. They hold a copy of the SwRect + // for manipulation, it gets written back at destruction. Thus this + // mechanism depends on scope usage, take care. It prevents errors using + // different instances of SwFrame in get/set methods which is more safe + class FrameWriteAccess : public SwRect + { + private: + SwFrameRect& mrTarget; + + FrameWriteAccess(const FrameWriteAccess&) = delete; + FrameWriteAccess& operator=(const FrameWriteAccess&) = delete; + + public: + FrameWriteAccess(SwFrameRect& rTarget) : SwRect(rTarget.getSwFrame()), mrTarget(rTarget) {} + ~FrameWriteAccess(); + void setSwRect(const SwRect& rNew) { *reinterpret_cast< SwRect* >(this) = rNew; } + }; + + // same for print + class PrintWriteAccess : public SwRect + { + private: + SwFrameRect& mrTarget; + + PrintWriteAccess(const PrintWriteAccess&) = delete; + PrintWriteAccess& operator=(const PrintWriteAccess&) = delete; + + public: + PrintWriteAccess(SwFrameRect& rTarget) : SwRect(rTarget.getSwPrint()), mrTarget(rTarget) {} + ~PrintWriteAccess(); + void setSwRect(const SwRect& rNew) { *reinterpret_cast< SwRect* >(this) = rNew; } + }; +}; + /** * Base class of the Writer layout elements. * @@ -123,7 +175,7 @@ namespace drawinglayer { namespace attribute { * level: pages, headers, footers, etc. (Inside a paragraph SwLinePortion * instances are used.) */ -class SW_DLLPUBLIC SwFrame: public SwClient, public SfxBroadcaster +class SW_DLLPUBLIC SwFrame : public SwFrameRect, public SwClient, public SfxBroadcaster { // the hidden Frame friend class SwFlowFrame; @@ -144,8 +196,6 @@ class SW_DLLPUBLIC SwFrame: public SwClient, public SfxBroadcaster // cache for (border) attributes static SwCache *mpCache; - bool mbInDtor; - // #i65250# // frame ID is now in general available - used for layout loop control static sal_uInt32 mnLastFrameId; @@ -225,12 +275,9 @@ class SW_DLLPUBLIC SwFrame: public SwClient, public SfxBroadcaster protected: SwSortedObjs* mpDrawObjs; // draw objects, can be 0 - - SwRect maFrame; // absolute position in document and size of the Frame - SwRect maPrt; // position relatively to Frame and size of PrtArea - SwFrameType mnFrameType; //Who am I? + bool mbInDtor : 1; bool mbReverse : 1; // Next line above/at the right side instead // under/at the left side of the previous line bool mbInvalidR2L : 1; @@ -548,10 +595,7 @@ public: virtual void Calc(vcl::RenderContext* pRenderContext) const; // here might be "formatted" inline void OptCalc() const; // here we assume (for optimization) that // the predecessors are already formatted - Point GetRelPos() const; - const SwRect &Frame() const { return maFrame; } - const SwRect &Prt() const { return maPrt; } // PaintArea is the area where content might be displayed. // The margin of a page or the space between columns belongs to it. @@ -560,13 +604,6 @@ public: // to the FrameArea except in case of negative Prt margins. const SwRect UnionFrame( bool bBorder = false ) const; - // HACK: Here we exceptionally allow direct access to members. - // This should not delude into changing those value randomly; it is the - // only option to circumvent compiler problems (same method with public - // and protected). - SwRect &Frame() { return maFrame; } - SwRect &Prt() { return maPrt; } - virtual Size ChgSize( const Size& aNewSize ); virtual void Cut() = 0; |