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  RES_TXTATR_CHARFMT>{} );
45  const SfxPoolItem* pItem;
46  if( GetCurAttr( aSet ) && SfxItemState::SET ==
47  aSet.GetItemState( RES_TXTATR_CHARFMT, false, &pItem ) )
48  pFormat = static_cast<const SwFormatCharFormat*>(pItem)->GetCharFormat();
49 
50  return pFormat;
51 }
52 
54 {
55  SwPaM* pPam = GetCursor();
56  const SwContentNode* pCNd = pPam->GetContentNode();
57  if( pCNd->IsTextNode() )
58  {
59  SwTextNode const*const pTextNode(pCNd->GetTextNode());
60  sal_Int32 nStt;
61  sal_Int32 nEnd;
62  if( pPam->HasMark() )
63  {
64  const SwPosition* pPtPos = pPam->GetPoint();
65  const SwPosition* pMkPos = pPam->GetMark();
66  if( pPtPos->nNode == pMkPos->nNode ) // in the same node?
67  {
68  nStt = pPtPos->nContent.GetIndex();
69  if( nStt < pMkPos->nContent.GetIndex() )
70  nEnd = pMkPos->nContent.GetIndex();
71  else
72  {
73  nEnd = nStt;
74  nStt = pMkPos->nContent.GetIndex();
75  }
76  }
77  else
78  {
79  nStt = pMkPos->nContent.GetIndex();
80  if( pPtPos->nNode < pMkPos->nNode )
81  {
82  nEnd = nStt;
83  nStt = 0;
84  }
85  else
86  nEnd = pTextNode->GetText().getLength();
87  }
88  }
89  else
90  nStt = nEnd = pPam->GetPoint()->nContent.GetIndex();
91 
92  SfxItemSet aSet( mxDoc->GetAttrPool(),
93  pCharFormat->GetAttrSet().GetRanges() );
94  pTextNode->GetParaAttr(aSet, nStt, nEnd, false, true, false, GetLayout());
95  pCharFormat->SetFormatAttr( aSet );
96  }
97  else if( pCNd->HasSwAttrSet() )
98  pCharFormat->SetFormatAttr( *pCNd->GetpSwAttrSet() );
99 }
100 
102 {
103  return GetDoc()->GetTableFrameFormatCount(bUsed);
104 }
105 
106 SwFrameFormat& SwEditShell::GetTableFrameFormat(size_t nFormat, bool bUsed ) const
107 {
108  return GetDoc()->GetTableFrameFormat(nFormat, bUsed );
109 }
110 
112 {
113  return GetDoc()->GetUniqueTableName();
114 }
115 
116 SwCharFormat* SwEditShell::MakeCharFormat( const OUString& rName )
117 {
118  SwCharFormat* pDerivedFrom = GetDoc()->GetDfltCharFormat();
119 
120  return GetDoc()->MakeCharFormat( rName, pDerivedFrom );
121 }
122 
124 {
126 }
127 
130 {
132 }
133 
135 {
137 }
138 
139 bool SwEditShell::IsUsed( const SwModify& rModify ) const
140 {
141  return mxDoc->IsUsed( rModify );
142 }
143 
144 const SwFlyFrameFormat* SwEditShell::FindFlyByName( const OUString& rName ) const
145 {
146  return mxDoc->FindFlyByName(rName);
147 }
148 
149 SwCharFormat* SwEditShell::FindCharFormatByName( const OUString& rName ) const
150 {
151  return mxDoc->FindCharFormatByName( rName );
152 }
153 
155 {
156  return mxDoc->FindTextFormatCollByName( rName );
157 }
158 
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwCharFormat * MakeCharFormat(const OUString &rName)
Definition: edfmt.cxx:116
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
size_t GetTableFrameFormatCount(bool bUsed=false) const
TABLE.
Definition: edfmt.cxx:101
Marks a position in the document model.
Definition: pam.hxx:35
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:123
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:184
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:835
SwNodeIndex nNode
Definition: pam.hxx:37
OUString GetUniqueTableName() const
Definition: ndtbl.cxx:3845
const SwPosition * GetMark() const
Definition: pam.hxx:209
#define RES_TXTATR_CHARFMT
Definition: hintids.hxx:143
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
void FillByEx(SwCharFormat *)
Definition: edfmt.cxx:53
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:746
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:174
SwIndex nContent
Definition: pam.hxx:38
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:425
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
sal_uInt16 GetCharFormatCount() const
CHAR.
Definition: edfmt.cxx:30
const SwFlyFrameFormat * FindFlyByName(const OUString &rName) const
Definition: edfmt.cxx:144
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
Base class for various Writer styles.
Definition: format.hxx:43
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:443
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:614
Style of a layout element.
Definition: frmfmt.hxx:57
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: edfmt.cxx:149
const SwPosition * GetPoint() const
Definition: pam.hxx:207
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:205
size_t size() const
Definition: docary.hxx:91
bool IsUsed(const SwModify &) const
Query if the paragraph-/character-/frame-/page-style is used.
Definition: edfmt.cxx:139
OUString GetUniqueTableName() const
Definition: edfmt.cxx:111
bool HasSwAttrSet() const
Definition: node.hxx:444
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed=false) const
Definition: edfmt.cxx:106
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:733
sal_Int32 GetIndex() const
Definition: index.hxx:95
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: edfmt.cxx:154
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:129
SwPageDesc * GetPageDescFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:134
size_t GetTableFrameFormatCount(bool bUsed) const
Definition: docfmt.cxx:750
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:176
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed) const
Definition: docfmt.cxx:767
const sal_uInt16 * GetRanges() const
SwCharFormat * GetCurCharFormat() const
Definition: edfmt.cxx:40
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2075
bool IsTextNode() const
Definition: node.hxx:636
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
SwCharFormat & GetCharFormat(sal_uInt16 nFormat) const
Definition: edfmt.cxx:35