LibreOffice Module sc (master) 1
tabvwsha.cxx
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#include <com/sun/star/table/BorderLineStyle.hpp>
21
22#include <comphelper/lok.hxx>
23#include <editeng/boxitem.hxx>
24#include <editeng/langitem.hxx>
25#include <o3tl/temporary.hxx>
26#include <sfx2/bindings.hxx>
27#include <sfx2/request.hxx>
28#include <sfx2/sfxdlg.hxx>
30#include <sfx2/viewfrm.hxx>
31#include <sfx2/dispatch.hxx>
32#include <sfx2/newstyle.hxx>
33#include <sfx2/tplpitem.hxx>
34#include <svl/ilstitem.hxx>
35#include <svl/numformat.hxx>
36#include <svl/zformat.hxx>
37#include <svl/int64item.hxx>
38#include <svl/ptitem.hxx>
39#include <svl/srchitem.hxx>
40#include <svl/srchdefs.hxx>
41#include <svl/stritem.hxx>
42#include <svl/whiter.hxx>
43#include <svx/numinf.hxx>
44#include <svx/xbtmpit.hxx>
45#include <svx/xlndsit.hxx>
46#include <svx/xlnstit.hxx>
47#include <svx/xlnedit.hxx>
48#include <svx/xflgrit.hxx>
49#include <svx/xflftrit.hxx>
50#include <svx/xflhtit.hxx>
52
53#include <global.hxx>
54#include <appoptio.hxx>
55#include <attrib.hxx>
56#include <cellform.hxx>
57#include <cellvalue.hxx>
58#include <compiler.hxx>
59#include <docsh.hxx>
60#include <document.hxx>
61#include <formulacell.hxx>
62#include <globstr.hrc>
63#include <inputhdl.hxx>
64#include <inputwin.hxx>
65#include <markdata.hxx>
66#include <patattr.hxx>
67#include <sc.hrc>
68#include <scabstdlg.hxx>
69#include <scitems.hxx>
70#include <scmod.hxx>
71#include <scresid.hxx>
72#include <stlpool.hxx>
73#include <tabvwsh.hxx>
74#include <tokenarray.hxx>
75#include <viewdata.hxx>
76#include <docpool.hxx>
77#include <printfun.hxx>
78#include <undostyl.hxx>
79#include <futext.hxx>
80
81#include <memory>
82
83using namespace com::sun::star;
84
85bool ScTabViewShell::GetFunction( OUString& rFuncStr, FormulaError nErrCode )
86{
87 sal_uInt32 nFuncs = SC_MOD()->GetAppOptions().GetStatusFunc();
88 ScViewData& rViewData = GetViewData();
89 ScMarkData& rMark = rViewData.GetMarkData();
90 bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked());
91 bool bFirst = true;
92 for ( sal_uInt16 nFunc = 0; nFunc < 32; nFunc++ )
93 {
94 if ( !(nFuncs & (1U << nFunc)) )
95 continue;
96 ScSubTotalFunc eFunc = static_cast<ScSubTotalFunc>(nFunc);
97
98 if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
99 nErrCode = FormulaError::NONE;
100
101 if (nErrCode != FormulaError::NONE)
102 {
103 rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
104 return true;
105 }
106
107 TranslateId pGlobStrId;
108 switch (eFunc)
109 {
110 case SUBTOTAL_FUNC_AVE: pGlobStrId = STR_FUN_TEXT_AVG; break;
111 case SUBTOTAL_FUNC_CNT: pGlobStrId = STR_FUN_TEXT_COUNT; break;
112 case SUBTOTAL_FUNC_CNT2: pGlobStrId = STR_FUN_TEXT_COUNT2; break;
113 case SUBTOTAL_FUNC_MAX: pGlobStrId = STR_FUN_TEXT_MAX; break;
114 case SUBTOTAL_FUNC_MIN: pGlobStrId = STR_FUN_TEXT_MIN; break;
115 case SUBTOTAL_FUNC_SUM: pGlobStrId = STR_FUN_TEXT_SUM; break;
116 case SUBTOTAL_FUNC_SELECTION_COUNT: pGlobStrId = STR_FUN_TEXT_SELECTION_COUNT; break;
117
118 default:
119 {
120 // added to avoid warnings
121 }
122 }
123 if (pGlobStrId)
124 {
125 ScDocument& rDoc = rViewData.GetDocument();
126 SCCOL nPosX = rViewData.GetCurX();
127 SCROW nPosY = rViewData.GetCurY();
128 SCTAB nTab = rViewData.GetTabNo();
129
130 OUString aStr = ScResId(pGlobStrId) + ": ";
131
132 ScAddress aCursor( nPosX, nPosY, nTab );
133 double nVal;
134 if ( rDoc.GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
135 {
136 if ( nVal == 0.0 )
137 aStr += "0";
138 else
139 {
140 // Number in the standard format, the other on the cursor position
141 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
142 sal_uInt32 nNumFmt = 0;
143 if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 && eFunc != SUBTOTAL_FUNC_SELECTION_COUNT)
144 {
145 // number format from attributes or formula
146 nNumFmt = rDoc.GetNumberFormat( nPosX, nPosY, nTab );
147 // If the number format is time (without date) and the
148 // result is not within 24 hours, use a duration
149 // format. Summing date+time doesn't make much sense
150 // otherwise but we also don't want to display duration
151 // for a single date+time value.
152 if (nVal < 0.0 || nVal >= 1.0)
153 {
154 const SvNumberformat* pFormat = pFormatter->GetEntry(nNumFmt);
155 if (pFormat && (pFormat->GetType() == SvNumFormatType::TIME))
156 nNumFmt = pFormatter->GetTimeFormat( nVal, pFormat->GetLanguage(), true);
157 }
158 }
159
160 OUString aValStr;
161 const Color* pDummy;
162 pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
163 aStr += aValStr;
164 }
165 }
166 if ( bFirst )
167 {
168 rFuncStr += aStr;
169 bFirst = false;
170 }
171 else
172 rFuncStr += "; " + aStr;
173 }
174 }
175
176 return !rFuncStr.isEmpty();
177}
178
179// Functions that are disabled, depending on the selection
180// Default:
181// SID_DELETE,
182// SID_DELETE_CONTENTS,
183// FID_DELETE_CELL
184// FID_VALIDATION
185
187{
188 ScViewData& rViewData = GetViewData();
189 ScDocument& rDoc = rViewData.GetDocument();
190 ScDocShell* pDocShell = rViewData.GetDocShell();
191 ScMarkData& rMark = rViewData.GetMarkData();
192 SCCOL nPosX = rViewData.GetCurX();
193 SCROW nPosY = rViewData.GetCurY();
194 SCTAB nTab = rViewData.GetTabNo();
195
196 SfxViewFrame& rThisFrame = GetViewFrame();
197 bool bOle = GetViewFrame().GetFrame().IsInPlace();
198
199 SCTAB nTabSelCount = rMark.GetSelectCount();
200
201 SfxWhichIter aIter(rSet);
202 sal_uInt16 nWhich = aIter.FirstWhich();
203
204 while ( nWhich )
205 {
206 switch ( nWhich )
207 {
208 case FID_CHG_COMMENT:
209 {
210 ScDocShell* pDocSh = GetViewData().GetDocShell();
211 ScAddress aPos( nPosX, nPosY, nTab );
212 if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() )
213 rSet.DisableItem( nWhich );
214 }
215 break;
216
217 case SID_OPENDLG_EDIT_PRINTAREA:
218 case SID_ADD_PRINTAREA:
219 case SID_DEFINE_PRINTAREA:
220 {
221 if ( pDocShell && pDocShell->IsDocShared() )
222 {
223 rSet.DisableItem( nWhich );
224 }
225 }
226 break;
227
228 case SID_DELETE_PRINTAREA:
229 if ( pDocShell && pDocShell->IsDocShared() )
230 {
231 rSet.DisableItem( nWhich );
232 }
233 else if (rDoc.IsPrintEntireSheet(nTab))
234 rSet.DisableItem(nWhich);
235 break;
236
237 case SID_STATUS_PAGESTYLE:
238 case SID_HFEDIT:
240 break;
241
242 case SID_SEARCH_ITEM:
243 {
244 SvxSearchItem aItem(ScGlobal::GetSearchItem()); // make a copy.
245 // Search on current selection if a range is marked.
246 aItem.SetSelection(rMark.IsMarked());
247 rSet.Put(aItem);
248 break;
249 }
250
251 case SID_SEARCH_OPTIONS:
252 {
253 // Anything goes
254 SearchOptionFlags nOptions = SearchOptionFlags::ALL;
255
256 // No replacement if ReadOnly
257 if (GetViewData().GetDocShell()->IsReadOnly())
258 nOptions &= ~SearchOptionFlags( SearchOptionFlags::REPLACE | SearchOptionFlags::REPLACE_ALL );
259 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(nOptions) ) );
260 }
261 break;
262
263 case SID_CURRENTCELL:
264 {
265 ScAddress aScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), 0 );
266 OUString aAddr(aScAddress.Format(ScRefFlags::ADDR_ABS, nullptr, rDoc.GetAddressConvention()));
267 SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
268
269 rSet.Put( aPosItem );
270 }
271 break;
272
273 case SID_CURRENTTAB:
274 // Table for Basic is 1-based
275 rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData().GetTabNo()) + 1 ) );
276 break;
277
278 case SID_CURRENTDOC:
279 rSet.Put( SfxStringItem( nWhich, GetViewData().GetDocShell()->GetTitle() ) );
280 break;
281
282 case FID_TOGGLEINPUTLINE:
283 {
284 sal_uInt16 nId = ScInputWindowWrapper::GetChildWindowId();
285
286 if ( rThisFrame.KnowsChildWindow( nId ) )
287 {
288 SfxChildWindow* pWnd = rThisFrame.GetChildWindow( nId );
289 rSet.Put( SfxBoolItem( nWhich, pWnd != nullptr ) );
290 }
291 else
292 rSet.DisableItem( nWhich );
293 }
294 break;
295
296 case FID_DEL_MANUALBREAKS:
297 if (!rDoc.HasManualBreaks(nTab))
298 rSet.DisableItem( nWhich );
299 break;
300
301 case FID_RESET_PRINTZOOM:
302 {
303 // disable if already set to default
304
305 OUString aStyleName = rDoc.GetPageStyle( nTab );
306 ScStyleSheetPool* pStylePool = rDoc.GetStyleSheetPool();
307 SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
308 SfxStyleFamily::Page );
309 OSL_ENSURE( pStyleSheet, "PageStyle not found" );
310 if ( pStyleSheet )
311 {
312 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
313 sal_uInt16 nScale = rStyleSet.Get(ATTR_PAGE_SCALE).GetValue();
314 sal_uInt16 nPages = rStyleSet.Get(ATTR_PAGE_SCALETOPAGES).GetValue();
315 if ( nScale == 100 && nPages == 0 )
316 rSet.DisableItem( nWhich );
317 }
318 }
319 break;
320
321 case SID_ZOOM_IN:
322 {
323 const Fraction& rZoomY = GetViewData().GetZoomY();
324 tools::Long nZoom = tools::Long(rZoomY * 100);
325 if (nZoom >= MAXZOOM)
326 rSet.DisableItem(nWhich);
327 }
328 break;
329 case SID_ZOOM_OUT:
330 {
331 const Fraction& rZoomY = GetViewData().GetZoomY();
332 tools::Long nZoom = tools::Long(rZoomY * 100);
333 if (nZoom <= MINZOOM)
334 rSet.DisableItem(nWhich);
335 }
336 break;
337
338 case FID_SCALE:
339 case SID_ATTR_ZOOM:
340 if ( bOle )
341 rSet.DisableItem( nWhich );
342 else
343 {
344 const Fraction& rOldY = GetViewData().GetZoomY();
345 sal_uInt16 nZoom = static_cast<sal_uInt16>(tools::Long( rOldY * 100 ));
346 rSet.Put( SvxZoomItem( SvxZoomType::PERCENT, nZoom, TypedWhichId<SvxZoomItem>(nWhich) ) );
347 }
348 break;
349
350 case SID_ATTR_ZOOMSLIDER:
351 {
352 if ( bOle )
353 rSet.DisableItem( nWhich );
354 else
355 {
356 const Fraction& rOldY = GetViewData().GetZoomY();
357 sal_uInt16 nCurrentZoom = static_cast<sal_uInt16>(tools::Long( rOldY * 100 ));
358
359 if( nCurrentZoom )
360 {
361 SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
362 aZoomSliderItem.AddSnappingPoint( 100 );
363 rSet.Put( aZoomSliderItem );
364 }
365 }
366 }
367 break;
368
369 case FID_FUNCTION_BOX:
370 {
371 const bool bBoxOpen = ::sfx2::sidebar::Sidebar::IsPanelVisible(u"ScFunctionsPanel",
372 rThisFrame.GetFrame().GetFrameInterface());
373 rSet.Put(SfxBoolItem(nWhich, bBoxOpen));
374 break;
375 }
376
377 case FID_TOGGLESYNTAX:
378 rSet.Put(SfxBoolItem(nWhich, GetViewData().IsSyntaxMode()));
379 break;
380
381 case FID_TOGGLEHEADERS:
382 rSet.Put(SfxBoolItem(nWhich, GetViewData().IsHeaderMode()));
383 break;
384
385 case FID_TOGGLEFORMULA:
386 {
387 const ScViewOptions& rOpts = rViewData.GetOptions();
388 bool bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
389 rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
390 }
391 break;
392
393 case FID_NORMALVIEWMODE:
394 case FID_PAGEBREAKMODE:
395 // always handle both slots - they exclude each other
396 if ( bOle )
397 {
398 rSet.DisableItem( FID_NORMALVIEWMODE );
399 rSet.DisableItem( FID_PAGEBREAKMODE );
400 }
401 else
402 {
403 rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData().IsPagebreakMode()));
404 rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData().IsPagebreakMode()));
405 }
406 break;
407
408 case FID_PROTECT_DOC:
409 {
410 if ( pDocShell && pDocShell->IsDocShared() )
411 {
412 rSet.DisableItem( nWhich );
413 }
414 else
415 {
416 rSet.Put( SfxBoolItem( nWhich, rDoc.IsDocProtected() ) );
417 }
418 }
419 break;
420
421 case FID_PROTECT_TABLE:
422 {
423 if ( pDocShell && pDocShell->IsDocShared() )
424 {
425 rSet.DisableItem( nWhich );
426 }
427 else
428 {
429 rSet.Put( SfxBoolItem( nWhich, rDoc.IsTabProtected( nTab ) ) );
430 }
431 }
432 break;
433
434 case SID_AUTO_OUTLINE:
435 {
436 if (rDoc.GetChangeTrack()!=nullptr || GetViewData().IsMultiMarked())
437 {
438 rSet.DisableItem( nWhich );
439 }
440 }
441 break;
442
443 case SID_OUTLINE_DELETEALL:
444 {
445 SCTAB nOlTab = GetViewData().GetTabNo();
446 ScOutlineTable* pOlTable = rDoc.GetOutlineTable( nOlTab );
447 if (pOlTable == nullptr)
448 rSet.DisableItem( nWhich );
449 }
450 break;
451
452 case SID_WINDOW_SPLIT:
453 rSet.Put(SfxBoolItem(nWhich,
454 rViewData.GetHSplitMode() == SC_SPLIT_NORMAL ||
455 rViewData.GetVSplitMode() == SC_SPLIT_NORMAL ));
456 break;
457
458 case SID_WINDOW_FIX:
460 {
461 rSet.Put(SfxBoolItem(nWhich,
462 rViewData.GetHSplitMode() == SC_SPLIT_FIX ||
463 rViewData.GetVSplitMode() == SC_SPLIT_FIX ));
464 }
465 else
466 {
467 rSet.Put(SfxBoolItem(nWhich,
468 rViewData.GetLOKSheetFreezeIndex(true) > 0 ||
469 rViewData.GetLOKSheetFreezeIndex(false) > 0 ));
470 }
471 break;
472
473 case SID_WINDOW_FIX_COL:
474 case SID_WINDOW_FIX_ROW:
475 {
476 Point aPos;
477 bool bIsCol = (nWhich == SID_WINDOW_FIX_COL);
478 aPos.setX(rViewData.GetLOKSheetFreezeIndex(bIsCol));
479 aPos.setY(rViewData.GetTabNo());
480 rSet.Put(SfxPointItem(nWhich, aPos));
481 }
482 break;
483
484 case FID_CHG_SHOW:
485 {
486 if ( rDoc.GetChangeTrack() == nullptr || ( pDocShell && pDocShell->IsDocShared() ) )
487 rSet.DisableItem( nWhich );
488 }
489 break;
490 case FID_CHG_ACCEPT:
491 {
492 if(
493 ( !rDoc.GetChangeTrack() && !rThisFrame.HasChildWindow(FID_CHG_ACCEPT) )
494 ||
495 ( pDocShell && pDocShell->IsDocShared() )
496 )
497 {
498 rSet.DisableItem( nWhich);
499 }
500 else
501 {
502 rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
503 rThisFrame.HasChildWindow(FID_CHG_ACCEPT)));
504 }
505 }
506 break;
507
508 case SID_FORMATPAGE:
509 // in protected tables
510 if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
511 rSet.DisableItem( nWhich );
512 break;
513
514 case SID_PRINTPREVIEW:
515 // Toggle slot needs a State
516 rSet.Put( SfxBoolItem( nWhich, false ) );
517 break;
518
519 case SID_READONLY_MODE:
521 break;
522
523 case FID_TAB_DESELECTALL:
524 if ( nTabSelCount == 1 )
525 rSet.DisableItem( nWhich ); // enabled only if several sheets are selected
526 break;
527
528 case FID_TOGGLEHIDDENCOLROW:
529 const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
531 break;
532
533 } // switch ( nWitch )
534 nWhich = aIter.NextWhich();
535 } // while ( nWitch )
536}
537
538void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OUString &rName)
539{
541
542 std::shared_ptr<SvxBoxItem> aLineOuter(std::make_shared<SvxBoxItem>(ATTR_BORDER));
543 std::shared_ptr<SvxBoxInfoItem> aLineInner(std::make_shared<SvxBoxInfoItem>(ATTR_BORDER_INNER));
544
545 const ScPatternAttr* pOldAttrs = GetSelectionPattern();
546
547 auto pOldSet = std::make_shared<SfxItemSet>(pOldAttrs->GetItemSet());
548
549 pOldSet->MergeRange(XATTR_FILLSTYLE, XATTR_FILLCOLOR);
550
551 pOldSet->MergeRange(SID_ATTR_BORDER_STYLES, SID_ATTR_BORDER_DEFAULT_WIDTH);
552
553 // We only allow these border line types.
554 std::vector<sal_Int32> aBorderStyles{
555 table::BorderLineStyle::SOLID,
556 table::BorderLineStyle::DOTTED,
557 table::BorderLineStyle::DASHED,
558 table::BorderLineStyle::FINE_DASHED,
559 table::BorderLineStyle::DASH_DOT,
560 table::BorderLineStyle::DASH_DOT_DOT,
561 table::BorderLineStyle::DOUBLE_THIN };
562
563 pOldSet->Put(SfxIntegerListItem(SID_ATTR_BORDER_STYLES, std::move(aBorderStyles)));
564
565 // Set the default border width to 0.75 points.
566 SfxInt64Item aBorderWidthItem(SID_ATTR_BORDER_DEFAULT_WIDTH, 75);
567 pOldSet->Put(aBorderWidthItem);
568
569 // Get border items and put them in the set:
570 GetSelectionFrame( aLineOuter, aLineInner );
571
572 //Fix border incorrect for RTL fdo#62399
573 if( rDoc.IsLayoutRTL( GetViewData().GetTabNo() ) )
574 {
575 std::unique_ptr<SvxBoxItem> aNewFrame(aLineOuter->Clone());
576 std::unique_ptr<SvxBoxInfoItem> aTempInfo(aLineInner->Clone());
577
578 if ( aLineInner->IsValid(SvxBoxInfoItemValidFlags::LEFT) )
579 aNewFrame->SetLine( aLineOuter->GetLeft(), SvxBoxItemLine::RIGHT );
580 if ( aLineInner->IsValid(SvxBoxInfoItemValidFlags::RIGHT) )
581 aNewFrame->SetLine( aLineOuter->GetRight(), SvxBoxItemLine::LEFT );
582
583 aLineInner->SetValid( SvxBoxInfoItemValidFlags::LEFT, aTempInfo->IsValid(SvxBoxInfoItemValidFlags::RIGHT));
584 aLineInner->SetValid( SvxBoxInfoItemValidFlags::RIGHT, aTempInfo->IsValid(SvxBoxInfoItemValidFlags::LEFT));
585
586 pOldSet->Put( std::move(aNewFrame) );
587 }
588 else
589 {
590 pOldSet->Put( *aLineOuter );
591 }
592
593 pOldSet->Put( *aLineInner );
594
595 // Generate NumberFormat Value from Value and Language and box it.
596 pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
597 pOldAttrs->GetNumberFormat( rDoc.GetFormatTable() ) ) );
598
599 std::unique_ptr<SvxNumberInfoItem> pNumberInfoItem = MakeNumberInfoItem(rDoc, GetViewData());
600 pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
601 pOldSet->Put( std::move(pNumberInfoItem) );
602
603 bInFormatDialog = true;
605
606 VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateScAttrDlg(GetFrameWeld(), pOldSet.get()));
607
608 if (!rName.isEmpty())
609 pDlg->SetCurPageId(rName);
610
611 auto pRequest = std::make_shared<SfxRequest>(rReq);
612 rReq.Ignore(); // the 'old' request is not relevant any more
613
614 pDlg->StartExecuteAsync([pDlg, pOldSet, pRequest, this](sal_Int32 nResult){
615 bInFormatDialog = false;
616
617 if ( nResult == RET_OK )
618 {
619 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
620 if(const SvxNumberInfoItem* pItem = pOutSet->GetItemIfSet(SID_ATTR_NUMBERFORMAT_INFO))
621 {
622 UpdateNumberFormatter(*pItem);
623 }
624
625 ApplyAttributes(pOutSet, pOldSet.get());
626
627 pRequest->Done(*pOutSet);
628 }
629
630 pDlg->disposeOnce();
631 });
632}
633
635{
636 ScModule* pScMod = SC_MOD();
637 if ( pScMod )
638 {
639 if( pScMod->IsRefDialogOpen() )
640 return pScMod->IsFormulaMode();
641 if( pScMod->IsFormulaMode() )
642 {
643 ScInputHandler* pHdl = pScMod->GetInputHdl();
644 if ( pHdl )
645 {
646 const ScViewData& rViewData = GetViewData();
647 ScDocument& rDoc = rViewData.GetDocument();
648 const ScAddress aPos( rViewData.GetCurPos() );
649 const sal_uInt32 nIndex = rDoc.GetAttr(aPos, ATTR_VALUE_FORMAT )->GetValue();
651 if (nType == SvNumFormatType::TEXT)
652 {
653 return false;
654 }
655 OUString aString = pHdl->GetEditString();
656 if ( !pHdl->GetSelIsRef() && aString.getLength() > 1 &&
657 ( aString[0] == '+' || aString[0] == '-' ) )
658 {
659 ScCompiler aComp( rDoc, aPos, rDoc.GetGrammar() );
660 aComp.SetCloseBrackets( false );
661 std::unique_ptr<ScTokenArray> pArr(aComp.CompileString(aString));
662 if ( pArr && pArr->MayReferenceFollow() )
663 {
664 return true;
665 }
666 }
667 else
668 {
669 return true;
670 }
671 }
672 }
673 }
674
675 return false;
676}
677
679{
680 if ( !IsRefInputMode() )
681 {
682 ScModule* pScMod = SC_MOD();
683 if ( pScMod )
684 {
685 pScMod->InputEnterHandler();
686 }
687 }
688}
689
690void ScTabViewShell::UpdateInputHandler( bool bForce /* = sal_False */, bool bStopEditing /* = sal_True */ )
691{
692 ScInputHandler* pHdl = mpInputHandler ? mpInputHandler.get() : SC_MOD()->GetInputHdl();
693
694 if ( pHdl )
695 {
696 OUString aString;
697 const EditTextObject* pObject = nullptr;
698 ScViewData& rViewData = GetViewData();
699 ScDocument& rDoc = rViewData.GetDocument();
700 SCCOL nPosX = rViewData.GetCurX();
701 SCROW nPosY = rViewData.GetCurY();
702 SCTAB nTab = rViewData.GetTabNo();
703 SCTAB nStartTab = 0;
704 SCTAB nEndTab = 0;
705 SCCOL nStartCol = 0;
706 SCROW nStartRow = 0;
707 SCCOL nEndCol = 0;
708 SCROW nEndRow = 0;
709 ScAddress aPos = rViewData.GetCurPos();
710
711 rViewData.GetSimpleArea( nStartCol, nStartRow, nStartTab,
712 nEndCol, nEndRow, nEndTab );
713
714 PutInOrder( nStartCol, nEndCol );
715 PutInOrder( nStartRow, nEndRow );
716 PutInOrder( nStartTab, nEndTab );
717
718 bool bHideFormula = false;
719 bool bHideAll = false;
720
721 if (rDoc.IsTabProtected(nTab))
722 {
723 const ScProtectionAttr* pProt = rDoc.GetAttr( nPosX,nPosY,nTab,
725 bHideFormula = pProt->GetHideFormula();
726 bHideAll = pProt->GetHideCell();
727 }
728
729 if (!bHideAll)
730 {
731 ScRefCellValue rCell(rDoc, aPos);
732 if (rCell.getType() == CELLTYPE_FORMULA)
733 {
734 if (!bHideFormula)
735 aString = rCell.getFormula()->GetFormula();
736 }
737 else if (rCell.getType() == CELLTYPE_EDIT)
738 {
739 pObject = rCell.getEditText();
740 }
741 else
742 {
743 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
744 sal_uInt32 nNumFmt = rDoc.GetNumberFormat( aPos );
745
746 aString = ScCellFormat::GetInputString( rCell, nNumFmt, *pFormatter, rDoc );
747 if (rCell.getType() == CELLTYPE_STRING)
748 {
749 // Put a ' in front if necessary, so that the string is not
750 // unintentionally interpreted as a number, and to show the
751 // user that it is a string (#35060#).
752 // If cell is not formatted as Text, a leading apostrophe
753 // needs another prepended, also '=' or '+' or '-'
754 // otherwise starting a formula.
755 // NOTE: this corresponds with
756 // sc/source/core/data/column3.cxx ScColumn::ParseString()
757 // removing one apostrophe.
758 // For number format Text IsNumberFormat() would never
759 // result in numeric anyway.
760 if (!pFormatter->IsTextFormat(nNumFmt) && (aString.startsWith("'")
761 || aString.startsWith("=") || aString.startsWith("+") || aString.startsWith("-")
762 || pFormatter->IsNumberFormat(aString, nNumFmt, o3tl::temporary(double()))))
763 aString = "'" + aString;
764 }
765 }
766 }
767
768 ScInputHdlState aState( ScAddress( nPosX, nPosY, nTab ),
769 ScAddress( nStartCol, nStartRow, nTab ),
770 ScAddress( nEndCol, nEndRow, nTab ),
771 aString,
772 pObject );
773
774 // if using the view's local input handler, this view can always be set
775 // as current view inside NotifyChange.
776 ScTabViewShell* pSourceSh = mpInputHandler ? this : nullptr;
777
778 pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
779 }
780
781 SfxBindings& rBindings = GetViewFrame().GetBindings();
782 rBindings.Invalidate( SID_STATUS_SUM ); // always together with the input row
783 rBindings.Invalidate( SID_ATTR_SIZE );
784 rBindings.Invalidate( SID_TABLE_CELL );
785}
786
788{
789 if( ScInputHandler* pHdl = mpInputHandler ? mpInputHandler.get() : SC_MOD()->GetInputHdl() )
790 pHdl->UpdateCellAdjust( eJust );
791}
792
794{
795 // only SID_SAVEDOC / SID_SAVEASDOC
796 bool bCommitChanges = true;
797 const SfxItemSet* pReqArgs = rReq.GetArgs();
798 const SfxPoolItem* pItem;
799
800 if (pReqArgs && pReqArgs->HasItem(FN_PARAM_1, &pItem))
801 bCommitChanges = !static_cast<const SfxBoolItem*>(pItem)->GetValue();
802
803 // Finish entering unless 'DontTerminateEdit' is specified, even if a formula is being processed
804 if (bCommitChanges)
805 {
806 bool bLOKActive = comphelper::LibreOfficeKit::isActive();
807
808 // Disable error dialog box when about to save in lok mode as
809 // this ultimately invokes SvpSalInstance::DoYield() when we want
810 // to save immediately without committing any erroneous input in possibly
811 // a cell with validation rules. After save is complete the user
812 // can continue editing.
813 SC_MOD()->InputEnterHandler(ScEnterMode::NORMAL, bLOKActive /* bBeforeSavingInLOK */);
814
815 if (bLOKActive)
816 {
817 // Normally this isn't needed, but in Calc when editing a cell formula
818 // and manually saving (without changing cells or hitting enter), while
819 // InputEnterHandler will mark the doc as modified (when it is), because
820 // we will save the doc immediately afterwards, the modified state event
821 // is clobbered. To avoid that, we need to update SID_DOC_MODIFIED so that
822 // a possible state of "true" after "InputEnterHandler" will be sent
823 // as a notification. It is important that the notification goes through
824 // normal process (cache) rather than directly notifying the views.
825 // Otherwise, because there is a previous state of "false" in cache, the
826 // "false" state after saving will be ignored.
827 // This will work only if .uno:ModifiedStatus message will be removed from
828 // the mechanism that keeps in the message queue only last message of
829 // a particular status even if the values are different.
830 GetViewData().GetDocShell()->GetViewBindings()->Update(SID_DOC_MODIFIED);
831 }
832 }
833
834 if ( GetViewData().GetDocShell()->IsDocShared() )
835 {
837 }
838
839 // otherwise as normal
841}
842
844{
845 SfxShell* pDocSh = GetViewData().GetDocShell();
846
847 SfxWhichIter aIter(rSet);
848 sal_uInt16 nWhich = aIter.FirstWhich();
849 while( nWhich )
850 {
851 if ( nWhich != SID_SAVEDOC || !GetViewData().GetDocShell()->IsDocShared() )
852 {
853 // get state from DocShell
854 pDocSh->GetSlotState( nWhich, nullptr, &rSet );
855 }
856 nWhich = aIter.NextWhich();
857 }
858}
859
861{
862 ScViewOptions aViewOptions = GetViewData().GetOptions();
863 ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
864
865 SfxBindings& rBindings = GetViewFrame().GetBindings();
866 const SfxItemSet* pArgs = rReq.GetArgs();
867 const SfxPoolItem* pItem;
868 sal_uInt16 nSlotId = rReq.GetSlot();
869 switch (nSlotId)
870 {
871 case SID_GRID_VISIBLE:
872 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SfxItemState::SET )
873 {
874 aGridOptions.SetGridVisible( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
875 aViewOptions.SetGridOptions(aGridOptions);
876 rBindings.Invalidate(SID_GRID_VISIBLE);
877 }
878 break;
879
880 case SID_GRID_USE:
881 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SfxItemState::SET )
882 {
883 aGridOptions.SetUseGridSnap( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
884 aViewOptions.SetGridOptions(aGridOptions);
885 rBindings.Invalidate(SID_GRID_USE);
886 }
887 break;
888
889 case SID_HELPLINES_MOVE:
890 if ( pArgs && pArgs->GetItemState(nSlotId,true,&pItem) == SfxItemState::SET )
891 {
892 aViewOptions.SetOption( VOPT_HELPLINES, static_cast<const SfxBoolItem*>(pItem)->GetValue() );
893 rBindings.Invalidate(SID_HELPLINES_MOVE);
894 }
895 break;
896 }
897
898 GetViewData().SetOptions(aViewOptions);
899}
900
902{
903 SfxBoolItem aBool;
904
905 const ScViewOptions& rViewOptions = GetViewData().GetOptions();
906 const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
907
908 aBool.SetValue(rGridOptions.GetGridVisible());
909 aBool.SetWhich( SID_GRID_VISIBLE );
910 rSet.Put( aBool );
911
912 aBool.SetValue(rGridOptions.GetUseGridSnap());
913 aBool.SetWhich( SID_GRID_USE );
914 rSet.Put( aBool );
915
916 aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
917 aBool.SetWhich( SID_HELPLINES_MOVE );
918 rSet.Put( aBool );
919}
920
922{
923 const SfxItemSet* pArgs = rReq.GetArgs();
924 const sal_uInt16 nSlotId = rReq.GetSlot();
925 if ( !pArgs && nSlotId != SID_STYLE_NEW_BY_EXAMPLE && nSlotId != SID_STYLE_UPDATE_BY_EXAMPLE )
926 {
927 // in case of vertical toolbar
928 GetDispatcher()->Execute( SID_STYLE_DESIGNER, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
929 return;
930 }
931
932 SfxBindings& rBindings = GetViewData().GetBindings();
933 const SCTAB nCurTab = GetViewData().GetTabNo();
934 ScDocShell* pDocSh = GetViewData().GetDocShell();
935 ScDocument& rDoc = pDocSh->GetDocument();
937 ScModule* pScMod = SC_MOD();
938 SdrObject* pEditObject = GetDrawView()->GetTextEditObject();
940 ESelection aSelection = pOLV ? pOLV->GetSelection() : ESelection();
941 OUString aRefName;
942 bool bUndo = rDoc.IsUndoEnabled();
943
944 SfxStyleSheetBasePool* pStylePool = rDoc.GetStyleSheetPool();
945 SfxStyleSheetBase* pStyleSheet = nullptr;
946
947 bool bStyleToMarked = false;
948 bool bListAction = false;
949 bool bAddUndo = false; // add ScUndoModifyStyle (style modified)
950 ScStyleSaveData aOldData; // for undo/redo
951 ScStyleSaveData aNewData;
952
953 SfxStyleFamily eFamily = SfxStyleFamily::Para;
954 const SfxUInt16Item* pFamItem;
955 const SfxStringItem* pFamilyNameItem;
956 if ( pArgs && (pFamItem = pArgs->GetItemIfSet( SID_STYLE_FAMILY )) )
957 eFamily = static_cast<SfxStyleFamily>(pFamItem->GetValue());
958 else if ( pArgs && (pFamilyNameItem = pArgs->GetItemIfSet( SID_STYLE_FAMILYNAME )) )
959 {
960 OUString sFamily = pFamilyNameItem->GetValue();
961 if (sFamily == "CellStyles")
962 eFamily = SfxStyleFamily::Para;
963 else if (sFamily == "PageStyles")
964 eFamily = SfxStyleFamily::Page;
965 else if (sFamily == "GraphicStyles")
966 eFamily = SfxStyleFamily::Frame;
967 }
968
969 OUString aStyleName;
970 sal_uInt16 nRetMask = 0xffff;
971
972 switch ( nSlotId )
973 {
974 case SID_STYLE_NEW:
975 {
976 const SfxPoolItem* pNameItem;
977 if (pArgs && SfxItemState::SET == pArgs->GetItemState( nSlotId, true, &pNameItem ))
978 aStyleName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
979
980 const SfxStringItem* pRefItem=nullptr;
981 if (pArgs && (pRefItem = pArgs->GetItemIfSet( SID_STYLE_REFERENCE )))
982 {
983 aRefName = pRefItem->GetValue();
984 }
985
986 pStyleSheet = &(pStylePool->Make( aStyleName, eFamily,
987 SfxStyleSearchBits::UserDefined ) );
988
989 if (pStyleSheet->HasParentSupport())
990 pStyleSheet->SetParent(aRefName);
991 }
992 break;
993
994 case SID_STYLE_APPLY:
995 {
996 const SfxStringItem* pNameItem = rReq.GetArg<SfxStringItem>(SID_APPLY_STYLE);
997 const SfxStringItem* pFamilyItem = rReq.GetArg<SfxStringItem>(SID_STYLE_FAMILYNAME);
998 if ( pFamilyItem && pNameItem )
999 {
1000 try
1001 {
1002 css::uno::Reference< css::container::XNameAccess > xStyles;
1003 css::uno::Reference< css::container::XNameAccess > xCont = pDocSh->GetModel()->getStyleFamilies();
1004 xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
1005 css::uno::Reference< css::beans::XPropertySet > xInfo;
1006 xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
1007 OUString aUIName;
1008 xInfo->getPropertyValue("DisplayName") >>= aUIName;
1009 if ( !aUIName.isEmpty() )
1010 rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
1011 }
1012 catch( css::uno::Exception& )
1013 {
1014 }
1015 }
1016 [[fallthrough]];
1017 }
1018 case SID_STYLE_EDIT:
1019 case SID_STYLE_DELETE:
1020 case SID_STYLE_HIDE:
1021 case SID_STYLE_SHOW:
1022 case SID_STYLE_NEW_BY_EXAMPLE:
1023 {
1024 const SfxPoolItem* pNameItem;
1025 if (pArgs && SfxItemState::SET == pArgs->GetItemState( nSlotId, true, &pNameItem ))
1026 aStyleName = static_cast<const SfxStringItem*>(pNameItem)->GetValue();
1027 else if ( nSlotId == SID_STYLE_NEW_BY_EXAMPLE )
1028 {
1029 weld::Window* pDialogParent = rReq.GetFrameWeld();
1030 if (!pDialogParent)
1031 pDialogParent = GetFrameWeld();
1032 SfxNewStyleDlg aDlg(pDialogParent, *pStylePool, eFamily);
1033 if (aDlg.run() != RET_OK)
1034 return;
1035 aStyleName = aDlg.GetName();
1036 }
1037
1038 pStyleSheet = pStylePool->Find( aStyleName, eFamily );
1039
1040 aOldData.InitFromStyle( pStyleSheet );
1041 }
1042 break;
1043
1044 case SID_STYLE_WATERCAN:
1045 {
1046 bool bWaterCan = pScMod->GetIsWaterCan();
1047
1048 if( !bWaterCan )
1049 {
1050 const SfxPoolItem* pItem;
1051
1052 if ( SfxItemState::SET ==
1053 pArgs->GetItemState( nSlotId, true, &pItem ) )
1054 {
1055 const SfxStringItem* pStrItem = dynamic_cast< const SfxStringItem *>( pItem );
1056 if ( pStrItem )
1057 {
1058 aStyleName = pStrItem->GetValue();
1059 pStyleSheet = pStylePool->Find( aStyleName, eFamily );
1060
1061 if ( pStyleSheet )
1062 {
1063 static_cast<ScStyleSheetPool*>(pStylePool)->
1064 SetActualStyleSheet( pStyleSheet );
1065 rReq.Done();
1066 }
1067 }
1068 }
1069 }
1070
1071 if ( !bWaterCan && pStyleSheet )
1072 {
1073 pScMod->SetWaterCan( true );
1074 SetActivePointer( PointerStyle::Fill );
1075 rReq.Done();
1076 }
1077 else
1078 {
1079 pScMod->SetWaterCan( false );
1080 SetActivePointer( PointerStyle::Arrow );
1081 rReq.Done();
1082 }
1083 }
1084 break;
1085
1086 default:
1087 break;
1088 }
1089
1090 // set new style for paintbrush format mode
1091 if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet )
1092 static_cast<ScStyleSheetPool*>(pStylePool)->SetActualStyleSheet( pStyleSheet );
1093
1094 switch ( eFamily )
1095 {
1096 case SfxStyleFamily::Para:
1097 {
1098 switch ( nSlotId )
1099 {
1100 case SID_STYLE_DELETE:
1101 {
1102 if ( pStyleSheet )
1103 {
1104 RemoveStyleSheetInUse( pStyleSheet );
1105 pStylePool->Remove( pStyleSheet );
1107 nRetMask = sal_uInt16(true);
1108 bAddUndo = true;
1109 rReq.Done();
1110 }
1111 else
1112 nRetMask = sal_uInt16(false);
1113 }
1114 break;
1115
1116 case SID_STYLE_HIDE:
1117 case SID_STYLE_SHOW:
1118 {
1119 if ( pStyleSheet )
1120 {
1121 pStyleSheet->SetHidden( nSlotId == SID_STYLE_HIDE );
1123 rReq.Done();
1124 }
1125 else
1126 nRetMask = sal_uInt16(false);
1127 }
1128 break;
1129
1130 case SID_STYLE_APPLY:
1131 {
1132 if ( pStyleSheet && !pScMod->GetIsWaterCan() )
1133 {
1134 // apply style sheet to document
1135 SetStyleSheetToMarked( static_cast<SfxStyleSheet*>(pStyleSheet) );
1137 rReq.Done();
1138 }
1139 }
1140 break;
1141
1142 case SID_STYLE_NEW_BY_EXAMPLE:
1143 case SID_STYLE_UPDATE_BY_EXAMPLE:
1144 {
1145 // create/replace style sheet by attributes
1146 // at cursor position:
1147
1148 const ScPatternAttr* pAttrItem = nullptr;
1149
1150 // The query if marked, was always wrong here,
1151 // so now no more, and just from the cursor.
1152 // If attributes are to be removed from the selection, still need to be
1153 // cautious not to adopt items from templates
1154 // (GetSelectionPattern also collects items from originals) (# 44748 #)
1155 SCCOL nCol = GetViewData().GetCurX();
1156 SCROW nRow = GetViewData().GetCurY();
1157 pAttrItem = rDoc.GetPattern( nCol, nRow, nCurTab );
1158
1159 SfxItemSet aAttrSet = pAttrItem->GetItemSet();
1160 aAttrSet.ClearItem( ATTR_MERGE );
1161 aAttrSet.ClearItem( ATTR_MERGE_FLAG );
1162
1163 // Do not adopt conditional formatting and validity,
1164 // because they can not be edited in the template
1165 aAttrSet.ClearItem( ATTR_VALIDDATA );
1166 aAttrSet.ClearItem( ATTR_CONDITIONAL );
1167
1168 if ( SID_STYLE_NEW_BY_EXAMPLE == nSlotId )
1169 {
1170 if ( bUndo )
1171 {
1172 OUString aUndo = ScResId( STR_UNDO_EDITCELLSTYLE );
1173 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, GetViewShellId() );
1174 bListAction = true;
1175 }
1176
1177 bool bConvertBack = false;
1178 SfxStyleSheet* pSheetInUse = const_cast<SfxStyleSheet*>(GetStyleSheetFromMarked());
1179
1180 // when a new style is present and is used in the selection,
1181 // then the parent can not be adopted:
1182 if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse )
1183 pSheetInUse = nullptr;
1184
1185 // if already present, first remove ...
1186 if ( pStyleSheet )
1187 {
1188 // style pointer to names before erase,
1189 // otherwise cells will get invalid pointer
1191 rDoc.StylesToNames();
1192 bConvertBack = true;
1193 pStylePool->Remove(pStyleSheet);
1194 }
1195
1196 // ...and create new
1197 pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
1198 SfxStyleSearchBits::UserDefined );
1199
1200 // when a style is present, then this will become
1201 // the parent of the new style:
1202 if ( pSheetInUse && pStyleSheet->HasParentSupport() )
1203 pStyleSheet->SetParent( pSheetInUse->GetName() );
1204
1205 if ( bConvertBack )
1206 // Name to style pointer
1207 rDoc.UpdStlShtPtrsFrmNms();
1208 else
1209 rDoc.GetPool()->CellStyleCreated( aStyleName, rDoc );
1210
1211 // Adopt attribute and use style
1212 pStyleSheet->GetItemSet().Put( aAttrSet );
1213 UpdateStyleSheetInUse( pStyleSheet );
1214
1215 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
1216 // (pStyleSheet pointer is used!)
1217 bStyleToMarked = true;
1218 }
1219 else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE )
1220 {
1221 pStyleSheet = const_cast<SfxStyleSheet*>(GetStyleSheetFromMarked());
1222
1223 if ( pStyleSheet )
1224 {
1225 aOldData.InitFromStyle( pStyleSheet );
1226
1227 if ( bUndo )
1228 {
1229 OUString aUndo = ScResId( STR_UNDO_EDITCELLSTYLE );
1230 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, GetViewShellId() );
1231 bListAction = true;
1232 }
1233
1234 pStyleSheet->GetItemSet().Put( aAttrSet );
1235 UpdateStyleSheetInUse( pStyleSheet );
1236
1237 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
1238 // (pStyleSheet pointer is used!)
1239 bStyleToMarked = true;
1240 }
1241 }
1242
1243 aNewData.InitFromStyle( pStyleSheet );
1244 bAddUndo = true;
1245 rReq.Done();
1246 }
1247 break;
1248
1249 default:
1250 break;
1251 }
1252 } // case SfxStyleFamily::Para:
1253 break;
1254
1255 case SfxStyleFamily::Page:
1256 {
1257 switch ( nSlotId )
1258 {
1259 case SID_STYLE_DELETE:
1260 {
1261 nRetMask = sal_uInt16( nullptr != pStyleSheet );
1262 if ( pStyleSheet )
1263 {
1264 if ( rDoc.RemovePageStyleInUse( pStyleSheet->GetName() ) )
1265 {
1266 ScPrintFunc( pDocSh, GetPrinter(true), nCurTab ).UpdatePages();
1267 rBindings.Invalidate( SID_STATUS_PAGESTYLE );
1268 rBindings.Invalidate( FID_RESET_PRINTZOOM );
1269 }
1270 pStylePool->Remove( pStyleSheet );
1271 rBindings.Invalidate( SID_STYLE_FAMILY4 );
1272 pDocSh->SetDocumentModified();
1273 bAddUndo = true;
1274 rReq.Done();
1275 }
1276 }
1277 break;
1278
1279 case SID_STYLE_HIDE:
1280 case SID_STYLE_SHOW:
1281 {
1282 nRetMask = sal_uInt16( nullptr != pStyleSheet );
1283 if ( pStyleSheet )
1284 {
1285 pStyleSheet->SetHidden( nSlotId == SID_STYLE_HIDE );
1286 rBindings.Invalidate( SID_STYLE_FAMILY4 );
1287 pDocSh->SetDocumentModified();
1288 rReq.Done();
1289 }
1290 }
1291 break;
1292
1293 case SID_STYLE_APPLY:
1294 {
1295 nRetMask = sal_uInt16( nullptr != pStyleSheet );
1296 if ( pStyleSheet && !pScMod->GetIsWaterCan() )
1297 {
1298 std::unique_ptr<ScUndoApplyPageStyle> pUndoAction;
1299 SCTAB nTabCount = rDoc.GetTableCount();
1300 for (const auto& rTab : rMark)
1301 {
1302 if (rTab >= nTabCount)
1303 break;
1304 OUString aOldName = rDoc.GetPageStyle( rTab );
1305 if ( aOldName != aStyleName )
1306 {
1307 rDoc.SetPageStyle( rTab, aStyleName );
1308 ScPrintFunc( pDocSh, GetPrinter(true), rTab ).UpdatePages();
1309 if( !pUndoAction )
1310 pUndoAction.reset(new ScUndoApplyPageStyle( pDocSh, aStyleName ));
1311 pUndoAction->AddSheetAction( rTab, aOldName );
1312 }
1313 }
1314 if( pUndoAction )
1315 {
1316 pDocSh->GetUndoManager()->AddUndoAction( std::move(pUndoAction) );
1317 pDocSh->SetDocumentModified();
1318 rBindings.Invalidate( SID_STYLE_FAMILY4 );
1319 rBindings.Invalidate( SID_STATUS_PAGESTYLE );
1320 rBindings.Invalidate( FID_RESET_PRINTZOOM );
1321 }
1322 rReq.Done();
1323 }
1324 }
1325 break;
1326
1327 case SID_STYLE_NEW_BY_EXAMPLE:
1328 {
1329 const OUString& rStrCurStyle = rDoc.GetPageStyle( nCurTab );
1330
1331 if ( rStrCurStyle != aStyleName )
1332 {
1333 SfxStyleSheetBase* pCurStyle = pStylePool->Find( rStrCurStyle, eFamily );
1334 SfxItemSet aAttrSet = pCurStyle->GetItemSet();
1335 SCTAB nInTab;
1336 bool bUsed = rDoc.IsPageStyleInUse( aStyleName, &nInTab );
1337
1338 // if already present, first remove...
1339 if ( pStyleSheet )
1340 pStylePool->Remove( pStyleSheet );
1341
1342 // ...and create new
1343 pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
1344 SfxStyleSearchBits::UserDefined );
1345
1346 // Adopt attribute
1347 pStyleSheet->GetItemSet().Put( aAttrSet );
1348 pDocSh->SetDocumentModified();
1349
1350 // If being used -> Update
1351 if ( bUsed )
1352 ScPrintFunc( pDocSh, GetPrinter(true), nInTab ).UpdatePages();
1353
1354 aNewData.InitFromStyle( pStyleSheet );
1355 bAddUndo = true;
1356 rReq.Done();
1357 nRetMask = sal_uInt16(true);
1358 }
1359 }
1360 break;
1361
1362 default:
1363 break;
1364 } // switch ( nSlotId )
1365 } // case SfxStyleFamily::Page:
1366 break;
1367
1368 case SfxStyleFamily::Frame:
1369 {
1370 switch ( nSlotId )
1371 {
1372 case SID_STYLE_DELETE:
1373 {
1374 if ( pStyleSheet )
1375 {
1376 pStylePool->Remove( pStyleSheet );
1378 pDocSh->SetDocumentModified();
1379 nRetMask = sal_uInt16(true);
1380 bAddUndo = true;
1381 rReq.Done();
1382 }
1383 else
1384 nRetMask = sal_uInt16(false);
1385 }
1386 break;
1387
1388 case SID_STYLE_HIDE:
1389 case SID_STYLE_SHOW:
1390 {
1391 if ( pStyleSheet )
1392 {
1393 pStyleSheet->SetHidden( nSlotId == SID_STYLE_HIDE );
1395 rReq.Done();
1396 }
1397 else
1398 nRetMask = sal_uInt16(false);
1399 }
1400 break;
1401
1402 case SID_STYLE_APPLY:
1403 {
1404 if ( pStyleSheet && !pScMod->GetIsWaterCan() )
1405 {
1407 GetScDrawView()->SetStyleSheet(static_cast<SfxStyleSheet*>(pStyleSheet), false);
1408
1411 rReq.Done();
1412 }
1413 }
1414 break;
1415
1416 case SID_STYLE_NEW_BY_EXAMPLE:
1417 case SID_STYLE_UPDATE_BY_EXAMPLE:
1418 {
1419 if (nSlotId == SID_STYLE_NEW_BY_EXAMPLE)
1420 {
1421 pStyleSheet = &pStylePool->Make( aStyleName, eFamily, SfxStyleSearchBits::UserDefined );
1422
1423 // when a style is present, then this will become
1424 // the parent of the new style:
1425 if (SfxStyleSheet* pOldStyle = GetDrawView()->GetStyleSheet())
1426 pStyleSheet->SetParent(pOldStyle->GetName());
1427 }
1428 else
1429 {
1430 pStyleSheet = GetDrawView()->GetStyleSheet();
1431 aOldData.InitFromStyle( pStyleSheet );
1432 }
1433
1434 if ( bUndo )
1435 {
1436 OUString aUndo = ScResId( STR_UNDO_EDITGRAPHICSTYLE );
1437 pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, GetViewShellId() );
1438 bListAction = true;
1439 }
1440
1441 SfxItemSet aCoreSet(GetDrawView()->GetModel().GetItemPool());
1442 GetDrawView()->GetAttributes(aCoreSet, true);
1443
1444 SfxItemSet* pStyleSet = &pStyleSheet->GetItemSet();
1445 pStyleSet->Put(aCoreSet);
1446 static_cast<SfxStyleSheet*>(pStyleSheet)->Broadcast(SfxHint(SfxHintId::DataChanged));
1447
1448 aNewData.InitFromStyle( pStyleSheet );
1449 bAddUndo = true;
1450
1451 // call SetStyleSheet after adding the ScUndoModifyStyle
1452 // (pStyleSheet pointer is used!)
1453 bStyleToMarked = true;
1454 rReq.Done();
1455 }
1456 break;
1457 default:
1458 break;
1459 }
1460 }
1461 break;
1462 default:
1463 break;
1464 } // switch ( eFamily )
1465
1466 // create new or process through Dialog:
1467 if ( nSlotId == SID_STYLE_NEW || nSlotId == SID_STYLE_EDIT )
1468 {
1469 if ( pStyleSheet )
1470 {
1471 SfxStyleFamily eFam = pStyleSheet->GetFamily();
1473 bool bPage = false;
1474
1475 // Store old Items from the style
1476 SfxItemSet aOldSet = pStyleSheet->GetItemSet();
1477 OUString aOldName = pStyleSheet->GetName();
1478
1479 switch ( eFam )
1480 {
1481 case SfxStyleFamily::Page:
1482 bPage = true;
1483 break;
1484
1485 case SfxStyleFamily::Para:
1486 {
1487 SfxItemSet& rSet = pStyleSheet->GetItemSet();
1488
1489 if ( const SfxUInt32Item* pItem = rSet.GetItemIfSet( ATTR_VALUE_FORMAT,
1490 false ) )
1491 {
1492 // Produce and format NumberFormat Value from Value and Language
1493 sal_uLong nFormat = pItem->GetValue();
1494 LanguageType eLang =
1495 rSet.Get(ATTR_LANGUAGE_FORMAT ).GetLanguage();
1496 sal_uLong nLangFormat = rDoc.GetFormatTable()->
1497 GetFormatForLanguageIfBuiltIn( nFormat, eLang );
1498 if ( nLangFormat != nFormat )
1499 {
1500 SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat );
1501 rSet.Put( aNewItem );
1502 aOldSet.Put( aNewItem );
1503 // Also in aOldSet for comparison after the dialog,
1504 // Otherwise might miss a language change
1505 }
1506 }
1507
1508 std::unique_ptr<SvxNumberInfoItem> pNumberInfoItem(
1510
1511 pDocSh->PutItem( *pNumberInfoItem );
1512 bPage = false;
1513
1514 // Definitely a SvxBoxInfoItem with Table = sal_False in set:
1515 // (If there is no item, the dialogue will also delete the
1516 // BORDER_OUTER SvxBoxItem from the Template Set)
1517 if ( rSet.GetItemState( ATTR_BORDER_INNER, false ) != SfxItemState::SET )
1518 {
1519 SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
1520 aBoxInfoItem.SetTable(false); // no inner lines
1521 aBoxInfoItem.SetDist(true);
1522 aBoxInfoItem.SetMinDist(false);
1523 rSet.Put( aBoxInfoItem );
1524 }
1525 }
1526 break;
1527
1528 case SfxStyleFamily::Frame:
1529 default:
1530 break;
1531 }
1532
1533 SetInFormatDialog(true);
1534
1535 SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
1537
1539
1540 weld::Window* pDialogParent = rReq.GetFrameWeld();
1541 if (!pDialogParent)
1542 pDialogParent = GetFrameWeld();
1543
1544 if (eFam == SfxStyleFamily::Frame)
1545 pDlg.disposeAndReset(pFact->CreateScDrawStyleDlg(pDialogParent, *pStyleSheet, GetDrawView()));
1546 else
1547 pDlg.disposeAndReset(pFact->CreateScStyleDlg(pDialogParent, *pStyleSheet, bPage));
1548
1549 short nResult = pDlg->Execute();
1550 SetInFormatDialog(false);
1551
1552 if ( nResult == RET_OK )
1553 {
1554 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
1555
1556 if ( pOutSet )
1557 {
1558 nRetMask = sal_uInt16(pStyleSheet->GetMask());
1559
1560 // Attribute comparisons (earlier in ModifyStyleSheet) now here
1561 // with the old values (the style is already changed)
1562 if ( SfxStyleFamily::Para == eFam )
1563 {
1564 SfxItemSet& rNewSet = pStyleSheet->GetItemSet();
1565 bool bNumFormatChanged;
1567 bNumFormatChanged, rNewSet, aOldSet ) )
1568 rDoc.InvalidateTextWidth( nullptr, nullptr, bNumFormatChanged );
1569
1570 SCTAB nTabCount = rDoc.GetTableCount();
1571 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
1572 rDoc.SetStreamValid(nTab, false);
1573
1574 sal_uLong nOldFormat = aOldSet.Get( ATTR_VALUE_FORMAT ).GetValue();
1575 sal_uLong nNewFormat = rNewSet.Get( ATTR_VALUE_FORMAT ).GetValue();
1576 if ( nNewFormat != nOldFormat )
1577 {
1578 SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
1579 const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat );
1580 const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat );
1581 if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() )
1582 rNewSet.Put( SvxLanguageItem(
1583 pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
1584 }
1585
1586 rDoc.GetPool()->CellStyleCreated( pStyleSheet->GetName(), rDoc );
1587 }
1588 else if ( SfxStyleFamily::Page == eFam )
1589 {
1591
1592 OUString aNewName = pStyleSheet->GetName();
1593 if ( aNewName != aOldName &&
1594 rDoc.RenamePageStyleInUse( aOldName, aNewName ) )
1595 {
1596 rBindings.Invalidate( SID_STATUS_PAGESTYLE );
1597 rBindings.Invalidate( FID_RESET_PRINTZOOM );
1598 }
1599
1600 rDoc.ModifyStyleSheet( *pStyleSheet, *pOutSet );
1601 rBindings.Invalidate( FID_RESET_PRINTZOOM );
1602 }
1603 else
1604 {
1605 SfxItemSet& rAttr = pStyleSheet->GetItemSet();
1607
1608 // check for unique names of named items for xml
1609 auto checkForUniqueItem = [&] (auto nWhichId)
1610 {
1611 if (auto pOldItem = rAttr.GetItemIfSet(nWhichId, false))
1612 {
1613 if (auto pNewItem = pOldItem->checkForUniqueItem(&GetDrawView()->GetModel()))
1614 rAttr.Put(std::move(pNewItem));
1615 }
1616 };
1617
1618 checkForUniqueItem(XATTR_FILLBITMAP);
1619 checkForUniqueItem(XATTR_LINEDASH);
1620 checkForUniqueItem(XATTR_LINESTART);
1621 checkForUniqueItem(XATTR_LINEEND);
1622 checkForUniqueItem(XATTR_FILLGRADIENT);
1623 checkForUniqueItem(XATTR_FILLFLOATTRANSPARENCE);
1624 checkForUniqueItem(XATTR_FILLHATCH);
1625
1626 static_cast<SfxStyleSheet*>(pStyleSheet)->Broadcast(SfxHint(SfxHintId::DataChanged));
1628 }
1629
1630 pDocSh->SetDocumentModified();
1631
1632 if ( SfxStyleFamily::Para == eFam )
1633 {
1635 *( pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO) ));
1636
1637 UpdateStyleSheetInUse( pStyleSheet );
1639 }
1640
1641 aNewData.InitFromStyle( pStyleSheet );
1642 bAddUndo = true;
1643 }
1644 }
1645 else
1646 {
1647 if ( nSlotId == SID_STYLE_NEW )
1648 pStylePool->Remove( pStyleSheet );
1649 else
1650 {
1651 // If in the meantime something was painted with the
1652 // temporary changed item set
1653 pDocSh->PostPaintGridAll();
1654 }
1655 }
1656 }
1657 }
1658
1659 rReq.SetReturnValue( SfxUInt16Item( nSlotId, nRetMask ) );
1660
1661 if ( bAddUndo && bUndo)
1662 pDocSh->GetUndoManager()->AddUndoAction(
1663 std::make_unique<ScUndoModifyStyle>( pDocSh, eFamily, aOldData, aNewData ) );
1664
1665 if ( bStyleToMarked )
1666 {
1667 // call SetStyleSheetToMarked after adding the ScUndoModifyStyle,
1668 // so redo will find the modified style
1669 if (eFamily == SfxStyleFamily::Para)
1670 {
1671 SetStyleSheetToMarked( static_cast<SfxStyleSheet*>(pStyleSheet) );
1672 }
1673 else if (eFamily == SfxStyleFamily::Frame)
1674 {
1676 GetScDrawView()->SetStyleSheet( static_cast<SfxStyleSheet*>(pStyleSheet), false );
1677 }
1679 }
1680
1681 if ( bListAction )
1682 pDocSh->GetUndoManager()->LeaveListAction();
1683
1684 // The above call to ScEndTextEdit left us in an inconsistent state:
1685 // Text editing isn't active, but the text edit shell still is. And we
1686 // couldn't just deactivate it fully, because in case of editing a
1687 // comment, that will make the comment disappear. So let's try to
1688 // reactivate text editing instead:
1689 auto pFuText = dynamic_cast<FuText*>(GetDrawFuncPtr());
1690 if (pFuText && pEditObject != GetDrawView()->GetTextEditObject())
1691 {
1692 pFuText->SetInEditMode(pEditObject);
1695 }
1696}
1697
1699{
1701 SfxStyleSheetBasePool* pStylePool = rDoc.GetStyleSheetPool();
1702
1703 bool bProtected = false;
1704 SCTAB nTabCount = rDoc.GetTableCount();
1705 for (SCTAB i=0; i<nTabCount && !bProtected; i++)
1706 if (rDoc.IsTabProtected(i)) // look after protected table
1707 bProtected = true;
1708
1709 SfxWhichIter aIter(rSet);
1710 sal_uInt16 nWhich = aIter.FirstWhich();
1711 sal_uInt16 nSlotId = 0;
1712
1713 while ( nWhich )
1714 {
1715 nSlotId = SfxItemPool::IsWhich( nWhich )
1716 ? GetPool().GetSlotId( nWhich )
1717 : nWhich;
1718
1719 switch ( nSlotId )
1720 {
1721 case SID_STYLE_APPLY:
1722 if ( !pStylePool )
1723 rSet.DisableItem( nSlotId );
1724 break;
1725
1726 case SID_STYLE_FAMILY2: // cell style sheets
1727 {
1728 SfxStyleSheet* pStyleSheet = const_cast<SfxStyleSheet*>(GetStyleSheetFromMarked());
1729
1730 if ( pStyleSheet )
1731 rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) );
1732 else
1733 rSet.Put( SfxTemplateItem( nSlotId, OUString() ) );
1734 }
1735 break;
1736
1737 case SID_STYLE_FAMILY3: // drawing style sheets
1738 {
1739 SfxStyleSheet* pStyleSheet = GetDrawView()->GetStyleSheet();
1740
1741 if ( pStyleSheet )
1742 rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) );
1743 else
1744 rSet.Put( SfxTemplateItem( nSlotId, OUString() ) );
1745 }
1746 break;
1747
1748 case SID_STYLE_FAMILY4: // page style sheets
1749 {
1750 SCTAB nCurTab = GetViewData().GetTabNo();
1751 OUString aPageStyle = rDoc.GetPageStyle( nCurTab );
1752 SfxStyleSheet* pStyleSheet = pStylePool ? static_cast<SfxStyleSheet*>(pStylePool->
1753 Find( aPageStyle, SfxStyleFamily::Page )) : nullptr;
1754
1755 if ( pStyleSheet )
1756 rSet.Put( SfxTemplateItem( nSlotId, aPageStyle ) );
1757 else
1758 rSet.Put( SfxTemplateItem( nSlotId, OUString() ) );
1759 }
1760 break;
1761
1762 case SID_STYLE_WATERCAN:
1763 {
1764 rSet.Put( SfxBoolItem( nSlotId, SC_MOD()->GetIsWaterCan() ) );
1765 }
1766 break;
1767
1768 case SID_STYLE_UPDATE_BY_EXAMPLE:
1769 {
1770 std::unique_ptr<SfxUInt16Item> pFamilyItem;
1771 GetViewFrame().GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
1772
1773 bool bPage = pFamilyItem && SfxStyleFamily::Page == static_cast<SfxStyleFamily>(pFamilyItem->GetValue());
1774
1775 if ( bProtected || bPage )
1776 rSet.DisableItem( nSlotId );
1777 }
1778 break;
1779
1780 case SID_STYLE_EDIT:
1781 case SID_STYLE_DELETE:
1782 case SID_STYLE_HIDE:
1783 case SID_STYLE_SHOW:
1784 {
1785 std::unique_ptr<SfxUInt16Item> pFamilyItem;
1786 GetViewFrame().GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
1787 bool bPage = pFamilyItem && SfxStyleFamily::Page == static_cast<SfxStyleFamily>(pFamilyItem->GetValue());
1788
1789 if ( bProtected && !bPage )
1790 rSet.DisableItem( nSlotId );
1791 }
1792 break;
1793
1794 default:
1795 break;
1796 }
1797
1798 nWhich = aIter.NextWhich();
1799 }
1800}
1801
1802/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void PutInOrder(T &nStart, T &nEnd)
Definition: address.hxx:150
sal_uInt16 GetValue() const
const OUString & GetValue() const
Base class for Text functions.
Definition: futext.hxx:28
void SetInEditMode(SdrObject *pObj=nullptr, const Point *pMousePixel=nullptr, bool bCursorToEnd=false, const KeyEvent *pInitialKey=nullptr)
Definition: futext.cxx:533
void SetSelection(const ESelection &)
ESelection GetSelection() const
void setX(tools::Long nX)
void setY(tools::Long nY)
virtual VclPtr< SfxAbstractTabDialog > CreateScStyleDlg(weld::Window *pParent, SfxStyleSheetBase &rStyleBase, bool bPage)=0
virtual VclPtr< SfxAbstractTabDialog > CreateScDrawStyleDlg(weld::Window *pParent, SfxStyleSheetBase &rStyleBase, SdrView *pView)=0
virtual VclPtr< SfxAbstractTabDialog > CreateScAttrDlg(weld::Window *pParent, const SfxItemSet *pCellAttrs)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
Definition: scabstdlg.cxx:37
SC_DLLPUBLIC void Format(OStringBuffer &r, ScRefFlags nFlags, const ScDocument *pDocument=nullptr, const Details &rDetails=detailsOOOa1) const
Definition: address.cxx:2074
static OUString GetInputString(const ScRefCellValue &rCell, sal_uInt32 nFormat, SvNumberFormatter &rFormatter, const ScDocument &rDoc, const svl::SharedString **pShared=nullptr, bool bFiltering=false, bool bForceSystemLocale=false)
Definition: cellform.cxx:129
void SetCloseBrackets(bool bVal)
Definition: compiler.hxx:433
std::unique_ptr< ScTokenArray > CompileString(const OUString &rFormula)
Tokenize formula expression string into an array of tokens.
Definition: compiler.cxx:4691
ScChangeAction * GetChangeAction(const ScAddress &rPos)
Definition: docsh3.cxx:572
void PostPaintGridAll()
Definition: docsh3.cxx:183
void SetDocumentModified()
Definition: docsh.cxx:2982
SfxBindings * GetViewBindings()
Definition: docsh4.cxx:2642
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
ScModelObj * GetModel() const
Definition: docsh.hxx:432
void GetStatePageStyle(SfxItemSet &rSet, SCTAB nCurTab)
Definition: docsh4.cxx:2039
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2968
void CellStyleCreated(std::u16string_view rName, const ScDocument &rDoc)
Definition: docpool.cxx:369
void ModifyStyleSheet(SfxStyleSheetBase &rPageStyle, const SfxItemSet &rChanges)
Definition: documen8.cxx:210
SC_DLLPUBLIC sal_uInt32 GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:3640
void InvalidateTextWidth(std::u16string_view rStyleName)
Definition: documen8.cxx:295
bool RemovePageStyleInUse(std::u16string_view rStrPageStyle)
Definition: documen8.cxx:325
SC_DLLPUBLIC bool IsDocProtected() const
Definition: documen3.cxx:1894
SC_DLLPUBLIC bool IsTabProtected(SCTAB nTab) const
Definition: documen3.cxx:1905
bool HasManualBreaks(SCTAB nTab) const
Definition: document.cxx:6222
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6050
SC_DLLPUBLIC formula::FormulaGrammar::AddressConvention GetAddressConvention() const
Definition: documen3.cxx:492
bool IsPageStyleInUse(std::u16string_view rStrPageStyle, SCTAB *pInTab)
Definition: documen8.cxx:310
void SetStreamValid(SCTAB nTab, bool bSet, bool bIgnoreLock=false)
Definition: document.cxx:904
void StylesToNames()
Definition: document.cxx:6112
void UpdStlShtPtrsFrmNms()
Definition: document.cxx:6099
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
Definition: document.cxx:6176
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:1010
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6055
SC_DLLPUBLIC ScOutlineTable * GetOutlineTable(SCTAB nTab, bool bCreate=false)
Definition: documen3.cxx:737
SC_DLLPUBLIC void SetPageStyle(SCTAB nTab, const OUString &rName)
Definition: document.cxx:6170
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
ScChangeTrack * GetChangeTrack() const
Definition: document.hxx:2494
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:974
bool IsUndoEnabled() const
Definition: document.hxx:1595
bool GetSelectionFunction(ScSubTotalFunc eFunc, const ScAddress &rCursor, const ScMarkData &rMark, double &rResult)
Definition: documen4.cxx:602
bool IsPrintEntireSheet(SCTAB nTab) const
Returns true, if the specified sheet is always printed.
Definition: document.cxx:6255
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4684
SC_DLLPUBLIC const ScPatternAttr * GetPattern(SCCOL nCol, SCROW nRow, SCTAB nTab) const
Definition: document.cxx:4719
bool RenamePageStyleInUse(std::u16string_view rOld, const OUString &rNew)
Definition: documen8.cxx:340
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:887
void InvalidateAttribs()
Definition: drawview.cxx:153
OUString GetFormula(const formula::FormulaGrammar::Grammar=formula::FormulaGrammar::GRAM_DEFAULT, const ScInterpreterContext *pContext=nullptr) const
static OUString GetLongErrorString(FormulaError nErrNumber)
Definition: global.cxx:347
static SC_DLLPUBLIC const SvxSearchItem & GetSearchItem()
Definition: global.cxx:227
static bool CheckWidthInvalidate(bool &bNumFormatChanged, const SfxItemSet &rNewAttrs, const SfxItemSet &rOldAttrs)
Definition: global.cxx:186
void NotifyChange(const ScInputHdlState *pState, bool bForce=false, ScTabViewShell *pSourceSh=nullptr, bool bStopEditing=true)
Definition: inputhdl.cxx:4172
bool GetSelIsRef() const
Definition: inputhdl.hxx:248
const OUString & GetEditString()
Definition: inputhdl.cxx:4483
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
bool IsMultiMarked() const
Definition: markdata.hxx:81
SCTAB GetSelectCount() const
Definition: markdata.cxx:180
bool IsMarked() const
Definition: markdata.hxx:80
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getStyleFamilies() override
XStyleFamiliesSupplier.
Definition: docuno.cxx:1474
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
Definition: scmod.cxx:1355
void SetWaterCan(bool bNew)
Definition: scmod.hxx:154
bool GetIsWaterCan() const
Definition: scmod.hxx:155
SC_DLLPUBLIC void InputEnterHandler(ScEnterMode nBlockMode=ScEnterMode::NORMAL, bool bBeforeSavingInLOK=false)
Definition: scmod.cxx:1411
bool IsFormulaMode()
Definition: scmod.cxx:1681
bool IsRefDialogOpen()
Definition: scmod.cxx:1665
sal_uInt32 GetNumberFormat(SvNumberFormatter *) const
Definition: patattr.cxx:1398
SfxItemSet & GetItemSet()
Definition: patattr.hxx:192
bool UpdatePages()
Definition: printfun.cxx:2426
bool GetHideFormula() const
Definition: attrib.hxx:150
bool GetHideCell() const
Definition: attrib.hxx:152
void InitFromStyle(const SfxStyleSheetBase *pSource)
Definition: undostyl.cxx:63
virtual SfxPrinter * GetPrinter(bool bCreate=false) override
Definition: tabvwsh4.cxx:1081
static void UpdateNumberFormatter(const SvxNumberInfoItem &rInfoItem)
Definition: tabvwsh5.cxx:383
void ExecStyle(SfxRequest &rReq)
Definition: tabvwsha.cxx:921
void ExecuteSave(SfxRequest &rReq)
Definition: tabvwsha.cxx:793
std::unique_ptr< ScInputHandler, o3tl::default_delete< ScInputHandler > > mpInputHandler
Definition: tabvwsh.hxx:120
virtual SdrView * GetDrawView() const override
Definition: tabvwsh2.cxx:49
void ExecDrawOpt(const SfxRequest &rReq)
Definition: tabvwsha.cxx:860
void UpdateInputHandler(bool bForce=false, bool bStopEditing=true)
Definition: tabvwsha.cxx:690
void GetDrawOptState(SfxItemSet &rSet)
Definition: tabvwsha.cxx:901
static std::unique_ptr< SvxNumberInfoItem > MakeNumberInfoItem(ScDocument &rDoc, const ScViewData &rViewData)
Definition: tabvwsh5.cxx:313
void GetStyleState(SfxItemSet &rSet)
Definition: tabvwsha.cxx:1698
void ExecuteCellFormatDlg(SfxRequest &rReq, const OUString &rTabPage)
Definition: tabvwsha.cxx:538
void UpdateInputHandlerCellAdjust(SvxCellHorJustify eJust)
Definition: tabvwsha.cxx:787
void SetInFormatDialog(bool bFlag)
Definition: tabvwsh.hxx:355
void GetState(SfxItemSet &rSet)
Definition: tabvwsha.cxx:186
void ExecuteInputDirect()
Definition: tabvwsha.cxx:678
bool GetFunction(OUString &rFuncStr, FormulaError nErrCode)
Definition: tabvwsha.cxx:85
void GetSaveState(SfxItemSet &rSet)
Definition: tabvwsha.cxx:843
bool IsRefInputMode() const
Definition: tabvwsha.cxx:634
bool bInFormatDialog
Definition: tabvwsh.hxx:149
FuPoor * GetDrawFuncPtr()
Definition: tabview.hxx:332
ScViewData & GetViewData()
Definition: tabview.hxx:344
ScDrawView * GetScDrawView()
Definition: tabview.hxx:352
void SetActivePointer(PointerStyle nPointer)
Definition: tabview.cxx:885
void InvalidateAttribs()
Definition: tabview3.cxx:252
void SetOptions(const ScViewOptions &rOpt)
Definition: viewdata.cxx:3982
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:554
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3146
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
SCCOLROW GetLOKSheetFreezeIndex(bool bIsCol) const
Definition: viewdata.cxx:4216
ScSplitMode GetHSplitMode() const
Definition: viewdata.hxx:416
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1182
ScSplitMode GetVSplitMode() const
Definition: viewdata.hxx:417
ScAddress GetCurPos() const
Definition: viewdata.cxx:4119
SfxBindings & GetBindings()
Definition: viewdata.cxx:3134
SCROW GetCurY() const
Definition: viewdata.hxx:402
SCCOL GetCurX() const
Definition: viewdata.hxx:401
void SetStyleSheetToMarked(const SfxStyleSheet *pStyleSheet)
Definition: viewfunc.cxx:1435
const SfxStyleSheet * GetStyleSheetFromMarked()
Definition: viewfunc.cxx:1415
void RemoveStyleSheetInUse(const SfxStyleSheetBase *pStyleSheet)
Definition: viewfunc.cxx:1530
SC_DLLPUBLIC const ScPatternAttr * GetSelectionPattern()
Definition: viewfunc.cxx:911
void UpdateStyleSheetInUse(const SfxStyleSheetBase *pStyleSheet)
Definition: viewfunc.cxx:1556
void GetSelectionFrame(std::shared_ptr< SvxBoxItem > &rLineOuter, std::shared_ptr< SvxBoxInfoItem > &rLineInner)
Definition: viewfunc.cxx:943
void ApplyAttributes(const SfxItemSet *pDialogSet, const SfxItemSet *pOldSet, bool bAdjustBlockHeight=true)
Definition: viewfunc.cxx:974
void SetOption(ScViewOption eOpt, bool bNew)
Definition: viewopti.hxx:85
const ScGridOptions & GetGridOptions() const
Definition: viewopti.hxx:94
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:86
void SetGridOptions(const ScGridOptions &rNew)
Definition: viewopti.hxx:95
void disposeAndReset(reference_type *pBody)
void SetStyleSheet(SfxStyleSheet *pStyleSheet, bool bDontRemoveHardAttr)
SfxStyleSheet * GetStyleSheet() const
SdrTextObj * GetTextEditObject() const
const OutlinerView * GetTextEditOutlinerView() const
void GetAttributes(SfxItemSet &rTargetSet, bool bOnlyHardAttr=false) const
SfxItemState QueryState(sal_uInt16 nSID, std::unique_ptr< SfxPoolItem > &rpState)
void Update(sal_uInt16 nId)
void Invalidate(sal_uInt16 nId)
void SetValue(bool const bTheValue)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
bool IsInPlace() const
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
static bool IsWhich(sal_uInt16 nId)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
OUString GetName() const
bool IsReadOnly() const
bool IsDocShared() const
void SetWhich(sal_uInt16 nId)
sal_uInt16 GetSlot() const
void Ignore()
const SfxItemSet * GetArgs() const
const T * GetArg(sal_uInt16 nSlotId) const
void AppendItem(const SfxPoolItem &)
void SetReturnValue(const SfxPoolItem &)
weld::Window * GetFrameWeld() const
void Done(bool bRemove=false)
void PutItem(const SfxPoolItem &rItem)
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
SfxItemPool & GetPool() const
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
const SfxPoolItem * ExecuteSlot(SfxRequest &rReq, const SfxInterface *pIF=nullptr)
SfxDispatcher * GetDispatcher() const
virtual void Remove(SfxStyleSheetBase *)
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
SfxStyleSearchBits GetMask() const
const OUString & GetName() const
SfxStyleFamily GetFamily() const
virtual void SetHidden(bool bValue)
virtual bool HasParentSupport() const
virtual bool SetParent(const OUString &)
virtual SfxItemSet & GetItemSet()
size_t LeaveListAction()
virtual void EnterListAction(const OUString &rComment, const OUString &rRepeatComment, sal_uInt16 nId, ViewShellId nViewShellId)
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SfxBindings & GetBindings()
bool HasChildWindow(sal_uInt16)
SfxChildWindow * GetChildWindow(sal_uInt16)
SfxFrame & GetFrame() const
bool KnowsChildWindow(sal_uInt16)
weld::Window * GetFrameWeld() const
ViewShellId GetViewShellId() const override
SfxViewFrame & GetViewFrame() const
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
sal_uInt32 GetTimeFormat(double fNumber, LanguageType eLnge, bool bForceDuration)
bool IsTextFormat(sal_uInt32 nFIndex) const
SvNumFormatType GetType(sal_uInt32 nFIndex) const
const SvNumberformat * GetEntry(sal_uInt32 nKey) const
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
LanguageType GetLanguage() const
SvNumFormatType GetType() const
void SetTable(bool bNew)
void SetDist(bool bNew)
void SetMinDist(bool bNew)
bool GetGridVisible() const
bool GetUseGridSnap() const
void SetUseGridSnap(bool bSet)
void SetGridVisible(bool bSet)
void SetSelection(bool bNewSelection)
void AddSnappingPoint(sal_Int32 nNew)
static bool IsPanelVisible(std::u16string_view rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame)
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
float u
EmbeddedObjectRef * pObject
FormulaError
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
OUString aUIName
@ CELLTYPE_EDIT
Definition: global.hxx:277
@ CELLTYPE_STRING
Definition: global.hxx:275
@ CELLTYPE_FORMULA
Definition: global.hxx:276
const sal_uInt16 MINZOOM
Definition: global.hxx:79
ScSubTotalFunc
Definition: global.hxx:860
@ SUBTOTAL_FUNC_MAX
Definition: global.hxx:865
@ SUBTOTAL_FUNC_CNT2
Definition: global.hxx:864
@ SUBTOTAL_FUNC_AVE
Definition: global.hxx:862
@ SUBTOTAL_FUNC_SELECTION_COUNT
Definition: global.hxx:874
@ SUBTOTAL_FUNC_SUM
Definition: global.hxx:870
@ SUBTOTAL_FUNC_MIN
Definition: global.hxx:866
@ SUBTOTAL_FUNC_CNT
Definition: global.hxx:863
const sal_uInt16 MAXZOOM
Definition: global.hxx:80
sal_Int32 nIndex
aStr
int i
constexpr T & temporary(T &&x)
void CleanupFillProperties(SfxItemSet &rItemSet)
long Long
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)
sal_Int16 nId
const char GetValue[]
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
constexpr TypedWhichId< ScMergeAttr > ATTR_MERGE(144)
constexpr TypedWhichId< SvxLanguageItem > ATTR_LANGUAGE_FORMAT(147)
constexpr TypedWhichId< SvxBoxInfoItem > ATTR_BORDER_INNER(151)
constexpr TypedWhichId< SvxBoxItem > ATTR_BORDER(150)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
constexpr TypedWhichId< ScProtectionAttr > ATTR_PROTECTION(149)
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALETOPAGES(176)
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
constexpr TypedWhichId< ScCondFormatItem > ATTR_CONDITIONAL(154)
#define SC_MOD()
Definition: scmod.hxx:247
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
SearchOptionFlags
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:108
ScFormulaCell * getFormula() const
Definition: cellvalue.hxx:137
const EditTextObject * getEditText() const
Definition: cellvalue.hxx:136
CellType getType() const
Definition: cellvalue.hxx:133
SfxStyleFamily
SvxCellHorJustify
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17
RET_OK
@ SC_SPLIT_FIX
Definition: viewdata.hxx:42
@ SC_SPLIT_NORMAL
Definition: viewdata.hxx:42
@ VOPT_HELPLINES
Definition: viewopti.hxx:44
@ VOPT_FORMULAS
Definition: viewopti.hxx:32
constexpr TypedWhichId< XFillColorItem > XATTR_FILLCOLOR(XATTR_FILL_FIRST+1)
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLUSESLIDEBACKGROUND)
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillFloatTransparenceItem > XATTR_FILLFLOATTRANSPARENCE(XATTR_FILL_FIRST+11)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
SvNumFormatType