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