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 };
88 
90 {
91  std::unique_ptr<SfxItemSet> pEditAttrs;
94 
95 public:
98 
99  bool NeedsObject() const { return bNeedsObject; }
100  bool NeedsCellAttr() const { return bNeedsCellAttr; }
101  const SfxItemSet& GetAttribs() const { return *pEditAttrs; }
102 };
103 
104 // construct pool before constructing EditEngine, destroy pool after EditEngine
106 {
107 protected:
112 
113  ScEnginePoolHelper( SfxItemPool* pEnginePool, bool bDeleteEnginePool );
114  ScEnginePoolHelper( const ScEnginePoolHelper& rOrg );
115  virtual ~ScEnginePoolHelper();
116 };
117 
119 {
120 public:
121  using EditEngine::SetText;
124  ScEditEngineDefaulter( SfxItemPool* pEnginePool,
125  bool bDeleteEnginePool = false );
129  virtual ~ScEditEngineDefaulter() override;
130 
132  void SetDefaults( const SfxItemSet& rDefaults, bool bRememberCopy = true );
133 
135  void SetDefaults( std::unique_ptr<SfxItemSet> pDefaults );
136 
140  void SetDefaultItem( const SfxPoolItem& rItem );
141 
143  const SfxItemSet& GetDefaults();
144 
146  void SetTextCurrentDefaults( const EditTextObject& rTextObject );
148  void SetTextNewDefaults( const EditTextObject& rTextObject,
149  const SfxItemSet& rDefaults, bool bRememberCopy = true );
151  void SetTextNewDefaults( const EditTextObject& rTextObject,
152  std::unique_ptr<SfxItemSet> pDefaults );
153 
155  void SetTextCurrentDefaults( const OUString& rText );
157  void SetTextNewDefaults( const OUString& rText,
158  const SfxItemSet& rDefaults );
160  void SetTextNewDefaults( const OUString& rText,
161  std::unique_ptr<SfxItemSet> pDefaults );
162 
165  void RemoveParaAttribs();
166 
169  void RepeatDefaults();
170 };
171 
172 // for field commands (or just fields?) in a table
174 {
175 private:
178 
179 public:
181  ScDocument* pDoc, SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool = nullptr,
182  bool bDeleteEnginePool = false);
183 
184  void SetExecuteURL(bool bSet) { bExecuteURL = bSet; }
185 
186  virtual void FieldClicked( const SvxFieldItem& rField ) override;
187  virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
188 };
189 
190 // 1/100 mm
192 {
193 private:
194  void Init(const ScPatternAttr& rPattern);
195 public:
196  ScTabEditEngine( ScDocument* pDoc ); // Default
197  ScTabEditEngine(const ScPatternAttr& rPattern,
198  SfxItemPool *pEngineItemPool, ScDocument *pDoc,
199  SfxItemPool* pTextObjectPool = nullptr );
200 };
201 
203 {
204  OUString aTitle; // title or file name (if no title)
205  OUString aLongDocName; // path and file name
206  OUString aShortDocName; // pure file name
207  OUString aTabName;
212 
214 };
215 
216 // for headers/footers with fields
218 {
219 private:
221 
222 public:
223  ScHeaderEditEngine( SfxItemPool* pEnginePool );
224  virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
225 
226  void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; }
227  void SetData(const ScHeaderFieldData& rNew) { aData = rNew; }
228 };
229 
230 // for Note text objects.
232 {
233 
234 public:
235  ScNoteEditEngine( SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool );
236 
237 };
238 
239 // SvxFieldData derivations were moved to Svx (comment can be deleted?)
240 
241 #endif
242 
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Rectangle GetEditArea(const ScPatternAttr *pPattern, bool bForceToTop)
Definition: editutil.cxx:281
std::unique_ptr< SfxItemSet > pEditAttrs
Definition: editutil.hxx:91
OUString aLongDocName
Definition: editutil.hxx:205
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:109
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:101
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:220
ScDocument * pDoc
Definition: editutil.hxx:39
virtual ~ScEnginePoolHelper()
Definition: editutil.cxx:466
ScNoteEditEngine(SfxItemPool *pEnginePool, SfxItemPool *pTextObjectPool)
Definition: editutil.cxx:896
void SetText(const OUString &rStr)
void SetExecuteURL(bool bSet)
Definition: editutil.hxx:184
ScEditAttrTester(ScEditEngineDefaulter *pEng)
Definition: editutil.cxx:388
OUString aShortDocName
Definition: editutil.hxx:206
tools::Long nTotalPages
Definition: editutil.hxx:210
sal_Int16 SCCOL
Definition: types.hxx:22
void SetNumType(SvxNumType eNew)
Definition: editutil.hxx:226
bool bInPrintTwips
Definition: editutil.hxx:49
OUString aTabName
Definition: editutil.hxx:207
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:227
sal_Int32 SCROW
Definition: types.hxx:18
SfxItemPool * pEnginePool
Definition: editutil.hxx:108
double nPPTX
Definition: editutil.hxx:45
static OUString ModifyDelimiters(const OUString &rOld)
Definition: editutil.cxx:62
ScEnginePoolHelper(SfxItemPool *pEnginePool, bool bDeleteEnginePool)
Definition: editutil.cxx:447
DateTime aDateTime
Definition: editutil.hxx:208
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:209
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:176
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:100
bool NeedsObject() const
Definition: editutil.hxx:99
SvxNumType eNumType
Definition: editutil.hxx:211
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