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