/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
ScAddress aCursor( nPosX, nPosY, nTab ); double nVal; if ( rDoc.GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
{ if ( nVal == 0.0 )
aStr += "0"; else
{ // Number in the standard format, the other on the cursor position
ScInterpreterContext& rContext = rDoc.GetNonThreadedContext();
sal_uInt32 nNumFmt = 0; if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 && eFunc != SUBTOTAL_FUNC_SELECTION_COUNT)
{ // number format from attributes or formula
nNumFmt = rDoc.GetNumberFormat( nPosX, nPosY, nTab ); // If the number format is time (without date) and the // result is not within 24 hours, use a duration // format. Summing date+time doesn't make much sense // otherwise but we also don't want to display duration // for a single date+time value. if (nVal < 0.0 || nVal >= 1.0)
{ const SvNumberformat* pFormat = rContext.NFGetFormatEntry(nNumFmt); if (pFormat && (pFormat->GetType() == SvNumFormatType::TIME))
nNumFmt = rContext.NFGetTimeFormat( nVal, pFormat->GetLanguage(), true);
}
}
case SID_OPENDLG_EDIT_PRINTAREA: case SID_ADD_PRINTAREA: case SID_DEFINE_PRINTAREA:
{ if ( rDocShell.IsDocShared() )
{
rSet.DisableItem( nWhich );
}
} break;
case SID_DELETE_PRINTAREA: if ( rDocShell.IsDocShared() )
{
rSet.DisableItem( nWhich );
} elseif (rDoc.IsPrintEntireSheet(nTab))
rSet.DisableItem(nWhich); break;
case SID_STATUS_PAGESTYLE: case SID_HFEDIT:
GetViewData().GetDocShell().GetStatePageStyle( rSet, nTab ); break;
case SID_SEARCH_ITEM:
{
SvxSearchItem aItem(ScGlobal::GetSearchItem()); // make a copy. // Search on current selection if a range is marked.
aItem.SetSelection(rMark.IsMarked());
rSet.Put(aItem); break;
}
case SID_SEARCH_OPTIONS:
{ // Anything goes
SearchOptionFlags nOptions = SearchOptionFlags::ALL;
// No replacement if ReadOnly if (GetViewData().GetDocShell().IsReadOnly() || IsCurrentLokViewReadOnly())
nOptions &= ~SearchOptionFlags( SearchOptionFlags::REPLACE | SearchOptionFlags::REPLACE_ALL );
rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(nOptions) ) );
} break;
case FID_NORMALVIEWMODE: case FID_PAGEBREAKMODE: // always handle both slots - they exclude each other if ( bOle )
{
rSet.DisableItem( FID_NORMALVIEWMODE );
rSet.DisableItem( FID_PAGEBREAKMODE );
} else
{
rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData().IsPagebreakMode()));
rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData().IsPagebreakMode()));
} break;
// We only allow these border line types.
std::vector<sal_Int32> aBorderStyles{
table::BorderLineStyle::SOLID,
table::BorderLineStyle::DOTTED,
table::BorderLineStyle::DASHED,
table::BorderLineStyle::FINE_DASHED,
table::BorderLineStyle::DASH_DOT,
table::BorderLineStyle::DASH_DOT_DOT,
table::BorderLineStyle::DOUBLE_THIN };
// Generate NumberFormat Value from Value and Language and box it. if (pOldAttrs->HasNumberFormat()) // tdf#42989: don't set it for multi-format selection
xOldSet->Put(
SfxUInt32Item(ATTR_VALUE_FORMAT, pOldAttrs->GetNumberFormat(rDoc.GetFormatTable()))); else// Make sure it's invalid, when ATTR_LANGUAGE_FORMAT is invalid
xOldSet->InvalidateItem(ATTR_VALUE_FORMAT);
aString = ScCellFormat::GetInputString( rCell, nNumFmt, &rContext, rDoc ); if (rCell.getType() == CELLTYPE_STRING)
{ // Put a ' in front if necessary, so that the string is not // unintentionally interpreted as a number, and to show the // user that it is a string (#35060#). // If cell is not formatted as Text, a leading apostrophe // needs another prepended, also '=' or '+' or '-' // otherwise starting a formula. // NOTE: this corresponds with // sc/source/core/data/column3.cxx ScColumn::ParseString() // removing one apostrophe. // For number format Text IsNumberFormat() would never // result in numeric anyway. if (!rContext.NFIsTextFormat(nNumFmt) && (aString.startsWith("'")
|| aString.startsWith("=") || aString.startsWith("+") || aString.startsWith("-")
|| rContext.NFIsNumberFormat(aString, nNumFmt, o3tl::temporary(double()))))
aString = "'" + aString;
}
}
}
// if using the view's local input handler, this view can always be set // as current view inside NotifyChange.
ScTabViewShell* pSourceSh = mpInputHandler ? this : nullptr;
// Finish entering unless 'DontTerminateEdit' is specified, even if a formula is being processed if (bCommitChanges)
{ bool bLOKActive = comphelper::LibreOfficeKit::isActive();
// Disable error dialog box when about to save in lok mode as // this ultimately invokes SvpSalInstance::DoYield() when we want // to save immediately without committing any erroneous input in possibly // a cell with validation rules. After save is complete the user // can continue editing.
ScModule::get()->InputEnterHandler(ScEnterMode::NORMAL, bLOKActive /* bBeforeSavingInLOK */);
if (bLOKActive)
{ // Normally this isn't needed, but in Calc when editing a cell formula // and manually saving (without changing cells or hitting enter), while // InputEnterHandler will mark the doc as modified (when it is), because // we will save the doc immediately afterwards, the modified state event // is clobbered. To avoid that, we need to update SID_DOC_MODIFIED so that // a possible state of "true" after "InputEnterHandler" will be sent // as a notification. It is important that the notification goes through // normal process (cache) rather than directly notifying the views. // Otherwise, because there is a previous state of "false" in cache, the // "false" state after saving will be ignored. // This will work only if .uno:ModifiedStatus message will be removed from // the mechanism that keeps in the message queue only last message of // a particular status even if the values are different. if (SfxBindings* pBindings = GetViewData().GetDocShell().GetViewBindings())
pBindings->Update(SID_DOC_MODIFIED);
}
}
if ( GetViewData().GetDocShell().IsDocShared() )
{
GetViewData().GetDocShell().SetDocumentModified();
}
// otherwise as normal
GetViewData().GetDocShell().ExecuteSlot( rReq );
}
// set new style for paintbrush format mode if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet ) static_cast<ScStyleSheetPool*>(pStylePool)->SetActualStyleSheet( pStyleSheet );
case SID_STYLE_HIDE: case SID_STYLE_SHOW:
{ if ( pStyleSheet )
{
pStyleSheet->SetHidden( nSlotId == SID_STYLE_HIDE );
InvalidateAttribs();
rReq.Done();
} else
nRetMask = sal_uInt16(false);
} break;
case SID_STYLE_APPLY:
{ if ( pStyleSheet && !pScMod->GetIsWaterCan() )
{ // apply style sheet to document
SetStyleSheetToMarked( static_cast<SfxStyleSheet*>(pStyleSheet) );
InvalidateAttribs();
rReq.Done();
}
} break;
case SID_STYLE_NEW_BY_EXAMPLE: case SID_STYLE_UPDATE_BY_EXAMPLE:
{ // create/replace style sheet by attributes // at cursor position:
const ScPatternAttr* pAttrItem = nullptr;
// The query if marked, was always wrong here, // so now no more, and just from the cursor. // If attributes are to be removed from the selection, still need to be // cautious not to adopt items from templates // (GetSelectionPattern also collects items from originals) (# 44748 #)
SCCOL nCol = GetViewData().GetCurX();
SCROW nRow = GetViewData().GetCurY();
pAttrItem = rDoc.GetPattern( nCol, nRow, nCurTab );
// Do not adopt conditional formatting and validity, // because they can not be edited in the template
aAttrSet.ClearItem( ATTR_VALIDDATA );
aAttrSet.ClearItem( ATTR_CONDITIONAL );
// when a new style is present and is used in the selection, // then the parent can not be adopted: if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse )
pSheetInUse = nullptr;
// if already present, first remove ... if ( pStyleSheet )
{ // style pointer to names before erase, // otherwise cells will get invalid pointer //!!! As it happens, a method that does it for a particular style
rDoc.getCellAttributeHelper().AllStylesToNames();
bConvertBack = true;
pStylePool->Remove(pStyleSheet);
}
// when a style is present, then this will become // the parent of the new style: if ( pSheetInUse && pStyleSheet->HasParentSupport() )
pStyleSheet->SetParent( pSheetInUse->GetName() );
if ( bConvertBack ) // Name to style pointer
rDoc.getCellAttributeHelper().UpdateAllStyleSheets(rDoc); else
rDoc.getCellAttributeHelper().CellStyleCreated(rDoc, aStyleName);
// Adopt attribute and use style
pStyleSheet->GetItemSet().Put( aAttrSet );
UpdateStyleSheetInUse( pStyleSheet );
// call SetStyleSheetToMarked after adding the ScUndoModifyStyle // (pStyleSheet pointer is used!)
bStyleToMarked = true;
} else// ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE )
{
pStyleSheet = const_cast<SfxStyleSheet*>(GetStyleSheetFromMarked());
if ( pStyleSheet )
{
xOldData->InitFromStyle( pStyleSheet );
case SID_STYLE_NEW_BY_EXAMPLE: case SID_STYLE_UPDATE_BY_EXAMPLE:
{ if (nSlotId == SID_STYLE_NEW_BY_EXAMPLE)
{
pStyleSheet = &pStylePool->Make( aStyleName, eFamily, SfxStyleSearchBits::UserDefined );
// when a style is present, then this will become // the parent of the new style: if (SfxStyleSheet* pOldStyle = GetDrawView()->GetStyleSheet())
pStyleSheet->SetParent(pOldStyle->GetName());
} else
{
pStyleSheet = GetDrawView()->GetStyleSheet();
xOldData->InitFromStyle( pStyleSheet );
}
// Store old Items from the style
std::shared_ptr<SfxItemSet> xOldSet = std::make_shared<SfxItemSet>(pStyleSheet->GetItemSet());
OUString aOldName = pStyleSheet->GetName();
case SfxStyleFamily::Para:
{
SfxItemSet& rSet = pStyleSheet->GetItemSet();
if ( const SfxUInt32Item* pItem = rSet.GetItemIfSet( ATTR_VALUE_FORMAT, false ) )
{ // Produce and format NumberFormat Value from Value and Language
sal_uLong nFormat = pItem->GetValue();
LanguageType eLang =
rSet.Get(ATTR_LANGUAGE_FORMAT ).GetLanguage();
sal_uLong nLangFormat = rDoc.GetFormatTable()->
GetFormatForLanguageIfBuiltIn( nFormat, eLang ); if ( nLangFormat != nFormat )
{
SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat );
rSet.Put( aNewItem );
xOldSet->Put( aNewItem ); // Also in aOldSet for comparison after the dialog, // Otherwise might miss a language change
}
}
// Definitely a SvxBoxInfoItem with Table = sal_False in set: // (If there is no item, the dialogue will also delete the // BORDER_OUTER SvxBoxItem from the Template Set) if ( rSet.GetItemState( ATTR_BORDER_INNER, false ) != SfxItemState::SET )
{
SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
aBoxInfoItem.SetTable(false); // no inner lines
aBoxInfoItem.SetDist(true);
aBoxInfoItem.SetMinDist(false);
rSet.Put( aBoxInfoItem );
}
} break;
if ( pOutSet )
{
rnRetMask = sal_uInt16(pStyleSheet->GetMask());
// Attribute comparisons (earlier in ModifyStyleSheet) now here // with the old values (the style is already changed) if ( SfxStyleFamily::Para == eFam )
{
SfxItemSet& rNewSet = pStyleSheet->GetItemSet(); bool bNumFormatChanged; if ( ScGlobal::CheckWidthInvalidate(
bNumFormatChanged, rNewSet, *xOldSet ) )
rDoc.InvalidateTextWidth( nullptr, nullptr, bNumFormatChanged );
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.