LibreOffice Module sw (master)  1
edfmt.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>
22 #include <editsh.hxx>
23 #include <pam.hxx>
24 #include <docary.hxx>
25 #include <fchrfmt.hxx>
26 #include <frmfmt.hxx>
27 #include <charfmt.hxx>
28 #include <ndtxt.hxx>
29 
31 {
32  return GetDoc()->GetCharFormats()->size();
33 }
34 
35 SwCharFormat& SwEditShell::GetCharFormat(sal_uInt16 nFormat) const
36 {
37  return *((*(GetDoc()->GetCharFormats()))[nFormat]);
38 }
39 
41 {
42  SwCharFormat *pFormat = nullptr;
44  const SfxPoolItem* pItem;
45  if( GetCurAttr( aSet ) && SfxItemState::SET ==
46  aSet.GetItemState( RES_TXTATR_CHARFMT, false, &pItem ) )
47  pFormat = static_cast<const SwFormatCharFormat*>(pItem)->GetCharFormat();
48 
49  return pFormat;
50 }
51 
53 {
54  SwPaM* pPam = GetCursor();
55  const SwContentNode* pCNd = pPam->GetContentNode();
56  if( pCNd->IsTextNode() )
57  {
58  SwTextNode const*const pTextNode(pCNd->GetTextNode());
59  sal_Int32 nStt;
60  sal_Int32 nEnd;
61  if( pPam->HasMark() )
62  {
63  const SwPosition* pPtPos = pPam->GetPoint();
64  const SwPosition* pMkPos = pPam->GetMark();
65  if( pPtPos->nNode == pMkPos->nNode ) // in the same node?
66  {
67  nStt = pPtPos->nContent.GetIndex();
68  if( nStt < pMkPos->nContent.GetIndex() )
69  nEnd = pMkPos->nContent.GetIndex();
70  else
71  {
72  nEnd = nStt;
73  nStt = pMkPos->nContent.GetIndex();
74  }
75  }
76  else
77  {
78  nStt = pMkPos->nContent.GetIndex();
79  if( pPtPos->nNode < pMkPos->nNode )
80  {
81  nEnd = nStt;
82  nStt = 0;
83  }
84  else
85  nEnd = pTextNode->GetText().getLength();
86  }
87  }
88  else
89  nStt = nEnd = pPam->GetPoint()->nContent.GetIndex();
90 
91  SfxItemSet aSet( mxDoc->GetAttrPool(),
92  pCharFormat->GetAttrSet().GetRanges() );
93  pTextNode->GetParaAttr(aSet, nStt, nEnd, false, true, false, GetLayout());
94  pCharFormat->SetFormatAttr( aSet );
95  }
96  else if( pCNd->HasSwAttrSet() )
97  pCharFormat->SetFormatAttr( *pCNd->GetpSwAttrSet() );
98 }
99 
101 {
102  return GetDoc()->GetTableFrameFormatCount(bUsed);
103 }
104 
105 SwFrameFormat& SwEditShell::GetTableFrameFormat(size_t nFormat, bool bUsed ) const
106 {
107  return GetDoc()->GetTableFrameFormat(nFormat, bUsed );
108 }
109 
111 {
112  return GetDoc()->GetUniqueTableName();
113 }
114 
115 SwCharFormat* SwEditShell::MakeCharFormat( const OUString& rName )
116 {
117  SwCharFormat* pDerivedFrom = GetDoc()->GetDfltCharFormat();
118 
119  return GetDoc()->MakeCharFormat( rName, pDerivedFrom );
120 }
121 
123 {
125 }
126 
129 {
131 }
132 
134 {
136 }
137 
138 bool SwEditShell::IsUsed( const sw::BroadcastingModify& rModify ) const
139 {
140  return mxDoc->IsUsed( rModify );
141 }
142 
143 const SwFlyFrameFormat* SwEditShell::FindFlyByName( const OUString& rName ) const
144 {
145  return mxDoc->FindFlyByName(rName);
146 }
147 
148 SwCharFormat* SwEditShell::FindCharFormatByName( const OUString& rName ) const
149 {
150  return mxDoc->FindCharFormatByName( rName );
151 }
152 
154 {
155  return mxDoc->FindTextFormatCollByName( rName );
156 }
157 
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwCharFormat * MakeCharFormat(const OUString &rName)
Definition: edfmt.cxx:115
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
size_t GetTableFrameFormatCount(bool bUsed=false) const
TABLE.
Definition: edfmt.cxx:100
Marks a position in the document model.
Definition: pam.hxx:36
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:122
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:856
SwNodeIndex nNode
Definition: pam.hxx:38
OUString GetUniqueTableName() const
Definition: ndtbl.cxx:3906
const SwPosition * GetMark() const
Definition: pam.hxx:210
const WhichRangesContainer & GetRanges() const
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:230
void FillByEx(SwCharFormat *)
Definition: edfmt.cxx:52
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:753
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:171
SwIndex nContent
Definition: pam.hxx:39
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:426
bool IsUsed(const sw::BroadcastingModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
Definition: edfmt.cxx:138
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
SwDoc * GetDoc() const
Definition: viewsh.hxx:282
sal_uInt16 GetCharFormatCount() const
CHAR.
Definition: edfmt.cxx:30
const SwFlyFrameFormat * FindFlyByName(const OUString &rName) const
Definition: edfmt.cxx:143
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
Base class for various Writer styles.
Definition: format.hxx:46
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:451
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:617
Style of a layout element.
Definition: frmfmt.hxx:59
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: edfmt.cxx:148
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SwPosition * GetPoint() const
Definition: pam.hxx:208
virtual SwFormat * GetFormatFromPool(sal_uInt16 nId)=0
Return required automatic format base class.
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:206
OUString GetUniqueTableName() const
Definition: edfmt.cxx:110
bool HasSwAttrSet() const
Definition: node.hxx:452
Represents the style of a text portion.
Definition: charfmt.hxx:26
size_t size() const
Definition: charformats.hxx:71
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed=false) const
Definition: edfmt.cxx:105
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:196
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:740
sal_Int32 GetIndex() const
Definition: index.hxx:91
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: edfmt.cxx:153
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
SwFormat * GetFormatFromPool(sal_uInt16 nId)
return the requested automatic format - base-class !
Definition: edfmt.cxx:128
SwPageDesc * GetPageDescFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:133
size_t GetTableFrameFormatCount(bool bUsed) const
Definition: docfmt.cxx:771
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:171
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed) const
Definition: docfmt.cxx:788
SwCharFormat * GetCurCharFormat() const
Definition: edfmt.cxx:40
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2174
bool IsTextNode() const
Definition: node.hxx:640
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:856
SwCharFormat & GetCharFormat(sal_uInt16 nFormat) const
Definition: edfmt.cxx:35