2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2008-04-03 13:08:34 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 08:56:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2008-04-03 13:08:34 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2008-04-03 13:08:34 +00:00
|
|
|
*
|
2008-04-11 08:56:00 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2008-04-03 13:08:34 +00:00
|
|
|
*
|
2008-04-11 08:56:00 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2008-04-03 13:08:34 +00:00
|
|
|
*
|
2008-04-11 08:56:00 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2008-04-03 13:08:34 +00:00
|
|
|
*
|
2008-04-11 08:56:00 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2008-04-03 13:08:34 +00:00
|
|
|
*
|
2008-04-11 08:56:00 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2008-04-03 13:08:34 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "PresenterTextView.hxx"
|
|
|
|
|
2009-09-17 11:26:03 +00:00
|
|
|
#include <i18npool/mslangid.hxx>
|
2008-04-03 13:08:34 +00:00
|
|
|
#include <cppcanvas/vclfactory.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/itempool.hxx>
|
|
|
|
#include <svl/itemset.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/linguprops.hxx>
|
|
|
|
#include <unotools/lingucfg.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/colritem.hxx>
|
|
|
|
#include <editeng/editeng.hxx>
|
|
|
|
#include <editeng/editstat.hxx>
|
|
|
|
#include <editeng/eeitem.hxx>
|
|
|
|
#include <editeng/fhgtitem.hxx>
|
|
|
|
#include <editeng/fontitem.hxx>
|
2008-04-03 13:08:34 +00:00
|
|
|
#include <svx/xflclit.hxx>
|
|
|
|
#include <vcl/bitmapex.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/virdev.hxx>
|
|
|
|
#include <com/sun/star/awt/FontDescriptor.hpp>
|
|
|
|
#include <com/sun/star/awt/Size.hpp>
|
|
|
|
#include <com/sun/star/rendering/XSpriteCanvas.hpp>
|
|
|
|
#include <com/sun/star/util/Color.hpp>
|
2009-09-17 11:26:03 +00:00
|
|
|
#include <com/sun/star/i18n/ScriptType.hpp>
|
|
|
|
|
2008-04-03 13:08:34 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using ::rtl::OUString;
|
|
|
|
|
|
|
|
namespace sd { namespace presenter {
|
|
|
|
|
|
|
|
//===== Service ===============================================================
|
|
|
|
|
|
|
|
Reference<XInterface> SAL_CALL PresenterTextViewService_createInstance (
|
|
|
|
const Reference<XComponentContext>& rxContext)
|
|
|
|
{
|
|
|
|
return Reference<XInterface>(static_cast<XWeak*>(new PresenterTextView(rxContext)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
::rtl::OUString PresenterTextViewService_getImplementationName (void) throw(RuntimeException)
|
|
|
|
{
|
2012-04-13 14:40:10 -03:00
|
|
|
return OUString("com.sun.star.comp.Draw.PresenterTextView");
|
2008-04-03 13:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sequence<rtl::OUString> SAL_CALL PresenterTextViewService_getSupportedServiceNames (void)
|
|
|
|
throw (RuntimeException)
|
|
|
|
{
|
2012-04-13 14:40:10 -03:00
|
|
|
static const ::rtl::OUString sServiceName("com.sun.star.drawing.PresenterTextView");
|
2008-04-03 13:08:34 +00:00
|
|
|
return Sequence<rtl::OUString>(&sServiceName, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===== PresenterTextView::Implementation =====================================
|
|
|
|
|
|
|
|
class PresenterTextView::Implementation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
const OUString msTextPropertyName;
|
|
|
|
const OUString msBitmapPropertyName;
|
|
|
|
const OUString msSizePropertyName;
|
|
|
|
const OUString msBackgroundColorPropertyName;
|
|
|
|
const OUString msTextColorPropertyName;
|
|
|
|
const OUString msFontDescriptorPropertyName;
|
|
|
|
const OUString msTopPropertyName;
|
|
|
|
const OUString msTopRelativePropertyName;
|
|
|
|
const OUString msTotalHeightPropertyName;
|
|
|
|
|
|
|
|
Implementation (void);
|
|
|
|
~Implementation (void);
|
|
|
|
|
|
|
|
void SetCanvas (const cppcanvas::CanvasSharedPtr& rCanvas);
|
|
|
|
void SetSize (const Size aSize);
|
|
|
|
void SetBackgroundColor (const Color aColor);
|
|
|
|
void SetTextColor (const Color aColor);
|
|
|
|
void SetFontDescriptor (const awt::FontDescriptor& rFontDescriptor);
|
|
|
|
sal_Int32 GetTop (void) const;
|
|
|
|
void SetTop (const sal_Int32 nTop);
|
|
|
|
void SetText (const OUString& Text);
|
|
|
|
sal_Int32 ParseDistance (const OUString& rsDistance) const;
|
|
|
|
Reference<rendering::XBitmap> GetBitmap (void);
|
|
|
|
sal_Int32 GetTotalHeight (void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Reference<rendering::XBitmap> mxBitmap;
|
|
|
|
cppcanvas::CanvasSharedPtr mpCanvas;
|
|
|
|
VirtualDevice* mpOutputDevice;
|
|
|
|
EditEngine* mpEditEngine;
|
|
|
|
SfxItemPool* mpEditEngineItemPool;
|
|
|
|
Size maSize;
|
|
|
|
Color maBackgroundColor;
|
|
|
|
Color maTextColor;
|
|
|
|
String msText;
|
|
|
|
sal_Int32 mnTop;
|
|
|
|
sal_Int32 mnTotalHeight;
|
|
|
|
|
|
|
|
EditEngine * GetEditEngine (void);
|
|
|
|
EditEngine* CreateEditEngine (void);
|
|
|
|
void CheckTop (void);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===== PresenterTextView =====================================================
|
|
|
|
|
|
|
|
PresenterTextView::PresenterTextView (const Reference<XComponentContext>& rxContext)
|
|
|
|
: PresenterTextViewInterfaceBase(),
|
|
|
|
mpImplementation(new Implementation())
|
|
|
|
{
|
|
|
|
(void)rxContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PresenterTextView::~PresenterTextView (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SAL_CALL PresenterTextView::disposing (void)
|
|
|
|
{
|
|
|
|
mpImplementation.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----- XInitialization -------------------------------------------------------
|
|
|
|
|
|
|
|
void SAL_CALL PresenterTextView::initialize (const Sequence<Any>& rArguments)
|
|
|
|
throw (Exception, RuntimeException)
|
|
|
|
{
|
|
|
|
ThrowIfDisposed();
|
|
|
|
|
|
|
|
if (rArguments.getLength() == 1)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference<rendering::XBitmapCanvas> xCanvas (rArguments[0], UNO_QUERY_THROW);
|
|
|
|
if (xCanvas.is())
|
|
|
|
{
|
|
|
|
mpImplementation->SetCanvas(
|
|
|
|
cppcanvas::VCLFactory::getInstance().createCanvas(xCanvas));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (RuntimeException&)
|
|
|
|
{
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-04-13 14:40:10 -03:00
|
|
|
throw RuntimeException("PresenterTextView: invalid number of arguments",
|
2008-04-03 13:08:34 +00:00
|
|
|
static_cast<XWeak*>(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Any PresenterTextView::GetPropertyValue (const OUString& rsPropertyName)
|
|
|
|
{
|
|
|
|
ThrowIfDisposed();
|
|
|
|
|
|
|
|
if (rsPropertyName == mpImplementation->msBitmapPropertyName)
|
|
|
|
{
|
|
|
|
return Any(mpImplementation->GetBitmap());
|
|
|
|
}
|
|
|
|
else if (rsPropertyName == mpImplementation->msTopPropertyName)
|
|
|
|
{
|
|
|
|
return Any(mpImplementation->GetTop());
|
|
|
|
}
|
|
|
|
else if (rsPropertyName == mpImplementation->msTotalHeightPropertyName)
|
|
|
|
{
|
|
|
|
return Any(mpImplementation->GetTotalHeight());
|
|
|
|
}
|
|
|
|
|
|
|
|
return Any();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Any PresenterTextView::SetPropertyValue (
|
|
|
|
const ::rtl::OUString& rsPropertyName,
|
|
|
|
const css::uno::Any& rValue)
|
|
|
|
{
|
|
|
|
ThrowIfDisposed();
|
|
|
|
|
|
|
|
Any aOldValue;
|
|
|
|
if (rsPropertyName == mpImplementation->msTextPropertyName)
|
|
|
|
{
|
|
|
|
OUString sText;
|
|
|
|
if (rValue >>= sText)
|
|
|
|
mpImplementation->SetText(sText);
|
|
|
|
}
|
|
|
|
else if (rsPropertyName == mpImplementation->msSizePropertyName)
|
|
|
|
{
|
|
|
|
awt::Size aSize;
|
|
|
|
if (rValue >>= aSize)
|
|
|
|
mpImplementation->SetSize(Size(aSize.Width,aSize.Height));
|
|
|
|
}
|
|
|
|
else if (rsPropertyName == mpImplementation->msBackgroundColorPropertyName)
|
|
|
|
{
|
2008-04-07 12:02:58 +00:00
|
|
|
util::Color aColor = util::Color();
|
2008-04-03 13:08:34 +00:00
|
|
|
if (rValue >>= aColor)
|
|
|
|
mpImplementation->SetBackgroundColor(Color(aColor));
|
|
|
|
}
|
|
|
|
else if (rsPropertyName == mpImplementation->msTextColorPropertyName)
|
|
|
|
{
|
2008-04-07 12:02:58 +00:00
|
|
|
util::Color aColor = util::Color();
|
2008-04-03 13:08:34 +00:00
|
|
|
if (rValue >>= aColor)
|
|
|
|
mpImplementation->SetTextColor(Color(aColor));
|
|
|
|
}
|
|
|
|
else if (rsPropertyName == mpImplementation->msFontDescriptorPropertyName)
|
|
|
|
{
|
|
|
|
awt::FontDescriptor aFontDescriptor;
|
|
|
|
if (rValue >>= aFontDescriptor)
|
|
|
|
mpImplementation->SetFontDescriptor(aFontDescriptor);
|
|
|
|
}
|
|
|
|
else if (rsPropertyName == mpImplementation->msTopPropertyName)
|
|
|
|
{
|
2008-04-07 12:02:58 +00:00
|
|
|
sal_Int32 nTop = 0;
|
2008-04-03 13:08:34 +00:00
|
|
|
if (rValue >>= nTop)
|
|
|
|
mpImplementation->SetTop(nTop);
|
|
|
|
}
|
|
|
|
else if (rsPropertyName == mpImplementation->msTopRelativePropertyName)
|
|
|
|
{
|
|
|
|
OUString sDistance;
|
|
|
|
if (rValue >>= sDistance)
|
|
|
|
mpImplementation->SetTop(
|
|
|
|
mpImplementation->GetTop()
|
|
|
|
+ mpImplementation->ParseDistance(sDistance));
|
|
|
|
}
|
|
|
|
return aOldValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::ThrowIfDisposed (void)
|
|
|
|
throw (::com::sun::star::lang::DisposedException)
|
|
|
|
{
|
|
|
|
if (PresenterTextViewInterfaceBase::rBHelper.bDisposed
|
|
|
|
|| PresenterTextViewInterfaceBase::rBHelper.bInDispose
|
|
|
|
|| mpImplementation.get()==NULL)
|
|
|
|
{
|
2012-04-13 14:40:10 -03:00
|
|
|
throw lang::DisposedException ("PresenterTextView object has already been disposed",
|
2008-04-03 13:08:34 +00:00
|
|
|
static_cast<uno::XWeak*>(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===== PresenterTextView::Implementation =====================================
|
|
|
|
|
|
|
|
PresenterTextView::Implementation::Implementation (void)
|
2012-04-13 14:40:10 -03:00
|
|
|
: msTextPropertyName("Text"),
|
|
|
|
msBitmapPropertyName("Bitmap"),
|
|
|
|
msSizePropertyName("Size"),
|
|
|
|
msBackgroundColorPropertyName("BackgroundColor"),
|
|
|
|
msTextColorPropertyName("TextColor"),
|
|
|
|
msFontDescriptorPropertyName("FontDescriptor"),
|
|
|
|
msTopPropertyName("Top"),
|
|
|
|
msTopRelativePropertyName("RelativeTop"),
|
|
|
|
msTotalHeightPropertyName("TotalHeight"),
|
2008-04-03 13:08:34 +00:00
|
|
|
mxBitmap(),
|
|
|
|
mpCanvas(),
|
|
|
|
mpOutputDevice(new VirtualDevice(*Application::GetDefaultDevice(), 0, 0)),
|
|
|
|
mpEditEngine(NULL),
|
|
|
|
mpEditEngineItemPool(EditEngine::CreatePool()),
|
|
|
|
maSize(100,100),
|
|
|
|
maBackgroundColor(0xffffffff),
|
|
|
|
maTextColor(0x00000000),
|
|
|
|
msText(),
|
|
|
|
mnTop(0),
|
|
|
|
mnTotalHeight(-1)
|
|
|
|
{
|
|
|
|
mpOutputDevice->SetMapMode(MAP_PIXEL);
|
|
|
|
|
|
|
|
GetEditEngine();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PresenterTextView::Implementation::~Implementation (void)
|
|
|
|
{
|
|
|
|
delete mpEditEngine;
|
CWS-TOOLING: integrate CWS aw063
2009-02-12 13:10:24 +0100 aw r267649 : #i99123# when a primitive is invisible, it is not sufficient to produce no output when decomposing, but to add invisible data using HitTestPrimitive2D. This is needed for the slideshow which relies on geometry data in MetaFiles when painting invisible objects
2009-02-12 13:08:39 +0100 aw r267648 : #i99123# do not ignore HitTestPrimitive2D, but draw empty rectangles instead. This is needed since Slideshow is based on getting MetaFile content when painting invisible objects
2009-02-11 16:04:28 +0100 aw r267620 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:04:10 +0100 aw r267619 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:56 +0100 aw r267618 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:39 +0100 aw r267617 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:03:21 +0100 aw r267615 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:48 +0100 aw r267614 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:24 +0100 aw r267613 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:02:01 +0100 aw r267612 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:01:32 +0100 aw r267611 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:01:05 +0100 aw r267610 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 16:00:15 +0100 aw r267608 : #i98788# made SfxItemPool destructor protected, added static ::Free method
2009-02-11 11:27:33 +0100 aw r267585 : #i98788# added missing include for STL
2009-02-10 17:46:50 +0100 aw r267570 : #i98788# added reaction on pool destruction
2009-02-10 17:11:58 +0100 aw r267562 : #i98788# added messaging mechanism to register for pool destruction
2009-02-10 13:35:35 +0100 aw r267549 : #i98788# removing changes, too complicated and risky for 3.1
2009-02-10 12:13:48 +0100 aw r267546 : #i98788# 4th round
2009-02-10 12:13:37 +0100 aw r267545 : #i98788# 4th round
2009-02-10 12:13:26 +0100 aw r267544 : #i98788# 4th round
2009-02-10 12:13:14 +0100 aw r267543 : #i98788# 4th round
2009-02-10 12:13:03 +0100 aw r267542 : #i98788# 4th round
2009-02-10 12:12:50 +0100 aw r267541 : #i98788# 4th round
2009-02-10 12:12:37 +0100 aw r267540 : #i98788# 4th round
2009-02-08 14:38:22 +0100 aw r267495 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:38:06 +0100 aw r267494 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:37:48 +0100 aw r267493 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:37:17 +0100 aw r267492 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:56 +0100 aw r267491 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:44 +0100 aw r267490 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:29 +0100 aw r267489 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:16 +0100 aw r267488 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:36:02 +0100 aw r267487 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-08 14:35:46 +0100 aw r267486 : #i98788# 3rd round of changes to SfxItemPool handling
2009-02-05 12:20:39 +0100 aw r267415 : #i98788# 2nd batch of adaptions for SfxItemPoolHolder addition
2009-02-04 15:12:54 +0100 aw r267385 : #i98788# added newline at EOF
2009-02-04 13:26:04 +0100 aw r267379 : #i98788# make SfxItemPool holdable
2009-02-04 13:25:40 +0100 aw r267378 : #i98788# make SfxItemPool holdable
2009-02-04 13:25:08 +0100 aw r267377 : #i98788# make SfxItemPool holdable
2009-02-04 13:24:42 +0100 aw r267376 : #i98788# make SfxItemPool holdable
2009-02-04 13:23:14 +0100 aw r267375 : #i98788# make SfxItemPool holdable
2009-02-04 13:23:02 +0100 aw r267374 : #i98788# make SfxItemPool holdable
2009-01-29 17:08:31 +0100 aw r267159 : #i97628# completed the fix
2009-01-29 17:08:15 +0100 aw r267158 : #i97628# completed the fix
2009-01-29 14:09:07 +0100 aw r267132 : #i97628# Corrected usage of ParagraphData in headers
2009-01-29 14:06:58 +0100 iha r267131 : #i98344# incorrect font size in charts
2009-01-29 12:13:46 +0100 aw r267115 : #i97628# back to old state; triggers too many errors in other modules
2009-01-29 12:03:51 +0100 aw r267114 : #i97628# enabled exceptions due to STL vector include
2009-01-29 11:21:37 +0100 aw r267107 : #i97628# added needed include
2009-01-28 17:58:29 +0100 aw r267077 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:58:12 +0100 aw r267076 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:57:51 +0100 aw r267074 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-28 17:57:21 +0100 aw r267073 : #i97628# first version of newly implemented OutlinerParaObject and adaptions
2009-01-27 17:07:33 +0100 aw r267011 : #i98402# added support for ViewRange when exporting MetaFiles in ObjectContactOfPageView::DoProcessDisplay to avoid to paint too much
2009-01-27 11:45:48 +0100 aw r266973 : #i98404# Added a warning to a place where a conversion to rectangle should not be copied from
2009-01-26 21:44:36 +0100 iha r266949 : #i98497# 3D charts are rendered with wrong size
2009-01-26 20:47:07 +0100 aw r266947 : #i98404# handle BackgroundColorPrimitive2D directly in PixelRenderers and avoid AA under all circumstances
2009-01-26 14:50:36 +0100 aw r266926 : #i98386# secured cloning of SdrObject in IMapUserData by boost::shared_prt usage
2009-01-26 12:51:30 +0100 aw r266916 : #i96581# added separated FontStretching and fallback for small X!=Y scale differences
2009-01-23 16:14:55 +0100 aw r266834 : #i96475# added missing implementation of TextDecoratedPortionPrimitive2D::getB2DRange
2009-01-23 15:24:34 +0100 aw r266826 : #i98405# fixed fallback to DrawAlphaRect to use the correctly sized rectangle
2009-01-23 13:34:43 +0100 aw r266813 : #i96474# fixed impSplitSingleWords for an unexpected case
2009-01-23 10:47:31 +0100 aw r266786 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:47:20 +0100 aw r266785 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:47:09 +0100 aw r266783 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:46:58 +0100 aw r266782 : #i98289#,#i96474# tooling and new flags for tasks
2009-01-23 10:46:48 +0100 aw r266781 : #i98289#,#i96474# tooling and new flags for tasks
2009-03-04 14:16:02 +00:00
|
|
|
SfxItemPool::Free(mpEditEngineItemPool);
|
2008-04-03 13:08:34 +00:00
|
|
|
delete mpOutputDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EditEngine * PresenterTextView::Implementation::GetEditEngine (void)
|
|
|
|
{
|
|
|
|
if (mpEditEngine == NULL)
|
|
|
|
mpEditEngine = CreateEditEngine ();
|
|
|
|
return mpEditEngine;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EditEngine* PresenterTextView::Implementation::CreateEditEngine (void)
|
|
|
|
{
|
|
|
|
EditEngine* pEditEngine = mpEditEngine;
|
|
|
|
if (pEditEngine == NULL)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// set fonts to be used
|
|
|
|
//
|
|
|
|
SvtLinguOptions aOpt;
|
|
|
|
SvtLinguConfig().GetOptions( aOpt );
|
2010-11-20 17:34:37 +00:00
|
|
|
|
2008-04-03 13:08:34 +00:00
|
|
|
struct FontDta {
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_Int16 nFallbackLang;
|
|
|
|
sal_Int16 nLang;
|
|
|
|
sal_uInt16 nFontType;
|
|
|
|
sal_uInt16 nFontInfoId;
|
2008-04-03 13:08:34 +00:00
|
|
|
} aTable[3] =
|
|
|
|
{
|
|
|
|
// info to get western font to be used
|
|
|
|
{ LANGUAGE_ENGLISH_US, LANGUAGE_NONE,
|
|
|
|
DEFAULTFONT_SERIF, EE_CHAR_FONTINFO },
|
|
|
|
// info to get CJK font to be used
|
|
|
|
{ LANGUAGE_JAPANESE, LANGUAGE_NONE,
|
|
|
|
DEFAULTFONT_CJK_TEXT, EE_CHAR_FONTINFO_CJK },
|
|
|
|
// info to get CTL font to be used
|
2009-01-06 12:54:16 +00:00
|
|
|
{ LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE,
|
2008-04-03 13:08:34 +00:00
|
|
|
DEFAULTFONT_CTL_TEXT, EE_CHAR_FONTINFO_CTL }
|
|
|
|
};
|
2009-09-17 11:26:03 +00:00
|
|
|
aTable[0].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
|
|
|
|
aTable[1].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
|
|
|
|
aTable[2].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
|
2010-11-20 17:34:37 +00:00
|
|
|
|
2008-04-03 13:08:34 +00:00
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
|
|
|
const FontDta &rFntDta = aTable[i];
|
|
|
|
LanguageType nLang = (LANGUAGE_NONE == rFntDta.nLang) ?
|
|
|
|
rFntDta.nFallbackLang : rFntDta.nLang;
|
|
|
|
Font aFont = Application::GetDefaultDevice()->GetDefaultFont(
|
|
|
|
rFntDta.nFontType, nLang, DEFAULTFONT_FLAGS_ONLYONE);
|
|
|
|
mpEditEngineItemPool->SetPoolDefaultItem(
|
|
|
|
SvxFontItem(
|
|
|
|
aFont.GetFamily(),
|
|
|
|
aFont.GetName(),
|
|
|
|
aFont.GetStyleName(),
|
|
|
|
aFont.GetPitch(),
|
|
|
|
aFont.GetCharSet(),
|
|
|
|
rFntDta.nFontInfoId));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pEditEngine = new EditEngine (mpEditEngineItemPool);
|
|
|
|
|
2011-01-17 11:41:00 +01:00
|
|
|
pEditEngine->EnableUndo (sal_True);
|
|
|
|
pEditEngine->SetDefTab (sal_uInt16(
|
2012-04-15 22:05:11 -03:00
|
|
|
Application::GetDefaultDevice()->GetTextWidth(rtl::OUString("XXXX"))));
|
2008-04-03 13:08:34 +00:00
|
|
|
|
|
|
|
pEditEngine->SetControlWord(
|
|
|
|
(pEditEngine->GetControlWord()
|
|
|
|
| EE_CNTRL_AUTOINDENTING) &
|
|
|
|
(~EE_CNTRL_UNDOATTRIBS) &
|
|
|
|
(~EE_CNTRL_PASTESPECIAL));
|
|
|
|
|
2012-04-15 22:05:11 -03:00
|
|
|
pEditEngine->SetWordDelimiters (rtl::OUString(" .=+-*/(){}[];\""));
|
2008-04-03 13:08:34 +00:00
|
|
|
pEditEngine->SetRefMapMode (MAP_PIXEL);
|
|
|
|
pEditEngine->SetPaperSize (Size(800, 0));
|
|
|
|
pEditEngine->EraseVirtualDevice();
|
|
|
|
pEditEngine->ClearModifyFlag();
|
|
|
|
}
|
|
|
|
|
|
|
|
return pEditEngine;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::Implementation::SetCanvas (const cppcanvas::CanvasSharedPtr& rpCanvas)
|
|
|
|
{
|
|
|
|
mpCanvas = rpCanvas;
|
|
|
|
mxBitmap = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::Implementation::SetSize (const Size aSize)
|
|
|
|
{
|
|
|
|
DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
|
|
|
|
|
|
|
|
maSize = aSize;
|
|
|
|
mpEditEngine->SetPaperSize(maSize);
|
|
|
|
mnTotalHeight = -1;
|
|
|
|
mxBitmap = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::Implementation::SetBackgroundColor (const Color aColor)
|
|
|
|
{
|
|
|
|
maBackgroundColor = aColor;
|
|
|
|
mxBitmap = NULL;
|
|
|
|
|
|
|
|
DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
|
|
|
|
DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
|
|
|
|
mpEditEngine->SetBackgroundColor(aColor);
|
2011-01-17 11:41:00 +01:00
|
|
|
mpEditEngine->EnableAutoColor(sal_False);
|
|
|
|
mpEditEngine->ForceAutoColor(sal_False);
|
2008-04-03 13:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::Implementation::SetTextColor (const Color aColor)
|
|
|
|
{
|
|
|
|
maTextColor = aColor;
|
|
|
|
mxBitmap = NULL;
|
|
|
|
|
|
|
|
DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
|
|
|
|
mpEditEngineItemPool->SetPoolDefaultItem(SvxColorItem(aColor, EE_CHAR_COLOR));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::Implementation::SetFontDescriptor (
|
|
|
|
const awt::FontDescriptor& rFontDescriptor)
|
|
|
|
{
|
|
|
|
mxBitmap = NULL;
|
|
|
|
|
|
|
|
DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
|
|
|
|
|
|
|
|
const sal_Int32 nFontHeight = rFontDescriptor.Height;
|
|
|
|
|
|
|
|
SvxFontHeightItem aFontHeight(
|
|
|
|
Application::GetDefaultDevice()->LogicToPixel(
|
|
|
|
Size(0, nFontHeight), MapMode (MAP_POINT)).Height(),
|
|
|
|
100,
|
|
|
|
EE_CHAR_FONTHEIGHT);
|
|
|
|
mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
|
|
|
|
aFontHeight.SetWhich (EE_CHAR_FONTHEIGHT_CJK);
|
|
|
|
mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
|
|
|
|
aFontHeight.SetWhich (EE_CHAR_FONTHEIGHT_CTL);
|
|
|
|
mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
|
|
|
|
|
|
|
|
SvxFontItem aSvxFontItem (EE_CHAR_FONTINFO);
|
2011-02-18 10:06:26 +01:00
|
|
|
aSvxFontItem.SetFamilyName( rFontDescriptor.Name );
|
2008-04-03 13:08:34 +00:00
|
|
|
mpEditEngineItemPool->SetPoolDefaultItem(aSvxFontItem);
|
|
|
|
|
|
|
|
mnTotalHeight = -1;
|
|
|
|
mxBitmap = NULL;
|
|
|
|
|
|
|
|
CheckTop();
|
2008-07-11 12:37:02 +00:00
|
|
|
mnTotalHeight = -1;
|
2008-04-03 13:08:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 PresenterTextView::Implementation::GetTop (void) const
|
|
|
|
{
|
|
|
|
return mnTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::Implementation::SetTop (const sal_Int32 nTop)
|
|
|
|
{
|
|
|
|
if (nTop == mnTop)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mnTop = nTop;
|
|
|
|
mxBitmap = NULL;
|
|
|
|
CheckTop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::Implementation::SetText (const OUString& rText)
|
|
|
|
{
|
|
|
|
DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
|
|
|
|
msText = rText;
|
|
|
|
mpEditEngine->SetPaperSize(maSize);
|
|
|
|
mnTotalHeight = -1;
|
|
|
|
mxBitmap = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 PresenterTextView::Implementation::ParseDistance (const OUString& rsDistance) const
|
|
|
|
{
|
|
|
|
DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
|
|
|
|
sal_Int32 nDistance (0);
|
|
|
|
if (rsDistance.endsWithAsciiL("px", 2))
|
|
|
|
{
|
|
|
|
nDistance = rsDistance.copy(0,rsDistance.getLength()-2).toInt32();
|
|
|
|
}
|
|
|
|
else if (rsDistance.endsWithAsciiL("l", 1))
|
|
|
|
{
|
|
|
|
const sal_Int32 nLines (rsDistance.copy(0,rsDistance.getLength()-1).toInt32());
|
|
|
|
// Take the height of the first line as the height of every line.
|
|
|
|
const sal_uInt32 nFirstLineHeight (mpEditEngine->GetLineHeight(0,0));
|
|
|
|
nDistance = nFirstLineHeight * nLines;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nDistance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Reference<rendering::XBitmap> PresenterTextView::Implementation::GetBitmap (void)
|
|
|
|
{
|
|
|
|
DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
|
|
|
|
|
|
|
|
if ( ! mxBitmap.is())
|
|
|
|
{
|
|
|
|
if (mpOutputDevice != NULL)
|
|
|
|
delete mpOutputDevice;
|
|
|
|
mpOutputDevice = new VirtualDevice(*Application::GetDefaultDevice(), 0, 0);
|
|
|
|
mpOutputDevice->SetMapMode(MAP_PIXEL);
|
2011-01-17 11:41:00 +01:00
|
|
|
mpOutputDevice->SetOutputSizePixel(maSize, sal_True);
|
2008-04-03 13:08:34 +00:00
|
|
|
mpOutputDevice->SetLineColor();
|
|
|
|
mpOutputDevice->SetFillColor();
|
|
|
|
mpOutputDevice->SetBackground(Wallpaper());
|
|
|
|
mpOutputDevice->Erase();
|
|
|
|
|
|
|
|
MapMode aMapMode (mpOutputDevice->GetMapMode());
|
|
|
|
aMapMode.SetOrigin(Point(0,0));
|
|
|
|
mpOutputDevice->SetMapMode(aMapMode);
|
|
|
|
const Rectangle aWindowBox (Point(0,0), maSize);
|
|
|
|
mpOutputDevice->DrawRect(aWindowBox);
|
|
|
|
|
|
|
|
mpEditEngine->Clear();
|
|
|
|
mpEditEngine->SetText(msText);
|
|
|
|
mpEditEngine->SetPaperSize(maSize);
|
|
|
|
|
|
|
|
mpEditEngine->Draw(mpOutputDevice, aWindowBox, Point(0,mnTop));
|
|
|
|
|
|
|
|
const BitmapEx aBitmap (mpOutputDevice->GetBitmapEx(Point(0,0), maSize));
|
|
|
|
mxBitmap = cppcanvas::VCLFactory::getInstance().createBitmap(
|
|
|
|
mpCanvas,
|
|
|
|
aBitmap
|
|
|
|
)->getUNOBitmap();
|
|
|
|
}
|
|
|
|
return mxBitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sal_Int32 PresenterTextView::Implementation::GetTotalHeight (void)
|
|
|
|
{
|
|
|
|
DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
|
|
|
|
|
|
|
|
if (mnTotalHeight < 0)
|
|
|
|
{
|
|
|
|
if ( ! mxBitmap.is())
|
|
|
|
GetBitmap();
|
|
|
|
mnTotalHeight = mpEditEngine->GetTextHeight();
|
|
|
|
}
|
|
|
|
return mnTotalHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void PresenterTextView::Implementation::CheckTop (void)
|
|
|
|
{
|
|
|
|
DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
|
|
|
|
|
|
|
|
if (mnTotalHeight < 0)
|
|
|
|
mnTotalHeight = mpEditEngine->GetTextHeight();
|
|
|
|
if (mpEditEngine!=NULL && mnTop >= mnTotalHeight)
|
|
|
|
mnTop = mnTotalHeight - mpEditEngine->GetLineHeight(0,0);
|
|
|
|
|
|
|
|
if (mnTotalHeight < maSize.Height())
|
|
|
|
mnTop = 0;
|
|
|
|
|
|
|
|
if (mnTotalHeight - mnTop < maSize.Height())
|
|
|
|
mnTop = mnTotalHeight - maSize.Height();
|
|
|
|
|
|
|
|
if (mnTop < 0)
|
|
|
|
mnTop = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} } // end of namespace ::sd::presenter
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|