Bug Summary

File:home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx
Warning:line 254, column 47
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name vdraw.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -isystem /usr/include/libxml2 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D SW_DLLIMPLEMENTATION -D SWUI_DLL_NAME="libswuilo.so" -D SYSTEM_LIBXML -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/i18n -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/icu/source/common -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/sw/source/core/inc -I /home/maarten/src/libreoffice/core/sw/source/filter/inc -I /home/maarten/src/libreoffice/core/sw/source/uibase/inc -I /home/maarten/src/libreoffice/core/sw/inc -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/sw/sdi -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/sw/generated -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/oovbaapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx

/home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx

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 <svx/svdmodel.hxx>
21#include <svx/svdpage.hxx>
22#include <swmodule.hxx>
23#include <svtools/accessibilityoptions.hxx>
24#include <svx/svdpagv.hxx>
25#include <fmtanchr.hxx>
26#include <frmfmt.hxx>
27
28#include <svx/svdoutl.hxx>
29
30#include <drawdoc.hxx>
31#include <fesh.hxx>
32#include <pagefrm.hxx>
33#include <rootfrm.hxx>
34#include <viewimp.hxx>
35#include <dflyobj.hxx>
36#include <printdata.hxx>
37#include <dcontact.hxx>
38#include <dview.hxx>
39#include <flyfrm.hxx>
40#include <vcl/svapp.hxx>
41#include <vcl/settings.hxx>
42#include <vcl/canvastools.hxx>
43#include <sal/log.hxx>
44
45#include <basegfx/range/b2irectangle.hxx>
46
47#include <IDocumentDrawModelAccess.hxx>
48
49void SwViewShellImp::StartAction()
50{
51 if ( HasDrawView() )
52 {
53 CurrShell aCurr( GetShell() );
54 if ( dynamic_cast<const SwFEShell*>( m_pShell) != nullptr )
55 static_cast<SwFEShell*>(m_pShell)->HideChainMarker(); // might have changed
56 }
57}
58
59void SwViewShellImp::EndAction()
60{
61 if ( HasDrawView() )
62 {
63 CurrShell aCurr( GetShell() );
64 if ( dynamic_cast<const SwFEShell*>(m_pShell) != nullptr )
65 static_cast<SwFEShell*>(m_pShell)->SetChainMarker(); // might have changed
66 }
67}
68
69void SwViewShellImp::LockPaint()
70{
71 if ( HasDrawView() )
72 {
73 m_bResetHdlHiddenPaint = !GetDrawView()->areMarkHandlesHidden();
74 GetDrawView()->hideMarkHandles();
75 }
76 else
77 {
78 m_bResetHdlHiddenPaint = false;
79 }
80}
81
82void SwViewShellImp::UnlockPaint()
83{
84 if ( m_bResetHdlHiddenPaint )
85 GetDrawView()->showMarkHandles();
86}
87
88void SwViewShellImp::PaintLayer( const SdrLayerID _nLayerID,
89 SwPrintData const*const pPrintData,
90 SwPageFrame const& rPageFrame,
91 const SwRect& aPaintRect,
92 const Color* _pPageBackgrdColor,
93 const bool _bIsPageRightToLeft,
94 sdr::contact::ViewObjectContactRedirector* pRedirector )
95{
96 if ( !HasDrawView() )
97 return;
98
99 //change the draw mode in high contrast mode
100 OutputDevice* pOutDev = GetShell()->GetOut();
101 DrawModeFlags nOldDrawMode = pOutDev->GetDrawMode();
102 if( GetShell()->GetWin() &&
103 Application::GetSettings().GetStyleSettings().GetHighContrastMode() &&
104 (!GetShell()->IsPreview()||SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetAccessibilityOptions().GetIsForPagePreviews()))
105 {
106 pOutDev->SetDrawMode( nOldDrawMode | DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill |
107 DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient );
108 }
109
110 // For correct handling of accessibility, high contrast, the
111 // page background color is set as the background color at the
112 // outliner of the draw view. Only necessary for the layers
113 // hell and heaven
114 Color aOldOutlinerBackgrdColor;
115 // set default horizontal text direction on painting <hell> or
116 // <heaven>.
117 EEHorizontalTextDirection aOldEEHoriTextDir = EEHorizontalTextDirection::L2R;
118 const IDocumentDrawModelAccess& rIDDMA = GetShell()->getIDocumentDrawModelAccess();
119 if ( (_nLayerID == rIDDMA.GetHellId()) ||
120 (_nLayerID == rIDDMA.GetHeavenId()) )
121 {
122 OSL_ENSURE( _pPageBackgrdColor,do { if (true && (!(_pPageBackgrdColor))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx"
":" "123" ": "), "%s", "incorrect usage of SwViewShellImp::PaintLayer: pPageBackgrdColor have to be set for painting layer <hell> or <heaven>"
); } } while (false)
123 "incorrect usage of SwViewShellImp::PaintLayer: pPageBackgrdColor have to be set for painting layer <hell> or <heaven>")do { if (true && (!(_pPageBackgrdColor))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx"
":" "123" ": "), "%s", "incorrect usage of SwViewShellImp::PaintLayer: pPageBackgrdColor have to be set for painting layer <hell> or <heaven>"
); } } while (false)
;
124 if ( _pPageBackgrdColor )
125 {
126 aOldOutlinerBackgrdColor =
127 GetDrawView()->GetModel()->GetDrawOutliner().GetBackgroundColor();
128 GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( *_pPageBackgrdColor );
129 }
130
131 aOldEEHoriTextDir =
132 GetDrawView()->GetModel()->GetDrawOutliner().GetDefaultHorizontalTextDirection();
133 EEHorizontalTextDirection aEEHoriTextDirOfPage =
134 _bIsPageRightToLeft ? EEHorizontalTextDirection::R2L : EEHorizontalTextDirection::L2R;
135 GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aEEHoriTextDirOfPage );
136 }
137
138 pOutDev->Push( PushFlags::LINECOLOR );
139 if (pPrintData)
140 {
141 // hide drawings but not form controls (form controls are handled elsewhere)
142 SdrView &rSdrView = GetPageView()->GetView();
143 rSdrView.setHideDraw( !pPrintData->IsPrintDraw() );
144 }
145 basegfx::B2IRectangle const pageFrame = vcl::unotools::b2IRectangleFromRectangle(rPageFrame.getFrameArea().SVRect());
146 GetPageView()->DrawLayer(_nLayerID, pOutDev, pRedirector, aPaintRect.SVRect(), &pageFrame);
147 pOutDev->Pop();
148
149 // reset background color of the outliner & default horiz. text dir.
150 if ( (_nLayerID == rIDDMA.GetHellId()) ||
151 (_nLayerID == rIDDMA.GetHeavenId()) )
152 {
153 GetDrawView()->GetModel()->GetDrawOutliner().SetBackgroundColor( aOldOutlinerBackgrdColor );
154 GetDrawView()->GetModel()->GetDrawOutliner().SetDefaultHorizontalTextDirection( aOldEEHoriTextDir );
155 }
156
157 pOutDev->SetDrawMode( nOldDrawMode );
158
159}
160
161#define FUZZY_EDGE400 400
162
163bool SwViewShellImp::IsDragPossible( const Point &rPoint )
164{
165 if ( !HasDrawView() )
166 return false;
167
168 const SdrMarkList &rMrkList = GetDrawView()->GetMarkedObjectList();
169
170 if( !rMrkList.GetMarkCount() )
171 return false;
172
173 SdrObject *pO = rMrkList.GetMark(rMrkList.GetMarkCount()-1)->GetMarkedSdrObj();
174
175 SwRect aRect;
176 if( pO && ::CalcClipRect( pO, aRect, false ) )
177 {
178 SwRect aTmp;
179 ::CalcClipRect( pO, aTmp );
180 aRect.Union( aTmp );
181 }
182 else
183 aRect = GetShell()->GetLayout()->getFrameArea();
184
185 aRect.AddTop (- FUZZY_EDGE400 );
186 aRect.AddBottom( FUZZY_EDGE400 );
187 aRect.AddLeft (- FUZZY_EDGE400 );
188 aRect.AddRight ( FUZZY_EDGE400 );
189 return aRect.IsInside( rPoint );
190}
191
192void SwViewShellImp::NotifySizeChg( const Size &rNewSz )
193{
194 if ( !HasDrawView() )
1
Calling 'SwViewShellImp::HasDrawView'
11
Returning from 'SwViewShellImp::HasDrawView'
12
Taking false branch
195 return;
196
197 if ( GetPageView() )
13
Assuming the condition is false
14
Taking false branch
198 GetPageView()->GetPage()->SetSize( rNewSz );
199
200 // Limitation of the work area
201 const tools::Rectangle aDocRect( Point( DOCUMENTBORDER284, DOCUMENTBORDER284 ), rNewSz );
202 const tools::Rectangle &rOldWork = GetDrawView()->GetWorkArea();
203 bool bCheckDrawObjs = false;
204 if ( aDocRect != rOldWork )
15
Calling 'Rectangle::operator!='
18
Returning from 'Rectangle::operator!='
19
Taking true branch
205 {
206 if ( rOldWork.Bottom() > aDocRect.Bottom() || rOldWork.Right() > aDocRect.Right())
20
Assuming the condition is true
207 bCheckDrawObjs = true;
208 GetDrawView()->SetWorkArea( aDocRect );
209 }
210 if ( !bCheckDrawObjs
20.1
'bCheckDrawObjs' is true
20.1
'bCheckDrawObjs' is true
20.1
'bCheckDrawObjs' is true
20.1
'bCheckDrawObjs' is true
20.1
'bCheckDrawObjs' is true
20.1
'bCheckDrawObjs' is true
)
21
Taking false branch
211 return;
212
213 OSL_ENSURE( m_pShell->getIDocumentDrawModelAccess().GetDrawModel(), "NotifySizeChg without DrawModel" )do { if (true && (!(m_pShell->getIDocumentDrawModelAccess
().GetDrawModel()))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx"
":" "213" ": "), "%s", "NotifySizeChg without DrawModel"); }
} while (false)
;
22
Assuming the condition is false
23
Taking false branch
24
Loop condition is false. Exiting loop
214 SdrPage* pPage = m_pShell->getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 );
215 const size_t nObjs = pPage->GetObjCount();
216 for( size_t nObj = 0; nObj < nObjs; ++nObj )
25
Assuming 'nObj' is < 'nObjs'
26
Loop condition is true. Entering loop body
217 {
218 SdrObject *pObj = pPage->GetObj( nObj );
27
'pObj' initialized here
219 if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
28
Assuming pointer value is null
29
Taking true branch
220 {
221 // Objects not anchored to the frame, do not need to be adjusted
222 const SwContact *pCont = GetUserCall(pObj);
223 // this function might be called by the InsertDocument, when
224 // a PageDesc-Attribute is set on a node. Then the SdrObject
225 // must not have an UserCall.
226 if( !pCont || dynamic_cast<const SwDrawContact*>( pCont) == nullptr )
30
Assuming 'pCont' is non-null
31
Taking false branch
227 continue;
228
229 const SwFrame *pAnchor = static_cast<const SwDrawContact*>(pCont)->GetAnchorFrame();
230 if ( !pAnchor || pAnchor->IsInFly() || !pAnchor->isFrameAreaDefinitionValid() ||
32
Assuming 'pAnchor' is non-null
33
Calling 'SwFrame::IsInFly'
37
Returning from 'SwFrame::IsInFly'
38
Assuming the condition is false
39
Calling 'SwFrameAreaDefinition::isFrameAreaDefinitionValid'
43
Returning from 'SwFrameAreaDefinition::isFrameAreaDefinitionValid'
44
Assuming the condition is false
54
Taking false branch
231 !pAnchor->GetUpper() || !pAnchor->FindPageFrame() ||
45
Assuming the condition is false
46
Calling 'SwFrame::FindPageFrame'
52
Returning from 'SwFrame::FindPageFrame'
232 (RndStdIds::FLY_AS_CHAR == pCont->GetFormat()->GetAnchor().GetAnchorId()) )
53
Assuming the condition is false
233 {
234 continue;
235 }
236 else
237 {
238 // Actually this should never happen but currently layouting
239 // is broken. So don't move anchors, if the page is invalid.
240 // This should be turned into a DBG_ASSERT, once layouting is fixed!
241 const SwPageFrame *pPageFrame = pAnchor->FindPageFrame();
55
Calling 'SwFrame::FindPageFrame'
61
Returning from 'SwFrame::FindPageFrame'
242 if (!pPageFrame
61.1
'pPageFrame' is non-null
61.1
'pPageFrame' is non-null
61.1
'pPageFrame' is non-null
61.1
'pPageFrame' is non-null
61.1
'pPageFrame' is non-null
61.1
'pPageFrame' is non-null
|| pPageFrame->IsInvalid() ) {
62
Calling 'SwPageFrame::IsInvalid'
66
Returning from 'SwPageFrame::IsInvalid'
67
Assuming the condition is false
68
Taking false branch
243 SAL_WARN( "sw.core", "Trying to move anchor from invalid page - fix layouting!" )do { if (true) { switch (sal_detail_log_report(::SAL_DETAIL_LOG_LEVEL_WARN
, "sw.core")) { case SAL_DETAIL_LOG_ACTION_IGNORE: break; case
SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail::getResult
( ::sal::detail::StreamStart() << "Trying to move anchor from invalid page - fix layouting!"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx"
":" "243" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Trying to move anchor from invalid page - fix layouting!"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Trying to move anchor from invalid page - fix layouting!"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx"
":" "243" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "Trying to move anchor from invalid page - fix layouting!"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx"
":" "243" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "Trying to move anchor from invalid page - fix layouting!"
), 0); } else { ::std::ostringstream sal_detail_stream; sal_detail_stream
<< "Trying to move anchor from invalid page - fix layouting!"
; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("sw.core"
), ("/home/maarten/src/libreoffice/core/sw/source/core/view/vdraw.cxx"
":" "243" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
244 continue;
245 }
246 }
247
248 // no move for drawing objects in header/footer
249 if ( pAnchor->FindFooterOrHeader() )
69
Assuming the condition is false
70
Taking false branch
250 {
251 continue;
252 }
253
254 const tools::Rectangle aObjBound( pObj->GetCurrentBoundRect() );
71
Called C++ object pointer is null
255 if ( !aDocRect.IsInside( aObjBound ) )
256 {
257 Size aSz;
258 if ( aObjBound.Left() > aDocRect.Right() )
259 aSz.setWidth( (aDocRect.Right() - aObjBound.Left()) - MINFLY23 );
260 if ( aObjBound.Top() > aDocRect.Bottom() )
261 aSz.setHeight( (aDocRect.Bottom() - aObjBound.Top()) - MINFLY23 );
262 if ( aSz.Width() || aSz.Height() )
263 pObj->Move( aSz );
264
265 // Don't let large objects disappear to the top
266 aSz.setWidth(0);
267 aSz.setHeight(0);
268 if ( aObjBound.Right() < aDocRect.Left() )
269 aSz.setWidth( (aDocRect.Left() - aObjBound.Right()) + MINFLY23 );
270 if ( aObjBound.Bottom() < aDocRect.Top() )
271 aSz.setHeight( (aDocRect.Top() - aObjBound.Bottom()) + MINFLY23 );
272 if ( aSz.Width() || aSz.Height() )
273 pObj->Move( aSz );
274 }
275 }
276 }
277}
278
279/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/sw/source/core/inc/viewimp.hxx

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_SOURCE_CORE_INC_VIEWIMP_HXX
20#define INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
21
22#include <tools/color.hxx>
23#include <svx/svdtypes.hxx>
24#include <swrect.hxx>
25#include <vector>
26#include <memory>
27
28class OutputDevice;
29class SwViewShell;
30class SwFlyFrame;
31class SwViewOption;
32class SwRegionRects;
33class SwFrame;
34class SwLayAction;
35class SwLayIdle;
36class SwDrawView;
37class SdrPageView;
38class SwPageFrame;
39class SwAccessibleMap;
40class SdrObject;
41class Fraction;
42class SwPrintData;
43class SwPagePreviewLayout;
44struct PreviewPage;
45class SwTextFrame;
46// --> OD #i76669#
47namespace sdr::contact { class ViewObjectContactRedirector; }
48// <--
49
50class SwViewShellImp
51{
52 friend class SwViewShell;
53
54 friend class SwLayAction; // Lay- and IdleAction register and deregister
55 friend class SwLayIdle;
56
57 // for paint of page preview
58 friend class SwPagePreviewLayout;
59
60 SwViewShell *m_pShell; // If someone passes an Imp, but needs a SwViewShell, we
61 // keep a backlink here
62
63 std::unique_ptr<SwDrawView> m_pDrawView; // Our DrawView
64 SdrPageView *m_pSdrPageView; // Exactly one Page for our DrawView
65
66 SwPageFrame *m_pFirstVisiblePage; // Always points to the first visible Page
67 std::unique_ptr<SwRegionRects> m_pRegion; // Collector of Paintrects from the LayAction
68
69 SwLayAction *m_pLayAction; // Is set if an Action object exists
70 // Is registered by the SwLayAction ctor and deregistered by the dtor
71 SwLayIdle *m_pIdleAct; // The same as SwLayAction for SwLayIdle
72
73 /// note: the map is *uniquely* owned here - the shared_ptr is only
74 /// used so that SwAccessibleContext can check via weak_ptr that it's alive
75 std::shared_ptr<SwAccessibleMap> m_pAccessibleMap;
76
77 bool m_bFirstPageInvalid : 1; // Pointer to the first Page invalid?
78 bool m_bResetHdlHiddenPaint : 1; // Ditto
79 bool m_bSmoothUpdate : 1; // For SmoothScroll
80 bool m_bStopSmooth : 1;
81
82 sal_uInt16 m_nRestoreActions ; // Count for the Action that need to be restored (UNO)
83 SwRect m_aSmoothRect;
84
85 std::unique_ptr<SwPagePreviewLayout> m_pPagePreviewLayout;
86
87 void SetFirstVisPage(OutputDevice const * pRenderContext); // Recalculate the first visible Page
88
89 void StartAction(); // Show handle and hide
90 void EndAction(); // Called by SwViewShell::ImplXXXAction
91 void LockPaint(); // Ditto; called by SwViewShell::ImplLockPaint
92 void UnlockPaint();
93
94private:
95
96 SwAccessibleMap *CreateAccessibleMap();
97
98 /** invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
99
100 #i27138#
101 implementation for wrapper method
102 <SwViewShell::InvalidateAccessibleParaFlowRelation(..)>
103
104 @param _pFromTextFrame
105 input parameter - paragraph frame, for which the relation CONTENT_FLOWS_FROM
106 has to be invalidated.
107 If NULL, no CONTENT_FLOWS_FROM relation has to be invalidated
108
109 @param _pToTextFrame
110 input parameter - paragraph frame, for which the relation CONTENT_FLOWS_TO
111 has to be invalidated.
112 If NULL, no CONTENT_FLOWS_TO relation has to be invalidated
113 */
114 void InvalidateAccessibleParaFlowRelation_( const SwTextFrame* _pFromTextFrame,
115 const SwTextFrame* _pToTextFrame );
116
117 /** invalidate text selection for paragraphs
118
119 #i27301#
120 implementation for wrapper method
121 <SwViewShell::InvalidateAccessibleParaTextSelection(..)>
122 */
123 void InvalidateAccessibleParaTextSelection_();
124
125 /** invalidate attributes for paragraphs and paragraph's characters
126
127 #i88069#
128 implementation for wrapper method
129 <SwViewShell::InvalidateAccessibleParaAttrs(..)>
130 */
131 void InvalidateAccessibleParaAttrs_( const SwTextFrame& rTextFrame );
132
133public:
134 SwViewShellImp( SwViewShell * );
135 ~SwViewShellImp();
136 void Init( const SwViewOption * ); /// Only for SwViewShell::Init()
137
138 const SwViewShell *GetShell() const { return m_pShell; }
139 SwViewShell *GetShell() { return m_pShell; }
140
141 Color GetRetoucheColor() const;
142
143 /// Management of the first visible Page
144 const SwPageFrame *GetFirstVisPage(OutputDevice const * pRenderContext) const;
145 SwPageFrame *GetFirstVisPage(OutputDevice const * pRenderContext);
146 void SetFirstVisPageInvalid() { m_bFirstPageInvalid = true; }
147
148 bool AddPaintRect( const SwRect &rRect );
149 SwRegionRects *GetRegion() { return m_pRegion.get(); }
150 void DelRegion();
151
152 /// New Interface for StarView Drawing
153 bool HasDrawView() const { return nullptr != m_pDrawView; }
2
Calling 'operator!=<SwDrawView, std::default_delete<SwDrawView>>'
9
Returning from 'operator!=<SwDrawView, std::default_delete<SwDrawView>>'
10
Returning the value 1, which participates in a condition later
154 SwDrawView* GetDrawView() { return m_pDrawView.get(); }
155 const SwDrawView* GetDrawView() const { return m_pDrawView.get(); }
156 SdrPageView*GetPageView() { return m_pSdrPageView; }
157 const SdrPageView*GetPageView() const { return m_pSdrPageView; }
158 void MakeDrawView();
159
160 /**
161 * @param _pPageBackgrdColor for setting this color as the background color
162 * at the outliner of the draw view for painting layers "hell" and "heaven"
163 *
164 * @param _bIsPageRightToLeft for the horizontal text direction of the page
165 * in order to set the default horizontal text direction at the outliner of
166 * the draw view for painting layers "hell" and "heaven"
167 */
168 void PaintLayer( const SdrLayerID _nLayerID,
169 SwPrintData const*const pPrintData,
170 SwPageFrame const& rPageFrame,
171 const SwRect& _rRect,
172 const Color* _pPageBackgrdColor,
173 const bool _bIsPageRightToLeft,
174 sdr::contact::ViewObjectContactRedirector* pRedirector );
175
176 /**
177 * Is passed to the DrawEngine as a Link and decides what is painted
178 * or not and in what way
179 */
180
181 // Interface Drawing
182 bool IsDragPossible( const Point &rPoint );
183 void NotifySizeChg( const Size &rNewSz );
184
185 /// SS for the Lay-/IdleAction and relatives
186 bool IsAction() const { return m_pLayAction != nullptr; }
187 bool IsIdleAction() const { return m_pIdleAct != nullptr; }
188 SwLayAction &GetLayAction() { return *m_pLayAction; }
189 const SwLayAction &GetLayAction() const { return *m_pLayAction; }
190
191 /**
192 * If an Action is running we ask it to check whether it's time
193 * to enable the WaitCursor
194 */
195 void CheckWaitCursor();
196
197 /// Asks the LayAction if present
198 bool IsCalcLayoutProgress() const;
199
200 /**
201 * @returns true if a LayAction is running
202 *
203 * There we also set the Flag for ExpressionFields
204 */
205 bool IsUpdateExpFields();
206
207 void SetRestoreActions(sal_uInt16 nSet){m_nRestoreActions = nSet;}
208 sal_uInt16 GetRestoreActions() const{return m_nRestoreActions;}
209
210 void InitPagePreviewLayout();
211
212 SwPagePreviewLayout* PagePreviewLayout()
213 {
214 return m_pPagePreviewLayout.get();
215 }
216
217 /// Is this view accessible?
218 bool IsAccessible() const { return m_pAccessibleMap != nullptr; }
219
220 inline SwAccessibleMap& GetAccessibleMap();
221
222 /// Update (this) accessible view
223 void UpdateAccessible();
224
225 /// Remove a frame from the accessible view
226 void DisposeAccessible( const SwFrame *pFrame, const SdrObject *pObj,
227 bool bRecursive, bool bCanSkipInvisible );
228 inline void DisposeAccessibleFrame( const SwFrame *pFrame,
229 bool bRecursive = false );
230 inline void DisposeAccessibleObj( const SdrObject *pObj, bool bCanSkipInvisible );
231
232 /// Move a frame's position in the accessible view
233 void MoveAccessible( const SwFrame *pFrame, const SdrObject *pObj,
234 const SwRect& rOldFrame );
235 inline void MoveAccessibleFrame( const SwFrame *pFrame, const SwRect& rOldFrame );
236
237 /// Add a frame in the accessible view
238 inline void AddAccessibleFrame( const SwFrame *pFrame );
239
240 inline void AddAccessibleObj( const SdrObject *pObj );
241
242 /// Invalidate accessible frame's content
243 void InvalidateAccessibleFrameContent( const SwFrame *pFrame );
244
245 /// Invalidate accessible frame's cursor position
246 void InvalidateAccessibleCursorPosition( const SwFrame *pFrame );
247
248 /// Invalidate editable state for all accessible frames
249 void InvalidateAccessibleEditableState( bool bAllShells,
250 const SwFrame *pFrame=nullptr );
251
252 /// Invalidate frame's relation set (for chained frames)
253 void InvalidateAccessibleRelationSet( const SwFlyFrame *pMaster,
254 const SwFlyFrame *pFollow );
255
256 /// update data for accessible preview
257 /// change method signature due to new page preview functionality
258 void UpdateAccessiblePreview( const std::vector<std::unique_ptr<PreviewPage>>& _rPreviewPages,
259 const Fraction& _rScale,
260 const SwPageFrame* _pSelectedPageFrame,
261 const Size& _rPreviewWinSize );
262
263 void InvalidateAccessiblePreviewSelection( sal_uInt16 nSelPage );
264
265 /// Fire all accessible events that have been collected so far
266 void FireAccessibleEvents();
267};
268
269inline SwAccessibleMap& SwViewShellImp::GetAccessibleMap()
270{
271 if( !m_pAccessibleMap )
272 CreateAccessibleMap();
273
274 return *m_pAccessibleMap;
275}
276
277inline void SwViewShellImp::DisposeAccessibleFrame( const SwFrame *pFrame,
278 bool bRecursive )
279{
280 DisposeAccessible( pFrame, nullptr, bRecursive, true );
281}
282
283inline void SwViewShellImp::DisposeAccessibleObj( const SdrObject *pObj, bool bCanSkipInvisible )
284{
285 DisposeAccessible( nullptr, pObj, false, bCanSkipInvisible );
286}
287
288inline void SwViewShellImp::MoveAccessibleFrame( const SwFrame *pFrame,
289 const SwRect& rOldFrame )
290{
291 MoveAccessible( pFrame, nullptr, rOldFrame );
292}
293
294inline void SwViewShellImp::AddAccessibleFrame( const SwFrame *pFrame )
295{
296 SwRect aEmptyRect;
297 MoveAccessible( pFrame, nullptr, aEmptyRect );
298}
299
300inline void SwViewShellImp::AddAccessibleObj( const SdrObject *pObj )
301{
302 SwRect aEmptyRect;
303 MoveAccessible( nullptr, pObj, aEmptyRect );
304}
305#endif // INCLUDED_SW_SOURCE_CORE_INC_VIEWIMP_HXX
306
307/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/unique_ptr.h

1// unique_ptr implementation -*- C++ -*-
2
3// Copyright (C) 2008-2020 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file bits/unique_ptr.h
26 * This is an internal header file, included by other library headers.
27 * Do not attempt to use it directly. @headername{memory}
28 */
29
30#ifndef _UNIQUE_PTR_H1
31#define _UNIQUE_PTR_H1 1
32
33#include <bits/c++config.h>
34#include <debug/assertions.h>
35#include <type_traits>
36#include <utility>
37#include <tuple>
38#include <bits/stl_function.h>
39#include <bits/functional_hash.h>
40#if __cplusplus201703L > 201703L
41# include <compare>
42# include <ostream>
43#endif
44
45namespace std _GLIBCXX_VISIBILITY(default)__attribute__ ((__visibility__ ("default")))
46{
47_GLIBCXX_BEGIN_NAMESPACE_VERSION
48
49 /**
50 * @addtogroup pointer_abstractions
51 * @{
52 */
53
54#if _GLIBCXX_USE_DEPRECATED1
55#pragma GCC diagnostic push
56#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
57 template<typename> class auto_ptr;
58#pragma GCC diagnostic pop
59#endif
60
61 /// Primary template of default_delete, used by unique_ptr for single objects
62 template<typename _Tp>
63 struct default_delete
64 {
65 /// Default constructor
66 constexpr default_delete() noexcept = default;
67
68 /** @brief Converting constructor.
69 *
70 * Allows conversion from a deleter for objects of another type, `_Up`,
71 * only if `_Up*` is convertible to `_Tp*`.
72 */
73 template<typename _Up,
74 typename = _Require<is_convertible<_Up*, _Tp*>>>
75 default_delete(const default_delete<_Up>&) noexcept { }
76
77 /// Calls `delete __ptr`
78 void
79 operator()(_Tp* __ptr) const
80 {
81 static_assert(!is_void<_Tp>::value,
82 "can't delete pointer to incomplete type");
83 static_assert(sizeof(_Tp)>0,
84 "can't delete pointer to incomplete type");
85 delete __ptr;
86 }
87 };
88
89 // _GLIBCXX_RESOLVE_LIB_DEFECTS
90 // DR 740 - omit specialization for array objects with a compile time length
91
92 /// Specialization of default_delete for arrays, used by `unique_ptr<T[]>`
93 template<typename _Tp>
94 struct default_delete<_Tp[]>
95 {
96 public:
97 /// Default constructor
98 constexpr default_delete() noexcept = default;
99
100 /** @brief Converting constructor.
101 *
102 * Allows conversion from a deleter for arrays of another type, such as
103 * a const-qualified version of `_Tp`.
104 *
105 * Conversions from types derived from `_Tp` are not allowed because
106 * it is undefined to `delete[]` an array of derived types through a
107 * pointer to the base type.
108 */
109 template<typename _Up,
110 typename = _Require<is_convertible<_Up(*)[], _Tp(*)[]>>>
111 default_delete(const default_delete<_Up[]>&) noexcept { }
112
113 /// Calls `delete[] __ptr`
114 template<typename _Up>
115 typename enable_if<is_convertible<_Up(*)[], _Tp(*)[]>::value>::type
116 operator()(_Up* __ptr) const
117 {
118 static_assert(sizeof(_Tp)>0,
119 "can't delete pointer to incomplete type");
120 delete [] __ptr;
121 }
122 };
123
124 /// @cond undocumented
125
126 // Manages the pointer and deleter of a unique_ptr
127 template <typename _Tp, typename _Dp>
128 class __uniq_ptr_impl
129 {
130 template <typename _Up, typename _Ep, typename = void>
131 struct _Ptr
132 {
133 using type = _Up*;
134 };
135
136 template <typename _Up, typename _Ep>
137 struct
138 _Ptr<_Up, _Ep, __void_t<typename remove_reference<_Ep>::type::pointer>>
139 {
140 using type = typename remove_reference<_Ep>::type::pointer;
141 };
142
143 public:
144 using _DeleterConstraint = enable_if<
145 __and_<__not_<is_pointer<_Dp>>,
146 is_default_constructible<_Dp>>::value>;
147
148 using pointer = typename _Ptr<_Tp, _Dp>::type;
149
150 static_assert( !is_rvalue_reference<_Dp>::value,
151 "unique_ptr's deleter type must be a function object type"
152 " or an lvalue reference type" );
153
154 __uniq_ptr_impl() = default;
155 __uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
156
157 template<typename _Del>
158 __uniq_ptr_impl(pointer __p, _Del&& __d)
159 : _M_t(__p, std::forward<_Del>(__d)) { }
160
161 __uniq_ptr_impl(__uniq_ptr_impl&& __u) noexcept
162 : _M_t(std::move(__u._M_t))
163 { __u._M_ptr() = nullptr; }
164
165 __uniq_ptr_impl& operator=(__uniq_ptr_impl&& __u) noexcept
166 {
167 reset(__u.release());
168 _M_deleter() = std::forward<_Dp>(__u._M_deleter());
169 return *this;
170 }
171
172 pointer& _M_ptr() { return std::get<0>(_M_t); }
173 pointer _M_ptr() const { return std::get<0>(_M_t); }
174 _Dp& _M_deleter() { return std::get<1>(_M_t); }
175 const _Dp& _M_deleter() const { return std::get<1>(_M_t); }
176
177 void reset(pointer __p) noexcept
178 {
179 const pointer __old_p = _M_ptr();
180 _M_ptr() = __p;
181 if (__old_p)
182 _M_deleter()(__old_p);
183 }
184
185 pointer release() noexcept
186 {
187 pointer __p = _M_ptr();
188 _M_ptr() = nullptr;
189 return __p;
190 }
191
192 void
193 swap(__uniq_ptr_impl& __rhs) noexcept
194 {
195 using std::swap;
196 swap(this->_M_ptr(), __rhs._M_ptr());
197 swap(this->_M_deleter(), __rhs._M_deleter());
198 }
199
200 private:
201 tuple<pointer, _Dp> _M_t;
202 };
203
204 // Defines move construction + assignment as either defaulted or deleted.
205 template <typename _Tp, typename _Dp,
206 bool = is_move_constructible<_Dp>::value,
207 bool = is_move_assignable<_Dp>::value>
208 struct __uniq_ptr_data : __uniq_ptr_impl<_Tp, _Dp>
209 {
210 using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl;
211 __uniq_ptr_data(__uniq_ptr_data&&) = default;
212 __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default;
213 };
214
215 template <typename _Tp, typename _Dp>
216 struct __uniq_ptr_data<_Tp, _Dp, true, false> : __uniq_ptr_impl<_Tp, _Dp>
217 {
218 using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl;
219 __uniq_ptr_data(__uniq_ptr_data&&) = default;
220 __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete;
221 };
222
223 template <typename _Tp, typename _Dp>
224 struct __uniq_ptr_data<_Tp, _Dp, false, true> : __uniq_ptr_impl<_Tp, _Dp>
225 {
226 using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl;
227 __uniq_ptr_data(__uniq_ptr_data&&) = delete;
228 __uniq_ptr_data& operator=(__uniq_ptr_data&&) = default;
229 };
230
231 template <typename _Tp, typename _Dp>
232 struct __uniq_ptr_data<_Tp, _Dp, false, false> : __uniq_ptr_impl<_Tp, _Dp>
233 {
234 using __uniq_ptr_impl<_Tp, _Dp>::__uniq_ptr_impl;
235 __uniq_ptr_data(__uniq_ptr_data&&) = delete;
236 __uniq_ptr_data& operator=(__uniq_ptr_data&&) = delete;
237 };
238 /// @endcond
239
240 /// 20.7.1.2 unique_ptr for single objects.
241 template <typename _Tp, typename _Dp = default_delete<_Tp>>
242 class unique_ptr
243 {
244 template <typename _Up>
245 using _DeleterConstraint =
246 typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type;
247
248 __uniq_ptr_data<_Tp, _Dp> _M_t;
249
250 public:
251 using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer;
252 using element_type = _Tp;
253 using deleter_type = _Dp;
254
255 private:
256 // helper template for detecting a safe conversion from another
257 // unique_ptr
258 template<typename _Up, typename _Ep>
259 using __safe_conversion_up = __and_<
260 is_convertible<typename unique_ptr<_Up, _Ep>::pointer, pointer>,
261 __not_<is_array<_Up>>
262 >;
263
264 public:
265 // Constructors.
266
267 /// Default constructor, creates a unique_ptr that owns nothing.
268 template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>>
269 constexpr unique_ptr() noexcept
270 : _M_t()
271 { }
272
273 /** Takes ownership of a pointer.
274 *
275 * @param __p A pointer to an object of @c element_type
276 *
277 * The deleter will be value-initialized.
278 */
279 template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>>
280 explicit
281 unique_ptr(pointer __p) noexcept
282 : _M_t(__p)
283 { }
284
285 /** Takes ownership of a pointer.
286 *
287 * @param __p A pointer to an object of @c element_type
288 * @param __d A reference to a deleter.
289 *
290 * The deleter will be initialized with @p __d
291 */
292 template<typename _Del = deleter_type,
293 typename = _Require<is_copy_constructible<_Del>>>
294 unique_ptr(pointer __p, const deleter_type& __d) noexcept
295 : _M_t(__p, __d) { }
296
297 /** Takes ownership of a pointer.
298 *
299 * @param __p A pointer to an object of @c element_type
300 * @param __d An rvalue reference to a (non-reference) deleter.
301 *
302 * The deleter will be initialized with @p std::move(__d)
303 */
304 template<typename _Del = deleter_type,
305 typename = _Require<is_move_constructible<_Del>>>
306 unique_ptr(pointer __p,
307 __enable_if_t<!is_lvalue_reference<_Del>::value,
308 _Del&&> __d) noexcept
309 : _M_t(__p, std::move(__d))
310 { }
311
312 template<typename _Del = deleter_type,
313 typename _DelUnref = typename remove_reference<_Del>::type>
314 unique_ptr(pointer,
315 __enable_if_t<is_lvalue_reference<_Del>::value,
316 _DelUnref&&>) = delete;
317
318 /// Creates a unique_ptr that owns nothing.
319 template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>>
320 constexpr unique_ptr(nullptr_t) noexcept
321 : _M_t()
322 { }
323
324 // Move constructors.
325
326 /// Move constructor.
327 unique_ptr(unique_ptr&&) = default;
328
329 /** @brief Converting constructor from another type
330 *
331 * Requires that the pointer owned by @p __u is convertible to the
332 * type of pointer owned by this object, @p __u does not own an array,
333 * and @p __u has a compatible deleter type.
334 */
335 template<typename _Up, typename _Ep, typename = _Require<
336 __safe_conversion_up<_Up, _Ep>,
337 typename conditional<is_reference<_Dp>::value,
338 is_same<_Ep, _Dp>,
339 is_convertible<_Ep, _Dp>>::type>>
340 unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
341 : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter()))
342 { }
343
344#if _GLIBCXX_USE_DEPRECATED1
345#pragma GCC diagnostic push
346#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
347 /// Converting constructor from @c auto_ptr
348 template<typename _Up, typename = _Require<
349 is_convertible<_Up*, _Tp*>, is_same<_Dp, default_delete<_Tp>>>>
350 unique_ptr(auto_ptr<_Up>&& __u) noexcept;
351#pragma GCC diagnostic pop
352#endif
353
354 /// Destructor, invokes the deleter if the stored pointer is not null.
355 ~unique_ptr() noexcept
356 {
357 static_assert(__is_invocable<deleter_type&, pointer>::value,
358 "unique_ptr's deleter must be invocable with a pointer");
359 auto& __ptr = _M_t._M_ptr();
360 if (__ptr != nullptr)
361 get_deleter()(std::move(__ptr));
362 __ptr = pointer();
363 }
364
365 // Assignment.
366
367 /** @brief Move assignment operator.
368 *
369 * Invokes the deleter if this object owns a pointer.
370 */
371 unique_ptr& operator=(unique_ptr&&) = default;
372
373 /** @brief Assignment from another type.
374 *
375 * @param __u The object to transfer ownership from, which owns a
376 * convertible pointer to a non-array object.
377 *
378 * Invokes the deleter if this object owns a pointer.
379 */
380 template<typename _Up, typename _Ep>
381 typename enable_if< __and_<
382 __safe_conversion_up<_Up, _Ep>,
383 is_assignable<deleter_type&, _Ep&&>
384 >::value,
385 unique_ptr&>::type
386 operator=(unique_ptr<_Up, _Ep>&& __u) noexcept
387 {
388 reset(__u.release());
389 get_deleter() = std::forward<_Ep>(__u.get_deleter());
390 return *this;
391 }
392
393 /// Reset the %unique_ptr to empty, invoking the deleter if necessary.
394 unique_ptr&
395 operator=(nullptr_t) noexcept
396 {
397 reset();
398 return *this;
399 }
400
401 // Observers.
402
403 /// Dereference the stored pointer.
404 typename add_lvalue_reference<element_type>::type
405 operator*() const
406 {
407 __glibcxx_assert(get() != pointer());
408 return *get();
409 }
410
411 /// Return the stored pointer.
412 pointer
413 operator->() const noexcept
414 {
415 _GLIBCXX_DEBUG_PEDASSERT(get() != pointer());
416 return get();
417 }
418
419 /// Return the stored pointer.
420 pointer
421 get() const noexcept
422 { return _M_t._M_ptr(); }
423
424 /// Return a reference to the stored deleter.
425 deleter_type&
426 get_deleter() noexcept
427 { return _M_t._M_deleter(); }
428
429 /// Return a reference to the stored deleter.
430 const deleter_type&
431 get_deleter() const noexcept
432 { return _M_t._M_deleter(); }
433
434 /// Return @c true if the stored pointer is not null.
435 explicit operator bool() const noexcept
436 { return get() == pointer() ? false : true; }
4
Assuming the condition is false
5
'?' condition is false
6
Returning the value 1, which participates in a condition later
437
438 // Modifiers.
439
440 /// Release ownership of any stored pointer.
441 pointer
442 release() noexcept
443 { return _M_t.release(); }
444
445 /** @brief Replace the stored pointer.
446 *
447 * @param __p The new pointer to store.
448 *
449 * The deleter will be invoked if a pointer is already owned.
450 */
451 void
452 reset(pointer __p = pointer()) noexcept
453 {
454 static_assert(__is_invocable<deleter_type&, pointer>::value,
455 "unique_ptr's deleter must be invocable with a pointer");
456 _M_t.reset(std::move(__p));
457 }
458
459 /// Exchange the pointer and deleter with another object.
460 void
461 swap(unique_ptr& __u) noexcept
462 {
463 static_assert(__is_swappable<_Dp>::value, "deleter must be swappable");
464 _M_t.swap(__u._M_t);
465 }
466
467 // Disable copy from lvalue.
468 unique_ptr(const unique_ptr&) = delete;
469 unique_ptr& operator=(const unique_ptr&) = delete;
470 };
471
472 /// 20.7.1.3 unique_ptr for array objects with a runtime length
473 // [unique.ptr.runtime]
474 // _GLIBCXX_RESOLVE_LIB_DEFECTS
475 // DR 740 - omit specialization for array objects with a compile time length
476 template<typename _Tp, typename _Dp>
477 class unique_ptr<_Tp[], _Dp>
478 {
479 template <typename _Up>
480 using _DeleterConstraint =
481 typename __uniq_ptr_impl<_Tp, _Up>::_DeleterConstraint::type;
482
483 __uniq_ptr_data<_Tp, _Dp> _M_t;
484
485 template<typename _Up>
486 using __remove_cv = typename remove_cv<_Up>::type;
487
488 // like is_base_of<_Tp, _Up> but false if unqualified types are the same
489 template<typename _Up>
490 using __is_derived_Tp
491 = __and_< is_base_of<_Tp, _Up>,
492 __not_<is_same<__remove_cv<_Tp>, __remove_cv<_Up>>> >;
493
494 public:
495 using pointer = typename __uniq_ptr_impl<_Tp, _Dp>::pointer;
496 using element_type = _Tp;
497 using deleter_type = _Dp;
498
499 // helper template for detecting a safe conversion from another
500 // unique_ptr
501 template<typename _Up, typename _Ep,
502 typename _UPtr = unique_ptr<_Up, _Ep>,
503 typename _UP_pointer = typename _UPtr::pointer,
504 typename _UP_element_type = typename _UPtr::element_type>
505 using __safe_conversion_up = __and_<
506 is_array<_Up>,
507 is_same<pointer, element_type*>,
508 is_same<_UP_pointer, _UP_element_type*>,
509 is_convertible<_UP_element_type(*)[], element_type(*)[]>
510 >;
511
512 // helper template for detecting a safe conversion from a raw pointer
513 template<typename _Up>
514 using __safe_conversion_raw = __and_<
515 __or_<__or_<is_same<_Up, pointer>,
516 is_same<_Up, nullptr_t>>,
517 __and_<is_pointer<_Up>,
518 is_same<pointer, element_type*>,
519 is_convertible<
520 typename remove_pointer<_Up>::type(*)[],
521 element_type(*)[]>
522 >
523 >
524 >;
525
526 // Constructors.
527
528 /// Default constructor, creates a unique_ptr that owns nothing.
529 template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>>
530 constexpr unique_ptr() noexcept
531 : _M_t()
532 { }
533
534 /** Takes ownership of a pointer.
535 *
536 * @param __p A pointer to an array of a type safely convertible
537 * to an array of @c element_type
538 *
539 * The deleter will be value-initialized.
540 */
541 template<typename _Up,
542 typename _Vp = _Dp,
543 typename = _DeleterConstraint<_Vp>,
544 typename = typename enable_if<
545 __safe_conversion_raw<_Up>::value, bool>::type>
546 explicit
547 unique_ptr(_Up __p) noexcept
548 : _M_t(__p)
549 { }
550
551 /** Takes ownership of a pointer.
552 *
553 * @param __p A pointer to an array of a type safely convertible
554 * to an array of @c element_type
555 * @param __d A reference to a deleter.
556 *
557 * The deleter will be initialized with @p __d
558 */
559 template<typename _Up, typename _Del = deleter_type,
560 typename = _Require<__safe_conversion_raw<_Up>,
561 is_copy_constructible<_Del>>>
562 unique_ptr(_Up __p, const deleter_type& __d) noexcept
563 : _M_t(__p, __d) { }
564
565 /** Takes ownership of a pointer.
566 *
567 * @param __p A pointer to an array of a type safely convertible
568 * to an array of @c element_type
569 * @param __d A reference to a deleter.
570 *
571 * The deleter will be initialized with @p std::move(__d)
572 */
573 template<typename _Up, typename _Del = deleter_type,
574 typename = _Require<__safe_conversion_raw<_Up>,
575 is_move_constructible<_Del>>>
576 unique_ptr(_Up __p,
577 __enable_if_t<!is_lvalue_reference<_Del>::value,
578 _Del&&> __d) noexcept
579 : _M_t(std::move(__p), std::move(__d))
580 { }
581
582 template<typename _Up, typename _Del = deleter_type,
583 typename _DelUnref = typename remove_reference<_Del>::type,
584 typename = _Require<__safe_conversion_raw<_Up>>>
585 unique_ptr(_Up,
586 __enable_if_t<is_lvalue_reference<_Del>::value,
587 _DelUnref&&>) = delete;
588
589 /// Move constructor.
590 unique_ptr(unique_ptr&&) = default;
591
592 /// Creates a unique_ptr that owns nothing.
593 template<typename _Del = _Dp, typename = _DeleterConstraint<_Del>>
594 constexpr unique_ptr(nullptr_t) noexcept
595 : _M_t()
596 { }
597
598 template<typename _Up, typename _Ep, typename = _Require<
599 __safe_conversion_up<_Up, _Ep>,
600 typename conditional<is_reference<_Dp>::value,
601 is_same<_Ep, _Dp>,
602 is_convertible<_Ep, _Dp>>::type>>
603 unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
604 : _M_t(__u.release(), std::forward<_Ep>(__u.get_deleter()))
605 { }
606
607 /// Destructor, invokes the deleter if the stored pointer is not null.
608 ~unique_ptr()
609 {
610 auto& __ptr = _M_t._M_ptr();
611 if (__ptr != nullptr)
612 get_deleter()(__ptr);
613 __ptr = pointer();
614 }
615
616 // Assignment.
617
618 /** @brief Move assignment operator.
619 *
620 * Invokes the deleter if this object owns a pointer.
621 */
622 unique_ptr&
623 operator=(unique_ptr&&) = default;
624
625 /** @brief Assignment from another type.
626 *
627 * @param __u The object to transfer ownership from, which owns a
628 * convertible pointer to an array object.
629 *
630 * Invokes the deleter if this object owns a pointer.
631 */
632 template<typename _Up, typename _Ep>
633 typename
634 enable_if<__and_<__safe_conversion_up<_Up, _Ep>,
635 is_assignable<deleter_type&, _Ep&&>
636 >::value,
637 unique_ptr&>::type
638 operator=(unique_ptr<_Up, _Ep>&& __u) noexcept
639 {
640 reset(__u.release());
641 get_deleter() = std::forward<_Ep>(__u.get_deleter());
642 return *this;
643 }
644
645 /// Reset the %unique_ptr to empty, invoking the deleter if necessary.
646 unique_ptr&
647 operator=(nullptr_t) noexcept
648 {
649 reset();
650 return *this;
651 }
652
653 // Observers.
654
655 /// Access an element of owned array.
656 typename std::add_lvalue_reference<element_type>::type
657 operator[](size_t __i) const
658 {
659 __glibcxx_assert(get() != pointer());
660 return get()[__i];
661 }
662
663 /// Return the stored pointer.
664 pointer
665 get() const noexcept
666 { return _M_t._M_ptr(); }
667
668 /// Return a reference to the stored deleter.
669 deleter_type&
670 get_deleter() noexcept
671 { return _M_t._M_deleter(); }
672
673 /// Return a reference to the stored deleter.
674 const deleter_type&
675 get_deleter() const noexcept
676 { return _M_t._M_deleter(); }
677
678 /// Return @c true if the stored pointer is not null.
679 explicit operator bool() const noexcept
680 { return get() == pointer() ? false : true; }
681
682 // Modifiers.
683
684 /// Release ownership of any stored pointer.
685 pointer
686 release() noexcept
687 { return _M_t.release(); }
688
689 /** @brief Replace the stored pointer.
690 *
691 * @param __p The new pointer to store.
692 *
693 * The deleter will be invoked if a pointer is already owned.
694 */
695 template <typename _Up,
696 typename = _Require<
697 __or_<is_same<_Up, pointer>,
698 __and_<is_same<pointer, element_type*>,
699 is_pointer<_Up>,
700 is_convertible<
701 typename remove_pointer<_Up>::type(*)[],
702 element_type(*)[]
703 >
704 >
705 >
706 >>
707 void
708 reset(_Up __p) noexcept
709 { _M_t.reset(std::move(__p)); }
710
711 void reset(nullptr_t = nullptr) noexcept
712 { reset(pointer()); }
713
714 /// Exchange the pointer and deleter with another object.
715 void
716 swap(unique_ptr& __u) noexcept
717 {
718 static_assert(__is_swappable<_Dp>::value, "deleter must be swappable");
719 _M_t.swap(__u._M_t);
720 }
721
722 // Disable copy from lvalue.
723 unique_ptr(const unique_ptr&) = delete;
724 unique_ptr& operator=(const unique_ptr&) = delete;
725 };
726
727 /// @relates unique_ptr @{
728
729 /// Swap overload for unique_ptr
730 template<typename _Tp, typename _Dp>
731 inline
732#if __cplusplus201703L > 201402L || !defined(__STRICT_ANSI__1) // c++1z or gnu++11
733 // Constrained free swap overload, see p0185r1
734 typename enable_if<__is_swappable<_Dp>::value>::type
735#else
736 void
737#endif
738 swap(unique_ptr<_Tp, _Dp>& __x,
739 unique_ptr<_Tp, _Dp>& __y) noexcept
740 { __x.swap(__y); }
741
742#if __cplusplus201703L > 201402L || !defined(__STRICT_ANSI__1) // c++1z or gnu++11
743 template<typename _Tp, typename _Dp>
744 typename enable_if<!__is_swappable<_Dp>::value>::type
745 swap(unique_ptr<_Tp, _Dp>&,
746 unique_ptr<_Tp, _Dp>&) = delete;
747#endif
748
749 /// Equality operator for unique_ptr objects, compares the owned pointers
750 template<typename _Tp, typename _Dp,
751 typename _Up, typename _Ep>
752 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
753 operator==(const unique_ptr<_Tp, _Dp>& __x,
754 const unique_ptr<_Up, _Ep>& __y)
755 { return __x.get() == __y.get(); }
756
757 /// unique_ptr comparison with nullptr
758 template<typename _Tp, typename _Dp>
759 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
760 operator==(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept
761 { return !__x; }
762
763#ifndef __cpp_lib_three_way_comparison
764 /// unique_ptr comparison with nullptr
765 template<typename _Tp, typename _Dp>
766 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
767 operator==(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept
768 { return !__x; }
769
770 /// Inequality operator for unique_ptr objects, compares the owned pointers
771 template<typename _Tp, typename _Dp,
772 typename _Up, typename _Ep>
773 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
774 operator!=(const unique_ptr<_Tp, _Dp>& __x,
775 const unique_ptr<_Up, _Ep>& __y)
776 { return __x.get() != __y.get(); }
777
778 /// unique_ptr comparison with nullptr
779 template<typename _Tp, typename _Dp>
780 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
781 operator!=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t) noexcept
782 { return (bool)__x; }
783
784 /// unique_ptr comparison with nullptr
785 template<typename _Tp, typename _Dp>
786 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
787 operator!=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x) noexcept
788 { return (bool)__x; }
3
Calling 'unique_ptr::operator bool'
7
Returning from 'unique_ptr::operator bool'
8
Returning the value 1, which participates in a condition later
789#endif // three way comparison
790
791 /// Relational operator for unique_ptr objects, compares the owned pointers
792 template<typename _Tp, typename _Dp,
793 typename _Up, typename _Ep>
794 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
795 operator<(const unique_ptr<_Tp, _Dp>& __x,
796 const unique_ptr<_Up, _Ep>& __y)
797 {
798 typedef typename
799 std::common_type<typename unique_ptr<_Tp, _Dp>::pointer,
800 typename unique_ptr<_Up, _Ep>::pointer>::type _CT;
801 return std::less<_CT>()(__x.get(), __y.get());
802 }
803
804 /// unique_ptr comparison with nullptr
805 template<typename _Tp, typename _Dp>
806 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
807 operator<(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
808 {
809 return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(),
810 nullptr);
811 }
812
813 /// unique_ptr comparison with nullptr
814 template<typename _Tp, typename _Dp>
815 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
816 operator<(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
817 {
818 return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr,
819 __x.get());
820 }
821
822 /// Relational operator for unique_ptr objects, compares the owned pointers
823 template<typename _Tp, typename _Dp,
824 typename _Up, typename _Ep>
825 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
826 operator<=(const unique_ptr<_Tp, _Dp>& __x,
827 const unique_ptr<_Up, _Ep>& __y)
828 { return !(__y < __x); }
829
830 /// unique_ptr comparison with nullptr
831 template<typename _Tp, typename _Dp>
832 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
833 operator<=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
834 { return !(nullptr < __x); }
835
836 /// unique_ptr comparison with nullptr
837 template<typename _Tp, typename _Dp>
838 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
839 operator<=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
840 { return !(__x < nullptr); }
841
842 /// Relational operator for unique_ptr objects, compares the owned pointers
843 template<typename _Tp, typename _Dp,
844 typename _Up, typename _Ep>
845 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
846 operator>(const unique_ptr<_Tp, _Dp>& __x,
847 const unique_ptr<_Up, _Ep>& __y)
848 { return (__y < __x); }
849
850 /// unique_ptr comparison with nullptr
851 template<typename _Tp, typename _Dp>
852 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
853 operator>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
854 {
855 return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(nullptr,
856 __x.get());
857 }
858
859 /// unique_ptr comparison with nullptr
860 template<typename _Tp, typename _Dp>
861 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
862 operator>(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
863 {
864 return std::less<typename unique_ptr<_Tp, _Dp>::pointer>()(__x.get(),
865 nullptr);
866 }
867
868 /// Relational operator for unique_ptr objects, compares the owned pointers
869 template<typename _Tp, typename _Dp,
870 typename _Up, typename _Ep>
871 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
872 operator>=(const unique_ptr<_Tp, _Dp>& __x,
873 const unique_ptr<_Up, _Ep>& __y)
874 { return !(__x < __y); }
875
876 /// unique_ptr comparison with nullptr
877 template<typename _Tp, typename _Dp>
878 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
879 operator>=(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
880 { return !(__x < nullptr); }
881
882 /// unique_ptr comparison with nullptr
883 template<typename _Tp, typename _Dp>
884 _GLIBCXX_NODISCARD[[__nodiscard__]] inline bool
885 operator>=(nullptr_t, const unique_ptr<_Tp, _Dp>& __x)
886 { return !(nullptr < __x); }
887
888#ifdef __cpp_lib_three_way_comparison
889 template<typename _Tp, typename _Dp, typename _Up, typename _Ep>
890 requires three_way_comparable_with<typename unique_ptr<_Tp, _Dp>::pointer,
891 typename unique_ptr<_Up, _Ep>::pointer>
892 inline
893 compare_three_way_result_t<typename unique_ptr<_Tp, _Dp>::pointer,
894 typename unique_ptr<_Up, _Ep>::pointer>
895 operator<=>(const unique_ptr<_Tp, _Dp>& __x,
896 const unique_ptr<_Up, _Ep>& __y)
897 { return compare_three_way()(__x.get(), __y.get()); }
898
899 template<typename _Tp, typename _Dp>
900 requires three_way_comparable<typename unique_ptr<_Tp, _Dp>::pointer>
901 inline
902 compare_three_way_result_t<typename unique_ptr<_Tp, _Dp>::pointer>
903 operator<=>(const unique_ptr<_Tp, _Dp>& __x, nullptr_t)
904 {
905 using pointer = typename unique_ptr<_Tp, _Dp>::pointer;
906 return compare_three_way()(__x.get(), static_cast<pointer>(nullptr));
907 }
908#endif
909 // @} relates unique_ptr
910
911 /// @cond undocumented
912 template<typename _Up, typename _Ptr = typename _Up::pointer,
913 bool = __poison_hash<_Ptr>::__enable_hash_call>
914 struct __uniq_ptr_hash
915#if ! _GLIBCXX_INLINE_VERSION0
916 : private __poison_hash<_Ptr>
917#endif
918 {
919 size_t
920 operator()(const _Up& __u) const
921 noexcept(noexcept(std::declval<hash<_Ptr>>()(std::declval<_Ptr>())))
922 { return hash<_Ptr>()(__u.get()); }
923 };
924
925 template<typename _Up, typename _Ptr>
926 struct __uniq_ptr_hash<_Up, _Ptr, false>
927 : private __poison_hash<_Ptr>
928 { };
929 /// @endcond
930
931 /// std::hash specialization for unique_ptr.
932 template<typename _Tp, typename _Dp>
933 struct hash<unique_ptr<_Tp, _Dp>>
934 : public __hash_base<size_t, unique_ptr<_Tp, _Dp>>,
935 public __uniq_ptr_hash<unique_ptr<_Tp, _Dp>>
936 { };
937
938#if __cplusplus201703L >= 201402L
939 /// @relates unique_ptr @{
940#define __cpp_lib_make_unique201304 201304
941
942 /// @cond undocumented
943
944 template<typename _Tp>
945 struct _MakeUniq
946 { typedef unique_ptr<_Tp> __single_object; };
947
948 template<typename _Tp>
949 struct _MakeUniq<_Tp[]>
950 { typedef unique_ptr<_Tp[]> __array; };
951
952 template<typename _Tp, size_t _Bound>
953 struct _MakeUniq<_Tp[_Bound]>
954 { struct __invalid_type { }; };
955
956 /// @endcond
957
958 /// std::make_unique for single objects
959 template<typename _Tp, typename... _Args>
960 inline typename _MakeUniq<_Tp>::__single_object
961 make_unique(_Args&&... __args)
962 { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
963
964 /// std::make_unique for arrays of unknown bound
965 template<typename _Tp>
966 inline typename _MakeUniq<_Tp>::__array
967 make_unique(size_t __num)
968 { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); }
969
970 /// Disable std::make_unique for arrays of known bound
971 template<typename _Tp, typename... _Args>
972 inline typename _MakeUniq<_Tp>::__invalid_type
973 make_unique(_Args&&...) = delete;
974 // @} relates unique_ptr
975#endif // C++14
976
977#if __cplusplus201703L > 201703L && __cpp_concepts
978 // _GLIBCXX_RESOLVE_LIB_DEFECTS
979 // 2948. unique_ptr does not define operator<< for stream output
980 /// Stream output operator for unique_ptr
981 template<typename _CharT, typename _Traits, typename _Tp, typename _Dp>
982 inline basic_ostream<_CharT, _Traits>&
983 operator<<(basic_ostream<_CharT, _Traits>& __os,
984 const unique_ptr<_Tp, _Dp>& __p)
985 requires requires { __os << __p.get(); }
986 {
987 __os << __p.get();
988 return __os;
989 }
990#endif // C++20
991
992 // @} group pointer_abstractions
993
994#if __cplusplus201703L >= 201703L
995 namespace __detail::__variant
996 {
997 template<typename> struct _Never_valueless_alt; // see <variant>
998
999 // Provide the strong exception-safety guarantee when emplacing a
1000 // unique_ptr into a variant.
1001 template<typename _Tp, typename _Del>
1002 struct _Never_valueless_alt<std::unique_ptr<_Tp, _Del>>
1003 : std::true_type
1004 { };
1005 } // namespace __detail::__variant
1006#endif // C++17
1007
1008_GLIBCXX_END_NAMESPACE_VERSION
1009} // namespace
1010
1011#endif /* _UNIQUE_PTR_H */

/home/maarten/src/libreoffice/core/include/tools/gen.hxx

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_TOOLS_GEN_HXX
20#define INCLUDED_TOOLS_GEN_HXX
21
22#include <tools/toolsdllapi.h>
23
24#include <limits.h>
25#include <algorithm>
26#include <ostream>
27#include <config_options.h>
28
29class SvStream;
30namespace rtl
31{
32 class OString;
33}
34
35enum TriState { TRISTATE_FALSE, TRISTATE_TRUE, TRISTATE_INDET };
36
37// Pair
38
39class SAL_WARN_UNUSED__attribute__((warn_unused)) Pair
40{
41public:
42 Pair() : nA(0), nB(0) {}
43 Pair( long _nA, long _nB ) : nA(_nA), nB(_nB) {}
44
45 long A() const { return nA; }
46 long B() const { return nB; }
47
48 long& A() { return nA; }
49 long& B() { return nB; }
50
51 TOOLS_DLLPUBLIC__attribute__ ((visibility("default"))) rtl::OString toString() const;
52
53protected:
54 long nA;
55 long nB;
56};
57
58namespace tools::detail {
59
60// Used to implement operator == for subclasses of Pair:
61inline bool equal(Pair const & p1, Pair const & p2)
62{
63 return p1.A() == p2.A() && p1.B() == p2.B();
64}
65
66}
67
68// Point
69
70class Size;
71class SAL_WARN_UNUSED__attribute__((warn_unused)) UNLESS_MERGELIBS(SAL_DLLPUBLIC_EXPORT)__attribute__ ((visibility("default"))) Point final : protected Pair
72{
73public:
74 Point() {}
75 Point( long nX, long nY ) : Pair( nX, nY ) {}
76
77 long X() const { return nA; }
78 long Y() const { return nB; }
79
80 void Move( long nHorzMove, long nVertMove );
81 void Move( Size const & s );
82 long AdjustX( long nHorzMove ) { nA += nHorzMove; return nA; }
83 long AdjustY( long nVertMove ) { nB += nVertMove; return nB; }
84
85 void RotateAround( long& rX, long& rY, short nOrientation ) const;
86 void RotateAround( Point&, short nOrientation ) const;
87
88 Point& operator += ( const Point& rPoint );
89 Point& operator -= ( const Point& rPoint );
90 Point& operator *= ( const long nVal );
91 Point& operator /= ( const long nVal );
92
93 friend inline Point operator+( const Point &rVal1, const Point &rVal2 );
94 friend inline Point operator-( const Point &rVal1, const Point &rVal2 );
95 friend inline Point operator*( const Point &rVal1, const long nVal2 );
96 friend inline Point operator/( const Point &rVal1, const long nVal2 );
97
98 long getX() const { return X(); }
99 long getY() const { return Y(); }
100 void setX(long nX) { nA = nX; }
101 void setY(long nY) { nB = nY; }
102
103 Pair const & toPair() const { return *this; }
104 Pair & toPair() { return *this; }
105
106 using Pair::toString;
107};
108
109inline void Point::Move( long nHorzMove, long nVertMove )
110{
111 nA += nHorzMove;
112 nB += nVertMove;
113}
114
115inline Point& Point::operator += ( const Point& rPoint )
116{
117 nA += rPoint.nA;
118 nB += rPoint.nB;
119 return *this;
120}
121
122inline Point& Point::operator -= ( const Point& rPoint )
123{
124 nA -= rPoint.nA;
125 nB -= rPoint.nB;
126 return *this;
127}
128
129inline Point& Point::operator *= ( const long nVal )
130{
131 nA *= nVal;
132 nB *= nVal;
133 return *this;
134}
135
136inline Point& Point::operator /= ( const long nVal )
137{
138 nA /= nVal;
139 nB /= nVal;
140 return *this;
141}
142
143inline Point operator+( const Point &rVal1, const Point &rVal2 )
144{
145 return Point( rVal1.nA+rVal2.nA, rVal1.nB+rVal2.nB );
146}
147
148inline Point operator-( const Point &rVal1, const Point &rVal2 )
149{
150 return Point( rVal1.nA-rVal2.nA, rVal1.nB-rVal2.nB );
151}
152
153inline Point operator*( const Point &rVal1, const long nVal2 )
154{
155 return Point( rVal1.nA*nVal2, rVal1.nB*nVal2 );
156}
157
158inline Point operator/( const Point &rVal1, const long nVal2 )
159{
160 return Point( rVal1.nA/nVal2, rVal1.nB/nVal2 );
161}
162
163inline bool operator ==(Point const & p1, Point const & p2)
164{
165 return tools::detail::equal(p1.toPair(), p2.toPair());
166}
167
168inline bool operator !=(Point const & p1, Point const & p2)
169{
170 return !(p1 == p2);
171}
172
173template< typename charT, typename traits >
174inline std::basic_ostream<charT, traits> & operator <<(
175 std::basic_ostream<charT, traits> & stream, const Point& point )
176{
177 return stream << point.X() << ',' << point.Y();
178}
179
180// Size
181
182class SAL_WARN_UNUSED__attribute__((warn_unused)) Size final : protected Pair
183{
184public:
185 Size() {}
186 Size( long nWidth, long nHeight ) : Pair( nWidth, nHeight ) {}
187
188 long Width() const { return nA; }
189 long Height() const { return nB; }
190
191 long AdjustWidth( long n ) { nA += n; return nA; }
192 long AdjustHeight( long n ) { nB += n; return nB; }
193
194 long getWidth() const { return Width(); }
195 long getHeight() const { return Height(); }
196 void setWidth(long nWidth) { nA = nWidth; }
197 void setHeight(long nHeight) { nB = nHeight; }
198
199 bool IsEmpty() const { return nA <= 0 || nB <= 0; }
200
201 void extendBy(long x, long y)
202 {
203 nA += x;
204 nB += y;
205 }
206
207 Pair const & toPair() const { return *this; }
208 Pair & toPair() { return *this; }
209
210 using Pair::toString;
211};
212
213inline bool operator ==(Size const & s1, Size const & s2)
214{
215 return tools::detail::equal(s1.toPair(), s2.toPair());
216}
217
218inline bool operator !=(Size const & s1, Size const & s2)
219{
220 return !(s1 == s2);
221}
222
223template< typename charT, typename traits >
224inline std::basic_ostream<charT, traits> & operator <<(
225 std::basic_ostream<charT, traits> & stream, const Size& size )
226{
227 return stream << size.Width() << 'x' << size.Height();
228}
229
230inline void Point::Move( Size const & s )
231{
232 AdjustX(s.Width());
233 AdjustY(s.Height());
234}
235
236// Range
237
238#define RANGE_MAX9223372036854775807L LONG_MAX9223372036854775807L
239
240class SAL_WARN_UNUSED__attribute__((warn_unused)) Range final : protected Pair
241{
242public:
243 Range() {}
244 Range( long nMin, long nMax ) : Pair( nMin, nMax ) {}
245
246 long Min() const { return nA; }
247 long Max() const { return nB; }
248 long Len() const { return nB - nA + 1; }
249
250 long& Min() { return nA; }
251 long& Max() { return nB; }
252
253 bool IsInside( long nIs ) const;
254
255 void Justify();
256
257 Pair const & toPair() const { return *this; }
258 Pair & toPair() { return *this; }
259
260 using Pair::toString;
261};
262
263inline bool Range::IsInside( long nIs ) const
264{
265 return ((nA <= nIs) && (nIs <= nB ));
266}
267
268inline void Range::Justify()
269{
270 if ( nA > nB )
271 {
272 long nHelp = nA;
273 nA = nB;
274 nB = nHelp;
275 }
276}
277
278inline bool operator ==(Range const & r1, Range const & r2)
279{
280 return tools::detail::equal(r1.toPair(), r2.toPair());
281}
282
283inline bool operator !=(Range const & r1, Range const & r2)
284{
285 return !(r1 == r2);
286}
287
288template< typename charT, typename traits >
289inline std::basic_ostream<charT, traits> & operator <<(
290 std::basic_ostream<charT, traits> & stream, const Range& range )
291{
292 return stream << range.Min() << '-' << range.Max();
293}
294
295// Selection
296
297#define SELECTION_MIN(-9223372036854775807L -1L) LONG_MIN(-9223372036854775807L -1L)
298#define SELECTION_MAX9223372036854775807L LONG_MAX9223372036854775807L
299
300class SAL_WARN_UNUSED__attribute__((warn_unused)) Selection final : protected Pair
301{
302public:
303 Selection() {}
304 Selection( long nPos ) : Pair( nPos, nPos ) {}
305 Selection( long nMin, long nMax ) : Pair( nMin, nMax ) {}
306
307 long Min() const { return nA; }
308 long Max() const { return nB; }
309 long Len() const { return nB - nA; }
310
311 long& Min() { return nA; }
312 long& Max() { return nB; }
313
314 bool IsInside( long nIs ) const;
315
316 void Justify();
317
318 bool operator !() const { return !Len(); }
319
320 long getMin() const { return Min(); }
321 void setMin(long nMin) { Min() = nMin; }
322 void setMax(long nMax) { Max() = nMax; }
323
324 Pair const & toPair() const { return *this; }
325 Pair & toPair() { return *this; }
326
327 using Pair::toString;
328};
329
330inline bool Selection::IsInside( long nIs ) const
331{
332 return ((nA <= nIs) && (nIs < nB ));
333}
334
335inline void Selection::Justify()
336{
337 if ( nA > nB )
338 {
339 long nHelp = nA;
340 nA = nB;
341 nB = nHelp;
342 }
343}
344
345inline bool operator ==(Selection const & s1, Selection const & s2)
346{
347 return tools::detail::equal(s1.toPair(), s2.toPair());
348}
349
350inline bool operator !=(Selection const & s1, Selection const & s2)
351{
352 return !(s1 == s2);
353}
354
355template< typename charT, typename traits >
356inline std::basic_ostream<charT, traits> & operator <<(
357 std::basic_ostream<charT, traits> & stream, const Selection& selection )
358{
359 return stream << selection.Min() << '-' << selection.Max();
360}
361// Rectangle
362
363#define RECT_MAX9223372036854775807L LONG_MAX9223372036854775807L
364#define RECT_MIN(-9223372036854775807L -1L) LONG_MIN(-9223372036854775807L -1L)
365
366/// Note: this class is a true marvel of engineering: because the author
367/// could not decide whether it's better to have a closed or half-open
368/// interval, they just implemented *both* in the same class!
369///
370/// If you have the misfortune of having to use this class, don't immediately
371/// despair but first take note that the uppercase GetWidth() / GetHeight()
372/// etc. methods interpret the interval as closed, while the lowercase
373/// getWidth() / getHeight() etc. methods interpret the interval as half-open.
374/// Ok, now is the time for despair.
375namespace tools
376{
377class SAL_WARN_UNUSED__attribute__((warn_unused)) TOOLS_DLLPUBLIC__attribute__ ((visibility("default"))) Rectangle final
378{
379 static constexpr short RECT_EMPTY = -32767;
380public:
381 Rectangle();
382 Rectangle( const Point& rLT, const Point& rRB );
383 Rectangle( long nLeft, long nTop,
384 long nRight, long nBottom );
385 /// Constructs an empty Rectangle, with top/left at the specified params
386 Rectangle( long nLeft, long nTop );
387 Rectangle( const Point& rLT, const Size& rSize );
388
389 static Rectangle Justify( const Point& rLT, const Point& rRB );
390
391 long Left() const { return nLeft; }
392 long Right() const;
393 long Top() const { return nTop; }
394 long Bottom() const;
395
396 void SetLeft(long v) { nLeft = v; }
397 void SetRight(long v) { nRight = v; }
398 void SetTop(long v) { nTop = v; }
399 void SetBottom(long v) { nBottom = v; }
400
401 inline Point TopLeft() const;
402 inline Point TopRight() const;
403 inline Point TopCenter() const;
404 inline Point BottomLeft() const;
405 inline Point BottomRight() const;
406 inline Point BottomCenter() const;
407 inline Point LeftCenter() const;
408 inline Point RightCenter() const;
409 inline Point Center() const;
410
411 /// Move the top and left edges by a delta, preserving width and height
412 inline void Move( long nHorzMoveDelta, long nVertMoveDelta );
413 void Move( Size const & s ) { Move(s.Width(), s.Height()); }
414 long AdjustLeft( long nHorzMoveDelta ) { nLeft += nHorzMoveDelta; return nLeft; }
415 long AdjustRight( long nHorzMoveDelta );
416 long AdjustTop( long nVertMoveDelta ) { nTop += nVertMoveDelta; return nTop; }
417 long AdjustBottom( long nVertMoveDelta );
418 inline void SetPos( const Point& rPoint );
419 void SetSize( const Size& rSize );
420 inline Size GetSize() const;
421
422 /// Returns the difference between right and left, assuming the range is inclusive.
423 inline long GetWidth() const;
424 /// Returns the difference between bottom and top, assuming the range is inclusive.
425 inline long GetHeight() const;
426
427 tools::Rectangle& Union( const tools::Rectangle& rRect );
428 tools::Rectangle& Intersection( const tools::Rectangle& rRect );
429 inline tools::Rectangle GetUnion( const tools::Rectangle& rRect ) const;
430 inline tools::Rectangle GetIntersection( const tools::Rectangle& rRect ) const;
431
432 void Justify();
433
434 bool IsInside( const Point& rPOINT ) const;
435 bool IsInside( const tools::Rectangle& rRect ) const;
436 bool IsOver( const tools::Rectangle& rRect ) const;
437
438 void SetEmpty() { nRight = nBottom = RECT_EMPTY; }
439 void SetWidthEmpty() { nRight = RECT_EMPTY; }
440 void SetHeightEmpty() { nBottom = RECT_EMPTY; }
441 inline bool IsEmpty() const;
442 bool IsWidthEmpty() const { return nRight == RECT_EMPTY; }
443 bool IsHeightEmpty() const { return nBottom == RECT_EMPTY; }
444
445 inline bool operator == ( const tools::Rectangle& rRect ) const;
446 inline bool operator != ( const tools::Rectangle& rRect ) const;
447
448 inline tools::Rectangle& operator += ( const Point& rPt );
449 inline tools::Rectangle& operator -= ( const Point& rPt );
450
451 friend inline tools::Rectangle operator + ( const tools::Rectangle& rRect, const Point& rPt );
452 friend inline tools::Rectangle operator - ( const tools::Rectangle& rRect, const Point& rPt );
453
454 // ONE
455 long getX() const { return nLeft; }
456 long getY() const { return nTop; }
457 /// Returns the difference between right and left, assuming the range includes one end, but not the other.
458 long getWidth() const;
459 /// Returns the difference between bottom and top, assuming the range includes one end, but not the other.
460 long getHeight() const;
461 /// Set the left edge of the rectangle to x, preserving the width
462 void setX( long x );
463 /// Set the top edge of the rectangle to y, preserving the height
464 void setY( long y );
465 void setWidth( long n ) { nRight = nLeft + n; }
466 void setHeight( long n ) { nBottom = nTop + n; }
467 /// Returns the string representation of the rectangle, format is "x, y, width, height".
468 rtl::OString toString() const;
469
470 /**
471 * Expands the rectangle in all directions by the input value.
472 */
473 void expand(long nExpandBy);
474 void shrink(long nShrinkBy);
475
476 /**
477 * Sanitizing variants for handling data from the outside
478 */
479 void SaturatingSetSize(const Size& rSize);
480 void SaturatingSetX(long x);
481 void SaturatingSetY(long y);
482
483private:
484 long nLeft;
485 long nTop;
486 long nRight;
487 long nBottom;
488};
489}
490
491inline tools::Rectangle::Rectangle()
492{
493 nLeft = nTop = 0;
494 nRight = nBottom = RECT_EMPTY;
495}
496
497inline tools::Rectangle::Rectangle( const Point& rLT, const Point& rRB )
498{
499 nLeft = rLT.X();
500 nTop = rLT.Y();
501 nRight = rRB.X();
502 nBottom = rRB.Y();
503}
504
505inline tools::Rectangle::Rectangle( long _nLeft, long _nTop,
506 long _nRight, long _nBottom )
507{
508 nLeft = _nLeft;
509 nTop = _nTop;
510 nRight = _nRight;
511 nBottom = _nBottom;
512}
513
514inline tools::Rectangle::Rectangle( long _nLeft, long _nTop )
515{
516 nLeft = _nLeft;
517 nTop = _nTop;
518 nRight = nBottom = RECT_EMPTY;
519}
520
521inline tools::Rectangle::Rectangle( const Point& rLT, const Size& rSize )
522{
523 nLeft = rLT.X();
524 nTop = rLT.Y();
525 nRight = rSize.Width() ? nLeft+(rSize.Width()-1) : RECT_EMPTY;
526 nBottom = rSize.Height() ? nTop+(rSize.Height()-1) : RECT_EMPTY;
527}
528
529inline bool tools::Rectangle::IsEmpty() const
530{
531 return (nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY);
532}
533
534inline Point tools::Rectangle::TopLeft() const
535{
536 return Point( nLeft, nTop );
537}
538
539inline Point tools::Rectangle::TopRight() const
540{
541 return Point( (nRight == RECT_EMPTY) ? nLeft : nRight, nTop );
542}
543
544inline Point tools::Rectangle::BottomLeft() const
545{
546 return Point( nLeft, (nBottom == RECT_EMPTY) ? nTop : nBottom );
547}
548
549inline Point tools::Rectangle::BottomRight() const
550{
551 return Point( (nRight == RECT_EMPTY) ? nLeft : nRight,
552 (nBottom == RECT_EMPTY) ? nTop : nBottom );
553}
554
555inline Point tools::Rectangle::TopCenter() const
556{
557 if ( IsEmpty() )
558 return Point( nLeft, nTop );
559 else
560 return Point( std::min( nLeft, nRight ) + std::abs( (nRight - nLeft)/2 ),
561 std::min( nTop, nBottom) );
562}
563
564inline Point tools::Rectangle::BottomCenter() const
565{
566 if ( IsEmpty() )
567 return Point( nLeft, nTop );
568 else
569 return Point( std::min( nLeft, nRight ) + std::abs( (nRight - nLeft)/2 ),
570 std::max( nTop, nBottom) );
571}
572
573inline Point tools::Rectangle::LeftCenter() const
574{
575 if ( IsEmpty() )
576 return Point( nLeft, nTop );
577 else
578 return Point( std::min( nLeft, nRight ), nTop + (nBottom - nTop)/2 );
579}
580
581inline Point tools::Rectangle::RightCenter() const
582{
583 if ( IsEmpty() )
584 return Point( nLeft, nTop );
585 else
586 return Point( std::max( nLeft, nRight ), nTop + (nBottom - nTop)/2 );
587}
588
589inline Point tools::Rectangle::Center() const
590{
591 if ( IsEmpty() )
592 return Point( nLeft, nTop );
593 else
594 return Point( nLeft+(nRight-nLeft)/2 , nTop+(nBottom-nTop)/2 );
595}
596
597inline void tools::Rectangle::Move( long nHorzMove, long nVertMove )
598{
599 nLeft += nHorzMove;
600 nTop += nVertMove;
601 if ( nRight != RECT_EMPTY )
602 nRight += nHorzMove;
603 if ( nBottom != RECT_EMPTY )
604 nBottom += nVertMove;
605}
606
607inline void tools::Rectangle::SetPos( const Point& rPoint )
608{
609 if ( nRight != RECT_EMPTY )
610 nRight += rPoint.X() - nLeft;
611 if ( nBottom != RECT_EMPTY )
612 nBottom += rPoint.Y() - nTop;
613 nLeft = rPoint.X();
614 nTop = rPoint.Y();
615}
616
617inline long tools::Rectangle::GetWidth() const
618{
619 long n;
620 if ( nRight == RECT_EMPTY )
621 n = 0;
622 else
623 {
624 n = nRight - nLeft;
625 if( n < 0 )
626 n--;
627 else
628 n++;
629 }
630
631 return n;
632}
633
634inline long tools::Rectangle::GetHeight() const
635{
636 long n;
637 if ( nBottom == RECT_EMPTY )
638 n = 0;
639 else
640 {
641 n = nBottom - nTop;
642 if ( n < 0 )
643 n--;
644 else
645 n++;
646 }
647
648 return n;
649}
650
651inline Size tools::Rectangle::GetSize() const
652{
653 return Size( GetWidth(), GetHeight() );
654}
655
656inline tools::Rectangle tools::Rectangle::GetUnion( const tools::Rectangle& rRect ) const
657{
658 tools::Rectangle aTmpRect( *this );
659 return aTmpRect.Union( rRect );
660}
661
662inline tools::Rectangle tools::Rectangle::GetIntersection( const tools::Rectangle& rRect ) const
663{
664 tools::Rectangle aTmpRect( *this );
665 return aTmpRect.Intersection( rRect );
666}
667
668inline bool tools::Rectangle::operator == ( const tools::Rectangle& rRect ) const
669{
670 return (nLeft == rRect.nLeft ) &&
671 (nTop == rRect.nTop ) &&
672 (nRight == rRect.nRight ) &&
673 (nBottom == rRect.nBottom );
674}
675
676inline bool tools::Rectangle::operator != ( const tools::Rectangle& rRect ) const
677{
678 return (nLeft != rRect.nLeft ) ||
16
Assuming 'nLeft' is not equal to 'rRect.nLeft'
17
Returning the value 1, which participates in a condition later
679 (nTop != rRect.nTop ) ||
680 (nRight != rRect.nRight ) ||
681 (nBottom != rRect.nBottom );
682}
683
684inline tools::Rectangle& tools::Rectangle::operator +=( const Point& rPt )
685{
686 nLeft += rPt.X();
687 nTop += rPt.Y();
688 if ( nRight != RECT_EMPTY )
689 nRight += rPt.X();
690 if ( nBottom != RECT_EMPTY )
691 nBottom += rPt.Y();
692 return *this;
693}
694
695inline tools::Rectangle& tools::Rectangle::operator -= ( const Point& rPt )
696{
697 nLeft -= rPt.X();
698 nTop -= rPt.Y();
699 if ( nRight != RECT_EMPTY )
700 nRight -= rPt.X();
701 if ( nBottom != RECT_EMPTY )
702 nBottom -= rPt.Y();
703 return *this;
704}
705
706namespace tools
707{
708inline Rectangle operator + ( const Rectangle& rRect, const Point& rPt )
709{
710 return rRect.IsEmpty()
711 ? Rectangle( rRect.nLeft + rPt.X(), rRect.nTop + rPt.Y() )
712 : Rectangle( rRect.nLeft + rPt.X(), rRect.nTop + rPt.Y(),
713 rRect.nRight + rPt.X(), rRect.nBottom + rPt.Y() );
714}
715
716inline Rectangle operator - ( const Rectangle& rRect, const Point& rPt )
717{
718 return rRect.IsEmpty()
719 ? Rectangle( rRect.nLeft - rPt.X(), rRect.nTop - rPt.Y() )
720 : Rectangle( rRect.nLeft - rPt.X(), rRect.nTop - rPt.Y(),
721 rRect.nRight - rPt.X(), rRect.nBottom - rPt.Y() );
722}
723}
724
725template< typename charT, typename traits >
726inline std::basic_ostream<charT, traits> & operator <<(
727 std::basic_ostream<charT, traits> & stream, const tools::Rectangle& rectangle )
728{
729 if (rectangle.IsEmpty())
730 return stream << "EMPTY";
731 else
732 return stream << rectangle.getWidth() << 'x' << rectangle.getHeight()
733 << "@(" << rectangle.getX() << ',' << rectangle.getY() << ")";
734}
735
736#endif
737
738/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/sw/source/core/inc/frame.hxx

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#ifndef INCLUDED_SW_SOURCE_CORE_INC_FRAME_HXX
21#define INCLUDED_SW_SOURCE_CORE_INC_FRAME_HXX
22
23#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
24#include <editeng/borderline.hxx>
25#include <svl/poolitem.hxx>
26#include <swtypes.hxx>
27#include <swrect.hxx>
28#include <calbck.hxx>
29#include <svl/SfxBroadcaster.hxx>
30#include <o3tl/typed_flags_set.hxx>
31#include <com/sun/star/style/TabStop.hpp>
32#include <basegfx/matrix/b2dhommatrix.hxx>
33#include <vcl/outdev.hxx>
34
35#include <memory>
36
37namespace drawinglayer::processor2d { class BaseProcessor2D; }
38
39class SwLayoutFrame;
40class SwRootFrame;
41class SwPageFrame;
42class SwBodyFrame;
43class SwFlyFrame;
44class SwSectionFrame;
45class SwFootnoteFrame;
46class SwFootnoteBossFrame;
47class SwTabFrame;
48class SwRowFrame;
49class SwContentFrame;
50class SwAttrSet;
51class Color;
52class SwBorderAttrs;
53class SwCache;
54class SvxBrushItem;
55class SvxFormatBreakItem;
56class SwFormatPageDesc;
57class SwSelectionList;
58struct SwPosition;
59struct SwCursorMoveState;
60class SwFormat;
61class SwPrintData;
62class SwSortedObjs;
63class SwAnchoredObject;
64enum class SvxFrameDirection;
65class IDocumentDrawModelAccess;
66
67// Each FrameType is represented here as a bit.
68// The bits must be set in a way that it can be determined with masking of
69// which kind of FrameType an instance is _and_ from what classes it was derived.
70// Each frame has in its base class a member that must be set by the
71// constructors accordingly.
72enum class SwFrameType
73{
74 None = 0x0000,
75 Root = 0x0001,
76 Page = 0x0002,
77 Column = 0x0004,
78 Header = 0x0008,
79 Footer = 0x0010,
80 FtnCont = 0x0020,
81 Ftn = 0x0040,
82 Body = 0x0080,
83 Fly = 0x0100,
84 Section = 0x0200,
85// UNUSED 0x0400
86 Tab = 0x0800,
87 Row = 0x1000,
88 Cell = 0x2000,
89 Txt = 0x4000,
90 NoTxt = 0x8000,
91};
92
93namespace o3tl
94{
95 template<> struct typed_flags<SwFrameType> : is_typed_flags<SwFrameType, 0xfbff> {};
96};
97
98// for internal use some common combinations
99#define FRM_LAYOUTSwFrameType(0x3bFF) SwFrameType(0x3bFF)
100#define FRM_ALLSwFrameType(0xfbff) SwFrameType(0xfbff)
101#define FRM_CNTNT(SwFrameType::Txt | SwFrameType::NoTxt) (SwFrameType::Txt | SwFrameType::NoTxt)
102#define FRM_FTNBOSS(SwFrameType::Page | SwFrameType::Column) (SwFrameType::Page | SwFrameType::Column)
103#define FRM_ACCESSIBLE(SwFrameType::Root | SwFrameType::Page | SwFrameType::Header |
SwFrameType::Footer | SwFrameType::Ftn | SwFrameType::Fly | SwFrameType
::Tab | SwFrameType::Cell | SwFrameType::Txt)
(SwFrameType::Root | SwFrameType::Page | SwFrameType::Header | SwFrameType::Footer | SwFrameType::Ftn | SwFrameType::Fly | SwFrameType::Tab | SwFrameType::Cell | SwFrameType::Txt)
104#define FRM_NEIGHBOUR(SwFrameType::Column | SwFrameType::Cell) (SwFrameType::Column | SwFrameType::Cell)
105#define FRM_NOTE_VERT(SwFrameType::FtnCont | SwFrameType::Ftn | SwFrameType::Section
| SwFrameType::Tab | SwFrameType::Row | SwFrameType::Cell | SwFrameType
::Txt)
(SwFrameType::FtnCont | SwFrameType::Ftn | SwFrameType::Section | SwFrameType::Tab | SwFrameType::Row | SwFrameType::Cell | SwFrameType::Txt)
106#define FRM_HEADFOOT(SwFrameType::Header | SwFrameType::Footer) (SwFrameType::Header | SwFrameType::Footer)
107#define FRM_BODYFTNC(SwFrameType::FtnCont | SwFrameType::Body) (SwFrameType::FtnCont | SwFrameType::Body)
108
109// for GetNextLeaf/GetPrevLeaf.
110enum MakePageType
111{
112 MAKEPAGE_NONE, // do not create page/footnote
113 MAKEPAGE_APPEND, // only append page if needed
114 MAKEPAGE_INSERT, // add or append page if needed
115 MAKEPAGE_FTN, // add footnote if needed
116 MAKEPAGE_NOSECTION // Don't create section frames
117};
118
119namespace drawinglayer::attribute {
120 class SdrAllFillAttributesHelper;
121 typedef std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
122}
123
124/// Helper class to isolate geometry-defining members of SwFrame
125/// and to control their accesses. Moved to own class to have no
126/// hidden accesses to 'private' members anymore.
127///
128/// Added most important flags about the state of this geometric
129/// information and if it is valid or not
130class SAL_DLLPUBLIC_RTTI__attribute__ ((type_visibility("default"))) SwFrameAreaDefinition
131{
132private:
133 friend void FriendHackInvalidateRowFrame(SwFrameAreaDefinition &);
134
135 // The absolute position and size of the SwFrame in the document.
136 // This values are set by the layouter implementations
137 SwRect maFrameArea;
138
139 // The 'inner' Frame Area defined by a SwRect relative to FrameArea:
140 // When identical to FrameArea, Pos() will be (0, 0) and Size identical.
141 SwRect maFramePrintArea;
142
143 // bitfield
144 bool mbFrameAreaPositionValid : 1;
145 bool mbFrameAreaSizeValid : 1;
146 bool mbFramePrintAreaValid : 1;
147
148 // #i65250#
149 // frame ID is now in general available - used for layout loop control
150 static sal_uInt32 mnLastFrameId;
151 const sal_uInt32 mnFrameId;
152
153protected:
154 // write access to mb*Valid flags
155 void setFrameAreaPositionValid(bool bNew);
156 void setFrameAreaSizeValid(bool bNew);
157 void setFramePrintAreaValid(bool bNew);
158
159public:
160 SwFrameAreaDefinition();
161 virtual ~SwFrameAreaDefinition();
162
163 // read access to mb*Valid flags
164 bool isFrameAreaPositionValid() const { return mbFrameAreaPositionValid; }
165 bool isFrameAreaSizeValid() const { return mbFrameAreaSizeValid; }
166 bool isFramePrintAreaValid() const { return mbFramePrintAreaValid; }
167
168 // syntactic sugar: test whole FrameAreaDefinition
169 bool isFrameAreaDefinitionValid() const { return isFrameAreaPositionValid() && isFrameAreaSizeValid() && isFramePrintAreaValid(); }
40
Assuming the condition is true
41
Assuming the condition is true
42
Returning value, which participates in a condition later
170
171 // #i65250#
172 sal_uInt32 GetFrameId() const { return mnFrameId; }
173
174 // read accesses to FrameArea definitions - only const access allowed.
175 // Do *not* const_cast results, it is necessary to track changes. use
176 // the below offered WriteAccess helper classes instead
177 const SwRect& getFrameArea() const { return maFrameArea; }
178 const SwRect& getFramePrintArea() const { return maFramePrintArea; }
179
180 // helper class(es) for FrameArea manipulation. These
181 // have to be used to apply changes to FrameAreas. They hold a copy of the
182 // SwRect for manipulation. It gets written back at destruction. Thus, this
183 // mechanism depends on scope usage, take care. It prevents errors using
184 // different instances of SwFrame in get/set methods which is more safe
185 class FrameAreaWriteAccess : public SwRect
186 {
187 private:
188 SwFrameAreaDefinition& mrTarget;
189
190 FrameAreaWriteAccess(const FrameAreaWriteAccess&) = delete;
191 FrameAreaWriteAccess& operator=(const FrameAreaWriteAccess&) = delete;
192
193 public:
194 FrameAreaWriteAccess(SwFrameAreaDefinition& rTarget) : SwRect(rTarget.getFrameArea()), mrTarget(rTarget) {}
195 ~FrameAreaWriteAccess();
196 void setSwRect(const SwRect& rNew) { *reinterpret_cast< SwRect* >(this) = rNew; }
197 };
198
199 // same helper for FramePrintArea
200 class FramePrintAreaWriteAccess : public SwRect
201 {
202 private:
203 SwFrameAreaDefinition& mrTarget;
204
205 FramePrintAreaWriteAccess(const FramePrintAreaWriteAccess&) = delete;
206 FramePrintAreaWriteAccess& operator=(const FramePrintAreaWriteAccess&) = delete;
207
208 public:
209 FramePrintAreaWriteAccess(SwFrameAreaDefinition& rTarget) : SwRect(rTarget.getFramePrintArea()), mrTarget(rTarget) {}
210 ~FramePrintAreaWriteAccess();
211 void setSwRect(const SwRect& rNew) { *reinterpret_cast< SwRect* >(this) = rNew; }
212 };
213
214 // RotateFlyFrame3 - Support for Transformations
215 // Hand out the Transformations for the current FrameAreaDefinition
216 // for the FrameArea and FramePrintArea.
217 // FramePrintArea is not relative to FrameArea in this
218 // transformation representation (to make it easier to use and understand).
219 // There is no 'set' method since SwFrame is a layout object. For
220 // some cases rotation will be included (used for SwGrfNode in inner
221 // SwFrame of a SwFlyFrame)
222 virtual basegfx::B2DHomMatrix getFrameAreaTransformation() const;
223 virtual basegfx::B2DHomMatrix getFramePrintAreaTransformation() const;
224
225 // RotateFlyFrame3 - Support for Transformations
226 // Modify current transformations by applying given translation
227 virtual void transform_translate(const Point& rOffset);
228};
229
230/// RotateFlyFrame3: Helper class when you want to make your SwFrame derivate
231/// transformable. It provides some tooling to do so. To use, add as member
232/// (see e.g. SwFlyFreeFrame which uses 'std::unique_ptr< TransformableSwFrame >')
233class TransformableSwFrame
234{
235private:
236 // The SwFrameAreaDefinition to work on
237 SwFrameAreaDefinition& mrSwFrameAreaDefinition;
238
239 // FrameAreaTransformation and FramePrintAreaTransformation
240 // !identity when needed (translate/scale is used (e.g. rotation))
241 basegfx::B2DHomMatrix maFrameAreaTransformation;
242 basegfx::B2DHomMatrix maFramePrintAreaTransformation;
243
244public:
245 TransformableSwFrame(SwFrameAreaDefinition& rSwFrameAreaDefinition)
246 : mrSwFrameAreaDefinition(rSwFrameAreaDefinition),
247 maFrameAreaTransformation(),
248 maFramePrintAreaTransformation()
249 {
250 }
251
252 // get SwFrameArea in transformation form
253 const basegfx::B2DHomMatrix& getLocalFrameAreaTransformation() const
254 {
255 return maFrameAreaTransformation;
256 }
257
258 // get SwFramePrintArea in transformation form
259 const basegfx::B2DHomMatrix& getLocalFramePrintAreaTransformation() const
260 {
261 return maFramePrintAreaTransformation;
262 }
263
264 // Helpers to re-create the untransformed SwRect(s) originally
265 // in the SwFrameAreaDefinition, based on the current Transformations.
266 SwRect getUntransformedFrameArea() const;
267 SwRect getUntransformedFramePrintArea() const;
268
269 // Helper method to re-create FrameAreaTransformations based on the
270 // current FrameAreaDefinition transformed by given rotation and Center
271 void createFrameAreaTransformations(
272 double fRotation,
273 const basegfx::B2DPoint& rCenter);
274
275 // Tooling method to reset the SwRect(s) in the current
276 // SwFrameAreaDefinition which are already adapted to
277 // Transformation back to the untransformed state, using
278 // the getUntransformedFrame*Area calls above when needed.
279 // Only the SwRect(s) are changed back, not the transformations.
280 void restoreFrameAreas();
281
282 // Re-Creates the SwRect(s) as BoundAreas based on the current
283 // set Transformations.
284 void adaptFrameAreasToTransformations();
285
286 // Modify current definitions by applying the given transformation
287 void transform(const basegfx::B2DHomMatrix& aTransform);
288};
289
290/**
291 * Base class of the Writer layout elements.
292 *
293 * This includes not only fly frames, but everything down to the paragraph
294 * level: pages, headers, footers, etc. (Inside a paragraph SwLinePortion
295 * instances are used.)
296 */
297class SW_DLLPUBLIC__attribute__ ((visibility("default"))) SwFrame : public SwFrameAreaDefinition, public SwClient, public SfxBroadcaster
298{
299 // the hidden Frame
300 friend class SwFlowFrame;
301 friend class SwLayoutFrame;
302 friend class SwLooping;
303 friend class SwDeletionChecker; // for GetDep()
304
305 // voids lower during creation of a column
306 friend SwFrame *SaveContent( SwLayoutFrame *, SwFrame* pStart );
307 friend void RestoreContent( SwFrame *, SwLayoutFrame *, SwFrame *pSibling );
308
309 // for validating a mistakenly invalidated one in SwContentFrame::MakeAll
310 friend void ValidateSz( SwFrame *pFrame );
311 // implemented in text/txtftn.cxx, prevents Footnote oscillation
312 friend void ValidateText( SwFrame *pFrame );
313
314 friend void MakeNxt( SwFrame *pFrame, SwFrame *pNxt );
315
316 // cache for (border) attributes
317 static SwCache *mpCache;
318
319 SwRootFrame *mpRoot;
320 SwLayoutFrame *mpUpper;
321 SwFrame *mpNext;
322 SwFrame *mpPrev;
323
324 // sw_redlinehide: hide these dangerous SwClient functions
325 using SwClient::GetRegisteredInNonConst;
326 using SwClient::GetRegisteredIn;
327
328 SwFrame *FindNext_();
329 SwFrame *FindPrev_();
330
331 /** method to determine next content frame in the same environment
332 for a flow frame (content frame, table frame, section frame)
333
334 #i27138# - adding documentation:
335 Travelling downwards through the layout to determine the next content
336 frame in the same environment. There are several environments in a
337 document, which form a closed context regarding this function. These
338 environments are:
339 - Each page header
340 - Each page footer
341 - Each unlinked fly frame
342 - Each group of linked fly frames
343 - All footnotes
344 - All document body frames
345 #i27138# - adding parameter <_bInSameFootnote>
346 Its default value is <false>. If its value is <true>, the environment
347 'All footnotes' is no longer treated. Instead each footnote is treated
348 as an own environment.
349
350 @param _bInSameFootnote
351 input parameter - boolean indicating, that the found next content
352 frame has to be in the same footnote frame. This parameter is only
353 relevant for flow frames in footnotes.
354
355 @return SwContentFrame*
356 pointer to the found next content frame. It's NULL, if none exists.
357 */
358 SwContentFrame* FindNextCnt_( const bool _bInSameFootnote );
359
360 /** method to determine previous content frame in the same environment
361 for a flow frame (content frame, table frame, section frame)
362
363 #i27138#
364 Travelling upwards through the layout to determine the previous content
365 frame in the same environment. There are several environments in a
366 document, which form a closed context regarding this function. These
367 environments are:
368 - Each page header
369 - Each page footer
370 - Each unlinked fly frame
371 - Each group of linked fly frames
372 - All footnotes
373 - All document body frames
374 #i27138# - adding parameter <_bInSameFootnote>
375 Its default value is <false>. If its value is <true>, the environment
376 'All footnotes' is no longer treated. Instead each footnote is treated
377 as an own environment.
378
379 The found previous content frame has to be in the same footnote frame. This is only
380 relevant for flow frames in footnotes.
381
382 @return SwContentFrame*
383 pointer to the found previous content frame. It's NULL, if none exists.
384 */
385 SwContentFrame* FindPrevCnt_();
386
387 void UpdateAttrFrame( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 & );
388 SwFrame* GetIndNext_();
389 void SetDirFlags( bool bVert );
390
391 const SwLayoutFrame* ImplGetNextLayoutLeaf( bool bFwd ) const;
392
393 SwPageFrame* ImplFindPageFrame();
394
395protected:
396 std::unique_ptr<SwSortedObjs> m_pDrawObjs; // draw objects, can be null
397 SwFrameType mnFrameType; //Who am I?
398
399 bool mbInDtor : 1;
400 bool mbInvalidR2L : 1;
401 bool mbDerivedR2L : 1;
402 bool mbRightToLeft : 1;
403 bool mbInvalidVert : 1;
404 bool mbDerivedVert : 1;
405 bool mbVertical : 1;
406
407 bool mbVertLR : 1;
408 bool mbVertLRBT : 1;
409
410 bool mbValidLineNum : 1;
411 bool mbFixSize : 1;
412
413 // if true, frame will be painted completely even content was changed
414 // only partially. For ContentFrames a border (from Action) will exclusively
415 // painted if <mbCompletePaint> is true.
416 bool mbCompletePaint : 1;
417
418 bool mbRetouche : 1; // frame is responsible for retouching
419
420 bool mbInfInvalid : 1; // InfoFlags are invalid
421 bool mbInfBody : 1; // Frame is in document body
422 bool mbInfTab : 1; // Frame is in a table
423 bool mbInfFly : 1; // Frame is in a Fly
424 bool mbInfFootnote : 1; // Frame is in a footnote
425 bool mbInfSct : 1; // Frame is in a section
426 bool mbColLocked : 1; // lock Grow/Shrink for column-wise section
427 // or fly frames, will be set in Format
428 bool m_isInDestroy : 1;
429 bool mbForbidDelete : 1;
430
431 void ColLock() { mbColLocked = true; }
432 void ColUnlock() { mbColLocked = false; }
433
434 virtual void DestroyImpl();
435 virtual ~SwFrame() override;
436
437 // Only used by SwRootFrame Ctor to get 'this' into mpRoot...
438 void setRootFrame( SwRootFrame* pRoot ) { mpRoot = pRoot; }
439
440 SwPageFrame *InsertPage( SwPageFrame *pSibling, bool bFootnote );
441 void PrepareMake(vcl::RenderContext* pRenderContext);
442 void OptPrepareMake();
443 virtual void MakePos();
444 // Format next frame of table frame to assure keeping attributes.
445 // In case of nested tables method <SwFrame::MakeAll()> is called to
446 // avoid formatting of superior table frame.
447 friend SwFrame* sw_FormatNextContentForKeep( SwTabFrame* pTabFrame );
448
449 virtual void MakeAll(vcl::RenderContext* pRenderContext) = 0;
450 // adjust frames of a page
451 SwTwips AdjustNeighbourhood( SwTwips nDiff, bool bTst = false );
452
453 // change only frame size not the size of PrtArea
454 virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) = 0;
455 virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) = 0;
456
457 /// use these so we can grep for SwFrame's GetRegisteredIn accesses
458 /// beware that SwTextFrame may return sw::WriterMultiListener
459 SwModify *GetDep() { return GetRegisteredInNonConst(); }
460 const SwModify *GetDep() const { return GetRegisteredIn(); }
461
462 SwFrame( SwModify*, SwFrame* );
463
464 void CheckDir( SvxFrameDirection nDir, bool bVert, bool bOnlyBiDi, bool bBrowse );
465
466 /** enumeration for the different invalidations
467 #i28701#
468 */
469 enum InvalidationType
470 {
471 INVALID_SIZE, INVALID_PRTAREA, INVALID_POS, INVALID_LINENUM, INVALID_ALL
472 };
473
474 /** method to determine, if an invalidation is allowed.
475 #i28701
476 */
477 virtual bool InvalidationAllowed( const InvalidationType _nInvalid ) const;
478
479 /** method to perform additional actions on an invalidation
480
481 #i28701#
482 Method has *only* to contain actions, which has to be performed on
483 *every* assignment of the corresponding flag to <false>.
484 */
485 virtual void ActionOnInvalidation( const InvalidationType _nInvalid );
486
487 // draw shadow and borders
488 void PaintShadow( const SwRect&, SwRect&, const SwBorderAttrs& ) const;
489 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
490
491 virtual const IDocumentDrawModelAccess& getIDocumentDrawModelAccess( );
492
493public:
494 virtual css::uno::Sequence< css::style::TabStop > GetTabStopInfo( SwTwips )
495 {
496 return css::uno::Sequence< css::style::TabStop >();
497 }
498
499
500 SwFrameType GetType() const { return mnFrameType; }
501
502 static SwCache &GetCache() { return *mpCache; }
503 static SwCache *GetCachePtr() { return mpCache; }
504 static void SetCache( SwCache *pNew ) { mpCache = pNew; }
505
506 // change PrtArea size and FrameSize
507 SwTwips Shrink( SwTwips, bool bTst = false, bool bInfo = false );
508 SwTwips Grow ( SwTwips, bool bTst = false, bool bInfo = false );
509
510 // different methods for inserting in layout tree (for performance reasons)
511
512 // insert before pBehind or at the end of the chain below mpUpper
513 void InsertBefore( SwLayoutFrame* pParent, SwFrame* pBehind );
514 // insert after pBefore or at the beginning of the chain below mpUpper
515 void InsertBehind( SwLayoutFrame *pParent, SwFrame *pBefore );
516 // insert before pBehind or at the end of the chain while considering
517 // the siblings of pSct
518 bool InsertGroupBefore( SwFrame* pParent, SwFrame* pWhere, SwFrame* pSct );
519 void RemoveFromLayout();
520
521 // For internal use only - who ignores this will be put in a sack and has
522 // to stay there for two days
523 // Does special treatment for Get_[Next|Prev]Leaf() (for tables).
524 SwLayoutFrame *GetLeaf( MakePageType eMakePage, bool bFwd );
525 SwLayoutFrame *GetNextLeaf ( MakePageType eMakePage );
526 SwLayoutFrame *GetNextFootnoteLeaf( MakePageType eMakePage );
527 SwLayoutFrame *GetNextSctLeaf( MakePageType eMakePage );
528 SwLayoutFrame *GetNextCellLeaf();
529 SwLayoutFrame *GetPrevLeaf ();
530 SwLayoutFrame *GetPrevFootnoteLeaf( MakePageType eMakeFootnote );
531 SwLayoutFrame *GetPrevSctLeaf();
532 SwLayoutFrame *GetPrevCellLeaf();
533 const SwLayoutFrame *GetLeaf ( MakePageType eMakePage, bool bFwd,
534 const SwFrame *pAnch ) const;
535
536 bool WrongPageDesc( SwPageFrame* pNew );
537
538 //#i28701# - new methods to append/remove drawing objects
539 void AppendDrawObj( SwAnchoredObject& _rNewObj );
540 void RemoveDrawObj( SwAnchoredObject& _rToRemoveObj );
541
542 // work with chain of FlyFrames
543 void AppendFly( SwFlyFrame *pNew );
544 void RemoveFly( SwFlyFrame *pToRemove );
545 const SwSortedObjs *GetDrawObjs() const { return m_pDrawObjs.get(); }
546 SwSortedObjs *GetDrawObjs() { return m_pDrawObjs.get(); }
547 // #i28701# - change purpose of method and adjust its name
548 void InvalidateObjs( const bool _bNoInvaOfAsCharAnchoredObjs = true );
549
550 virtual void PaintSwFrameShadowAndBorder(
551 const SwRect&,
552 const SwPageFrame* pPage,
553 const SwBorderAttrs&) const;
554 void PaintBaBo( const SwRect&, const SwPageFrame *pPage,
555 const bool bOnlyTextBackground = false) const;
556 void PaintSwFrameBackground( const SwRect&, const SwPageFrame *pPage,
557 const SwBorderAttrs &,
558 const bool bLowerMode = false,
559 const bool bLowerBorder = false,
560 const bool bOnlyTextBackground = false ) const;
561 void PaintBorderLine( const SwRect&, const SwRect&, const SwPageFrame*,
562 const Color *pColor,
563 const SvxBorderLineStyle = SvxBorderLineStyle::SOLID ) const;
564
565 std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> CreateProcessor2D( ) const;
566 void ProcessPrimitives( const drawinglayer::primitive2d::Primitive2DContainer& rSequence ) const;
567
568 // retouch, not in the area of the given Rect!
569 void Retouch( const SwPageFrame *pPage, const SwRect &rRect ) const;
570
571 bool GetBackgroundBrush(
572 drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes,
573 const SvxBrushItem*& rpBrush,
574 const Color*& rpColor,
575 SwRect &rOrigRect,
576 bool bLowerMode,
577 bool bConsiderTextBox ) const;
578
579 inline void SetCompletePaint() const;
580 inline void ResetCompletePaint() const;
581 bool IsCompletePaint() const { return mbCompletePaint; }
582
583 inline void SetRetouche() const;
584 inline void ResetRetouche() const;
585 bool IsRetouche() const { return mbRetouche; }
586
587 void SetInfFlags();
588 void InvalidateInfFlags() { mbInfInvalid = true; }
589 inline bool IsInDocBody() const; // use InfoFlags, determine flags
590 inline bool IsInFootnote() const; // if necessary
591 inline bool IsInTab() const;
592 inline bool IsInFly() const;
593 inline bool IsInSct() const;
594
595 // If frame is inside a split table row, this function returns
596 // the corresponding row frame in the follow table.
597 const SwRowFrame* IsInSplitTableRow() const;
598
599 // If frame is inside a follow flow row, this function returns
600 // the corresponding row frame master table
601 const SwRowFrame* IsInFollowFlowRow() const;
602
603 bool IsInBalancedSection() const;
604
605 inline bool IsVertical() const;
606 inline bool IsVertLR() const;
607 inline bool IsVertLRBT() const;
608
609 void SetDerivedVert( bool bNew ){ mbDerivedVert = bNew; }
610 void SetInvalidVert( bool bNew) { mbInvalidVert = bNew; }
611 inline bool IsRightToLeft() const;
612 void SetDerivedR2L( bool bNew ) { mbDerivedR2L = bNew; }
613
614 void CheckDirChange();
615 // returns upper left frame position for LTR and
616 // upper right frame position for Asian / RTL frames
617 Point GetFrameAnchorPos( bool bIgnoreFlysAnchoredAtThisFrame ) const;
618
619 /** determine, if frame is moveable in given environment
620
621 method replaced 'old' method <bool IsMoveable() const>.
622 Determines, if frame is moveable in given environment. if no environment
623 is given (parameter _pLayoutFrame == 0), the movability in the actual
624 environment (<GetUpper()) is checked.
625
626 @param _pLayoutFrame
627 input parameter - given environment (layout frame), in which the movability
628 will be checked. If not set ( == 0 ), actual environment is taken.
629
630 @return boolean, indicating, if frame is moveable in given environment
631 */
632 bool IsMoveable( const SwLayoutFrame* _pLayoutFrame = nullptr ) const;
633
634 // Is it permitted for the (Text)Frame to add a footnote in the current
635 // environment (not e.g. for repeating table headlines)
636 bool IsFootnoteAllowed() const;
637
638 virtual void Format( vcl::RenderContext* pRenderContext, const SwBorderAttrs *pAttrs = nullptr );
639
640 virtual void CheckDirection( bool bVert );
641
642 void ReinitializeFrameSizeAttrFlags();
643
644 /// WARNING: this may not return correct RES_PAGEDESC/RES_BREAK items for
645 /// SwTextFrame, use GetBreakItem()/GetPageDescItem() instead
646 const SwAttrSet *GetAttrSet() const;
647 virtual const SvxFormatBreakItem& GetBreakItem() const;
648 virtual const SwFormatPageDesc& GetPageDescItem() const;
649
650 bool HasFixSize() const { return mbFixSize; }
651
652 // check all pages (starting from the given) and correct them if needed
653 static void CheckPageDescs( SwPageFrame *pStart, bool bNotifyFields = true, SwPageFrame** ppPrev = nullptr);
654
655 // might return 0, with and without const
656 SwFrame *GetNext() { return mpNext; }
657 SwFrame *GetPrev() { return mpPrev; }
658 SwLayoutFrame *GetUpper() { return mpUpper; }
659 SwRootFrame *getRootFrame(){ return mpRoot; }
660 SwPageFrame *FindPageFrame() { return IsPageFrame() ? reinterpret_cast<SwPageFrame*>(this) : ImplFindPageFrame(); }
48
'?' condition is true
49
Returning pointer, which participates in a condition later
57
'?' condition is true
58
Returning pointer, which participates in a condition later
661 SwFrame *FindColFrame();
662 SwRowFrame *FindRowFrame();
663 SwFootnoteBossFrame *FindFootnoteBossFrame( bool bFootnotes = false );
664 SwTabFrame *ImplFindTabFrame();
665 SwFootnoteFrame *ImplFindFootnoteFrame();
666 SwFlyFrame *ImplFindFlyFrame();
667 SwSectionFrame *ImplFindSctFrame();
668 const SwBodyFrame *ImplFindBodyFrame() const;
669 SwFrame *FindFooterOrHeader();
670 SwFrame *GetLower();
671 const SwFrame *GetNext() const { return mpNext; }
672 const SwFrame *GetPrev() const { return mpPrev; }
673 const SwLayoutFrame *GetUpper() const { return mpUpper; }
674 const SwRootFrame *getRootFrame() const { return mpRoot; }
675 inline SwTabFrame *FindTabFrame();
676 inline SwFootnoteFrame *FindFootnoteFrame();
677 inline SwFlyFrame *FindFlyFrame();
678 inline SwSectionFrame *FindSctFrame();
679 inline SwFrame *FindNext();
680 // #i27138# - add parameter <_bInSameFootnote>
681 SwContentFrame* FindNextCnt( const bool _bInSameFootnote = false );
682 inline SwFrame *FindPrev();
683 inline const SwPageFrame *FindPageFrame() const;
684 inline const SwFootnoteBossFrame *FindFootnoteBossFrame( bool bFootnote = false ) const;
685 inline const SwFrame *FindColFrame() const;
686 inline const SwFrame *FindFooterOrHeader() const;
687 inline const SwTabFrame *FindTabFrame() const;
688 inline const SwFootnoteFrame *FindFootnoteFrame() const;
689 inline const SwFlyFrame *FindFlyFrame() const;
690 inline const SwSectionFrame *FindSctFrame() const;
691 inline const SwBodyFrame *FindBodyFrame() const;
692 inline const SwFrame *FindNext() const;
693 // #i27138# - add parameter <_bInSameFootnote>
694 const SwContentFrame* FindNextCnt( const bool _bInSameFootnote = false ) const;
695 inline const SwFrame *FindPrev() const;
696 const SwFrame *GetLower() const;
697
698 SwContentFrame* FindPrevCnt();
699
700 const SwContentFrame* FindPrevCnt() const;
701
702 // #i79774#
703 SwFrame* GetIndPrev_() const;
704 SwFrame* GetIndPrev() const
705 { return ( mpPrev || !IsInSct() ) ? mpPrev : GetIndPrev_(); }
706
707 SwFrame* GetIndNext()
708 { return ( mpNext || !IsInSct() ) ? mpNext : GetIndNext_(); }
709 const SwFrame* GetIndNext() const { return const_cast<SwFrame*>(this)->GetIndNext(); }
710
711 sal_uInt16 GetPhyPageNum() const; // page number without offset
712 sal_uInt16 GetVirtPageNum() const; // page number with offset
713 bool OnRightPage() const { return 0 != GetPhyPageNum() % 2; };
714 bool WannaRightPage() const;
715 bool OnFirstPage() const;
716
717 inline const SwLayoutFrame *GetPrevLayoutLeaf() const;
718 inline const SwLayoutFrame *GetNextLayoutLeaf() const;
719 inline SwLayoutFrame *GetPrevLayoutLeaf();
720 inline SwLayoutFrame *GetNextLayoutLeaf();
721
722 virtual void Calc(vcl::RenderContext* pRenderContext) const; // here might be "formatted"
723 inline void OptCalc() const; // here we assume (for optimization) that
724 // the predecessors are already formatted
725 Point GetRelPos() const;
726
727 // PaintArea is the area where content might be displayed.
728 // The margin of a page or the space between columns belongs to it.
729 SwRect GetPaintArea() const;
730
731 // UnionFrame is the union of Frame- and PrtArea, normally identical
732 // to the FrameArea except in case of negative Prt margins.
733 SwRect UnionFrame( bool bBorder = false ) const;
734
735 virtual Size ChgSize( const Size& aNewSize );
736
737 virtual void Cut() = 0;
738 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) = 0;
739
740 void ValidateLineNum() { mbValidLineNum = true; }
741
742 bool GetValidLineNumFlag()const { return mbValidLineNum; }
743
744 // Only invalidate Frame
745 // #i28701# - add call to method <ActionOnInvalidation(..)>
746 // for all invalidation methods.
747 // #i28701# - use method <InvalidationAllowed(..)> to
748 // decide, if invalidation will to be performed or not.
749 // #i26945# - no additional invalidation, if it's already
750 // invalidate.
751 void InvalidateSize_()
752 {
753 if ( isFrameAreaSizeValid() && InvalidationAllowed( INVALID_SIZE ) )
754 {
755 setFrameAreaSizeValid(false);
756 ActionOnInvalidation( INVALID_SIZE );
757 }
758 }
759 void InvalidatePrt_()
760 {
761 if ( isFramePrintAreaValid() && InvalidationAllowed( INVALID_PRTAREA ) )
762 {
763 setFramePrintAreaValid(false);
764 ActionOnInvalidation( INVALID_PRTAREA );
765 }
766 }
767 void InvalidatePos_()
768 {
769 if ( isFrameAreaPositionValid() && InvalidationAllowed( INVALID_POS ) )
770 {
771 setFrameAreaPositionValid(false);
772 ActionOnInvalidation( INVALID_POS );
773 }
774 }
775 void InvalidateLineNum_()
776 {
777 if ( mbValidLineNum && InvalidationAllowed( INVALID_LINENUM ) )
778 {
779 mbValidLineNum = false;
780 ActionOnInvalidation( INVALID_LINENUM );
781 }
782 }
783 void InvalidateAll_()
784 {
785 if ( ( isFrameAreaSizeValid() || isFramePrintAreaValid() || isFrameAreaPositionValid() ) && InvalidationAllowed( INVALID_ALL ) )
786 {
787 setFrameAreaSizeValid(false);
788 setFrameAreaPositionValid(false);
789 setFramePrintAreaValid(false);
790 ActionOnInvalidation( INVALID_ALL );
791 }
792 }
793 // also notify page at the same time
794 inline void InvalidateSize();
795 inline void InvalidatePrt();
796 inline void InvalidatePos();
797 inline void InvalidateLineNum();
798 inline void InvalidateAll();
799 void ImplInvalidateSize();
800 void ImplInvalidatePrt();
801 void ImplInvalidatePos();
802 void ImplInvalidateLineNum();
803
804 inline void InvalidateNextPos( bool bNoFootnote = false );
805 void ImplInvalidateNextPos( bool bNoFootnote );
806
807 /** method to invalidate printing area of next frame
808 #i11859#
809 */
810 void InvalidateNextPrtArea();
811
812 void InvalidatePage( const SwPageFrame *pPage = nullptr ) const;
813
814 virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const;
815
816 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
817 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const;
818 virtual bool GetCharRect( SwRect &, const SwPosition&,
819 SwCursorMoveState* = nullptr, bool bAllowFarAway = true ) const;
820 virtual void PaintSwFrame( vcl::RenderContext& rRenderContext, SwRect const&,
821 SwPrintData const*const pPrintData = nullptr ) const;
822
823 // HACK: shortcut between frame and formatting
824 // It's your own fault if you cast void* incorrectly! In any case check
825 // the void* for 0.
826 virtual bool Prepare( const PrepareHint ePrep = PrepareHint::Clear,
827 const void *pVoid = nullptr, bool bNotify = true );
828
829 // true if it is the correct class, false otherwise
830 inline bool IsLayoutFrame() const;
831 inline bool IsRootFrame() const;
832 inline bool IsPageFrame() const;
833 inline bool IsColumnFrame() const;
834 inline bool IsFootnoteBossFrame() const; // footnote bosses might be PageFrames or ColumnFrames
835 inline bool IsHeaderFrame() const;
836 inline bool IsFooterFrame() const;
837 inline bool IsFootnoteContFrame() const;
838 inline bool IsFootnoteFrame() const;
839 inline bool IsBodyFrame() const;
840 inline bool IsColBodyFrame() const; // implemented in layfrm.hxx, BodyFrame above ColumnFrame
841 inline bool IsPageBodyFrame() const; // implemented in layfrm.hxx, BodyFrame above PageFrame
842 inline bool IsFlyFrame() const;
843 inline bool IsSctFrame() const;
844 inline bool IsTabFrame() const;
845 inline bool IsRowFrame() const;
846 inline bool IsCellFrame() const;
847 inline bool IsContentFrame() const;
848 inline bool IsTextFrame() const;
849 inline bool IsNoTextFrame() const;
850 // Frames where its PrtArea depends on their neighbors and that are
851 // positioned in the content flow
852 inline bool IsFlowFrame() const;
853 // Frames that are capable of retouching or that might need to retouch behind
854 // themselves
855 inline bool IsRetoucheFrame() const;
856 inline bool IsAccessibleFrame() const;
857
858 void PrepareCursor(); // CursorShell is allowed to call this
859
860 // Is the Frame (or the section containing it) protected? Same for Fly in
861 // Fly in ... and footnotes
862 bool IsProtected() const;
863
864 bool IsColLocked() const { return mbColLocked; }
865 virtual bool IsDeleteForbidden() const { return mbForbidDelete; }
866
867 /// this is the only way to delete a SwFrame instance
868 static void DestroyFrame(SwFrame *const pFrame);
869
870 bool IsInDtor() const { return mbInDtor; }
871
872 // No inline cause we need the function pointers
873 long GetTopMargin() const;
874 long GetBottomMargin() const;
875 long GetLeftMargin() const;
876 long GetRightMargin() const;
877 void SetTopBottomMargins( long, long );
878 void SetLeftRightMargins( long, long );
879 void SetRightLeftMargins( long, long );
880 long GetPrtLeft() const;
881 long GetPrtBottom() const;
882 long GetPrtRight() const;
883 long GetPrtTop() const;
884 bool SetMinLeft( long );
885 bool SetMaxBottom( long );
886 bool SetMaxRight( long );
887 void MakeBelowPos( const SwFrame*, const SwFrame*, bool );
888 void MakeLeftPos( const SwFrame*, const SwFrame*, bool );
889 void MakeRightPos( const SwFrame*, const SwFrame*, bool );
890 bool IsNeighbourFrame() const
891 { return bool(GetType() & FRM_NEIGHBOUR(SwFrameType::Column | SwFrameType::Cell)); }
892
893 // NEW TABLES
894 // Some functions for covered/covering table cells. This way unnecessary
895 // includes can be avoided
896 virtual bool IsLeaveUpperAllowed() const;
897 virtual bool IsCoveredCell() const;
898 bool IsInCoveredCell() const;
899
900 // #i81146# new loop control
901 bool KnowsFormat( const SwFormat& rFormat ) const;
902 void RegisterToFormat( SwFormat& rFormat );
903 void ValidateThisAndAllLowers( const sal_uInt16 nStage );
904
905 void ForbidDelete() { mbForbidDelete = true; }
906 void AllowDelete() { mbForbidDelete = false; }
907
908 drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const;
909 bool supportsFullDrawingLayerFillAttributeSet() const;
910
911public:
912 // if writer is NULL, dumps the layout structure as XML in layout.xml
913 virtual void dumpAsXml(xmlTextWriterPtr writer = nullptr) const;
914 void dumpTopMostAsXml(xmlTextWriterPtr writer = nullptr) const;
915 void dumpInfosAsXml(xmlTextWriterPtr writer) const;
916 virtual void dumpAsXmlAttributes(xmlTextWriterPtr writer) const;
917 void dumpChildrenAsXml(xmlTextWriterPtr writer) const;
918 bool IsCollapse() const;
919};
920
921inline bool SwFrame::IsInDocBody() const
922{
923 if ( mbInfInvalid )
924 const_cast<SwFrame*>(this)->SetInfFlags();
925 return mbInfBody;
926}
927inline bool SwFrame::IsInFootnote() const
928{
929 if ( mbInfInvalid )
930 const_cast<SwFrame*>(this)->SetInfFlags();
931 return mbInfFootnote;
932}
933inline bool SwFrame::IsInTab() const
934{
935 if ( mbInfInvalid )
936 const_cast<SwFrame*>(this)->SetInfFlags();
937 return mbInfTab;
938}
939inline bool SwFrame::IsInFly() const
940{
941 if ( mbInfInvalid )
34
Assuming field 'mbInfInvalid' is false
35
Taking false branch
942 const_cast<SwFrame*>(this)->SetInfFlags();
943 return mbInfFly;
36
Returning value, which participates in a condition later
944}
945inline bool SwFrame::IsInSct() const
946{
947 if ( mbInfInvalid )
948 const_cast<SwFrame*>(this)->SetInfFlags();
949 return mbInfSct;
950}
951bool SwFrame::IsVertical() const
952{
953 if( mbInvalidVert )
954 const_cast<SwFrame*>(this)->SetDirFlags( true );
955 return mbVertical;
956}
957inline bool SwFrame::IsVertLR() const
958{
959 return mbVertLR;
960}
961inline bool SwFrame::IsVertLRBT() const
962{
963 return mbVertLRBT;
964}
965inline bool SwFrame::IsRightToLeft() const
966{
967 if( mbInvalidR2L )
968 const_cast<SwFrame*>(this)->SetDirFlags( false );
969 return mbRightToLeft;
970}
971
972inline void SwFrame::SetCompletePaint() const
973{
974 const_cast<SwFrame*>(this)->mbCompletePaint = true;
975}
976inline void SwFrame::ResetCompletePaint() const
977{
978 const_cast<SwFrame*>(this)->mbCompletePaint = false;
979}
980
981inline void SwFrame::SetRetouche() const
982{
983 const_cast<SwFrame*>(this)->mbRetouche = true;
984}
985inline void SwFrame::ResetRetouche() const
986{
987 const_cast<SwFrame*>(this)->mbRetouche = false;
988}
989
990inline SwLayoutFrame *SwFrame::GetNextLayoutLeaf()
991{
992 return const_cast<SwLayoutFrame*>(static_cast<const SwFrame*>(this)->GetNextLayoutLeaf());
993}
994inline SwLayoutFrame *SwFrame::GetPrevLayoutLeaf()
995{
996 return const_cast<SwLayoutFrame*>(static_cast<const SwFrame*>(this)->GetPrevLayoutLeaf());
997}
998inline const SwLayoutFrame *SwFrame::GetNextLayoutLeaf() const
999{
1000 return ImplGetNextLayoutLeaf( true );
1001}
1002inline const SwLayoutFrame *SwFrame::GetPrevLayoutLeaf() const
1003{
1004 return ImplGetNextLayoutLeaf( false );
1005}
1006
1007inline void SwFrame::InvalidateSize()
1008{
1009 if ( isFrameAreaSizeValid() )
1010 {
1011 ImplInvalidateSize();
1012 }
1013}
1014inline void SwFrame::InvalidatePrt()
1015{
1016 if ( isFramePrintAreaValid() )
1017 {
1018 ImplInvalidatePrt();
1019 }
1020}
1021inline void SwFrame::InvalidatePos()
1022{
1023 if ( isFrameAreaPositionValid() )
1024 {
1025 ImplInvalidatePos();
1026 }
1027}
1028inline void SwFrame::InvalidateLineNum()
1029{
1030 if ( mbValidLineNum )
1031 ImplInvalidateLineNum();
1032}
1033inline void SwFrame::InvalidateAll()
1034{
1035 if ( InvalidationAllowed( INVALID_ALL ) )
1036 {
1037 if ( isFrameAreaDefinitionValid() )
1038 {
1039 ImplInvalidatePos();
1040 }
1041
1042 setFrameAreaSizeValid(false);
1043 setFrameAreaPositionValid(false);
1044 setFramePrintAreaValid(false);
1045
1046 // #i28701#
1047 ActionOnInvalidation( INVALID_ALL );
1048 }
1049}
1050inline void SwFrame::InvalidateNextPos( bool bNoFootnote )
1051{
1052 if ( mpNext && !mpNext->IsSctFrame() )
1053 mpNext->InvalidatePos();
1054 else
1055 ImplInvalidateNextPos( bNoFootnote );
1056}
1057
1058inline void SwFrame::OptCalc() const
1059{
1060 if ( !isFrameAreaPositionValid() || !isFramePrintAreaValid() || !isFrameAreaSizeValid() )
1061 {
1062 const_cast<SwFrame*>(this)->OptPrepareMake();
1063 }
1064}
1065inline const SwPageFrame *SwFrame::FindPageFrame() const
1066{
1067 return const_cast<SwFrame*>(this)->FindPageFrame();
47
Calling 'SwFrame::FindPageFrame'
50
Returning from 'SwFrame::FindPageFrame'
51
Returning pointer, which participates in a condition later
56
Calling 'SwFrame::FindPageFrame'
59
Returning from 'SwFrame::FindPageFrame'
60
Returning pointer, which participates in a condition later
1068}
1069inline const SwFrame *SwFrame::FindColFrame() const
1070{
1071 return const_cast<SwFrame*>(this)->FindColFrame();
1072}
1073inline const SwFrame *SwFrame::FindFooterOrHeader() const
1074{
1075 return const_cast<SwFrame*>(this)->FindFooterOrHeader();
1076}
1077inline SwTabFrame *SwFrame::FindTabFrame()
1078{
1079 return IsInTab() ? ImplFindTabFrame() : nullptr;
1080}
1081inline const SwFootnoteBossFrame *SwFrame::FindFootnoteBossFrame( bool bFootnote ) const
1082{
1083 return const_cast<SwFrame*>(this)->FindFootnoteBossFrame( bFootnote );
1084}
1085inline SwFootnoteFrame *SwFrame::FindFootnoteFrame()
1086{
1087 return IsInFootnote() ? ImplFindFootnoteFrame() : nullptr;
1088}
1089inline SwFlyFrame *SwFrame::FindFlyFrame()
1090{
1091 return IsInFly() ? ImplFindFlyFrame() : nullptr;
1092}
1093inline SwSectionFrame *SwFrame::FindSctFrame()
1094{
1095 return IsInSct() ? ImplFindSctFrame() : nullptr;
1096}
1097
1098inline const SwBodyFrame *SwFrame::FindBodyFrame() const
1099{
1100 return IsInDocBody() ? ImplFindBodyFrame() : nullptr;
1101}
1102
1103inline const SwTabFrame *SwFrame::FindTabFrame() const
1104{
1105 return IsInTab() ? const_cast<SwFrame*>(this)->ImplFindTabFrame() : nullptr;
1106}
1107inline const SwFootnoteFrame *SwFrame::FindFootnoteFrame() const
1108{
1109 return IsInFootnote() ? const_cast<SwFrame*>(this)->ImplFindFootnoteFrame() : nullptr;
1110}
1111inline const SwFlyFrame *SwFrame::FindFlyFrame() const
1112{
1113 return IsInFly() ? const_cast<SwFrame*>(this)->ImplFindFlyFrame() : nullptr;
1114}
1115inline const SwSectionFrame *SwFrame::FindSctFrame() const
1116{
1117 return IsInSct() ? const_cast<SwFrame*>(this)->ImplFindSctFrame() : nullptr;
1118}
1119inline SwFrame *SwFrame::FindNext()
1120{
1121 if ( mpNext )
1122 return mpNext;
1123 else
1124 return FindNext_();
1125}
1126inline const SwFrame *SwFrame::FindNext() const
1127{
1128 if ( mpNext )
1129 return mpNext;
1130 else
1131 return const_cast<SwFrame*>(this)->FindNext_();
1132}
1133inline SwFrame *SwFrame::FindPrev()
1134{
1135 if ( mpPrev && !mpPrev->IsSctFrame() )
1136 return mpPrev;
1137 else
1138 return FindPrev_();
1139}
1140inline const SwFrame *SwFrame::FindPrev() const
1141{
1142 if ( mpPrev && !mpPrev->IsSctFrame() )
1143 return mpPrev;
1144 else
1145 return const_cast<SwFrame*>(this)->FindPrev_();
1146}
1147
1148inline bool SwFrame::IsLayoutFrame() const
1149{
1150 return bool(GetType() & FRM_LAYOUTSwFrameType(0x3bFF));
1151}
1152inline bool SwFrame::IsRootFrame() const
1153{
1154 return mnFrameType == SwFrameType::Root;
1155}
1156inline bool SwFrame::IsPageFrame() const
1157{
1158 return mnFrameType == SwFrameType::Page;
1159}
1160inline bool SwFrame::IsColumnFrame() const
1161{
1162 return mnFrameType == SwFrameType::Column;
1163}
1164inline bool SwFrame::IsFootnoteBossFrame() const
1165{
1166 return bool(GetType() & FRM_FTNBOSS(SwFrameType::Page | SwFrameType::Column));
1167}
1168inline bool SwFrame::IsHeaderFrame() const
1169{
1170 return mnFrameType == SwFrameType::Header;
1171}
1172inline bool SwFrame::IsFooterFrame() const
1173{
1174 return mnFrameType == SwFrameType::Footer;
1175}
1176inline bool SwFrame::IsFootnoteContFrame() const
1177{
1178 return mnFrameType == SwFrameType::FtnCont;
1179}
1180inline bool SwFrame::IsFootnoteFrame() const
1181{
1182 return mnFrameType == SwFrameType::Ftn;
1183}
1184inline bool SwFrame::IsBodyFrame() const
1185{
1186 return mnFrameType == SwFrameType::Body;
1187}
1188inline bool SwFrame::IsFlyFrame() const
1189{
1190 return mnFrameType == SwFrameType::Fly;
1191}
1192inline bool SwFrame::IsSctFrame() const
1193{
1194 return mnFrameType == SwFrameType::Section;
1195}
1196inline bool SwFrame::IsTabFrame() const
1197{
1198 return mnFrameType == SwFrameType::Tab;
1199}
1200inline bool SwFrame::IsRowFrame() const
1201{
1202 return mnFrameType == SwFrameType::Row;
1203}
1204inline bool SwFrame::IsCellFrame() const
1205{
1206 return mnFrameType == SwFrameType::Cell;
1207}
1208inline bool SwFrame::IsContentFrame() const
1209{
1210 return bool(GetType() & FRM_CNTNT(SwFrameType::Txt | SwFrameType::NoTxt));
1211}
1212inline bool SwFrame::IsTextFrame() const
1213{
1214 return mnFrameType == SwFrameType::Txt;
1215}
1216inline bool SwFrame::IsNoTextFrame() const
1217{
1218 return mnFrameType == SwFrameType::NoTxt;
1219}
1220inline bool SwFrame::IsFlowFrame() const
1221{
1222 return bool(GetType() & (FRM_CNTNT(SwFrameType::Txt | SwFrameType::NoTxt)|SwFrameType::Tab|SwFrameType::Section));
1223}
1224inline bool SwFrame::IsRetoucheFrame() const
1225{
1226 return bool(GetType() & (FRM_CNTNT(SwFrameType::Txt | SwFrameType::NoTxt)|SwFrameType::Tab|SwFrameType::Section|SwFrameType::Ftn));
1227}
1228inline bool SwFrame::IsAccessibleFrame() const
1229{
1230 return bool(GetType() & FRM_ACCESSIBLE(SwFrameType::Root | SwFrameType::Page | SwFrameType::Header |
SwFrameType::Footer | SwFrameType::Ftn | SwFrameType::Fly | SwFrameType
::Tab | SwFrameType::Cell | SwFrameType::Txt)
);
1231}
1232
1233//use this to protect a SwFrame for a given scope from getting deleted
1234class SwFrameDeleteGuard
1235{
1236private:
1237 SwFrame *m_pForbidFrame;
1238public:
1239 //Flag pFrame for SwFrameDeleteGuard lifetime that we shouldn't delete
1240 //it in e.g. SwSectionFrame::MergeNext etc because we will need it
1241 //again after the SwFrameDeleteGuard dtor
1242 explicit SwFrameDeleteGuard(SwFrame* pFrame)
1243 : m_pForbidFrame((pFrame && !pFrame->IsDeleteForbidden()) ?
1244 pFrame : nullptr)
1245 {
1246 if (m_pForbidFrame)
1247 m_pForbidFrame->ForbidDelete();
1248 }
1249
1250 SwFrameDeleteGuard(const SwFrameDeleteGuard&) =delete;
1251
1252 ~SwFrameDeleteGuard()
1253 {
1254 if (m_pForbidFrame)
1255 m_pForbidFrame->AllowDelete();
1256 }
1257
1258 SwFrameDeleteGuard& operator=(const SwFrameDeleteGuard&) =delete;
1259};
1260
1261typedef long (SwFrame::*SwFrameGet)() const;
1262typedef bool (SwFrame::*SwFrameMax)( long );
1263typedef void (SwFrame::*SwFrameMakePos)( const SwFrame*, const SwFrame*, bool );
1264typedef long (*SwOperator)( long, long );
1265typedef void (SwFrame::*SwFrameSet)( long, long );
1266
1267struct SwRectFnCollection
1268{
1269 SwRectGet fnGetTop;
1270 SwRectGet fnGetBottom;
1271 SwRectGet fnGetLeft;
1272 SwRectGet fnGetRight;
1273 SwRectGet fnGetWidth;
1274 SwRectGet fnGetHeight;
1275 SwRectPoint fnGetPos;
1276 SwRectSize fnGetSize;
1277
1278 SwRectSet fnSetTop;
1279 SwRectSet fnSetBottom;
1280 SwRectSet fnSetLeft;
1281 SwRectSet fnSetRight;
1282 SwRectSet fnSetWidth;
1283 SwRectSet fnSetHeight;
1284
1285 SwRectSet fnSubTop;
1286 SwRectSet fnAddBottom;
1287 SwRectSet fnSubLeft;
1288 SwRectSet fnAddRight;
1289 SwRectSet fnAddWidth;
1290 SwRectSet fnAddHeight;
1291
1292 SwRectSet fnSetPosX;
1293 SwRectSet fnSetPosY;
1294
1295 SwFrameGet fnGetTopMargin;
1296 SwFrameGet fnGetBottomMargin;
1297 SwFrameGet fnGetLeftMargin;
1298 SwFrameGet fnGetRightMargin;
1299 SwFrameSet fnSetXMargins;
1300 SwFrameSet fnSetYMargins;
1301 SwFrameGet fnGetPrtTop;
1302 SwFrameGet fnGetPrtBottom;
1303 SwFrameGet fnGetPrtLeft;
1304 SwFrameGet fnGetPrtRight;
1305 SwRectDist fnTopDist;
1306 SwRectDist fnBottomDist;
1307 SwRectDist fnLeftDist;
1308 SwRectDist fnRightDist;
1309 SwFrameMax fnSetLimit;
1310 SwRectMax fnOverStep;
1311
1312 SwRectSetPos fnSetPos;
1313 SwFrameMakePos fnMakePos;
1314 SwOperator fnXDiff;
1315 SwOperator fnYDiff;
1316 SwOperator fnXInc;
1317 SwOperator fnYInc;
1318
1319 SwRectSetTwice fnSetLeftAndWidth;
1320 SwRectSetTwice fnSetTopAndHeight;
1321};
1322
1323typedef SwRectFnCollection* SwRectFn;
1324
1325// This class allows to use proper methods regardless of orientation (LTR/RTL, horizontal or vertical)
1326extern SwRectFn fnRectHori, fnRectVert, fnRectVertL2R, fnRectVertL2RB2T;
1327class SwRectFnSet {
1328public:
1329 explicit SwRectFnSet(const SwFrame *pFrame)
1330 : m_bVert(pFrame->IsVertical())
1331 , m_bVertL2R(pFrame->IsVertLR())
1332 , m_bVertL2RB2T(pFrame->IsVertLRBT())
1333 {
1334 m_fnRect = m_bVert ? (m_bVertL2R ? (m_bVertL2RB2T ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert) : fnRectHori;
1335 }
1336
1337 void Refresh(const SwFrame *pFrame)
1338 {
1339 m_bVert = pFrame->IsVertical();
1340 m_bVertL2R = pFrame->IsVertLR();
1341 m_bVertL2RB2T = pFrame->IsVertLRBT();
1342 m_fnRect = m_bVert ? (m_bVertL2R ? (m_bVertL2RB2T ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert) : fnRectHori;
1343 }
1344
1345 bool IsVert() const { return m_bVert; }
1346 bool IsVertL2R() const { return m_bVertL2R; }
1347 SwRectFn FnRect() const { return m_fnRect; }
1348
1349 bool PosDiff(const SwRect &rRect1, const SwRect &rRect2) const
1350 {
1351 return ((rRect1.*m_fnRect->fnGetTop)() != (rRect2.*m_fnRect->fnGetTop)()
1352 || (rRect1.*m_fnRect->fnGetLeft)() != (rRect2.*m_fnRect->fnGetLeft)());
1353 }
1354
1355 long GetTop (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetTop) (); }
1356 long GetBottom(const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetBottom)(); }
1357 long GetLeft (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetLeft) (); }
1358 long GetRight (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetRight) (); }
1359 long GetWidth (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetWidth) (); }
1360 long GetHeight(const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetHeight)(); }
1361 Point GetPos (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetPos) (); }
1362 Size GetSize (const SwRect& rRect) const { return (rRect.*m_fnRect->fnGetSize) (); }
1363
1364 void SetTop (SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSetTop) (nNew); }
1365 void SetBottom(SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSetBottom)(nNew); }
1366 void SetLeft (SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSetLeft) (nNew); }
1367 void SetRight (SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSetRight) (nNew); }
1368 void SetWidth (SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSetWidth) (nNew); }
1369 void SetHeight(SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSetHeight)(nNew); }
1370
1371 void SubTop (SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSubTop) (nNew); }
1372 void AddBottom(SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnAddBottom)(nNew); }
1373 void SubLeft (SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSubLeft) (nNew); }
1374 void AddRight (SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnAddRight) (nNew); }
1375 void AddWidth (SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnAddWidth) (nNew); }
1376 void AddHeight(SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnAddHeight)(nNew); }
1377
1378 void SetPosX(SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSetPosX)(nNew); }
1379 void SetPosY(SwRect& rRect, long nNew) const { (rRect.*m_fnRect->fnSetPosY)(nNew); }
1380
1381 long GetTopMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetTopMargin) (); }
1382 long GetBottomMargin(const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetBottomMargin)(); }
1383 long GetLeftMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetLeftMargin) (); }
1384 long GetRightMargin (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetRightMargin) (); }
1385 void SetXMargins(SwFrame& rFrame, long nLeft, long nRight) const { (rFrame.*m_fnRect->fnSetXMargins)(nLeft, nRight); }
1386 void SetYMargins(SwFrame& rFrame, long nTop, long nBottom) const { (rFrame.*m_fnRect->fnSetYMargins)(nTop, nBottom); }
1387 long GetPrtTop (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtTop) (); }
1388 long GetPrtBottom (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtBottom) (); }
1389 long GetPrtLeft (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtLeft) (); }
1390 long GetPrtRight (const SwFrame& rFrame) const { return (rFrame.*m_fnRect->fnGetPrtRight) (); }
1391 long TopDist (const SwRect& rRect, long nPos) const { return (rRect.*m_fnRect->fnTopDist) (nPos); }
1392 long BottomDist(const SwRect& rRect, long nPos) const { return (rRect.*m_fnRect->fnBottomDist) (nPos); }
1393 long LeftDist (const SwRect& rRect, long nPos) const { return (rRect.*m_fnRect->fnLeftDist) (nPos); }
1394 long RightDist (const SwRect& rRect, long nPos) const { return (rRect.*m_fnRect->fnRightDist) (nPos); }
1395 void SetLimit (SwFrame& rFrame, long nNew) const { (rFrame.*m_fnRect->fnSetLimit) (nNew); }
1396 bool OverStep (const SwRect& rRect, long nPos) const { return (rRect.*m_fnRect->fnOverStep) (nPos); }
1397
1398 void SetPos(SwRect& rRect, const Point& rNew) const { (rRect.*m_fnRect->fnSetPos)(rNew); }
1399 void MakePos(SwFrame& rFrame, const SwFrame* pUp, const SwFrame* pPrv, bool bNotify) const { (rFrame.*m_fnRect->fnMakePos)(pUp, pPrv, bNotify); }
1400 long XDiff(long n1, long n2) const { return (m_fnRect->fnXDiff) (n1, n2); }
1401 long YDiff(long n1, long n2) const { return (m_fnRect->fnYDiff) (n1, n2); }
1402 long XInc (long n1, long n2) const { return (m_fnRect->fnXInc) (n1, n2); }
1403 long YInc (long n1, long n2) const { return (m_fnRect->fnYInc) (n1, n2); }
1404
1405 void SetLeftAndWidth(SwRect& rRect, long nLeft, long nWidth) const { (rRect.*m_fnRect->fnSetLeftAndWidth)(nLeft, nWidth); }
1406 void SetTopAndHeight(SwRect& rRect, long nTop, long nHeight) const { (rRect.*m_fnRect->fnSetTopAndHeight)(nTop, nHeight); }
1407
1408private:
1409 bool m_bVert;
1410 bool m_bVertL2R;
1411 bool m_bVertL2RB2T;
1412 SwRectFn m_fnRect;
1413};
1414
1415#endif
1416
1417/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/home/maarten/src/libreoffice/core/sw/source/core/inc/pagefrm.hxx

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_SOURCE_CORE_INC_PAGEFRM_HXX
20#define INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
21
22#include <viewsh.hxx>
23#include "ftnboss.hxx"
24#include "hffrm.hxx"
25
26#include <SidebarWindowsTypes.hxx>
27
28class SwFlyFrame;
29class SwFlyFrameFormat;
30class SwPageDesc;
31class SwContentFrame;
32struct SwPosition;
33struct SwCursorMoveState;
34class SwAttrSetChg;
35namespace vcl { class Font; }
36class SwSortedObjs;
37class SwAnchoredObject;
38
39/// A page of the document layout. Upper frame is expected to be an SwRootFrame
40/// instance. At least an SwBodyFrame lower is expected.
41class SAL_DLLPUBLIC_RTTI__attribute__ ((type_visibility("default"))) SwPageFrame: public SwFootnoteBossFrame
42{
43 friend class SwFrame;
44
45 std::unique_ptr<SwSortedObjs> m_pSortedObjs;
46
47 SwPageDesc *m_pDesc; //PageDesc that describes the Page
48
49 /// Physical page number: index into list of SwRootFrame lowers
50 sal_uInt16 m_nPhyPageNum;
51
52 bool m_bInvalidContent :1;
53 bool m_bInvalidLayout :1;
54 bool m_bInvalidFlyContent :1;
55 bool m_bInvalidFlyLayout :1;
56 bool m_bInvalidFlyInCnt :1;
57 bool m_bFootnotePage :1; // This Page is for document end footnotes
58 bool m_bEmptyPage :1; // This Page is an explicitly empty page
59 bool m_bEndNotePage :1; // 'Footnote page' for end notes
60 bool m_bInvalidSpelling :1; // We need online spelling
61 bool m_bInvalidSmartTags :1; // We need checking for smarttags
62 bool m_bInvalidAutoCmplWrds :1; // Update auto complete word list
63 bool m_bInvalidWordCount :1;
64 bool m_bHasGrid :1; // Grid for Asian layout
65
66 static const sal_Int8 mnShadowPxWidth;
67
68 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
69 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
70
71 /// Adapt the max. footnote height in each single column
72 void SetColMaxFootnoteHeight();
73
74 /** determine rectangle for horizontal page shadow
75
76 #i9719#
77
78 @param _rPageRect
79 input parameter - constant instance reference of the page rectangle.
80 Generally, it's the frame area of the page, but for empty pages in print
81 preview, this parameter is useful.
82
83 @param _pViewShell
84 input parameter - instance of the view shell, for which the rectangle
85 has to be generated.
86
87 @param _orBottomShadowRect
88 output parameter - instance reference of the bottom shadow rectangle for
89 the given page rectangle
90 */
91
92 static void GetHorizontalShadowRect( const SwRect& _rPageRect,
93 const SwViewShell* _pViewShell,
94 OutputDevice const * pRenderContext,
95 SwRect& _orBottomShadowRect,
96 bool bPaintLeftShadow,
97 bool bPaintRightShadow,
98 bool bRightSidebar );
99
100 virtual void DestroyImpl() override;
101 virtual ~SwPageFrame() override;
102
103protected:
104 virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
105 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
106 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
107
108 /// Calculate the content height of a page (without columns).
109 size_t GetContentHeight(const long nTop, const long nBottom) const;
110
111public:
112 SwPageFrame( SwFrameFormat*, SwFrame*, SwPageDesc* );
113
114 /// Make this public, so that the SwViewShell can access it when switching from browse mode
115 /// Add/remove header/footer
116 void PrepareHeader();
117 void PrepareFooter();
118
119 const SwSortedObjs *GetSortedObjs() const { return m_pSortedObjs.get(); }
120 SwSortedObjs *GetSortedObjs() { return m_pSortedObjs.get(); }
121
122 void AppendDrawObjToPage( SwAnchoredObject& _rNewObj );
123 void RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj );
124
125 void AppendFlyToPage( SwFlyFrame *pNew );
126 void RemoveFlyFromPage( SwFlyFrame *pToRemove );
127 void MoveFly( SwFlyFrame *pToMove, SwPageFrame *pDest ); // Optimized Remove/Append
128
129 void SetPageDesc( SwPageDesc *, SwFrameFormat * );
130 SwPageDesc *GetPageDesc() { return m_pDesc; }
131 const SwPageDesc *GetPageDesc() const { return m_pDesc; }
132 SwPageDesc *FindPageDesc();
133
134 SwContentFrame *FindLastBodyContent();
135 inline SwContentFrame *FindFirstBodyContent();
136 inline const SwContentFrame *FindFirstBodyContent() const;
137 inline const SwContentFrame *FindLastBodyContent() const;
138
139 SwRect GetBoundRect(OutputDevice const * pOutputDevice) const;
140
141 // Specialized GetContentPos() for Field in Frames
142 void GetContentPosition( const Point &rPt, SwPosition &rPos ) const;
143
144 bool IsEmptyPage() const { return m_bEmptyPage; } // Explicitly empty page
145
146 void UpdateFootnoteNum();
147
148 /// Always call after Paste
149 /// Creates the page-bound frames and formats the generic content
150 void PreparePage( bool bFootnote );
151
152 // Sends a Prepare() to all ContentFrames caused by a changed register template
153 void PrepareRegisterChg();
154
155 // Appends a fly frame - the given one or a new one - at the page frame.
156 // Needed for <Modify> and <MakeFrames>
157 // - return value not needed any more
158 // - second parameter is of type <SwFlyFrameFormat*>
159 // - third parameter only needed for assertion, but calling method assures
160 // this assertion. Thus, delete it.
161 void PlaceFly( SwFlyFrame* pFly, SwFlyFrameFormat* pFormat );
162
163 virtual bool GetModelPositionForViewPoint( SwPosition *, Point&,
164 SwCursorMoveState* = nullptr, bool bTestBackground = false ) const override;
165 /// Get info from Client
166 virtual bool GetInfo( SfxPoolItem& ) const override;
167
168 virtual void Cut() override;
169 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
170 virtual void CheckDirection( bool bVert ) override;
171 void CheckGrid( bool bInvalidate );
172 void PaintGrid( OutputDevice const * pOut, SwRect const &rRect ) const;
173 bool HasGrid() const { return m_bHasGrid; }
174
175 void PaintDecorators( ) const;
176 virtual void PaintSubsidiaryLines( const SwPageFrame*, const SwRect& ) const override;
177 virtual void PaintBreak() const override;
178
179 /// Paint line number etc.
180 void RefreshExtraData( const SwRect & ) const;
181
182 /// Paint helper lines
183 void RefreshSubsidiary( const SwRect& ) const;
184
185 /// Foot note interface
186 bool IsFootnotePage() const { return m_bFootnotePage; }
187 bool IsEndNotePage() const { return m_bEndNotePage; }
188 void SetFootnotePage( bool b ) { m_bFootnotePage = b; }
189 void SetEndNotePage( bool b ) { m_bEndNotePage = b; }
190
191 sal_uInt16 GetPhyPageNum() const { return m_nPhyPageNum;}
192 void SetPhyPageNum( sal_uInt16 nNum ) { m_nPhyPageNum = nNum;}
193
194 /// Validate, invalidate and query the Page status
195 /// Layout/Content and Fly/non-Fly respectively are inspected separately
196 inline void InvalidateFlyLayout() const;
197 inline void InvalidateFlyContent() const;
198 inline void InvalidateFlyInCnt() const;
199 inline void InvalidateLayout() const;
200 inline void InvalidateContent() const;
201 inline void InvalidateSpelling() const;
202 inline void InvalidateSmartTags() const;
203 inline void InvalidateAutoCompleteWords() const;
204 inline void InvalidateWordCount() const;
205 inline void ValidateFlyLayout() const;
206 inline void ValidateFlyContent() const;
207 inline void ValidateFlyInCnt() const;
208 inline void ValidateLayout() const;
209 inline void ValidateContent() const;
210 inline void ValidateSpelling() const;
211 inline void ValidateSmartTags() const;
212 inline void ValidateAutoCompleteWords() const;
213 inline void ValidateWordCount() const;
214 inline bool IsInvalid() const;
215 inline bool IsInvalidFly() const;
216 bool IsRightShadowNeeded() const;
217 bool IsLeftShadowNeeded() const;
218 bool IsInvalidFlyLayout() const { return m_bInvalidFlyLayout; }
219 bool IsInvalidFlyContent() const { return m_bInvalidFlyContent; }
220 bool IsInvalidFlyInCnt() const { return m_bInvalidFlyInCnt; }
221 bool IsInvalidLayout() const { return m_bInvalidLayout; }
222 bool IsInvalidContent() const { return (m_bInvalidContent || m_bInvalidFlyInCnt); }
223 bool IsInvalidSpelling() const { return m_bInvalidSpelling; }
224 bool IsInvalidSmartTags() const { return m_bInvalidSmartTags; }
225 bool IsInvalidAutoCompleteWords() const { return m_bInvalidAutoCmplWrds; }
226 bool IsInvalidWordCount() const { return m_bInvalidWordCount; }
227
228 /** SwPageFrame::GetDrawBackgrdColor
229
230 determine the color, that is respectively will be drawn as background
231 for the page frame.
232
233 @return reference to an instance of class Color
234 */
235 Color GetDrawBackgrdColor() const;
236
237 /** paint margin area of a page
238
239 implement paint of margin area; margin area will be painted for a
240 view shell with a window and if the document is not in online layout.
241
242 @param _rOutputRect
243 input parameter - constant instance reference of the rectangle, for
244 which an output has to be generated.
245
246 @param _pViewShell
247 input parameter - instance of the view shell, on which the output
248 has to be generated.
249 */
250 void PaintMarginArea( const SwRect& _rOutputRect,
251 SwViewShell const * _pViewShell ) const;
252
253 /** paint page border and shadow
254
255 @param _rPageRect
256 input parameter - constant instance reference of the page rectangle.
257 Generally, it's the frame area of the page, but for empty pages in print
258 preview, this parameter is useful.
259
260 @param _pViewShell
261 input parameter - instance of the view shell, on which the output
262 has to be generated.
263
264 @param bPaintRightShadow
265 Should we paint shadow on the right or not (used in book mode)
266
267 @param bFullBottomShadow
268 Should we have a bottom shadow of the same size as the pages or
269 not (for right pages in book mode in a LTR environment).
270
271 @param bRightSidebar
272 Is the note sidebar on the right or not (used to adjust the
273 shadow with & position).
274 */
275 static void PaintBorderAndShadow( const SwRect& _rPageRect,
276 const SwViewShell* _pViewShell,
277 bool bPaintLeftShadow,
278 bool bPaintRightShadow,
279 bool bRightSidebar );
280
281 /** get bound rectangle of border and shadow for repaints
282
283 @param _rPageRect
284 input parameter - constant instance reference of the page rectangle.
285 Generally, it's the frame area of the page, but for empty pages in print
286 preview, this parameter is useful.
287
288 @param _pViewShell
289 input parameter - instance of the view shell, for which the rectangle
290 has to be generated.
291
292 @param _orBorderAndShadowBoundRect
293 output parameter - instance reference of the bounded border and shadow
294 rectangle for the given page rectangle
295 */
296 static void GetBorderAndShadowBoundRect( const SwRect& _rPageRect,
297 const SwViewShell* _pViewShell,
298 OutputDevice const * pRenderContext,
299 SwRect& _orBorderAndShadowBoundRect,
300 const bool bLeftShadow,
301 const bool bRightShadow,
302 const bool bRightSidebar
303 );
304
305 static void PaintNotesSidebar(const SwRect& _rPageRect, SwViewShell* _pViewShell, sal_uInt16 nPageNum, bool bRight);
306 static void PaintNotesSidebarArrows(const Point &rMiddleFirst, const Point &rMiddleSecond, SwViewShell const * _pViewShell, const Color& rColorUp, const Color& rColorDown);
307 /**
308 asks the page on which side a margin should be shown, e.g for notes
309 returns true for left side, false for right side
310 */
311 sw::sidebarwindows::SidebarPosition SidebarPosition() const;
312
313 virtual bool FillSelection( SwSelectionList& rList, const SwRect& rRect ) const override;
314
315 SwRect PrtWithoutHeaderAndFooter() const;
316
317 // in case this is an empty page, this function returns the 'reference' page
318 const SwPageFrame& GetFormatPage() const;
319
320 /// If in header or footer area, it also indicates the exact area in rControl.
321 /// Header or footer must be active, otherwise returns false.
322 bool IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const;
323
324 // return font used to paint the "empty page" string
325 static const vcl::Font& GetEmptyPageFont();
326
327 static SwTwips GetSidebarBorderWidth( const SwViewShell* );
328
329 /// Is bottom-of-page-frame - bottom-of-text-frame difference valid in case whitespace is hidden?
330 /// If false is returned, then the caller should handle negative difference as (at least) zero difference instead.
331 bool CheckPageHeightValidForHideWhitespace(SwTwips nDiff);
332
333 const SwHeaderFrame* GetHeaderFrame() const;
334 const SwFooterFrame* GetFooterFrame() const;
335};
336
337inline SwContentFrame *SwPageFrame::FindFirstBodyContent()
338{
339 SwLayoutFrame *pBody = FindBodyCont();
340 return pBody ? pBody->ContainsContent() : nullptr;
341}
342inline const SwContentFrame *SwPageFrame::FindFirstBodyContent() const
343{
344 const SwLayoutFrame *pBody = FindBodyCont();
345 return pBody ? pBody->ContainsContent() : nullptr;
346}
347inline const SwContentFrame *SwPageFrame::FindLastBodyContent() const
348{
349 return const_cast<SwPageFrame*>(this)->FindLastBodyContent();
350}
351inline void SwPageFrame::InvalidateFlyLayout() const
352{
353 const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = true;
354}
355inline void SwPageFrame::InvalidateFlyContent() const
356{
357 const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = true;
358}
359inline void SwPageFrame::InvalidateFlyInCnt() const
360{
361 const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = true;
362}
363inline void SwPageFrame::InvalidateLayout() const
364{
365 const_cast<SwPageFrame*>(this)->m_bInvalidLayout = true;
366}
367inline void SwPageFrame::InvalidateContent() const
368{
369 const_cast<SwPageFrame*>(this)->m_bInvalidContent = true;
370}
371inline void SwPageFrame::InvalidateSpelling() const
372{
373 const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = true;
374}
375
376inline void SwPageFrame::InvalidateSmartTags() const
377{
378 const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = true;
379}
380inline void SwPageFrame::InvalidateAutoCompleteWords() const
381{
382 const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = true;
383}
384inline void SwPageFrame::InvalidateWordCount() const
385{
386 const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = true;
387}
388inline void SwPageFrame::ValidateFlyLayout() const
389{
390 const_cast<SwPageFrame*>(this)->m_bInvalidFlyLayout = false;
391}
392inline void SwPageFrame::ValidateFlyContent() const
393{
394 const_cast<SwPageFrame*>(this)->m_bInvalidFlyContent = false;
395}
396inline void SwPageFrame::ValidateFlyInCnt() const
397{
398 const_cast<SwPageFrame*>(this)->m_bInvalidFlyInCnt = false;
399}
400inline void SwPageFrame::ValidateLayout() const
401{
402 const_cast<SwPageFrame*>(this)->m_bInvalidLayout = false;
403}
404inline void SwPageFrame::ValidateContent() const
405{
406 const_cast<SwPageFrame*>(this)->m_bInvalidContent = false;
407}
408inline void SwPageFrame::ValidateSpelling() const
409{
410 const_cast<SwPageFrame*>(this)->m_bInvalidSpelling = false;
411}
412
413inline void SwPageFrame::ValidateSmartTags() const
414{
415 const_cast<SwPageFrame*>(this)->m_bInvalidSmartTags = false;
416}
417inline void SwPageFrame::ValidateAutoCompleteWords() const
418{
419 const_cast<SwPageFrame*>(this)->m_bInvalidAutoCmplWrds = false;
420}
421inline void SwPageFrame::ValidateWordCount() const
422{
423 const_cast<SwPageFrame*>(this)->m_bInvalidWordCount = false;
424}
425
426inline bool SwPageFrame::IsInvalid() const
427{
428 return (m_bInvalidContent || m_bInvalidLayout || m_bInvalidFlyInCnt);
63
Assuming field 'm_bInvalidContent' is false
64
Assuming field 'm_bInvalidLayout' is false
65
Returning value, which participates in a condition later
429}
430inline bool SwPageFrame::IsInvalidFly() const
431{
432 return m_bInvalidFlyLayout || m_bInvalidFlyContent;
433}
434
435
436class SwTextGridItem;
437
438SwTextGridItem const* GetGridItem(SwPageFrame const*const);
439
440sal_uInt16 GetGridWidth(SwTextGridItem const&, SwDoc const&);
441
442#endif // INCLUDED_SW_SOURCE_CORE_INC_PAGEFRM_HXX
443
444/* vim:set shiftwidth=4 softtabstop=4 expandtab: */