1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: notemark.cxx,v $
10 * $Revision: 1.12.126.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include <svx/svdoutl.hxx>
35 #include <svx/svdmodel.hxx>
36 #include <svx/svdpage.hxx>
37 #include <svx/svdocapt.hxx>
38 #include <sfx2/printer.hxx>
39 #include <svtools/pathoptions.hxx>
40 #include <svtools/itempool.hxx>
41 #include <vcl/svapp.hxx>
43 #include "notemark.hxx"
44 #include "document.hxx"
47 #define SC_NOTEMARK_TIME 800
48 #define SC_NOTEMARK_SHORT 70
50 // -----------------------------------------------------------------------
52 ScNoteMarker::ScNoteMarker( Window
* pWin
, Window
* pRight
, Window
* pBottom
, Window
* pDiagonal
,
53 ScDocument
* pD
, ScAddress aPos
, const String
& rUser
,
54 const MapMode
& rMap
, BOOL bLeftEdge
, BOOL bForce
, BOOL bKeyboard
) :
57 pBottomWin( pBottom
),
58 pDiagWin( pDiagonal
),
64 bByKeyboard( bKeyboard
),
69 Size aSizePixel
= pWindow
->GetOutputSizePixel();
71 aSizePixel
.Width() += pRightWin
->GetOutputSizePixel().Width();
73 aSizePixel
.Height() += pBottomWin
->GetOutputSizePixel().Height();
74 Rectangle
aVisPixel( Point( 0, 0 ), aSizePixel
);
75 aVisRect
= pWindow
->PixelToLogic( aVisPixel
, aMapMode
);
77 aTimer
.SetTimeoutHdl( LINK( this, ScNoteMarker
, TimeHdl
) );
78 aTimer
.SetTimeout( bForce
? SC_NOTEMARK_SHORT
: SC_NOTEMARK_TIME
);
82 ScNoteMarker::~ScNoteMarker()
89 IMPL_LINK( ScNoteMarker
, TimeHdl
, Timer
*, EMPTYARG
)
93 SvtPathOptions aPathOpt
;
94 String aPath
= aPathOpt
.GetPalettePath();
95 pModel
= new SdrModel(aPath
);
96 pModel
->SetScaleUnit(MAP_100TH_MM
);
97 SfxItemPool
& rPool
= pModel
->GetItemPool();
98 rPool
.SetDefaultMetric(SFX_MAPUNIT_100TH_MM
);
99 rPool
.FreezeIdRanges();
101 OutputDevice
* pPrinter
= pDoc
->GetRefDevice();
104 // Am Outliner des Draw-Model ist auch der Drucker als RefDevice gesetzt,
105 // und es soll einheitlich aussehen.
106 Outliner
& rOutliner
= pModel
->GetDrawOutliner();
107 rOutliner
.SetRefDevice(pPrinter
);
110 if( SdrPage
* pPage
= pModel
->AllocPage( FALSE
) )
112 pObject
= ScNoteUtil::CreateTempCaption( *pDoc
, aDocPos
, *pPage
, aUserText
, aVisRect
, bLeft
);
114 aRect
= pObject
->GetCurrentBoundRect();
116 // #39351# Page einfuegen damit das Model sie kennt und auch deleted
117 pModel
->InsertPage( pPage
);
127 void lcl_DrawWin( SdrObject
* pObject
, Window
* pWindow
, const MapMode
& rMap
)
129 MapMode aOld
= pWindow
->GetMapMode();
130 pWindow
->SetMapMode( rMap
);
132 ULONG nOldDrawMode
= pWindow
->GetDrawMode();
133 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
135 pWindow
->SetDrawMode( nOldDrawMode
| DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
|
136 DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
);
139 pObject
->SingleObjectPainter( *pWindow
); // #110094#-17
141 pWindow
->SetDrawMode( nOldDrawMode
);
142 pWindow
->SetMapMode( aOld
);
145 MapMode
lcl_MoveMapMode( const MapMode
& rMap
, const Size
& rMove
)
148 Point aOrigin
= aNew
.GetOrigin();
149 aOrigin
.X() -= rMove
.Width();
150 aOrigin
.Y() -= rMove
.Height();
151 aNew
.SetOrigin(aOrigin
);
155 void ScNoteMarker::Draw()
157 if ( pObject
&& bVisible
)
159 lcl_DrawWin( pObject
, pWindow
, aMapMode
);
161 if ( pRightWin
|| pBottomWin
)
163 Size aWinSize
= pWindow
->PixelToLogic( pWindow
->GetOutputSizePixel(), aMapMode
);
165 lcl_DrawWin( pObject
, pRightWin
,
166 lcl_MoveMapMode( aMapMode
, Size( aWinSize
.Width(), 0 ) ) );
168 lcl_DrawWin( pObject
, pBottomWin
,
169 lcl_MoveMapMode( aMapMode
, Size( 0, aWinSize
.Height() ) ) );
171 lcl_DrawWin( pObject
, pDiagWin
, lcl_MoveMapMode( aMapMode
, aWinSize
) );
176 void ScNoteMarker::InvalidateWin()
180 pWindow
->Invalidate( pWindow
->LogicToLogic(aRect
, aMapMode
, pWindow
->GetMapMode()) );
182 if ( pRightWin
|| pBottomWin
)
184 Size aWinSize
= pWindow
->PixelToLogic( pWindow
->GetOutputSizePixel(), aMapMode
);
186 pRightWin
->Invalidate( pRightWin
->LogicToLogic(aRect
,
187 lcl_MoveMapMode( aMapMode
, Size( aWinSize
.Width(), 0 ) ),
188 pRightWin
->GetMapMode()) );
190 pBottomWin
->Invalidate( pBottomWin
->LogicToLogic(aRect
,
191 lcl_MoveMapMode( aMapMode
, Size( 0, aWinSize
.Height() ) ),
192 pBottomWin
->GetMapMode()) );
194 pDiagWin
->Invalidate( pDiagWin
->LogicToLogic(aRect
,
195 lcl_MoveMapMode( aMapMode
, aWinSize
),
196 pDiagWin
->GetMapMode()) );