Bug Summary

File:home/maarten/src/libreoffice/core/sw/source/core/access/accdoc.cxx
Warning:line 597, column 27
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 accdoc.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/access/accdoc.cxx

/home/maarten/src/libreoffice/core/sw/source/core/access/accdoc.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 <vcl/window.hxx>
21#include <rootfrm.hxx>
22
23#include <com/sun/star/accessibility/AccessibleRole.hpp>
24#include <com/sun/star/accessibility/AccessibleStateType.hpp>
25#include <com/sun/star/accessibility/AccessibleEventId.hpp>
26#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
27#include <unotools/accessiblestatesethelper.hxx>
28#include <cppuhelper/typeprovider.hxx>
29#include <vcl/svapp.hxx>
30#include <cppuhelper/supportsservice.hxx>
31#include <viewsh.hxx>
32#include <doc.hxx>
33#include <accmap.hxx>
34#include "accdoc.hxx"
35#include <strings.hrc>
36#include <pagefrm.hxx>
37
38#include <swatrset.hxx>
39#include <docsh.hxx>
40#include <crsrsh.hxx>
41#include <fesh.hxx>
42#include <fmtclds.hxx>
43#include <flyfrm.hxx>
44#include <txtfrm.hxx>
45#include <sectfrm.hxx>
46#include <section.hxx>
47#include <svx/unoapi.hxx>
48#include <swmodule.hxx>
49#include <svtools/colorcfg.hxx>
50
51#include <fmtanchr.hxx>
52#include <viewimp.hxx>
53#include <dview.hxx>
54#include <dcontact.hxx>
55#include <svx/svdmark.hxx>
56const char sServiceName[] = "com.sun.star.text.AccessibleTextDocumentView";
57const char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleDocumentView";
58
59using namespace ::com::sun::star;
60using namespace ::com::sun::star::accessibility;
61
62using lang::IndexOutOfBoundsException;
63
64// SwAccessibleDocumentBase: base class for SwAccessibleDocument and
65// SwAccessiblePreview
66
67SwAccessibleDocumentBase::SwAccessibleDocumentBase(
68 std::shared_ptr<SwAccessibleMap> const& pMap)
69 : SwAccessibleContext(pMap, AccessibleRole::DOCUMENT_TEXT,
70 pMap->GetShell()->GetLayout())
71 , mxParent(pMap->GetShell()->GetWin()->GetAccessibleParentWindow()->GetAccessible())
72 , mpChildWin(nullptr)
73{
74}
75
76SwAccessibleDocumentBase::~SwAccessibleDocumentBase()
77{
78}
79
80void SwAccessibleDocumentBase::SetVisArea()
81{
82 SolarMutexGuard aGuard;
83
84 SwRect aOldVisArea( GetVisArea() );
85 const SwRect& rNewVisArea = GetMap()->GetVisArea();
86 if( aOldVisArea != rNewVisArea )
87 {
88 SwAccessibleFrame::SetVisArea( GetMap()->GetVisArea() );
89 // #i58139# - showing state of document view needs also be updated.
90 // Thus, call method <Scrolled(..)> instead of <ChildrenScrolled(..)>
91 // ChildrenScrolled( GetFrame(), aOldVisArea );
92 Scrolled( aOldVisArea );
93 }
94}
95
96void SwAccessibleDocumentBase::AddChild( vcl::Window *pWin, bool bFireEvent )
97{
98 SolarMutexGuard aGuard;
99
100 OSL_ENSURE( !mpChildWin, "only one child window is supported" )do { if (true && (!(!mpChildWin))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/access/accdoc.cxx"
":" "100" ": "), "%s", "only one child window is supported")
; } } while (false)
;
101 if( !mpChildWin )
102 {
103 mpChildWin = pWin;
104
105 if( bFireEvent )
106 {
107 AccessibleEventObject aEvent;
108 aEvent.EventId = AccessibleEventId::CHILD;
109 aEvent.NewValue <<= mpChildWin->GetAccessible();
110 FireAccessibleEvent( aEvent );
111 }
112 }
113}
114
115void SwAccessibleDocumentBase::RemoveChild( vcl::Window *pWin )
116{
117 SolarMutexGuard aGuard;
118
119 OSL_ENSURE( !mpChildWin || pWin == mpChildWin, "invalid child window to remove" )do { if (true && (!(!mpChildWin || pWin == mpChildWin
))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sw/source/core/access/accdoc.cxx"
":" "119" ": "), "%s", "invalid child window to remove"); } }
while (false)
;
120 if( mpChildWin && pWin == mpChildWin )
121 {
122 AccessibleEventObject aEvent;
123 aEvent.EventId = AccessibleEventId::CHILD;
124 aEvent.OldValue <<= mpChildWin->GetAccessible();
125 FireAccessibleEvent( aEvent );
126
127 mpChildWin = nullptr;
128 }
129}
130
131sal_Int32 SAL_CALL SwAccessibleDocumentBase::getAccessibleChildCount()
132{
133 SolarMutexGuard aGuard;
134
135 // ThrowIfDisposed is called by parent
136
137 sal_Int32 nChildren = SwAccessibleContext::getAccessibleChildCount();
138 if( !IsDisposing() && mpChildWin )
139 nChildren++;
140
141 return nChildren;
142}
143
144uno::Reference< XAccessible> SAL_CALL
145 SwAccessibleDocumentBase::getAccessibleChild( sal_Int32 nIndex )
146{
147 SolarMutexGuard aGuard;
148
149 if( mpChildWin )
150 {
151 ThrowIfDisposed();
152
153 if ( nIndex == GetChildCount( *(GetMap()) ) )
154 {
155 return mpChildWin->GetAccessible();
156 }
157 }
158
159 return SwAccessibleContext::getAccessibleChild( nIndex );
160}
161
162uno::Reference< XAccessible> SAL_CALL SwAccessibleDocumentBase::getAccessibleParent()
163{
164 return mxParent;
165}
166
167sal_Int32 SAL_CALL SwAccessibleDocumentBase::getAccessibleIndexInParent()
168{
169 SolarMutexGuard aGuard;
170
171 uno::Reference < XAccessibleContext > xAcc( mxParent->getAccessibleContext() );
172 uno::Reference < XAccessible > xThis( this );
173 sal_Int32 nCount = xAcc->getAccessibleChildCount();
174
175 for( sal_Int32 i=0; i < nCount; i++ )
176 {
177 try
178 {
179 if( xAcc->getAccessibleChild( i ) == xThis )
180 return i;
181 }
182 catch(const css::lang::IndexOutOfBoundsException &)
183 {
184 return -1;
185 }
186 }
187 return -1;
188}
189
190OUString SAL_CALL SwAccessibleDocumentBase::getAccessibleDescription()
191{
192 return GetResource( STR_ACCESS_DOC_DESCreinterpret_cast<char const *>("STR_ACCESS_DOC_DESC" "\004"
u8"Document view")
);
193}
194
195OUString SAL_CALL SwAccessibleDocumentBase::getAccessibleName()
196{
197 SolarMutexGuard g;
198
199 OUString sAccName = GetResource( STR_ACCESS_DOC_WORDPROCESSINGreinterpret_cast<char const *>("STR_ACCESS_DOC_WORDPROCESSING"
"\004" u8"%PRODUCTNAME Document")
);
200 SwDoc *pDoc = GetMap() ? GetShell()->GetDoc() : nullptr;
201 if ( pDoc )
202 {
203 OUString sFileName = pDoc->getDocAccTitle();
204 if ( sFileName.isEmpty() )
205 {
206 SwDocShell* pDocSh = pDoc->GetDocShell();
207 if ( pDocSh )
208 {
209 sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME3 );
210 }
211 }
212
213 if ( !sFileName.isEmpty() )
214 {
215 sAccName = sFileName + " - " + sAccName;
216 }
217 }
218
219 return sAccName;
220}
221
222awt::Rectangle SAL_CALL SwAccessibleDocumentBase::getBounds()
223{
224 try
225 {
226 SolarMutexGuard aGuard;
227
228 vcl::Window *pWin = GetWindow();
229 if (!pWin)
230 {
231 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
232 }
233
234 tools::Rectangle aPixBounds( pWin->GetWindowExtentsRelative( pWin->GetAccessibleParentWindow() ) );
235 awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(),
236 aPixBounds.GetWidth(), aPixBounds.GetHeight() );
237
238 return aBox;
239 }
240 catch(const css::lang::IndexOutOfBoundsException &)
241 {
242 return awt::Rectangle();
243 }
244}
245
246awt::Point SAL_CALL SwAccessibleDocumentBase::getLocation()
247{
248 SolarMutexGuard aGuard;
249
250 vcl::Window *pWin = GetWindow();
251 if (!pWin)
252 {
253 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
254 }
255
256 Point aPixPos( pWin->GetWindowExtentsRelative( pWin->GetAccessibleParentWindow() ).TopLeft() );
257 awt::Point aLoc( aPixPos.getX(), aPixPos.getY() );
258
259 return aLoc;
260}
261
262css::awt::Point SAL_CALL SwAccessibleDocumentBase::getLocationOnScreen()
263{
264 SolarMutexGuard aGuard;
265
266 vcl::Window *pWin = GetWindow();
267 if (!pWin)
268 {
269 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
270 }
271
272 Point aPixPos( pWin->GetWindowExtentsRelative( nullptr ).TopLeft() );
273 awt::Point aLoc( aPixPos.getX(), aPixPos.getY() );
274
275 return aLoc;
276}
277
278css::awt::Size SAL_CALL SwAccessibleDocumentBase::getSize()
279{
280 SolarMutexGuard aGuard;
281
282 vcl::Window *pWin = GetWindow();
283 if (!pWin)
284 {
285 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
286 }
287
288 Size aPixSize( pWin->GetWindowExtentsRelative( nullptr ).GetSize() );
289 awt::Size aSize( aPixSize.Width(), aPixSize.Height() );
290
291 return aSize;
292}
293
294sal_Bool SAL_CALL SwAccessibleDocumentBase::containsPoint(
295 const awt::Point& aPoint )
296{
297 SolarMutexGuard aGuard;
298
299 vcl::Window *pWin = GetWindow();
300 if (!pWin)
301 {
302 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
303 }
304
305 tools::Rectangle aPixBounds( pWin->GetWindowExtentsRelative( nullptr ) );
306 aPixBounds.Move(-aPixBounds.Left(), -aPixBounds.Top());
307
308 Point aPixPoint( aPoint.X, aPoint.Y );
309 return aPixBounds.IsInside( aPixPoint );
310}
311
312uno::Reference< XAccessible > SAL_CALL SwAccessibleDocumentBase::getAccessibleAtPoint(
313 const awt::Point& aPoint )
314{
315 SolarMutexGuard aGuard;
316
317 if( mpChildWin )
318 {
319 ThrowIfDisposed();
320
321 vcl::Window *pWin = GetWindow();
322 if (!pWin)
323 {
324 throw uno::RuntimeException("no Window", static_cast<cppu::OWeakObject*>(this));
325 }
326
327 Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to window
328 if( mpChildWin->GetWindowExtentsRelative( pWin ).IsInside( aPixPoint ) )
329 return mpChildWin->GetAccessible();
330 }
331
332 return SwAccessibleContext::getAccessibleAtPoint( aPoint );
333}
334
335// SwAccessibleDocument
336
337void SwAccessibleDocument::GetStates(
338 ::utl::AccessibleStateSetHelper& rStateSet )
339{
340 SwAccessibleContext::GetStates( rStateSet );
341
342 // MULTISELECTABLE
343 rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE );
344 rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
345}
346
347SwAccessibleDocument::SwAccessibleDocument(
348 std::shared_ptr<SwAccessibleMap> const& pInitMap)
349 : SwAccessibleDocumentBase(pInitMap)
350 , maSelectionHelper(*this)
351{
352 SetName(pInitMap->GetDocName());
353 vcl::Window *pWin = pInitMap->GetShell()->GetWin();
354 if( pWin )
355 {
356 pWin->AddChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener )::tools::detail::makeLink( ::tools::detail::castTo<SwAccessibleDocument
*>(this), &SwAccessibleDocument::LinkStubWindowChildEventListener
)
);
357 sal_uInt16 nCount = pWin->GetChildCount();
358 for( sal_uInt16 i=0; i < nCount; i++ )
359 {
360 vcl::Window* pChildWin = pWin->GetChild( i );
361 if( pChildWin &&
362 AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
363 AddChild( pChildWin, false );
364 }
365 }
366}
367
368SwAccessibleDocument::~SwAccessibleDocument()
369{
370 vcl::Window *pWin = GetMap() ? GetMap()->GetShell()->GetWin() : nullptr;
371 if( pWin )
372 pWin->RemoveChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener )::tools::detail::makeLink( ::tools::detail::castTo<SwAccessibleDocument
*>(this), &SwAccessibleDocument::LinkStubWindowChildEventListener
)
);
373}
374
375void SwAccessibleDocument::Dispose(bool bRecursive, bool bCanSkipInvisible)
376{
377 OSL_ENSURE( GetFrame() && GetMap(), "already disposed" )do { if (true && (!(GetFrame() && GetMap())))
{ sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"
), ("/home/maarten/src/libreoffice/core/sw/source/core/access/accdoc.cxx"
":" "377" ": "), "%s", "already disposed"); } } while (false
)
;
378
379 vcl::Window *pWin = GetMap() ? GetMap()->GetShell()->GetWin() : nullptr;
380 if( pWin )
381 pWin->RemoveChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener )::tools::detail::makeLink( ::tools::detail::castTo<SwAccessibleDocument
*>(this), &SwAccessibleDocument::LinkStubWindowChildEventListener
)
);
382 SwAccessibleContext::Dispose(bRecursive, bCanSkipInvisible);
383}
384
385IMPL_LINK( SwAccessibleDocument, WindowChildEventListener, VclWindowEvent&, rEvent, void )void SwAccessibleDocument::LinkStubWindowChildEventListener(void
* instance, VclWindowEvent& data) { return static_cast<
SwAccessibleDocument *>(instance)->WindowChildEventListener
(data); } void SwAccessibleDocument::WindowChildEventListener
(VclWindowEvent& rEvent)
386{
387 OSL_ENSURE( rEvent.GetWindow(), "Window???" )do { if (true && (!(rEvent.GetWindow()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/sw/source/core/access/accdoc.cxx"
":" "387" ": "), "%s", "Window???"); } } while (false)
;
388 switch ( rEvent.GetId() )
389 {
390 case VclEventId::WindowShow: // send create on show for direct accessible children
391 {
392 vcl::Window* pChildWin = static_cast< vcl::Window* >( rEvent.GetData() );
393 if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
394 {
395 AddChild( pChildWin );
396 }
397 }
398 break;
399 case VclEventId::WindowHide: // send destroy on hide for direct accessible children
400 {
401 vcl::Window* pChildWin = static_cast< vcl::Window* >( rEvent.GetData() );
402 if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
403 {
404 RemoveChild( pChildWin );
405 }
406 }
407 break;
408 case VclEventId::ObjectDying: // send destroy on hide for direct accessible children
409 {
410 vcl::Window* pChildWin = rEvent.GetWindow();
411 if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
412 {
413 RemoveChild( pChildWin );
414 }
415 }
416 break;
417 default: break;
418 }
419}
420
421OUString SAL_CALL SwAccessibleDocument::getImplementationName()
422{
423 return sImplementationName;
424}
425
426sal_Bool SAL_CALL SwAccessibleDocument::supportsService(const OUString& sTestServiceName)
427{
428 return cppu::supportsService(this, sTestServiceName);
429}
430
431uno::Sequence< OUString > SAL_CALL SwAccessibleDocument::getSupportedServiceNames()
432{
433 return { sServiceName, sAccessibleServiceName };
434}
435
436// XInterface
437
438uno::Any SwAccessibleDocument::queryInterface(
439 const uno::Type& rType )
440{
441 uno::Any aRet;
442 if ( rType == cppu::UnoType<XAccessibleSelection>::get() )
443 {
444 uno::Reference<XAccessibleSelection> aSelect = this;
445 aRet <<= aSelect;
446 }
447 else if ( rType == cppu::UnoType<XAccessibleExtendedAttributes>::get())
448 {
449 uno::Reference<XAccessibleExtendedAttributes> aAttribute = this;
450 aRet <<= aAttribute;
451 }
452 else
453 aRet = SwAccessibleContext::queryInterface( rType );
454 return aRet;
455}
456
457// XTypeProvider
458uno::Sequence< uno::Type > SAL_CALL SwAccessibleDocument::getTypes()
459{
460 return cppu::OTypeCollection(
461 cppu::UnoType<XAccessibleSelection>::get(),
462 SwAccessibleDocumentBase::getTypes() ).getTypes();
463}
464
465uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleDocument::getImplementationId()
466{
467 return css::uno::Sequence<sal_Int8>();
468}
469
470// XAccessibleSelection
471
472void SwAccessibleDocument::selectAccessibleChild(
473 sal_Int32 nChildIndex )
474{
475 maSelectionHelper.selectAccessibleChild(nChildIndex);
476}
477
478sal_Bool SwAccessibleDocument::isAccessibleChildSelected(
479 sal_Int32 nChildIndex )
480{
481 return maSelectionHelper.isAccessibleChildSelected(nChildIndex);
482}
483
484void SwAccessibleDocument::clearAccessibleSelection( )
485{
486}
487
488void SwAccessibleDocument::selectAllAccessibleChildren( )
489{
490 maSelectionHelper.selectAllAccessibleChildren();
491}
492
493sal_Int32 SwAccessibleDocument::getSelectedAccessibleChildCount( )
494{
495 return maSelectionHelper.getSelectedAccessibleChildCount();
496}
497
498uno::Reference<XAccessible> SwAccessibleDocument::getSelectedAccessibleChild(
499 sal_Int32 nSelectedChildIndex )
500{
501 return maSelectionHelper.getSelectedAccessibleChild(nSelectedChildIndex);
502}
503
504// index has to be treated as global child index.
505void SwAccessibleDocument::deselectAccessibleChild(
506 sal_Int32 nChildIndex )
507{
508 maSelectionHelper.deselectAccessibleChild( nChildIndex );
509}
510
511uno::Any SAL_CALL SwAccessibleDocument::getExtendedAttributes()
512{
513 SolarMutexGuard g;
514
515 uno::Any anyAttribute;
516 SwDoc *pDoc = GetMap() ? GetShell()->GetDoc() : nullptr;
1
Assuming the condition is true
2
'?' condition is true
517
518 if (!pDoc)
3
Assuming 'pDoc' is non-null
4
Taking false branch
519 return anyAttribute;
520 SwCursorShell* pCursorShell = GetCursorShell();
521 if( !pCursorShell )
5
Assuming 'pCursorShell' is non-null
6
Taking false branch
522 return anyAttribute;
523
524 SwFEShell* pFEShell = dynamic_cast<const SwFEShell*>( pCursorShell) != nullptr
7
'?' condition is true
525 ? static_cast<SwFEShell*>( pCursorShell )
526 : nullptr;
527 if( pFEShell
7.1
'pFEShell' is non-null
7.1
'pFEShell' is non-null
7.1
'pFEShell' is non-null
)
8
Taking true branch
528 {
529 OUString sDisplay;
530 sal_uInt16 nPage, nLogPage;
531 pFEShell->GetPageNumber(-1,true,nPage,nLogPage,sDisplay);
532
533 OUString sValue = "page-name:" + sDisplay +
534 ";page-number:" +
535 OUString::number( nPage ) +
536 ";total-pages:" +
537 OUString::number( pCursorShell->GetPageCnt() ) + ";";
538
539 SwContentFrame* pCurrFrame = pCursorShell->GetCurrFrame();
540 SwPageFrame* pCurrPage=static_cast<SwFrame*>(pCurrFrame)->FindPageFrame();
541 sal_uLong nLineNum = 0;
542 SwTextFrame* pTextFrame = nullptr;
543 SwTextFrame* pCurrTextFrame = nullptr;
544 pTextFrame = static_cast< SwTextFrame* >(pCurrPage->ContainsContent());
545 if (pCurrFrame->IsInFly())//such as, graphic,chart
9
Calling 'SwFrame::IsInFly'
13
Returning from 'SwFrame::IsInFly'
14
Assuming the condition is false
15
Taking false branch
546 {
547 SwFlyFrame *pFlyFrame = pCurrFrame->FindFlyFrame();
548 const SwFormatAnchor& rAnchor = pFlyFrame->GetFormat()->GetAnchor();
549 RndStdIds eAnchorId = rAnchor.GetAnchorId();
550 if(eAnchorId == RndStdIds::FLY_AS_CHAR)
551 {
552 const SwFrame *pSwFrame = pFlyFrame->GetAnchorFrame();
553 if(pSwFrame->IsTextFrame())
554 pCurrTextFrame = const_cast<SwTextFrame*>(static_cast<const SwTextFrame*>(pSwFrame));
555 }
556 }
557 else
558 {
559 assert(dynamic_cast<SwTextFrame*>(pCurrFrame))(static_cast <bool> (dynamic_cast<SwTextFrame*>(pCurrFrame
)) ? void (0) : __assert_fail ("dynamic_cast<SwTextFrame*>(pCurrFrame)"
, "/home/maarten/src/libreoffice/core/sw/source/core/access/accdoc.cxx"
, 559, __extension__ __PRETTY_FUNCTION__))
;
16
'?' condition is true
560 pCurrTextFrame = static_cast<SwTextFrame* >(pCurrFrame);
561 }
562 //check whether the text frame where the Graph/OLE/Frame anchored is in the Header/Footer
563 SwFrame* pFrame = pCurrTextFrame;
564 while ( pFrame
16.1
'pFrame' is non-null
16.1
'pFrame' is non-null
16.1
'pFrame' is non-null
&& !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() )
17
Loop condition is true. Entering loop body
18
Assuming 'pFrame' is null
565 pFrame = pFrame->GetUpper();
566 if ( pFrame
18.1
'pFrame' is null
18.1
'pFrame' is null
18.1
'pFrame' is null
)
19
Taking false branch
567 pCurrTextFrame = nullptr;
568 //check shape
569 if(pCursorShell->Imp()->GetDrawView())
20
Assuming the condition is false
21
Taking false branch
570 {
571 const SdrMarkList &rMrkList = pCursorShell->Imp()->GetDrawView()->GetMarkedObjectList();
572 for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
573 {
574 SdrObject *pObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
575 SwFrameFormat* pFormat = static_cast<SwDrawContact*>(pObj->GetUserCall())->GetFormat();
576 const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
577 if( RndStdIds::FLY_AS_CHAR != rAnchor.GetAnchorId() )
578 pCurrTextFrame = nullptr;
579 }
580 }
581 //calculate line number
582 if (pCurrTextFrame
21.1
'pCurrTextFrame' is non-null
21.1
'pCurrTextFrame' is non-null
21.1
'pCurrTextFrame' is non-null
&& pTextFrame)
22
Assuming 'pTextFrame' is non-null
23
Taking true branch
583 {
584 if (!(pCurrTextFrame->IsInTab() || pCurrTextFrame->IsInFootnote()))
24
Assuming the condition is false
25
Assuming the condition is true
26
Taking true branch
585 {
586 while( pTextFrame != pCurrTextFrame )
27
Assuming 'pTextFrame' is not equal to 'pCurrTextFrame'
28
Loop condition is true. Entering loop body
37
Assuming 'pTextFrame' is not equal to 'pCurrTextFrame'
38
Loop condition is true. Entering loop body
587 {
588 //check header/footer
589 pFrame = pTextFrame;
590 while ( pFrame
28.1
'pFrame' is non-null
28.1
'pFrame' is non-null
28.1
'pFrame' is non-null
&& !pFrame->IsHeaderFrame() && !pFrame->IsFooterFrame() )
39
Assuming 'pFrame' is null
591 pFrame = pFrame->GetUpper();
592 if ( pFrame
28.2
'pFrame' is non-null
39.1
'pFrame' is null
28.2
'pFrame' is non-null
39.1
'pFrame' is null
28.2
'pFrame' is non-null
39.1
'pFrame' is null
)
29
Taking true branch
40
Taking false branch
593 {
594 pTextFrame = static_cast< SwTextFrame*>(pTextFrame->GetNextContentFrame());
30
Calling 'SwContentFrame::GetNextContentFrame'
34
Returning from 'SwContentFrame::GetNextContentFrame'
35
Value assigned to 'pTextFrame'
595 continue;
36
Execution continues on line 586
596 }
597 if (!(pTextFrame->IsInTab() || pTextFrame->IsInFootnote() || pTextFrame->IsInFly()))
41
Called C++ object pointer is null
598 nLineNum += pTextFrame->GetThisLines();
599 pTextFrame = static_cast< SwTextFrame* >(pTextFrame ->GetNextContentFrame());
600 }
601 SwPaM* pCaret = pCursorShell->GetCursor();
602 if (!pCurrTextFrame->IsEmpty() && pCaret)
603 {
604 assert(pCurrTextFrame->IsTextFrame())(static_cast <bool> (pCurrTextFrame->IsTextFrame()) ?
void (0) : __assert_fail ("pCurrTextFrame->IsTextFrame()"
, "/home/maarten/src/libreoffice/core/sw/source/core/access/accdoc.cxx"
, 604, __extension__ __PRETTY_FUNCTION__))
;
605 const SwPosition* pPoint = nullptr;
606 if (pCurrTextFrame->IsInFly())
607 {
608 SwFlyFrame *pFlyFrame = pCurrTextFrame->FindFlyFrame();
609 const SwFormatAnchor& rAnchor = pFlyFrame->GetFormat()->GetAnchor();
610 pPoint = rAnchor.GetContentAnchor();
611 SwContentNode *const pNode(pPoint->nNode.GetNode().GetContentNode());
612 pCurrTextFrame = pNode
613 ? static_cast<SwTextFrame*>(pNode->getLayoutFrame(
614 pCurrTextFrame->getRootFrame(), pPoint))
615 : nullptr;
616 }
617 else
618 pPoint = pCaret->GetPoint();
619 if (pCurrTextFrame)
620 {
621 TextFrameIndex const nActPos(pCurrTextFrame->MapModelToViewPos(*pPoint));
622 nLineNum += pCurrTextFrame->GetLineCount( nActPos );
623 }
624 }
625 else
626 ++nLineNum;
627 }
628 }
629
630 sValue += "line-number:" + OUString::number( nLineNum ) + ";";
631
632 SwFrame* pCurrCol=static_cast<SwFrame*>(pCurrFrame)->FindColFrame();
633
634 sValue += "column-number:";
635
636 int nCurrCol = 1;
637 if(pCurrCol!=nullptr)
638 {
639 //SwLayoutFrame* pParent = pCurrCol->GetUpper();
640 SwFrame* pCurrPageCol=static_cast<SwFrame*>(pCurrFrame)->FindColFrame();
641 while(pCurrPageCol && pCurrPageCol->GetUpper() && pCurrPageCol->GetUpper()->IsPageFrame())
642 {
643 pCurrPageCol = pCurrPageCol->GetUpper();
644 }
645
646 SwLayoutFrame* pParent = pCurrPageCol->GetUpper();
647
648 if(pParent!=nullptr)
649 {
650 SwFrame* pCol = pParent->Lower();
651 while(pCol&&(pCol!=pCurrPageCol))
652 {
653 pCol = pCol->GetNext();
654 ++nCurrCol;
655 }
656 }
657 }
658 sValue += OUString::number( nCurrCol ) + ";";
659
660 const SwFormatCol &rFormatCol=pCurrPage->GetAttrSet()->GetCol();
661 sal_uInt16 nColCount=rFormatCol.GetNumCols();
662 nColCount = nColCount>0?nColCount:1;
663 sValue += "total-columns:" + OUString::number( nColCount ) + ";";
664
665 SwSectionFrame* pCurrSctFrame=static_cast<SwFrame*>(pCurrFrame)->FindSctFrame();
666 if(pCurrSctFrame!=nullptr && pCurrSctFrame->GetSection()!=nullptr )
667 {
668 OUString sectionName = pCurrSctFrame->GetSection()->GetSectionName();
669
670 sectionName = sectionName.replaceFirst( "\\" , "\\\\" );
671 sectionName = sectionName.replaceFirst( "=" , "\\=" );
672 sectionName = sectionName.replaceFirst( ";" , "\\;" );
673 sectionName = sectionName.replaceFirst( "," , "\\," );
674 sectionName = sectionName.replaceFirst( ":" , "\\:" );
675
676 sValue += "section-name:" + sectionName + ";";
677
678 //section-columns-number
679
680 nCurrCol = 1;
681
682 if(pCurrCol!=nullptr)
683 {
684 SwLayoutFrame* pParent = pCurrCol->GetUpper();
685 if(pParent!=nullptr)
686 {
687 SwFrame* pCol = pParent->Lower();
688 while(pCol&&(pCol!=pCurrCol))
689 {
690 pCol = pCol->GetNext();
691 nCurrCol +=1;
692 }
693 }
694 }
695 sValue += "section-columns-number:" +
696 OUString::number( nCurrCol ) + ";";
697
698 //section-total-columns
699 const SwFormatCol &rFormatSctCol=pCurrSctFrame->GetAttrSet()->GetCol();
700 sal_uInt16 nSctColCount=rFormatSctCol.GetNumCols();
701 nSctColCount = nSctColCount>0?nSctColCount:1;
702 sValue += "section-total-columns:" +
703 OUString::number( nSctColCount ) + ";";
704 }
705
706 anyAttribute <<= sValue;
707 }
708 return anyAttribute;
709}
710
711sal_Int32 SAL_CALL SwAccessibleDocument::getBackground()
712{
713 SolarMutexGuard aGuard;
714 return sal_Int32(SW_MOD()( static_cast<SwModule*>(SfxApplication::GetModule(SfxToolsModule
::Writer)))
->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor);
715}
716
717/* 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(); }
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(); }
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 )
10
Assuming field 'mbInfInvalid' is false
11
Taking false branch
942 const_cast<SwFrame*>(this)->SetInfFlags();
943 return mbInfFly;
12
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();
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/cntfrm.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_CNTFRM_HXX
21#define INCLUDED_SW_SOURCE_CORE_INC_CNTFRM_HXX
22
23#include "frame.hxx"
24#include "flowfrm.hxx"
25#include <cshtyp.hxx>
26
27class SwLayoutFrame;
28class SwContentNode;
29class SwBorderAttrs;
30class SwAttrSetChg;
31class SwTextFrame;
32
33// implemented in cntfrm.cxx, used in cntfrm.cxx and crsrsh.cxx
34extern bool GetFrameInPage( const SwContentFrame*, SwWhichPage, SwPosPage, SwPaM* );
35
36class SAL_DLLPUBLIC_RTTI__attribute__ ((type_visibility("default"))) SwContentFrame: public SwFrame, public SwFlowFrame
37{
38 friend void MakeNxt( SwFrame *pFrame, SwFrame *pNxt ); // calls MakePrtArea
39
40 // parameter <bObjsInNewUpper> indicates that objects exist in remaining
41 // area of new upper
42 bool WouldFit_( SwTwips nSpace,
43 SwLayoutFrame *pNewUpper,
44 bool bTstMove,
45 const bool bObjsInNewUpper );
46
47 virtual void MakeAll(vcl::RenderContext* pRenderContext) override;
48
49 void UpdateAttr_( const SfxPoolItem*, const SfxPoolItem*, sal_uInt8 &,
50 SwAttrSetChg *pa = nullptr, SwAttrSetChg *pb = nullptr );
51
52 virtual bool ShouldBwdMoved( SwLayoutFrame *pNewUpper, bool& ) override;
53
54 const SwContentFrame* ImplGetNextContentFrame( bool bFwd ) const;
55
56protected:
57 void MakePrtArea( const SwBorderAttrs & );
58
59 virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
60 virtual SwTwips ShrinkFrame( SwTwips, bool bTst = false, bool bInfo = false ) override;
61 virtual SwTwips GrowFrame ( SwTwips, bool bTst = false, bool bInfo = false ) override;
62
63 SwContentFrame( SwContentNode * const, SwFrame* );
64
65 virtual void DestroyImpl() override;
66 virtual ~SwContentFrame() override;
67
68public:
69
70 virtual void Cut() override;
71 virtual void Paste( SwFrame* pParent, SwFrame* pSibling = nullptr ) override;
72
73 inline const SwContentFrame *GetFollow() const;
74 inline SwContentFrame *GetFollow();
75 SwTextFrame* FindMaster() const;
76
77 // layout dependent cursor travelling
78 virtual bool LeftMargin(SwPaM *) const = 0;
79 virtual bool RightMargin(SwPaM *, bool bAPI = false) const = 0;
80 virtual bool UnitUp( SwPaM *, const SwTwips nOffset,
81 bool bSetInReadOnly ) const;
82 virtual bool UnitDown( SwPaM *, const SwTwips nOffset,
83 bool bSetInReadOnly ) const;
84
85 // nMaxHeight is the required height
86 // bSplit indicates that the paragraph has to be split
87 // bTst indicates that we are currently doing a test formatting
88 virtual bool WouldFit( SwTwips &nMaxHeight, bool &bSplit, bool bTst );
89
90 bool MoveFootnoteCntFwd( bool, SwFootnoteBossFrame* ); // called by MoveFwd if content
91
92 inline SwContentFrame* GetNextContentFrame() const;
93 inline SwContentFrame* GetPrevContentFrame() const;
94 static bool CalcLowers(SwLayoutFrame & rLay, SwLayoutFrame const& rDontLeave,
95 long nBottom, bool bSkipRowSpanCells);
96};
97
98inline SwContentFrame* SwContentFrame::GetNextContentFrame() const
99{
100 if ( GetNext() && GetNext()->IsContentFrame() )
31
Assuming the condition is false
101 return const_cast<SwContentFrame*>(static_cast<const SwContentFrame*>(GetNext()));
102 else
103 return const_cast<SwContentFrame*>(ImplGetNextContentFrame( true ));
32
Returning pointer, which participates in a condition later
33
Returning pointer
104}
105
106inline SwContentFrame* SwContentFrame::GetPrevContentFrame() const
107{
108 if ( GetPrev() && GetPrev()->IsContentFrame() )
109 return const_cast<SwContentFrame*>(static_cast<const SwContentFrame*>(GetPrev()));
110 else
111 return const_cast<SwContentFrame*>(ImplGetNextContentFrame( false ));
112}
113
114inline const SwContentFrame *SwContentFrame::GetFollow() const
115{
116 return static_cast<const SwContentFrame*>(SwFlowFrame::GetFollow());
117}
118inline SwContentFrame *SwContentFrame::GetFollow()
119{
120 return static_cast<SwContentFrame*>(SwFlowFrame::GetFollow());
121}
122
123#endif
124
125/* vim:set shiftwidth=4 softtabstop=4 expandtab: */