LibreOffice Module sc (master) 1
editutil.hxx
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#pragma once
21
22#include <memory>
23#include "scdllapi.h"
24#include "types.hxx"
25#include <editeng/editeng.hxx>
26#include <svx/pageitem.hxx>
27#include <tools/datetime.hxx>
28#include <tools/gen.hxx>
29#include <tools/fract.hxx>
30#include <vcl/outdev.hxx>
31
32class ScDocument;
33class ScPatternAttr;
35
37{
43 VclPtr<OutputDevice> pDev; // MapMode has to be set
44 double nPPTX;
45 double nPPTY;
49
50public:
51 static OUString ModifyDelimiters( const OUString& rOld );
52
54 static OUString GetSpaceDelimitedString( const EditEngine& rEngine );
55
57 static OUString GetMultilineString( const EditEngine& rEngine );
58 static OUString GetMultilineString( const EditTextObject& rEdit );
59
67 SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText, const ScDocument* pDoc );
68
69 static std::unique_ptr<EditTextObject> CreateURLObjectFromURL(
70 ScDocument& rDoc, const OUString& rURL, const OUString& rText );
71
72 static void RemoveCharAttribs( EditTextObject& rEditText, const ScPatternAttr& rAttr );
73
74 static std::unique_ptr<EditTextObject> Clone( const EditTextObject& rSrc, ScDocument& rDestDoc );
75
76 static OUString GetCellFieldValue(
77 const SvxFieldData& rFieldData, const ScDocument* pDoc, std::optional<Color>* ppTextColor, std::optional<FontLineStyle>* ppFldLineStyle );
78
79public:
80 ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
81 const Point& rCellPos,
82 OutputDevice* pDevice, double nScaleX, double nScaleY,
83 const Fraction& rX, const Fraction& rY, bool bPrintTwips = false );
84
85 tools::Rectangle GetEditArea( const ScPatternAttr* pPattern, bool bForceToTop );
86 tools::Long GetIndent(const ScPatternAttr* pPattern) const;
87 void GetMargins(const ScPatternAttr* pPattern, tools::Long& nLeftMargin, tools::Long& nTopMargin,
88 tools::Long& nRightMargin, tools::Long& BottomMargin) const;
89
90};
91
93{
94 std::unique_ptr<SfxItemSet> pEditAttrs;
97
98public:
101
102 bool NeedsObject() const { return bNeedsObject; }
103 bool NeedsCellAttr() const { return bNeedsCellAttr; }
104 const SfxItemSet& GetAttribs() const { return *pEditAttrs; }
105};
106
107// construct pool before constructing EditEngine, destroy pool after EditEngine
109{
110protected:
115
118 virtual ~ScEnginePoolHelper();
119};
120
122{
123public:
128 bool bDeleteEnginePool = false );
132 virtual ~ScEditEngineDefaulter() override;
133
135 void SetDefaults( const SfxItemSet& rDefaults, bool bRememberCopy = true );
136
138 void SetDefaults( std::unique_ptr<SfxItemSet> pDefaults );
139
143 void SetDefaultItem( const SfxPoolItem& rItem );
144
146 const SfxItemSet& GetDefaults();
147
149 void SetTextCurrentDefaults( const EditTextObject& rTextObject );
151 void SetTextNewDefaults( const EditTextObject& rTextObject,
152 const SfxItemSet& rDefaults, bool bRememberCopy = true );
153
155 void SetTextCurrentDefaults( const OUString& rText );
157 void SetTextNewDefaults( const OUString& rText,
158 const SfxItemSet& rDefaults );
159
162 void RemoveParaAttribs();
163
166 void RepeatDefaults();
167};
168
169// for field commands (or just fields?) in a table
171{
172private:
175
176public:
178 ScDocument* pDoc, SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool = nullptr,
179 bool bDeleteEnginePool = false);
180
181 void SetExecuteURL(bool bSet) { bExecuteURL = bSet; }
182
183 virtual bool FieldClicked( const SvxFieldItem& rField ) override;
184 virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor, std::optional<FontLineStyle>& rFldLineStyle ) override;
185};
186
187// 1/100 mm
189{
190private:
191 void Init(const ScPatternAttr& rPattern);
192public:
193 ScTabEditEngine( ScDocument* pDoc ); // Default
194 ScTabEditEngine(const ScPatternAttr& rPattern,
195 SfxItemPool *pEngineItemPool, ScDocument *pDoc,
196 SfxItemPool* pTextObjectPool = nullptr );
197};
198
200{
201 OUString aTitle; // title or file name (if no title)
202 OUString aLongDocName; // path and file name
203 OUString aShortDocName; // pure file name
204 OUString aTabName;
209
211};
212
213// for headers/footers with fields
215{
216private:
218
219public:
220 ScHeaderEditEngine( SfxItemPool* pEnginePool );
221 virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor, std::optional<FontLineStyle>& rFldLineStyle ) override;
222
223 void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; }
224 void SetData(const ScHeaderFieldData& rNew) { aData = rNew; }
225};
226
227// for Note text objects.
229{
230
231public:
233
234};
235
236// SvxFieldData derivations were moved to Svx (comment can be deleted?)
237
238/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rTxtColor, std::optional< Color > &rFldColor, std::optional< FontLineStyle > &rFldLineStyle)
void SetText(const OUString &rStr)
virtual bool FieldClicked(const SvxFieldItem &rField)
const SfxItemSet & GetAttribs() const
Definition: editutil.hxx:104
std::unique_ptr< SfxItemSet > pEditAttrs
Definition: editutil.hxx:94
ScEditAttrTester(ScEditEngineDefaulter *pEng)
Definition: editutil.cxx:456
bool NeedsObject() const
Definition: editutil.hxx:102
bool NeedsCellAttr() const
Definition: editutil.hxx:103
Point aCellPos
Definition: editutil.hxx:42
static void RemoveCharAttribs(EditTextObject &rEditText, const ScPatternAttr &rAttr)
Definition: editutil.cxx:155
ScEditUtil(ScDocument *pDocument, SCCOL nX, SCROW nY, SCTAB nZ, const Point &rCellPos, OutputDevice *pDevice, double nScaleX, double nScaleY, const Fraction &rX, const Fraction &rY, bool bPrintTwips=false)
Definition: editutil.cxx:56
void GetMargins(const ScPatternAttr *pPattern, tools::Long &nLeftMargin, tools::Long &nTopMargin, tools::Long &nRightMargin, tools::Long &BottomMargin) const
Definition: editutil.cxx:322
Fraction aZoomY
Definition: editutil.hxx:47
static OUString GetCellFieldValue(const SvxFieldData &rFieldData, const ScDocument *pDoc, std::optional< Color > *ppTextColor, std::optional< FontLineStyle > *ppFldLineStyle)
Definition: editutil.cxx:215
ScDocument * pDoc
Definition: editutil.hxx:38
bool bInPrintTwips
Definition: editutil.hxx:48
SCTAB nTab
Definition: editutil.hxx:41
static std::unique_ptr< EditTextObject > CreateURLObjectFromURL(ScDocument &rDoc, const OUString &rURL, const OUString &rText)
Definition: editutil.cxx:144
static OUString ModifyDelimiters(const OUString &rOld)
Definition: editutil.cxx:65
double nPPTX
Definition: editutil.hxx:44
double nPPTY
Definition: editutil.hxx:45
tools::Rectangle GetEditArea(const ScPatternAttr *pPattern, bool bForceToTop)
Definition: editutil.cxx:338
tools::Long GetIndent(const ScPatternAttr *pPattern) const
Definition: editutil.cxx:305
Fraction aZoomX
Definition: editutil.hxx:46
static OUString GetMultilineString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:109
VclPtr< OutputDevice > pDev
Definition: editutil.hxx:43
SCROW nRow
Definition: editutil.hxx:40
static std::unique_ptr< EditTextObject > Clone(const EditTextObject &rSrc, ScDocument &rDestDoc)
Definition: editutil.cxx:189
static OUString GetSpaceDelimitedString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by spaces.
Definition: editutil.cxx:105
static SC_DLLPUBLIC OUString GetString(const EditTextObject &rEditText, const ScDocument *pDoc)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:119
SCCOL nCol
Definition: editutil.hxx:39
virtual ~ScEnginePoolHelper()
Definition: editutil.cxx:534
rtl::Reference< SfxItemPool > pEnginePool
Definition: editutil.hxx:111
ScEnginePoolHelper(SfxItemPool *pEnginePool, bool bDeleteEnginePool)
Definition: editutil.cxx:515
SfxItemSet * pDefaults
Definition: editutil.hxx:112
void SetExecuteURL(bool bSet)
Definition: editutil.hxx:181
ScDocument * mpDoc
Definition: editutil.hxx:173
ScHeaderFieldData aData
Definition: editutil.hxx:217
void SetData(const ScHeaderFieldData &rNew)
Definition: editutil.hxx:224
void SetNumType(SvxNumType eNew)
Definition: editutil.hxx:223
ScNoteEditEngine(SfxItemPool *pEnginePool, SfxItemPool *pTextObjectPool)
Definition: editutil.cxx:931
void Init()
constexpr OUStringLiteral aData
long Long
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
OUString aLongDocName
Definition: editutil.hxx:202
tools::Long nPageNo
Definition: editutil.hxx:206
DateTime aDateTime
Definition: editutil.hxx:205
OUString aShortDocName
Definition: editutil.hxx:203
OUString aTabName
Definition: editutil.hxx:204
SvxNumType eNumType
Definition: editutil.hxx:208
tools::Long nTotalPages
Definition: editutil.hxx:207
SvxNumType
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17