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>
30 #include "notemark.hxx"
31 #include "document.hxx"
34 #define SC_NOTEMARK_TIME 800
35 #define SC_NOTEMARK_SHORT 70
37 // -----------------------------------------------------------------------
39 ScNoteMarker::ScNoteMarker( Window
* pWin
, Window
* pRight
, Window
* pBottom
, Window
* pDiagonal
,
40 ScDocument
* pD
, ScAddress aPos
, const String
& rUser
,
41 const MapMode
& rMap
, sal_Bool bLeftEdge
, sal_Bool bForce
, sal_Bool bKeyboard
) :
44 pBottomWin( pBottom
),
45 pDiagWin( pDiagonal
),
51 bByKeyboard( bKeyboard
),
56 Size aSizePixel
= pWindow
->GetOutputSizePixel();
58 aSizePixel
.Width() += pRightWin
->GetOutputSizePixel().Width();
60 aSizePixel
.Height() += pBottomWin
->GetOutputSizePixel().Height();
61 Rectangle
aVisPixel( Point( 0, 0 ), aSizePixel
);
62 aVisRect
= pWindow
->PixelToLogic( aVisPixel
, aMapMode
);
64 aTimer
.SetTimeoutHdl( LINK( this, ScNoteMarker
, TimeHdl
) );
65 aTimer
.SetTimeout( bForce
? SC_NOTEMARK_SHORT
: SC_NOTEMARK_TIME
);
69 ScNoteMarker::~ScNoteMarker()
76 IMPL_LINK_NOARG(ScNoteMarker
, TimeHdl
)
80 SvtPathOptions aPathOpt
;
81 String aPath
= aPathOpt
.GetPalettePath();
82 pModel
= new SdrModel(aPath
);
83 pModel
->SetScaleUnit(MAP_100TH_MM
);
84 SfxItemPool
& rPool
= pModel
->GetItemPool();
85 rPool
.SetDefaultMetric(SFX_MAPUNIT_100TH_MM
);
86 rPool
.FreezeIdRanges();
88 OutputDevice
* pPrinter
= pDoc
->GetRefDevice();
91 // Am Outliner des Draw-Model ist auch der Drucker als RefDevice gesetzt,
92 // und es soll einheitlich aussehen.
93 Outliner
& rOutliner
= pModel
->GetDrawOutliner();
94 rOutliner
.SetRefDevice(pPrinter
);
97 if( SdrPage
* pPage
= pModel
->AllocPage( false ) )
99 pObject
= ScNoteUtil::CreateTempCaption( *pDoc
, aDocPos
, *pPage
, aUserText
, aVisRect
, bLeft
);
102 pObject
->SetGridOffset( aGridOff
);
103 aRect
= pObject
->GetCurrentBoundRect();
106 // Page einfuegen damit das Model sie kennt und auch deleted
107 pModel
->InsertPage( pPage
);
117 static void lcl_DrawWin( SdrObject
* pObject
, Window
* pWindow
, const MapMode
& rMap
)
119 MapMode aOld
= pWindow
->GetMapMode();
120 pWindow
->SetMapMode( rMap
);
122 sal_uLong nOldDrawMode
= pWindow
->GetDrawMode();
123 if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
125 pWindow
->SetDrawMode( nOldDrawMode
| DRAWMODE_SETTINGSLINE
| DRAWMODE_SETTINGSFILL
|
126 DRAWMODE_SETTINGSTEXT
| DRAWMODE_SETTINGSGRADIENT
);
129 pObject
->SingleObjectPainter( *pWindow
); // #110094#-17
131 pWindow
->SetDrawMode( nOldDrawMode
);
132 pWindow
->SetMapMode( aOld
);
135 static MapMode
lcl_MoveMapMode( const MapMode
& rMap
, const Size
& rMove
)
138 Point aOrigin
= aNew
.GetOrigin();
139 aOrigin
.X() -= rMove
.Width();
140 aOrigin
.Y() -= rMove
.Height();
141 aNew
.SetOrigin(aOrigin
);
145 void ScNoteMarker::Draw()
147 if ( pObject
&& bVisible
)
149 lcl_DrawWin( pObject
, pWindow
, aMapMode
);
151 if ( pRightWin
|| pBottomWin
)
153 Size aWinSize
= pWindow
->PixelToLogic( pWindow
->GetOutputSizePixel(), aMapMode
);
155 lcl_DrawWin( pObject
, pRightWin
,
156 lcl_MoveMapMode( aMapMode
, Size( aWinSize
.Width(), 0 ) ) );
158 lcl_DrawWin( pObject
, pBottomWin
,
159 lcl_MoveMapMode( aMapMode
, Size( 0, aWinSize
.Height() ) ) );
161 lcl_DrawWin( pObject
, pDiagWin
, lcl_MoveMapMode( aMapMode
, aWinSize
) );
166 void ScNoteMarker::InvalidateWin()
170 pWindow
->Invalidate( pWindow
->LogicToLogic(aRect
, aMapMode
, pWindow
->GetMapMode()) );
172 if ( pRightWin
|| pBottomWin
)
174 Size aWinSize
= pWindow
->PixelToLogic( pWindow
->GetOutputSizePixel(), aMapMode
);
176 pRightWin
->Invalidate( pRightWin
->LogicToLogic(aRect
,
177 lcl_MoveMapMode( aMapMode
, Size( aWinSize
.Width(), 0 ) ),
178 pRightWin
->GetMapMode()) );
180 pBottomWin
->Invalidate( pBottomWin
->LogicToLogic(aRect
,
181 lcl_MoveMapMode( aMapMode
, Size( 0, aWinSize
.Height() ) ),
182 pBottomWin
->GetMapMode()) );
184 pDiagWin
->Invalidate( pDiagWin
->LogicToLogic(aRect
,
185 lcl_MoveMapMode( aMapMode
, aWinSize
),
186 pDiagWin
->GetMapMode()) );
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */