1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/svdoutl.hxx>
22 #include <svx/svdmodel.hxx>
23 #include <svx/svdpage.hxx>
24 #include <svx/svdocapt.hxx>
25 #include <sfx2/printer.hxx>
26 #include <unotools/pathoptions.hxx>
27 #include <svl/itempool.hxx>
28 #include <vcl/svapp.hxx>
29 #include <vcl/settings.hxx>
31 #include "notemark.hxx"
32 #include "document.hxx"
35 #define SC_NOTEMARK_TIME 800
36 #define SC_NOTEMARK_SHORT 70
38 ScNoteMarker::ScNoteMarker( Window
* pWin
, Window
* pRight
, Window
* pBottom
, Window
* pDiagonal
,
39 ScDocument
* pD
, ScAddress aPos
, const OUString
& rUser
,
40 const MapMode
& rMap
, bool bLeftEdge
, bool bForce
, bool bKeyboard
) :
43 pBottomWin( pBottom
),
44 pDiagWin( pDiagonal
),
50 bByKeyboard( bKeyboard
),
55 Size aSizePixel
= pWindow
->GetOutputSizePixel();
57 aSizePixel
.Width() += pRightWin
->GetOutputSizePixel().Width();
59 aSizePixel
.Height() += pBottomWin
->GetOutputSizePixel().Height();
60 Rectangle
aVisPixel( Point( 0, 0 ), aSizePixel
);
61 aVisRect
= pWindow
->PixelToLogic( aVisPixel
, aMapMode
);
63 aTimer
.SetTimeoutHdl( LINK( this, ScNoteMarker
, TimeHdl
) );
64 aTimer
.SetTimeout( bForce
? SC_NOTEMARK_SHORT
: SC_NOTEMARK_TIME
);
68 ScNoteMarker::~ScNoteMarker()
75 IMPL_LINK_NOARG(ScNoteMarker
, TimeHdl
)
79 SvtPathOptions aPathOpt
;
80 OUString aPath
= aPathOpt
.GetPalettePath();
81 pModel
= new SdrModel(aPath
, NULL
, NULL
, false, false);
82 pModel
->SetScaleUnit(MAP_100TH_MM
);
83 SfxItemPool
& rPool
= pModel
->GetItemPool();
84 rPool
.SetDefaultMetric(SFX_MAPUNIT_100TH_MM
);
85 rPool
.FreezeIdRanges();
87 OutputDevice
* pPrinter
= pDoc
->GetRefDevice();
90 // Am Outliner des Draw-Model ist auch der Drucker als RefDevice gesetzt,
91 // und es soll einheitlich aussehen.
92 Outliner
& rOutliner
= pModel
->GetDrawOutliner();
93 rOutliner
.SetRefDevice(pPrinter
);
96 if( SdrPage
* pPage
= pModel
->AllocPage( false ) )
98 pObject
= ScNoteUtil::CreateTempCaption( *pDoc
, aDocPos
, *pPage
, aUserText
, aVisRect
, bLeft
);
101 pObject
->SetGridOffset( aGridOff
);
102 aRect
= pObject
->GetCurrentBoundRect();
105 // Page einfuegen damit das Model sie kennt und auch deleted
106 pModel
->InsertPage( pPage
);
116 static void lcl_DrawWin( SdrObject
* pObject
, Window
* pWindow
, const MapMode
& rMap
)
118 MapMode aOld
= pWindow
->GetMapMode();
119 pWindow
->SetMapMode( rMap
);
121 sal_uLong nOldDrawMode
= pWindow
->GetDrawMode();
122 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
124 pWindow
->SetDrawMode( nOldDrawMode
| DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
|
125 DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
);
128 pObject
->SingleObjectPainter( *pWindow
); // #110094#-17
130 pWindow
->SetDrawMode( nOldDrawMode
);
131 pWindow
->SetMapMode( aOld
);
134 static MapMode
lcl_MoveMapMode( const MapMode
& rMap
, const Size
& rMove
)
137 Point aOrigin
= aNew
.GetOrigin();
138 aOrigin
.X() -= rMove
.Width();
139 aOrigin
.Y() -= rMove
.Height();
140 aNew
.SetOrigin(aOrigin
);
144 void ScNoteMarker::Draw()
146 if ( pObject
&& bVisible
)
148 lcl_DrawWin( pObject
, pWindow
, aMapMode
);
150 if ( pRightWin
|| pBottomWin
)
152 Size aWinSize
= pWindow
->PixelToLogic( pWindow
->GetOutputSizePixel(), aMapMode
);
154 lcl_DrawWin( pObject
, pRightWin
,
155 lcl_MoveMapMode( aMapMode
, Size( aWinSize
.Width(), 0 ) ) );
157 lcl_DrawWin( pObject
, pBottomWin
,
158 lcl_MoveMapMode( aMapMode
, Size( 0, aWinSize
.Height() ) ) );
160 lcl_DrawWin( pObject
, pDiagWin
, lcl_MoveMapMode( aMapMode
, aWinSize
) );
165 void ScNoteMarker::InvalidateWin()
169 pWindow
->Invalidate( pWindow
->LogicToLogic(aRect
, aMapMode
, pWindow
->GetMapMode()) );
171 if ( pRightWin
|| pBottomWin
)
173 Size aWinSize
= pWindow
->PixelToLogic( pWindow
->GetOutputSizePixel(), aMapMode
);
175 pRightWin
->Invalidate( pRightWin
->LogicToLogic(aRect
,
176 lcl_MoveMapMode( aMapMode
, Size( aWinSize
.Width(), 0 ) ),
177 pRightWin
->GetMapMode()) );
179 pBottomWin
->Invalidate( pBottomWin
->LogicToLogic(aRect
,
180 lcl_MoveMapMode( aMapMode
, Size( 0, aWinSize
.Height() ) ),
181 pBottomWin
->GetMapMode()) );
183 pDiagWin
->Invalidate( pDiagWin
->LogicToLogic(aRect
,
184 lcl_MoveMapMode( aMapMode
, aWinSize
),
185 pDiagWin
->GetMapMode()) );
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */