20#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
21#include <com/sun/star/document/XDocumentProperties.hpp>
29#include <officecfg/Office/Common.hxx>
38#include <svx/svxids.hrc>
43#include <osl/diagnose.h>
62#include <progress.hxx>
89 pViewSh->
Notify( *
this, aHint );
95 Broadcast(
SfxHint( SfxHintId::ScDataChanged ) );
103 sal_uInt16 nExtFlags )
105 ScRange aRange(nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
112 for (
size_t i = 0,
n = rRanges.
size();
i <
n; ++
i)
133 nCol2, nRow2, nTab2 ), nLockPart );
144 if (nCol1>0) --nCol1;
145 if (nCol2<m_pDocument->MaxCol()) ++nCol2;
146 if (nRow1>0) --nRow1;
147 if (nRow2<m_pDocument->MaxRow()) ++nRow2;
152 m_pDocument->ExtendMerge( nCol1, nRow1, nCol2, nRow2, nTab1 );
154 if ( nCol1 != 0 || nCol2 !=
m_pDocument->MaxCol() )
255 if ( xRangeList.
is() )
261 ScRange const & rRange = (*xRangeList)[
i];
268 if ( pPaint->GetModified() )
274 OSL_FAIL(
"UnlockPaint without LockPaint");
342 OSL_FAIL(
"UnlockDocument without LockDocument");
363 bool bTextWysiwyg =
SC_MOD()->GetInputOptions().GetTextWysiwyg();
370 OUString aTestString(
371 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789");
388 pVirtWindow->SetMapMode(
MapMode(MapUnit::MapPixel));
390 pVirtWindow->SetFont(aDefFont);
394 if (nPrinterWidth && nWindowWidth)
398 OSL_FAIL(
"GetTextSize returns 0 ??");
420 aDocOpt.
SetYear2000(officecfg::Office::Common::DateFormat::TwoDigitYear::get());
434 aDocOpt.
SetDate( 30, 12, 1899);
443 m_pDocument->SetLanguage( nDefLang, nCjkLang, nCtlLang );
474 if ( pOld && pOld->IsPrinting() )
477 if (nDiffFlags & SfxPrinterChangeFlags::PRINTER)
493 if (
SC_MOD()->GetInputOptions().GetTextWysiwyg() )
511 else if (nDiffFlags & SfxPrinterChangeFlags::JOBSETUP)
516 pOldPrinter->SetJobSetup( pNewPrinter->GetJobSetup() );
526 if (nDiffFlags & SfxPrinterChangeFlags::OPTIONS)
531 if (nDiffFlags & (SfxPrinterChangeFlags::CHG_ORIENTATION | SfxPrinterChangeFlags::CHG_SIZE))
540 if (nDiffFlags & SfxPrinterChangeFlags::CHG_ORIENTATION)
544 bool bNewLand = ( pNewPrinter->GetOrientation() == Orientation::Landscape );
545 if (bNewLand != bWasLand)
559 if (nDiffFlags & SfxPrinterChangeFlags::CHG_SIZE)
640 if (!pAction)
return;
643 OUString aAuthor = pAction->
GetUser();
655 std::unique_ptr<ScRedComDialog> pDlg(
new ScRedComDialog( pParent, aSet,
this,pAction,bPrevNext));
682 aThisFile = pThisMed->
GetName();
689 aOtherFile = pOtherMed->
GetName();
691 bool bSameDoc = ( aThisFile == aOtherFile && !aThisFile.isEmpty() );
699 uno::Reference<document::XDocumentProperties> xDocProps(
700 GetModel()->getDocumentProperties());
701 OSL_ENSURE(xDocProps.is(),
"no DocumentProperties");
702 OUString aDocUser = xDocProps->getModifiedBy();
704 if ( !aDocUser.isEmpty() )
735 if ( !pAction || !pFirstSearchAction || !pLastSearchAction )
753 if (aActionDesc == aADesc)
755 OSL_FAIL(
"lcl_FindAction(): found equal action!" );
780 OSL_ENSURE(pThisTrack,
"ChangeTracking not enabled?");
786 m_pDocument->SetChangeViewSettings(aChangeViewSet);
799 while (
lcl_Equal( pSourceAction, pThisAction, bIgnore100Sec ) )
802 pSourceAction = pSourceAction->
GetNext();
803 pThisAction = pThisAction->
GetNext();
825 if (!nNewActionCount)
829 ScProgress aProgress(
this,
"...", nNewActionCount,
true );
833 pSourceTrack->
MergePrepare( pFirstMergeAction, bShared );
837 while ( pThisAction )
876 pThisAction = pThisAction->
GetNext();
882 bool bHasRejected =
false;
883 OUString aOldUser = pThisTrack->
GetUser();
887 pSourceAction = pFirstMergeAction;
888 while ( pSourceAction && pSourceAction->
GetActionNumber() <= nLastMergeAction )
890 bool bMergeAction =
false;
893 if ( !bCheckDuplicates || !
lcl_FindAction( rOtherDoc, pSourceAction, *
m_pDocument, pFirstSearchAction, pLastSearchAction, bIgnore100Sec ) )
918#if OSL_DEBUG_LEVEL > 0
922 SAL_WARN(
"sc", aValue <<
" omitted");
933 bool bExecute =
true;
939 if ( nReject >= nFirstNewNumber )
944 if ( pOldAction && pOldAction->
IsVirgin() )
946 pThisTrack->
Reject( pOldAction );
961 pThisTrack->
Reject(pOldAction);
973 switch ( eSourceType )
980 OSL_ENSURE( aSourceRange.
aStart == aSourceRange.
aEnd,
"huch?" );
999 aValue = aValue.copy(1, aValue.getLength()-2);
1001 nullptr,
nullptr, aValue,
false,
false,
1061 aSourceRange.
aStart,
true,
true,
false,
false );
1070 const OUString& rComment = pSourceAction->
GetComment();
1071 if ( !rComment.isEmpty() )
1077 OSL_FAIL(
"MergeDocument: what to do with the comment?!?" );
1084 if ( bShared && !pSourceAction->
IsRejected() )
1094 if ( bShared && pMergeMap )
1100 sal_uLong nActionCount = nActionMax - nOldActionMax;
1101 sal_uLong nAction = nActionMax - nActionCount + 1;
1103 while ( nAction <= nActionMax )
1107 (*pMergeMap)[ nAction++ ] = nSourceAction++;
1111 (*pMergeMap)[ nSourceAction++ ] = nAction++;
1119 pSourceAction = pSourceAction->
GetNext();
1122 rMarkData = std::move(aOldMarkData);
1123 pThisTrack->
SetUser(aOldUser);
1126 pSourceTrack->
Clear();
1136 if ( !pSharedDocShell )
1149 if ( !pSharedTrack )
1157 m_pDocument->SetChangeViewSettings( aChangeViewSet );
1163 while (
lcl_Equal( pThisAction, pSharedAction, bIgnore100Sec ) )
1165 pThisAction = pThisAction->
GetNext();
1166 pSharedAction = pSharedAction->
GetNext();
1169 if ( pSharedAction )
1176 std::optional<ScDocument> pTmpDoc(std::in_place);
1180 pTmpDoc->CreateValidTabName( sTabName );
1183 m_pDocument->GetChangeTrack()->Clone( &*pTmpDoc );
1185 pSharedDocShell->
MergeDocument( *pTmpDoc,
true,
true, 0, &aOwnInverseMergeMap,
true );
1187 sal_uLong nActStartOwn = nActEndShared + 1;
1192 ScConflictsFinder aFinder( pSharedTrack, nActStartShared, nActEndShared, nActStartOwn, nActEndOwn, aConflictsList );
1193 if ( aFinder.
Find() )
1205 VclMessageType::Question, VclButtonsType::YesNo,
1206 ScResId(STR_DOC_WILLNOTBESAVED)));
1207 xQueryBox->set_default_response(
RET_YES);
1208 if (xQueryBox->run() ==
RET_YES)
1221 pSharedTrack->
Undo( nActStartOwn, nActEndOwn );
1228 pTmpDoc->CreateValidTabName( sTabName );
1231 pThisTrack->
Clone( &*pTmpDoc );
1238 pThisTrack->
Reject( pAction,
true );
1247 MergeDocument( rSharedDoc,
true,
true, 0, &aSharedMergeMap );
1251 if ( !aConflictsList.empty() )
1255 pAction = pThisTrack->
GetAction( nEndShared );
1270 m_pDocument->SetChangeViewSettings( aChangeViewSet );
1275 MergeDocument( *pTmpDoc,
true,
true, nEndShared - nStartShared + 1, &aOwnMergeMap );
1280 if ( !aConflictsList.empty() )
1284 pAction = pThisTrack->
GetAction( nEndShared );
1292 pAction = pThisTrack->
GetAction( nEndOwn );
1313 m_pDocument->SetChangeViewSettings( aChangeViewSet );
1321 VclMessageType::Info, VclButtonsType::Ok,
1326 return ( pThisAction !=
nullptr );
const SCTAB SC_TAB_APPEND
SfxApplication * SfxGetpApp()
static OutputDevice * GetDefaultDevice()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
bool IsEqualIgnoreNanoSec(const DateTime &rDateTime) const
OUString getDate(const Date &rDate) const
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
const MapMode & GetMapMode() const
ScRange MakeRange(const ScDocument &rDoc) const
bool IsTabDeleteCol() const
ScBigRange GetOverAllRange() const
ScBigRange & GetFromRange()
const OUString & GetComment() const
void SetComment(const OUString &rStr)
ScBigRange & GetBigRange()
sal_uLong GetRejectAction() const
sal_uLong GetActionNumber() const
const DateTime & GetDateTimeUTC() const
ScChangeActionType GetType() const
virtual OUString GetDescription(ScDocument &rDoc, bool bSplitRange=false, bool bWarning=true) const
ScChangeAction * GetNext() const
ScChangeAction * GetPrev() const
SC_DLLPUBLIC DateTime GetDateTime() const
ScChangeActionState GetState() const
const OUString & GetUser() const
void RemoveAllDeletedIn()
ScChangeAction * GetLast() const
SC_DLLPUBLIC void AppendInsert(const ScRange &rRange, bool bEndOfList=false)
SC_DLLPUBLIC ScChangeTrack * Clone(ScDocument *pDocument) const
void MergePrepare(const ScChangeAction *pFirstMerge, bool bShared)
may only be used in a temporary opened document.
SC_DLLPUBLIC ScChangeAction * GetAction(sal_uLong nAction) const
SC_DLLPUBLIC void SetUser(const OUString &rUser)
SC_DLLPUBLIC void AppendMove(const ScRange &rFromRange, const ScRange &rToRange, ScDocument *pRefDoc)
sal_uLong GetActionMax() const
void MergeOwn(ScChangeAction *pAct, sal_uLong nFirstMerge, bool bShared)
void NotifyModified(ScChangeTrackMsgType eMsgType, sal_uLong nStartAction, sal_uLong nEndAction)
static bool MergeIgnore(const ScChangeAction &, sal_uLong nFirstMerge)
void SetFixDateTimeUTC(const DateTime &rDT)
SC_DLLPUBLIC void Undo(sal_uLong nStartAction, sal_uLong nEndAction, bool bMerge=false)
bool Reject(ScChangeAction *, ScChangeActionMap *, bool bRecursion)
bool IsTimeNanoSeconds() const
SC_DLLPUBLIC void AppendDeleteRange(const ScRange &, ScDocument *pRefDoc, SCTAB nDz, sal_uLong nRejectingInsert)
void SetUseFixDateTime(bool bVal)
static void MergeActionState(ScChangeAction *pAct, const ScChangeAction *pOtherAct)
const OUString & GetUser() const
ScChangeAction * GetFirst() const
void SetShowChanges(bool bFlag)
void SetTheActionRange(sal_uLong nFirst, sal_uLong nLast)
void SetShowAccepted(bool bVal)
static void TransformConflictsList(ScConflictsList &rConflictsList, ScChangeActionMergeMap *pSharedMap, ScChangeActionMergeMap *pOwnMap)
void HandleAction(ScChangeAction *pAction, bool bIsSharedAction, bool bHandleContentAction, bool bHandleNonContentAction)
bool MoveBlock(const ScRange &rSource, const ScAddress &rDestPos, bool bCut, bool bRecord, bool bPaint, bool bApi)
bool InsertCells(const ScRange &rRange, const ScMarkData *pTabMark, InsCellCmd eCmd, bool bRecord, bool bApi, bool bPartOfPaste=false)
bool DeleteCells(const ScRange &rRange, const ScMarkData *pTabMark, DelCellCmd eCmd, bool bApi)
SC_DLLPUBLIC bool InsertTable(SCTAB nTab, const OUString &rName, bool bRecord, bool bApi)
bool DeleteTable(SCTAB nTab, bool bRecord)
SC_DLLPUBLIC bool EnterMatrix(const ScRange &rRange, const ScMarkData *pTabMark, const ScTokenArray *pTokenArray, const OUString &rString, bool bApi, bool bEnglish, const OUString &rFormulaNmsp, const formula::FormulaGrammar::Grammar)
void SetYear2000(sal_uInt16 nVal)
void SetAutoSpell(bool bVal)
void SetStdPrecision(sal_uInt16 n)
void SetDate(sal_uInt16 nD, sal_uInt16 nM, sal_Int16 nY)
ScChangeAction * GetChangeAction(const ScAddress &rPos)
void PostPaintCell(SCCOL nCol, SCROW nRow, SCTAB nTab)
static weld::Window * GetActiveDialogParent()
SAL_DLLPRIVATE void UnlockPaint_Impl(bool bDoc)
OutputDevice * GetRefDevice()
double m_nPrtToScreenFactor
bool MergeSharedDocument(ScDocShell *pSharedDocShell)
void SetDocumentModified()
sal_uInt16 m_nDocumentLock
SAL_DLLPRIVATE void LockPaint_Impl(bool bDoc)
virtual Printer * GetDocumentPrinter() override
SAL_DLLPRIVATE void LockDocument_Impl(sal_uInt16 nNew)
sal_uInt16 SetPrinter(VclPtr< SfxPrinter > const &pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL)
SAL_DLLPRIVATE void UnlockDocument_Impl(sal_uInt16 nNew)
void CompareDocument(ScDocument &rOtherDoc)
const ScDocument & GetDocument() const
void UpdatePaintExt(sal_uInt16 &rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab)
void ExecuteChangeCommentDialog(ScChangeAction *pAction, weld::Window *pParent, bool bPrevNext=true)
std::shared_ptr< ScDocument > m_pDocument
void SetChangeComment(ScChangeAction *pAction, const OUString &rComment)
std::unique_ptr< ScPaintLockData > m_pPaintLockData
std::unique_ptr< DocShell_Impl > m_pImpl
void PostEditView(ScEditEngineDefaulter *pEditEngine, const ScAddress &rCursorPos)
ScTabViewShell * GetBestViewShell(bool bOnlyVisible=true)
void PostPaint(SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, sal_uInt16 nExtFlags=0)
void MergeDocument(ScDocument &rOtherDoc, bool bShared=false, bool bCheckDuplicates=false, sal_uLong nOffset=0, ScChangeActionMergeMap *pMergeMap=nullptr, bool bInverseMap=false)
SAL_DLLPRIVATE void InitOptions(bool bForLoading)
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
static ScViewData * GetViewData()
void SetLockCount(sal_uInt16 nNew)
void SetFormulaOptions(const ScFormulaOptions &rOpt, bool bForLoading=false)
ScModelObj * GetModel() const
void SetInplace(bool bInplace)
SfxObjectShell * GetDocumentShell() const
ScChangeTrack * GetChangeTrack() const
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
void SelectOneTable(SCTAB nTab)
ScInputHandler * GetInputHdl(ScTabViewShell *pViewSh=nullptr, bool bUseRef=true)
Input-Handler.
SC_DLLPUBLIC const ScFormulaOptions & GetFormulaOptions()
SC_DLLPUBLIC const ScDocOptions & GetDocOptions()
static void GetSpellSettings(LanguageType &rDefLang, LanguageType &rCjkLang, LanguageType &rCtlLang, bool &rAutoSpell)
const ScViewOptions & GetViewOptions()
static void fillFontOnly(vcl::Font &rFont, const SfxItemSet &rItemSet, const OutputDevice *pOutDev=nullptr, const Fraction *pScale=nullptr, const SfxItemSet *pCondSet=nullptr, SvtScriptType nScript=SvtScriptType::NONE)
Static helper function to fill a font object from the passed item set.
void SetStateCountDown(sal_uInt64 nVal)
void push_back(const ScRange &rRange)
bool Contains(const ScAddress &) const
is Address& fully in Range?
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
static ScTabViewShell * GetActiveViewShell()
ScViewData & GetViewData()
ScMarkData & GetMarkData()
ScDocShell * GetDocShell() const
void EnterData(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const EditTextObject *pData=nullptr, bool bMatrixExpand=false)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static void notifyDocumentSizeChangedAllViews(vcl::ITiledRenderable *pDoc, bool bInvalidateAll=true)
const OUString & GetName() const
SfxMedium * GetMedium() const
void PutItem(const SfxPoolItem &rItem)
SfxItemPool & GetPool() const
SfxViewShell * GetViewShell() const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual SfxItemSet & GetItemSet()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetLandscape(bool bL)
static Size GetPaperSize(Paper ePaper, MapUnit eUnit=MapUnit::MapTwip)
::std::vector< ScConflictsListEntry > ScConflictsList
static bool lcl_FindAction(ScDocument &rDoc, const ScChangeAction *pAction, ScDocument &rSearchDoc, const ScChangeAction *pFirstSearchAction, const ScChangeAction *pLastSearchAction, bool bIgnore100Sec)
static bool lcl_Equal(const ScChangeAction *pA, const ScChangeAction *pB, bool bIgnore100Sec)
std::unordered_map< sal_uLong, sal_uLong > ScChangeActionMergeMap
#define SAL_WARN(area, stream)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
constexpr TypedWhichId< SvxPageItem > ATTR_PAGE(159)
Store arbitrary cell value of any kind.
ScFormulaCell * getFormula() const
#define SFX_PRINTERROR_BUSY