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 <viewsh.hxx>
29 #include <set>
30 
32 {
34  if ( pTmpRoot &&
35  (rNew.IsCountBlankLines() != mpLineNumberInfo->IsCountBlankLines() ||
36  rNew.IsRestartEachPage() != mpLineNumberInfo->IsRestartEachPage()) )
37  {
38  pTmpRoot->StartAllAction();
39  // FME 2007-08-14 #i80120# Invalidate size, because ChgThisLines()
40  // is only (and may only be) called by the formatting routines
41  //pTmpRoot->InvalidateAllContent( SwInvalidateFlags::LineNum | SwInvalidateFlags::Size );
42  for( auto aLayout : GetAllLayouts() )
43  aLayout->InvalidateAllContent( SwInvalidateFlags::LineNum | SwInvalidateFlags::Size );
44  pTmpRoot->EndAllAction();
45  }
46  *mpLineNumberInfo = rNew;
48 }
49 
51 {
52  return *mpLineNumberInfo;
53 }
54 
56  nPosFromLeft( MM50 ),
57  nCountBy( 5 ),
58  nDividerCountBy( 3 ),
60  bPaintLineNumbers( false ),
61  bCountBlankLines( true ),
62  bCountInFlys( false ),
63  bRestartEachPage( false )
64 {
65 }
66 
68  aType( rCpy.GetNumType() ),
69  aDivider( rCpy.GetDivider() ),
70  nPosFromLeft( rCpy.GetPosFromLeft() ),
71  nCountBy( rCpy.GetCountBy() ),
72  nDividerCountBy( rCpy.GetDividerCountBy() ),
73  ePos( rCpy.GetPos() ),
74  bPaintLineNumbers( rCpy.IsPaintLineNumbers() ),
75  bCountBlankLines( rCpy.IsCountBlankLines() ),
76  bCountInFlys( rCpy.IsCountInFlys() ),
77  bRestartEachPage( rCpy.IsRestartEachPage() )
78 {
80 }
81 
83 {
85 
86  aType = rCpy.GetNumType();
87  aDivider = rCpy.GetDivider();
89  nCountBy = rCpy.GetCountBy();
91  ePos = rCpy.GetPos();
94  bCountInFlys = rCpy.IsCountInFlys();
96 
97  return *this;
98 }
99 
101 {
102  if ( !GetRegisteredIn() )
103  {
105  pFormat->Add( const_cast<SwLineNumberInfo*>(this) );
106  }
107  return const_cast<SwCharFormat*>(static_cast<const SwCharFormat*>(GetRegisteredIn()));
108 }
109 
111 {
112  OSL_ENSURE( pChFormat, "SetCharFormat, 0 is not a valid pointer" );
113  pChFormat->Add( this );
114 }
115 
116 void SwLineNumberInfo::Modify( const SfxPoolItem* pOld, const SfxPoolItem* /*pNew*/ )
117 {
118  CheckRegistration( pOld );
119  SwDoc *pDoc = static_cast<SwCharFormat*>(GetRegisteredIn())->GetDoc();
121  if( pRoot )
122  {
123  pRoot->StartAllAction();
124  for( auto aLayout : pDoc->GetAllLayouts() )
125  aLayout->AllAddPaintRect();
126  pRoot->EndAllAction();
127  }
128 }
129 
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
SwLineNumberInfo & operator=(const SwLineNumberInfo &)
Definition: lineinfo.cxx:82
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
const SwLineNumberInfo & GetLineNumberInfo() const
Definition: lineinfo.cxx:50
virtual const SwRootFrame * GetCurrentLayout() const =0
sal_uInt16 GetCountBy() const
Definition: lineinfo.hxx:75
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:84
bool IsCountInFlys() const
Definition: lineinfo.hxx:87
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:90
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:72
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:426
std::set< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1673
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:437
< purpose of derivation from SwClient: character style for displaying the numbers.
Definition: lineinfo.hxx:37
void SetCharFormat(SwCharFormat *)
Definition: lineinfo.cxx:110
virtual void Modify(const SfxPoolItem *, const SfxPoolItem *) override
Definition: lineinfo.cxx:116
sal_uInt16 nPosFromLeft
Position for paint.
Definition: lineinfo.hxx:42
#define MM50
Definition: swtypes.hxx:59
bool IsPaintLineNumbers() const
Definition: lineinfo.hxx:81
LineNumberPosition GetPos() const
Definition: lineinfo.hxx:78
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
SwCharFormat * GetCharFormat(IDocumentStylePoolAccess &rIDSPA) const
Definition: lineinfo.cxx:100
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:31
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:67
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:1866
const SvxNumberType & GetNumType() const
Definition: lineinfo.hxx:64
sal_uInt16 GetDividerCountBy() const
Definition: lineinfo.hxx:69
OUString aDivider
String for additional interval (vert. lines user defined)
Definition: lineinfo.hxx:41
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1878
LineNumberPosition ePos
Where should the display occur (number and divider)
Definition: lineinfo.hxx:46