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 #ifndef INCLUDED_SC_INC_EDITUTIL_HXX
21 #define INCLUDED_SC_INC_EDITUTIL_HXX
22 
23 #include <memory>
24 #include "scdllapi.h"
25 #include "types.hxx"
26 #include <editeng/editeng.hxx>
27 #include <svx/pageitem.hxx>
28 #include <tools/datetime.hxx>
29 #include <tools/gen.hxx>
30 #include <tools/fract.hxx>
31 #include <vcl/outdev.hxx>
32 
33 class ScDocument;
34 class ScPatternAttr;
36 
38 {
44  VclPtr<OutputDevice> pDev; // MapMode has to be set
45  double nPPTX;
46  double nPPTY;
50 
51 public:
52  static OUString ModifyDelimiters( const OUString& rOld );
53 
55  static OUString GetSpaceDelimitedString( const EditEngine& rEngine );
56 
58  static OUString GetMultilineString( const EditEngine& rEngine );
59  static OUString GetMultilineString( const EditTextObject& rEdit );
60 
68  SC_DLLPUBLIC static OUString GetString( const EditTextObject& rEditText, const ScDocument* pDoc );
69 
70  static std::unique_ptr<EditTextObject> CreateURLObjectFromURL(
71  ScDocument& rDoc, const OUString& rURL, const OUString& rText );
72 
73  static void RemoveCharAttribs( EditTextObject& rEditText, const ScPatternAttr& rAttr );
74 
75  static std::unique_ptr<EditTextObject> Clone( const EditTextObject& rSrc, ScDocument& rDestDoc );
76 
77  static OUString GetCellFieldValue(
78  const SvxFieldData& rFieldData, const ScDocument* pDoc, std::optional<Color>* ppTextColor );
79 
80 public:
81  ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
82  const Point& rCellPos,
83  OutputDevice* pDevice, double nScaleX, double nScaleY,
84  const Fraction& rX, const Fraction& rY, bool bPrintTwips = false );
85 
86  tools::Rectangle GetEditArea( const ScPatternAttr* pPattern, bool bForceToTop );
87  tools::Long GetIndent(const ScPatternAttr* pPattern) const;
88  void GetMargins(const ScPatternAttr* pPattern, tools::Long& nLeftMargin, tools::Long& nTopMargin,
89  tools::Long& nRightMargin, tools::Long& BottomMargin) const;
90 
91 };
92 
94 {
95  std::unique_ptr<SfxItemSet> pEditAttrs;
98 
99 public:
102 
103  bool NeedsObject() const { return bNeedsObject; }
104  bool NeedsCellAttr() const { return bNeedsCellAttr; }
105  const SfxItemSet& GetAttribs() const { return *pEditAttrs; }
106 };
107 
108 // construct pool before constructing EditEngine, destroy pool after EditEngine
110 {
111 protected:
116 
117  ScEnginePoolHelper( SfxItemPool* pEnginePool, bool bDeleteEnginePool );
118  ScEnginePoolHelper( const ScEnginePoolHelper& rOrg );
119  virtual ~ScEnginePoolHelper();
120 };
121 
123 {
124 public:
125  using EditEngine::SetText;
128  ScEditEngineDefaulter( SfxItemPool* pEnginePool,
129  bool bDeleteEnginePool = false );
133  virtual ~ScEditEngineDefaulter() override;
134 
136  void SetDefaults( const SfxItemSet& rDefaults, bool bRememberCopy = true );
137 
139  void SetDefaults( std::unique_ptr<SfxItemSet> pDefaults );
140 
144  void SetDefaultItem( const SfxPoolItem& rItem );
145 
147  const SfxItemSet& GetDefaults();
148 
150  void SetTextCurrentDefaults( const EditTextObject& rTextObject );
152  void SetTextNewDefaults( const EditTextObject& rTextObject,
153  const SfxItemSet& rDefaults, bool bRememberCopy = true );
155  void SetTextNewDefaults( const EditTextObject& rTextObject,
156  std::unique_ptr<SfxItemSet> pDefaults );
157 
159  void SetTextCurrentDefaults( const OUString& rText );
161  void SetTextNewDefaults( const OUString& rText,
162  const SfxItemSet& rDefaults );
164  void SetTextNewDefaults( const OUString& rText,
165  std::unique_ptr<SfxItemSet> pDefaults );
166 
169  void RemoveParaAttribs();
170 
173  void RepeatDefaults();
174 };
175 
176 // for field commands (or just fields?) in a table
178 {
179 private:
182 
183 public:
185  ScDocument* pDoc, SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool = nullptr,
186  bool bDeleteEnginePool = false);
187 
188  void SetExecuteURL(bool bSet) { bExecuteURL = bSet; }
189 
190  virtual void FieldClicked( const SvxFieldItem& rField ) override;
191  virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
192 };
193 
194 // 1/100 mm
196 {
197 private:
198  void Init(const ScPatternAttr& rPattern);
199 public:
200  ScTabEditEngine( ScDocument* pDoc ); // Default
201  ScTabEditEngine(const ScPatternAttr& rPattern,
202  SfxItemPool *pEngineItemPool, ScDocument *pDoc,
203  SfxItemPool* pTextObjectPool = nullptr );
204 };
205 
207 {
208  OUString aTitle; // title or file name (if no title)
209  OUString aLongDocName; // path and file name
210  OUString aShortDocName; // pure file name
211  OUString aTabName;
216 
218 };
219 
220 // for headers/footers with fields
222 {
223 private:
225 
226 public:
227  ScHeaderEditEngine( SfxItemPool* pEnginePool );
228  virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
229 
230  void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; }
231  void SetData(const ScHeaderFieldData& rNew) { aData = rNew; }
232 };
233 
234 // for Note text objects.
236 {
237 
238 public:
239  ScNoteEditEngine( SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool );
240 
241 };
242 
243 // SvxFieldData derivations were moved to Svx (comment can be deleted?)
244 
245 #endif
246 
247 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Rectangle GetEditArea(const ScPatternAttr *pPattern, bool bForceToTop)
Definition: editutil.cxx:314
std::unique_ptr< SfxItemSet > pEditAttrs
Definition: editutil.hxx:95
OUString aLongDocName
Definition: editutil.hxx:209
Fraction aZoomX
Definition: editutil.hxx:47
Fraction aZoomY
Definition: editutil.hxx:48
SCTAB nTab
Definition: editutil.hxx:42
SCROW nRow
Definition: editutil.hxx:41
SfxItemSet * pDefaults
Definition: editutil.hxx:113
void Init()
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rTxtColor, std::optional< Color > &rFldColor)
Point aCellPos
Definition: editutil.hxx:43
const SfxItemSet & GetAttribs() const
Definition: editutil.hxx:105
long Long
double nPPTY
Definition: editutil.hxx:46
static std::unique_ptr< EditTextObject > CreateURLObjectFromURL(ScDocument &rDoc, const OUString &rURL, const OUString &rText)
Definition: editutil.cxx:136
SvxNumType
ScHeaderFieldData aData
Definition: editutil.hxx:224
ScDocument * pDoc
Definition: editutil.hxx:39
virtual ~ScEnginePoolHelper()
Definition: editutil.cxx:509
ScNoteEditEngine(SfxItemPool *pEnginePool, SfxItemPool *pTextObjectPool)
Definition: editutil.cxx:939
void SetText(const OUString &rStr)
void SetExecuteURL(bool bSet)
Definition: editutil.hxx:188
ScEditAttrTester(ScEditEngineDefaulter *pEng)
Definition: editutil.cxx:431
OUString aShortDocName
Definition: editutil.hxx:210
tools::Long nTotalPages
Definition: editutil.hxx:214
sal_Int16 SCCOL
Definition: types.hxx:22
void SetNumType(SvxNumType eNew)
Definition: editutil.hxx:230
bool bInPrintTwips
Definition: editutil.hxx:49
OUString aTabName
Definition: editutil.hxx:211
static OUString GetCellFieldValue(const SvxFieldData &rFieldData, const ScDocument *pDoc, std::optional< Color > *ppTextColor)
Definition: editutil.cxx:194
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:53
void SetData(const ScHeaderFieldData &rNew)
Definition: editutil.hxx:231
sal_Int32 SCROW
Definition: types.hxx:18
tools::Long GetIndent(const ScPatternAttr *pPattern) const
Definition: editutil.cxx:281
void GetMargins(const ScPatternAttr *pPattern, tools::Long &nLeftMargin, tools::Long &nTopMargin, tools::Long &nRightMargin, tools::Long &BottomMargin) const
Definition: editutil.cxx:298
SfxItemPool * pEnginePool
Definition: editutil.hxx:112
double nPPTX
Definition: editutil.hxx:45
static OUString ModifyDelimiters(const OUString &rOld)
Definition: editutil.cxx:62
ScEnginePoolHelper(SfxItemPool *pEnginePool, bool bDeleteEnginePool)
Definition: editutil.cxx:490
DateTime aDateTime
Definition: editutil.hxx:212
static OUString GetSpaceDelimitedString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by spaces.
Definition: editutil.cxx:97
static void RemoveCharAttribs(EditTextObject &rEditText, const ScPatternAttr &rAttr)
Definition: editutil.cxx:147
tools::Long nPageNo
Definition: editutil.hxx:213
static SC_DLLPUBLIC OUString GetString(const EditTextObject &rEditText, const ScDocument *pDoc)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:111
virtual void FieldClicked(const SvxFieldItem &rField)
ScDocument * mpDoc
Definition: editutil.hxx:180
static std::unique_ptr< EditTextObject > Clone(const EditTextObject &rSrc, ScDocument &rDestDoc)
Definition: editutil.cxx:168
VclPtr< OutputDevice > pDev
Definition: editutil.hxx:44
SCCOL nCol
Definition: editutil.hxx:40
bool NeedsCellAttr() const
Definition: editutil.hxx:104
bool NeedsObject() const
Definition: editutil.hxx:103
SvxNumType eNumType
Definition: editutil.hxx:215
static OUString GetMultilineString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:101
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
sal_Int16 SCTAB
Definition: types.hxx:23