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->GetPointContentNode();
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->GetNode() == pMkPos->GetNode() ) // in the same node?
65 {
66 nStt = pPtPos->GetContentIndex();
67 if( nStt < pMkPos->GetContentIndex() )
68 nEnd = pMkPos->GetContentIndex();
69 else
70 {
71 nEnd = nStt;
72 nStt = pMkPos->GetContentIndex();
73 }
74 }
75 else
76 {
77 nStt = pMkPos->GetContentIndex();
78 if( pPtPos->GetNode() < pMkPos->GetNode() )
79 {
80 nEnd = nStt;
81 nStt = 0;
82 }
83 else
84 nEnd = pTextNode->GetText().getLength();
85 }
86 }
87 else
88 nStt = nEnd = pPam->GetPoint()->GetContentIndex();
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:494
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:493
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
size_t GetTableFrameFormatCount(bool bUsed) const
Definition: docfmt.cxx:778
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:768
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:755
OUString GetUniqueTableName() const
Definition: ndtbl.cxx:3907
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:440
SwTableFormat & GetTableFrameFormat(size_t nFormat, bool bUsed) const
Definition: docfmt.cxx:795
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:863
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:447
Style of a layout element.
Definition: frmfmt.hxx:72
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
bool IsTextNode() const
Definition: node.hxx:190
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
const SwPosition * GetMark() const
Definition: pam.hxx:255
SwContentNode * GetPointContentNode() const
Definition: pam.hxx:279
const SwPosition * GetPoint() const
Definition: pam.hxx:253
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:251
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
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:2140
const OUString & GetText() const
Definition: ndtxt.hxx:244
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:199
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2163
SwDoc * GetDoc() const
Definition: viewsh.hxx:308
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:648
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
sal_Int16 nId
Marks a position in the document model.
Definition: pam.hxx:38
SwNode & GetNode() const
Definition: pam.hxx:81
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85