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 <swtable.hxx>
24 #include <pam.hxx>
25 #include <docary.hxx>
26 #include <fchrfmt.hxx>
27 #include <frmfmt.hxx>
28 #include <charfmt.hxx>
29 #include <ndtxt.hxx>
30 #include <hints.hxx>
31 
33 {
34  return GetDoc()->GetCharFormats()->size();
35 }
36 
37 SwCharFormat& SwEditShell::GetCharFormat(sal_uInt16 nFormat) const
38 {
39  return *((*(GetDoc()->GetCharFormats()))[nFormat]);
40 }
41 
43 {
44  SwCharFormat *pFormat = nullptr;
46  RES_TXTATR_CHARFMT>{} );
47  const SfxPoolItem* pItem;
48  if( GetCurAttr( aSet ) && SfxItemState::SET ==
49  aSet.GetItemState( RES_TXTATR_CHARFMT, false, &pItem ) )
50  pFormat = static_cast<const SwFormatCharFormat*>(pItem)->GetCharFormat();
51 
52  return pFormat;
53 }
54 
56 {
57  SwPaM* pPam = GetCursor();
58  const SwContentNode* pCNd = pPam->GetContentNode();
59  if( pCNd->IsTextNode() )
60  {
61  SwTextNode const*const pTextNode(pCNd->GetTextNode());
62  sal_Int32 nStt;
63  sal_Int32 nEnd;
64  if( pPam->HasMark() )
65  {
66  const SwPosition* pPtPos = pPam->GetPoint();
67  const SwPosition* pMkPos = pPam->GetMark();
68  if( pPtPos->nNode == pMkPos->nNode ) // in the same node?
69  {
70  nStt = pPtPos->nContent.GetIndex();
71  if( nStt < pMkPos->nContent.GetIndex() )
72  nEnd = pMkPos->nContent.GetIndex();
73  else
74  {
75  nEnd = nStt;
76  nStt = pMkPos->nContent.GetIndex();
77  }
78  }
79  else
80  {
81  nStt = pMkPos->nContent.GetIndex();
82  if( pPtPos->nNode < pMkPos->nNode )
83  {
84  nEnd = nStt;
85  nStt = 0;
86  }
87  else
88  nEnd = pTextNode->GetText().getLength();
89  }
90  }
91  else
92  nStt = nEnd = pPam->GetPoint()->nContent.GetIndex();
93 
94  SfxItemSet aSet( mxDoc->GetAttrPool(),
95  pCharFormat->GetAttrSet().GetRanges() );
96  pTextNode->GetParaAttr(aSet, nStt, nEnd, false, true, false, GetLayout());
97  pCharFormat->SetFormatAttr( aSet );
98  }
99  else if( pCNd->HasSwAttrSet() )
100  pCharFormat->SetFormatAttr( *pCNd->GetpSwAttrSet() );
101 }
102 
104 {
105  return GetDoc()->GetTableFrameFormatCount(bUsed);
106 }
107 
108 SwFrameFormat& SwEditShell::GetTableFrameFormat(size_t nFormat, bool bUsed ) const
109 {
110  return GetDoc()->GetTableFrameFormat(nFormat, bUsed );
111 }
112 
114 {
115  return GetDoc()->GetUniqueTableName();
116 }
117 
118 SwCharFormat* SwEditShell::MakeCharFormat( const OUString& rName )
119 {
120  SwCharFormat* pDerivedFrom = GetDoc()->GetDfltCharFormat();
121 
122  return GetDoc()->MakeCharFormat( rName, pDerivedFrom );
123 }
124 
126 {
128 }
129 
132 {
134 }
135 
137 {
139 }
140 
141 bool SwEditShell::IsUsed( const SwModify& rModify ) const
142 {
143  return mxDoc->IsUsed( rModify );
144 }
145 
146 const SwFlyFrameFormat* SwEditShell::FindFlyByName( const OUString& rName ) const
147 {
148  return mxDoc->FindFlyByName(rName);
149 }
150 
151 SwCharFormat* SwEditShell::FindCharFormatByName( const OUString& rName ) const
152 {
153  return mxDoc->FindCharFormatByName( rName );
154 }
155 
157 {
158  return mxDoc->FindTextFormatCollByName( rName );
159 }
160 
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwCharFormat * MakeCharFormat(const OUString &rName)
Definition: edfmt.cxx:118
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
size_t GetTableFrameFormatCount(bool bUsed=false) const
TABLE.
Definition: edfmt.cxx:103
Marks a position in the document model.
Definition: pam.hxx:35
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:125
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:185
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:867
SwNodeIndex nNode
Definition: pam.hxx:37
OUString GetUniqueTableName() const
Definition: ndtbl.cxx:3852
const SwPosition * GetMark() const
Definition: pam.hxx:209
#define RES_TXTATR_CHARFMT
Definition: hintids.hxx:142
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
void FillByEx(SwCharFormat *)
Definition: edfmt.cxx:55
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:747
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:458
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
sal_uInt16 GetCharFormatCount() const
CHAR.
Definition: edfmt.cxx:32
const SwFlyFrameFormat * FindFlyByName(const OUString &rName) const
Definition: edfmt.cxx:146
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:151
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:141
OUString GetUniqueTableName() const
Definition: edfmt.cxx:113
bool HasSwAttrSet() const
Definition: node.hxx:444
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:460
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed=false) const
Definition: edfmt.cxx:108
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:734
sal_Int32 GetIndex() const
Definition: index.hxx:95
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: edfmt.cxx:156
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:131
SwPageDesc * GetPageDescFromPool(sal_uInt16 nId)
Definition: edfmt.cxx:136
size_t GetTableFrameFormatCount(bool bUsed) const
Definition: docfmt.cxx:782
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:181
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed) const
Definition: docfmt.cxx:799
const sal_uInt16 * GetRanges() const
SwCharFormat * GetCurCharFormat() const
Definition: edfmt.cxx:42
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2072
bool IsTextNode() const
Definition: node.hxx:636
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:843
SwCharFormat & GetCharFormat(sal_uInt16 nFormat) const
Definition: edfmt.cxx:37