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 <set>
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  nPosFromLeft( MM50 ),
56  nCountBy( 5 ),
57  nDividerCountBy( 3 ),
59  bPaintLineNumbers( false ),
60  bCountBlankLines( true ),
61  bCountInFlys( false ),
62  bRestartEachPage( false )
63 {
64 }
65 
67  aType( rCpy.GetNumType() ),
68  aDivider( rCpy.GetDivider() ),
69  nPosFromLeft( rCpy.GetPosFromLeft() ),
70  nCountBy( rCpy.GetCountBy() ),
71  nDividerCountBy( rCpy.GetDividerCountBy() ),
72  ePos( rCpy.GetPos() ),
73  bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
74  bCountBlankLines( rCpy.IsCountBlankLines() ),
75  bCountInFlys( rCpy.IsCountInFlys() ),
76  bRestartEachPage( rCpy.IsRestartEachPage() )
77 {
79 }
80 
82 {
84 
85  aType = rCpy.GetNumType();
86  aDivider = rCpy.GetDivider();
88  nCountBy = rCpy.GetCountBy();
90  ePos = rCpy.GetPos();
93  bCountInFlys = rCpy.IsCountInFlys();
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 
115 void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* /*pNew*/ )
116 {
117  CheckRegistration( pOld );
118  SwDoc *pDoc = static_cast<SwCharFormat*>(GetRegisteredIn())->GetDoc();
120  if( pRoot )
121  {
122  pRoot->StartAllAction();
123  for( auto aLayout : pDoc->GetAllLayouts() )
124  aLayout->AllAddPaintRect();
125  pRoot->EndAllAction();
126  }
127 }
128 
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
SwLineNumberInfo & operator=(const SwLineNumberInfo &)
Definition: lineinfo.cxx:81
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
const SwLineNumberInfo & GetLineNumberInfo() const
Definition: lineinfo.cxx:49
virtual const SwRootFrame * GetCurrentLayout() const =0
sal_uInt16 GetCountBy() const
Definition: lineinfo.hxx:74
virtual void SetModified()=0
Must be called manually at changes of format.
Definition: doc.hxx:185
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:874
bool IsCountBlankLines() const
Definition: lineinfo.hxx:83
bool IsCountInFlys() const
Definition: lineinfo.hxx:86
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
css::chart::ChartAxisLabelPosition ePos
bool bPaintLineNumbers
Should anything be displayed?
Definition: lineinfo.hxx:47
void StartListeningToSameModifyAs(const SwClient &)
Definition: calbck.cxx:116
bool IsRestartEachPage() const
Definition: lineinfo.hxx:89
bool bRestartEachPage
Restart counting at the first paragraph of each page (even on follows when paragraphs are split) ...
Definition: lineinfo.hxx:50
sal_uInt16 GetPosFromLeft() const
Definition: lineinfo.hxx:71
std::unique_ptr< sw::ModifyChangedHint > CheckRegistration(const SfxPoolItem *pOldValue)
Definition: calbck.cxx:78
sal_uInt16 nCountBy
Paint only for every n line.
Definition: lineinfo.hxx:43
bool bCountInFlys
Count also within FlyFrames?
Definition: lineinfo.hxx:49
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:393
std::set< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1660
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
< purpose of derivation from SwClient: character style for displaying the numbers.
Definition: lineinfo.hxx:37
void SetCharFormat(SwCharFormat *)
Definition: lineinfo.cxx:109
virtual void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: lineinfo.cxx:115
sal_uInt16 nPosFromLeft
Position for paint.
Definition: lineinfo.hxx:42
#define MM50
Definition: swtypes.hxx:59
bool IsPaintLineNumbers() const
Definition: lineinfo.hxx:80
LineNumberPosition GetPos() const
Definition: lineinfo.hxx:77
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
SwCharFormat * GetCharFormat(IDocumentStylePoolAccess &rIDSPA) const
Definition: lineinfo.cxx:99
bool bCountBlankLines
Count empty lines?
Definition: lineinfo.hxx:48
sal_uInt16 nDividerCountBy
Interval for display of an user defined string every n lines.
Definition: lineinfo.hxx:44
void SetLineNumberInfo(const SwLineNumberInfo &rInfo)
Definition: lineinfo.cxx:30
SvxNumberType aType
e.g. roman linenumbers
Definition: lineinfo.hxx:40
Line numbering.
Definition: poolfmt.hxx:126
Access to the style pool.
const OUString & GetDivider() const
Definition: lineinfo.hxx:66
std::unique_ptr< SwLineNumberInfo > mpLineNumberInfo
Definition: doc.hxx:254
void StartAllAction()
Set up Start-/EndAction for all Shells on an as high as possible (Shell section) level.
Definition: pagechg.cxx:1864
const SvxNumberType & GetNumType() const
Definition: lineinfo.hxx:63
sal_uInt16 GetDividerCountBy() const
Definition: lineinfo.hxx:68
OUString aDivider
String for additional interval (vert. lines user defined)
Definition: lineinfo.hxx:41
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1876
LineNumberPosition ePos
Where should the display occur (number and divider)
Definition: lineinfo.hxx:46