LibreOffice Module sw (master) 1
lineinfo.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <doc.hxx>
23#include <IDocumentState.hxx>
24#include <lineinfo.hxx>
25#include <charfmt.hxx>
26#include <poolfmt.hxx>
27#include <rootfrm.hxx>
28#include <osl/diagnose.h>
29
31{
33 if ( pTmpRoot &&
34 (rNew.IsCountBlankLines() != mpLineNumberInfo->IsCountBlankLines() ||
35 rNew.IsRestartEachPage() != mpLineNumberInfo->IsRestartEachPage()) )
36 {
37 pTmpRoot->StartAllAction();
38 // FME 2007-08-14 #i80120# Invalidate size, because ChgThisLines()
39 // is only (and may only be) called by the formatting routines
40 //pTmpRoot->InvalidateAllContent( SwInvalidateFlags::LineNum | SwInvalidateFlags::Size );
41 for( auto aLayout : GetAllLayouts() )
42 aLayout->InvalidateAllContent( SwInvalidateFlags::LineNum | SwInvalidateFlags::Size );
43 pTmpRoot->EndAllAction();
44 }
45 *mpLineNumberInfo = rNew;
47}
48
50{
51 return *mpLineNumberInfo;
52}
53
55 m_nPosFromLeft(o3tl::toTwips(5, o3tl::Length::mm)),
56 m_nCountBy( 5 ),
57 m_nDividerCountBy( 3 ),
58 m_ePos( LINENUMBER_POS_LEFT ),
59 m_bPaintLineNumbers( false ),
60 m_bCountBlankLines( true ),
61 m_bCountInFlys( false ),
62 m_bRestartEachPage( false )
63{
64}
65
67 m_aType( rCpy.GetNumType() ),
68 m_aDivider( rCpy.GetDivider() ),
69 m_nPosFromLeft( rCpy.GetPosFromLeft() ),
70 m_nCountBy( rCpy.GetCountBy() ),
71 m_nDividerCountBy( rCpy.GetDividerCountBy() ),
72 m_ePos( rCpy.GetPos() ),
73 m_bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
74 m_bCountBlankLines( rCpy.IsCountBlankLines() ),
75 m_bCountInFlys( rCpy.IsCountInFlys() ),
76 m_bRestartEachPage( rCpy.IsRestartEachPage() )
77{
79}
80
82{
84
85 m_aType = rCpy.GetNumType();
86 m_aDivider = rCpy.GetDivider();
88 m_nCountBy = rCpy.GetCountBy();
90 m_ePos = rCpy.GetPos();
95
96 return *this;
97}
98
100{
101 if ( !GetRegisteredIn() )
102 {
104 pFormat->Add( const_cast<SwLineNumberInfo*>(this) );
105 }
106 return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(GetRegisteredIn()));
107}
108
110{
111 OSL_ENSURE( pChFormat, "SetCharFormat, 0 is not a valid pointer" );
112 pChFormat->Add( this );
113}
114
116{
117 if (rHint.GetId() != SfxHintId::SwLegacyModify)
118 return;
119 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
120 CheckRegistration( pLegacy->m_pOld );
121 SwDoc *pDoc = static_cast<SwCharFormat*>(GetRegisteredIn())->GetDoc();
123 if( pRoot )
124 {
125 pRoot->StartAllAction();
126 for( auto aLayout : pDoc->GetAllLayouts() )
127 aLayout->AllAddPaintRect();
128 pRoot->EndAllAction();
129 }
130}
131
132/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
uno::Type m_aType
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual void SetModified()=0
Must be called manually at changes of format.
Access to the style pool.
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
SfxHintId GetId() const
Represents the style of a text portion.
Definition: charfmt.hxx:27
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:166
void StartListeningToSameModifyAs(const SwClient &)
Definition: calbck.cxx:128
std::optional< sw::ModifyChangedHint > CheckRegistration(const SfxPoolItem *pOldValue)
Definition: calbck.cxx:77
Definition: doc.hxx:194
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:400
o3tl::sorted_vector< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1687
std::unique_ptr< SwLineNumberInfo > mpLineNumberInfo
Definition: doc.hxx:263
const SwLineNumberInfo & GetLineNumberInfo() const
Definition: lineinfo.cxx:49
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:411
void SetLineNumberInfo(const SwLineNumberInfo &rInfo)
Definition: lineinfo.cxx:30
< purpose of derivation from SwClient: character style for displaying the numbers.
Definition: lineinfo.hxx:39
bool m_bRestartEachPage
Restart counting at the first paragraph of each page (even on follows when paragraphs are split)
Definition: lineinfo.hxx:50
bool m_bPaintLineNumbers
Should anything be displayed?
Definition: lineinfo.hxx:47
const OUString & GetDivider() const
Definition: lineinfo.hxx:66
sal_uInt16 m_nDividerCountBy
Interval for display of an user defined string every n lines.
Definition: lineinfo.hxx:44
sal_uInt16 GetCountBy() const
Definition: lineinfo.hxx:74
const SvxNumberType & GetNumType() const
Definition: lineinfo.hxx:63
bool m_bCountBlankLines
Count empty lines?
Definition: lineinfo.hxx:48
sal_uInt16 m_nPosFromLeft
Position for paint.
Definition: lineinfo.hxx:42
bool IsRestartEachPage() const
Definition: lineinfo.hxx:89
void SetCharFormat(SwCharFormat *)
Definition: lineinfo.cxx:109
SwCharFormat * GetCharFormat(IDocumentStylePoolAccess &rIDSPA) const
Definition: lineinfo.cxx:99
bool IsPaintLineNumbers() const
Definition: lineinfo.hxx:80
bool IsCountBlankLines() const
Definition: lineinfo.hxx:83
sal_uInt16 GetPosFromLeft() const
Definition: lineinfo.hxx:71
bool m_bCountInFlys
Count also within FlyFrames?
Definition: lineinfo.hxx:49
bool IsCountInFlys() const
Definition: lineinfo.hxx:86
SwLineNumberInfo & operator=(const SwLineNumberInfo &)
Definition: lineinfo.cxx:81
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: lineinfo.cxx:115
LineNumberPosition m_ePos
Where should the display occur (number and divider)
Definition: lineinfo.hxx:46
sal_uInt16 GetDividerCountBy() const
Definition: lineinfo.hxx:68
LineNumberPosition GetPos() const
Definition: lineinfo.hxx:77
OUString m_aDivider
String for additional interval (vert. lines user defined)
Definition: lineinfo.hxx:41
sal_uInt16 m_nCountBy
Paint only for every n line.
Definition: lineinfo.hxx:43
SvxNumberType m_aType
e.g. roman linenumbers
Definition: lineinfo.hxx:40
void Add(SwClient *pDepend)
Definition: calbck.cxx:172
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
void StartAllAction()
Set up Start-/EndAction for all Shells on an as high as possible (Shell section) level.
Definition: pagechg.cxx:1911
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1923
@ LINENUMBER_POS_LEFT
Definition: lineinfo.hxx:31
constexpr auto toTwips(N number, Length from)
Length
@ RES_POOLCHR_LINENUM
Line numbering.
Definition: poolfmt.hxx:125
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:889