Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "undoutil.hxx"
30 : :
31 : : #include "docsh.hxx"
32 : : #include "tabvwsh.hxx"
33 : : #include "document.hxx"
34 : : #include "dbdata.hxx"
35 : : #include "globstr.hrc"
36 : : #include "globalnames.hxx"
37 : : #include "global.hxx"
38 : : #include "markdata.hxx"
39 : :
40 : 0 : void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell,
41 : : SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
42 : : SCCOL nEndX, SCROW nEndY, SCTAB nEndZ )
43 : : {
44 [ # # ]: 0 : if ( pDocShell->IsPaintLocked() )
45 : 0 : return;
46 : :
47 : 0 : ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
48 [ # # ]: 0 : if (pViewShell)
49 : : {
50 : 0 : SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
51 [ # # ][ # # ]: 0 : if ( nViewTab < nStartZ || nViewTab > nEndZ )
52 : 0 : pViewShell->SetTabNo( nStartZ );
53 : :
54 : 0 : pViewShell->DoneBlockMode();
55 : 0 : pViewShell->MoveCursorAbs( nStartX, nStartY, SC_FOLLOW_JUMP, false, false );
56 : 0 : pViewShell->InitOwnBlockMode();
57 [ # # ]: 0 : pViewShell->GetViewData()->GetMarkData().
58 [ # # ]: 0 : SetMarkArea( ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ) );
59 : 0 : pViewShell->MarkDataChanged();
60 : : }
61 : : }
62 : :
63 : :
64 : 0 : void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell,
65 : : const ScAddress& rBlockStart,
66 : : const ScAddress& rBlockEnd )
67 : : {
68 : 0 : MarkSimpleBlock( pDocShell, rBlockStart.Col(), rBlockStart.Row(), rBlockStart.Tab(),
69 : 0 : rBlockEnd.Col(), rBlockEnd.Row(), rBlockEnd.Tab() );
70 : 0 : }
71 : :
72 : :
73 : 0 : void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell,
74 : : const ScRange& rRange )
75 : : {
76 : 0 : MarkSimpleBlock( pDocShell, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
77 : 0 : rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab() );
78 : 0 : }
79 : :
80 : :
81 : :
82 : 0 : ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB nTab,
83 : : SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
84 : : {
85 : 0 : ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 );
86 : :
87 [ # # ]: 0 : if (!pRet)
88 : : {
89 : 0 : bool bWasTemp = false;
90 [ # # ]: 0 : if ( pUndoData )
91 : : {
92 : 0 : const ::rtl::OUString& aName = pUndoData->GetName();
93 [ # # ]: 0 : if ( aName == STR_DB_LOCAL_NONAME )
94 : 0 : bWasTemp = true;
95 : : }
96 : : OSL_ENSURE(bWasTemp, "Undo: didn't find database range");
97 : : (void)bWasTemp;
98 : 0 : pRet = pDoc->GetAnonymousDBData(nTab);
99 [ # # ]: 0 : if (!pRet)
100 : : {
101 : : pRet = new ScDBData( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)), nTab,
102 : : nCol1,nRow1, nCol2,nRow2, sal_True,
103 [ # # ][ # # ]: 0 : pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) );
[ # # ]
104 : 0 : pDoc->SetAnonymousDBData(nTab,pRet);
105 : : }
106 : : }
107 : :
108 : 0 : return pRet;
109 : : }
110 : :
111 : :
112 : 0 : void ScUndoUtil::PaintMore( ScDocShell* pDocShell,
113 : : const ScRange& rRange )
114 : : {
115 : 0 : SCCOL nCol1 = rRange.aStart.Col();
116 : 0 : SCROW nRow1 = rRange.aStart.Row();
117 : 0 : SCCOL nCol2 = rRange.aEnd.Col();
118 : 0 : SCROW nRow2 = rRange.aEnd.Row();
119 [ # # ]: 0 : if (nCol1 > 0) --nCol1;
120 [ # # ]: 0 : if (nRow1 > 0) --nRow1;
121 [ # # ]: 0 : if (nCol2<MAXCOL) ++nCol2;
122 [ # # ]: 0 : if (nRow2<MAXROW) ++nRow2;
123 : :
124 : 0 : pDocShell->PostPaint( nCol1,nRow1,rRange.aStart.Tab(),
125 : 0 : nCol2,nRow2,rRange.aEnd.Tab(), PAINT_GRID );
126 : 0 : }
127 : :
128 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|