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 
32 class ScDocument;
33 class ScPatternAttr;
35 
37 {
43  VclPtr<OutputDevice> pDev; // MapMode has to be set
44  double nPPTX;
45  double nPPTY;
49 
50 public:
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 );
78 
79 public:
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 
98 public:
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 {
110 protected:
115 
116  ScEnginePoolHelper( SfxItemPool* pEnginePool, bool bDeleteEnginePool );
117  ScEnginePoolHelper( const ScEnginePoolHelper& rOrg );
118  virtual ~ScEnginePoolHelper();
119 };
120 
122 {
123 public:
124  using EditEngine::SetText;
127  ScEditEngineDefaulter( SfxItemPool* pEnginePool,
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 );
154  void SetTextNewDefaults( const EditTextObject& rTextObject,
155  std::unique_ptr<SfxItemSet> pDefaults );
156 
158  void SetTextCurrentDefaults( const OUString& rText );
160  void SetTextNewDefaults( const OUString& rText,
161  const SfxItemSet& rDefaults );
163  void SetTextNewDefaults( const OUString& rText,
164  std::unique_ptr<SfxItemSet> pDefaults );
165 
168  void RemoveParaAttribs();
169 
172  void RepeatDefaults();
173 };
174 
175 // for field commands (or just fields?) in a table
177 {
178 private:
181 
182 public:
184  ScDocument* pDoc, SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool = nullptr,
185  bool bDeleteEnginePool = false);
186 
187  void SetExecuteURL(bool bSet) { bExecuteURL = bSet; }
188 
189  virtual void FieldClicked( const SvxFieldItem& rField ) override;
190  virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
191 };
192 
193 // 1/100 mm
195 {
196 private:
197  void Init(const ScPatternAttr& rPattern);
198 public:
199  ScTabEditEngine( ScDocument* pDoc ); // Default
200  ScTabEditEngine(const ScPatternAttr& rPattern,
201  SfxItemPool *pEngineItemPool, ScDocument *pDoc,
202  SfxItemPool* pTextObjectPool = nullptr );
203 };
204 
206 {
207  OUString aTitle; // title or file name (if no title)
208  OUString aLongDocName; // path and file name
209  OUString aShortDocName; // pure file name
210  OUString aTabName;
215 
217 };
218 
219 // for headers/footers with fields
221 {
222 private:
224 
225 public:
226  ScHeaderEditEngine( SfxItemPool* pEnginePool );
227  virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, std::optional<Color>& rTxtColor, std::optional<Color>& rFldColor ) override;
228 
229  void SetNumType(SvxNumType eNew) { aData.eNumType = eNew; }
230  void SetData(const ScHeaderFieldData& rNew) { aData = rNew; }
231 };
232 
233 // for Note text objects.
235 {
236 
237 public:
238  ScNoteEditEngine( SfxItemPool* pEnginePool, SfxItemPool* pTextObjectPool );
239 
240 };
241 
242 // SvxFieldData derivations were moved to Svx (comment can be deleted?)
243 
244 /* 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:94
OUString aLongDocName
Definition: editutil.hxx:208
Fraction aZoomX
Definition: editutil.hxx:46
Fraction aZoomY
Definition: editutil.hxx:47
SCTAB nTab
Definition: editutil.hxx:41
SCROW nRow
Definition: editutil.hxx:40
SfxItemSet * pDefaults
Definition: editutil.hxx:112
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:42
const SfxItemSet & GetAttribs() const
Definition: editutil.hxx:104
long Long
double nPPTY
Definition: editutil.hxx:45
static std::unique_ptr< EditTextObject > CreateURLObjectFromURL(ScDocument &rDoc, const OUString &rURL, const OUString &rText)
Definition: editutil.cxx:136
SvxNumType
ScHeaderFieldData aData
Definition: editutil.hxx:223
ScDocument * pDoc
Definition: editutil.hxx:38
virtual ~ScEnginePoolHelper()
Definition: editutil.cxx:509
ScNoteEditEngine(SfxItemPool *pEnginePool, SfxItemPool *pTextObjectPool)
Definition: editutil.cxx:937
void SetText(const OUString &rStr)
void SetExecuteURL(bool bSet)
Definition: editutil.hxx:187
ScEditAttrTester(ScEditEngineDefaulter *pEng)
Definition: editutil.cxx:431
OUString aShortDocName
Definition: editutil.hxx:209
tools::Long nTotalPages
Definition: editutil.hxx:213
sal_Int16 SCCOL
Definition: types.hxx:21
void SetNumType(SvxNumType eNew)
Definition: editutil.hxx:229
bool bInPrintTwips
Definition: editutil.hxx:48
OUString aTabName
Definition: editutil.hxx:210
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:230
sal_Int32 SCROW
Definition: types.hxx:17
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
rtl::Reference< SfxItemPool > pEnginePool
Definition: editutil.hxx:111
double nPPTX
Definition: editutil.hxx:44
static OUString ModifyDelimiters(const OUString &rOld)
Definition: editutil.cxx:62
ScEnginePoolHelper(SfxItemPool *pEnginePool, bool bDeleteEnginePool)
Definition: editutil.cxx:490
DateTime aDateTime
Definition: editutil.hxx:211
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:212
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:179
static std::unique_ptr< EditTextObject > Clone(const EditTextObject &rSrc, ScDocument &rDestDoc)
Definition: editutil.cxx:168
VclPtr< OutputDevice > pDev
Definition: editutil.hxx:43
SCCOL nCol
Definition: editutil.hxx:39
bool NeedsCellAttr() const
Definition: editutil.hxx:103
bool NeedsObject() const
Definition: editutil.hxx:102
SvxNumType eNumType
Definition: editutil.hxx:214
static OUString GetMultilineString(const EditEngine &rEngine)
Retrieves string with paragraphs delimited by new lines (' ').
Definition: editutil.cxx:101
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
sal_Int16 SCTAB
Definition: types.hxx:22