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 private:
121  using EditEngine::SetText;
122 
123 public:
126  ScEditEngineDefaulter( SfxItemPool* pEnginePool,
127  bool bDeleteEnginePool = false );
131  virtual ~ScEditEngineDefaulter() override;
132 
134  void SetDefaults( const SfxItemSet& rDefaults, bool bRememberCopy = true );
135 
137  void SetDefaults( std::unique_ptr<SfxItemSet> pDefaults );
138 
142  void SetDefaultItem( const SfxPoolItem& rItem );
143 
145  const SfxItemSet& GetDefaults();
146 
148  void SetTextCurrentDefaults( const EditTextObject& rTextObject );
150  void SetTextNewDefaults( const EditTextObject& rTextObject,
151  const SfxItemSet& rDefaults, bool bRememberCopy = true );
153  void SetTextNewDefaults( const EditTextObject& rTextObject,
154  std::unique_ptr<SfxItemSet> pDefaults );
155 
157  void SetTextCurrentDefaults( const OUString& rText );
159  void SetTextNewDefaults( const OUString& rText,
160  const SfxItemSet& rDefaults );
162  void SetTextNewDefaults( const OUString& rText,
163  std::unique_ptr<SfxItemSet> pDefaults );
164 
167  void RemoveParaAttribs();
168 
171  void RepeatDefaults();
172 };
173 
174 // for field commands (or just fields?) in a table
176 {
177 private:
180 
181 public:
183  ScDocument* pDoc, SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool = nullptr,
184  bool bDeleteEnginePool = false);
185 
186  void SetExecuteURL(bool bSet) { bExecuteURL = bSet; }
187 
188  virtual void FieldClicked( const SvxFieldItem& rField ) override;
189  virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
190 };
191 
192 // 1/100 mm
194 {
195 private:
196  void Init(const ScPatternAttr& rPattern);
197 public:
198  ScTabEditEngine( ScDocument* pDoc ); // Default
199  ScTabEditEngine(const ScPatternAttr& rPattern,
200  SfxItemPool *pEngineItemPool, ScDocument *pDoc,
201  SfxItemPool* pTextObjectPool = nullptr );
202 };
203 
205 {
206  OUString aTitle; // title or file name (if no title)
207  OUString aLongDocName; // path and file name
208  OUString aShortDocName; // pure file name
209  OUString aTabName;
211  long nPageNo;
214 
216 };
217 
218 // for headers/footers with fields
220 {
221 private:
223 
224 public:
225  ScHeaderEditEngine( SfxItemPool* pEnginePool );
226  virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
227 
228  void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; }
229  void SetData(const ScHeaderFieldData& rNew) { aData = rNew; }
230 };
231 
232 // for Note text objects.
234 {
235 
236 public:
237  ScNoteEditEngine( SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool );
238 
239 };
240 
241 // SvxFieldData derivations were moved to Svx (comment can be deleted?)
242 
243 #endif
244 
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Rectangle GetEditArea(const ScPatternAttr *pPattern, bool bForceToTop)
Definition: editutil.cxx:285
std::unique_ptr< SfxItemSet > pEditAttrs
Definition: editutil.hxx:91
OUString aLongDocName
Definition: editutil.hxx:207
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
double nPPTY
Definition: editutil.hxx:46
static std::unique_ptr< EditTextObject > CreateURLObjectFromURL(ScDocument &rDoc, const OUString &rURL, const OUString &rText)
Definition: editutil.cxx:140
SvxNumType
ScHeaderFieldData aData
Definition: editutil.hxx:222
ScDocument * pDoc
Definition: editutil.hxx:39
virtual ~ScEnginePoolHelper()
Definition: editutil.cxx:470
ScNoteEditEngine(SfxItemPool *pEnginePool, SfxItemPool *pTextObjectPool)
Definition: editutil.cxx:900
void SetText(const OUString &rStr)
void SetExecuteURL(bool bSet)
Definition: editutil.hxx:186
ScEditAttrTester(ScEditEngineDefaulter *pEng)
Definition: editutil.cxx:392
OUString aShortDocName
Definition: editutil.hxx:208
sal_Int16 SCCOL
Definition: types.hxx:22
void SetNumType(SvxNumType eNew)
Definition: editutil.hxx:228
bool bInPrintTwips
Definition: editutil.hxx:49
OUString aTabName
Definition: editutil.hxx:209
static OUString GetCellFieldValue(const SvxFieldData &rFieldData, const ScDocument *pDoc, std::optional< Color > *ppTextColor)
Definition: editutil.cxx:198
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:57
void SetData(const ScHeaderFieldData &rNew)
Definition: editutil.hxx:229
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:66
ScEnginePoolHelper(SfxItemPool *pEnginePool, bool bDeleteEnginePool)
Definition: editutil.cxx:451
DateTime aDateTime
Definition: editutil.hxx:210
static OUString GetSpaceDelimitedString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by spaces.
Definition: editutil.cxx:101
static void RemoveCharAttribs(EditTextObject &rEditText, const ScPatternAttr &rAttr)
Definition: editutil.cxx:151
static SC_DLLPUBLIC OUString GetString(const EditTextObject &rEditText, const ScDocument *pDoc)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:115
virtual void FieldClicked(const SvxFieldItem &rField)
ScDocument * mpDoc
Definition: editutil.hxx:178
static std::unique_ptr< EditTextObject > Clone(const EditTextObject &rSrc, ScDocument &rDestDoc)
Definition: editutil.cxx:172
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:213
static OUString GetMultilineString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:105
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
sal_Int16 SCTAB
Definition: types.hxx:23